OMAP3EVM: Reset the smsc911x ethernet controller in board_init
authorVaibhav Hiremath <hvaibhav@ti.com>
Mon, 24 Jan 2011 19:25:55 +0000 (19:25 +0000)
committerTony Lindgren <tony@atomide.com>
Thu, 17 Feb 2011 22:15:57 +0000 (14:15 -0800)
With addition of hwmod support to gpio, the ethernet controller
goes undetected for OMAP35xEVM. So explicitly assert the reset signal to
ethernet controller smsc911x -

- GPIO7 (>=RevG version of EVM's)
- GPIO64 (<=RevD version of EVM's)

Tested this patch on RevG version of EVM with ES3.1 Si.

This patch is based on intial version from Charulatha V, reference
to original discussion -
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35784.html

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/board-omap3evm.c

index ac50bf949447132db3adaa0fbb4999ff9446bbc3..b9f954e839d37c31138409a68a625b2c64d6d6e2 100644 (file)
 #define OMAP3EVM_ETHR_ID_REV   0x50
 #define OMAP3EVM_ETHR_GPIO_IRQ 176
 #define OMAP3EVM_SMSC911X_CS   5
+/*
+ * Eth Reset signal
+ *     64 = Generation 1 (<=RevD)
+ *     7 = Generation 2 (>=RevE)
+ */
+#define OMAP3EVM_GEN1_ETHR_GPIO_RST    64
+#define OMAP3EVM_GEN2_ETHR_GPIO_RST    7
 
 static u8 omap3_evm_version;
 
@@ -126,10 +133,15 @@ static struct platform_device omap3evm_smsc911x_device = {
 
 static inline void __init omap3evm_init_smsc911x(void)
 {
-       int eth_cs;
+       int eth_cs, eth_rst;
        struct clk *l3ck;
        unsigned int rate;
 
+       if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1)
+               eth_rst = OMAP3EVM_GEN1_ETHR_GPIO_RST;
+       else
+               eth_rst = OMAP3EVM_GEN2_ETHR_GPIO_RST;
+
        eth_cs = OMAP3EVM_SMSC911X_CS;
 
        l3ck = clk_get(NULL, "l3_ck");
@@ -138,6 +150,27 @@ static inline void __init omap3evm_init_smsc911x(void)
        else
                rate = clk_get_rate(l3ck);
 
+       /* Configure ethernet controller reset gpio */
+       if (cpu_is_omap3430()) {
+               if (gpio_request(eth_rst, "SMSC911x gpio") < 0) {
+                       pr_err(KERN_ERR "Failed to request %d for smsc911x\n",
+                                       eth_rst);
+                       return;
+               }
+
+               if (gpio_direction_output(eth_rst, 1) < 0) {
+                       pr_err(KERN_ERR "Failed to set direction of %d for" \
+                                       " smsc911x\n", eth_rst);
+                       return;
+               }
+               /* reset pulse to ethernet controller*/
+               usleep_range(150, 220);
+               gpio_set_value(eth_rst, 0);
+               usleep_range(150, 220);
+               gpio_set_value(eth_rst, 1);
+               usleep_range(1, 2);
+       }
+
        if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMSC911x irq") < 0) {
                printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
                        OMAP3EVM_ETHR_GPIO_IRQ);
@@ -713,6 +746,10 @@ static struct omap_board_mux board_mux[] __initdata = {
                                OMAP_PIN_OFF_WAKEUPENABLE),
        OMAP3_MUX(MCSPI1_CS1, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
                                OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW),
+       OMAP3_MUX(SYS_BOOT5, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
+                               OMAP_PIN_OFF_NONE),
+       OMAP3_MUX(GPMC_WAIT2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
+                               OMAP_PIN_OFF_NONE),
 #ifdef CONFIG_WL12XX_PLATFORM_DATA
        /* WLAN IRQ - GPIO 149 */
        OMAP3_MUX(UART1_RTS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),