diff options
author | Fugang Duan <b38611@freescale.com> | 2015-09-06 22:55:00 -0400 |
---|---|---|
committer | Shawn Guo <shawnguo@kernel.org> | 2015-09-22 20:47:54 -0400 |
commit | 69f9c5047d04945693ecc1bdfdb8a3dc2a1f48cf (patch) | |
tree | 83f2cd09c83158506e3a89ad5ce228cec7acb04b | |
parent | 7dc87ff8815ef43717c936faea79013855e3dbef (diff) |
ARM: imx: add enet init for i.MX7D platform
Add enet phy fixup, clock source init for i.MX7D platform.
Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
-rw-r--r-- | arch/arm/mach-imx/mach-imx7d.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/mach-imx7d.c b/arch/arm/mach-imx/mach-imx7d.c index 62f3437257f1..b450f525a670 100644 --- a/arch/arm/mach-imx/mach-imx7d.c +++ b/arch/arm/mach-imx/mach-imx7d.c | |||
@@ -6,12 +6,85 @@ | |||
6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
7 | */ | 7 | */ |
8 | #include <linux/irqchip.h> | 8 | #include <linux/irqchip.h> |
9 | #include <linux/mfd/syscon.h> | ||
10 | #include <linux/mfd/syscon/imx7-iomuxc-gpr.h> | ||
9 | #include <linux/of_platform.h> | 11 | #include <linux/of_platform.h> |
12 | #include <linux/phy.h> | ||
13 | #include <linux/regmap.h> | ||
14 | |||
10 | #include <asm/mach/arch.h> | 15 | #include <asm/mach/arch.h> |
11 | #include <asm/mach/map.h> | 16 | #include <asm/mach/map.h> |
12 | 17 | ||
13 | #include "common.h" | 18 | #include "common.h" |
14 | 19 | ||
20 | static int ar8031_phy_fixup(struct phy_device *dev) | ||
21 | { | ||
22 | u16 val; | ||
23 | |||
24 | /* Set RGMII IO voltage to 1.8V */ | ||
25 | phy_write(dev, 0x1d, 0x1f); | ||
26 | phy_write(dev, 0x1e, 0x8); | ||
27 | |||
28 | /* disable phy AR8031 SmartEEE function. */ | ||
29 | phy_write(dev, 0xd, 0x3); | ||
30 | phy_write(dev, 0xe, 0x805d); | ||
31 | phy_write(dev, 0xd, 0x4003); | ||
32 | val = phy_read(dev, 0xe); | ||
33 | val &= ~(0x1 << 8); | ||
34 | phy_write(dev, 0xe, val); | ||
35 | |||
36 | /* introduce tx clock delay */ | ||
37 | phy_write(dev, 0x1d, 0x5); | ||
38 | val = phy_read(dev, 0x1e); | ||
39 | val |= 0x0100; | ||
40 | phy_write(dev, 0x1e, val); | ||
41 | |||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | static int bcm54220_phy_fixup(struct phy_device *dev) | ||
46 | { | ||
47 | /* enable RXC skew select RGMII copper mode */ | ||
48 | phy_write(dev, 0x1e, 0x21); | ||
49 | phy_write(dev, 0x1f, 0x7ea8); | ||
50 | phy_write(dev, 0x1e, 0x2f); | ||
51 | phy_write(dev, 0x1f, 0x71b7); | ||
52 | |||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | #define PHY_ID_AR8031 0x004dd074 | ||
57 | #define PHY_ID_BCM54220 0x600d8589 | ||
58 | |||
59 | static void __init imx7d_enet_phy_init(void) | ||
60 | { | ||
61 | if (IS_BUILTIN(CONFIG_PHYLIB)) { | ||
62 | phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff, | ||
63 | ar8031_phy_fixup); | ||
64 | phy_register_fixup_for_uid(PHY_ID_BCM54220, 0xffffffff, | ||
65 | bcm54220_phy_fixup); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | static void __init imx7d_enet_clk_sel(void) | ||
70 | { | ||
71 | struct regmap *gpr; | ||
72 | |||
73 | gpr = syscon_regmap_lookup_by_compatible("fsl,imx7d-iomuxc-gpr"); | ||
74 | if (!IS_ERR(gpr)) { | ||
75 | regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK, 0); | ||
76 | regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_CLK_DIR_MASK, 0); | ||
77 | } else { | ||
78 | pr_err("failed to find fsl,imx7d-iomux-gpr regmap\n"); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static inline void imx7d_enet_init(void) | ||
83 | { | ||
84 | imx7d_enet_phy_init(); | ||
85 | imx7d_enet_clk_sel(); | ||
86 | } | ||
87 | |||
15 | static void __init imx7d_init_machine(void) | 88 | static void __init imx7d_init_machine(void) |
16 | { | 89 | { |
17 | struct device *parent; | 90 | struct device *parent; |
@@ -22,6 +95,7 @@ static void __init imx7d_init_machine(void) | |||
22 | 95 | ||
23 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 96 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
24 | imx_anatop_init(); | 97 | imx_anatop_init(); |
98 | imx7d_enet_init(); | ||
25 | } | 99 | } |
26 | 100 | ||
27 | static void __init imx7d_init_irq(void) | 101 | static void __init imx7d_init_irq(void) |