2 * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
4 * Authors: Igor Grinberg <grinberg@compulab.co.il>
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/errno.h>
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/mem.h>
16 #include <asm/arch/sys_proto.h>
21 static u32 cl_omap3_smc911x_gpmc_net_config[GPMC_MAX_REG] = {
31 static void cl_omap3_smc911x_setup_net_chip_gmpc(int cs, u32 base_addr)
33 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
35 enable_gpmc_cs_config(cl_omap3_smc911x_gpmc_net_config,
36 &gpmc_cfg->cs[cs], base_addr, GPMC_SIZE_16M);
38 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
39 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
41 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
42 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
44 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
45 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
46 &ctrl_base->gpmc_nadv_ale);
49 #ifdef CONFIG_OMAP_GPIO
50 static int cl_omap3_smc911x_reset_net_chip(int gpio)
54 if (!gpio_is_valid(gpio))
57 err = gpio_request(gpio, "eth rst");
61 /* Set gpio as output and send a pulse */
62 gpio_direction_output(gpio, 1);
64 gpio_set_value(gpio, 0);
66 gpio_set_value(gpio, 1);
71 #else /* !CONFIG_OMAP_GPIO */
72 static inline int cl_omap3_smc911x_reset_net_chip(int gpio) { return 0; }
73 #endif /* CONFIG_OMAP_GPIO */
75 int cl_omap3_smc911x_init(int id, int cs, u32 base_addr,
76 int (*reset)(int), int rst_gpio)
80 cl_omap3_smc911x_setup_net_chip_gmpc(cs, base_addr);
85 cl_omap3_smc911x_reset_net_chip(rst_gpio);
87 ret = smc911x_initialize(id, base_addr);
91 printf("Failed initializing SMC911x! ");