diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-21 14:07:35 +0800 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-22 18:30:51 +0800 |
commit | 6f3aa8231064b9ea0b165423702265a7989294b7 (patch) | |
tree | 601fce4421191bed7dd4ee0f062e87237909a0fe /arch/arm/mach-at91/at91sam9260_devices.c | |
parent | 4b193e0755e6a3ca580dd08c4633b79312e72cd4 (diff) | |
download | barebox-6f3aa8231064b9ea0b165423702265a7989294b7.tar.gz barebox-6f3aa8231064b9ea0b165423702265a7989294b7.tar.xz |
at91: switch to add_generic_device
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'arch/arm/mach-at91/at91sam9260_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 209 |
1 files changed, 38 insertions, 171 deletions
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 3808c66e89..468f00d6be 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c @@ -31,21 +31,6 @@ void at91_add_device_sdram(u32 size) } #if defined(CONFIG_DRIVER_NET_MACB) -static struct resource eth_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_EMAC, - .size = 0x1000, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d macb_dev = { - .id = -1, - .name = "macb", - .resource = eth_resources, - .num_resources = ARRAY_SIZE(eth_resources), -}; - void at91_add_device_eth(struct at91_ether_platform_data *data) { if (!data) @@ -74,29 +59,14 @@ void at91_add_device_eth(struct at91_ether_platform_data *data) at91_set_B_periph(AT91_PIN_PA22, 0); /* ETXER */ } - macb_dev.platform_data = data; - register_device(&macb_dev); + add_generic_device("macb", 0, NULL, AT91SAM9260_BASE_EMAC, 0x1000, + IORESOURCE_MEM, data); } #else void at91_add_device_eth(struct at91_ether_platform_data *data) {} #endif #if defined(CONFIG_NAND_ATMEL) -static struct resource nand_resources[] = { - [0] = { - .start = AT91_CHIPSELECT_3, - .size = 0x10, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d nand_dev = { - .id = -1, - .name = "atmel_nand", - .resource = nand_resources, - .num_resources = ARRAY_SIZE(nand_resources), -}; - void at91_add_device_nand(struct atmel_nand_data *data) { unsigned long csa; @@ -119,49 +89,19 @@ void at91_add_device_nand(struct atmel_nand_data *data) if (data->det_pin) at91_set_gpio_input(data->det_pin, 1); - nand_dev.platform_data = data; - register_device(&nand_dev); + add_generic_device("atmel_nand", 0, NULL, AT91_CHIPSELECT_3, 0x10, + IORESOURCE_MEM, data); } #else void at91_add_device_nand(struct atmel_nand_data *data) {} #endif -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_BASE_SYS + AT91_DBGU, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d dbgu_serial_device = { - .id = 0, - .name = "atmel_serial", - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), -}; - static inline void configure_dbgu_pins(void) { at91_set_A_periph(AT91_PIN_PB14, 0); /* DRXD */ at91_set_A_periph(AT91_PIN_PB15, 1); /* DTXD */ } -static struct resource uart0_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US0, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d uart0_serial_device = { - .id = 1, - .name = "atmel_serial", - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), -}; - static inline void configure_usart0_pins(unsigned pins) { at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD0 */ @@ -181,21 +121,6 @@ static inline void configure_usart0_pins(unsigned pins) at91_set_A_periph(AT91_PIN_PB25, 0); /* RI0 */ } -static struct resource uart1_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US1, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d uart1_serial_device = { - .id = 2, - .name = "atmel_serial", - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), -}; - static inline void configure_usart1_pins(unsigned pins) { at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD1 */ @@ -207,21 +132,6 @@ static inline void configure_usart1_pins(unsigned pins) at91_set_A_periph(AT91_PIN_PB29, 0); /* CTS1 */ } -static struct resource uart2_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US2, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d uart2_serial_device = { - .id = 3, - .name = "atmel_serial", - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - static inline void configure_usart2_pins(unsigned pins) { at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD2 */ @@ -233,21 +143,6 @@ static inline void configure_usart2_pins(unsigned pins) at91_set_A_periph(AT91_PIN_PA5, 0); /* CTS2 */ } -static struct resource uart3_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US3, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d uart3_serial_device = { - .id = 4, - .name = "atmel_serial", - .resource = uart3_resources, - .num_resources = ARRAY_SIZE(uart3_resources), -}; - static inline void configure_usart3_pins(unsigned pins) { at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD3 */ @@ -259,42 +154,12 @@ static inline void configure_usart3_pins(unsigned pins) at91_set_B_periph(AT91_PIN_PC10, 0); /* CTS3 */ } -static struct resource uart4_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US4, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d uart4_serial_device = { - .id = 5, - .name = "atmel_serial", - .resource = uart4_resources, - .num_resources = ARRAY_SIZE(uart4_resources), -}; - static inline void configure_usart4_pins(void) { at91_set_B_periph(AT91_PIN_PA31, 1); /* TXD4 */ at91_set_B_periph(AT91_PIN_PA30, 0); /* RXD4 */ } -static struct resource uart5_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US5, - .size = 4096, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d uart5_serial_device = { - .id = 6, - .name = "atmel_serial", - .resource = uart5_resources, - .num_resources = ARRAY_SIZE(uart5_resources), -}; - static inline void configure_usart5_pins(void) { at91_set_A_periph(AT91_PIN_PB12, 1); /* TXD5 */ @@ -303,66 +168,68 @@ static inline void configure_usart5_pins(void) void at91_register_uart(unsigned id, unsigned pins) { + resource_size_t start; + struct device_d *dev; + char* clk_name; + switch (id) { case 0: /* DBGU */ configure_dbgu_pins(); - at91_clock_associate("mck", &dbgu_serial_device, "usart"); - register_device(&dbgu_serial_device); + start = AT91_BASE_SYS + AT91_DBGU; + clk_name = "mck"; + id = 0; break; case AT91SAM9260_ID_US0: configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &uart0_serial_device, "usart"); - register_device(&uart0_serial_device); + clk_name = "usart0_clk"; + start = AT91SAM9260_BASE_US0; + id = 1; break; case AT91SAM9260_ID_US1: configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &uart1_serial_device, "usart"); - register_device(&uart1_serial_device); + clk_name = "usart1_clk"; + start = AT91SAM9260_BASE_US1; + id = 2; break; case AT91SAM9260_ID_US2: configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &uart2_serial_device, "usart"); - register_device(&uart2_serial_device); + clk_name = "usart2_clk"; + start = AT91SAM9260_BASE_US2; + id = 3; break; case AT91SAM9260_ID_US3: configure_usart3_pins(pins); - at91_clock_associate("usart3_clk", &uart3_serial_device, "usart"); - register_device(&uart3_serial_device); + clk_name = "usart3_clk"; + start = AT91SAM9260_BASE_US3; + id = 4; break; case AT91SAM9260_ID_US4: configure_usart4_pins(); - at91_clock_associate("usart4_clk", &uart4_serial_device, "usart"); - register_device(&uart4_serial_device); + clk_name = "usart4_clk"; + start = AT91SAM9260_BASE_US4; + id = 5; break; case AT91SAM9260_ID_US5: configure_usart5_pins(); - at91_clock_associate("usart5_clk", &uart5_serial_device, "usart"); - register_device(&uart5_serial_device); + clk_name = "usart5_clk"; + start = AT91SAM9260_BASE_US5; + id = 6; break; default: return; } + + dev = add_generic_device("atmel_serial", id, NULL, start, 4096, + IORESOURCE_MEM, NULL); + at91_clock_associate(clk_name, dev, "usart"); } #if defined(CONFIG_MCI_ATMEL) -static struct resource mci_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_MCI, - .size = SZ_16K, - .flags = IORESOURCE_MEM, - }, -}; - -static struct device_d mci_device = { - .id = -1, - .name = "atmel_mci", - .num_resources = ARRAY_SIZE(mci_resources), - .resource = mci_resources, -}; - /* Consider only one slot : slot 0 */ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) { + struct device_d *dev; + if (!data) return; @@ -393,9 +260,9 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) at91_set_A_periph(AT91_PIN_PA11, 1); } - mci_device.platform_data = data; - at91_clock_associate("mci_clk", &mci_device, "mci_clk"); - register_device(&mci_device); + dev = add_generic_device("atmel_mci", 0, NULL, AT91SAM9260_BASE_MCI, SZ_16K, + IORESOURCE_MEM, data); + at91_clock_associate("mci_clk", dev, "mci_clk"); } #else void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {} |