| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1 | /* | 
|  | 2 | * arch/arm/mach-at91/at91sam9263_devices.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 2007 Atmel Corporation. | 
|  | 5 | * | 
|  | 6 | * This program is free software; you can redistribute it and/or modify | 
|  | 7 | * it under the terms of the GNU General Public License as published by | 
|  | 8 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 9 | * (at your option) any later version. | 
|  | 10 | * | 
|  | 11 | */ | 
|  | 12 | #include <asm/mach/arch.h> | 
|  | 13 | #include <asm/mach/map.h> | 
|  | 14 |  | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 15 | #include <linux/dma-mapping.h> | 
| Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 16 | #include <linux/gpio.h> | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 17 | #include <linux/platform_device.h> | 
| Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 18 | #include <linux/i2c-gpio.h> | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 19 |  | 
| Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 20 | #include <linux/fb.h> | 
| Jan Altenberg | b8b7860 | 2007-08-03 12:14:34 +0100 | [diff] [blame] | 21 | #include <video/atmel_lcdc.h> | 
|  | 22 |  | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/board.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/at91sam9263.h> | 
|  | 25 | #include <mach/at91sam9263_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> | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 28 |  | 
|  | 29 | #include "generic.h" | 
|  | 30 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 31 |  | 
|  | 32 | /* -------------------------------------------------------------------- | 
|  | 33 | *  USB Host | 
|  | 34 | * -------------------------------------------------------------------- */ | 
|  | 35 |  | 
|  | 36 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 37 | static u64 ohci_dmamask = DMA_BIT_MASK(32); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 38 | static struct at91_usbh_data usbh_data; | 
|  | 39 |  | 
|  | 40 | static struct resource usbh_resources[] = { | 
|  | 41 | [0] = { | 
|  | 42 | .start	= AT91SAM9263_UHP_BASE, | 
|  | 43 | .end	= AT91SAM9263_UHP_BASE + SZ_1M - 1, | 
|  | 44 | .flags	= IORESOURCE_MEM, | 
|  | 45 | }, | 
|  | 46 | [1] = { | 
|  | 47 | .start	= AT91SAM9263_ID_UHP, | 
|  | 48 | .end	= AT91SAM9263_ID_UHP, | 
|  | 49 | .flags	= IORESOURCE_IRQ, | 
|  | 50 | }, | 
|  | 51 | }; | 
|  | 52 |  | 
|  | 53 | static struct platform_device at91_usbh_device = { | 
|  | 54 | .name		= "at91_ohci", | 
|  | 55 | .id		= -1, | 
|  | 56 | .dev		= { | 
|  | 57 | .dma_mask		= &ohci_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 58 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 59 | .platform_data		= &usbh_data, | 
|  | 60 | }, | 
|  | 61 | .resource	= usbh_resources, | 
|  | 62 | .num_resources	= ARRAY_SIZE(usbh_resources), | 
|  | 63 | }; | 
|  | 64 |  | 
|  | 65 | void __init at91_add_device_usbh(struct at91_usbh_data *data) | 
|  | 66 | { | 
|  | 67 | int i; | 
|  | 68 |  | 
|  | 69 | if (!data) | 
|  | 70 | return; | 
|  | 71 |  | 
|  | 72 | /* Enable VBus control for UHP ports */ | 
|  | 73 | for (i = 0; i < data->ports; i++) { | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 74 | if (gpio_is_valid(data->vbus_pin[i])) | 
| Nicolas Ferre | cca0355 | 2012-03-28 11:56:28 +0200 | [diff] [blame^] | 75 | at91_set_gpio_output(data->vbus_pin[i], | 
|  | 76 | data->vbus_pin_active_low[i]); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 77 | } | 
|  | 78 |  | 
| Thomas Petazzoni | 1fcaea7 | 2011-07-13 11:29:18 +0200 | [diff] [blame] | 79 | /* Enable overcurrent notification */ | 
|  | 80 | for (i = 0; i < data->ports; i++) { | 
|  | 81 | if (data->overcurrent_pin[i]) | 
|  | 82 | at91_set_gpio_input(data->overcurrent_pin[i], 1); | 
|  | 83 | } | 
|  | 84 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 85 | usbh_data = *data; | 
|  | 86 | platform_device_register(&at91_usbh_device); | 
|  | 87 | } | 
|  | 88 | #else | 
|  | 89 | void __init at91_add_device_usbh(struct at91_usbh_data *data) {} | 
|  | 90 | #endif | 
|  | 91 |  | 
|  | 92 |  | 
|  | 93 | /* -------------------------------------------------------------------- | 
|  | 94 | *  USB Device (Gadget) | 
|  | 95 | * -------------------------------------------------------------------- */ | 
|  | 96 |  | 
| Nicolas Ferre | e8c9dc9 | 2012-01-27 11:14:44 +0100 | [diff] [blame] | 97 | #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 98 | static struct at91_udc_data udc_data; | 
|  | 99 |  | 
|  | 100 | static struct resource udc_resources[] = { | 
|  | 101 | [0] = { | 
|  | 102 | .start	= AT91SAM9263_BASE_UDP, | 
|  | 103 | .end	= AT91SAM9263_BASE_UDP + SZ_16K - 1, | 
|  | 104 | .flags	= IORESOURCE_MEM, | 
|  | 105 | }, | 
|  | 106 | [1] = { | 
|  | 107 | .start	= AT91SAM9263_ID_UDP, | 
|  | 108 | .end	= AT91SAM9263_ID_UDP, | 
|  | 109 | .flags	= IORESOURCE_IRQ, | 
|  | 110 | }, | 
|  | 111 | }; | 
|  | 112 |  | 
|  | 113 | static struct platform_device at91_udc_device = { | 
|  | 114 | .name		= "at91_udc", | 
|  | 115 | .id		= -1, | 
|  | 116 | .dev		= { | 
|  | 117 | .platform_data		= &udc_data, | 
|  | 118 | }, | 
|  | 119 | .resource	= udc_resources, | 
|  | 120 | .num_resources	= ARRAY_SIZE(udc_resources), | 
|  | 121 | }; | 
|  | 122 |  | 
|  | 123 | void __init at91_add_device_udc(struct at91_udc_data *data) | 
|  | 124 | { | 
|  | 125 | if (!data) | 
|  | 126 | return; | 
|  | 127 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 128 | if (gpio_is_valid(data->vbus_pin)) { | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 129 | at91_set_gpio_input(data->vbus_pin, 0); | 
|  | 130 | at91_set_deglitch(data->vbus_pin, 1); | 
|  | 131 | } | 
|  | 132 |  | 
|  | 133 | /* Pullup pin is handled internally by USB device peripheral */ | 
|  | 134 |  | 
|  | 135 | udc_data = *data; | 
|  | 136 | platform_device_register(&at91_udc_device); | 
|  | 137 | } | 
|  | 138 | #else | 
|  | 139 | void __init at91_add_device_udc(struct at91_udc_data *data) {} | 
|  | 140 | #endif | 
|  | 141 |  | 
|  | 142 |  | 
|  | 143 | /* -------------------------------------------------------------------- | 
|  | 144 | *  Ethernet | 
|  | 145 | * -------------------------------------------------------------------- */ | 
|  | 146 |  | 
|  | 147 | #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 148 | static u64 eth_dmamask = DMA_BIT_MASK(32); | 
| Jamie Iles | 84e0cdb | 2011-03-08 20:17:06 +0000 | [diff] [blame] | 149 | static struct macb_platform_data eth_data; | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 150 |  | 
|  | 151 | static struct resource eth_resources[] = { | 
|  | 152 | [0] = { | 
|  | 153 | .start	= AT91SAM9263_BASE_EMAC, | 
|  | 154 | .end	= AT91SAM9263_BASE_EMAC + SZ_16K - 1, | 
|  | 155 | .flags	= IORESOURCE_MEM, | 
|  | 156 | }, | 
|  | 157 | [1] = { | 
|  | 158 | .start	= AT91SAM9263_ID_EMAC, | 
|  | 159 | .end	= AT91SAM9263_ID_EMAC, | 
|  | 160 | .flags	= IORESOURCE_IRQ, | 
|  | 161 | }, | 
|  | 162 | }; | 
|  | 163 |  | 
|  | 164 | static struct platform_device at91sam9263_eth_device = { | 
|  | 165 | .name		= "macb", | 
|  | 166 | .id		= -1, | 
|  | 167 | .dev		= { | 
|  | 168 | .dma_mask		= ð_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 169 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 170 | .platform_data		= ð_data, | 
|  | 171 | }, | 
|  | 172 | .resource	= eth_resources, | 
|  | 173 | .num_resources	= ARRAY_SIZE(eth_resources), | 
|  | 174 | }; | 
|  | 175 |  | 
| Jamie Iles | 84e0cdb | 2011-03-08 20:17:06 +0000 | [diff] [blame] | 176 | void __init at91_add_device_eth(struct macb_platform_data *data) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 177 | { | 
|  | 178 | if (!data) | 
|  | 179 | return; | 
|  | 180 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 181 | if (gpio_is_valid(data->phy_irq_pin)) { | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 182 | at91_set_gpio_input(data->phy_irq_pin, 0); | 
|  | 183 | at91_set_deglitch(data->phy_irq_pin, 1); | 
|  | 184 | } | 
|  | 185 |  | 
|  | 186 | /* Pins used for MII and RMII */ | 
|  | 187 | at91_set_A_periph(AT91_PIN_PE21, 0);	/* ETXCK_EREFCK */ | 
|  | 188 | at91_set_B_periph(AT91_PIN_PC25, 0);	/* ERXDV */ | 
|  | 189 | at91_set_A_periph(AT91_PIN_PE25, 0);	/* ERX0 */ | 
|  | 190 | at91_set_A_periph(AT91_PIN_PE26, 0);	/* ERX1 */ | 
|  | 191 | at91_set_A_periph(AT91_PIN_PE27, 0);	/* ERXER */ | 
|  | 192 | at91_set_A_periph(AT91_PIN_PE28, 0);	/* ETXEN */ | 
|  | 193 | at91_set_A_periph(AT91_PIN_PE23, 0);	/* ETX0 */ | 
|  | 194 | at91_set_A_periph(AT91_PIN_PE24, 0);	/* ETX1 */ | 
|  | 195 | at91_set_A_periph(AT91_PIN_PE30, 0);	/* EMDIO */ | 
|  | 196 | at91_set_A_periph(AT91_PIN_PE29, 0);	/* EMDC */ | 
|  | 197 |  | 
|  | 198 | if (!data->is_rmii) { | 
|  | 199 | at91_set_A_periph(AT91_PIN_PE22, 0);	/* ECRS */ | 
|  | 200 | at91_set_B_periph(AT91_PIN_PC26, 0);	/* ECOL */ | 
|  | 201 | at91_set_B_periph(AT91_PIN_PC22, 0);	/* ERX2 */ | 
|  | 202 | at91_set_B_periph(AT91_PIN_PC23, 0);	/* ERX3 */ | 
|  | 203 | at91_set_B_periph(AT91_PIN_PC27, 0);	/* ERXCK */ | 
|  | 204 | at91_set_B_periph(AT91_PIN_PC20, 0);	/* ETX2 */ | 
|  | 205 | at91_set_B_periph(AT91_PIN_PC21, 0);	/* ETX3 */ | 
|  | 206 | at91_set_B_periph(AT91_PIN_PC24, 0);	/* ETXER */ | 
|  | 207 | } | 
|  | 208 |  | 
|  | 209 | eth_data = *data; | 
|  | 210 | platform_device_register(&at91sam9263_eth_device); | 
|  | 211 | } | 
|  | 212 | #else | 
| Jamie Iles | 84e0cdb | 2011-03-08 20:17:06 +0000 | [diff] [blame] | 213 | void __init at91_add_device_eth(struct macb_platform_data *data) {} | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 214 | #endif | 
|  | 215 |  | 
|  | 216 |  | 
|  | 217 | /* -------------------------------------------------------------------- | 
|  | 218 | *  MMC / SD | 
|  | 219 | * -------------------------------------------------------------------- */ | 
|  | 220 |  | 
|  | 221 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 222 | static u64 mmc_dmamask = DMA_BIT_MASK(32); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 223 | static struct at91_mmc_data mmc0_data, mmc1_data; | 
|  | 224 |  | 
|  | 225 | static struct resource mmc0_resources[] = { | 
|  | 226 | [0] = { | 
|  | 227 | .start	= AT91SAM9263_BASE_MCI0, | 
|  | 228 | .end	= AT91SAM9263_BASE_MCI0 + SZ_16K - 1, | 
|  | 229 | .flags	= IORESOURCE_MEM, | 
|  | 230 | }, | 
|  | 231 | [1] = { | 
|  | 232 | .start	= AT91SAM9263_ID_MCI0, | 
|  | 233 | .end	= AT91SAM9263_ID_MCI0, | 
|  | 234 | .flags	= IORESOURCE_IRQ, | 
|  | 235 | }, | 
|  | 236 | }; | 
|  | 237 |  | 
|  | 238 | static struct platform_device at91sam9263_mmc0_device = { | 
|  | 239 | .name		= "at91_mci", | 
|  | 240 | .id		= 0, | 
|  | 241 | .dev		= { | 
|  | 242 | .dma_mask		= &mmc_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 243 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 244 | .platform_data		= &mmc0_data, | 
|  | 245 | }, | 
|  | 246 | .resource	= mmc0_resources, | 
|  | 247 | .num_resources	= ARRAY_SIZE(mmc0_resources), | 
|  | 248 | }; | 
|  | 249 |  | 
|  | 250 | static struct resource mmc1_resources[] = { | 
|  | 251 | [0] = { | 
|  | 252 | .start	= AT91SAM9263_BASE_MCI1, | 
|  | 253 | .end	= AT91SAM9263_BASE_MCI1 + SZ_16K - 1, | 
|  | 254 | .flags	= IORESOURCE_MEM, | 
|  | 255 | }, | 
|  | 256 | [1] = { | 
|  | 257 | .start	= AT91SAM9263_ID_MCI1, | 
|  | 258 | .end	= AT91SAM9263_ID_MCI1, | 
|  | 259 | .flags	= IORESOURCE_IRQ, | 
|  | 260 | }, | 
|  | 261 | }; | 
|  | 262 |  | 
|  | 263 | static struct platform_device at91sam9263_mmc1_device = { | 
|  | 264 | .name		= "at91_mci", | 
|  | 265 | .id		= 1, | 
|  | 266 | .dev		= { | 
|  | 267 | .dma_mask		= &mmc_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 268 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 269 | .platform_data		= &mmc1_data, | 
|  | 270 | }, | 
|  | 271 | .resource	= mmc1_resources, | 
|  | 272 | .num_resources	= ARRAY_SIZE(mmc1_resources), | 
|  | 273 | }; | 
|  | 274 |  | 
|  | 275 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | 
|  | 276 | { | 
|  | 277 | if (!data) | 
|  | 278 | return; | 
|  | 279 |  | 
|  | 280 | /* input/irq */ | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 281 | if (gpio_is_valid(data->det_pin)) { | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 282 | at91_set_gpio_input(data->det_pin, 1); | 
|  | 283 | at91_set_deglitch(data->det_pin, 1); | 
|  | 284 | } | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 285 | if (gpio_is_valid(data->wp_pin)) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 286 | at91_set_gpio_input(data->wp_pin, 1); | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 287 | if (gpio_is_valid(data->vcc_pin)) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 288 | at91_set_gpio_output(data->vcc_pin, 0); | 
|  | 289 |  | 
|  | 290 | if (mmc_id == 0) {		/* MCI0 */ | 
|  | 291 | /* CLK */ | 
|  | 292 | at91_set_A_periph(AT91_PIN_PA12, 0); | 
|  | 293 |  | 
|  | 294 | if (data->slot_b) { | 
|  | 295 | /* CMD */ | 
|  | 296 | at91_set_A_periph(AT91_PIN_PA16, 1); | 
|  | 297 |  | 
|  | 298 | /* DAT0, maybe DAT1..DAT3 */ | 
|  | 299 | at91_set_A_periph(AT91_PIN_PA17, 1); | 
|  | 300 | if (data->wire4) { | 
|  | 301 | at91_set_A_periph(AT91_PIN_PA18, 1); | 
|  | 302 | at91_set_A_periph(AT91_PIN_PA19, 1); | 
|  | 303 | at91_set_A_periph(AT91_PIN_PA20, 1); | 
|  | 304 | } | 
|  | 305 | } else { | 
|  | 306 | /* CMD */ | 
|  | 307 | at91_set_A_periph(AT91_PIN_PA1, 1); | 
|  | 308 |  | 
|  | 309 | /* DAT0, maybe DAT1..DAT3 */ | 
|  | 310 | at91_set_A_periph(AT91_PIN_PA0, 1); | 
|  | 311 | if (data->wire4) { | 
|  | 312 | at91_set_A_periph(AT91_PIN_PA3, 1); | 
|  | 313 | at91_set_A_periph(AT91_PIN_PA4, 1); | 
|  | 314 | at91_set_A_periph(AT91_PIN_PA5, 1); | 
|  | 315 | } | 
|  | 316 | } | 
|  | 317 |  | 
|  | 318 | mmc0_data = *data; | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 319 | platform_device_register(&at91sam9263_mmc0_device); | 
|  | 320 | } else {			/* MCI1 */ | 
|  | 321 | /* CLK */ | 
|  | 322 | at91_set_A_periph(AT91_PIN_PA6, 0); | 
|  | 323 |  | 
|  | 324 | if (data->slot_b) { | 
|  | 325 | /* CMD */ | 
|  | 326 | at91_set_A_periph(AT91_PIN_PA21, 1); | 
|  | 327 |  | 
|  | 328 | /* DAT0, maybe DAT1..DAT3 */ | 
|  | 329 | at91_set_A_periph(AT91_PIN_PA22, 1); | 
|  | 330 | if (data->wire4) { | 
|  | 331 | at91_set_A_periph(AT91_PIN_PA23, 1); | 
|  | 332 | at91_set_A_periph(AT91_PIN_PA24, 1); | 
|  | 333 | at91_set_A_periph(AT91_PIN_PA25, 1); | 
|  | 334 | } | 
|  | 335 | } else { | 
|  | 336 | /* CMD */ | 
|  | 337 | at91_set_A_periph(AT91_PIN_PA7, 1); | 
|  | 338 |  | 
|  | 339 | /* DAT0, maybe DAT1..DAT3 */ | 
|  | 340 | at91_set_A_periph(AT91_PIN_PA8, 1); | 
|  | 341 | if (data->wire4) { | 
|  | 342 | at91_set_A_periph(AT91_PIN_PA9, 1); | 
|  | 343 | at91_set_A_periph(AT91_PIN_PA10, 1); | 
|  | 344 | at91_set_A_periph(AT91_PIN_PA11, 1); | 
|  | 345 | } | 
|  | 346 | } | 
|  | 347 |  | 
|  | 348 | mmc1_data = *data; | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 349 | platform_device_register(&at91sam9263_mmc1_device); | 
|  | 350 | } | 
|  | 351 | } | 
|  | 352 | #else | 
|  | 353 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} | 
|  | 354 | #endif | 
|  | 355 |  | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 356 | /* -------------------------------------------------------------------- | 
|  | 357 | *  Compact Flash (PCMCIA or IDE) | 
|  | 358 | * -------------------------------------------------------------------- */ | 
|  | 359 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cf84475 | 2011-12-15 21:24:03 +0800 | [diff] [blame] | 360 | #if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \ | 
|  | 361 | defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 362 |  | 
|  | 363 | static struct at91_cf_data cf0_data; | 
|  | 364 |  | 
|  | 365 | static struct resource cf0_resources[] = { | 
|  | 366 | [0] = { | 
|  | 367 | .start	= AT91_CHIPSELECT_4, | 
|  | 368 | .end	= AT91_CHIPSELECT_4 + SZ_256M - 1, | 
|  | 369 | .flags	= IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, | 
|  | 370 | } | 
|  | 371 | }; | 
|  | 372 |  | 
|  | 373 | static struct platform_device cf0_device = { | 
|  | 374 | .id		= 0, | 
|  | 375 | .dev		= { | 
|  | 376 | .platform_data	= &cf0_data, | 
|  | 377 | }, | 
|  | 378 | .resource	= cf0_resources, | 
|  | 379 | .num_resources	= ARRAY_SIZE(cf0_resources), | 
|  | 380 | }; | 
|  | 381 |  | 
|  | 382 | static struct at91_cf_data cf1_data; | 
|  | 383 |  | 
|  | 384 | static struct resource cf1_resources[] = { | 
|  | 385 | [0] = { | 
|  | 386 | .start	= AT91_CHIPSELECT_5, | 
|  | 387 | .end	= AT91_CHIPSELECT_5 + SZ_256M - 1, | 
|  | 388 | .flags	= IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, | 
|  | 389 | } | 
|  | 390 | }; | 
|  | 391 |  | 
|  | 392 | static struct platform_device cf1_device = { | 
|  | 393 | .id		= 1, | 
|  | 394 | .dev		= { | 
|  | 395 | .platform_data	= &cf1_data, | 
|  | 396 | }, | 
|  | 397 | .resource	= cf1_resources, | 
|  | 398 | .num_resources	= ARRAY_SIZE(cf1_resources), | 
|  | 399 | }; | 
|  | 400 |  | 
|  | 401 | void __init at91_add_device_cf(struct at91_cf_data *data) | 
|  | 402 | { | 
|  | 403 | unsigned long ebi0_csa; | 
|  | 404 | struct platform_device *pdev; | 
|  | 405 |  | 
|  | 406 | if (!data) | 
|  | 407 | return; | 
|  | 408 |  | 
|  | 409 | /* | 
|  | 410 | * assign CS4 or CS5 to SMC with Compact Flash logic support, | 
|  | 411 | * we assume SMC timings are configured by board code, | 
|  | 412 | * except True IDE where timings are controlled by driver | 
|  | 413 | */ | 
| Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 414 | ebi0_csa = at91_matrix_read(AT91_MATRIX_EBI0CSA); | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 415 | switch (data->chipselect) { | 
|  | 416 | case 4: | 
|  | 417 | at91_set_A_periph(AT91_PIN_PD6, 0);  /* EBI0_NCS4/CFCS0 */ | 
|  | 418 | ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1; | 
|  | 419 | cf0_data = *data; | 
|  | 420 | pdev = &cf0_device; | 
|  | 421 | break; | 
|  | 422 | case 5: | 
|  | 423 | at91_set_A_periph(AT91_PIN_PD7, 0);  /* EBI0_NCS5/CFCS1 */ | 
|  | 424 | ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2; | 
|  | 425 | cf1_data = *data; | 
|  | 426 | pdev = &cf1_device; | 
|  | 427 | break; | 
|  | 428 | default: | 
|  | 429 | printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n", | 
|  | 430 | data->chipselect); | 
|  | 431 | return; | 
|  | 432 | } | 
| Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 433 | at91_matrix_write(AT91_MATRIX_EBI0CSA, ebi0_csa); | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 434 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 435 | if (gpio_is_valid(data->det_pin)) { | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 436 | at91_set_gpio_input(data->det_pin, 1); | 
|  | 437 | at91_set_deglitch(data->det_pin, 1); | 
|  | 438 | } | 
|  | 439 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 440 | if (gpio_is_valid(data->irq_pin)) { | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 441 | at91_set_gpio_input(data->irq_pin, 1); | 
|  | 442 | at91_set_deglitch(data->irq_pin, 1); | 
|  | 443 | } | 
|  | 444 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 445 | if (gpio_is_valid(data->vcc_pin)) | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 446 | /* initially off */ | 
|  | 447 | at91_set_gpio_output(data->vcc_pin, 0); | 
|  | 448 |  | 
|  | 449 | /* enable EBI controlled pins */ | 
|  | 450 | at91_set_A_periph(AT91_PIN_PD5, 1);  /* NWAIT */ | 
|  | 451 | at91_set_A_periph(AT91_PIN_PD8, 0);  /* CFCE1 */ | 
|  | 452 | at91_set_A_periph(AT91_PIN_PD9, 0);  /* CFCE2 */ | 
|  | 453 | at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */ | 
|  | 454 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | cf84475 | 2011-12-15 21:24:03 +0800 | [diff] [blame] | 455 | pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "pata_at91" : "at91_cf"; | 
| Stanislaw Gruszka | e565f20 | 2009-03-05 16:10:58 +0100 | [diff] [blame] | 456 | platform_device_register(pdev); | 
|  | 457 | } | 
|  | 458 | #else | 
|  | 459 | void __init at91_add_device_cf(struct at91_cf_data *data) {} | 
|  | 460 | #endif | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 461 |  | 
|  | 462 | /* -------------------------------------------------------------------- | 
|  | 463 | *  NAND / SmartMedia | 
|  | 464 | * -------------------------------------------------------------------- */ | 
|  | 465 |  | 
| Pieter du Preez | f6ed6f7 | 2008-08-01 10:06:40 +0100 | [diff] [blame] | 466 | #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] | 467 | static struct atmel_nand_data nand_data; | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 468 |  | 
|  | 469 | #define NAND_BASE	AT91_CHIPSELECT_3 | 
|  | 470 |  | 
|  | 471 | static struct resource nand_resources[] = { | 
| Andrew Victor | d7a2415 | 2008-04-02 21:44:44 +0100 | [diff] [blame] | 472 | [0] = { | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 473 | .start	= NAND_BASE, | 
|  | 474 | .end	= NAND_BASE + SZ_256M - 1, | 
|  | 475 | .flags	= IORESOURCE_MEM, | 
| Andrew Victor | d7a2415 | 2008-04-02 21:44:44 +0100 | [diff] [blame] | 476 | }, | 
|  | 477 | [1] = { | 
| Jean-Christophe PLAGNIOL-VILLARD | d28edd1 | 2011-09-18 09:31:56 +0800 | [diff] [blame] | 478 | .start	= AT91SAM9263_BASE_ECC0, | 
|  | 479 | .end	= AT91SAM9263_BASE_ECC0 + SZ_512 - 1, | 
| Andrew Victor | d7a2415 | 2008-04-02 21:44:44 +0100 | [diff] [blame] | 480 | .flags	= IORESOURCE_MEM, | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 481 | } | 
|  | 482 | }; | 
|  | 483 |  | 
|  | 484 | static struct platform_device at91sam9263_nand_device = { | 
| HÃ¥vard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 485 | .name		= "atmel_nand", | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 486 | .id		= -1, | 
|  | 487 | .dev		= { | 
|  | 488 | .platform_data	= &nand_data, | 
|  | 489 | }, | 
|  | 490 | .resource	= nand_resources, | 
|  | 491 | .num_resources	= ARRAY_SIZE(nand_resources), | 
|  | 492 | }; | 
|  | 493 |  | 
| HÃ¥vard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 494 | void __init at91_add_device_nand(struct atmel_nand_data *data) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 495 | { | 
| Andrew Victor | 461d3b4 | 2008-10-06 20:01:00 +0100 | [diff] [blame] | 496 | unsigned long csa; | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 497 |  | 
|  | 498 | if (!data) | 
|  | 499 | return; | 
|  | 500 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 501 | csa = at91_matrix_read(AT91_MATRIX_EBI0CSA); | 
|  | 502 | at91_matrix_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 503 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 504 | /* enable pin */ | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 505 | if (gpio_is_valid(data->enable_pin)) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 506 | at91_set_gpio_output(data->enable_pin, 1); | 
|  | 507 |  | 
|  | 508 | /* ready/busy pin */ | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 509 | if (gpio_is_valid(data->rdy_pin)) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 510 | at91_set_gpio_input(data->rdy_pin, 1); | 
|  | 511 |  | 
|  | 512 | /* card detect pin */ | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 513 | if (gpio_is_valid(data->det_pin)) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 514 | at91_set_gpio_input(data->det_pin, 1); | 
|  | 515 |  | 
|  | 516 | nand_data = *data; | 
|  | 517 | platform_device_register(&at91sam9263_nand_device); | 
|  | 518 | } | 
|  | 519 | #else | 
| HÃ¥vard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 520 | void __init at91_add_device_nand(struct atmel_nand_data *data) {} | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 521 | #endif | 
|  | 522 |  | 
|  | 523 |  | 
|  | 524 | /* -------------------------------------------------------------------- | 
|  | 525 | *  TWI (i2c) | 
|  | 526 | * -------------------------------------------------------------------- */ | 
|  | 527 |  | 
| Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 528 | /* | 
|  | 529 | * Prefer the GPIO code since the TWI controller isn't robust | 
|  | 530 | * (gets overruns and underruns under load) and can only issue | 
|  | 531 | * repeated STARTs in one scenario (the driver doesn't yet handle them). | 
|  | 532 | */ | 
|  | 533 | #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) | 
|  | 534 |  | 
|  | 535 | static struct i2c_gpio_platform_data pdata = { | 
|  | 536 | .sda_pin		= AT91_PIN_PB4, | 
|  | 537 | .sda_is_open_drain	= 1, | 
|  | 538 | .scl_pin		= AT91_PIN_PB5, | 
|  | 539 | .scl_is_open_drain	= 1, | 
|  | 540 | .udelay			= 2,		/* ~100 kHz */ | 
|  | 541 | }; | 
|  | 542 |  | 
|  | 543 | static struct platform_device at91sam9263_twi_device = { | 
|  | 544 | .name			= "i2c-gpio", | 
|  | 545 | .id			= -1, | 
|  | 546 | .dev.platform_data	= &pdata, | 
|  | 547 | }; | 
|  | 548 |  | 
|  | 549 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) | 
|  | 550 | { | 
|  | 551 | at91_set_GPIO_periph(AT91_PIN_PB4, 1);		/* TWD (SDA) */ | 
|  | 552 | at91_set_multi_drive(AT91_PIN_PB4, 1); | 
|  | 553 |  | 
|  | 554 | at91_set_GPIO_periph(AT91_PIN_PB5, 1);		/* TWCK (SCL) */ | 
|  | 555 | at91_set_multi_drive(AT91_PIN_PB5, 1); | 
|  | 556 |  | 
|  | 557 | i2c_register_board_info(0, devices, nr_devices); | 
|  | 558 | platform_device_register(&at91sam9263_twi_device); | 
|  | 559 | } | 
|  | 560 |  | 
|  | 561 | #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 562 |  | 
|  | 563 | static struct resource twi_resources[] = { | 
|  | 564 | [0] = { | 
|  | 565 | .start	= AT91SAM9263_BASE_TWI, | 
|  | 566 | .end	= AT91SAM9263_BASE_TWI + SZ_16K - 1, | 
|  | 567 | .flags	= IORESOURCE_MEM, | 
|  | 568 | }, | 
|  | 569 | [1] = { | 
|  | 570 | .start	= AT91SAM9263_ID_TWI, | 
|  | 571 | .end	= AT91SAM9263_ID_TWI, | 
|  | 572 | .flags	= IORESOURCE_IRQ, | 
|  | 573 | }, | 
|  | 574 | }; | 
|  | 575 |  | 
|  | 576 | static struct platform_device at91sam9263_twi_device = { | 
|  | 577 | .name		= "at91_i2c", | 
|  | 578 | .id		= -1, | 
|  | 579 | .resource	= twi_resources, | 
|  | 580 | .num_resources	= ARRAY_SIZE(twi_resources), | 
|  | 581 | }; | 
|  | 582 |  | 
| Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 583 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 584 | { | 
|  | 585 | /* pins used for TWI interface */ | 
|  | 586 | at91_set_A_periph(AT91_PIN_PB4, 0);		/* TWD */ | 
|  | 587 | at91_set_multi_drive(AT91_PIN_PB4, 1); | 
|  | 588 |  | 
|  | 589 | at91_set_A_periph(AT91_PIN_PB5, 0);		/* TWCK */ | 
|  | 590 | at91_set_multi_drive(AT91_PIN_PB5, 1); | 
|  | 591 |  | 
| Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 592 | i2c_register_board_info(0, devices, nr_devices); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 593 | platform_device_register(&at91sam9263_twi_device); | 
|  | 594 | } | 
|  | 595 | #else | 
| Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 596 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 597 | #endif | 
|  | 598 |  | 
|  | 599 |  | 
|  | 600 | /* -------------------------------------------------------------------- | 
|  | 601 | *  SPI | 
|  | 602 | * -------------------------------------------------------------------- */ | 
|  | 603 |  | 
|  | 604 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 605 | static u64 spi_dmamask = DMA_BIT_MASK(32); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 606 |  | 
|  | 607 | static struct resource spi0_resources[] = { | 
|  | 608 | [0] = { | 
|  | 609 | .start	= AT91SAM9263_BASE_SPI0, | 
|  | 610 | .end	= AT91SAM9263_BASE_SPI0 + SZ_16K - 1, | 
|  | 611 | .flags	= IORESOURCE_MEM, | 
|  | 612 | }, | 
|  | 613 | [1] = { | 
|  | 614 | .start	= AT91SAM9263_ID_SPI0, | 
|  | 615 | .end	= AT91SAM9263_ID_SPI0, | 
|  | 616 | .flags	= IORESOURCE_IRQ, | 
|  | 617 | }, | 
|  | 618 | }; | 
|  | 619 |  | 
|  | 620 | static struct platform_device at91sam9263_spi0_device = { | 
|  | 621 | .name		= "atmel_spi", | 
|  | 622 | .id		= 0, | 
|  | 623 | .dev		= { | 
|  | 624 | .dma_mask		= &spi_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 625 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 626 | }, | 
|  | 627 | .resource	= spi0_resources, | 
|  | 628 | .num_resources	= ARRAY_SIZE(spi0_resources), | 
|  | 629 | }; | 
|  | 630 |  | 
|  | 631 | static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 }; | 
|  | 632 |  | 
|  | 633 | static struct resource spi1_resources[] = { | 
|  | 634 | [0] = { | 
|  | 635 | .start	= AT91SAM9263_BASE_SPI1, | 
|  | 636 | .end	= AT91SAM9263_BASE_SPI1 + SZ_16K - 1, | 
|  | 637 | .flags	= IORESOURCE_MEM, | 
|  | 638 | }, | 
|  | 639 | [1] = { | 
|  | 640 | .start	= AT91SAM9263_ID_SPI1, | 
|  | 641 | .end	= AT91SAM9263_ID_SPI1, | 
|  | 642 | .flags	= IORESOURCE_IRQ, | 
|  | 643 | }, | 
|  | 644 | }; | 
|  | 645 |  | 
|  | 646 | static struct platform_device at91sam9263_spi1_device = { | 
|  | 647 | .name		= "atmel_spi", | 
|  | 648 | .id		= 1, | 
|  | 649 | .dev		= { | 
|  | 650 | .dma_mask		= &spi_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 651 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 652 | }, | 
|  | 653 | .resource	= spi1_resources, | 
|  | 654 | .num_resources	= ARRAY_SIZE(spi1_resources), | 
|  | 655 | }; | 
|  | 656 |  | 
|  | 657 | static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 }; | 
|  | 658 |  | 
|  | 659 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | 
|  | 660 | { | 
|  | 661 | int i; | 
|  | 662 | unsigned long cs_pin; | 
|  | 663 | short enable_spi0 = 0; | 
|  | 664 | short enable_spi1 = 0; | 
|  | 665 |  | 
|  | 666 | /* Choose SPI chip-selects */ | 
|  | 667 | for (i = 0; i < nr_devices; i++) { | 
|  | 668 | if (devices[i].controller_data) | 
|  | 669 | cs_pin = (unsigned long) devices[i].controller_data; | 
|  | 670 | else if (devices[i].bus_num == 0) | 
|  | 671 | cs_pin = spi0_standard_cs[devices[i].chip_select]; | 
|  | 672 | else | 
|  | 673 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | 
|  | 674 |  | 
|  | 675 | if (devices[i].bus_num == 0) | 
|  | 676 | enable_spi0 = 1; | 
|  | 677 | else | 
|  | 678 | enable_spi1 = 1; | 
|  | 679 |  | 
|  | 680 | /* enable chip-select pin */ | 
|  | 681 | at91_set_gpio_output(cs_pin, 1); | 
|  | 682 |  | 
|  | 683 | /* pass chip-select pin to driver */ | 
|  | 684 | devices[i].controller_data = (void *) cs_pin; | 
|  | 685 | } | 
|  | 686 |  | 
|  | 687 | spi_register_board_info(devices, nr_devices); | 
|  | 688 |  | 
|  | 689 | /* Configure SPI bus(es) */ | 
|  | 690 | if (enable_spi0) { | 
|  | 691 | at91_set_B_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */ | 
|  | 692 | at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */ | 
| Andrew Victor | 7f6e2d9 | 2007-02-22 07:34:56 +0100 | [diff] [blame] | 693 | at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */ | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 694 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 695 | platform_device_register(&at91sam9263_spi0_device); | 
|  | 696 | } | 
|  | 697 | if (enable_spi1) { | 
|  | 698 | at91_set_A_periph(AT91_PIN_PB12, 0);	/* SPI1_MISO */ | 
|  | 699 | at91_set_A_periph(AT91_PIN_PB13, 0);	/* SPI1_MOSI */ | 
|  | 700 | at91_set_A_periph(AT91_PIN_PB14, 0);	/* SPI1_SPCK */ | 
|  | 701 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 702 | platform_device_register(&at91sam9263_spi1_device); | 
|  | 703 | } | 
|  | 704 | } | 
|  | 705 | #else | 
|  | 706 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} | 
|  | 707 | #endif | 
|  | 708 |  | 
|  | 709 |  | 
|  | 710 | /* -------------------------------------------------------------------- | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 711 | *  AC97 | 
|  | 712 | * -------------------------------------------------------------------- */ | 
|  | 713 |  | 
| sedji gaouaou | d656f07 | 2009-08-06 15:20:22 +0100 | [diff] [blame] | 714 | #if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE) | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 715 | static u64 ac97_dmamask = DMA_BIT_MASK(32); | 
| sedji gaouaou | d656f07 | 2009-08-06 15:20:22 +0100 | [diff] [blame] | 716 | static struct ac97c_platform_data ac97_data; | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 717 |  | 
|  | 718 | static struct resource ac97_resources[] = { | 
|  | 719 | [0] = { | 
|  | 720 | .start	= AT91SAM9263_BASE_AC97C, | 
|  | 721 | .end	= AT91SAM9263_BASE_AC97C + SZ_16K - 1, | 
|  | 722 | .flags	= IORESOURCE_MEM, | 
|  | 723 | }, | 
|  | 724 | [1] = { | 
|  | 725 | .start	= AT91SAM9263_ID_AC97C, | 
|  | 726 | .end	= AT91SAM9263_ID_AC97C, | 
|  | 727 | .flags	= IORESOURCE_IRQ, | 
|  | 728 | }, | 
|  | 729 | }; | 
|  | 730 |  | 
|  | 731 | static struct platform_device at91sam9263_ac97_device = { | 
| sedji gaouaou | d656f07 | 2009-08-06 15:20:22 +0100 | [diff] [blame] | 732 | .name		= "atmel_ac97c", | 
|  | 733 | .id		= 0, | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 734 | .dev		= { | 
|  | 735 | .dma_mask		= &ac97_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 736 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 737 | .platform_data		= &ac97_data, | 
|  | 738 | }, | 
|  | 739 | .resource	= ac97_resources, | 
|  | 740 | .num_resources	= ARRAY_SIZE(ac97_resources), | 
|  | 741 | }; | 
|  | 742 |  | 
| sedji gaouaou | d656f07 | 2009-08-06 15:20:22 +0100 | [diff] [blame] | 743 | void __init at91_add_device_ac97(struct ac97c_platform_data *data) | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 744 | { | 
|  | 745 | if (!data) | 
|  | 746 | return; | 
|  | 747 |  | 
|  | 748 | at91_set_A_periph(AT91_PIN_PB0, 0);	/* AC97FS */ | 
|  | 749 | at91_set_A_periph(AT91_PIN_PB1, 0);	/* AC97CK */ | 
|  | 750 | at91_set_A_periph(AT91_PIN_PB2, 0);	/* AC97TX */ | 
|  | 751 | at91_set_A_periph(AT91_PIN_PB3, 0);	/* AC97RX */ | 
|  | 752 |  | 
|  | 753 | /* reset */ | 
| Jean-Christophe PLAGNIOL-VILLARD | cc9f9ae | 2011-09-19 15:28:25 +0800 | [diff] [blame] | 754 | if (gpio_is_valid(data->reset_pin)) | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 755 | at91_set_gpio_output(data->reset_pin, 0); | 
|  | 756 |  | 
| sedji gaouaou | d656f07 | 2009-08-06 15:20:22 +0100 | [diff] [blame] | 757 | ac97_data = *data; | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 758 | platform_device_register(&at91sam9263_ac97_device); | 
|  | 759 | } | 
|  | 760 | #else | 
| sedji gaouaou | d656f07 | 2009-08-06 15:20:22 +0100 | [diff] [blame] | 761 | void __init at91_add_device_ac97(struct ac97c_platform_data *data) {} | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 762 | #endif | 
|  | 763 |  | 
| Marc Kleine-Budde | 58a587d | 2009-09-16 23:37:32 +0000 | [diff] [blame] | 764 | /* -------------------------------------------------------------------- | 
|  | 765 | *  CAN Controller | 
|  | 766 | * -------------------------------------------------------------------- */ | 
|  | 767 |  | 
|  | 768 | #if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE) | 
|  | 769 | static struct resource can_resources[] = { | 
|  | 770 | [0] = { | 
|  | 771 | .start	= AT91SAM9263_BASE_CAN, | 
|  | 772 | .end	= AT91SAM9263_BASE_CAN + SZ_16K - 1, | 
|  | 773 | .flags	= IORESOURCE_MEM, | 
|  | 774 | }, | 
|  | 775 | [1] = { | 
|  | 776 | .start	= AT91SAM9263_ID_CAN, | 
|  | 777 | .end	= AT91SAM9263_ID_CAN, | 
|  | 778 | .flags	= IORESOURCE_IRQ, | 
|  | 779 | }, | 
|  | 780 | }; | 
|  | 781 |  | 
|  | 782 | static struct platform_device at91sam9263_can_device = { | 
|  | 783 | .name		= "at91_can", | 
|  | 784 | .id		= -1, | 
|  | 785 | .resource	= can_resources, | 
|  | 786 | .num_resources	= ARRAY_SIZE(can_resources), | 
|  | 787 | }; | 
|  | 788 |  | 
|  | 789 | void __init at91_add_device_can(struct at91_can_data *data) | 
|  | 790 | { | 
|  | 791 | at91_set_A_periph(AT91_PIN_PA13, 0);	/* CANTX */ | 
|  | 792 | at91_set_A_periph(AT91_PIN_PA14, 0);	/* CANRX */ | 
|  | 793 | at91sam9263_can_device.dev.platform_data = data; | 
|  | 794 |  | 
|  | 795 | platform_device_register(&at91sam9263_can_device); | 
|  | 796 | } | 
|  | 797 | #else | 
|  | 798 | void __init at91_add_device_can(struct at91_can_data *data) {} | 
|  | 799 | #endif | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 800 |  | 
|  | 801 | /* -------------------------------------------------------------------- | 
|  | 802 | *  LCD Controller | 
|  | 803 | * -------------------------------------------------------------------- */ | 
|  | 804 |  | 
|  | 805 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 806 | static u64 lcdc_dmamask = DMA_BIT_MASK(32); | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 807 | static struct atmel_lcdfb_info lcdc_data; | 
|  | 808 |  | 
|  | 809 | static struct resource lcdc_resources[] = { | 
|  | 810 | [0] = { | 
|  | 811 | .start	= AT91SAM9263_LCDC_BASE, | 
|  | 812 | .end	= AT91SAM9263_LCDC_BASE + SZ_4K - 1, | 
|  | 813 | .flags	= IORESOURCE_MEM, | 
|  | 814 | }, | 
|  | 815 | [1] = { | 
|  | 816 | .start	= AT91SAM9263_ID_LCDC, | 
|  | 817 | .end	= AT91SAM9263_ID_LCDC, | 
|  | 818 | .flags	= IORESOURCE_IRQ, | 
|  | 819 | }, | 
|  | 820 | }; | 
|  | 821 |  | 
|  | 822 | static struct platform_device at91_lcdc_device = { | 
|  | 823 | .name		= "atmel_lcdfb", | 
|  | 824 | .id		= 0, | 
|  | 825 | .dev		= { | 
|  | 826 | .dma_mask		= &lcdc_dmamask, | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 827 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
| Andrew Victor | 7776a94 | 2007-05-02 17:46:49 +0100 | [diff] [blame] | 828 | .platform_data		= &lcdc_data, | 
|  | 829 | }, | 
|  | 830 | .resource	= lcdc_resources, | 
|  | 831 | .num_resources	= ARRAY_SIZE(lcdc_resources), | 
|  | 832 | }; | 
|  | 833 |  | 
|  | 834 | void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) | 
|  | 835 | { | 
|  | 836 | if (!data) | 
|  | 837 | return; | 
|  | 838 |  | 
|  | 839 | at91_set_A_periph(AT91_PIN_PC1, 0);	/* LCDHSYNC */ | 
|  | 840 | at91_set_A_periph(AT91_PIN_PC2, 0);	/* LCDDOTCK */ | 
|  | 841 | at91_set_A_periph(AT91_PIN_PC3, 0);	/* LCDDEN */ | 
|  | 842 | at91_set_B_periph(AT91_PIN_PB9, 0);	/* LCDCC */ | 
|  | 843 | at91_set_A_periph(AT91_PIN_PC6, 0);	/* LCDD2 */ | 
|  | 844 | at91_set_A_periph(AT91_PIN_PC7, 0);	/* LCDD3 */ | 
|  | 845 | at91_set_A_periph(AT91_PIN_PC8, 0);	/* LCDD4 */ | 
|  | 846 | at91_set_A_periph(AT91_PIN_PC9, 0);	/* LCDD5 */ | 
|  | 847 | at91_set_A_periph(AT91_PIN_PC10, 0);	/* LCDD6 */ | 
|  | 848 | at91_set_A_periph(AT91_PIN_PC11, 0);	/* LCDD7 */ | 
|  | 849 | at91_set_A_periph(AT91_PIN_PC14, 0);	/* LCDD10 */ | 
|  | 850 | at91_set_A_periph(AT91_PIN_PC15, 0);	/* LCDD11 */ | 
|  | 851 | at91_set_A_periph(AT91_PIN_PC16, 0);	/* LCDD12 */ | 
|  | 852 | at91_set_B_periph(AT91_PIN_PC12, 0);	/* LCDD13 */ | 
|  | 853 | at91_set_A_periph(AT91_PIN_PC18, 0);	/* LCDD14 */ | 
|  | 854 | at91_set_A_periph(AT91_PIN_PC19, 0);	/* LCDD15 */ | 
|  | 855 | at91_set_A_periph(AT91_PIN_PC22, 0);	/* LCDD18 */ | 
|  | 856 | at91_set_A_periph(AT91_PIN_PC23, 0);	/* LCDD19 */ | 
|  | 857 | at91_set_A_periph(AT91_PIN_PC24, 0);	/* LCDD20 */ | 
|  | 858 | at91_set_B_periph(AT91_PIN_PC17, 0);	/* LCDD21 */ | 
|  | 859 | at91_set_A_periph(AT91_PIN_PC26, 0);	/* LCDD22 */ | 
|  | 860 | at91_set_A_periph(AT91_PIN_PC27, 0);	/* LCDD23 */ | 
|  | 861 |  | 
|  | 862 | lcdc_data = *data; | 
|  | 863 | platform_device_register(&at91_lcdc_device); | 
|  | 864 | } | 
|  | 865 | #else | 
|  | 866 | void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} | 
|  | 867 | #endif | 
|  | 868 |  | 
|  | 869 |  | 
|  | 870 | /* -------------------------------------------------------------------- | 
| Andrew Victor | e292080 | 2008-01-22 11:43:26 +0100 | [diff] [blame] | 871 | *  Image Sensor Interface | 
|  | 872 | * -------------------------------------------------------------------- */ | 
|  | 873 |  | 
|  | 874 | #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE) | 
|  | 875 |  | 
|  | 876 | struct resource isi_resources[] = { | 
|  | 877 | [0] = { | 
|  | 878 | .start	= AT91SAM9263_BASE_ISI, | 
|  | 879 | .end	= AT91SAM9263_BASE_ISI + SZ_16K - 1, | 
|  | 880 | .flags	= IORESOURCE_MEM, | 
|  | 881 | }, | 
|  | 882 | [1] = { | 
|  | 883 | .start	= AT91SAM9263_ID_ISI, | 
|  | 884 | .end	= AT91SAM9263_ID_ISI, | 
|  | 885 | .flags	= IORESOURCE_IRQ, | 
|  | 886 | }, | 
|  | 887 | }; | 
|  | 888 |  | 
|  | 889 | static struct platform_device at91sam9263_isi_device = { | 
|  | 890 | .name		= "at91_isi", | 
|  | 891 | .id		= -1, | 
|  | 892 | .resource	= isi_resources, | 
|  | 893 | .num_resources	= ARRAY_SIZE(isi_resources), | 
|  | 894 | }; | 
|  | 895 |  | 
| Josh Wu | 45bb9e6 | 2011-10-22 15:17:39 +0800 | [diff] [blame] | 896 | void __init at91_add_device_isi(struct isi_platform_data *data, | 
|  | 897 | bool use_pck_as_mck) | 
| Andrew Victor | e292080 | 2008-01-22 11:43:26 +0100 | [diff] [blame] | 898 | { | 
|  | 899 | at91_set_A_periph(AT91_PIN_PE0, 0);	/* ISI_D0 */ | 
|  | 900 | at91_set_A_periph(AT91_PIN_PE1, 0);	/* ISI_D1 */ | 
|  | 901 | at91_set_A_periph(AT91_PIN_PE2, 0);	/* ISI_D2 */ | 
|  | 902 | at91_set_A_periph(AT91_PIN_PE3, 0);	/* ISI_D3 */ | 
|  | 903 | at91_set_A_periph(AT91_PIN_PE4, 0);	/* ISI_D4 */ | 
|  | 904 | at91_set_A_periph(AT91_PIN_PE5, 0);	/* ISI_D5 */ | 
|  | 905 | at91_set_A_periph(AT91_PIN_PE6, 0);	/* ISI_D6 */ | 
|  | 906 | at91_set_A_periph(AT91_PIN_PE7, 0);	/* ISI_D7 */ | 
|  | 907 | at91_set_A_periph(AT91_PIN_PE8, 0);	/* ISI_PCK */ | 
|  | 908 | at91_set_A_periph(AT91_PIN_PE9, 0);	/* ISI_HSYNC */ | 
|  | 909 | at91_set_A_periph(AT91_PIN_PE10, 0);	/* ISI_VSYNC */ | 
| Andrew Victor | e292080 | 2008-01-22 11:43:26 +0100 | [diff] [blame] | 910 | at91_set_B_periph(AT91_PIN_PE12, 0);	/* ISI_PD8 */ | 
|  | 911 | at91_set_B_periph(AT91_PIN_PE13, 0);	/* ISI_PD9 */ | 
|  | 912 | at91_set_B_periph(AT91_PIN_PE14, 0);	/* ISI_PD10 */ | 
|  | 913 | at91_set_B_periph(AT91_PIN_PE15, 0);	/* ISI_PD11 */ | 
| Josh Wu | 45bb9e6 | 2011-10-22 15:17:39 +0800 | [diff] [blame] | 914 |  | 
|  | 915 | if (use_pck_as_mck) { | 
|  | 916 | at91_set_B_periph(AT91_PIN_PE11, 0);	/* ISI_MCK (PCK3) */ | 
|  | 917 |  | 
|  | 918 | /* TODO: register the PCK for ISI_MCK and set its parent */ | 
|  | 919 | } | 
| Andrew Victor | e292080 | 2008-01-22 11:43:26 +0100 | [diff] [blame] | 920 | } | 
|  | 921 | #else | 
| Josh Wu | 45bb9e6 | 2011-10-22 15:17:39 +0800 | [diff] [blame] | 922 | void __init at91_add_device_isi(struct isi_platform_data *data, | 
|  | 923 | bool use_pck_as_mck) {} | 
| Andrew Victor | e292080 | 2008-01-22 11:43:26 +0100 | [diff] [blame] | 924 | #endif | 
|  | 925 |  | 
|  | 926 |  | 
|  | 927 | /* -------------------------------------------------------------------- | 
| Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 928 | *  Timer/Counter block | 
|  | 929 | * -------------------------------------------------------------------- */ | 
|  | 930 |  | 
|  | 931 | #ifdef CONFIG_ATMEL_TCLIB | 
|  | 932 |  | 
|  | 933 | static struct resource tcb_resources[] = { | 
|  | 934 | [0] = { | 
|  | 935 | .start	= AT91SAM9263_BASE_TCB0, | 
|  | 936 | .end	= AT91SAM9263_BASE_TCB0 + SZ_16K - 1, | 
|  | 937 | .flags	= IORESOURCE_MEM, | 
|  | 938 | }, | 
|  | 939 | [1] = { | 
|  | 940 | .start	= AT91SAM9263_ID_TCB, | 
|  | 941 | .end	= AT91SAM9263_ID_TCB, | 
|  | 942 | .flags	= IORESOURCE_IRQ, | 
|  | 943 | }, | 
|  | 944 | }; | 
|  | 945 |  | 
|  | 946 | static struct platform_device at91sam9263_tcb_device = { | 
|  | 947 | .name		= "atmel_tcb", | 
|  | 948 | .id		= 0, | 
|  | 949 | .resource	= tcb_resources, | 
|  | 950 | .num_resources	= ARRAY_SIZE(tcb_resources), | 
|  | 951 | }; | 
|  | 952 |  | 
|  | 953 | static void __init at91_add_device_tc(void) | 
|  | 954 | { | 
| Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 955 | platform_device_register(&at91sam9263_tcb_device); | 
|  | 956 | } | 
|  | 957 | #else | 
|  | 958 | static void __init at91_add_device_tc(void) { } | 
|  | 959 | #endif | 
|  | 960 |  | 
|  | 961 |  | 
|  | 962 | /* -------------------------------------------------------------------- | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 963 | *  RTT | 
|  | 964 | * -------------------------------------------------------------------- */ | 
|  | 965 |  | 
|  | 966 | static struct resource rtt0_resources[] = { | 
|  | 967 | { | 
| Jean-Christophe PLAGNIOL-VILLARD | eab5fd6 | 2011-09-18 10:12:00 +0800 | [diff] [blame] | 968 | .start	= AT91SAM9263_BASE_RTT0, | 
|  | 969 | .end	= AT91SAM9263_BASE_RTT0 + SZ_16 - 1, | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 970 | .flags	= IORESOURCE_MEM, | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 971 | }, { | 
|  | 972 | .flags	= IORESOURCE_MEM, | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 973 | } | 
|  | 974 | }; | 
|  | 975 |  | 
|  | 976 | static struct platform_device at91sam9263_rtt0_device = { | 
|  | 977 | .name		= "at91_rtt", | 
|  | 978 | .id		= 0, | 
|  | 979 | .resource	= rtt0_resources, | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 980 | }; | 
|  | 981 |  | 
|  | 982 | static struct resource rtt1_resources[] = { | 
|  | 983 | { | 
| Jean-Christophe PLAGNIOL-VILLARD | eab5fd6 | 2011-09-18 10:12:00 +0800 | [diff] [blame] | 984 | .start	= AT91SAM9263_BASE_RTT1, | 
|  | 985 | .end	= AT91SAM9263_BASE_RTT1 + SZ_16 - 1, | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 986 | .flags	= IORESOURCE_MEM, | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 987 | }, { | 
|  | 988 | .flags	= IORESOURCE_MEM, | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 989 | } | 
|  | 990 | }; | 
|  | 991 |  | 
|  | 992 | static struct platform_device at91sam9263_rtt1_device = { | 
|  | 993 | .name		= "at91_rtt", | 
|  | 994 | .id		= 1, | 
|  | 995 | .resource	= rtt1_resources, | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 996 | }; | 
|  | 997 |  | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 998 | #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9) | 
|  | 999 | static void __init at91_add_device_rtt_rtc(void) | 
|  | 1000 | { | 
|  | 1001 | struct platform_device *pdev; | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1002 | struct resource *r; | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1003 |  | 
|  | 1004 | switch (CONFIG_RTC_DRV_AT91SAM9_RTT) { | 
|  | 1005 | case 0: | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1006 | /* | 
|  | 1007 | * The second resource is needed only for the chosen RTT: | 
|  | 1008 | * GPBR will serve as the storage for RTC time offset | 
|  | 1009 | */ | 
|  | 1010 | at91sam9263_rtt0_device.num_resources = 2; | 
|  | 1011 | at91sam9263_rtt1_device.num_resources = 1; | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1012 | pdev = &at91sam9263_rtt0_device; | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1013 | r = rtt0_resources; | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1014 | break; | 
|  | 1015 | case 1: | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1016 | at91sam9263_rtt0_device.num_resources = 1; | 
|  | 1017 | at91sam9263_rtt1_device.num_resources = 2; | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1018 | pdev = &at91sam9263_rtt1_device; | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1019 | r = rtt1_resources; | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1020 | break; | 
|  | 1021 | default: | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1022 | pr_err("at91sam9263: only supports 2 RTT (%d)\n", | 
|  | 1023 | CONFIG_RTC_DRV_AT91SAM9_RTT); | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1024 | return; | 
|  | 1025 | } | 
|  | 1026 |  | 
|  | 1027 | pdev->name = "rtc-at91sam9"; | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1028 | r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR; | 
|  | 1029 | r[1].end = r[1].start + 3; | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1030 | } | 
|  | 1031 | #else | 
| Jean-Christophe PLAGNIOL-VILLARD | b3af8b4 | 2012-02-15 21:24:46 +0800 | [diff] [blame] | 1032 | static void __init at91_add_device_rtt_rtc(void) | 
|  | 1033 | { | 
|  | 1034 | /* Only one resource is needed: RTT not used as RTC */ | 
|  | 1035 | at91sam9263_rtt0_device.num_resources = 1; | 
|  | 1036 | at91sam9263_rtt1_device.num_resources = 1; | 
|  | 1037 | } | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1038 | #endif | 
|  | 1039 |  | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 1040 | static void __init at91_add_device_rtt(void) | 
|  | 1041 | { | 
| Jean-Christophe PLAGNIOL-VILLARD | 205056a | 2012-02-15 20:51:37 +0800 | [diff] [blame] | 1042 | at91_add_device_rtt_rtc(); | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 1043 | platform_device_register(&at91sam9263_rtt0_device); | 
|  | 1044 | platform_device_register(&at91sam9263_rtt1_device); | 
|  | 1045 | } | 
|  | 1046 |  | 
|  | 1047 |  | 
|  | 1048 | /* -------------------------------------------------------------------- | 
|  | 1049 | *  Watchdog | 
|  | 1050 | * -------------------------------------------------------------------- */ | 
|  | 1051 |  | 
| Andrew Victor | 2af29b7 | 2009-02-11 21:23:10 +0100 | [diff] [blame] | 1052 | #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) | 
| Jean-Christophe PLAGNIOL-VILLARD | c1c30a2 | 2011-11-02 01:43:31 +0800 | [diff] [blame] | 1053 | static struct resource wdt_resources[] = { | 
|  | 1054 | { | 
|  | 1055 | .start	= AT91SAM9263_BASE_WDT, | 
|  | 1056 | .end	= AT91SAM9263_BASE_WDT + SZ_16 - 1, | 
|  | 1057 | .flags	= IORESOURCE_MEM, | 
|  | 1058 | } | 
|  | 1059 | }; | 
|  | 1060 |  | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 1061 | static struct platform_device at91sam9263_wdt_device = { | 
|  | 1062 | .name		= "at91_wdt", | 
|  | 1063 | .id		= -1, | 
| Jean-Christophe PLAGNIOL-VILLARD | c1c30a2 | 2011-11-02 01:43:31 +0800 | [diff] [blame] | 1064 | .resource	= wdt_resources, | 
|  | 1065 | .num_resources	= ARRAY_SIZE(wdt_resources), | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 1066 | }; | 
|  | 1067 |  | 
|  | 1068 | static void __init at91_add_device_watchdog(void) | 
|  | 1069 | { | 
|  | 1070 | platform_device_register(&at91sam9263_wdt_device); | 
|  | 1071 | } | 
|  | 1072 | #else | 
|  | 1073 | static void __init at91_add_device_watchdog(void) {} | 
|  | 1074 | #endif | 
|  | 1075 |  | 
|  | 1076 |  | 
|  | 1077 | /* -------------------------------------------------------------------- | 
| Andrew Victor | bb1ad68 | 2008-09-18 19:42:37 +0100 | [diff] [blame] | 1078 | *  PWM | 
|  | 1079 | * --------------------------------------------------------------------*/ | 
|  | 1080 |  | 
|  | 1081 | #if defined(CONFIG_ATMEL_PWM) | 
|  | 1082 | static u32 pwm_mask; | 
|  | 1083 |  | 
|  | 1084 | static struct resource pwm_resources[] = { | 
|  | 1085 | [0] = { | 
|  | 1086 | .start	= AT91SAM9263_BASE_PWMC, | 
|  | 1087 | .end	= AT91SAM9263_BASE_PWMC + SZ_16K - 1, | 
|  | 1088 | .flags	= IORESOURCE_MEM, | 
|  | 1089 | }, | 
|  | 1090 | [1] = { | 
|  | 1091 | .start	= AT91SAM9263_ID_PWMC, | 
|  | 1092 | .end	= AT91SAM9263_ID_PWMC, | 
|  | 1093 | .flags	= IORESOURCE_IRQ, | 
|  | 1094 | }, | 
|  | 1095 | }; | 
|  | 1096 |  | 
|  | 1097 | static struct platform_device at91sam9263_pwm0_device = { | 
|  | 1098 | .name	= "atmel_pwm", | 
|  | 1099 | .id	= -1, | 
|  | 1100 | .dev	= { | 
|  | 1101 | .platform_data		= &pwm_mask, | 
|  | 1102 | }, | 
|  | 1103 | .resource	= pwm_resources, | 
|  | 1104 | .num_resources	= ARRAY_SIZE(pwm_resources), | 
|  | 1105 | }; | 
|  | 1106 |  | 
|  | 1107 | void __init at91_add_device_pwm(u32 mask) | 
|  | 1108 | { | 
|  | 1109 | if (mask & (1 << AT91_PWM0)) | 
|  | 1110 | at91_set_B_periph(AT91_PIN_PB7, 1);	/* enable PWM0 */ | 
|  | 1111 |  | 
|  | 1112 | if (mask & (1 << AT91_PWM1)) | 
|  | 1113 | at91_set_B_periph(AT91_PIN_PB8, 1);	/* enable PWM1 */ | 
|  | 1114 |  | 
|  | 1115 | if (mask & (1 << AT91_PWM2)) | 
|  | 1116 | at91_set_B_periph(AT91_PIN_PC29, 1);	/* enable PWM2 */ | 
|  | 1117 |  | 
|  | 1118 | if (mask & (1 << AT91_PWM3)) | 
|  | 1119 | at91_set_B_periph(AT91_PIN_PB29, 1);	/* enable PWM3 */ | 
|  | 1120 |  | 
|  | 1121 | pwm_mask = mask; | 
|  | 1122 |  | 
|  | 1123 | platform_device_register(&at91sam9263_pwm0_device); | 
|  | 1124 | } | 
|  | 1125 | #else | 
|  | 1126 | void __init at91_add_device_pwm(u32 mask) {} | 
|  | 1127 | #endif | 
|  | 1128 |  | 
|  | 1129 |  | 
|  | 1130 | /* -------------------------------------------------------------------- | 
| Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 1131 | *  SSC -- Synchronous Serial Controller | 
|  | 1132 | * -------------------------------------------------------------------- */ | 
|  | 1133 |  | 
|  | 1134 | #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE) | 
|  | 1135 | static u64 ssc0_dmamask = DMA_BIT_MASK(32); | 
|  | 1136 |  | 
|  | 1137 | static struct resource ssc0_resources[] = { | 
|  | 1138 | [0] = { | 
|  | 1139 | .start	= AT91SAM9263_BASE_SSC0, | 
|  | 1140 | .end	= AT91SAM9263_BASE_SSC0 + SZ_16K - 1, | 
|  | 1141 | .flags	= IORESOURCE_MEM, | 
|  | 1142 | }, | 
|  | 1143 | [1] = { | 
|  | 1144 | .start	= AT91SAM9263_ID_SSC0, | 
|  | 1145 | .end	= AT91SAM9263_ID_SSC0, | 
|  | 1146 | .flags	= IORESOURCE_IRQ, | 
|  | 1147 | }, | 
|  | 1148 | }; | 
|  | 1149 |  | 
|  | 1150 | static struct platform_device at91sam9263_ssc0_device = { | 
|  | 1151 | .name	= "ssc", | 
|  | 1152 | .id	= 0, | 
|  | 1153 | .dev	= { | 
|  | 1154 | .dma_mask		= &ssc0_dmamask, | 
|  | 1155 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 1156 | }, | 
|  | 1157 | .resource	= ssc0_resources, | 
|  | 1158 | .num_resources	= ARRAY_SIZE(ssc0_resources), | 
|  | 1159 | }; | 
|  | 1160 |  | 
|  | 1161 | static inline void configure_ssc0_pins(unsigned pins) | 
|  | 1162 | { | 
|  | 1163 | if (pins & ATMEL_SSC_TF) | 
|  | 1164 | at91_set_B_periph(AT91_PIN_PB0, 1); | 
|  | 1165 | if (pins & ATMEL_SSC_TK) | 
|  | 1166 | at91_set_B_periph(AT91_PIN_PB1, 1); | 
|  | 1167 | if (pins & ATMEL_SSC_TD) | 
|  | 1168 | at91_set_B_periph(AT91_PIN_PB2, 1); | 
|  | 1169 | if (pins & ATMEL_SSC_RD) | 
|  | 1170 | at91_set_B_periph(AT91_PIN_PB3, 1); | 
|  | 1171 | if (pins & ATMEL_SSC_RK) | 
|  | 1172 | at91_set_B_periph(AT91_PIN_PB4, 1); | 
|  | 1173 | if (pins & ATMEL_SSC_RF) | 
|  | 1174 | at91_set_B_periph(AT91_PIN_PB5, 1); | 
|  | 1175 | } | 
|  | 1176 |  | 
|  | 1177 | static u64 ssc1_dmamask = DMA_BIT_MASK(32); | 
|  | 1178 |  | 
|  | 1179 | static struct resource ssc1_resources[] = { | 
|  | 1180 | [0] = { | 
|  | 1181 | .start	= AT91SAM9263_BASE_SSC1, | 
|  | 1182 | .end	= AT91SAM9263_BASE_SSC1 + SZ_16K - 1, | 
|  | 1183 | .flags	= IORESOURCE_MEM, | 
|  | 1184 | }, | 
|  | 1185 | [1] = { | 
|  | 1186 | .start	= AT91SAM9263_ID_SSC1, | 
|  | 1187 | .end	= AT91SAM9263_ID_SSC1, | 
|  | 1188 | .flags	= IORESOURCE_IRQ, | 
|  | 1189 | }, | 
|  | 1190 | }; | 
|  | 1191 |  | 
|  | 1192 | static struct platform_device at91sam9263_ssc1_device = { | 
|  | 1193 | .name	= "ssc", | 
|  | 1194 | .id	= 1, | 
|  | 1195 | .dev	= { | 
|  | 1196 | .dma_mask		= &ssc1_dmamask, | 
|  | 1197 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 1198 | }, | 
|  | 1199 | .resource	= ssc1_resources, | 
|  | 1200 | .num_resources	= ARRAY_SIZE(ssc1_resources), | 
|  | 1201 | }; | 
|  | 1202 |  | 
|  | 1203 | static inline void configure_ssc1_pins(unsigned pins) | 
|  | 1204 | { | 
|  | 1205 | if (pins & ATMEL_SSC_TF) | 
|  | 1206 | at91_set_A_periph(AT91_PIN_PB6, 1); | 
|  | 1207 | if (pins & ATMEL_SSC_TK) | 
|  | 1208 | at91_set_A_periph(AT91_PIN_PB7, 1); | 
|  | 1209 | if (pins & ATMEL_SSC_TD) | 
|  | 1210 | at91_set_A_periph(AT91_PIN_PB8, 1); | 
|  | 1211 | if (pins & ATMEL_SSC_RD) | 
|  | 1212 | at91_set_A_periph(AT91_PIN_PB9, 1); | 
|  | 1213 | if (pins & ATMEL_SSC_RK) | 
|  | 1214 | at91_set_A_periph(AT91_PIN_PB10, 1); | 
|  | 1215 | if (pins & ATMEL_SSC_RF) | 
|  | 1216 | at91_set_A_periph(AT91_PIN_PB11, 1); | 
|  | 1217 | } | 
|  | 1218 |  | 
|  | 1219 | /* | 
| Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 1220 | * SSC controllers are accessed through library code, instead of any | 
|  | 1221 | * kind of all-singing/all-dancing driver.  For example one could be | 
|  | 1222 | * used by a particular I2S audio codec's driver, while another one | 
|  | 1223 | * on the same system might be used by a custom data capture driver. | 
|  | 1224 | */ | 
|  | 1225 | void __init at91_add_device_ssc(unsigned id, unsigned pins) | 
|  | 1226 | { | 
|  | 1227 | struct platform_device *pdev; | 
|  | 1228 |  | 
|  | 1229 | /* | 
|  | 1230 | * NOTE: caller is responsible for passing information matching | 
|  | 1231 | * "pins" to whatever will be using each particular controller. | 
|  | 1232 | */ | 
|  | 1233 | switch (id) { | 
|  | 1234 | case AT91SAM9263_ID_SSC0: | 
|  | 1235 | pdev = &at91sam9263_ssc0_device; | 
|  | 1236 | configure_ssc0_pins(pins); | 
| Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 1237 | break; | 
|  | 1238 | case AT91SAM9263_ID_SSC1: | 
|  | 1239 | pdev = &at91sam9263_ssc1_device; | 
|  | 1240 | configure_ssc1_pins(pins); | 
| Andrew Victor | bfbc326 | 2008-01-23 09:18:06 +0100 | [diff] [blame] | 1241 | break; | 
|  | 1242 | default: | 
|  | 1243 | return; | 
|  | 1244 | } | 
|  | 1245 |  | 
|  | 1246 | platform_device_register(pdev); | 
|  | 1247 | } | 
|  | 1248 |  | 
|  | 1249 | #else | 
|  | 1250 | void __init at91_add_device_ssc(unsigned id, unsigned pins) {} | 
|  | 1251 | #endif | 
|  | 1252 |  | 
|  | 1253 |  | 
|  | 1254 | /* -------------------------------------------------------------------- | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1255 | *  UART | 
|  | 1256 | * -------------------------------------------------------------------- */ | 
|  | 1257 |  | 
|  | 1258 | #if defined(CONFIG_SERIAL_ATMEL) | 
|  | 1259 |  | 
|  | 1260 | static struct resource dbgu_resources[] = { | 
|  | 1261 | [0] = { | 
| Jean-Christophe PLAGNIOL-VILLARD | 13079a7 | 2011-11-02 01:43:31 +0800 | [diff] [blame] | 1262 | .start	= AT91SAM9263_BASE_DBGU, | 
|  | 1263 | .end	= AT91SAM9263_BASE_DBGU + SZ_512 - 1, | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1264 | .flags	= IORESOURCE_MEM, | 
|  | 1265 | }, | 
|  | 1266 | [1] = { | 
|  | 1267 | .start	= AT91_ID_SYS, | 
|  | 1268 | .end	= AT91_ID_SYS, | 
|  | 1269 | .flags	= IORESOURCE_IRQ, | 
|  | 1270 | }, | 
|  | 1271 | }; | 
|  | 1272 |  | 
|  | 1273 | static struct atmel_uart_data dbgu_data = { | 
|  | 1274 | .use_dma_tx	= 0, | 
|  | 1275 | .use_dma_rx	= 0,		/* DBGU not capable of receive DMA */ | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1276 | }; | 
|  | 1277 |  | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1278 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 
|  | 1279 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1280 | static struct platform_device at91sam9263_dbgu_device = { | 
|  | 1281 | .name		= "atmel_usart", | 
|  | 1282 | .id		= 0, | 
|  | 1283 | .dev		= { | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1284 | .dma_mask		= &dbgu_dmamask, | 
|  | 1285 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 1286 | .platform_data		= &dbgu_data, | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1287 | }, | 
|  | 1288 | .resource	= dbgu_resources, | 
|  | 1289 | .num_resources	= ARRAY_SIZE(dbgu_resources), | 
|  | 1290 | }; | 
|  | 1291 |  | 
|  | 1292 | static inline void configure_dbgu_pins(void) | 
|  | 1293 | { | 
|  | 1294 | at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */ | 
|  | 1295 | at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */ | 
|  | 1296 | } | 
|  | 1297 |  | 
|  | 1298 | static struct resource uart0_resources[] = { | 
|  | 1299 | [0] = { | 
|  | 1300 | .start	= AT91SAM9263_BASE_US0, | 
|  | 1301 | .end	= AT91SAM9263_BASE_US0 + SZ_16K - 1, | 
|  | 1302 | .flags	= IORESOURCE_MEM, | 
|  | 1303 | }, | 
|  | 1304 | [1] = { | 
|  | 1305 | .start	= AT91SAM9263_ID_US0, | 
|  | 1306 | .end	= AT91SAM9263_ID_US0, | 
|  | 1307 | .flags	= IORESOURCE_IRQ, | 
|  | 1308 | }, | 
|  | 1309 | }; | 
|  | 1310 |  | 
|  | 1311 | static struct atmel_uart_data uart0_data = { | 
|  | 1312 | .use_dma_tx	= 1, | 
|  | 1313 | .use_dma_rx	= 1, | 
|  | 1314 | }; | 
|  | 1315 |  | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1316 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 
|  | 1317 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1318 | static struct platform_device at91sam9263_uart0_device = { | 
|  | 1319 | .name		= "atmel_usart", | 
|  | 1320 | .id		= 1, | 
|  | 1321 | .dev		= { | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1322 | .dma_mask		= &uart0_dmamask, | 
|  | 1323 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 1324 | .platform_data		= &uart0_data, | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1325 | }, | 
|  | 1326 | .resource	= uart0_resources, | 
|  | 1327 | .num_resources	= ARRAY_SIZE(uart0_resources), | 
|  | 1328 | }; | 
|  | 1329 |  | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1330 | static inline void configure_usart0_pins(unsigned pins) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1331 | { | 
|  | 1332 | at91_set_A_periph(AT91_PIN_PA26, 1);		/* TXD0 */ | 
|  | 1333 | at91_set_A_periph(AT91_PIN_PA27, 0);		/* RXD0 */ | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1334 |  | 
|  | 1335 | if (pins & ATMEL_UART_RTS) | 
|  | 1336 | at91_set_A_periph(AT91_PIN_PA28, 0);	/* RTS0 */ | 
|  | 1337 | if (pins & ATMEL_UART_CTS) | 
|  | 1338 | at91_set_A_periph(AT91_PIN_PA29, 0);	/* CTS0 */ | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1339 | } | 
|  | 1340 |  | 
|  | 1341 | static struct resource uart1_resources[] = { | 
|  | 1342 | [0] = { | 
|  | 1343 | .start	= AT91SAM9263_BASE_US1, | 
|  | 1344 | .end	= AT91SAM9263_BASE_US1 + SZ_16K - 1, | 
|  | 1345 | .flags	= IORESOURCE_MEM, | 
|  | 1346 | }, | 
|  | 1347 | [1] = { | 
|  | 1348 | .start	= AT91SAM9263_ID_US1, | 
|  | 1349 | .end	= AT91SAM9263_ID_US1, | 
|  | 1350 | .flags	= IORESOURCE_IRQ, | 
|  | 1351 | }, | 
|  | 1352 | }; | 
|  | 1353 |  | 
|  | 1354 | static struct atmel_uart_data uart1_data = { | 
|  | 1355 | .use_dma_tx	= 1, | 
|  | 1356 | .use_dma_rx	= 1, | 
|  | 1357 | }; | 
|  | 1358 |  | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1359 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 
|  | 1360 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1361 | static struct platform_device at91sam9263_uart1_device = { | 
|  | 1362 | .name		= "atmel_usart", | 
|  | 1363 | .id		= 2, | 
|  | 1364 | .dev		= { | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1365 | .dma_mask		= &uart1_dmamask, | 
|  | 1366 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 1367 | .platform_data		= &uart1_data, | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1368 | }, | 
|  | 1369 | .resource	= uart1_resources, | 
|  | 1370 | .num_resources	= ARRAY_SIZE(uart1_resources), | 
|  | 1371 | }; | 
|  | 1372 |  | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1373 | static inline void configure_usart1_pins(unsigned pins) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1374 | { | 
|  | 1375 | at91_set_A_periph(AT91_PIN_PD0, 1);		/* TXD1 */ | 
|  | 1376 | at91_set_A_periph(AT91_PIN_PD1, 0);		/* RXD1 */ | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1377 |  | 
|  | 1378 | if (pins & ATMEL_UART_RTS) | 
|  | 1379 | at91_set_B_periph(AT91_PIN_PD7, 0);	/* RTS1 */ | 
|  | 1380 | if (pins & ATMEL_UART_CTS) | 
|  | 1381 | at91_set_B_periph(AT91_PIN_PD8, 0);	/* CTS1 */ | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1382 | } | 
|  | 1383 |  | 
|  | 1384 | static struct resource uart2_resources[] = { | 
|  | 1385 | [0] = { | 
|  | 1386 | .start	= AT91SAM9263_BASE_US2, | 
|  | 1387 | .end	= AT91SAM9263_BASE_US2 + SZ_16K - 1, | 
|  | 1388 | .flags	= IORESOURCE_MEM, | 
|  | 1389 | }, | 
|  | 1390 | [1] = { | 
|  | 1391 | .start	= AT91SAM9263_ID_US2, | 
|  | 1392 | .end	= AT91SAM9263_ID_US2, | 
|  | 1393 | .flags	= IORESOURCE_IRQ, | 
|  | 1394 | }, | 
|  | 1395 | }; | 
|  | 1396 |  | 
|  | 1397 | static struct atmel_uart_data uart2_data = { | 
|  | 1398 | .use_dma_tx	= 1, | 
|  | 1399 | .use_dma_rx	= 1, | 
|  | 1400 | }; | 
|  | 1401 |  | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1402 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 
|  | 1403 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1404 | static struct platform_device at91sam9263_uart2_device = { | 
|  | 1405 | .name		= "atmel_usart", | 
|  | 1406 | .id		= 3, | 
|  | 1407 | .dev		= { | 
| Andrew Victor | c6686ff | 2008-01-23 09:13:53 +0100 | [diff] [blame] | 1408 | .dma_mask		= &uart2_dmamask, | 
|  | 1409 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 1410 | .platform_data		= &uart2_data, | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1411 | }, | 
|  | 1412 | .resource	= uart2_resources, | 
|  | 1413 | .num_resources	= ARRAY_SIZE(uart2_resources), | 
|  | 1414 | }; | 
|  | 1415 |  | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1416 | static inline void configure_usart2_pins(unsigned pins) | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1417 | { | 
|  | 1418 | at91_set_A_periph(AT91_PIN_PD2, 1);		/* TXD2 */ | 
|  | 1419 | at91_set_A_periph(AT91_PIN_PD3, 0);		/* RXD2 */ | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1420 |  | 
|  | 1421 | if (pins & ATMEL_UART_RTS) | 
|  | 1422 | at91_set_B_periph(AT91_PIN_PD5, 0);	/* RTS2 */ | 
|  | 1423 | if (pins & ATMEL_UART_CTS) | 
|  | 1424 | at91_set_B_periph(AT91_PIN_PD6, 0);	/* CTS2 */ | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1425 | } | 
|  | 1426 |  | 
| Andrew Victor | 11aadac | 2008-04-15 21:16:38 +0100 | [diff] [blame] | 1427 | static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */ | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1428 |  | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1429 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | 
|  | 1430 | { | 
|  | 1431 | struct platform_device *pdev; | 
| Jean-Christophe PLAGNIOL-VILLARD | 2b348e2 | 2011-04-10 14:10:05 +0800 | [diff] [blame] | 1432 | struct atmel_uart_data *pdata; | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1433 |  | 
|  | 1434 | switch (id) { | 
|  | 1435 | case 0:		/* DBGU */ | 
|  | 1436 | pdev = &at91sam9263_dbgu_device; | 
|  | 1437 | configure_dbgu_pins(); | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1438 | break; | 
|  | 1439 | case AT91SAM9263_ID_US0: | 
|  | 1440 | pdev = &at91sam9263_uart0_device; | 
|  | 1441 | configure_usart0_pins(pins); | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1442 | break; | 
|  | 1443 | case AT91SAM9263_ID_US1: | 
|  | 1444 | pdev = &at91sam9263_uart1_device; | 
|  | 1445 | configure_usart1_pins(pins); | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1446 | break; | 
|  | 1447 | case AT91SAM9263_ID_US2: | 
|  | 1448 | pdev = &at91sam9263_uart2_device; | 
|  | 1449 | configure_usart2_pins(pins); | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1450 | break; | 
|  | 1451 | default: | 
|  | 1452 | return; | 
|  | 1453 | } | 
| Jean-Christophe PLAGNIOL-VILLARD | 2b348e2 | 2011-04-10 14:10:05 +0800 | [diff] [blame] | 1454 | pdata = pdev->dev.platform_data; | 
|  | 1455 | pdata->num = portnr;		/* update to mapped ID */ | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1456 |  | 
|  | 1457 | if (portnr < ATMEL_MAX_UART) | 
|  | 1458 | at91_uarts[portnr] = pdev; | 
|  | 1459 | } | 
|  | 1460 |  | 
|  | 1461 | void __init at91_set_serial_console(unsigned portnr) | 
|  | 1462 | { | 
| Jean-Christophe PLAGNIOL-VILLARD | bd60299 | 2011-02-02 07:27:07 +0100 | [diff] [blame] | 1463 | if (portnr < ATMEL_MAX_UART) { | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1464 | atmel_default_console_device = at91_uarts[portnr]; | 
| Jean-Christophe PLAGNIOL-VILLARD | 5c1f966 | 2011-06-21 11:24:33 +0800 | [diff] [blame] | 1465 | at91sam9263_set_console_clock(at91_uarts[portnr]->id); | 
| Jean-Christophe PLAGNIOL-VILLARD | bd60299 | 2011-02-02 07:27:07 +0100 | [diff] [blame] | 1466 | } | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1467 | } | 
|  | 1468 |  | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1469 | void __init at91_add_device_serial(void) | 
|  | 1470 | { | 
|  | 1471 | int i; | 
|  | 1472 |  | 
|  | 1473 | for (i = 0; i < ATMEL_MAX_UART; i++) { | 
|  | 1474 | if (at91_uarts[i]) | 
|  | 1475 | platform_device_register(at91_uarts[i]); | 
|  | 1476 | } | 
| Andrew Victor | 11aadac | 2008-04-15 21:16:38 +0100 | [diff] [blame] | 1477 |  | 
|  | 1478 | if (!atmel_default_console_device) | 
|  | 1479 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1480 | } | 
|  | 1481 | #else | 
| Andrew Victor | c8f385a | 2008-01-23 09:25:15 +0100 | [diff] [blame] | 1482 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | 
|  | 1483 | void __init at91_set_serial_console(unsigned portnr) {} | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1484 | void __init at91_add_device_serial(void) {} | 
|  | 1485 | #endif | 
|  | 1486 |  | 
|  | 1487 |  | 
|  | 1488 | /* -------------------------------------------------------------------- */ | 
|  | 1489 | /* | 
|  | 1490 | * These devices are always present and don't need any board-specific | 
|  | 1491 | * setup. | 
|  | 1492 | */ | 
|  | 1493 | static int __init at91_add_standard_devices(void) | 
|  | 1494 | { | 
| Andrew Victor | 884f5a6 | 2008-01-23 09:11:13 +0100 | [diff] [blame] | 1495 | at91_add_device_rtt(); | 
|  | 1496 | at91_add_device_watchdog(); | 
| Andrew Victor | e5f40bf | 2008-04-02 21:58:00 +0100 | [diff] [blame] | 1497 | at91_add_device_tc(); | 
| Andrew Victor | b2c6561 | 2007-02-08 09:42:40 +0100 | [diff] [blame] | 1498 | return 0; | 
|  | 1499 | } | 
|  | 1500 |  | 
|  | 1501 | arch_initcall(at91_add_standard_devices); |