aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/board-da850-evm.c
diff options
context:
space:
mode:
authorSekhar Nori <nsekhar@ti.com>2009-10-21 11:48:22 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-11-25 13:21:35 -0500
commitbae105879f2f2404155da6f50b3636193d228a62 (patch)
tree8e6e73a218a3a77680598ecba8334cd2f510f303 /arch/arm/mach-davinci/board-da850-evm.c
parentb5ebe4e198e595cad412a9de2d7b253693545d30 (diff)
davinci: DA850/OMAP-L138 EVM: implement autodetect of RMII PHY
Implement autodetection of RMII PHY by shifting the decision to use the RMII PHY to da850_evm_ui_expander_setup() from da850_evm_init() earlier. Without this patch, selecting RMII PHY in the UI expander menu will make the MII PHY unusable even though UI board is not connected. The actual configuration and registration of the EMAC device is delayed to device_initcall() so it happens after the UI card detection is complete. A side effect of this patch is the removal of a voilation of Documentation/SubmittingPatches section 2.2 in function da850_evm_init() Signed-off-by: Sekhar Nori <nsekhar@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.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 23e2024c3d9..fd6f7800611 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -148,10 +148,21 @@ static struct platform_device da850_evm_nandflash_device = {
148static u32 ui_card_detected; 148static u32 ui_card_detected;
149static void da850_evm_setup_nor_nand(void); 149static void da850_evm_setup_nor_nand(void);
150 150
151#ifdef CONFIG_DA850_UI_RMII
152static inline void da850_evm_setup_emac_rmii(int rmii_sel)
153{
154 struct davinci_soc_info *soc_info = &davinci_soc_info;
155
156 soc_info->emac_pdata->rmii_en = 1;
157 gpio_set_value(rmii_sel, 0);
158}
159#else
160static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
161#endif
162
151static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, 163static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
152 unsigned ngpio, void *c) 164 unsigned ngpio, void *c)
153{ 165{
154 struct davinci_soc_info *soc_info = &davinci_soc_info;
155 int sel_a, sel_b, sel_c, ret; 166 int sel_a, sel_b, sel_c, ret;
156 167
157 sel_a = gpio + 7; 168 sel_a = gpio + 7;
@@ -186,9 +197,7 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
186 197
187 da850_evm_setup_nor_nand(); 198 da850_evm_setup_nor_nand();
188 199
189 if (soc_info->emac_pdata->rmii_en) 200 da850_evm_setup_emac_rmii(sel_a);
190 /* enable RMII */
191 gpio_set_value(sel_a, 0);
192 201
193 return 0; 202 return 0;
194 203
@@ -513,11 +522,16 @@ static const short da850_evm_lcdc_pins[] = {
513 -1 522 -1
514}; 523};
515 524
516static int __init da850_evm_config_emac(u8 rmii_en) 525static int __init da850_evm_config_emac(void)
517{ 526{
518 void __iomem *cfg_chip3_base; 527 void __iomem *cfg_chip3_base;
519 int ret; 528 int ret;
520 u32 val; 529 u32 val;
530 struct davinci_soc_info *soc_info = &davinci_soc_info;
531 u8 rmii_en = soc_info->emac_pdata->rmii_en;
532
533 if (!machine_is_davinci_da850_evm())
534 return 0;
521 535
522 cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG); 536 cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
523 537
@@ -562,12 +576,20 @@ static int __init da850_evm_config_emac(u8 rmii_en)
562 " functional\n"); 576 " functional\n");
563 } 577 }
564 578
579 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
580 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
581
582 ret = da8xx_register_emac();
583 if (ret)
584 pr_warning("da850_evm_init: emac registration failed: %d\n",
585 ret);
586
565 return 0; 587 return 0;
566} 588}
589device_initcall(da850_evm_config_emac);
567 590
568static __init void da850_evm_init(void) 591static __init void da850_evm_init(void)
569{ 592{
570 struct davinci_soc_info *soc_info = &davinci_soc_info;
571 int ret; 593 int ret;
572 594
573 ret = pmic_tps65070_init(); 595 ret = pmic_tps65070_init();
@@ -590,22 +612,6 @@ static __init void da850_evm_init(void)
590 pr_warning("da850_evm_init: i2c0 registration failed: %d\n", 612 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
591 ret); 613 ret);
592 614
593 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
594 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
595#ifdef CONFIG_DA850_UI_RMII
596 soc_info->emac_pdata->rmii_en = 1;
597#else
598 soc_info->emac_pdata->rmii_en = 0;
599#endif
600
601 ret = da850_evm_config_emac(soc_info->emac_pdata->rmii_en);
602 if (ret)
603 pr_warning("da850_evm_init: emac setup failed: %d\n", ret);
604
605 ret = da8xx_register_emac();
606 if (ret)
607 pr_warning("da850_evm_init: emac registration failed: %d\n",
608 ret);
609 615
610 ret = da8xx_register_watchdog(); 616 ret = da8xx_register_watchdog();
611 if (ret) 617 if (ret)