Path: blob/master/arch/xtensa/platforms/s6105/device.c
15118 views
/*1* s6105 platform devices2*3* Copyright (c) 2009 emlix GmbH4*/56#include <linux/kernel.h>7#include <linux/gpio.h>8#include <linux/init.h>9#include <linux/irq.h>10#include <linux/phy.h>11#include <linux/platform_device.h>12#include <linux/serial.h>13#include <linux/serial_8250.h>1415#include <variant/hardware.h>16#include <variant/dmac.h>1718#include <platform/gpio.h>1920#define GPIO3_INTNUM 321#define UART_INTNUM 422#define GMAC_INTNUM 52324static const signed char gpio3_irq_mappings[] = {25S6_INTC_GPIO(3),26-127};2829static const signed char uart_irq_mappings[] = {30S6_INTC_UART(0),31S6_INTC_UART(1),32-1,33};3435static const signed char gmac_irq_mappings[] = {36S6_INTC_GMAC_STAT,37S6_INTC_GMAC_ERR,38S6_INTC_DMA_HOSTTERMCNT(0),39S6_INTC_DMA_HOSTTERMCNT(1),40-141};4243const signed char *platform_irq_mappings[NR_IRQS] = {44[GPIO3_INTNUM] = gpio3_irq_mappings,45[UART_INTNUM] = uart_irq_mappings,46[GMAC_INTNUM] = gmac_irq_mappings,47};4849static struct plat_serial8250_port serial_platform_data[] = {50{51.membase = (void *)S6_REG_UART + 0x0000,52.mapbase = S6_REG_UART + 0x0000,53.irq = UART_INTNUM,54.uartclk = S6_SCLK,55.regshift = 2,56.iotype = SERIAL_IO_MEM,57.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST,58},59{60.membase = (void *)S6_REG_UART + 0x1000,61.mapbase = S6_REG_UART + 0x1000,62.irq = UART_INTNUM,63.uartclk = S6_SCLK,64.regshift = 2,65.iotype = SERIAL_IO_MEM,66.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST,67},68{ },69};7071static struct resource s6_gmac_resource[] = {72{73.name = "mem",74.start = (resource_size_t)S6_REG_GMAC,75.end = (resource_size_t)S6_REG_GMAC + 0x10000 - 1,76.flags = IORESOURCE_MEM,77},78{79.name = "dma",80.start = (resource_size_t)81DMA_CHNL(S6_REG_HIFDMA, S6_HIFDMA_GMACTX),82.end = (resource_size_t)83DMA_CHNL(S6_REG_HIFDMA, S6_HIFDMA_GMACTX) + 0x100 - 1,84.flags = IORESOURCE_DMA,85},86{87.name = "dma",88.start = (resource_size_t)89DMA_CHNL(S6_REG_HIFDMA, S6_HIFDMA_GMACRX),90.end = (resource_size_t)91DMA_CHNL(S6_REG_HIFDMA, S6_HIFDMA_GMACRX) + 0x100 - 1,92.flags = IORESOURCE_DMA,93},94{95.name = "io",96.start = (resource_size_t)S6_MEM_GMAC,97.end = (resource_size_t)S6_MEM_GMAC + 0x2000000 - 1,98.flags = IORESOURCE_IO,99},100{101.name = "irq",102.start = (resource_size_t)GMAC_INTNUM,103.flags = IORESOURCE_IRQ,104},105{106.name = "irq",107.start = (resource_size_t)PHY_POLL,108.flags = IORESOURCE_IRQ,109},110};111112static int __init prepare_phy_irq(int pin)113{114int irq;115if (gpio_request(pin, "s6gmac_phy") < 0)116goto fail;117if (gpio_direction_input(pin) < 0)118goto free;119irq = gpio_to_irq(pin);120if (irq < 0)121goto free;122if (irq_set_irq_type(irq, IRQ_TYPE_LEVEL_LOW) < 0)123goto free;124return irq;125free:126gpio_free(pin);127fail:128return PHY_POLL;129}130131static struct platform_device platform_devices[] = {132{133.name = "serial8250",134.id = PLAT8250_DEV_PLATFORM,135.dev = {136.platform_data = serial_platform_data,137},138},139{140.name = "s6gmac",141.id = 0,142.resource = s6_gmac_resource,143.num_resources = ARRAY_SIZE(s6_gmac_resource),144},145{146I2C_BOARD_INFO("m41t62", S6I2C_ADDR_M41T62),147},148};149150static int __init device_init(void)151{152int i;153154s6_gmac_resource[5].start = prepare_phy_irq(GPIO_PHY_IRQ);155156for (i = 0; i < ARRAY_SIZE(platform_devices); i++)157platform_device_register(&platform_devices[i]);158return 0;159}160arch_initcall_sync(device_init);161162163