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