summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSudhakar Rajashekhara <sudhakar.raj@ti.com>2010-01-20 15:30:48 +0530
committerSudhakar Rajashekhara <sudhakar.raj@ti.com>2010-01-21 15:26:22 +0530
commit4312018de5b3f5370d8776d0a8d21d4bc8b24f4d (patch)
tree73a3d896e13750785bd2c5cfb86554ee1347a27f
parent652a0e7a3e86a6b525eb517d16009bf0ab73b0ed (diff)
da850: Add RMII support for EMAC
Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
-rw-r--r--board/davinci/da8xxevm/da850evm.c108
-rw-r--r--include/asm-arm/arch-davinci/hardware.h4
-rw-r--r--include/configs/da850evm.h1
3 files changed, 110 insertions, 3 deletions
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
index fbe1e12def..5fed7f531c 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -68,6 +68,15 @@ const struct pinmux_config uart_pins[] = {
#ifdef CONFIG_DRIVER_TI_EMAC
const struct pinmux_config emac_pins[] = {
+#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
+ { pinmux[14], 8, 2 },
+ { pinmux[14], 8, 3 },
+ { pinmux[14], 8, 4 },
+ { pinmux[14], 8, 5 },
+ { pinmux[14], 8, 6 },
+ { pinmux[14], 8, 7 },
+ { pinmux[15], 8, 1 },
+#else
{ pinmux[2], 8, 1 },
{ pinmux[2], 8, 2 },
{ pinmux[2], 8, 3 },
@@ -83,10 +92,11 @@ const struct pinmux_config emac_pins[] = {
{ pinmux[3], 8, 5 },
{ pinmux[3], 8, 6 },
{ pinmux[3], 8, 7 },
+#endif /* CONFIG_DRIVER_TI_EMAC_USE_RMII */
{ pinmux[4], 8, 0 },
{ pinmux[4], 8, 1 }
};
-#endif
+#endif /* CONFIG_DRIVER_TI_EMAC */
/* I2C pin muxer settings */
const struct pinmux_config i2c_pins[] = {
@@ -217,10 +227,12 @@ int board_init(void)
#ifdef CONFIG_DRIVER_TI_EMAC
if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
return 1;
-#ifdef CONFIG_MACH_DAVINCI_DA850_EVM
+#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
+ REG(CFGCHIP3) |= (1 << 8);
+#else
/* set cfgchip3 to selct MII */
REG(CFGCHIP3) &= ~(1 << 8);
-#endif /* CONFIG_MACH_DAVINCI_DA850_EVM */
+#endif /* CONFIG_DRIVER_TI_EMAC_USE_RMII */
#endif /* CONFIG_DRIVER_TI_EMAC */
@@ -275,6 +287,90 @@ err_probe:
return ret;
}
+#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
+/**
+ * rmii_hw_init
+ *
+ * DA850/OMAP-L138 EVM can interface to a daughter card for
+ * additional features. This card has an I2C GPIO Expander TCA6416
+ * to select the required functions like camera, RMII Ethernet,
+ * character LCD, video.
+ *
+ * Initialization of the expander involves configuring the
+ * polarity and direction of the ports. P07-P05 are used here.
+ * These ports are connected to a Mux chip which enables only one
+ * functionality at a time.
+ *
+ * For RMII phy to respond, the MII MDIO clock has to be disabled
+ * since both the PHY devices have address as zero. The MII MDIO
+ * clock is controlled via GPIO2[6].
+ *
+ * This code is valid for Beta version of the hardware
+ */
+int rmii_hw_init(void)
+{
+ const struct pinmux_config gpio_pins[] = {
+ { pinmux[6], 8, 1 }
+ };
+ u_int8_t buf[2];
+ unsigned int temp;
+ int ret;
+
+ /* PinMux for GPIO */
+ if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0)
+ return 1;
+
+ /* I2C Exapnder configuration */
+ /* Set polarity to non-inverted */
+ buf[0] = 0x0;
+ buf[1] = 0x0;
+ ret = i2c_write(CONFIG_SYS_I2C_EXPANDER_ADDR, 4, 1, buf, 2);
+ if (ret) {
+ printf("\nExpander @ 0x%02x write FAILED!!!\n",
+ CONFIG_SYS_I2C_EXPANDER_ADDR);
+ return ret;
+ }
+
+ /* Configure P07-P05 as outputs */
+ buf[0] = 0x1f;
+ buf[1] = 0xff;
+ ret = i2c_write(CONFIG_SYS_I2C_EXPANDER_ADDR, 6, 1, buf, 2);
+ if (ret) {
+ printf("\nExpander @ 0x%02x write FAILED!!!\n",
+ CONFIG_SYS_I2C_EXPANDER_ADDR);
+ }
+
+ /* For Ethernet RMII selection
+ * P07(SelA)=0
+ * P06(SelB)=1
+ * P05(SelC)=1
+ */
+ if (i2c_read(CONFIG_SYS_I2C_EXPANDER_ADDR, 2, 1, buf, 1)) {
+ printf("\nExpander @ 0x%02x read FAILED!!!\n",
+ CONFIG_SYS_I2C_EXPANDER_ADDR);
+ }
+
+ buf[0] &= 0x1f;
+ buf[0] |= (0 << 7) | (1 << 6) | (1 << 5);
+ if (i2c_write(CONFIG_SYS_I2C_EXPANDER_ADDR, 2, 1, buf, 1)) {
+ printf("\nExpander @ 0x%02x write FAILED!!!\n",
+ CONFIG_SYS_I2C_EXPANDER_ADDR);
+ }
+
+ /* Set the output as high */
+ temp = REG(GPIO_BANK2_REG_SET_ADDR);
+ temp |= (0x01 << 6);
+ REG(GPIO_BANK2_REG_SET_ADDR) = temp;
+
+ /* Set the GPIO direction as output */
+ temp = REG(GPIO_BANK2_REG_DIR_ADDR);
+ temp &= ~(0x01 << 6);
+ REG(GPIO_BANK2_REG_DIR_ADDR) = temp;
+
+ return 0;
+}
+#endif
+
int misc_init_r(void)
{
uint8_t tmp[20], addr[10];
@@ -296,6 +392,12 @@ int misc_init_r(void)
setenv("ethaddr", (char *)tmp);
}
+#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
+ /* Select RMII fucntion through the expander */
+ if (rmii_hw_init())
+ printf("RMII hardware init failed!!!\n");
+#endif
+
return (0);
}
diff --git a/include/asm-arm/arch-davinci/hardware.h b/include/asm-arm/arch-davinci/hardware.h
index 7b5f0940e2..f22a77dac4 100644
--- a/include/asm-arm/arch-davinci/hardware.h
+++ b/include/asm-arm/arch-davinci/hardware.h
@@ -152,6 +152,10 @@ typedef volatile unsigned int * dv_reg_p;
#define DAVINCI_BOOTCFG_BASE 0x01c14000
#define JTAG_ID_REG (DAVINCI_BOOTCFG_BASE + 0x18)
#define CFGCHIP3 (DAVINCI_BOOTCFG_BASE + 0x188)
+#define GPIO_BANK2_REG_DIR_ADDR (DAVINCI_GPIO_BASE + 0x38)
+#define GPIO_BANK2_REG_OPDATA_ADDR (DAVINCI_GPIO_BASE + 0x3c)
+#define GPIO_BANK2_REG_SET_ADDR (DAVINCI_GPIO_BASE + 0x40)
+#define GPIO_BANK2_REG_CLR_ADDR (DAVINCI_GPIO_BASE + 0x44)
#endif /* CONFIG_SOC_DA8XX */
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h
index dc4e7377cf..35c5c9bf58 100644
--- a/include/configs/da850evm.h
+++ b/include/configs/da850evm.h
@@ -91,6 +91,7 @@
*/
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
+#define CONFIG_SYS_I2C_EXPANDER_ADDR 0x20
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 6
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 20