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