aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/board-usb-a926x.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2011-08-30 12:25:53 -0400
committerNicolas Ferre <nicolas.ferre@atmel.com>2011-09-07 10:33:56 -0400
commit0a072a247fa79979dd31813decb6b118d7d511fd (patch)
tree1c6f339d08f3e070c257373cfe00865f781e6332 /arch/arm/mach-at91/board-usb-a926x.c
parent6939fd49787e233fd0d7640a4de72815bc8c649a (diff)
at91: USB-A9G20 C01 & C11 board support
Add support for Calao USB-A9G20 boards. It will be integrated in existing support for board of same form factor using at91sam9260 or at91sam9263. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch/arm/mach-at91/board-usb-a926x.c')
-rw-r--r--arch/arm/mach-at91/board-usb-a926x.c145
1 files changed, 119 insertions, 26 deletions
diff --git a/arch/arm/mach-at91/board-usb-a926x.c b/arch/arm/mach-at91/board-usb-a926x.c
index b9b9847fa55d..260260b81992 100644
--- a/arch/arm/mach-at91/board-usb-a926x.c
+++ b/arch/arm/mach-at91/board-usb-a926x.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 2005 SAN People 4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation. 5 * Copyright (C) 2007 Atmel Corporation.
6 * Copyright (C) 2007 Calao-systems 6 * Copyright (C) 2007 Calao-systems
7 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -28,6 +29,7 @@
28#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
29#include <linux/gpio_keys.h> 30#include <linux/gpio_keys.h>
30#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/spi/mmc_spi.h>
31 33
32#include <asm/setup.h> 34#include <asm/setup.h>
33#include <asm/mach-types.h> 35#include <asm/mach-types.h>
@@ -74,18 +76,42 @@ static struct at91_udc_data __initdata ek_udc_data = {
74 .pullup_pin = 0, /* pull-up driven by UDC */ 76 .pullup_pin = 0, /* pull-up driven by UDC */
75}; 77};
76 78
77void ek_add_device_udc(void) 79static void __init ek_add_device_udc(void)
78{ 80{
79 if (machine_is_usb_a9260()) 81 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
80 ek_udc_data.vbus_pin = AT91_PIN_PC5; 82 ek_udc_data.vbus_pin = AT91_PIN_PC5;
81 83
82 at91_add_device_udc(&ek_udc_data); 84 at91_add_device_udc(&ek_udc_data);
83} 85}
84 86
87#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
88#define MMC_SPI_CARD_DETECT_INT AT91_PIN_PC4
89static int at91_mmc_spi_init(struct device *dev,
90 irqreturn_t (*detect_int)(int, void *), void *data)
91{
92 /* Configure Interrupt pin as input, no pull-up */
93 at91_set_gpio_input(MMC_SPI_CARD_DETECT_INT, 0);
94 return request_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), detect_int,
95 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
96 "mmc-spi-detect", data);
97}
98
99static void at91_mmc_spi_exit(struct device *dev, void *data)
100{
101 free_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), data);
102}
103
104static struct mmc_spi_platform_data at91_mmc_spi_pdata = {
105 .init = at91_mmc_spi_init,
106 .exit = at91_mmc_spi_exit,
107 .detect_delay = 100, /* msecs */
108};
109#endif
110
85/* 111/*
86 * SPI devices. 112 * SPI devices.
87 */ 113 */
88static struct spi_board_info ek_spi_devices[] = { 114static struct spi_board_info usb_a9263_spi_devices[] = {
89#if !defined(CONFIG_MMC_AT91) 115#if !defined(CONFIG_MMC_AT91)
90 { /* DataFlash chip */ 116 { /* DataFlash chip */
91 .modalias = "mtd_dataflash", 117 .modalias = "mtd_dataflash",
@@ -96,10 +122,25 @@ static struct spi_board_info ek_spi_devices[] = {
96#endif 122#endif
97}; 123};
98 124
99void ek_add_device_spi(void) 125static struct spi_board_info usb_a9g20_spi_devices[] = {
126#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
127 {
128 .modalias = "mmc_spi",
129 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
130 .bus_num = 1,
131 .chip_select = 0,
132 .platform_data = &at91_mmc_spi_pdata,
133 .mode = SPI_MODE_3,
134 },
135#endif
136};
137
138static void __init ek_add_device_spi(void)
100{ 139{
101 if (machine_is_usb_a9263()) 140 if (machine_is_usb_a9263())
102 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); 141 at91_add_device_spi(usb_a9263_spi_devices, ARRAY_SIZE(usb_a9263_spi_devices));
142 else if (machine_is_usb_a9g20())
143 at91_add_device_spi(usb_a9g20_spi_devices, ARRAY_SIZE(usb_a9g20_spi_devices));
103} 144}
104 145
105/* 146/*
@@ -110,9 +151,9 @@ static struct at91_eth_data __initdata ek_macb_data = {
110 .is_rmii = 1, 151 .is_rmii = 1,
111}; 152};
112 153
113void ek_add_device_eth(void) 154static void __init ek_add_device_eth(void)
114{ 155{
115 if (machine_is_usb_a9260()) 156 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
116 ek_macb_data.phy_irq_pin = AT91_PIN_PA31; 157 ek_macb_data.phy_irq_pin = AT91_PIN_PA31;
117 158
118 at91_add_device_eth(&ek_macb_data); 159 at91_add_device_eth(&ek_macb_data);
@@ -123,19 +164,29 @@ void ek_add_device_eth(void)
123 */ 164 */
124static struct mtd_partition __initdata ek_nand_partition[] = { 165static struct mtd_partition __initdata ek_nand_partition[] = {
125 { 166 {
126 .name = "Uboot & Kernel", 167 .name = "barebox",
127 .offset = 0, 168 .offset = 0,
128 .size = SZ_16M, 169 .size = 3 * SZ_128K,
129 }, 170 }, {
130 { 171 .name = "bareboxenv",
131 .name = "Root FS",
132 .offset = MTDPART_OFS_NXTBLK, 172 .offset = MTDPART_OFS_NXTBLK,
133 .size = 120 * SZ_1M, 173 .size = SZ_128K,
134 }, 174 }, {
135 { 175 .name = "bareboxenv2",
136 .name = "FS", 176 .offset = MTDPART_OFS_NXTBLK,
177 .size = SZ_128K,
178 }, {
179 .name = "kernel",
180 .offset = MTDPART_OFS_NXTBLK,
181 .size = 4 * SZ_1M,
182 }, {
183 .name = "rootfs",
137 .offset = MTDPART_OFS_NXTBLK, 184 .offset = MTDPART_OFS_NXTBLK,
138 .size = 120 * SZ_1M, 185 .size = 120 * SZ_1M,
186 }, {
187 .name = "data",
188 .offset = MTDPART_OFS_NXTBLK,
189 .size = MTDPART_SIZ_FULL,
139 } 190 }
140}; 191};
141 192
@@ -154,7 +205,7 @@ static struct atmel_nand_data __initdata ek_nand_data = {
154 .partition_info = nand_partitions, 205 .partition_info = nand_partitions,
155}; 206};
156 207
157static struct sam9_smc_config __initdata ek_nand_smc_config = { 208static struct sam9_smc_config __initdata usb_a9260_nand_smc_config = {
158 .ncs_read_setup = 0, 209 .ncs_read_setup = 0,
159 .nrd_setup = 1, 210 .nrd_setup = 1,
160 .ncs_write_setup = 0, 211 .ncs_write_setup = 0,
@@ -172,15 +223,36 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {
172 .tdf_cycles = 2, 223 .tdf_cycles = 2,
173}; 224};
174 225
226static struct sam9_smc_config __initdata usb_a9g20_nand_smc_config = {
227 .ncs_read_setup = 0,
228 .nrd_setup = 2,
229 .ncs_write_setup = 0,
230 .nwe_setup = 2,
231
232 .ncs_read_pulse = 4,
233 .nrd_pulse = 4,
234 .ncs_write_pulse = 4,
235 .nwe_pulse = 4,
236
237 .read_cycle = 7,
238 .write_cycle = 7,
239
240 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
241 .tdf_cycles = 3,
242};
243
175static void __init ek_add_device_nand(void) 244static void __init ek_add_device_nand(void)
176{ 245{
177 if (machine_is_usb_a9260()) { 246 if (machine_is_usb_a9260() || machine_is_usb_a9g20()) {
178 ek_nand_data.rdy_pin = AT91_PIN_PC13; 247 ek_nand_data.rdy_pin = AT91_PIN_PC13;
179 ek_nand_data.enable_pin = AT91_PIN_PC14; 248 ek_nand_data.enable_pin = AT91_PIN_PC14;
180 } 249 }
181 250
182 /* configure chip-select 3 (NAND) */ 251 /* configure chip-select 3 (NAND) */
183 sam9_smc_configure(3, &ek_nand_smc_config); 252 if (machine_is_usb_a9g20())
253 sam9_smc_configure(3, &usb_a9g20_nand_smc_config);
254 else
255 sam9_smc_configure(3, &usb_a9260_nand_smc_config);
184 256
185 at91_add_device_nand(&ek_nand_data); 257 at91_add_device_nand(&ek_nand_data);
186} 258}
@@ -237,15 +309,20 @@ static struct gpio_led ek_leds[] = {
237 } 309 }
238}; 310};
239 311
240void ek_add_device_leds(void) 312static struct i2c_board_info __initdata ek_i2c_devices[] = {
313 {
314 I2C_BOARD_INFO("rv3029c2", 0x56),
315 },
316};
317
318static void __init ek_add_device_leds(void)
241{ 319{
242 if (machine_is_usb_a9260()) 320 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
243 ek_leds[0].active_low = 0; 321 ek_leds[0].active_low = 0;
244 322
245 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 323 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
246} 324}
247 325
248
249static void __init ek_board_init(void) 326static void __init ek_board_init(void)
250{ 327{
251 /* Serial */ 328 /* Serial */
@@ -260,15 +337,22 @@ static void __init ek_board_init(void)
260 ek_add_device_eth(); 337 ek_add_device_eth();
261 /* NAND */ 338 /* NAND */
262 ek_add_device_nand(); 339 ek_add_device_nand();
263 /* I2C */
264 at91_add_device_i2c(NULL, 0);
265 /* Push Buttons */ 340 /* Push Buttons */
266 ek_add_device_buttons(); 341 ek_add_device_buttons();
267 /* LEDs */ 342 /* LEDs */
268 ek_add_device_leds(); 343 ek_add_device_leds();
269 /* shutdown controller, wakeup button (5 msec low) */ 344
270 at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW 345 if (machine_is_usb_a9g20()) {
346 /* I2C */
347 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
348 } else {
349 /* I2C */
350 at91_add_device_i2c(NULL, 0);
351 /* shutdown controller, wakeup button (5 msec low) */
352 at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10)
353 | AT91_SHDW_WKMODE0_LOW
271 | AT91_SHDW_RTTWKEN); 354 | AT91_SHDW_RTTWKEN);
355 }
272} 356}
273 357
274MACHINE_START(USB_A9263, "CALAO USB_A9263") 358MACHINE_START(USB_A9263, "CALAO USB_A9263")
@@ -288,3 +372,12 @@ MACHINE_START(USB_A9260, "CALAO USB_A9260")
288 .init_irq = at91_init_irq_default, 372 .init_irq = at91_init_irq_default,
289 .init_machine = ek_board_init, 373 .init_machine = ek_board_init,
290MACHINE_END 374MACHINE_END
375
376MACHINE_START(USB_A9G20, "CALAO USB_A92G0")
377 /* Maintainer: Jean-Christophe PLAGNIOL-VILLARD */
378 .timer = &at91sam926x_timer,
379 .map_io = at91_map_io,
380 .init_early = ek_init_early,
381 .init_irq = at91_init_irq_default,
382 .init_machine = ek_board_init,
383MACHINE_END