Path: blob/master/arch/arm/mach-at91/board-sam9260ek.c
10817 views
/*1* linux/arch/arm/mach-at91/board-sam9260ek.c2*3* Copyright (C) 2005 SAN People4* Copyright (C) 2006 Atmel5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19*/2021#include <linux/types.h>22#include <linux/init.h>23#include <linux/mm.h>24#include <linux/module.h>25#include <linux/platform_device.h>26#include <linux/spi/spi.h>27#include <linux/spi/at73c213.h>28#include <linux/clk.h>29#include <linux/i2c/at24.h>30#include <linux/gpio_keys.h>31#include <linux/input.h>3233#include <asm/setup.h>34#include <asm/mach-types.h>35#include <asm/irq.h>3637#include <asm/mach/arch.h>38#include <asm/mach/map.h>39#include <asm/mach/irq.h>4041#include <mach/hardware.h>42#include <mach/board.h>43#include <mach/gpio.h>44#include <mach/at91sam9_smc.h>45#include <mach/at91_shdwc.h>46#include <mach/system_rev.h>4748#include "sam9_smc.h"49#include "generic.h"505152static void __init ek_init_early(void)53{54/* Initialize processor: 18.432 MHz crystal */55at91sam9260_initialize(18432000);5657/* DBGU on ttyS0. (Rx & Tx only) */58at91_register_uart(0, 0, 0);5960/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */61at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS62| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD63| ATMEL_UART_RI);6465/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */66at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);6768/* set serial console to ttyS0 (ie, DBGU) */69at91_set_serial_console(0);70}7172static void __init ek_init_irq(void)73{74at91sam9260_init_interrupts(NULL);75}767778/*79* USB Host port80*/81static struct at91_usbh_data __initdata ek_usbh_data = {82.ports = 2,83};8485/*86* USB Device port87*/88static struct at91_udc_data __initdata ek_udc_data = {89.vbus_pin = AT91_PIN_PC5,90.pullup_pin = 0, /* pull-up driven by UDC */91};929394/*95* Audio96*/97static struct at73c213_board_info at73c213_data = {98.ssc_id = 0,99.shortname = "AT91SAM9260-EK external DAC",100};101102#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)103static void __init at73c213_set_clk(struct at73c213_board_info *info)104{105struct clk *pck0;106struct clk *plla;107108pck0 = clk_get(NULL, "pck0");109plla = clk_get(NULL, "plla");110111/* AT73C213 MCK Clock */112at91_set_B_periph(AT91_PIN_PC1, 0); /* PCK0 */113114clk_set_parent(pck0, plla);115clk_put(plla);116117info->dac_clk = pck0;118}119#else120static void __init at73c213_set_clk(struct at73c213_board_info *info) {}121#endif122123/*124* SPI devices.125*/126static struct spi_board_info ek_spi_devices[] = {127#if !defined(CONFIG_MMC_AT91)128{ /* DataFlash chip */129.modalias = "mtd_dataflash",130.chip_select = 1,131.max_speed_hz = 15 * 1000 * 1000,132.bus_num = 0,133},134#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)135{ /* DataFlash card */136.modalias = "mtd_dataflash",137.chip_select = 0,138.max_speed_hz = 15 * 1000 * 1000,139.bus_num = 0,140},141#endif142#endif143#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)144{ /* AT73C213 DAC */145.modalias = "at73c213",146.chip_select = 0,147.max_speed_hz = 10 * 1000 * 1000,148.bus_num = 1,149.mode = SPI_MODE_1,150.platform_data = &at73c213_data,151},152#endif153};154155156/*157* MACB Ethernet device158*/159static struct at91_eth_data __initdata ek_macb_data = {160.phy_irq_pin = AT91_PIN_PA7,161.is_rmii = 1,162};163164165/*166* NAND flash167*/168static struct mtd_partition __initdata ek_nand_partition[] = {169{170.name = "Partition 1",171.offset = 0,172.size = SZ_256K,173},174{175.name = "Partition 2",176.offset = MTDPART_OFS_NXTBLK,177.size = MTDPART_SIZ_FULL,178},179};180181static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)182{183*num_partitions = ARRAY_SIZE(ek_nand_partition);184return ek_nand_partition;185}186187static struct atmel_nand_data __initdata ek_nand_data = {188.ale = 21,189.cle = 22,190// .det_pin = ... not connected191.rdy_pin = AT91_PIN_PC13,192.enable_pin = AT91_PIN_PC14,193.partition_info = nand_partitions,194};195196static struct sam9_smc_config __initdata ek_nand_smc_config = {197.ncs_read_setup = 0,198.nrd_setup = 1,199.ncs_write_setup = 0,200.nwe_setup = 1,201202.ncs_read_pulse = 3,203.nrd_pulse = 3,204.ncs_write_pulse = 3,205.nwe_pulse = 3,206207.read_cycle = 5,208.write_cycle = 5,209210.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,211.tdf_cycles = 2,212};213214static void __init ek_add_device_nand(void)215{216ek_nand_data.bus_width_16 = board_have_nand_16bit();217/* setup bus-width (8 or 16) */218if (ek_nand_data.bus_width_16)219ek_nand_smc_config.mode |= AT91_SMC_DBW_16;220else221ek_nand_smc_config.mode |= AT91_SMC_DBW_8;222223/* configure chip-select 3 (NAND) */224sam9_smc_configure(3, &ek_nand_smc_config);225226at91_add_device_nand(&ek_nand_data);227}228229230/*231* MCI (SD/MMC)232*/233static struct at91_mmc_data __initdata ek_mmc_data = {234.slot_b = 1,235.wire4 = 1,236// .det_pin = ... not connected237// .wp_pin = ... not connected238// .vcc_pin = ... not connected239};240241242/*243* LEDs244*/245static struct gpio_led ek_leds[] = {246{ /* "bottom" led, green, userled1 to be defined */247.name = "ds5",248.gpio = AT91_PIN_PA6,249.active_low = 1,250.default_trigger = "none",251},252{ /* "power" led, yellow */253.name = "ds1",254.gpio = AT91_PIN_PA9,255.default_trigger = "heartbeat",256}257};258259/*260* I2C devices261*/262static struct at24_platform_data at24c512 = {263.byte_len = SZ_512K / 8,264.page_size = 128,265.flags = AT24_FLAG_ADDR16,266};267268static struct i2c_board_info __initdata ek_i2c_devices[] = {269{270I2C_BOARD_INFO("24c512", 0x50),271.platform_data = &at24c512,272},273/* more devices can be added using expansion connectors */274};275276277/*278* GPIO Buttons279*/280#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)281static struct gpio_keys_button ek_buttons[] = {282{283.gpio = AT91_PIN_PA30,284.code = BTN_3,285.desc = "Button 3",286.active_low = 1,287.wakeup = 1,288},289{290.gpio = AT91_PIN_PA31,291.code = BTN_4,292.desc = "Button 4",293.active_low = 1,294.wakeup = 1,295}296};297298static struct gpio_keys_platform_data ek_button_data = {299.buttons = ek_buttons,300.nbuttons = ARRAY_SIZE(ek_buttons),301};302303static struct platform_device ek_button_device = {304.name = "gpio-keys",305.id = -1,306.num_resources = 0,307.dev = {308.platform_data = &ek_button_data,309}310};311312static void __init ek_add_device_buttons(void)313{314at91_set_gpio_input(AT91_PIN_PA30, 1); /* btn3 */315at91_set_deglitch(AT91_PIN_PA30, 1);316at91_set_gpio_input(AT91_PIN_PA31, 1); /* btn4 */317at91_set_deglitch(AT91_PIN_PA31, 1);318319platform_device_register(&ek_button_device);320}321#else322static void __init ek_add_device_buttons(void) {}323#endif324325326static void __init ek_board_init(void)327{328/* Serial */329at91_add_device_serial();330/* USB Host */331at91_add_device_usbh(&ek_usbh_data);332/* USB Device */333at91_add_device_udc(&ek_udc_data);334/* SPI */335at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));336/* NAND */337ek_add_device_nand();338/* Ethernet */339at91_add_device_eth(&ek_macb_data);340/* MMC */341at91_add_device_mmc(0, &ek_mmc_data);342/* I2C */343at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));344/* SSC (to AT73C213) */345at73c213_set_clk(&at73c213_data);346at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);347/* LEDs */348at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));349/* Push Buttons */350ek_add_device_buttons();351}352353MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")354/* Maintainer: Atmel */355.timer = &at91sam926x_timer,356.map_io = at91sam9260_map_io,357.init_early = ek_init_early,358.init_irq = ek_init_irq,359.init_machine = ek_board_init,360MACHINE_END361362363