2 * s6105 platform devices
4 * Copyright (c) 2009 emlix GmbH
7 #include <linux/kernel.h>
8 #include <linux/gpio.h>
9 #include <linux/init.h>
10 #include <linux/irq.h>
11 #include <linux/phy.h>
12 #include <linux/platform_device.h>
13 #include <linux/serial.h>
14 #include <linux/serial_8250.h>
16 #include <variant/hardware.h>
17 #include <variant/dmac.h>
19 #include <platform/gpio.h>
21 #define GPIO3_INTNUM 3
25 static const signed char gpio3_irq_mappings
[] = {
30 static const signed char uart_irq_mappings
[] = {
36 static const signed char gmac_irq_mappings
[] = {
39 S6_INTC_DMA_HOSTTERMCNT(0),
40 S6_INTC_DMA_HOSTTERMCNT(1),
44 const signed char *platform_irq_mappings
[NR_IRQS
] = {
45 [GPIO3_INTNUM
] = gpio3_irq_mappings
,
46 [UART_INTNUM
] = uart_irq_mappings
,
47 [GMAC_INTNUM
] = gmac_irq_mappings
,
50 static struct plat_serial8250_port serial_platform_data
[] = {
52 .membase
= (void *)S6_REG_UART
+ 0x0000,
53 .mapbase
= S6_REG_UART
+ 0x0000,
57 .iotype
= SERIAL_IO_MEM
,
58 .flags
= ASYNC_BOOT_AUTOCONF
| ASYNC_SKIP_TEST
,
61 .membase
= (void *)S6_REG_UART
+ 0x1000,
62 .mapbase
= S6_REG_UART
+ 0x1000,
66 .iotype
= SERIAL_IO_MEM
,
67 .flags
= ASYNC_BOOT_AUTOCONF
| ASYNC_SKIP_TEST
,
72 static struct resource s6_gmac_resource
[] = {
75 .start
= (resource_size_t
)S6_REG_GMAC
,
76 .end
= (resource_size_t
)S6_REG_GMAC
+ 0x10000 - 1,
77 .flags
= IORESOURCE_MEM
,
81 .start
= (resource_size_t
)
82 DMA_CHNL(S6_REG_HIFDMA
, S6_HIFDMA_GMACTX
),
83 .end
= (resource_size_t
)
84 DMA_CHNL(S6_REG_HIFDMA
, S6_HIFDMA_GMACTX
) + 0x100 - 1,
85 .flags
= IORESOURCE_DMA
,
89 .start
= (resource_size_t
)
90 DMA_CHNL(S6_REG_HIFDMA
, S6_HIFDMA_GMACRX
),
91 .end
= (resource_size_t
)
92 DMA_CHNL(S6_REG_HIFDMA
, S6_HIFDMA_GMACRX
) + 0x100 - 1,
93 .flags
= IORESOURCE_DMA
,
97 .start
= (resource_size_t
)S6_MEM_GMAC
,
98 .end
= (resource_size_t
)S6_MEM_GMAC
+ 0x2000000 - 1,
99 .flags
= IORESOURCE_IO
,
103 .start
= (resource_size_t
)GMAC_INTNUM
,
104 .flags
= IORESOURCE_IRQ
,
108 .start
= (resource_size_t
)PHY_POLL
,
109 .flags
= IORESOURCE_IRQ
,
113 static int __init
prepare_phy_irq(int pin
)
116 if (gpio_request(pin
, "s6gmac_phy") < 0)
118 if (gpio_direction_input(pin
) < 0)
120 irq
= gpio_to_irq(pin
);
123 if (irq_set_irq_type(irq
, IRQ_TYPE_LEVEL_LOW
) < 0)
132 static struct platform_device platform_devices
[] = {
134 .name
= "serial8250",
135 .id
= PLAT8250_DEV_PLATFORM
,
137 .platform_data
= serial_platform_data
,
143 .resource
= s6_gmac_resource
,
144 .num_resources
= ARRAY_SIZE(s6_gmac_resource
),
147 I2C_BOARD_INFO("m41t62", S6I2C_ADDR_M41T62
),
151 static int __init
device_init(void)
155 s6_gmac_resource
[5].start
= prepare_phy_irq(GPIO_PHY_IRQ
);
157 for (i
= 0; i
< ARRAY_SIZE(platform_devices
); i
++)
158 platform_device_register(&platform_devices
[i
]);
161 arch_initcall_sync(device_init
);