mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
net/fec: gasket needs to be enabled for some i.mx
On the recent i.mx (mx25/50/53), there is a gasket inside fec controller which needs to be enabled no matter phy works in MII or RMII mode. The current code enables the gasket only when phy interface is RMII. It's broken when the driver works with a MII phy. The patch uses platform_device_id to distinguish the SoCs that have the gasket and enables it on these SoCs for both MII and RMII mode. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Reported-by: Troy Kisky <troy.kisky@boundarydevices.com> Cc: David S. Miller <davem@davemloft.net> Cc: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
22698aa252
commit
0ca1e290b7
@ -296,7 +296,7 @@ static struct clk_lookup lookups[] = {
|
|||||||
_REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk)
|
_REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk)
|
||||||
_REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk)
|
_REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk)
|
||||||
_REGISTER_CLOCK("imx-i2c.2", NULL, i2c_clk)
|
_REGISTER_CLOCK("imx-i2c.2", NULL, i2c_clk)
|
||||||
_REGISTER_CLOCK("fec.0", NULL, fec_clk)
|
_REGISTER_CLOCK("imx25-fec.0", NULL, fec_clk)
|
||||||
_REGISTER_CLOCK("imxdi_rtc.0", NULL, dryice_clk)
|
_REGISTER_CLOCK("imxdi_rtc.0", NULL, dryice_clk)
|
||||||
_REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
|
_REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
|
||||||
_REGISTER_CLOCK("imx2-wdt.0", NULL, wdt_clk)
|
_REGISTER_CLOCK("imx2-wdt.0", NULL, wdt_clk)
|
||||||
|
@ -663,7 +663,7 @@ static struct clk_lookup lookups[] = {
|
|||||||
_REGISTER_CLOCK(NULL, "brom", brom_clk)
|
_REGISTER_CLOCK(NULL, "brom", brom_clk)
|
||||||
_REGISTER_CLOCK(NULL, "emma", emma_clk)
|
_REGISTER_CLOCK(NULL, "emma", emma_clk)
|
||||||
_REGISTER_CLOCK(NULL, "slcdc", slcdc_clk)
|
_REGISTER_CLOCK(NULL, "slcdc", slcdc_clk)
|
||||||
_REGISTER_CLOCK("fec.0", NULL, fec_clk)
|
_REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
|
||||||
_REGISTER_CLOCK(NULL, "emi", emi_clk)
|
_REGISTER_CLOCK(NULL, "emi", emi_clk)
|
||||||
_REGISTER_CLOCK(NULL, "sahara2", sahara2_clk)
|
_REGISTER_CLOCK(NULL, "sahara2", sahara2_clk)
|
||||||
_REGISTER_CLOCK(NULL, "ata", ata_clk)
|
_REGISTER_CLOCK(NULL, "ata", ata_clk)
|
||||||
|
@ -461,7 +461,8 @@ static struct clk_lookup lookups[] = {
|
|||||||
_REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
|
_REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
|
||||||
_REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
|
_REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
|
||||||
_REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk)
|
_REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk)
|
||||||
_REGISTER_CLOCK("fec.0", NULL, fec_clk)
|
/* i.mx35 has the i.mx27 type fec */
|
||||||
|
_REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
|
||||||
_REGISTER_CLOCK(NULL, "gpio", gpio1_clk)
|
_REGISTER_CLOCK(NULL, "gpio", gpio1_clk)
|
||||||
_REGISTER_CLOCK(NULL, "gpio", gpio2_clk)
|
_REGISTER_CLOCK(NULL, "gpio", gpio2_clk)
|
||||||
_REGISTER_CLOCK(NULL, "gpio", gpio3_clk)
|
_REGISTER_CLOCK(NULL, "gpio", gpio3_clk)
|
||||||
|
@ -1427,7 +1427,8 @@ static struct clk_lookup mx51_lookups[] = {
|
|||||||
_REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
|
_REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
|
||||||
_REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
|
_REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
|
||||||
_REGISTER_CLOCK(NULL, "gpt", gpt_clk)
|
_REGISTER_CLOCK(NULL, "gpt", gpt_clk)
|
||||||
_REGISTER_CLOCK("fec.0", NULL, fec_clk)
|
/* i.mx51 has the i.mx27 type fec */
|
||||||
|
_REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
|
||||||
_REGISTER_CLOCK("mxc_pwm.0", "pwm", pwm1_clk)
|
_REGISTER_CLOCK("mxc_pwm.0", "pwm", pwm1_clk)
|
||||||
_REGISTER_CLOCK("mxc_pwm.1", "pwm", pwm2_clk)
|
_REGISTER_CLOCK("mxc_pwm.1", "pwm", pwm2_clk)
|
||||||
_REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
|
_REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
|
||||||
@ -1478,7 +1479,8 @@ static struct clk_lookup mx53_lookups[] = {
|
|||||||
_REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk)
|
_REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk)
|
||||||
_REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk)
|
_REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk)
|
||||||
_REGISTER_CLOCK(NULL, "gpt", gpt_clk)
|
_REGISTER_CLOCK(NULL, "gpt", gpt_clk)
|
||||||
_REGISTER_CLOCK("fec.0", NULL, fec_clk)
|
/* i.mx53 has the i.mx25 type fec */
|
||||||
|
_REGISTER_CLOCK("imx25-fec.0", NULL, fec_clk)
|
||||||
_REGISTER_CLOCK(NULL, "iim_clk", iim_clk)
|
_REGISTER_CLOCK(NULL, "iim_clk", iim_clk)
|
||||||
_REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
|
_REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
|
||||||
_REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
|
_REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
|
||||||
|
@ -11,40 +11,45 @@
|
|||||||
#include <mach/hardware.h>
|
#include <mach/hardware.h>
|
||||||
#include <mach/devices-common.h>
|
#include <mach/devices-common.h>
|
||||||
|
|
||||||
#define imx_fec_data_entry_single(soc) \
|
#define imx_fec_data_entry_single(soc, _devid) \
|
||||||
{ \
|
{ \
|
||||||
|
.devid = _devid, \
|
||||||
.iobase = soc ## _FEC_BASE_ADDR, \
|
.iobase = soc ## _FEC_BASE_ADDR, \
|
||||||
.irq = soc ## _INT_FEC, \
|
.irq = soc ## _INT_FEC, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_IMX25
|
#ifdef CONFIG_SOC_IMX25
|
||||||
const struct imx_fec_data imx25_fec_data __initconst =
|
const struct imx_fec_data imx25_fec_data __initconst =
|
||||||
imx_fec_data_entry_single(MX25);
|
imx_fec_data_entry_single(MX25, "imx25-fec");
|
||||||
#endif /* ifdef CONFIG_SOC_IMX25 */
|
#endif /* ifdef CONFIG_SOC_IMX25 */
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_IMX27
|
#ifdef CONFIG_SOC_IMX27
|
||||||
const struct imx_fec_data imx27_fec_data __initconst =
|
const struct imx_fec_data imx27_fec_data __initconst =
|
||||||
imx_fec_data_entry_single(MX27);
|
imx_fec_data_entry_single(MX27, "imx27-fec");
|
||||||
#endif /* ifdef CONFIG_SOC_IMX27 */
|
#endif /* ifdef CONFIG_SOC_IMX27 */
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_IMX35
|
#ifdef CONFIG_SOC_IMX35
|
||||||
|
/* i.mx35 has the i.mx27 type fec */
|
||||||
const struct imx_fec_data imx35_fec_data __initconst =
|
const struct imx_fec_data imx35_fec_data __initconst =
|
||||||
imx_fec_data_entry_single(MX35);
|
imx_fec_data_entry_single(MX35, "imx27-fec");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_IMX50
|
#ifdef CONFIG_SOC_IMX50
|
||||||
|
/* i.mx50 has the i.mx25 type fec */
|
||||||
const struct imx_fec_data imx50_fec_data __initconst =
|
const struct imx_fec_data imx50_fec_data __initconst =
|
||||||
imx_fec_data_entry_single(MX50);
|
imx_fec_data_entry_single(MX50, "imx25-fec");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_IMX51
|
#ifdef CONFIG_SOC_IMX51
|
||||||
|
/* i.mx51 has the i.mx27 type fec */
|
||||||
const struct imx_fec_data imx51_fec_data __initconst =
|
const struct imx_fec_data imx51_fec_data __initconst =
|
||||||
imx_fec_data_entry_single(MX51);
|
imx_fec_data_entry_single(MX51, "imx27-fec");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SOC_IMX53
|
#ifdef CONFIG_SOC_IMX53
|
||||||
|
/* i.mx53 has the i.mx25 type fec */
|
||||||
const struct imx_fec_data imx53_fec_data __initconst =
|
const struct imx_fec_data imx53_fec_data __initconst =
|
||||||
imx_fec_data_entry_single(MX53);
|
imx_fec_data_entry_single(MX53, "imx25-fec");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct platform_device *__init imx_add_fec(
|
struct platform_device *__init imx_add_fec(
|
||||||
@ -63,7 +68,7 @@ struct platform_device *__init imx_add_fec(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return imx_add_platform_device_dmamask("fec", 0,
|
return imx_add_platform_device_dmamask(data->devid, 0,
|
||||||
res, ARRAY_SIZE(res),
|
res, ARRAY_SIZE(res),
|
||||||
pdata, sizeof(*pdata), DMA_BIT_MASK(32));
|
pdata, sizeof(*pdata), DMA_BIT_MASK(32));
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ static inline struct platform_device *imx_add_platform_device(
|
|||||||
|
|
||||||
#include <linux/fec.h>
|
#include <linux/fec.h>
|
||||||
struct imx_fec_data {
|
struct imx_fec_data {
|
||||||
|
const char *devid;
|
||||||
resource_size_t iobase;
|
resource_size_t iobase;
|
||||||
resource_size_t irq;
|
resource_size_t irq;
|
||||||
};
|
};
|
||||||
|
@ -66,17 +66,28 @@
|
|||||||
#define FEC_QUIRK_ENET_MAC (1 << 0)
|
#define FEC_QUIRK_ENET_MAC (1 << 0)
|
||||||
/* Controller needs driver to swap frame */
|
/* Controller needs driver to swap frame */
|
||||||
#define FEC_QUIRK_SWAP_FRAME (1 << 1)
|
#define FEC_QUIRK_SWAP_FRAME (1 << 1)
|
||||||
|
/* Controller uses gasket */
|
||||||
|
#define FEC_QUIRK_USE_GASKET (1 << 2)
|
||||||
|
|
||||||
static struct platform_device_id fec_devtype[] = {
|
static struct platform_device_id fec_devtype[] = {
|
||||||
{
|
{
|
||||||
|
/* keep it for coldfire */
|
||||||
.name = DRIVER_NAME,
|
.name = DRIVER_NAME,
|
||||||
.driver_data = 0,
|
.driver_data = 0,
|
||||||
|
}, {
|
||||||
|
.name = "imx25-fec",
|
||||||
|
.driver_data = FEC_QUIRK_USE_GASKET,
|
||||||
|
}, {
|
||||||
|
.name = "imx27-fec",
|
||||||
|
.driver_data = 0,
|
||||||
}, {
|
}, {
|
||||||
.name = "imx28-fec",
|
.name = "imx28-fec",
|
||||||
.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
|
.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
|
||||||
},
|
}, {
|
||||||
{ }
|
/* sentinel */
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
MODULE_DEVICE_TABLE(platform, fec_devtype);
|
||||||
|
|
||||||
static unsigned char macaddr[ETH_ALEN];
|
static unsigned char macaddr[ETH_ALEN];
|
||||||
module_param_array(macaddr, byte, NULL, 0);
|
module_param_array(macaddr, byte, NULL, 0);
|
||||||
@ -427,7 +438,7 @@ fec_restart(struct net_device *ndev, int duplex)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef FEC_MIIGSK_ENR
|
#ifdef FEC_MIIGSK_ENR
|
||||||
if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
|
if (id_entry->driver_data & FEC_QUIRK_USE_GASKET) {
|
||||||
/* disable the gasket and wait */
|
/* disable the gasket and wait */
|
||||||
writel(0, fep->hwp + FEC_MIIGSK_ENR);
|
writel(0, fep->hwp + FEC_MIIGSK_ENR);
|
||||||
while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
|
while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
|
||||||
@ -436,8 +447,11 @@ fec_restart(struct net_device *ndev, int duplex)
|
|||||||
/*
|
/*
|
||||||
* configure the gasket:
|
* configure the gasket:
|
||||||
* RMII, 50 MHz, no loopback, no echo
|
* RMII, 50 MHz, no loopback, no echo
|
||||||
|
* MII, 25 MHz, no loopback, no echo
|
||||||
*/
|
*/
|
||||||
writel(1, fep->hwp + FEC_MIIGSK_CFGR);
|
writel((fep->phy_interface == PHY_INTERFACE_MODE_RMII) ?
|
||||||
|
1 : 0, fep->hwp + FEC_MIIGSK_CFGR);
|
||||||
|
|
||||||
|
|
||||||
/* re-enable the gasket */
|
/* re-enable the gasket */
|
||||||
writel(2, fep->hwp + FEC_MIIGSK_ENR);
|
writel(2, fep->hwp + FEC_MIIGSK_ENR);
|
||||||
|
Loading…
Reference in New Issue
Block a user