Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / mips / sgi-ip22 / ip22-platform.c
blob37ad267165790bde93b11d7b4ce2a7f548399fb9
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/init.h>
3 #include <linux/if_ether.h>
4 #include <linux/kernel.h>
5 #include <linux/platform_device.h>
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>
14 static struct resource sgiwd93_0_resources[] = {
16 .name = "eth0 irq",
17 .start = SGI_WD93_0_IRQ,
18 .end = SGI_WD93_0_IRQ,
19 .flags = IORESOURCE_IRQ
23 static struct sgiwd93_platform_data sgiwd93_0_pd = {
24 .unit = 0,
25 .irq = SGI_WD93_0_IRQ,
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,
38 static struct resource sgiwd93_1_resources[] = {
40 .name = "eth0 irq",
41 .start = SGI_WD93_1_IRQ,
42 .end = SGI_WD93_1_IRQ,
43 .flags = IORESOURCE_IRQ
47 static struct sgiwd93_platform_data sgiwd93_1_pd = {
48 .unit = 1,
49 .irq = SGI_WD93_1_IRQ,
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,
63 * Create a platform device for the GPI port that receives the
64 * image data from the embedded camera.
66 static int __init sgiwd93_devinit(void)
68 int res;
70 sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;
71 sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;
73 res = platform_device_register(&sgiwd93_0_device);
74 if (res)
75 return res;
77 if (!ip22_is_fullhouse())
78 return 0;
80 sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;
81 sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;
83 return platform_device_register(&sgiwd93_1_device);
86 device_initcall(sgiwd93_devinit);
88 static struct resource sgiseeq_0_resources[] = {
90 .name = "eth0 irq",
91 .start = SGI_ENET_IRQ,
92 .end = SGI_ENET_IRQ,
93 .flags = IORESOURCE_IRQ
97 static struct sgiseeq_platform_data eth0_pd;
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 = &eth0_pd,
109 static struct resource sgiseeq_1_resources[] = {
111 .name = "eth1 irq",
112 .start = SGI_GIO_0_IRQ,
113 .end = SGI_GIO_0_IRQ,
114 .flags = IORESOURCE_IRQ
118 static struct sgiseeq_platform_data eth1_pd;
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 = &eth1_pd,
131 * Create a platform device for the GPI port that receives the
132 * image data from the embedded camera.
134 static int __init sgiseeq_devinit(void)
136 unsigned int pbdma __maybe_unused;
137 int res, i;
139 eth0_pd.hpc = hpc3c0;
140 eth0_pd.irq = SGI_ENET_IRQ;
141 #define EADDR_NVOFS 250
142 for (i = 0; i < 3; i++) {
143 unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
145 eth0_pd.mac[2 * i] = tmp >> 8;
146 eth0_pd.mac[2 * i + 1] = tmp & 0xff;
149 res = platform_device_register(&eth0_device);
150 if (res)
151 return res;
153 /* Second HPC is missing? */
154 if (ip22_is_fullhouse() ||
155 get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1]))
156 return 0;
158 sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |
159 SGIMC_GIOPAR_HPC264;
160 hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
161 /* interrupt/config register on Challenge S Mezz board */
162 hpc3c1->pbus_extregs[0][0] = 0x30;
164 eth1_pd.hpc = hpc3c1;
165 eth1_pd.irq = SGI_GIO_0_IRQ;
166 #define EADDR_NVOFS 250
167 for (i = 0; i < 3; i++) {
168 unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,
169 EADDR_NVOFS / 2 + i);
171 eth1_pd.mac[2 * i] = tmp >> 8;
172 eth1_pd.mac[2 * i + 1] = tmp & 0xff;
175 return platform_device_register(&eth1_device);
178 device_initcall(sgiseeq_devinit);
180 static int __init sgi_hal2_devinit(void)
182 return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));
185 device_initcall(sgi_hal2_devinit);
187 static int __init sgi_button_devinit(void)
189 if (ip22_is_fullhouse())
190 return 0; /* full house has no volume buttons */
192 return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
195 device_initcall(sgi_button_devinit);
197 static int __init sgi_ds1286_devinit(void)
199 struct resource res;
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;
206 return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,
207 &res, 1));
210 device_initcall(sgi_ds1286_devinit);