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