ec9de179a41e34bdf0b5b9583e1bc925b0b39172
[openwrt/staging/yousong.git] / target / linux / apm821xx / patches-4.4 / 701-powerpc_ibm_apm82181_phyclk_fix.patch
1 diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
2 index 5d7db6c..01bed2e 100644
3 --- a/drivers/net/ethernet/ibm/emac/core.c
4 +++ b/drivers/net/ethernet/ibm/emac/core.c
5 @@ -129,6 +129,7 @@ static inline void emac_report_timeout_error(struct emac_instance *dev,
6 {
7 if (emac_has_feature(dev, EMAC_FTR_440GX_PHY_CLK_FIX |
8 EMAC_FTR_460EX_PHY_CLK_FIX |
9 + EMAC_FTR_APM821XX_PHY_CLK_FIX |
10 EMAC_FTR_440EP_PHY_CLK_FIX))
11 DBG(dev, "%s" NL, error);
12 else if (net_ratelimit())
13 @@ -146,6 +147,10 @@ static inline void emac_rx_clk_tx(struct emac_instance *dev)
14 if (emac_has_feature(dev, EMAC_FTR_440EP_PHY_CLK_FIX))
15 dcri_clrset(SDR0, SDR0_MFR,
16 0, SDR0_MFR_ECS >> dev->cell_index);
17 +
18 + if (emac_has_feature(dev, EMAC_FTR_APM821XX_PHY_CLK_FIX))
19 + dcri_clrset(SDR0, SDR0_ETH_CFG,
20 + 0, 0x00000100 >> dev->cell_index);
21 #endif
22 }
23
24 @@ -155,6 +160,10 @@ static inline void emac_rx_clk_default(struct emac_instance *dev)
25 if (emac_has_feature(dev, EMAC_FTR_440EP_PHY_CLK_FIX))
26 dcri_clrset(SDR0, SDR0_MFR,
27 SDR0_MFR_ECS >> dev->cell_index, 0);
28 +
29 + if (emac_has_feature(dev, EMAC_FTR_APM821XX_PHY_CLK_FIX))
30 + dcri_clrset(SDR0, SDR0_ETH_CFG,
31 + 0x00000100 >> dev->cell_index, 0);
32 #endif
33 }
34
35 @@ -2587,7 +2596,7 @@ static int emac_init_config(struct emac_instance *dev)
36 if (of_device_is_compatible(np, "ibm,emac-apm821xx")) {
37 dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
38 EMAC_FTR_APM821XX_NO_HALF_DUPLEX |
39 - EMAC_FTR_460EX_PHY_CLK_FIX);
40 + EMAC_FTR_APM821XX_PHY_CLK_FIX);
41 }
42 } else if (of_device_is_compatible(np, "ibm,emac4")) {
43 dev->features |= EMAC_FTR_EMAC4;
44 diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h
45 index 93ae114..072176a 100644
46 --- a/drivers/net/ethernet/ibm/emac/core.h
47 +++ b/drivers/net/ethernet/ibm/emac/core.h
48 @@ -333,6 +333,8 @@ struct emac_instance {
49 */
50 #define EMAC_FTR_APM821XX_NO_HALF_DUPLEX 0x00001000
51
52 +#define EMAC_FTR_APM821XX_PHY_CLK_FIX 0x000002000
53 +
54 /* Right now, we don't quite handle the always/possible masks on the
55 * most optimal way as we don't have a way to say something like
56 * always EMAC4. Patches welcome.