Path: blob/master/arch/arm/mach-at91/board-cpu9krea.c
10817 views
/*1* linux/arch/arm/mach-at91/board-cpu9krea.c2*3* Copyright (C) 2005 SAN People4* Copyright (C) 2006 Atmel5* Copyright (C) 2009 Eric Benard - [email protected]6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20*/2122#include <linux/types.h>23#include <linux/init.h>24#include <linux/mm.h>25#include <linux/module.h>26#include <linux/platform_device.h>27#include <linux/clk.h>28#include <linux/gpio_keys.h>29#include <linux/input.h>30#include <linux/mtd/physmap.h>3132#include <asm/setup.h>33#include <asm/mach-types.h>34#include <asm/irq.h>3536#include <asm/mach/arch.h>37#include <asm/mach/map.h>38#include <asm/mach/irq.h>3940#include <mach/hardware.h>41#include <mach/board.h>42#include <mach/gpio.h>43#include <mach/at91sam9_smc.h>44#include <mach/at91sam9260_matrix.h>4546#include "sam9_smc.h"47#include "generic.h"4849static void __init cpu9krea_init_early(void)50{51/* Initialize processor: 18.432 MHz crystal */52at91sam9260_initialize(18432000);5354/* DGBU on ttyS0. (Rx & Tx only) */55at91_register_uart(0, 0, 0);5657/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */58at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |59ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |60ATMEL_UART_DCD | ATMEL_UART_RI);6162/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */63at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |64ATMEL_UART_RTS);6566/* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */67at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |68ATMEL_UART_RTS);6970/* USART3 on ttyS4. (Rx, Tx) */71at91_register_uart(AT91SAM9260_ID_US3, 4, 0);7273/* USART4 on ttyS5. (Rx, Tx) */74at91_register_uart(AT91SAM9260_ID_US4, 5, 0);7576/* USART5 on ttyS6. (Rx, Tx) */77at91_register_uart(AT91SAM9260_ID_US5, 6, 0);7879/* set serial console to ttyS0 (ie, DBGU) */80at91_set_serial_console(0);81}8283static void __init cpu9krea_init_irq(void)84{85at91sam9260_init_interrupts(NULL);86}8788/*89* USB Host port90*/91static struct at91_usbh_data __initdata cpu9krea_usbh_data = {92.ports = 2,93};9495/*96* USB Device port97*/98static struct at91_udc_data __initdata cpu9krea_udc_data = {99.vbus_pin = AT91_PIN_PC8,100.pullup_pin = 0, /* pull-up driven by UDC */101};102103/*104* MACB Ethernet device105*/106static struct at91_eth_data __initdata cpu9krea_macb_data = {107.is_rmii = 1,108};109110/*111* NAND flash112*/113static struct atmel_nand_data __initdata cpu9krea_nand_data = {114.ale = 21,115.cle = 22,116.rdy_pin = AT91_PIN_PC13,117.enable_pin = AT91_PIN_PC14,118.bus_width_16 = 0,119};120121#ifdef CONFIG_MACH_CPU9260122static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {123.ncs_read_setup = 0,124.nrd_setup = 1,125.ncs_write_setup = 0,126.nwe_setup = 1,127128.ncs_read_pulse = 3,129.nrd_pulse = 3,130.ncs_write_pulse = 3,131.nwe_pulse = 3,132133.read_cycle = 5,134.write_cycle = 5,135136.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE137| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,138.tdf_cycles = 2,139};140#else141static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {142.ncs_read_setup = 0,143.nrd_setup = 2,144.ncs_write_setup = 0,145.nwe_setup = 2,146147.ncs_read_pulse = 4,148.nrd_pulse = 4,149.ncs_write_pulse = 4,150.nwe_pulse = 4,151152.read_cycle = 7,153.write_cycle = 7,154155.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE156| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,157.tdf_cycles = 3,158};159#endif160161static void __init cpu9krea_add_device_nand(void)162{163sam9_smc_configure(3, &cpu9krea_nand_smc_config);164at91_add_device_nand(&cpu9krea_nand_data);165}166167/*168* NOR flash169*/170static struct physmap_flash_data cpuat9260_nor_data = {171.width = 2,172};173174#define NOR_BASE AT91_CHIPSELECT_0175#define NOR_SIZE SZ_64M176177static struct resource nor_flash_resources[] = {178{179.start = NOR_BASE,180.end = NOR_BASE + NOR_SIZE - 1,181.flags = IORESOURCE_MEM,182}183};184185static struct platform_device cpu9krea_nor_flash = {186.name = "physmap-flash",187.id = 0,188.dev = {189.platform_data = &cpuat9260_nor_data,190},191.resource = nor_flash_resources,192.num_resources = ARRAY_SIZE(nor_flash_resources),193};194195#ifdef CONFIG_MACH_CPU9260196static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {197.ncs_read_setup = 0,198.nrd_setup = 1,199.ncs_write_setup = 0,200.nwe_setup = 1,201202.ncs_read_pulse = 10,203.nrd_pulse = 10,204.ncs_write_pulse = 6,205.nwe_pulse = 6,206207.read_cycle = 12,208.write_cycle = 8,209210.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE211| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE212| AT91_SMC_DBW_16,213.tdf_cycles = 2,214};215#else216static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {217.ncs_read_setup = 0,218.nrd_setup = 1,219.ncs_write_setup = 0,220.nwe_setup = 1,221222.ncs_read_pulse = 13,223.nrd_pulse = 13,224.ncs_write_pulse = 8,225.nwe_pulse = 8,226227.read_cycle = 15,228.write_cycle = 10,229230.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE231| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE232| AT91_SMC_DBW_16,233.tdf_cycles = 2,234};235#endif236237static __init void cpu9krea_add_device_nor(void)238{239unsigned long csa;240241csa = at91_sys_read(AT91_MATRIX_EBICSA);242at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);243244/* configure chip-select 0 (NOR) */245sam9_smc_configure(0, &cpu9krea_nor_smc_config);246247platform_device_register(&cpu9krea_nor_flash);248}249250/*251* LEDs252*/253static struct gpio_led cpu9krea_leds[] = {254{ /* LED1 */255.name = "LED1",256.gpio = AT91_PIN_PC11,257.active_low = 1,258.default_trigger = "timer",259},260{ /* LED2 */261.name = "LED2",262.gpio = AT91_PIN_PC12,263.active_low = 1,264.default_trigger = "heartbeat",265},266{ /* LED3 */267.name = "LED3",268.gpio = AT91_PIN_PC7,269.active_low = 1,270.default_trigger = "none",271},272{ /* LED4 */273.name = "LED4",274.gpio = AT91_PIN_PC9,275.active_low = 1,276.default_trigger = "none",277}278};279280static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {281{282I2C_BOARD_INFO("rtc-ds1307", 0x68),283.type = "ds1339",284},285};286287/*288* GPIO Buttons289*/290#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)291static struct gpio_keys_button cpu9krea_buttons[] = {292{293.gpio = AT91_PIN_PC3,294.code = BTN_0,295.desc = "BP1",296.active_low = 1,297.wakeup = 1,298},299{300.gpio = AT91_PIN_PB20,301.code = BTN_1,302.desc = "BP2",303.active_low = 1,304.wakeup = 1,305}306};307308static struct gpio_keys_platform_data cpu9krea_button_data = {309.buttons = cpu9krea_buttons,310.nbuttons = ARRAY_SIZE(cpu9krea_buttons),311};312313static struct platform_device cpu9krea_button_device = {314.name = "gpio-keys",315.id = -1,316.num_resources = 0,317.dev = {318.platform_data = &cpu9krea_button_data,319}320};321322static void __init cpu9krea_add_device_buttons(void)323{324at91_set_gpio_input(AT91_PIN_PC3, 1); /* BP1 */325at91_set_deglitch(AT91_PIN_PC3, 1);326at91_set_gpio_input(AT91_PIN_PB20, 1); /* BP2 */327at91_set_deglitch(AT91_PIN_PB20, 1);328329platform_device_register(&cpu9krea_button_device);330}331#else332static void __init cpu9krea_add_device_buttons(void)333{334}335#endif336337/*338* MCI (SD/MMC)339*/340static struct at91_mmc_data __initdata cpu9krea_mmc_data = {341.slot_b = 0,342.wire4 = 1,343.det_pin = AT91_PIN_PA29,344};345346static void __init cpu9krea_board_init(void)347{348/* NOR */349cpu9krea_add_device_nor();350/* Serial */351at91_add_device_serial();352/* USB Host */353at91_add_device_usbh(&cpu9krea_usbh_data);354/* USB Device */355at91_add_device_udc(&cpu9krea_udc_data);356/* NAND */357cpu9krea_add_device_nand();358/* Ethernet */359at91_add_device_eth(&cpu9krea_macb_data);360/* MMC */361at91_add_device_mmc(0, &cpu9krea_mmc_data);362/* I2C */363at91_add_device_i2c(cpu9krea_i2c_devices,364ARRAY_SIZE(cpu9krea_i2c_devices));365/* LEDs */366at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds));367/* Push Buttons */368cpu9krea_add_device_buttons();369}370371#ifdef CONFIG_MACH_CPU9260372MACHINE_START(CPUAT9260, "Eukrea CPU9260")373#else374MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")375#endif376/* Maintainer: Eric Benard - EUKREA Electromatique */377.timer = &at91sam926x_timer,378.map_io = at91sam9260_map_io,379.init_early = cpu9krea_init_early,380.init_irq = cpu9krea_init_irq,381.init_machine = cpu9krea_board_init,382MACHINE_END383384385