Skip to content

Commit 524ef29

Browse files
mbizonfreeboxralfbaechle
authored andcommitted
MIPS: BCM63xx: Add support for second uart.
The BCm63xx SOC has two uarts. Some boards use the second one for bluetooth. This patch changes platform device registration code to handle this. Changes to the UART driver were already merged in 6a2c7ea. Signed-off-by: Maxime Bizon <mbizon@freebox.fr> To: linux-mips@linux-mips.org Cc: Maxime Bizon <mbizon@freebox.fr> Patchwork: http://patchwork.linux-mips.org/patch/900/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 97befcf commit 524ef29

6 files changed

Lines changed: 102 additions & 19 deletions

File tree

‎arch/mips/bcm63xx/boards/board_bcm963xx.c‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <asm/addrspace.h>
1919
#include <bcm63xx_board.h>
2020
#include <bcm63xx_cpu.h>
21+
#include <bcm63xx_dev_uart.h>
2122
#include <bcm63xx_regs.h>
2223
#include <bcm63xx_io.h>
2324
#include <bcm63xx_dev_pci.h>
@@ -40,6 +41,7 @@ static struct board_info __initdata board_96338gw = {
4041
.name = "96338GW",
4142
.expected_cpu_id = 0x6338,
4243

44+
.has_uart0 = 1,
4345
.has_enet0 = 1,
4446
.enet0 = {
4547
.force_speed_100 = 1,
@@ -82,6 +84,7 @@ static struct board_info __initdata board_96338w = {
8284
.name = "96338W",
8385
.expected_cpu_id = 0x6338,
8486

87+
.has_uart0 = 1,
8588
.has_enet0 = 1,
8689
.enet0 = {
8790
.force_speed_100 = 1,
@@ -126,6 +129,8 @@ static struct board_info __initdata board_96338w = {
126129
static struct board_info __initdata board_96345gw2 = {
127130
.name = "96345GW2",
128131
.expected_cpu_id = 0x6345,
132+
133+
.has_uart0 = 1,
129134
};
130135
#endif
131136

@@ -137,6 +142,7 @@ static struct board_info __initdata board_96348r = {
137142
.name = "96348R",
138143
.expected_cpu_id = 0x6348,
139144

145+
.has_uart0 = 1,
140146
.has_enet0 = 1,
141147
.has_pci = 1,
142148

@@ -180,6 +186,7 @@ static struct board_info __initdata board_96348gw_10 = {
180186
.name = "96348GW-10",
181187
.expected_cpu_id = 0x6348,
182188

189+
.has_uart0 = 1,
183190
.has_enet0 = 1,
184191
.has_enet1 = 1,
185192
.has_pci = 1,
@@ -239,6 +246,7 @@ static struct board_info __initdata board_96348gw_11 = {
239246
.name = "96348GW-11",
240247
.expected_cpu_id = 0x6348,
241248

249+
.has_uart0 = 1,
242250
.has_enet0 = 1,
243251
.has_enet1 = 1,
244252
.has_pci = 1,
@@ -292,6 +300,7 @@ static struct board_info __initdata board_96348gw = {
292300
.name = "96348GW",
293301
.expected_cpu_id = 0x6348,
294302

303+
.has_uart0 = 1,
295304
.has_enet0 = 1,
296305
.has_enet1 = 1,
297306
.has_pci = 1,
@@ -349,9 +358,10 @@ static struct board_info __initdata board_FAST2404 = {
349358
.name = "F@ST2404",
350359
.expected_cpu_id = 0x6348,
351360

352-
.has_enet0 = 1,
353-
.has_enet1 = 1,
354-
.has_pci = 1,
361+
.has_uart0 = 1,
362+
.has_enet0 = 1,
363+
.has_enet1 = 1,
364+
.has_pci = 1,
355365

356366
.enet0 = {
357367
.has_phy = 1,
@@ -391,6 +401,7 @@ static struct board_info __initdata board_DV201AMR = {
391401
.name = "DV201AMR",
392402
.expected_cpu_id = 0x6348,
393403

404+
.has_uart0 = 1,
394405
.has_pci = 1,
395406
.has_ohci0 = 1,
396407

@@ -410,6 +421,7 @@ static struct board_info __initdata board_96348gw_a = {
410421
.name = "96348GW-A",
411422
.expected_cpu_id = 0x6348,
412423

424+
.has_uart0 = 1,
413425
.has_enet0 = 1,
414426
.has_enet1 = 1,
415427
.has_pci = 1,
@@ -435,6 +447,7 @@ static struct board_info __initdata board_96358vw = {
435447
.name = "96358VW",
436448
.expected_cpu_id = 0x6358,
437449

450+
.has_uart0 = 1,
438451
.has_enet0 = 1,
439452
.has_enet1 = 1,
440453
.has_pci = 1,
@@ -486,6 +499,7 @@ static struct board_info __initdata board_96358vw2 = {
486499
.name = "96358VW2",
487500
.expected_cpu_id = 0x6358,
488501

502+
.has_uart0 = 1,
489503
.has_enet0 = 1,
490504
.has_enet1 = 1,
491505
.has_pci = 1,
@@ -533,6 +547,7 @@ static struct board_info __initdata board_AGPFS0 = {
533547
.name = "AGPF-S0",
534548
.expected_cpu_id = 0x6358,
535549

550+
.has_uart0 = 1,
536551
.has_enet0 = 1,
537552
.has_enet1 = 1,
538553
.has_pci = 1,
@@ -834,6 +849,12 @@ int __init board_register_devices(void)
834849
{
835850
u32 val;
836851

852+
if (board.has_uart0)
853+
bcm63xx_uart_register(0);
854+
855+
if (board.has_uart1)
856+
bcm63xx_uart_register(1);
857+
837858
if (board.has_pccard)
838859
bcm63xx_pcmcia_register();
839860

‎arch/mips/bcm63xx/cpu.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static const unsigned long bcm96338_regs_base[] = {
3636
[RSET_TIMER] = BCM_6338_TIMER_BASE,
3737
[RSET_WDT] = BCM_6338_WDT_BASE,
3838
[RSET_UART0] = BCM_6338_UART0_BASE,
39+
[RSET_UART1] = BCM_6338_UART1_BASE,
3940
[RSET_GPIO] = BCM_6338_GPIO_BASE,
4041
[RSET_SPI] = BCM_6338_SPI_BASE,
4142
[RSET_OHCI0] = BCM_6338_OHCI0_BASE,
@@ -72,6 +73,7 @@ static const unsigned long bcm96345_regs_base[] = {
7273
[RSET_TIMER] = BCM_6345_TIMER_BASE,
7374
[RSET_WDT] = BCM_6345_WDT_BASE,
7475
[RSET_UART0] = BCM_6345_UART0_BASE,
76+
[RSET_UART1] = BCM_6345_UART1_BASE,
7577
[RSET_GPIO] = BCM_6345_GPIO_BASE,
7678
[RSET_SPI] = BCM_6345_SPI_BASE,
7779
[RSET_UDC0] = BCM_6345_UDC0_BASE,
@@ -109,6 +111,7 @@ static const unsigned long bcm96348_regs_base[] = {
109111
[RSET_TIMER] = BCM_6348_TIMER_BASE,
110112
[RSET_WDT] = BCM_6348_WDT_BASE,
111113
[RSET_UART0] = BCM_6348_UART0_BASE,
114+
[RSET_UART1] = BCM_6348_UART1_BASE,
112115
[RSET_GPIO] = BCM_6348_GPIO_BASE,
113116
[RSET_SPI] = BCM_6348_SPI_BASE,
114117
[RSET_OHCI0] = BCM_6348_OHCI0_BASE,
@@ -150,6 +153,7 @@ static const unsigned long bcm96358_regs_base[] = {
150153
[RSET_TIMER] = BCM_6358_TIMER_BASE,
151154
[RSET_WDT] = BCM_6358_WDT_BASE,
152155
[RSET_UART0] = BCM_6358_UART0_BASE,
156+
[RSET_UART1] = BCM_6358_UART1_BASE,
153157
[RSET_GPIO] = BCM_6358_GPIO_BASE,
154158
[RSET_SPI] = BCM_6358_SPI_BASE,
155159
[RSET_OHCI0] = BCM_6358_OHCI0_BASE,
@@ -170,6 +174,7 @@ static const unsigned long bcm96358_regs_base[] = {
170174
static const int bcm96358_irqs[] = {
171175
[IRQ_TIMER] = BCM_6358_TIMER_IRQ,
172176
[IRQ_UART0] = BCM_6358_UART0_IRQ,
177+
[IRQ_UART1] = BCM_6358_UART1_IRQ,
173178
[IRQ_DSL] = BCM_6358_DSL_IRQ,
174179
[IRQ_ENET0] = BCM_6358_ENET0_IRQ,
175180
[IRQ_ENET1] = BCM_6358_ENET1_IRQ,

‎arch/mips/bcm63xx/dev-uart.c‎

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,65 @@
1111
#include <linux/platform_device.h>
1212
#include <bcm63xx_cpu.h>
1313

14-
static struct resource uart_resources[] = {
14+
static struct resource uart0_resources[] = {
1515
{
16-
.start = -1, /* filled at runtime */
17-
.end = -1, /* filled at runtime */
16+
/* start & end filled at runtime */
1817
.flags = IORESOURCE_MEM,
1918
},
2019
{
21-
.start = -1, /* filled at runtime */
20+
/* start filled at runtime */
2221
.flags = IORESOURCE_IRQ,
2322
},
2423
};
2524

26-
static struct platform_device bcm63xx_uart_device = {
27-
.name = "bcm63xx_uart",
28-
.id = 0,
29-
.num_resources = ARRAY_SIZE(uart_resources),
30-
.resource = uart_resources,
25+
static struct resource uart1_resources[] = {
26+
{
27+
/* start & end filled at runtime */
28+
.flags = IORESOURCE_MEM,
29+
},
30+
{
31+
/* start filled at runtime */
32+
.flags = IORESOURCE_IRQ,
33+
},
34+
};
35+
36+
static struct platform_device bcm63xx_uart_devices[] = {
37+
{
38+
.name = "bcm63xx_uart",
39+
.id = 0,
40+
.num_resources = ARRAY_SIZE(uart0_resources),
41+
.resource = uart0_resources,
42+
},
43+
44+
{
45+
.name = "bcm63xx_uart",
46+
.id = 1,
47+
.num_resources = ARRAY_SIZE(uart1_resources),
48+
.resource = uart1_resources,
49+
}
3150
};
3251

33-
int __init bcm63xx_uart_register(void)
52+
int __init bcm63xx_uart_register(unsigned int id)
3453
{
35-
uart_resources[0].start = bcm63xx_regset_address(RSET_UART0);
36-
uart_resources[0].end = uart_resources[0].start;
37-
uart_resources[0].end += RSET_UART_SIZE - 1;
38-
uart_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0);
39-
return platform_device_register(&bcm63xx_uart_device);
54+
if (id >= ARRAY_SIZE(bcm63xx_uart_devices))
55+
return -ENODEV;
56+
57+
if (id == 1 && !BCMCPU_IS_6358())
58+
return -ENODEV;
59+
60+
if (id == 0) {
61+
uart0_resources[0].start = bcm63xx_regset_address(RSET_UART0);
62+
uart0_resources[0].end = uart0_resources[0].start +
63+
RSET_UART_SIZE - 1;
64+
uart0_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0);
65+
}
66+
67+
if (id == 1) {
68+
uart1_resources[0].start = bcm63xx_regset_address(RSET_UART1);
69+
uart1_resources[0].end = uart1_resources[0].start +
70+
RSET_UART_SIZE - 1;
71+
uart1_resources[1].start = bcm63xx_get_irq_number(IRQ_UART1);
72+
}
73+
74+
return platform_device_register(&bcm63xx_uart_devices[id]);
4075
}
41-
arch_initcall(bcm63xx_uart_register);

‎arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum bcm63xx_regs_set {
8585
RSET_TIMER,
8686
RSET_WDT,
8787
RSET_UART0,
88+
RSET_UART1,
8889
RSET_GPIO,
8990
RSET_SPI,
9091
RSET_UDC0,
@@ -123,6 +124,7 @@ enum bcm63xx_regs_set {
123124
#define BCM_6338_TIMER_BASE (0xfffe0200)
124125
#define BCM_6338_WDT_BASE (0xfffe021c)
125126
#define BCM_6338_UART0_BASE (0xfffe0300)
127+
#define BCM_6338_UART1_BASE (0xdeadbeef)
126128
#define BCM_6338_GPIO_BASE (0xfffe0400)
127129
#define BCM_6338_SPI_BASE (0xfffe0c00)
128130
#define BCM_6338_UDC0_BASE (0xdeadbeef)
@@ -153,6 +155,7 @@ enum bcm63xx_regs_set {
153155
#define BCM_6345_TIMER_BASE (0xfffe0200)
154156
#define BCM_6345_WDT_BASE (0xfffe021c)
155157
#define BCM_6345_UART0_BASE (0xfffe0300)
158+
#define BCM_6345_UART1_BASE (0xdeadbeef)
156159
#define BCM_6345_GPIO_BASE (0xfffe0400)
157160
#define BCM_6345_SPI_BASE (0xdeadbeef)
158161
#define BCM_6345_UDC0_BASE (0xdeadbeef)
@@ -182,6 +185,7 @@ enum bcm63xx_regs_set {
182185
#define BCM_6348_TIMER_BASE (0xfffe0200)
183186
#define BCM_6348_WDT_BASE (0xfffe021c)
184187
#define BCM_6348_UART0_BASE (0xfffe0300)
188+
#define BCM_6348_UART1_BASE (0xdeadbeef)
185189
#define BCM_6348_GPIO_BASE (0xfffe0400)
186190
#define BCM_6348_SPI_BASE (0xfffe0c00)
187191
#define BCM_6348_UDC0_BASE (0xfffe1000)
@@ -208,6 +212,7 @@ enum bcm63xx_regs_set {
208212
#define BCM_6358_TIMER_BASE (0xfffe0040)
209213
#define BCM_6358_WDT_BASE (0xfffe005c)
210214
#define BCM_6358_UART0_BASE (0xfffe0100)
215+
#define BCM_6358_UART1_BASE (0xfffe0120)
211216
#define BCM_6358_GPIO_BASE (0xfffe0080)
212217
#define BCM_6358_SPI_BASE (0xdeadbeef)
213218
#define BCM_6358_UDC0_BASE (0xfffe0800)
@@ -246,6 +251,8 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
246251
return BCM_6338_WDT_BASE;
247252
case RSET_UART0:
248253
return BCM_6338_UART0_BASE;
254+
case RSET_UART1:
255+
return BCM_6338_UART1_BASE;
249256
case RSET_GPIO:
250257
return BCM_6338_GPIO_BASE;
251258
case RSET_SPI:
@@ -292,6 +299,8 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
292299
return BCM_6345_WDT_BASE;
293300
case RSET_UART0:
294301
return BCM_6345_UART0_BASE;
302+
case RSET_UART1:
303+
return BCM_6345_UART1_BASE;
295304
case RSET_GPIO:
296305
return BCM_6345_GPIO_BASE;
297306
case RSET_SPI:
@@ -338,6 +347,8 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
338347
return BCM_6348_WDT_BASE;
339348
case RSET_UART0:
340349
return BCM_6348_UART0_BASE;
350+
case RSET_UART1:
351+
return BCM_6348_UART1_BASE;
341352
case RSET_GPIO:
342353
return BCM_6348_GPIO_BASE;
343354
case RSET_SPI:
@@ -384,6 +395,8 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
384395
return BCM_6358_WDT_BASE;
385396
case RSET_UART0:
386397
return BCM_6358_UART0_BASE;
398+
case RSET_UART1:
399+
return BCM_6358_UART1_BASE;
387400
case RSET_GPIO:
388401
return BCM_6358_GPIO_BASE;
389402
case RSET_SPI:
@@ -429,6 +442,7 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
429442
enum bcm63xx_irq {
430443
IRQ_TIMER = 0,
431444
IRQ_UART0,
445+
IRQ_UART1,
432446
IRQ_DSL,
433447
IRQ_ENET0,
434448
IRQ_ENET1,
@@ -510,6 +524,7 @@ enum bcm63xx_irq {
510524
*/
511525
#define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
512526
#define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
527+
#define BCM_6358_UART1_IRQ (IRQ_INTERNAL_BASE + 3)
513528
#define BCM_6358_OHCI0_IRQ (IRQ_INTERNAL_BASE + 5)
514529
#define BCM_6358_ENET1_IRQ (IRQ_INTERNAL_BASE + 6)
515530
#define BCM_6358_ENET0_IRQ (IRQ_INTERNAL_BASE + 8)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef BCM63XX_DEV_UART_H_
2+
#define BCM63XX_DEV_UART_H_
3+
4+
int bcm63xx_uart_register(unsigned int id);
5+
6+
#endif /* BCM63XX_DEV_UART_H_ */

‎arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct board_info {
4545
unsigned int has_ohci0:1;
4646
unsigned int has_ehci0:1;
4747
unsigned int has_dsp:1;
48+
unsigned int has_uart0:1;
49+
unsigned int has_uart1:1;
4850

4951
/* ethernet config */
5052
struct bcm63xx_enet_platform_data enet0;

0 commit comments

Comments
 (0)