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