1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * This file is subject to the terms and conditions of the GNU General Public
3*4882a593Smuzhiyun * License. See the file "COPYING" in the main directory of this archive
4*4882a593Smuzhiyun * for more details.
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #include <linux/init.h>
10*4882a593Smuzhiyun #include <linux/kernel.h>
11*4882a593Smuzhiyun #include <linux/platform_device.h>
12*4882a593Smuzhiyun #include <bcm63xx_cpu.h>
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun static struct resource uart0_resources[] = {
15*4882a593Smuzhiyun {
16*4882a593Smuzhiyun /* start & end filled at runtime */
17*4882a593Smuzhiyun .flags = IORESOURCE_MEM,
18*4882a593Smuzhiyun },
19*4882a593Smuzhiyun {
20*4882a593Smuzhiyun /* start filled at runtime */
21*4882a593Smuzhiyun .flags = IORESOURCE_IRQ,
22*4882a593Smuzhiyun },
23*4882a593Smuzhiyun };
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun static struct resource uart1_resources[] = {
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun /* start & end filled at runtime */
28*4882a593Smuzhiyun .flags = IORESOURCE_MEM,
29*4882a593Smuzhiyun },
30*4882a593Smuzhiyun {
31*4882a593Smuzhiyun /* start filled at runtime */
32*4882a593Smuzhiyun .flags = IORESOURCE_IRQ,
33*4882a593Smuzhiyun },
34*4882a593Smuzhiyun };
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun static struct platform_device bcm63xx_uart_devices[] = {
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun .name = "bcm63xx_uart",
39*4882a593Smuzhiyun .id = 0,
40*4882a593Smuzhiyun .num_resources = ARRAY_SIZE(uart0_resources),
41*4882a593Smuzhiyun .resource = uart0_resources,
42*4882a593Smuzhiyun },
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun {
45*4882a593Smuzhiyun .name = "bcm63xx_uart",
46*4882a593Smuzhiyun .id = 1,
47*4882a593Smuzhiyun .num_resources = ARRAY_SIZE(uart1_resources),
48*4882a593Smuzhiyun .resource = uart1_resources,
49*4882a593Smuzhiyun }
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun
bcm63xx_uart_register(unsigned int id)52*4882a593Smuzhiyun int __init bcm63xx_uart_register(unsigned int id)
53*4882a593Smuzhiyun {
54*4882a593Smuzhiyun if (id >= ARRAY_SIZE(bcm63xx_uart_devices))
55*4882a593Smuzhiyun return -ENODEV;
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun if (id == 1 && (!BCMCPU_IS_3368() && !BCMCPU_IS_6358() &&
58*4882a593Smuzhiyun !BCMCPU_IS_6368()))
59*4882a593Smuzhiyun return -ENODEV;
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun if (id == 0) {
62*4882a593Smuzhiyun uart0_resources[0].start = bcm63xx_regset_address(RSET_UART0);
63*4882a593Smuzhiyun uart0_resources[0].end = uart0_resources[0].start +
64*4882a593Smuzhiyun RSET_UART_SIZE - 1;
65*4882a593Smuzhiyun uart0_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0);
66*4882a593Smuzhiyun }
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun if (id == 1) {
69*4882a593Smuzhiyun uart1_resources[0].start = bcm63xx_regset_address(RSET_UART1);
70*4882a593Smuzhiyun uart1_resources[0].end = uart1_resources[0].start +
71*4882a593Smuzhiyun RSET_UART_SIZE - 1;
72*4882a593Smuzhiyun uart1_resources[1].start = bcm63xx_get_irq_number(IRQ_UART1);
73*4882a593Smuzhiyun }
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun return platform_device_register(&bcm63xx_uart_devices[id]);
76*4882a593Smuzhiyun }
77