diff options
author | Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | 2007-05-08 11:03:02 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-07-12 12:41:13 -0400 |
commit | 891649409edbed528728b4a104d29e43e9d7473a (patch) | |
tree | 837091ee652d4b6905736c8d12cdc74397d6d1b7 /arch/mips | |
parent | 8c41286edffef0d6e7fb770b178275c8beb24055 (diff) |
[MIPS] separate platform_device registration for VR41xx serial interface
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/vr41xx/common/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/vr41xx/common/siu.c | 120 |
2 files changed, 121 insertions, 1 deletions
diff --git a/arch/mips/vr41xx/common/Makefile b/arch/mips/vr41xx/common/Makefile index f842783acd86..fcf94d7b1478 100644 --- a/arch/mips/vr41xx/common/Makefile +++ b/arch/mips/vr41xx/common/Makefile | |||
@@ -2,4 +2,4 @@ | |||
2 | # Makefile for common code of the NEC VR4100 series. | 2 | # Makefile for common code of the NEC VR4100 series. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o type.o | 5 | obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o siu.o type.o |
diff --git a/arch/mips/vr41xx/common/siu.c b/arch/mips/vr41xx/common/siu.c new file mode 100644 index 000000000000..a1e774142163 --- /dev/null +++ b/arch/mips/vr41xx/common/siu.c | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | * NEC VR4100 series SIU platform device. | ||
3 | * | ||
4 | * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/ioport.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/serial_core.h> | ||
25 | |||
26 | #include <asm/cpu.h> | ||
27 | #include <asm/vr41xx/siu.h> | ||
28 | |||
29 | static unsigned int siu_type1_ports[SIU_PORTS_MAX] __initdata = { | ||
30 | PORT_VR41XX_SIU, | ||
31 | PORT_UNKNOWN, | ||
32 | }; | ||
33 | |||
34 | static struct resource siu_type1_resource[] __initdata = { | ||
35 | { | ||
36 | .start = 0x0c000000, | ||
37 | .end = 0x0c00000a, | ||
38 | .flags = IORESOURCE_MEM, | ||
39 | }, | ||
40 | { | ||
41 | .start = SIU_IRQ, | ||
42 | .end = SIU_IRQ, | ||
43 | .flags = IORESOURCE_IRQ, | ||
44 | }, | ||
45 | }; | ||
46 | |||
47 | static unsigned int siu_type2_ports[SIU_PORTS_MAX] __initdata = { | ||
48 | PORT_VR41XX_SIU, | ||
49 | PORT_VR41XX_DSIU, | ||
50 | }; | ||
51 | |||
52 | static struct resource siu_type2_resource[] __initdata = { | ||
53 | { | ||
54 | .start = 0x0f000800, | ||
55 | .end = 0x0f00080a, | ||
56 | .flags = IORESOURCE_MEM, | ||
57 | }, | ||
58 | { | ||
59 | .start = 0x0f000820, | ||
60 | .end = 0x0f000829, | ||
61 | .flags = IORESOURCE_MEM, | ||
62 | }, | ||
63 | { | ||
64 | .start = SIU_IRQ, | ||
65 | .end = SIU_IRQ, | ||
66 | .flags = IORESOURCE_IRQ, | ||
67 | }, | ||
68 | { | ||
69 | .start = DSIU_IRQ, | ||
70 | .end = DSIU_IRQ, | ||
71 | .flags = IORESOURCE_IRQ, | ||
72 | }, | ||
73 | }; | ||
74 | |||
75 | static int __init vr41xx_siu_add(void) | ||
76 | { | ||
77 | struct platform_device *pdev; | ||
78 | struct resource *res; | ||
79 | unsigned int num; | ||
80 | int retval; | ||
81 | |||
82 | pdev = platform_device_alloc("SIU", -1); | ||
83 | if (!pdev) | ||
84 | return -ENOMEM; | ||
85 | |||
86 | switch (current_cpu_data.cputype) { | ||
87 | case CPU_VR4111: | ||
88 | case CPU_VR4121: | ||
89 | pdev->dev.platform_data = siu_type1_ports; | ||
90 | res = siu_type1_resource; | ||
91 | num = ARRAY_SIZE(siu_type1_resource); | ||
92 | break; | ||
93 | case CPU_VR4122: | ||
94 | case CPU_VR4131: | ||
95 | case CPU_VR4133: | ||
96 | pdev->dev.platform_data = siu_type2_ports; | ||
97 | res = siu_type2_resource; | ||
98 | num = ARRAY_SIZE(siu_type2_resource); | ||
99 | break; | ||
100 | default: | ||
101 | retval = -ENODEV; | ||
102 | goto err_free_device; | ||
103 | } | ||
104 | |||
105 | retval = platform_device_add_resources(pdev, res, num); | ||
106 | if (retval) | ||
107 | goto err_free_device; | ||
108 | |||
109 | retval = platform_device_add(pdev); | ||
110 | if (retval) | ||
111 | goto err_free_device; | ||
112 | |||
113 | return 0; | ||
114 | |||
115 | err_free_device: | ||
116 | platform_device_put(pdev); | ||
117 | |||
118 | return retval; | ||
119 | } | ||
120 | device_initcall(vr41xx_siu_add); | ||