1*b2441318SGreg 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> 6df9f5408SRalf Baechle 7df9f5408SRalf Baechle #include <asm/paccess.h> 8df9f5408SRalf Baechle #include <asm/sgi/ip22.h> 9df9f5408SRalf Baechle #include <asm/sgi/hpc3.h> 10df9f5408SRalf Baechle #include <asm/sgi/mc.h> 11df9f5408SRalf Baechle #include <asm/sgi/seeq.h> 12df9f5408SRalf Baechle #include <asm/sgi/wd.h> 13df9f5408SRalf Baechle 14df9f5408SRalf Baechle static struct resource sgiwd93_0_resources[] = { 15df9f5408SRalf Baechle { 16df9f5408SRalf Baechle .name = "eth0 irq", 17df9f5408SRalf Baechle .start = SGI_WD93_0_IRQ, 18df9f5408SRalf Baechle .end = SGI_WD93_0_IRQ, 19df9f5408SRalf Baechle .flags = IORESOURCE_IRQ 20df9f5408SRalf Baechle } 21df9f5408SRalf Baechle }; 22df9f5408SRalf Baechle 23df9f5408SRalf Baechle static struct sgiwd93_platform_data sgiwd93_0_pd = { 24df9f5408SRalf Baechle .unit = 0, 25df9f5408SRalf Baechle .irq = SGI_WD93_0_IRQ, 26df9f5408SRalf Baechle }; 27df9f5408SRalf Baechle 28df9f5408SRalf Baechle static struct platform_device sgiwd93_0_device = { 29df9f5408SRalf Baechle .name = "sgiwd93", 30df9f5408SRalf Baechle .id = 0, 31df9f5408SRalf Baechle .num_resources = ARRAY_SIZE(sgiwd93_0_resources), 32df9f5408SRalf Baechle .resource = sgiwd93_0_resources, 33df9f5408SRalf Baechle .dev = { 34df9f5408SRalf Baechle .platform_data = &sgiwd93_0_pd, 35df9f5408SRalf Baechle }, 36df9f5408SRalf Baechle }; 37df9f5408SRalf Baechle 38df9f5408SRalf Baechle static struct resource sgiwd93_1_resources[] = { 39df9f5408SRalf Baechle { 40df9f5408SRalf Baechle .name = "eth0 irq", 41df9f5408SRalf Baechle .start = SGI_WD93_1_IRQ, 42df9f5408SRalf Baechle .end = SGI_WD93_1_IRQ, 43df9f5408SRalf Baechle .flags = IORESOURCE_IRQ 44df9f5408SRalf Baechle } 45df9f5408SRalf Baechle }; 46df9f5408SRalf Baechle 47df9f5408SRalf Baechle static struct sgiwd93_platform_data sgiwd93_1_pd = { 48df9f5408SRalf Baechle .unit = 1, 49df9f5408SRalf Baechle .irq = SGI_WD93_1_IRQ, 50df9f5408SRalf Baechle }; 51df9f5408SRalf Baechle 52df9f5408SRalf Baechle static struct platform_device sgiwd93_1_device = { 53df9f5408SRalf Baechle .name = "sgiwd93", 54df9f5408SRalf Baechle .id = 1, 55df9f5408SRalf Baechle .num_resources = ARRAY_SIZE(sgiwd93_1_resources), 56df9f5408SRalf Baechle .resource = sgiwd93_1_resources, 57df9f5408SRalf Baechle .dev = { 58df9f5408SRalf Baechle .platform_data = &sgiwd93_1_pd, 59df9f5408SRalf Baechle }, 60df9f5408SRalf Baechle }; 61df9f5408SRalf Baechle 62df9f5408SRalf Baechle /* 63df9f5408SRalf Baechle * Create a platform device for the GPI port that receives the 64df9f5408SRalf Baechle * image data from the embedded camera. 65df9f5408SRalf Baechle */ 66df9f5408SRalf Baechle static int __init sgiwd93_devinit(void) 67df9f5408SRalf Baechle { 68df9f5408SRalf Baechle int res; 69df9f5408SRalf Baechle 70df9f5408SRalf Baechle sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0; 71df9f5408SRalf Baechle sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext; 72df9f5408SRalf Baechle 73df9f5408SRalf Baechle res = platform_device_register(&sgiwd93_0_device); 74df9f5408SRalf Baechle if (res) 75df9f5408SRalf Baechle return res; 76df9f5408SRalf Baechle 77df9f5408SRalf Baechle if (!ip22_is_fullhouse()) 78df9f5408SRalf Baechle return 0; 79df9f5408SRalf Baechle 80df9f5408SRalf Baechle sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1; 81df9f5408SRalf Baechle sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext; 82df9f5408SRalf Baechle 83df9f5408SRalf Baechle return platform_device_register(&sgiwd93_1_device); 84df9f5408SRalf Baechle } 85df9f5408SRalf Baechle 86df9f5408SRalf Baechle device_initcall(sgiwd93_devinit); 87df9f5408SRalf Baechle 88df9f5408SRalf Baechle static struct resource sgiseeq_0_resources[] = { 89df9f5408SRalf Baechle { 90df9f5408SRalf Baechle .name = "eth0 irq", 91df9f5408SRalf Baechle .start = SGI_ENET_IRQ, 92df9f5408SRalf Baechle .end = SGI_ENET_IRQ, 93df9f5408SRalf Baechle .flags = IORESOURCE_IRQ 94df9f5408SRalf Baechle } 95df9f5408SRalf Baechle }; 96df9f5408SRalf Baechle 97df9f5408SRalf Baechle static struct sgiseeq_platform_data eth0_pd; 98df9f5408SRalf Baechle 99df9f5408SRalf Baechle static struct platform_device eth0_device = { 100df9f5408SRalf Baechle .name = "sgiseeq", 101df9f5408SRalf Baechle .id = 0, 102df9f5408SRalf Baechle .num_resources = ARRAY_SIZE(sgiseeq_0_resources), 103df9f5408SRalf Baechle .resource = sgiseeq_0_resources, 104df9f5408SRalf Baechle .dev = { 105df9f5408SRalf Baechle .platform_data = ð0_pd, 106df9f5408SRalf Baechle }, 107df9f5408SRalf Baechle }; 108df9f5408SRalf Baechle 109df9f5408SRalf Baechle static struct resource sgiseeq_1_resources[] = { 110df9f5408SRalf Baechle { 111df9f5408SRalf Baechle .name = "eth1 irq", 112df9f5408SRalf Baechle .start = SGI_GIO_0_IRQ, 113df9f5408SRalf Baechle .end = SGI_GIO_0_IRQ, 114df9f5408SRalf Baechle .flags = IORESOURCE_IRQ 115df9f5408SRalf Baechle } 116df9f5408SRalf Baechle }; 117df9f5408SRalf Baechle 118df9f5408SRalf Baechle static struct sgiseeq_platform_data eth1_pd; 119df9f5408SRalf Baechle 120df9f5408SRalf Baechle static struct platform_device eth1_device = { 121df9f5408SRalf Baechle .name = "sgiseeq", 122df9f5408SRalf Baechle .id = 1, 123df9f5408SRalf Baechle .num_resources = ARRAY_SIZE(sgiseeq_1_resources), 124df9f5408SRalf Baechle .resource = sgiseeq_1_resources, 125df9f5408SRalf Baechle .dev = { 126df9f5408SRalf Baechle .platform_data = ð1_pd, 127df9f5408SRalf Baechle }, 128df9f5408SRalf Baechle }; 129df9f5408SRalf Baechle 130df9f5408SRalf Baechle /* 131df9f5408SRalf Baechle * Create a platform device for the GPI port that receives the 132df9f5408SRalf Baechle * image data from the embedded camera. 133df9f5408SRalf Baechle */ 134df9f5408SRalf Baechle static int __init sgiseeq_devinit(void) 135df9f5408SRalf Baechle { 1363be1afc8SRalf Baechle unsigned int pbdma __maybe_unused; 137df9f5408SRalf Baechle int res, i; 138df9f5408SRalf Baechle 139df9f5408SRalf Baechle eth0_pd.hpc = hpc3c0; 140df9f5408SRalf Baechle eth0_pd.irq = SGI_ENET_IRQ; 141df9f5408SRalf Baechle #define EADDR_NVOFS 250 142df9f5408SRalf Baechle for (i = 0; i < 3; i++) { 143df9f5408SRalf Baechle unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i); 144df9f5408SRalf Baechle 145df9f5408SRalf Baechle eth0_pd.mac[2 * i] = tmp >> 8; 146df9f5408SRalf Baechle eth0_pd.mac[2 * i + 1] = tmp & 0xff; 147df9f5408SRalf Baechle } 148df9f5408SRalf Baechle 149df9f5408SRalf Baechle res = platform_device_register(ð0_device); 150df9f5408SRalf Baechle if (res) 151df9f5408SRalf Baechle return res; 152df9f5408SRalf Baechle 153df9f5408SRalf Baechle /* Second HPC is missing? */ 1544a911b1eSThomas Bogendoerfer if (ip22_is_fullhouse() || 1553be1afc8SRalf Baechle get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1])) 156df9f5408SRalf Baechle return 0; 157df9f5408SRalf Baechle 158df9f5408SRalf Baechle sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 | 159df9f5408SRalf Baechle SGIMC_GIOPAR_HPC264; 160df9f5408SRalf Baechle hpc3c1->pbus_piocfg[0][0] = 0x3ffff; 161df9f5408SRalf Baechle /* interrupt/config register on Challenge S Mezz board */ 162df9f5408SRalf Baechle hpc3c1->pbus_extregs[0][0] = 0x30; 163df9f5408SRalf Baechle 164df9f5408SRalf Baechle eth1_pd.hpc = hpc3c1; 165df9f5408SRalf Baechle eth1_pd.irq = SGI_GIO_0_IRQ; 166df9f5408SRalf Baechle #define EADDR_NVOFS 250 167df9f5408SRalf Baechle for (i = 0; i < 3; i++) { 168df9f5408SRalf Baechle unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom, 169df9f5408SRalf Baechle EADDR_NVOFS / 2 + i); 170df9f5408SRalf Baechle 171df9f5408SRalf Baechle eth1_pd.mac[2 * i] = tmp >> 8; 172df9f5408SRalf Baechle eth1_pd.mac[2 * i + 1] = tmp & 0xff; 173df9f5408SRalf Baechle } 174df9f5408SRalf Baechle 175df9f5408SRalf Baechle return platform_device_register(ð1_device); 176df9f5408SRalf Baechle } 177df9f5408SRalf Baechle 178df9f5408SRalf Baechle device_initcall(sgiseeq_devinit); 1795b438c44SThomas Bogendoerfer 1805b438c44SThomas Bogendoerfer static int __init sgi_hal2_devinit(void) 1815b438c44SThomas Bogendoerfer { 1825b438c44SThomas Bogendoerfer return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0)); 1835b438c44SThomas Bogendoerfer } 1845b438c44SThomas Bogendoerfer 1855b438c44SThomas Bogendoerfer device_initcall(sgi_hal2_devinit); 186b03d7b18SThomas Bogendoerfer 187b03d7b18SThomas Bogendoerfer static int __init sgi_button_devinit(void) 188b03d7b18SThomas Bogendoerfer { 189b03d7b18SThomas Bogendoerfer if (ip22_is_fullhouse()) 190b03d7b18SThomas Bogendoerfer return 0; /* full house has no volume buttons */ 191b03d7b18SThomas Bogendoerfer 1925a334fa9SThomas Bogendoerfer return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0)); 193b03d7b18SThomas Bogendoerfer } 194b03d7b18SThomas Bogendoerfer 195b03d7b18SThomas Bogendoerfer device_initcall(sgi_button_devinit); 1967d81a5e0SThomas Bogendoerfer 1977d81a5e0SThomas Bogendoerfer static int __init sgi_ds1286_devinit(void) 1987d81a5e0SThomas Bogendoerfer { 1997d81a5e0SThomas Bogendoerfer struct resource res; 2007d81a5e0SThomas Bogendoerfer 2017d81a5e0SThomas Bogendoerfer memset(&res, 0, sizeof(res)); 2027d81a5e0SThomas Bogendoerfer res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs); 2037d81a5e0SThomas Bogendoerfer res.end = res.start + sizeof(hpc3c0->rtcregs) - 1; 2047d81a5e0SThomas Bogendoerfer res.flags = IORESOURCE_MEM; 2057d81a5e0SThomas Bogendoerfer 2067d81a5e0SThomas Bogendoerfer return IS_ERR(platform_device_register_simple("rtc-ds1286", -1, 2077d81a5e0SThomas Bogendoerfer &res, 1)); 2087d81a5e0SThomas Bogendoerfer } 2097d81a5e0SThomas Bogendoerfer 2107d81a5e0SThomas Bogendoerfer device_initcall(sgi_ds1286_devinit); 211