Path: blob/master/arch/mips/sgi-ip22/ip22-platform.c
10818 views
#include <linux/init.h>1#include <linux/if_ether.h>2#include <linux/kernel.h>3#include <linux/platform_device.h>45#include <asm/paccess.h>6#include <asm/sgi/ip22.h>7#include <asm/sgi/hpc3.h>8#include <asm/sgi/mc.h>9#include <asm/sgi/seeq.h>10#include <asm/sgi/wd.h>1112static struct resource sgiwd93_0_resources[] = {13{14.name = "eth0 irq",15.start = SGI_WD93_0_IRQ,16.end = SGI_WD93_0_IRQ,17.flags = IORESOURCE_IRQ18}19};2021static struct sgiwd93_platform_data sgiwd93_0_pd = {22.unit = 0,23.irq = SGI_WD93_0_IRQ,24};2526static struct platform_device sgiwd93_0_device = {27.name = "sgiwd93",28.id = 0,29.num_resources = ARRAY_SIZE(sgiwd93_0_resources),30.resource = sgiwd93_0_resources,31.dev = {32.platform_data = &sgiwd93_0_pd,33},34};3536static struct resource sgiwd93_1_resources[] = {37{38.name = "eth0 irq",39.start = SGI_WD93_1_IRQ,40.end = SGI_WD93_1_IRQ,41.flags = IORESOURCE_IRQ42}43};4445static struct sgiwd93_platform_data sgiwd93_1_pd = {46.unit = 1,47.irq = SGI_WD93_1_IRQ,48};4950static struct platform_device sgiwd93_1_device = {51.name = "sgiwd93",52.id = 1,53.num_resources = ARRAY_SIZE(sgiwd93_1_resources),54.resource = sgiwd93_1_resources,55.dev = {56.platform_data = &sgiwd93_1_pd,57},58};5960/*61* Create a platform device for the GPI port that receives the62* image data from the embedded camera.63*/64static int __init sgiwd93_devinit(void)65{66int res;6768sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;69sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;7071res = platform_device_register(&sgiwd93_0_device);72if (res)73return res;7475if (!ip22_is_fullhouse())76return 0;7778sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;79sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;8081return platform_device_register(&sgiwd93_1_device);82}8384device_initcall(sgiwd93_devinit);8586static struct resource sgiseeq_0_resources[] = {87{88.name = "eth0 irq",89.start = SGI_ENET_IRQ,90.end = SGI_ENET_IRQ,91.flags = IORESOURCE_IRQ92}93};9495static struct sgiseeq_platform_data eth0_pd;9697static struct platform_device eth0_device = {98.name = "sgiseeq",99.id = 0,100.num_resources = ARRAY_SIZE(sgiseeq_0_resources),101.resource = sgiseeq_0_resources,102.dev = {103.platform_data = ð0_pd,104},105};106107static struct resource sgiseeq_1_resources[] = {108{109.name = "eth1 irq",110.start = SGI_GIO_0_IRQ,111.end = SGI_GIO_0_IRQ,112.flags = IORESOURCE_IRQ113}114};115116static struct sgiseeq_platform_data eth1_pd;117118static struct platform_device eth1_device = {119.name = "sgiseeq",120.id = 1,121.num_resources = ARRAY_SIZE(sgiseeq_1_resources),122.resource = sgiseeq_1_resources,123.dev = {124.platform_data = ð1_pd,125},126};127128/*129* Create a platform device for the GPI port that receives the130* image data from the embedded camera.131*/132static int __init sgiseeq_devinit(void)133{134unsigned int pbdma __maybe_unused;135int res, i;136137eth0_pd.hpc = hpc3c0;138eth0_pd.irq = SGI_ENET_IRQ;139#define EADDR_NVOFS 250140for (i = 0; i < 3; i++) {141unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);142143eth0_pd.mac[2 * i] = tmp >> 8;144eth0_pd.mac[2 * i + 1] = tmp & 0xff;145}146147res = platform_device_register(ð0_device);148if (res)149return res;150151/* Second HPC is missing? */152if (ip22_is_fullhouse() ||153get_dbe(pbdma, (unsigned int *)&hpc3c1->pbdma[1]))154return 0;155156sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |157SGIMC_GIOPAR_HPC264;158hpc3c1->pbus_piocfg[0][0] = 0x3ffff;159/* interrupt/config register on Challenge S Mezz board */160hpc3c1->pbus_extregs[0][0] = 0x30;161162eth1_pd.hpc = hpc3c1;163eth1_pd.irq = SGI_GIO_0_IRQ;164#define EADDR_NVOFS 250165for (i = 0; i < 3; i++) {166unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,167EADDR_NVOFS / 2 + i);168169eth1_pd.mac[2 * i] = tmp >> 8;170eth1_pd.mac[2 * i + 1] = tmp & 0xff;171}172173return platform_device_register(ð1_device);174}175176device_initcall(sgiseeq_devinit);177178static int __init sgi_hal2_devinit(void)179{180return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));181}182183device_initcall(sgi_hal2_devinit);184185static int __init sgi_button_devinit(void)186{187if (ip22_is_fullhouse())188return 0; /* full house has no volume buttons */189190return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));191}192193device_initcall(sgi_button_devinit);194195static int __init sgi_ds1286_devinit(void)196{197struct resource res;198199memset(&res, 0, sizeof(res));200res.start = HPC3_CHIP0_BASE + offsetof(struct hpc3_regs, rtcregs);201res.end = res.start + sizeof(hpc3c0->rtcregs) - 1;202res.flags = IORESOURCE_MEM;203204return IS_ERR(platform_device_register_simple("rtc-ds1286", -1,205&res, 1));206}207208device_initcall(sgi_ds1286_devinit);209210211