blob: a14fd32b76bdae03383e19e35ae71e663da1c802 [file] [log] [blame]
Ralf Baechledf9f5402007-05-11 15:48:58 +01001#include <linux/init.h>
2#include <linux/if_ether.h>
3#include <linux/kernel.h>
4#include <linux/platform_device.h>
5
6#include <asm/paccess.h>
7#include <asm/sgi/ip22.h>
8#include <asm/sgi/hpc3.h>
9#include <asm/sgi/mc.h>
10#include <asm/sgi/seeq.h>
11#include <asm/sgi/wd.h>
12
13static struct resource sgiwd93_0_resources[] = {
14 {
15 .name = "eth0 irq",
16 .start = SGI_WD93_0_IRQ,
17 .end = SGI_WD93_0_IRQ,
18 .flags = IORESOURCE_IRQ
19 }
20};
21
22static struct sgiwd93_platform_data sgiwd93_0_pd = {
23 .unit = 0,
24 .irq = SGI_WD93_0_IRQ,
25};
26
27static struct platform_device sgiwd93_0_device = {
28 .name = "sgiwd93",
29 .id = 0,
30 .num_resources = ARRAY_SIZE(sgiwd93_0_resources),
31 .resource = sgiwd93_0_resources,
32 .dev = {
33 .platform_data = &sgiwd93_0_pd,
34 },
35};
36
37static struct resource sgiwd93_1_resources[] = {
38 {
39 .name = "eth0 irq",
40 .start = SGI_WD93_1_IRQ,
41 .end = SGI_WD93_1_IRQ,
42 .flags = IORESOURCE_IRQ
43 }
44};
45
46static struct sgiwd93_platform_data sgiwd93_1_pd = {
47 .unit = 1,
48 .irq = SGI_WD93_1_IRQ,
49};
50
51static struct platform_device sgiwd93_1_device = {
52 .name = "sgiwd93",
53 .id = 1,
54 .num_resources = ARRAY_SIZE(sgiwd93_1_resources),
55 .resource = sgiwd93_1_resources,
56 .dev = {
57 .platform_data = &sgiwd93_1_pd,
58 },
59};
60
61/*
62 * Create a platform device for the GPI port that receives the
63 * image data from the embedded camera.
64 */
65static int __init sgiwd93_devinit(void)
66{
67 int res;
68
69 sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;
70 sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;
71
72 res = platform_device_register(&sgiwd93_0_device);
73 if (res)
74 return res;
75
76 if (!ip22_is_fullhouse())
77 return 0;
78
79 sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;
80 sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;
81
82 return platform_device_register(&sgiwd93_1_device);
83}
84
85device_initcall(sgiwd93_devinit);
86
87static struct resource sgiseeq_0_resources[] = {
88 {
89 .name = "eth0 irq",
90 .start = SGI_ENET_IRQ,
91 .end = SGI_ENET_IRQ,
92 .flags = IORESOURCE_IRQ
93 }
94};
95
96static struct sgiseeq_platform_data eth0_pd;
97
98static struct platform_device eth0_device = {
99 .name = "sgiseeq",
100 .id = 0,
101 .num_resources = ARRAY_SIZE(sgiseeq_0_resources),
102 .resource = sgiseeq_0_resources,
103 .dev = {
104 .platform_data = &eth0_pd,
105 },
106};
107
108static struct resource sgiseeq_1_resources[] = {
109 {
110 .name = "eth1 irq",
111 .start = SGI_GIO_0_IRQ,
112 .end = SGI_GIO_0_IRQ,
113 .flags = IORESOURCE_IRQ
114 }
115};
116
117static struct sgiseeq_platform_data eth1_pd;
118
119static struct platform_device eth1_device = {
120 .name = "sgiseeq",
121 .id = 1,
122 .num_resources = ARRAY_SIZE(sgiseeq_1_resources),
123 .resource = sgiseeq_1_resources,
124 .dev = {
125 .platform_data = &eth1_pd,
126 },
127};
128
129/*
130 * Create a platform device for the GPI port that receives the
131 * image data from the embedded camera.
132 */
133static int __init sgiseeq_devinit(void)
134{
Ralf Baechle3be1afc2011-03-29 11:06:49 +0200135 unsigned int pbdma __maybe_unused;
Ralf Baechledf9f5402007-05-11 15:48:58 +0100136 int res, i;
137
138 eth0_pd.hpc = hpc3c0;
139 eth0_pd.irq = SGI_ENET_IRQ;
Ralf Baechle70342282013-01-22 12:59:30 +0100140#define EADDR_NVOFS 250
Ralf Baechledf9f5402007-05-11 15:48:58 +0100141 for (i = 0; i < 3; i++) {
142 unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
143
144 eth0_pd.mac[2 * i] = tmp >> 8;
145 eth0_pd.mac[2 * i + 1] = tmp & 0xff;
146 }
147
148 res = platform_device_register(&eth0_device);
149 if (res)
150 return res;
151
152 /* Second HPC is missing? */
Thomas Bogendoerfer4a911b12008-09-04 23:05:45 +0200153 if (ip22_is_fullhouse() ||
Ralf Baechle3be1afc2011-03-29 11:06:49 +0200154 get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1]))
Ralf Baechledf9f5402007-05-11 15:48:58 +0100155 return 0;
156
157 sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |
Ralf Baechle70342282013-01-22 12:59:30 +0100158 SGIMC_GIOPAR_HPC264;
Ralf Baechledf9f5402007-05-11 15:48:58 +0100159 hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
160 /* interrupt/config register on Challenge S Mezz board */
161 hpc3c1->pbus_extregs[0][0] = 0x30;
162
163 eth1_pd.hpc = hpc3c1;
164 eth1_pd.irq = SGI_GIO_0_IRQ;
Ralf Baechle70342282013-01-22 12:59:30 +0100165#define EADDR_NVOFS 250
Ralf Baechledf9f5402007-05-11 15:48:58 +0100166 for (i = 0; i < 3; i++) {
167 unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,
Ralf Baechle70342282013-01-22 12:59:30 +0100168 EADDR_NVOFS / 2 + i);
Ralf Baechledf9f5402007-05-11 15:48:58 +0100169
170 eth1_pd.mac[2 * i] = tmp >> 8;
171 eth1_pd.mac[2 * i + 1] = tmp & 0xff;
172 }
173
174 return platform_device_register(&eth1_device);
175}
176
177device_initcall(sgiseeq_devinit);
Thomas Bogendoerfer5b438c42008-07-10 20:29:55 +0200178
179static int __init sgi_hal2_devinit(void)
180{
181 return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));
182}
183
184device_initcall(sgi_hal2_devinit);
Thomas Bogendoerferb03d7b12008-07-11 23:03:03 +0200185
186static int __init sgi_button_devinit(void)
187{
188 if (ip22_is_fullhouse())
189 return 0; /* full house has no volume buttons */
190
Thomas Bogendoerfer5a334fa2008-07-16 15:18:54 +0200191 return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
Thomas Bogendoerferb03d7b12008-07-11 23:03:03 +0200192}
193
194device_initcall(sgi_button_devinit);
Thomas Bogendoerfer7d81a5e2008-10-14 17:16:55 +0200195
196static int __init sgi_ds1286_devinit(void)
197{
198 struct resource res;
199
200 memset(&res, 0, sizeof(res));
201 res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs);
202 res.end = res.start + sizeof(hpc3c0->rtcregs) - 1;
203 res.flags = IORESOURCE_MEM;
204
205 return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,
206 &res, 1));
207}
208
209device_initcall(sgi_ds1286_devinit);