diff options
Diffstat (limited to 'arch/mips/bcm63xx/dev-enet.c')
-rw-r--r-- | arch/mips/bcm63xx/dev-enet.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/arch/mips/bcm63xx/dev-enet.c b/arch/mips/bcm63xx/dev-enet.c index 6cbaee0f6d70..52bc01df9bfe 100644 --- a/arch/mips/bcm63xx/dev-enet.c +++ b/arch/mips/bcm63xx/dev-enet.c | |||
@@ -9,10 +9,44 @@ | |||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/platform_device.h> | 11 | #include <linux/platform_device.h> |
12 | #include <linux/export.h> | ||
12 | #include <bcm63xx_dev_enet.h> | 13 | #include <bcm63xx_dev_enet.h> |
13 | #include <bcm63xx_io.h> | 14 | #include <bcm63xx_io.h> |
14 | #include <bcm63xx_regs.h> | 15 | #include <bcm63xx_regs.h> |
15 | 16 | ||
17 | #ifdef BCMCPU_RUNTIME_DETECT | ||
18 | static const unsigned long bcm6348_regs_enetdmac[] = { | ||
19 | [ENETDMAC_CHANCFG] = ENETDMAC_CHANCFG_REG, | ||
20 | [ENETDMAC_IR] = ENETDMAC_IR_REG, | ||
21 | [ENETDMAC_IRMASK] = ENETDMAC_IRMASK_REG, | ||
22 | [ENETDMAC_MAXBURST] = ENETDMAC_MAXBURST_REG, | ||
23 | }; | ||
24 | |||
25 | static const unsigned long bcm6345_regs_enetdmac[] = { | ||
26 | [ENETDMAC_CHANCFG] = ENETDMA_6345_CHANCFG_REG, | ||
27 | [ENETDMAC_IR] = ENETDMA_6345_IR_REG, | ||
28 | [ENETDMAC_IRMASK] = ENETDMA_6345_IRMASK_REG, | ||
29 | [ENETDMAC_MAXBURST] = ENETDMA_6345_MAXBURST_REG, | ||
30 | [ENETDMAC_BUFALLOC] = ENETDMA_6345_BUFALLOC_REG, | ||
31 | [ENETDMAC_RSTART] = ENETDMA_6345_RSTART_REG, | ||
32 | [ENETDMAC_FC] = ENETDMA_6345_FC_REG, | ||
33 | [ENETDMAC_LEN] = ENETDMA_6345_LEN_REG, | ||
34 | }; | ||
35 | |||
36 | const unsigned long *bcm63xx_regs_enetdmac; | ||
37 | EXPORT_SYMBOL(bcm63xx_regs_enetdmac); | ||
38 | |||
39 | static __init void bcm63xx_enetdmac_regs_init(void) | ||
40 | { | ||
41 | if (BCMCPU_IS_6345()) | ||
42 | bcm63xx_regs_enetdmac = bcm6345_regs_enetdmac; | ||
43 | else | ||
44 | bcm63xx_regs_enetdmac = bcm6348_regs_enetdmac; | ||
45 | } | ||
46 | #else | ||
47 | static __init void bcm63xx_enetdmac_regs_init(void) { } | ||
48 | #endif | ||
49 | |||
16 | static struct resource shared_res[] = { | 50 | static struct resource shared_res[] = { |
17 | { | 51 | { |
18 | .start = -1, /* filled at runtime */ | 52 | .start = -1, /* filled at runtime */ |
@@ -137,12 +171,19 @@ static int __init register_shared(void) | |||
137 | if (shared_device_registered) | 171 | if (shared_device_registered) |
138 | return 0; | 172 | return 0; |
139 | 173 | ||
174 | bcm63xx_enetdmac_regs_init(); | ||
175 | |||
140 | shared_res[0].start = bcm63xx_regset_address(RSET_ENETDMA); | 176 | shared_res[0].start = bcm63xx_regset_address(RSET_ENETDMA); |
141 | shared_res[0].end = shared_res[0].start; | 177 | shared_res[0].end = shared_res[0].start; |
142 | shared_res[0].end += (RSET_ENETDMA_SIZE) - 1; | 178 | if (BCMCPU_IS_6345()) |
179 | shared_res[0].end += (RSET_6345_ENETDMA_SIZE) - 1; | ||
180 | else | ||
181 | shared_res[0].end += (RSET_ENETDMA_SIZE) - 1; | ||
143 | 182 | ||
144 | if (BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_6368()) | 183 | if (BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_6368()) |
145 | chan_count = 32; | 184 | chan_count = 32; |
185 | else if (BCMCPU_IS_6345()) | ||
186 | chan_count = 8; | ||
146 | else | 187 | else |
147 | chan_count = 16; | 188 | chan_count = 16; |
148 | 189 | ||
@@ -172,7 +213,7 @@ int __init bcm63xx_enet_register(int unit, | |||
172 | if (unit > 1) | 213 | if (unit > 1) |
173 | return -ENODEV; | 214 | return -ENODEV; |
174 | 215 | ||
175 | if (unit == 1 && BCMCPU_IS_6338()) | 216 | if (unit == 1 && (BCMCPU_IS_6338() || BCMCPU_IS_6345())) |
176 | return -ENODEV; | 217 | return -ENODEV; |
177 | 218 | ||
178 | ret = register_shared(); | 219 | ret = register_shared(); |
@@ -213,6 +254,21 @@ int __init bcm63xx_enet_register(int unit, | |||
213 | dpd->phy_interrupt = bcm63xx_get_irq_number(IRQ_ENET_PHY); | 254 | dpd->phy_interrupt = bcm63xx_get_irq_number(IRQ_ENET_PHY); |
214 | } | 255 | } |
215 | 256 | ||
257 | dpd->dma_chan_en_mask = ENETDMAC_CHANCFG_EN_MASK; | ||
258 | dpd->dma_chan_int_mask = ENETDMAC_IR_PKTDONE_MASK; | ||
259 | if (BCMCPU_IS_6345()) { | ||
260 | dpd->dma_chan_en_mask |= ENETDMAC_CHANCFG_CHAINING_MASK; | ||
261 | dpd->dma_chan_en_mask |= ENETDMAC_CHANCFG_WRAP_EN_MASK; | ||
262 | dpd->dma_chan_en_mask |= ENETDMAC_CHANCFG_FLOWC_EN_MASK; | ||
263 | dpd->dma_chan_int_mask |= ENETDMA_IR_BUFDONE_MASK; | ||
264 | dpd->dma_chan_int_mask |= ENETDMA_IR_NOTOWNER_MASK; | ||
265 | dpd->dma_chan_width = ENETDMA_6345_CHAN_WIDTH; | ||
266 | dpd->dma_desc_shift = ENETDMA_6345_DESC_SHIFT; | ||
267 | } else { | ||
268 | dpd->dma_has_sram = true; | ||
269 | dpd->dma_chan_width = ENETDMA_CHAN_WIDTH; | ||
270 | } | ||
271 | |||
216 | ret = platform_device_register(pdev); | 272 | ret = platform_device_register(pdev); |
217 | if (ret) | 273 | if (ret) |
218 | return ret; | 274 | return ret; |
@@ -246,6 +302,11 @@ bcm63xx_enetsw_register(const struct bcm63xx_enetsw_platform_data *pd) | |||
246 | else if (BCMCPU_IS_6362() || BCMCPU_IS_6368()) | 302 | else if (BCMCPU_IS_6362() || BCMCPU_IS_6368()) |
247 | enetsw_pd.num_ports = ENETSW_PORTS_6368; | 303 | enetsw_pd.num_ports = ENETSW_PORTS_6368; |
248 | 304 | ||
305 | enetsw_pd.dma_has_sram = true; | ||
306 | enetsw_pd.dma_chan_width = ENETDMA_CHAN_WIDTH; | ||
307 | enetsw_pd.dma_chan_en_mask = ENETDMAC_CHANCFG_EN_MASK; | ||
308 | enetsw_pd.dma_chan_int_mask = ENETDMAC_IR_PKTDONE_MASK; | ||
309 | |||
249 | ret = platform_device_register(&bcm63xx_enetsw_device); | 310 | ret = platform_device_register(&bcm63xx_enetsw_device); |
250 | if (ret) | 311 | if (ret) |
251 | return ret; | 312 | return ret; |