Skip to content

Commit

Permalink
davinci: DA850/OMAP-L138 EVM: implement autodetect of RMII PHY
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nsekhar authored and metaliveblog committed Nov 25, 2009
1 parent b5ebe4e commit bae1058
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions arch/arm/mach-davinci/board-da850-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,21 @@ static struct platform_device da850_evm_nandflash_device = {
static u32 ui_card_detected;
static void da850_evm_setup_nor_nand(void);

#ifdef CONFIG_DA850_UI_RMII
static inline void da850_evm_setup_emac_rmii(int rmii_sel)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;

soc_info->emac_pdata->rmii_en = 1;
gpio_set_value(rmii_sel, 0);
}
#else
static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
#endif

static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
unsigned ngpio, void *c)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
int sel_a, sel_b, sel_c, ret;

sel_a = gpio + 7;
Expand Down Expand Up @@ -186,9 +197,7 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,

da850_evm_setup_nor_nand();

if (soc_info->emac_pdata->rmii_en)
/* enable RMII */
gpio_set_value(sel_a, 0);
da850_evm_setup_emac_rmii(sel_a);

return 0;

Expand Down Expand Up @@ -513,11 +522,16 @@ static const short da850_evm_lcdc_pins[] = {
-1
};

static int __init da850_evm_config_emac(u8 rmii_en)
static int __init da850_evm_config_emac(void)
{
void __iomem *cfg_chip3_base;
int ret;
u32 val;
struct davinci_soc_info *soc_info = &davinci_soc_info;
u8 rmii_en = soc_info->emac_pdata->rmii_en;

if (!machine_is_davinci_da850_evm())
return 0;

cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);

Expand Down Expand Up @@ -562,12 +576,20 @@ static int __init da850_evm_config_emac(u8 rmii_en)
" functional\n");
}

soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;

ret = da8xx_register_emac();
if (ret)
pr_warning("da850_evm_init: emac registration failed: %d\n",
ret);

return 0;
}
device_initcall(da850_evm_config_emac);

static __init void da850_evm_init(void)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
int ret;

ret = pmic_tps65070_init();
Expand All @@ -590,22 +612,6 @@ static __init void da850_evm_init(void)
pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
ret);

soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
#ifdef CONFIG_DA850_UI_RMII
soc_info->emac_pdata->rmii_en = 1;
#else
soc_info->emac_pdata->rmii_en = 0;
#endif

ret = da850_evm_config_emac(soc_info->emac_pdata->rmii_en);
if (ret)
pr_warning("da850_evm_init: emac setup failed: %d\n", ret);

ret = da8xx_register_emac();
if (ret)
pr_warning("da850_evm_init: emac registration failed: %d\n",
ret);

ret = da8xx_register_watchdog();
if (ret)
Expand Down

0 comments on commit bae1058

Please sign in to comment.