Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.13.7.
  1/*
  2 * linux/arch/arm/mach-at91/board-cpu9krea.c
  3 *
  4 *  Copyright (C) 2005 SAN People
  5 *  Copyright (C) 2006 Atmel
  6 *  Copyright (C) 2009 Eric Benard - eric@eukrea.com
  7 *
  8 * 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 * the Free Software Foundation; either version 2 of the License, or
 11 * (at your option) any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 * GNU General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU General Public License
 19 * along with this program; if not, write to the Free Software
 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 21 */
 22
 23#include <linux/types.h>
 24#include <linux/init.h>
 25#include <linux/mm.h>
 26#include <linux/module.h>
 27#include <linux/platform_device.h>
 28#include <linux/clk.h>
 29#include <linux/gpio_keys.h>
 30#include <linux/input.h>
 31#include <linux/mtd/physmap.h>
 32
 33#include <asm/setup.h>
 34#include <asm/mach-types.h>
 35#include <asm/irq.h>
 36
 37#include <asm/mach/arch.h>
 38#include <asm/mach/map.h>
 39#include <asm/mach/irq.h>
 40
 41#include <mach/hardware.h>
 42#include <mach/board.h>
 43#include <mach/gpio.h>
 44#include <mach/at91sam9_smc.h>
 45#include <mach/at91sam9260_matrix.h>
 46
 47#include "sam9_smc.h"
 48#include "generic.h"
 49
 50static void __init cpu9krea_init_early(void)
 51{
 52	/* Initialize processor: 18.432 MHz crystal */
 53	at91_initialize(18432000);
 54
 55	/* DGBU on ttyS0. (Rx & Tx only) */
 56	at91_register_uart(0, 0, 0);
 57
 58	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
 59	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
 60		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
 61		ATMEL_UART_DCD | ATMEL_UART_RI);
 62
 63	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
 64	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
 65		ATMEL_UART_RTS);
 66
 67	/* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
 68	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
 69		ATMEL_UART_RTS);
 70
 71	/* USART3 on ttyS4. (Rx, Tx) */
 72	at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
 73
 74	/* USART4 on ttyS5. (Rx, Tx) */
 75	at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
 76
 77	/* USART5 on ttyS6. (Rx, Tx) */
 78	at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
 79
 80	/* set serial console to ttyS0 (ie, DBGU) */
 81	at91_set_serial_console(0);
 82}
 83
 84/*
 85 * USB Host port
 86 */
 87static struct at91_usbh_data __initdata cpu9krea_usbh_data = {
 88	.ports		= 2,
 89};
 90
 91/*
 92 * USB Device port
 93 */
 94static struct at91_udc_data __initdata cpu9krea_udc_data = {
 95	.vbus_pin	= AT91_PIN_PC8,
 96	.pullup_pin	= 0,		/* pull-up driven by UDC */
 97};
 98
 99/*
100 * MACB Ethernet device
101 */
102static struct at91_eth_data __initdata cpu9krea_macb_data = {
103	.is_rmii	= 1,
104};
105
106/*
107 * NAND flash
108 */
109static struct atmel_nand_data __initdata cpu9krea_nand_data = {
110	.ale		= 21,
111	.cle		= 22,
112	.rdy_pin	= AT91_PIN_PC13,
113	.enable_pin	= AT91_PIN_PC14,
114	.bus_width_16	= 0,
115};
116
117#ifdef CONFIG_MACH_CPU9260
118static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
119	.ncs_read_setup		= 0,
120	.nrd_setup		= 1,
121	.ncs_write_setup	= 0,
122	.nwe_setup		= 1,
123
124	.ncs_read_pulse		= 3,
125	.nrd_pulse		= 3,
126	.ncs_write_pulse	= 3,
127	.nwe_pulse		= 3,
128
129	.read_cycle		= 5,
130	.write_cycle		= 5,
131
132	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE
133		| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
134	.tdf_cycles		= 2,
135};
136#else
137static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
138	.ncs_read_setup		= 0,
139	.nrd_setup		= 2,
140	.ncs_write_setup	= 0,
141	.nwe_setup		= 2,
142
143	.ncs_read_pulse		= 4,
144	.nrd_pulse		= 4,
145	.ncs_write_pulse	= 4,
146	.nwe_pulse		= 4,
147
148	.read_cycle		= 7,
149	.write_cycle		= 7,
150
151	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE
152		| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
153	.tdf_cycles		= 3,
154};
155#endif
156
157static void __init cpu9krea_add_device_nand(void)
158{
159	sam9_smc_configure(3, &cpu9krea_nand_smc_config);
160	at91_add_device_nand(&cpu9krea_nand_data);
161}
162
163/*
164 * NOR flash
165 */
166static struct physmap_flash_data cpuat9260_nor_data = {
167	.width		= 2,
168};
169
170#define NOR_BASE	AT91_CHIPSELECT_0
171#define NOR_SIZE	SZ_64M
172
173static struct resource nor_flash_resources[] = {
174	{
175		.start	= NOR_BASE,
176		.end	= NOR_BASE + NOR_SIZE - 1,
177		.flags	= IORESOURCE_MEM,
178	}
179};
180
181static struct platform_device cpu9krea_nor_flash = {
182	.name		= "physmap-flash",
183	.id		= 0,
184	.dev		= {
185		.platform_data	= &cpuat9260_nor_data,
186	},
187	.resource	= nor_flash_resources,
188	.num_resources	= ARRAY_SIZE(nor_flash_resources),
189};
190
191#ifdef CONFIG_MACH_CPU9260
192static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
193	.ncs_read_setup		= 0,
194	.nrd_setup		= 1,
195	.ncs_write_setup	= 0,
196	.nwe_setup		= 1,
197
198	.ncs_read_pulse		= 10,
199	.nrd_pulse		= 10,
200	.ncs_write_pulse	= 6,
201	.nwe_pulse		= 6,
202
203	.read_cycle		= 12,
204	.write_cycle		= 8,
205
206	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE
207			| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
208			| AT91_SMC_DBW_16,
209	.tdf_cycles		= 2,
210};
211#else
212static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
213	.ncs_read_setup		= 0,
214	.nrd_setup		= 1,
215	.ncs_write_setup	= 0,
216	.nwe_setup		= 1,
217
218	.ncs_read_pulse		= 13,
219	.nrd_pulse		= 13,
220	.ncs_write_pulse	= 8,
221	.nwe_pulse		= 8,
222
223	.read_cycle		= 15,
224	.write_cycle		= 10,
225
226	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE
227			| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
228			| AT91_SMC_DBW_16,
229	.tdf_cycles		= 2,
230};
231#endif
232
233static __init void cpu9krea_add_device_nor(void)
234{
235	unsigned long csa;
236
237	csa = at91_sys_read(AT91_MATRIX_EBICSA);
238	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
239
240	/* configure chip-select 0 (NOR) */
241	sam9_smc_configure(0, &cpu9krea_nor_smc_config);
242
243	platform_device_register(&cpu9krea_nor_flash);
244}
245
246/*
247 * LEDs
248 */
249static struct gpio_led cpu9krea_leds[] = {
250	{	/* LED1 */
251		.name			= "LED1",
252		.gpio			= AT91_PIN_PC11,
253		.active_low		= 1,
254		.default_trigger	= "timer",
255	},
256	{	/* LED2 */
257		.name			= "LED2",
258		.gpio			= AT91_PIN_PC12,
259		.active_low		= 1,
260		.default_trigger	= "heartbeat",
261	},
262	{	/* LED3 */
263		.name			= "LED3",
264		.gpio			= AT91_PIN_PC7,
265		.active_low		= 1,
266		.default_trigger	= "none",
267	},
268	{	/* LED4 */
269		.name			= "LED4",
270		.gpio			= AT91_PIN_PC9,
271		.active_low		= 1,
272		.default_trigger	= "none",
273	}
274};
275
276static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {
277	{
278		I2C_BOARD_INFO("rtc-ds1307", 0x68),
279		.type	= "ds1339",
280	},
281};
282
283/*
284 * GPIO Buttons
285 */
286#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
287static struct gpio_keys_button cpu9krea_buttons[] = {
288	{
289		.gpio		= AT91_PIN_PC3,
290		.code		= BTN_0,
291		.desc		= "BP1",
292		.active_low	= 1,
293		.wakeup		= 1,
294	},
295	{
296		.gpio		= AT91_PIN_PB20,
297		.code		= BTN_1,
298		.desc		= "BP2",
299		.active_low	= 1,
300		.wakeup		= 1,
301	}
302};
303
304static struct gpio_keys_platform_data cpu9krea_button_data = {
305	.buttons	= cpu9krea_buttons,
306	.nbuttons	= ARRAY_SIZE(cpu9krea_buttons),
307};
308
309static struct platform_device cpu9krea_button_device = {
310	.name		= "gpio-keys",
311	.id		= -1,
312	.num_resources	= 0,
313	.dev		= {
314		.platform_data	= &cpu9krea_button_data,
315	}
316};
317
318static void __init cpu9krea_add_device_buttons(void)
319{
320	at91_set_gpio_input(AT91_PIN_PC3, 1);	/* BP1 */
321	at91_set_deglitch(AT91_PIN_PC3, 1);
322	at91_set_gpio_input(AT91_PIN_PB20, 1);	/* BP2 */
323	at91_set_deglitch(AT91_PIN_PB20, 1);
324
325	platform_device_register(&cpu9krea_button_device);
326}
327#else
328static void __init cpu9krea_add_device_buttons(void)
329{
330}
331#endif
332
333/*
334 * MCI (SD/MMC)
335 */
336static struct at91_mmc_data __initdata cpu9krea_mmc_data = {
337	.slot_b		= 0,
338	.wire4		= 1,
339	.det_pin	= AT91_PIN_PA29,
340};
341
342static void __init cpu9krea_board_init(void)
343{
344	/* NOR */
345	cpu9krea_add_device_nor();
346	/* Serial */
347	at91_add_device_serial();
348	/* USB Host */
349	at91_add_device_usbh(&cpu9krea_usbh_data);
350	/* USB Device */
351	at91_add_device_udc(&cpu9krea_udc_data);
352	/* NAND */
353	cpu9krea_add_device_nand();
354	/* Ethernet */
355	at91_add_device_eth(&cpu9krea_macb_data);
356	/* MMC */
357	at91_add_device_mmc(0, &cpu9krea_mmc_data);
358	/* I2C */
359	at91_add_device_i2c(cpu9krea_i2c_devices,
360		ARRAY_SIZE(cpu9krea_i2c_devices));
361	/* LEDs */
362	at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds));
363	/* Push Buttons */
364	cpu9krea_add_device_buttons();
365}
366
367#ifdef CONFIG_MACH_CPU9260
368MACHINE_START(CPUAT9260, "Eukrea CPU9260")
369#else
370MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
371#endif
372	/* Maintainer: Eric Benard - EUKREA Electromatique */
373	.timer		= &at91sam926x_timer,
374	.map_io		= at91_map_io,
375	.init_early	= cpu9krea_init_early,
376	.init_irq	= at91_init_irq_default,
377	.init_machine	= cpu9krea_board_init,
378MACHINE_END