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>
6 #include <linux/dma-mapping.h>
8 #include <asm/paccess.h>
9 #include <asm/sgi/ip22.h>
10 #include <asm/sgi/hpc3.h>
11 #include <asm/sgi/mc.h>
12 #include <asm/sgi/seeq.h>
13 #include <asm/sgi/wd.h>
15 static struct resource sgiwd93_0_resources[] = {
18 .start = SGI_WD93_0_IRQ,
19 .end = SGI_WD93_0_IRQ,
20 .flags = IORESOURCE_IRQ
24 static struct sgiwd93_platform_data sgiwd93_0_pd = {
26 .irq = SGI_WD93_0_IRQ,
29 static u64 sgiwd93_0_dma_mask = DMA_BIT_MASK(32);
31 static struct platform_device sgiwd93_0_device = {
34 .num_resources = ARRAY_SIZE(sgiwd93_0_resources),
35 .resource = sgiwd93_0_resources,
37 .platform_data = &sgiwd93_0_pd,
38 .dma_mask = &sgiwd93_0_dma_mask,
39 .coherent_dma_mask = DMA_BIT_MASK(32),
43 static struct resource sgiwd93_1_resources[] = {
46 .start = SGI_WD93_1_IRQ,
47 .end = SGI_WD93_1_IRQ,
48 .flags = IORESOURCE_IRQ
52 static struct sgiwd93_platform_data sgiwd93_1_pd = {
54 .irq = SGI_WD93_1_IRQ,
57 static u64 sgiwd93_1_dma_mask = DMA_BIT_MASK(32);
59 static struct platform_device sgiwd93_1_device = {
62 .num_resources = ARRAY_SIZE(sgiwd93_1_resources),
63 .resource = sgiwd93_1_resources,
65 .platform_data = &sgiwd93_1_pd,
66 .dma_mask = &sgiwd93_1_dma_mask,
67 .coherent_dma_mask = DMA_BIT_MASK(32),
72 * Create a platform device for the GPI port that receives the
73 * image data from the embedded camera.
75 static int __init sgiwd93_devinit(void)
79 sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;
80 sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;
82 res = platform_device_register(&sgiwd93_0_device);
86 if (!ip22_is_fullhouse())
89 sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;
90 sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;
92 return platform_device_register(&sgiwd93_1_device);
95 device_initcall(sgiwd93_devinit);
97 static struct resource sgiseeq_0_resources[] = {
100 .start = SGI_ENET_IRQ,
102 .flags = IORESOURCE_IRQ
106 static struct sgiseeq_platform_data eth0_pd;
108 static u64 sgiseeq_dma_mask = DMA_BIT_MASK(32);
110 static struct platform_device eth0_device = {
113 .num_resources = ARRAY_SIZE(sgiseeq_0_resources),
114 .resource = sgiseeq_0_resources,
116 .platform_data = ð0_pd,
117 .dma_mask = &sgiseeq_dma_mask,
118 .coherent_dma_mask = DMA_BIT_MASK(32),
122 static struct resource sgiseeq_1_resources[] = {
125 .start = SGI_GIO_0_IRQ,
126 .end = SGI_GIO_0_IRQ,
127 .flags = IORESOURCE_IRQ
131 static struct sgiseeq_platform_data eth1_pd;
133 static struct platform_device eth1_device = {
136 .num_resources = ARRAY_SIZE(sgiseeq_1_resources),
137 .resource = sgiseeq_1_resources,
139 .platform_data = ð1_pd,
144 * Create a platform device for the GPI port that receives the
145 * image data from the embedded camera.
147 static int __init sgiseeq_devinit(void)
149 unsigned int pbdma __maybe_unused;
152 eth0_pd.hpc = hpc3c0;
153 eth0_pd.irq = SGI_ENET_IRQ;
154 #define EADDR_NVOFS 250
155 for (i = 0; i < 3; i++) {
156 unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
158 eth0_pd.mac[2 * i] = tmp >> 8;
159 eth0_pd.mac[2 * i + 1] = tmp & 0xff;
162 res = platform_device_register(ð0_device);
166 /* Second HPC is missing? */
167 if (ip22_is_fullhouse() ||
168 get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1]))
171 sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |
173 hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
174 /* interrupt/config register on Challenge S Mezz board */
175 hpc3c1->pbus_extregs[0][0] = 0x30;
177 eth1_pd.hpc = hpc3c1;
178 eth1_pd.irq = SGI_GIO_0_IRQ;
179 #define EADDR_NVOFS 250
180 for (i = 0; i < 3; i++) {
181 unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,
182 EADDR_NVOFS / 2 + i);
184 eth1_pd.mac[2 * i] = tmp >> 8;
185 eth1_pd.mac[2 * i + 1] = tmp & 0xff;
188 return platform_device_register(ð1_device);
191 device_initcall(sgiseeq_devinit);
193 static int __init sgi_hal2_devinit(void)
195 return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));
198 device_initcall(sgi_hal2_devinit);
200 static int __init sgi_button_devinit(void)
202 if (ip22_is_fullhouse())
203 return 0; /* full house has no volume buttons */
205 return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
208 device_initcall(sgi_button_devinit);
210 static int __init sgi_ds1286_devinit(void)
214 memset(&res, 0, sizeof(res));
215 res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs);
216 res.end = res.start + sizeof(hpc3c0->rtcregs) - 1;
217 res.flags = IORESOURCE_MEM;
219 return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,
223 device_initcall(sgi_ds1286_devinit);