diff options
Diffstat (limited to 'arch/mips/loongson1/common/platform.c')
-rw-r--r-- | arch/mips/loongson1/common/platform.c | 141 |
1 files changed, 123 insertions, 18 deletions
diff --git a/arch/mips/loongson1/common/platform.c b/arch/mips/loongson1/common/platform.c index fdf8cb5987a4..ddf1d4cbf31e 100644 --- a/arch/mips/loongson1/common/platform.c +++ b/arch/mips/loongson1/common/platform.c | |||
@@ -16,8 +16,10 @@ | |||
16 | #include <linux/usb/ehci_pdriver.h> | 16 | #include <linux/usb/ehci_pdriver.h> |
17 | #include <asm-generic/sizes.h> | 17 | #include <asm-generic/sizes.h> |
18 | 18 | ||
19 | #include <cpufreq.h> | ||
19 | #include <loongson1.h> | 20 | #include <loongson1.h> |
20 | 21 | ||
22 | /* 8250/16550 compatible UART */ | ||
21 | #define LS1X_UART(_id) \ | 23 | #define LS1X_UART(_id) \ |
22 | { \ | 24 | { \ |
23 | .mapbase = LS1X_UART ## _id ## _BASE, \ | 25 | .mapbase = LS1X_UART ## _id ## _BASE, \ |
@@ -27,7 +29,7 @@ | |||
27 | .type = PORT_16550A, \ | 29 | .type = PORT_16550A, \ |
28 | } | 30 | } |
29 | 31 | ||
30 | static struct plat_serial8250_port ls1x_serial8250_port[] = { | 32 | static struct plat_serial8250_port ls1x_serial8250_pdata[] = { |
31 | LS1X_UART(0), | 33 | LS1X_UART(0), |
32 | LS1X_UART(1), | 34 | LS1X_UART(1), |
33 | LS1X_UART(2), | 35 | LS1X_UART(2), |
@@ -35,11 +37,11 @@ static struct plat_serial8250_port ls1x_serial8250_port[] = { | |||
35 | {}, | 37 | {}, |
36 | }; | 38 | }; |
37 | 39 | ||
38 | struct platform_device ls1x_uart_device = { | 40 | struct platform_device ls1x_uart_pdev = { |
39 | .name = "serial8250", | 41 | .name = "serial8250", |
40 | .id = PLAT8250_DEV_PLATFORM, | 42 | .id = PLAT8250_DEV_PLATFORM, |
41 | .dev = { | 43 | .dev = { |
42 | .platform_data = ls1x_serial8250_port, | 44 | .platform_data = ls1x_serial8250_pdata, |
43 | }, | 45 | }, |
44 | }; | 46 | }; |
45 | 47 | ||
@@ -48,16 +50,97 @@ void __init ls1x_serial_setup(struct platform_device *pdev) | |||
48 | struct clk *clk; | 50 | struct clk *clk; |
49 | struct plat_serial8250_port *p; | 51 | struct plat_serial8250_port *p; |
50 | 52 | ||
51 | clk = clk_get(NULL, pdev->name); | 53 | clk = clk_get(&pdev->dev, pdev->name); |
52 | if (IS_ERR(clk)) | 54 | if (IS_ERR(clk)) { |
53 | panic("unable to get %s clock, err=%ld", | 55 | pr_err("unable to get %s clock, err=%ld", |
54 | pdev->name, PTR_ERR(clk)); | 56 | pdev->name, PTR_ERR(clk)); |
57 | return; | ||
58 | } | ||
59 | clk_prepare_enable(clk); | ||
55 | 60 | ||
56 | for (p = pdev->dev.platform_data; p->flags != 0; ++p) | 61 | for (p = pdev->dev.platform_data; p->flags != 0; ++p) |
57 | p->uartclk = clk_get_rate(clk); | 62 | p->uartclk = clk_get_rate(clk); |
58 | } | 63 | } |
59 | 64 | ||
65 | /* CPUFreq */ | ||
66 | static struct plat_ls1x_cpufreq ls1x_cpufreq_pdata = { | ||
67 | .clk_name = "cpu_clk", | ||
68 | .osc_clk_name = "osc_33m_clk", | ||
69 | .max_freq = 266 * 1000, | ||
70 | .min_freq = 33 * 1000, | ||
71 | }; | ||
72 | |||
73 | struct platform_device ls1x_cpufreq_pdev = { | ||
74 | .name = "ls1x-cpufreq", | ||
75 | .dev = { | ||
76 | .platform_data = &ls1x_cpufreq_pdata, | ||
77 | }, | ||
78 | }; | ||
79 | |||
60 | /* Synopsys Ethernet GMAC */ | 80 | /* Synopsys Ethernet GMAC */ |
81 | static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { | ||
82 | .phy_mask = 0, | ||
83 | }; | ||
84 | |||
85 | static struct stmmac_dma_cfg ls1x_eth_dma_cfg = { | ||
86 | .pbl = 1, | ||
87 | }; | ||
88 | |||
89 | int ls1x_eth_mux_init(struct platform_device *pdev, void *priv) | ||
90 | { | ||
91 | struct plat_stmmacenet_data *plat_dat = NULL; | ||
92 | u32 val; | ||
93 | |||
94 | val = __raw_readl(LS1X_MUX_CTRL1); | ||
95 | |||
96 | plat_dat = dev_get_platdata(&pdev->dev); | ||
97 | if (plat_dat->bus_id) { | ||
98 | __raw_writel(__raw_readl(LS1X_MUX_CTRL0) | GMAC1_USE_UART1 | | ||
99 | GMAC1_USE_UART0, LS1X_MUX_CTRL0); | ||
100 | switch (plat_dat->interface) { | ||
101 | case PHY_INTERFACE_MODE_RGMII: | ||
102 | val &= ~(GMAC1_USE_TXCLK | GMAC1_USE_PWM23); | ||
103 | break; | ||
104 | case PHY_INTERFACE_MODE_MII: | ||
105 | val |= (GMAC1_USE_TXCLK | GMAC1_USE_PWM23); | ||
106 | break; | ||
107 | default: | ||
108 | pr_err("unsupported mii mode %d\n", | ||
109 | plat_dat->interface); | ||
110 | return -ENOTSUPP; | ||
111 | } | ||
112 | val &= ~GMAC1_SHUT; | ||
113 | } else { | ||
114 | switch (plat_dat->interface) { | ||
115 | case PHY_INTERFACE_MODE_RGMII: | ||
116 | val &= ~(GMAC0_USE_TXCLK | GMAC0_USE_PWM01); | ||
117 | break; | ||
118 | case PHY_INTERFACE_MODE_MII: | ||
119 | val |= (GMAC0_USE_TXCLK | GMAC0_USE_PWM01); | ||
120 | break; | ||
121 | default: | ||
122 | pr_err("unsupported mii mode %d\n", | ||
123 | plat_dat->interface); | ||
124 | return -ENOTSUPP; | ||
125 | } | ||
126 | val &= ~GMAC0_SHUT; | ||
127 | } | ||
128 | __raw_writel(val, LS1X_MUX_CTRL1); | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static struct plat_stmmacenet_data ls1x_eth0_pdata = { | ||
134 | .bus_id = 0, | ||
135 | .phy_addr = -1, | ||
136 | .interface = PHY_INTERFACE_MODE_MII, | ||
137 | .mdio_bus_data = &ls1x_mdio_bus_data, | ||
138 | .dma_cfg = &ls1x_eth_dma_cfg, | ||
139 | .has_gmac = 1, | ||
140 | .tx_coe = 1, | ||
141 | .init = ls1x_eth_mux_init, | ||
142 | }; | ||
143 | |||
61 | static struct resource ls1x_eth0_resources[] = { | 144 | static struct resource ls1x_eth0_resources[] = { |
62 | [0] = { | 145 | [0] = { |
63 | .start = LS1X_GMAC0_BASE, | 146 | .start = LS1X_GMAC0_BASE, |
@@ -71,25 +154,47 @@ static struct resource ls1x_eth0_resources[] = { | |||
71 | }, | 154 | }, |
72 | }; | 155 | }; |
73 | 156 | ||
74 | static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { | 157 | struct platform_device ls1x_eth0_pdev = { |
75 | .phy_mask = 0, | 158 | .name = "stmmaceth", |
159 | .id = 0, | ||
160 | .num_resources = ARRAY_SIZE(ls1x_eth0_resources), | ||
161 | .resource = ls1x_eth0_resources, | ||
162 | .dev = { | ||
163 | .platform_data = &ls1x_eth0_pdata, | ||
164 | }, | ||
76 | }; | 165 | }; |
77 | 166 | ||
78 | static struct plat_stmmacenet_data ls1x_eth_data = { | 167 | static struct plat_stmmacenet_data ls1x_eth1_pdata = { |
79 | .bus_id = 0, | 168 | .bus_id = 1, |
80 | .phy_addr = -1, | 169 | .phy_addr = -1, |
170 | .interface = PHY_INTERFACE_MODE_MII, | ||
81 | .mdio_bus_data = &ls1x_mdio_bus_data, | 171 | .mdio_bus_data = &ls1x_mdio_bus_data, |
172 | .dma_cfg = &ls1x_eth_dma_cfg, | ||
82 | .has_gmac = 1, | 173 | .has_gmac = 1, |
83 | .tx_coe = 1, | 174 | .tx_coe = 1, |
175 | .init = ls1x_eth_mux_init, | ||
84 | }; | 176 | }; |
85 | 177 | ||
86 | struct platform_device ls1x_eth0_device = { | 178 | static struct resource ls1x_eth1_resources[] = { |
179 | [0] = { | ||
180 | .start = LS1X_GMAC1_BASE, | ||
181 | .end = LS1X_GMAC1_BASE + SZ_64K - 1, | ||
182 | .flags = IORESOURCE_MEM, | ||
183 | }, | ||
184 | [1] = { | ||
185 | .name = "macirq", | ||
186 | .start = LS1X_GMAC1_IRQ, | ||
187 | .flags = IORESOURCE_IRQ, | ||
188 | }, | ||
189 | }; | ||
190 | |||
191 | struct platform_device ls1x_eth1_pdev = { | ||
87 | .name = "stmmaceth", | 192 | .name = "stmmaceth", |
88 | .id = 0, | 193 | .id = 1, |
89 | .num_resources = ARRAY_SIZE(ls1x_eth0_resources), | 194 | .num_resources = ARRAY_SIZE(ls1x_eth1_resources), |
90 | .resource = ls1x_eth0_resources, | 195 | .resource = ls1x_eth1_resources, |
91 | .dev = { | 196 | .dev = { |
92 | .platform_data = &ls1x_eth_data, | 197 | .platform_data = &ls1x_eth1_pdata, |
93 | }, | 198 | }, |
94 | }; | 199 | }; |
95 | 200 | ||
@@ -111,7 +216,7 @@ static struct resource ls1x_ehci_resources[] = { | |||
111 | static struct usb_ehci_pdata ls1x_ehci_pdata = { | 216 | static struct usb_ehci_pdata ls1x_ehci_pdata = { |
112 | }; | 217 | }; |
113 | 218 | ||
114 | struct platform_device ls1x_ehci_device = { | 219 | struct platform_device ls1x_ehci_pdev = { |
115 | .name = "ehci-platform", | 220 | .name = "ehci-platform", |
116 | .id = -1, | 221 | .id = -1, |
117 | .num_resources = ARRAY_SIZE(ls1x_ehci_resources), | 222 | .num_resources = ARRAY_SIZE(ls1x_ehci_resources), |
@@ -123,7 +228,7 @@ struct platform_device ls1x_ehci_device = { | |||
123 | }; | 228 | }; |
124 | 229 | ||
125 | /* Real Time Clock */ | 230 | /* Real Time Clock */ |
126 | struct platform_device ls1x_rtc_device = { | 231 | struct platform_device ls1x_rtc_pdev = { |
127 | .name = "ls1x-rtc", | 232 | .name = "ls1x-rtc", |
128 | .id = -1, | 233 | .id = -1, |
129 | }; | 234 | }; |