Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1 | /* |
Andrew Victor | 9d04126 | 2007-02-05 11:42:07 +0100 | [diff] [blame] | 2 | * arch/arm/mach-at91/at91sam9261_devices.c |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> |
| 5 | * Copyright (C) 2005 David Brownell |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | #include <asm/mach/arch.h> |
| 14 | #include <asm/mach/map.h> |
| 15 | |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 16 | #include <linux/dma-mapping.h> |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 17 | #include <linux/gpio.h> |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 19 | #include <linux/i2c-gpio.h> |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 20 | |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 21 | #include <linux/fb.h> |
Jan Altenberg | b8b78609 | 2007-08-03 12:14:34 +0100 | [diff] [blame] | 22 | #include <video/atmel_lcdc.h> |
| 23 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/at91sam9261.h> |
| 25 | #include <mach/at91sam9261_matrix.h> |
Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 26 | #include <mach/at91_matrix.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <mach/at91sam9_smc.h> |
Uwe Kleine-König | ac11a1d | 2013-11-14 10:49:19 +0100 | [diff] [blame] | 28 | #include <mach/hardware.h> |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 29 | |
Jean-Christophe PLAGNIOL-VILLARD | 43d2f53 | 2012-10-30 05:14:17 +0800 | [diff] [blame] | 30 | #include "board.h" |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 31 | #include "generic.h" |
Linus Walleij | cf2e933 | 2014-03-27 14:18:51 +0100 | [diff] [blame] | 32 | #include "gpio.h" |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 33 | |
| 34 | /* -------------------------------------------------------------------- |
| 35 | * USB Host |
| 36 | * -------------------------------------------------------------------- */ |
| 37 | |
| 38 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 39 | static u64 ohci_dmamask = DMA_BIT_MASK(32); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 40 | static struct at91_usbh_data usbh_data; |
| 41 | |
| 42 | static struct resource usbh_resources[] = { |
| 43 | [0] = { |
| 44 | .start = AT91SAM9261_UHP_BASE, |
| 45 | .end = AT91SAM9261_UHP_BASE + SZ_1M - 1, |
| 46 | .flags = IORESOURCE_MEM, |
| 47 | }, |
| 48 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 49 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP, |
| 50 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 51 | .flags = IORESOURCE_IRQ, |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | static struct platform_device at91sam9261_usbh_device = { |
| 56 | .name = "at91_ohci", |
| 57 | .id = -1, |
| 58 | .dev = { |
| 59 | .dma_mask = &ohci_dmamask, |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 60 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 61 | .platform_data = &usbh_data, |
| 62 | }, |
| 63 | .resource = usbh_resources, |
| 64 | .num_resources = ARRAY_SIZE(usbh_resources), |
| 65 | }; |
| 66 | |
| 67 | void __init at91_add_device_usbh(struct at91_usbh_data *data) |
| 68 | { |
Thomas Petazzoni | 1fcaea7 | 2011-07-13 11:29:18 +0200 | [diff] [blame] | 69 | int i; |
| 70 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 71 | if (!data) |
| 72 | return; |
| 73 | |
Thomas Petazzoni | 1fcaea7 | 2011-07-13 11:29:18 +0200 | [diff] [blame] | 74 | /* Enable overcurrent notification */ |
| 75 | for (i = 0; i < data->ports; i++) { |
Johan Hovold | 641f3ce | 2012-11-14 12:18:17 +0100 | [diff] [blame] | 76 | if (gpio_is_valid(data->overcurrent_pin[i])) |
Thomas Petazzoni | 1fcaea7 | 2011-07-13 11:29:18 +0200 | [diff] [blame] | 77 | at91_set_gpio_input(data->overcurrent_pin[i], 1); |
| 78 | } |
| 79 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 80 | usbh_data = *data; |
| 81 | platform_device_register(&at91sam9261_usbh_device); |
| 82 | } |
| 83 | #else |
| 84 | void __init at91_add_device_usbh(struct at91_usbh_data *data) {} |
| 85 | #endif |
| 86 | |
| 87 | |
| 88 | /* -------------------------------------------------------------------- |
| 89 | * USB Device (Gadget) |
| 90 | * -------------------------------------------------------------------- */ |
| 91 | |
Nicolas Ferre | e8c9dc9 | 2012-01-27 11:14:44 +0100 | [diff] [blame] | 92 | #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 93 | static struct at91_udc_data udc_data; |
| 94 | |
| 95 | static struct resource udc_resources[] = { |
| 96 | [0] = { |
| 97 | .start = AT91SAM9261_BASE_UDP, |
| 98 | .end = AT91SAM9261_BASE_UDP + SZ_16K - 1, |
| 99 | .flags = IORESOURCE_MEM, |
| 100 | }, |
| 101 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 102 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP, |
| 103 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 104 | .flags = IORESOURCE_IRQ, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct platform_device at91sam9261_udc_device = { |
| 109 | .name = "at91_udc", |
| 110 | .id = -1, |
| 111 | .dev = { |
| 112 | .platform_data = &udc_data, |
| 113 | }, |
| 114 | .resource = udc_resources, |
| 115 | .num_resources = ARRAY_SIZE(udc_resources), |
| 116 | }; |
| 117 | |
| 118 | void __init at91_add_device_udc(struct at91_udc_data *data) |
| 119 | { |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 120 | if (!data) |
| 121 | return; |
| 122 | |
Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 123 | if (gpio_is_valid(data->vbus_pin)) { |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 124 | at91_set_gpio_input(data->vbus_pin, 0); |
| 125 | at91_set_deglitch(data->vbus_pin, 1); |
| 126 | } |
| 127 | |
Christian Glindkamp | da7a42d | 2008-01-03 12:15:23 +0100 | [diff] [blame] | 128 | /* Pullup pin is handled internally by USB device peripheral */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 129 | |
| 130 | udc_data = *data; |
| 131 | platform_device_register(&at91sam9261_udc_device); |
| 132 | } |
| 133 | #else |
| 134 | void __init at91_add_device_udc(struct at91_udc_data *data) {} |
| 135 | #endif |
| 136 | |
| 137 | /* -------------------------------------------------------------------- |
| 138 | * MMC / SD |
| 139 | * -------------------------------------------------------------------- */ |
| 140 | |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 141 | #if IS_ENABLED(CONFIG_MMC_ATMELMCI) |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 142 | static u64 mmc_dmamask = DMA_BIT_MASK(32); |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 143 | static struct mci_platform_data mmc_data; |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 144 | |
| 145 | static struct resource mmc_resources[] = { |
| 146 | [0] = { |
| 147 | .start = AT91SAM9261_BASE_MCI, |
| 148 | .end = AT91SAM9261_BASE_MCI + SZ_16K - 1, |
| 149 | .flags = IORESOURCE_MEM, |
| 150 | }, |
| 151 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 152 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI, |
| 153 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 154 | .flags = IORESOURCE_IRQ, |
| 155 | }, |
| 156 | }; |
| 157 | |
| 158 | static struct platform_device at91sam9261_mmc_device = { |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 159 | .name = "atmel_mci", |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 160 | .id = -1, |
| 161 | .dev = { |
| 162 | .dma_mask = &mmc_dmamask, |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 163 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 164 | .platform_data = &mmc_data, |
| 165 | }, |
| 166 | .resource = mmc_resources, |
| 167 | .num_resources = ARRAY_SIZE(mmc_resources), |
| 168 | }; |
| 169 | |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 170 | void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 171 | { |
| 172 | if (!data) |
| 173 | return; |
| 174 | |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 175 | if (data->slot[0].bus_width) { |
| 176 | /* input/irq */ |
| 177 | if (gpio_is_valid(data->slot[0].detect_pin)) { |
| 178 | at91_set_gpio_input(data->slot[0].detect_pin, 1); |
| 179 | at91_set_deglitch(data->slot[0].detect_pin, 1); |
| 180 | } |
| 181 | if (gpio_is_valid(data->slot[0].wp_pin)) |
| 182 | at91_set_gpio_input(data->slot[0].wp_pin, 1); |
| 183 | |
| 184 | /* CLK */ |
| 185 | at91_set_B_periph(AT91_PIN_PA2, 0); |
| 186 | |
| 187 | /* CMD */ |
| 188 | at91_set_B_periph(AT91_PIN_PA1, 1); |
| 189 | |
| 190 | /* DAT0, maybe DAT1..DAT3 */ |
| 191 | at91_set_B_periph(AT91_PIN_PA0, 1); |
| 192 | if (data->slot[0].bus_width == 4) { |
| 193 | at91_set_B_periph(AT91_PIN_PA4, 1); |
| 194 | at91_set_B_periph(AT91_PIN_PA5, 1); |
| 195 | at91_set_B_periph(AT91_PIN_PA6, 1); |
| 196 | } |
| 197 | |
| 198 | mmc_data = *data; |
| 199 | platform_device_register(&at91sam9261_mmc_device); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 200 | } |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 201 | } |
| 202 | #else |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 203 | void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {} |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 204 | #endif |
| 205 | |
| 206 | |
| 207 | /* -------------------------------------------------------------------- |
| 208 | * NAND / SmartMedia |
| 209 | * -------------------------------------------------------------------- */ |
| 210 | |
Pieter du Preez | f6ed6f7 | 2008-08-01 10:06:40 +0100 | [diff] [blame] | 211 | #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE) |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 212 | static struct atmel_nand_data nand_data; |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 213 | |
| 214 | #define NAND_BASE AT91_CHIPSELECT_3 |
| 215 | |
| 216 | static struct resource nand_resources[] = { |
| 217 | { |
| 218 | .start = NAND_BASE, |
| 219 | .end = NAND_BASE + SZ_256M - 1, |
| 220 | .flags = IORESOURCE_MEM, |
| 221 | } |
| 222 | }; |
| 223 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 224 | static struct platform_device atmel_nand_device = { |
| 225 | .name = "atmel_nand", |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 226 | .id = -1, |
| 227 | .dev = { |
| 228 | .platform_data = &nand_data, |
| 229 | }, |
| 230 | .resource = nand_resources, |
| 231 | .num_resources = ARRAY_SIZE(nand_resources), |
| 232 | }; |
| 233 | |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 234 | void __init at91_add_device_nand(struct atmel_nand_data *data) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 235 | { |
Andrew Victor | 461d3b4 | 2008-10-06 20:01:00 +0100 | [diff] [blame] | 236 | unsigned long csa; |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 237 | |
| 238 | if (!data) |
| 239 | return; |
| 240 | |
Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 241 | csa = at91_matrix_read(AT91_MATRIX_EBICSA); |
| 242 | at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 243 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 244 | /* enable pin */ |
Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 245 | if (gpio_is_valid(data->enable_pin)) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 246 | at91_set_gpio_output(data->enable_pin, 1); |
| 247 | |
| 248 | /* ready/busy pin */ |
Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 249 | if (gpio_is_valid(data->rdy_pin)) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 250 | at91_set_gpio_input(data->rdy_pin, 1); |
| 251 | |
| 252 | /* card detect pin */ |
Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 253 | if (gpio_is_valid(data->det_pin)) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 254 | at91_set_gpio_input(data->det_pin, 1); |
| 255 | |
| 256 | at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */ |
| 257 | at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */ |
| 258 | |
| 259 | nand_data = *data; |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 260 | platform_device_register(&atmel_nand_device); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | #else |
Håvard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 264 | void __init at91_add_device_nand(struct atmel_nand_data *data) {} |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 265 | #endif |
| 266 | |
| 267 | |
| 268 | /* -------------------------------------------------------------------- |
| 269 | * TWI (i2c) |
| 270 | * -------------------------------------------------------------------- */ |
| 271 | |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 272 | /* |
| 273 | * Prefer the GPIO code since the TWI controller isn't robust |
| 274 | * (gets overruns and underruns under load) and can only issue |
| 275 | * repeated STARTs in one scenario (the driver doesn't yet handle them). |
| 276 | */ |
| 277 | #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) |
| 278 | |
| 279 | static struct i2c_gpio_platform_data pdata = { |
| 280 | .sda_pin = AT91_PIN_PA7, |
| 281 | .sda_is_open_drain = 1, |
| 282 | .scl_pin = AT91_PIN_PA8, |
| 283 | .scl_is_open_drain = 1, |
| 284 | .udelay = 2, /* ~100 kHz */ |
| 285 | }; |
| 286 | |
| 287 | static struct platform_device at91sam9261_twi_device = { |
| 288 | .name = "i2c-gpio", |
Bo Shen | 7840487 | 2012-10-15 17:30:27 +0800 | [diff] [blame] | 289 | .id = 0, |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 290 | .dev.platform_data = &pdata, |
| 291 | }; |
| 292 | |
| 293 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) |
| 294 | { |
| 295 | at91_set_GPIO_periph(AT91_PIN_PA7, 1); /* TWD (SDA) */ |
| 296 | at91_set_multi_drive(AT91_PIN_PA7, 1); |
| 297 | |
| 298 | at91_set_GPIO_periph(AT91_PIN_PA8, 1); /* TWCK (SCL) */ |
| 299 | at91_set_multi_drive(AT91_PIN_PA8, 1); |
| 300 | |
| 301 | i2c_register_board_info(0, devices, nr_devices); |
| 302 | platform_device_register(&at91sam9261_twi_device); |
| 303 | } |
| 304 | |
| 305 | #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 306 | |
| 307 | static struct resource twi_resources[] = { |
| 308 | [0] = { |
| 309 | .start = AT91SAM9261_BASE_TWI, |
| 310 | .end = AT91SAM9261_BASE_TWI + SZ_16K - 1, |
| 311 | .flags = IORESOURCE_MEM, |
| 312 | }, |
| 313 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 314 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI, |
| 315 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 316 | .flags = IORESOURCE_IRQ, |
| 317 | }, |
| 318 | }; |
| 319 | |
| 320 | static struct platform_device at91sam9261_twi_device = { |
Bo Shen | 302090a | 2012-10-15 17:30:28 +0800 | [diff] [blame] | 321 | .id = 0, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 322 | .resource = twi_resources, |
| 323 | .num_resources = ARRAY_SIZE(twi_resources), |
| 324 | }; |
| 325 | |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 326 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 327 | { |
Nikolaus Voss | fac368a | 2011-11-08 11:49:46 +0100 | [diff] [blame] | 328 | /* IP version is not the same on 9261 and g10 */ |
| 329 | if (cpu_is_at91sam9g10()) { |
| 330 | at91sam9261_twi_device.name = "i2c-at91sam9g10"; |
Ludovic Desroches | 94e7346 | 2012-09-12 08:42:13 +0200 | [diff] [blame] | 331 | /* I2C PIO must not be configured as open-drain on this chip */ |
Nikolaus Voss | fac368a | 2011-11-08 11:49:46 +0100 | [diff] [blame] | 332 | } else { |
| 333 | at91sam9261_twi_device.name = "i2c-at91sam9261"; |
Ludovic Desroches | 94e7346 | 2012-09-12 08:42:13 +0200 | [diff] [blame] | 334 | at91_set_multi_drive(AT91_PIN_PA7, 1); |
| 335 | at91_set_multi_drive(AT91_PIN_PA8, 1); |
Nikolaus Voss | fac368a | 2011-11-08 11:49:46 +0100 | [diff] [blame] | 336 | } |
| 337 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 338 | /* pins used for TWI interface */ |
| 339 | at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 340 | at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 341 | |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 342 | i2c_register_board_info(0, devices, nr_devices); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 343 | platform_device_register(&at91sam9261_twi_device); |
| 344 | } |
| 345 | #else |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 346 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 347 | #endif |
| 348 | |
| 349 | |
| 350 | /* -------------------------------------------------------------------- |
| 351 | * SPI |
| 352 | * -------------------------------------------------------------------- */ |
| 353 | |
| 354 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 355 | static u64 spi_dmamask = DMA_BIT_MASK(32); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 356 | |
| 357 | static struct resource spi0_resources[] = { |
| 358 | [0] = { |
| 359 | .start = AT91SAM9261_BASE_SPI0, |
| 360 | .end = AT91SAM9261_BASE_SPI0 + SZ_16K - 1, |
| 361 | .flags = IORESOURCE_MEM, |
| 362 | }, |
| 363 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 364 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0, |
| 365 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 366 | .flags = IORESOURCE_IRQ, |
| 367 | }, |
| 368 | }; |
| 369 | |
| 370 | static struct platform_device at91sam9261_spi0_device = { |
| 371 | .name = "atmel_spi", |
| 372 | .id = 0, |
| 373 | .dev = { |
| 374 | .dma_mask = &spi_dmamask, |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 375 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 376 | }, |
| 377 | .resource = spi0_resources, |
| 378 | .num_resources = ARRAY_SIZE(spi0_resources), |
| 379 | }; |
| 380 | |
| 381 | static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 }; |
| 382 | |
| 383 | static struct resource spi1_resources[] = { |
| 384 | [0] = { |
| 385 | .start = AT91SAM9261_BASE_SPI1, |
| 386 | .end = AT91SAM9261_BASE_SPI1 + SZ_16K - 1, |
| 387 | .flags = IORESOURCE_MEM, |
| 388 | }, |
| 389 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 390 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1, |
| 391 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 392 | .flags = IORESOURCE_IRQ, |
| 393 | }, |
| 394 | }; |
| 395 | |
| 396 | static struct platform_device at91sam9261_spi1_device = { |
| 397 | .name = "atmel_spi", |
| 398 | .id = 1, |
| 399 | .dev = { |
| 400 | .dma_mask = &spi_dmamask, |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 401 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 402 | }, |
| 403 | .resource = spi1_resources, |
| 404 | .num_resources = ARRAY_SIZE(spi1_resources), |
| 405 | }; |
| 406 | |
| 407 | static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB28, AT91_PIN_PA24, AT91_PIN_PA25, AT91_PIN_PA26 }; |
| 408 | |
| 409 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) |
| 410 | { |
| 411 | int i; |
| 412 | unsigned long cs_pin; |
| 413 | short enable_spi0 = 0; |
| 414 | short enable_spi1 = 0; |
| 415 | |
| 416 | /* Choose SPI chip-selects */ |
| 417 | for (i = 0; i < nr_devices; i++) { |
| 418 | if (devices[i].controller_data) |
| 419 | cs_pin = (unsigned long) devices[i].controller_data; |
| 420 | else if (devices[i].bus_num == 0) |
| 421 | cs_pin = spi0_standard_cs[devices[i].chip_select]; |
| 422 | else |
| 423 | cs_pin = spi1_standard_cs[devices[i].chip_select]; |
| 424 | |
Nicolas Ferre | 0c2c1f6 | 2012-03-28 11:58:58 +0200 | [diff] [blame] | 425 | if (!gpio_is_valid(cs_pin)) |
| 426 | continue; |
| 427 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 428 | if (devices[i].bus_num == 0) |
| 429 | enable_spi0 = 1; |
| 430 | else |
| 431 | enable_spi1 = 1; |
| 432 | |
| 433 | /* enable chip-select pin */ |
| 434 | at91_set_gpio_output(cs_pin, 1); |
| 435 | |
| 436 | /* pass chip-select pin to driver */ |
| 437 | devices[i].controller_data = (void *) cs_pin; |
| 438 | } |
| 439 | |
| 440 | spi_register_board_info(devices, nr_devices); |
| 441 | |
| 442 | /* Configure SPI bus(es) */ |
| 443 | if (enable_spi0) { |
| 444 | at91_set_A_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */ |
| 445 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ |
| 446 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ |
| 447 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 448 | platform_device_register(&at91sam9261_spi0_device); |
| 449 | } |
| 450 | if (enable_spi1) { |
| 451 | at91_set_A_periph(AT91_PIN_PB30, 0); /* SPI1_MISO */ |
| 452 | at91_set_A_periph(AT91_PIN_PB31, 0); /* SPI1_MOSI */ |
| 453 | at91_set_A_periph(AT91_PIN_PB29, 0); /* SPI1_SPCK */ |
| 454 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 455 | platform_device_register(&at91sam9261_spi1_device); |
| 456 | } |
| 457 | } |
| 458 | #else |
| 459 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} |
| 460 | #endif |
| 461 | |
| 462 | |
| 463 | /* -------------------------------------------------------------------- |
| 464 | * LCD Controller |
| 465 | * -------------------------------------------------------------------- */ |
| 466 | |
Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 467 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 468 | static u64 lcdc_dmamask = DMA_BIT_MASK(32); |
Jean-Christophe PLAGNIOL-VILLARD | 8af2c28 | 2013-03-28 22:53:42 +0800 | [diff] [blame] | 469 | static struct atmel_lcdfb_pdata lcdc_data; |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 470 | |
| 471 | static struct resource lcdc_resources[] = { |
| 472 | [0] = { |
| 473 | .start = AT91SAM9261_LCDC_BASE, |
| 474 | .end = AT91SAM9261_LCDC_BASE + SZ_4K - 1, |
| 475 | .flags = IORESOURCE_MEM, |
| 476 | }, |
| 477 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 478 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC, |
| 479 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 480 | .flags = IORESOURCE_IRQ, |
| 481 | }, |
| 482 | #if defined(CONFIG_FB_INTSRAM) |
| 483 | [2] = { |
| 484 | .start = AT91SAM9261_SRAM_BASE, |
| 485 | .end = AT91SAM9261_SRAM_BASE + AT91SAM9261_SRAM_SIZE - 1, |
| 486 | .flags = IORESOURCE_MEM, |
| 487 | }, |
| 488 | #endif |
| 489 | }; |
| 490 | |
| 491 | static struct platform_device at91_lcdc_device = { |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 492 | .id = 0, |
| 493 | .dev = { |
| 494 | .dma_mask = &lcdc_dmamask, |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 495 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 496 | .platform_data = &lcdc_data, |
| 497 | }, |
| 498 | .resource = lcdc_resources, |
| 499 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 500 | }; |
| 501 | |
Jean-Christophe PLAGNIOL-VILLARD | 8af2c28 | 2013-03-28 22:53:42 +0800 | [diff] [blame] | 502 | void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 503 | { |
| 504 | if (!data) { |
| 505 | return; |
| 506 | } |
| 507 | |
Johan Hovold | bbd44f6b | 2013-02-07 16:31:58 +0100 | [diff] [blame] | 508 | if (cpu_is_at91sam9g10()) |
| 509 | at91_lcdc_device.name = "at91sam9g10-lcdfb"; |
| 510 | else |
| 511 | at91_lcdc_device.name = "at91sam9261-lcdfb"; |
| 512 | |
Andrew Victor | f06e656 | 2008-01-22 11:37:32 +0100 | [diff] [blame] | 513 | #if defined(CONFIG_FB_ATMEL_STN) |
| 514 | at91_set_A_periph(AT91_PIN_PB0, 0); /* LCDVSYNC */ |
| 515 | at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */ |
| 516 | at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */ |
| 517 | at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */ |
| 518 | at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */ |
| 519 | at91_set_A_periph(AT91_PIN_PB5, 0); /* LCDD0 */ |
| 520 | at91_set_A_periph(AT91_PIN_PB6, 0); /* LCDD1 */ |
| 521 | at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */ |
| 522 | at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */ |
| 523 | #else |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 524 | at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */ |
| 525 | at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */ |
| 526 | at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */ |
| 527 | at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */ |
| 528 | at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */ |
| 529 | at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */ |
| 530 | at91_set_A_periph(AT91_PIN_PB9, 0); /* LCDD4 */ |
| 531 | at91_set_A_periph(AT91_PIN_PB10, 0); /* LCDD5 */ |
| 532 | at91_set_A_periph(AT91_PIN_PB11, 0); /* LCDD6 */ |
| 533 | at91_set_A_periph(AT91_PIN_PB12, 0); /* LCDD7 */ |
| 534 | at91_set_A_periph(AT91_PIN_PB15, 0); /* LCDD10 */ |
| 535 | at91_set_A_periph(AT91_PIN_PB16, 0); /* LCDD11 */ |
| 536 | at91_set_A_periph(AT91_PIN_PB17, 0); /* LCDD12 */ |
| 537 | at91_set_A_periph(AT91_PIN_PB18, 0); /* LCDD13 */ |
| 538 | at91_set_A_periph(AT91_PIN_PB19, 0); /* LCDD14 */ |
| 539 | at91_set_A_periph(AT91_PIN_PB20, 0); /* LCDD15 */ |
| 540 | at91_set_B_periph(AT91_PIN_PB23, 0); /* LCDD18 */ |
| 541 | at91_set_B_periph(AT91_PIN_PB24, 0); /* LCDD19 */ |
| 542 | at91_set_B_periph(AT91_PIN_PB25, 0); /* LCDD20 */ |
| 543 | at91_set_B_periph(AT91_PIN_PB26, 0); /* LCDD21 */ |
| 544 | at91_set_B_periph(AT91_PIN_PB27, 0); /* LCDD22 */ |
| 545 | at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */ |
Andrew Victor | f06e656 | 2008-01-22 11:37:32 +0100 | [diff] [blame] | 546 | #endif |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 547 | |
Haavard Skinnemoen | 01d3a5e | 2008-04-28 02:15:19 -0700 | [diff] [blame] | 548 | if (ARRAY_SIZE(lcdc_resources) > 2) { |
| 549 | void __iomem *fb; |
| 550 | struct resource *fb_res = &lcdc_resources[2]; |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 551 | size_t fb_len = resource_size(fb_res); |
Haavard Skinnemoen | 01d3a5e | 2008-04-28 02:15:19 -0700 | [diff] [blame] | 552 | |
Nicolas Ferre | 9089870 | 2008-05-14 16:05:38 -0700 | [diff] [blame] | 553 | fb = ioremap(fb_res->start, fb_len); |
Haavard Skinnemoen | 01d3a5e | 2008-04-28 02:15:19 -0700 | [diff] [blame] | 554 | if (fb) { |
| 555 | memset(fb, 0, fb_len); |
Nicolas Ferre | 9089870 | 2008-05-14 16:05:38 -0700 | [diff] [blame] | 556 | iounmap(fb); |
Haavard Skinnemoen | 01d3a5e | 2008-04-28 02:15:19 -0700 | [diff] [blame] | 557 | } |
| 558 | } |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 559 | lcdc_data = *data; |
| 560 | platform_device_register(&at91_lcdc_device); |
| 561 | } |
| 562 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 8af2c28 | 2013-03-28 22:53:42 +0800 | [diff] [blame] | 563 | void __init at91_add_device_lcdc(struct atmel_lcdfb_pdata *data) {} |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 564 | #endif |
| 565 | |
| 566 | |
| 567 | /* -------------------------------------------------------------------- |
Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 568 | * Timer/Counter block |
| 569 | * -------------------------------------------------------------------- */ |
| 570 | |
| 571 | #ifdef CONFIG_ATMEL_TCLIB |
| 572 | |
| 573 | static struct resource tcb_resources[] = { |
| 574 | [0] = { |
| 575 | .start = AT91SAM9261_BASE_TCB0, |
| 576 | .end = AT91SAM9261_BASE_TCB0 + SZ_16K - 1, |
| 577 | .flags = IORESOURCE_MEM, |
| 578 | }, |
| 579 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 580 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC0, |
| 581 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC0, |
Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 582 | .flags = IORESOURCE_IRQ, |
| 583 | }, |
| 584 | [2] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 585 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC1, |
| 586 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC1, |
Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 587 | .flags = IORESOURCE_IRQ, |
| 588 | }, |
| 589 | [3] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 590 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC2, |
| 591 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC2, |
Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 592 | .flags = IORESOURCE_IRQ, |
| 593 | }, |
| 594 | }; |
| 595 | |
| 596 | static struct platform_device at91sam9261_tcb_device = { |
| 597 | .name = "atmel_tcb", |
| 598 | .id = 0, |
| 599 | .resource = tcb_resources, |
| 600 | .num_resources = ARRAY_SIZE(tcb_resources), |
| 601 | }; |
| 602 | |
| 603 | static void __init at91_add_device_tc(void) |
| 604 | { |
Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 605 | platform_device_register(&at91sam9261_tcb_device); |
| 606 | } |
| 607 | #else |
| 608 | static void __init at91_add_device_tc(void) { } |
| 609 | #endif |
| 610 | |
| 611 | |
| 612 | /* -------------------------------------------------------------------- |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 613 | * RTT |
| 614 | * -------------------------------------------------------------------- */ |
| 615 | |
| 616 | static struct resource rtt_resources[] = { |
| 617 | { |
Jean-Christophe PLAGNIOL-VILLARD | eab5fd6 | 2011-09-18 10:12:00 +0800 | [diff] [blame] | 618 | .start = AT91SAM9261_BASE_RTT, |
| 619 | .end = AT91SAM9261_BASE_RTT + SZ_16 - 1, |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 620 | .flags = IORESOURCE_MEM, |
Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 621 | }, { |
| 622 | .flags = IORESOURCE_MEM, |
Ludovic Desroches | e402af6 | 2012-08-14 11:19:22 +0200 | [diff] [blame] | 623 | }, { |
| 624 | .flags = IORESOURCE_IRQ, |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 625 | } |
| 626 | }; |
| 627 | |
| 628 | static struct platform_device at91sam9261_rtt_device = { |
| 629 | .name = "at91_rtt", |
Andrew Victor | 4fd9212 | 2008-04-02 21:55:19 +0100 | [diff] [blame] | 630 | .id = 0, |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 631 | .resource = rtt_resources, |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 632 | }; |
| 633 | |
Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 634 | #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) |
| 635 | static void __init at91_add_device_rtt_rtc(void) |
| 636 | { |
| 637 | at91sam9261_rtt_device.name = "rtc-at91sam9"; |
Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 638 | /* |
| 639 | * The second resource is needed: |
| 640 | * GPBR will serve as the storage for RTC time offset |
| 641 | */ |
Ludovic Desroches | e402af6 | 2012-08-14 11:19:22 +0200 | [diff] [blame] | 642 | at91sam9261_rtt_device.num_resources = 3; |
Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 643 | rtt_resources[1].start = AT91SAM9261_BASE_GPBR + |
| 644 | 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; |
| 645 | rtt_resources[1].end = rtt_resources[1].start + 3; |
Ludovic Desroches | e402af6 | 2012-08-14 11:19:22 +0200 | [diff] [blame] | 646 | rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS; |
| 647 | rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS; |
Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 648 | } |
| 649 | #else |
Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 650 | static void __init at91_add_device_rtt_rtc(void) |
| 651 | { |
| 652 | /* Only one resource is needed: RTT not used as RTC */ |
| 653 | at91sam9261_rtt_device.num_resources = 1; |
| 654 | } |
Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 655 | #endif |
| 656 | |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 657 | static void __init at91_add_device_rtt(void) |
| 658 | { |
Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 659 | at91_add_device_rtt_rtc(); |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 660 | platform_device_register(&at91sam9261_rtt_device); |
| 661 | } |
| 662 | |
| 663 | |
| 664 | /* -------------------------------------------------------------------- |
| 665 | * Watchdog |
| 666 | * -------------------------------------------------------------------- */ |
| 667 | |
Andrew Victor | 2af29b7 | 2009-02-11 21:23:10 +0100 | [diff] [blame] | 668 | #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) |
Jean-Christophe PLAGNIOL-VILLARD | c1c30a2 | 2011-11-02 01:43:31 +0800 | [diff] [blame] | 669 | static struct resource wdt_resources[] = { |
| 670 | { |
| 671 | .start = AT91SAM9261_BASE_WDT, |
| 672 | .end = AT91SAM9261_BASE_WDT + SZ_16 - 1, |
| 673 | .flags = IORESOURCE_MEM, |
| 674 | } |
| 675 | }; |
| 676 | |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 677 | static struct platform_device at91sam9261_wdt_device = { |
| 678 | .name = "at91_wdt", |
| 679 | .id = -1, |
Jean-Christophe PLAGNIOL-VILLARD | c1c30a2 | 2011-11-02 01:43:31 +0800 | [diff] [blame] | 680 | .resource = wdt_resources, |
| 681 | .num_resources = ARRAY_SIZE(wdt_resources), |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 682 | }; |
| 683 | |
| 684 | static void __init at91_add_device_watchdog(void) |
| 685 | { |
| 686 | platform_device_register(&at91sam9261_wdt_device); |
| 687 | } |
| 688 | #else |
| 689 | static void __init at91_add_device_watchdog(void) {} |
| 690 | #endif |
| 691 | |
| 692 | |
| 693 | /* -------------------------------------------------------------------- |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 694 | * SSC -- Synchronous Serial Controller |
| 695 | * -------------------------------------------------------------------- */ |
| 696 | |
| 697 | #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE) |
| 698 | static u64 ssc0_dmamask = DMA_BIT_MASK(32); |
| 699 | |
| 700 | static struct resource ssc0_resources[] = { |
| 701 | [0] = { |
| 702 | .start = AT91SAM9261_BASE_SSC0, |
| 703 | .end = AT91SAM9261_BASE_SSC0 + SZ_16K - 1, |
| 704 | .flags = IORESOURCE_MEM, |
| 705 | }, |
| 706 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 707 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0, |
| 708 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0, |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 709 | .flags = IORESOURCE_IRQ, |
| 710 | }, |
| 711 | }; |
| 712 | |
| 713 | static struct platform_device at91sam9261_ssc0_device = { |
Bo Shen | 636036d2 | 2012-11-06 13:57:51 +0800 | [diff] [blame] | 714 | .name = "at91rm9200_ssc", |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 715 | .id = 0, |
| 716 | .dev = { |
| 717 | .dma_mask = &ssc0_dmamask, |
| 718 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 719 | }, |
| 720 | .resource = ssc0_resources, |
| 721 | .num_resources = ARRAY_SIZE(ssc0_resources), |
| 722 | }; |
| 723 | |
| 724 | static inline void configure_ssc0_pins(unsigned pins) |
| 725 | { |
| 726 | if (pins & ATMEL_SSC_TF) |
| 727 | at91_set_A_periph(AT91_PIN_PB21, 1); |
| 728 | if (pins & ATMEL_SSC_TK) |
| 729 | at91_set_A_periph(AT91_PIN_PB22, 1); |
| 730 | if (pins & ATMEL_SSC_TD) |
| 731 | at91_set_A_periph(AT91_PIN_PB23, 1); |
| 732 | if (pins & ATMEL_SSC_RD) |
| 733 | at91_set_A_periph(AT91_PIN_PB24, 1); |
| 734 | if (pins & ATMEL_SSC_RK) |
| 735 | at91_set_A_periph(AT91_PIN_PB25, 1); |
| 736 | if (pins & ATMEL_SSC_RF) |
| 737 | at91_set_A_periph(AT91_PIN_PB26, 1); |
| 738 | } |
| 739 | |
| 740 | static u64 ssc1_dmamask = DMA_BIT_MASK(32); |
| 741 | |
| 742 | static struct resource ssc1_resources[] = { |
| 743 | [0] = { |
| 744 | .start = AT91SAM9261_BASE_SSC1, |
| 745 | .end = AT91SAM9261_BASE_SSC1 + SZ_16K - 1, |
| 746 | .flags = IORESOURCE_MEM, |
| 747 | }, |
| 748 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 749 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1, |
| 750 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1, |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 751 | .flags = IORESOURCE_IRQ, |
| 752 | }, |
| 753 | }; |
| 754 | |
| 755 | static struct platform_device at91sam9261_ssc1_device = { |
Bo Shen | 636036d2 | 2012-11-06 13:57:51 +0800 | [diff] [blame] | 756 | .name = "at91rm9200_ssc", |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 757 | .id = 1, |
| 758 | .dev = { |
| 759 | .dma_mask = &ssc1_dmamask, |
| 760 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 761 | }, |
| 762 | .resource = ssc1_resources, |
| 763 | .num_resources = ARRAY_SIZE(ssc1_resources), |
| 764 | }; |
| 765 | |
| 766 | static inline void configure_ssc1_pins(unsigned pins) |
| 767 | { |
| 768 | if (pins & ATMEL_SSC_TF) |
| 769 | at91_set_B_periph(AT91_PIN_PA17, 1); |
| 770 | if (pins & ATMEL_SSC_TK) |
| 771 | at91_set_B_periph(AT91_PIN_PA18, 1); |
| 772 | if (pins & ATMEL_SSC_TD) |
| 773 | at91_set_B_periph(AT91_PIN_PA19, 1); |
| 774 | if (pins & ATMEL_SSC_RD) |
| 775 | at91_set_B_periph(AT91_PIN_PA20, 1); |
| 776 | if (pins & ATMEL_SSC_RK) |
| 777 | at91_set_B_periph(AT91_PIN_PA21, 1); |
| 778 | if (pins & ATMEL_SSC_RF) |
| 779 | at91_set_B_periph(AT91_PIN_PA22, 1); |
| 780 | } |
| 781 | |
| 782 | static u64 ssc2_dmamask = DMA_BIT_MASK(32); |
| 783 | |
| 784 | static struct resource ssc2_resources[] = { |
| 785 | [0] = { |
| 786 | .start = AT91SAM9261_BASE_SSC2, |
| 787 | .end = AT91SAM9261_BASE_SSC2 + SZ_16K - 1, |
| 788 | .flags = IORESOURCE_MEM, |
| 789 | }, |
| 790 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 791 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2, |
| 792 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2, |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 793 | .flags = IORESOURCE_IRQ, |
| 794 | }, |
| 795 | }; |
| 796 | |
| 797 | static struct platform_device at91sam9261_ssc2_device = { |
Bo Shen | 636036d2 | 2012-11-06 13:57:51 +0800 | [diff] [blame] | 798 | .name = "at91rm9200_ssc", |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 799 | .id = 2, |
| 800 | .dev = { |
| 801 | .dma_mask = &ssc2_dmamask, |
| 802 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 803 | }, |
| 804 | .resource = ssc2_resources, |
| 805 | .num_resources = ARRAY_SIZE(ssc2_resources), |
| 806 | }; |
| 807 | |
| 808 | static inline void configure_ssc2_pins(unsigned pins) |
| 809 | { |
| 810 | if (pins & ATMEL_SSC_TF) |
| 811 | at91_set_B_periph(AT91_PIN_PC25, 1); |
| 812 | if (pins & ATMEL_SSC_TK) |
| 813 | at91_set_B_periph(AT91_PIN_PC26, 1); |
| 814 | if (pins & ATMEL_SSC_TD) |
| 815 | at91_set_B_periph(AT91_PIN_PC27, 1); |
| 816 | if (pins & ATMEL_SSC_RD) |
| 817 | at91_set_B_periph(AT91_PIN_PC28, 1); |
| 818 | if (pins & ATMEL_SSC_RK) |
| 819 | at91_set_B_periph(AT91_PIN_PC29, 1); |
| 820 | if (pins & ATMEL_SSC_RF) |
| 821 | at91_set_B_periph(AT91_PIN_PC30, 1); |
| 822 | } |
| 823 | |
| 824 | /* |
| 825 | * SSC controllers are accessed through library code, instead of any |
| 826 | * kind of all-singing/all-dancing driver. For example one could be |
| 827 | * used by a particular I2S audio codec's driver, while another one |
| 828 | * on the same system might be used by a custom data capture driver. |
| 829 | */ |
| 830 | void __init at91_add_device_ssc(unsigned id, unsigned pins) |
| 831 | { |
| 832 | struct platform_device *pdev; |
| 833 | |
| 834 | /* |
| 835 | * NOTE: caller is responsible for passing information matching |
| 836 | * "pins" to whatever will be using each particular controller. |
| 837 | */ |
| 838 | switch (id) { |
| 839 | case AT91SAM9261_ID_SSC0: |
| 840 | pdev = &at91sam9261_ssc0_device; |
| 841 | configure_ssc0_pins(pins); |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 842 | break; |
| 843 | case AT91SAM9261_ID_SSC1: |
| 844 | pdev = &at91sam9261_ssc1_device; |
| 845 | configure_ssc1_pins(pins); |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 846 | break; |
| 847 | case AT91SAM9261_ID_SSC2: |
| 848 | pdev = &at91sam9261_ssc2_device; |
| 849 | configure_ssc2_pins(pins); |
Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 850 | break; |
| 851 | default: |
| 852 | return; |
| 853 | } |
| 854 | |
| 855 | platform_device_register(pdev); |
| 856 | } |
| 857 | |
| 858 | #else |
| 859 | void __init at91_add_device_ssc(unsigned id, unsigned pins) {} |
| 860 | #endif |
| 861 | |
| 862 | |
| 863 | /* -------------------------------------------------------------------- |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 864 | * UART |
| 865 | * -------------------------------------------------------------------- */ |
| 866 | |
| 867 | #if defined(CONFIG_SERIAL_ATMEL) |
| 868 | static struct resource dbgu_resources[] = { |
| 869 | [0] = { |
Jean-Christophe PLAGNIOL-VILLARD | 13079a7 | 2011-11-02 01:43:31 +0800 | [diff] [blame] | 870 | .start = AT91SAM9261_BASE_DBGU, |
| 871 | .end = AT91SAM9261_BASE_DBGU + SZ_512 - 1, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 872 | .flags = IORESOURCE_MEM, |
| 873 | }, |
| 874 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 875 | .start = NR_IRQS_LEGACY + AT91_ID_SYS, |
| 876 | .end = NR_IRQS_LEGACY + AT91_ID_SYS, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 877 | .flags = IORESOURCE_IRQ, |
| 878 | }, |
| 879 | }; |
| 880 | |
| 881 | static struct atmel_uart_data dbgu_data = { |
| 882 | .use_dma_tx = 0, |
| 883 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 884 | }; |
| 885 | |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 886 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| 887 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 888 | static struct platform_device at91sam9261_dbgu_device = { |
| 889 | .name = "atmel_usart", |
| 890 | .id = 0, |
| 891 | .dev = { |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 892 | .dma_mask = &dbgu_dmamask, |
| 893 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 894 | .platform_data = &dbgu_data, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 895 | }, |
| 896 | .resource = dbgu_resources, |
| 897 | .num_resources = ARRAY_SIZE(dbgu_resources), |
| 898 | }; |
| 899 | |
| 900 | static inline void configure_dbgu_pins(void) |
| 901 | { |
| 902 | at91_set_A_periph(AT91_PIN_PA9, 0); /* DRXD */ |
| 903 | at91_set_A_periph(AT91_PIN_PA10, 1); /* DTXD */ |
| 904 | } |
| 905 | |
| 906 | static struct resource uart0_resources[] = { |
| 907 | [0] = { |
| 908 | .start = AT91SAM9261_BASE_US0, |
| 909 | .end = AT91SAM9261_BASE_US0 + SZ_16K - 1, |
| 910 | .flags = IORESOURCE_MEM, |
| 911 | }, |
| 912 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 913 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US0, |
| 914 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US0, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 915 | .flags = IORESOURCE_IRQ, |
| 916 | }, |
| 917 | }; |
| 918 | |
| 919 | static struct atmel_uart_data uart0_data = { |
| 920 | .use_dma_tx = 1, |
| 921 | .use_dma_rx = 1, |
| 922 | }; |
| 923 | |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 924 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| 925 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 926 | static struct platform_device at91sam9261_uart0_device = { |
| 927 | .name = "atmel_usart", |
| 928 | .id = 1, |
| 929 | .dev = { |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 930 | .dma_mask = &uart0_dmamask, |
| 931 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 932 | .platform_data = &uart0_data, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 933 | }, |
| 934 | .resource = uart0_resources, |
| 935 | .num_resources = ARRAY_SIZE(uart0_resources), |
| 936 | }; |
| 937 | |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 938 | static inline void configure_usart0_pins(unsigned pins) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 939 | { |
| 940 | at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ |
| 941 | at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 942 | |
| 943 | if (pins & ATMEL_UART_RTS) |
| 944 | at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ |
| 945 | if (pins & ATMEL_UART_CTS) |
| 946 | at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | static struct resource uart1_resources[] = { |
| 950 | [0] = { |
| 951 | .start = AT91SAM9261_BASE_US1, |
| 952 | .end = AT91SAM9261_BASE_US1 + SZ_16K - 1, |
| 953 | .flags = IORESOURCE_MEM, |
| 954 | }, |
| 955 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 956 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US1, |
| 957 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US1, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 958 | .flags = IORESOURCE_IRQ, |
| 959 | }, |
| 960 | }; |
| 961 | |
| 962 | static struct atmel_uart_data uart1_data = { |
| 963 | .use_dma_tx = 1, |
| 964 | .use_dma_rx = 1, |
| 965 | }; |
| 966 | |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 967 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| 968 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 969 | static struct platform_device at91sam9261_uart1_device = { |
| 970 | .name = "atmel_usart", |
| 971 | .id = 2, |
| 972 | .dev = { |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 973 | .dma_mask = &uart1_dmamask, |
| 974 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 975 | .platform_data = &uart1_data, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 976 | }, |
| 977 | .resource = uart1_resources, |
| 978 | .num_resources = ARRAY_SIZE(uart1_resources), |
| 979 | }; |
| 980 | |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 981 | static inline void configure_usart1_pins(unsigned pins) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 982 | { |
| 983 | at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ |
| 984 | at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 985 | |
| 986 | if (pins & ATMEL_UART_RTS) |
| 987 | at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */ |
| 988 | if (pins & ATMEL_UART_CTS) |
| 989 | at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | static struct resource uart2_resources[] = { |
| 993 | [0] = { |
| 994 | .start = AT91SAM9261_BASE_US2, |
| 995 | .end = AT91SAM9261_BASE_US2 + SZ_16K - 1, |
| 996 | .flags = IORESOURCE_MEM, |
| 997 | }, |
| 998 | [1] = { |
Ludovic Desroches | 8fe82a5 | 2012-06-21 14:47:27 +0200 | [diff] [blame] | 999 | .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US2, |
| 1000 | .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US2, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1001 | .flags = IORESOURCE_IRQ, |
| 1002 | }, |
| 1003 | }; |
| 1004 | |
| 1005 | static struct atmel_uart_data uart2_data = { |
| 1006 | .use_dma_tx = 1, |
| 1007 | .use_dma_rx = 1, |
| 1008 | }; |
| 1009 | |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1010 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
| 1011 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1012 | static struct platform_device at91sam9261_uart2_device = { |
| 1013 | .name = "atmel_usart", |
| 1014 | .id = 3, |
| 1015 | .dev = { |
Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1016 | .dma_mask = &uart2_dmamask, |
| 1017 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 1018 | .platform_data = &uart2_data, |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1019 | }, |
| 1020 | .resource = uart2_resources, |
| 1021 | .num_resources = ARRAY_SIZE(uart2_resources), |
| 1022 | }; |
| 1023 | |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1024 | static inline void configure_usart2_pins(unsigned pins) |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1025 | { |
| 1026 | at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ |
| 1027 | at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1028 | |
| 1029 | if (pins & ATMEL_UART_RTS) |
| 1030 | at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/ |
| 1031 | if (pins & ATMEL_UART_CTS) |
| 1032 | at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1033 | } |
| 1034 | |
Andrew Victor | 11aadac | 2008-04-15 21:16:38 +0100 | [diff] [blame] | 1035 | static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1036 | |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1037 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) |
| 1038 | { |
| 1039 | struct platform_device *pdev; |
Jean-Christophe PLAGNIOL-VILLARD | 2b348e2 | 2011-04-10 14:10:05 +0800 | [diff] [blame] | 1040 | struct atmel_uart_data *pdata; |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1041 | |
| 1042 | switch (id) { |
| 1043 | case 0: /* DBGU */ |
| 1044 | pdev = &at91sam9261_dbgu_device; |
| 1045 | configure_dbgu_pins(); |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1046 | break; |
| 1047 | case AT91SAM9261_ID_US0: |
| 1048 | pdev = &at91sam9261_uart0_device; |
| 1049 | configure_usart0_pins(pins); |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1050 | break; |
| 1051 | case AT91SAM9261_ID_US1: |
| 1052 | pdev = &at91sam9261_uart1_device; |
| 1053 | configure_usart1_pins(pins); |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1054 | break; |
| 1055 | case AT91SAM9261_ID_US2: |
| 1056 | pdev = &at91sam9261_uart2_device; |
| 1057 | configure_usart2_pins(pins); |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1058 | break; |
| 1059 | default: |
| 1060 | return; |
| 1061 | } |
Jean-Christophe PLAGNIOL-VILLARD | 2b348e2 | 2011-04-10 14:10:05 +0800 | [diff] [blame] | 1062 | pdata = pdev->dev.platform_data; |
| 1063 | pdata->num = portnr; /* update to mapped ID */ |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1064 | |
| 1065 | if (portnr < ATMEL_MAX_UART) |
| 1066 | at91_uarts[portnr] = pdev; |
| 1067 | } |
| 1068 | |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1069 | void __init at91_add_device_serial(void) |
| 1070 | { |
| 1071 | int i; |
| 1072 | |
| 1073 | for (i = 0; i < ATMEL_MAX_UART; i++) { |
| 1074 | if (at91_uarts[i]) |
| 1075 | platform_device_register(at91_uarts[i]); |
| 1076 | } |
| 1077 | } |
| 1078 | #else |
Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1079 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1080 | void __init at91_add_device_serial(void) {} |
| 1081 | #endif |
| 1082 | |
| 1083 | |
| 1084 | /* -------------------------------------------------------------------- */ |
| 1085 | |
| 1086 | /* |
| 1087 | * These devices are always present and don't need any board-specific |
| 1088 | * setup. |
| 1089 | */ |
| 1090 | static int __init at91_add_standard_devices(void) |
| 1091 | { |
Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 1092 | at91_add_device_rtt(); |
| 1093 | at91_add_device_watchdog(); |
Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 1094 | at91_add_device_tc(); |
Andrew Victor | 86ad76b | 2006-11-30 16:45:01 +0100 | [diff] [blame] | 1095 | return 0; |
| 1096 | } |
| 1097 | |
| 1098 | arch_initcall(at91_add_standard_devices); |