aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/board-da850-evm.c
diff options
context:
space:
mode:
authorChaithrika U S <chaithrika@ti.com>2009-09-30 17:00:53 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-11-25 13:21:30 -0500
commit2206771c4359e236308122ad3fed7f5d91586fd7 (patch)
tree8eb60320325d81abc989770578edf59b7e50540b /arch/arm/mach-davinci/board-da850-evm.c
parent75e2ea643fe43d5aa836475acee5bd97cd9ea4bf (diff)
davinci: RMII support for DA850/OMAP-L138 EVM
DA850/OMAP-L138 EVM has a RMII Ethernet PHY on the UI daughter card. The PHY is enabled by proper programming of the IO Expander (TCA6416) ports. Also for RMII PHY to work, the MDIO clock of MII PHY has to be disabled since both the PHYs have the same address. This is done via the GPIO2[6] pin. This patch adds support for RMII PHY. This patch also adds a menuconfig option to select one or no peripheral connected to expander. Currently, sub-options in this menu are RMII and no peripheral.This menuconfig option is similar to the one present for UI card on DA830/OMAP-L137 EVM. Signed-off-by: Chaithrika U S <chaithrika@ti.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/board-da850-evm.c')
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 05b2d87d96b..53e434ba626 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -45,6 +45,8 @@
45#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0) 45#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
46#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1) 46#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
47 47
48#define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
49
48static struct mtd_partition da850_evm_norflash_partition[] = { 50static struct mtd_partition da850_evm_norflash_partition[] = {
49 { 51 {
50 .name = "NOR filesystem", 52 .name = "NOR filesystem",
@@ -152,6 +154,7 @@ static void da850_evm_setup_nor_nand(void);
152static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, 154static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
153 unsigned ngpio, void *c) 155 unsigned ngpio, void *c)
154{ 156{
157 struct davinci_soc_info *soc_info = &davinci_soc_info;
155 int sel_a, sel_b, sel_c, ret; 158 int sel_a, sel_b, sel_c, ret;
156 159
157 sel_a = gpio + 7; 160 sel_a = gpio + 7;
@@ -186,6 +189,10 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
186 189
187 da850_evm_setup_nor_nand(); 190 da850_evm_setup_nor_nand();
188 191
192 if (soc_info->emac_pdata->rmii_en)
193 /* enable RMII */
194 gpio_set_value(sel_a, 0);
195
189 return 0; 196 return 0;
190 197
191exp_setup_selc_fail: 198exp_setup_selc_fail:
@@ -509,6 +516,58 @@ static const short da850_evm_lcdc_pins[] = {
509 -1 516 -1
510}; 517};
511 518
519static int __init da850_evm_config_emac(u8 rmii_en)
520{
521 void __iomem *cfg_chip3_base;
522 int ret;
523 u32 val;
524
525 cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
526
527 /* configure the CFGCHIP3 register for RMII or MII */
528 val = __raw_readl(cfg_chip3_base);
529 if (rmii_en)
530 val |= BIT(8);
531 else
532 val &= ~BIT(8);
533
534 __raw_writel(val, cfg_chip3_base);
535
536 if (!rmii_en)
537 ret = da8xx_pinmux_setup(da850_cpgmac_pins);
538 else
539 ret = da8xx_pinmux_setup(da850_rmii_pins);
540 if (ret)
541 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
542 ret);
543
544 ret = davinci_cfg_reg(DA850_GPIO2_6);
545 if (ret)
546 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
547 "failed\n");
548
549 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
550 if (ret) {
551 pr_warning("Cannot open GPIO %d\n",
552 DA850_MII_MDIO_CLKEN_PIN);
553 return ret;
554 }
555
556 if (rmii_en) {
557 /* Disable MII MDIO clock */
558 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, 1);
559 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
560 " functional\n");
561 } else {
562 /* Enable MII MDIO clock */
563 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, 0);
564 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
565 " functional\n");
566 }
567
568 return 0;
569}
570
512static __init void da850_evm_init(void) 571static __init void da850_evm_init(void)
513{ 572{
514 struct davinci_soc_info *soc_info = &davinci_soc_info; 573 struct davinci_soc_info *soc_info = &davinci_soc_info;
@@ -536,12 +595,15 @@ static __init void da850_evm_init(void)
536 595
537 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK; 596 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
538 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY; 597 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
598#ifdef CONFIG_DA850_UI_RMII
599 soc_info->emac_pdata->rmii_en = 1;
600#else
539 soc_info->emac_pdata->rmii_en = 0; 601 soc_info->emac_pdata->rmii_en = 0;
602#endif
540 603
541 ret = da8xx_pinmux_setup(da850_cpgmac_pins); 604 ret = da850_evm_config_emac(soc_info->emac_pdata->rmii_en);
542 if (ret) 605 if (ret)
543 pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n", 606 pr_warning("da850_evm_init: emac setup failed: %d\n", ret);
544 ret);
545 607
546 ret = da8xx_register_emac(); 608 ret = da8xx_register_emac();
547 if (ret) 609 if (ret)