Path: blob/master/arch/arm/mach-at91/board-sam9263ek.c
10817 views
/*1* linux/arch/arm/mach-at91/board-sam9263ek.c2*3* Copyright (C) 2005 SAN People4* Copyright (C) 2007 Atmel Corporation.5*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/ads7846.h>28#include <linux/i2c/at24.h>29#include <linux/fb.h>30#include <linux/gpio_keys.h>31#include <linux/input.h>32#include <linux/leds.h>3334#include <video/atmel_lcdc.h>3536#include <asm/setup.h>37#include <asm/mach-types.h>38#include <asm/irq.h>3940#include <asm/mach/arch.h>41#include <asm/mach/map.h>42#include <asm/mach/irq.h>4344#include <mach/hardware.h>45#include <mach/board.h>46#include <mach/gpio.h>47#include <mach/at91sam9_smc.h>48#include <mach/at91_shdwc.h>49#include <mach/system_rev.h>5051#include "sam9_smc.h"52#include "generic.h"535455static void __init ek_init_early(void)56{57/* Initialize processor: 16.367 MHz crystal */58at91sam9263_initialize(16367660);5960/* DBGU on ttyS0. (Rx & Tx only) */61at91_register_uart(0, 0, 0);6263/* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */64at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);6566/* set serial console to ttyS0 (ie, DBGU) */67at91_set_serial_console(0);68}6970static void __init ek_init_irq(void)71{72at91sam9263_init_interrupts(NULL);73}747576/*77* USB Host port78*/79static struct at91_usbh_data __initdata ek_usbh_data = {80.ports = 2,81.vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 },82};8384/*85* USB Device port86*/87static struct at91_udc_data __initdata ek_udc_data = {88.vbus_pin = AT91_PIN_PA25,89.pullup_pin = 0, /* pull-up driven by UDC */90};919293/*94* ADS7846 Touchscreen95*/96#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)97static int ads7843_pendown_state(void)98{99return !at91_get_gpio_value(AT91_PIN_PA15); /* Touchscreen PENIRQ */100}101102static struct ads7846_platform_data ads_info = {103.model = 7843,104.x_min = 150,105.x_max = 3830,106.y_min = 190,107.y_max = 3830,108.vref_delay_usecs = 100,109.x_plate_ohms = 450,110.y_plate_ohms = 250,111.pressure_max = 15000,112.debounce_max = 1,113.debounce_rep = 0,114.debounce_tol = (~0),115.get_pendown_state = ads7843_pendown_state,116};117118static void __init ek_add_device_ts(void)119{120at91_set_B_periph(AT91_PIN_PA15, 1); /* External IRQ1, with pullup */121at91_set_gpio_input(AT91_PIN_PA31, 1); /* Touchscreen BUSY signal */122}123#else124static void __init ek_add_device_ts(void) {}125#endif126127/*128* SPI devices.129*/130static struct spi_board_info ek_spi_devices[] = {131#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)132{ /* DataFlash card */133.modalias = "mtd_dataflash",134.chip_select = 0,135.max_speed_hz = 15 * 1000 * 1000,136.bus_num = 0,137},138#endif139#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)140{141.modalias = "ads7846",142.chip_select = 3,143.max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */144.bus_num = 0,145.platform_data = &ads_info,146.irq = AT91SAM9263_ID_IRQ1,147},148#endif149};150151152/*153* MCI (SD/MMC)154*/155static struct at91_mmc_data __initdata ek_mmc_data = {156.wire4 = 1,157.det_pin = AT91_PIN_PE18,158.wp_pin = AT91_PIN_PE19,159// .vcc_pin = ... not connected160};161162163/*164* MACB Ethernet device165*/166static struct at91_eth_data __initdata ek_macb_data = {167.phy_irq_pin = AT91_PIN_PE31,168.is_rmii = 1,169};170171172/*173* NAND flash174*/175static struct mtd_partition __initdata ek_nand_partition[] = {176{177.name = "Partition 1",178.offset = 0,179.size = SZ_64M,180},181{182.name = "Partition 2",183.offset = MTDPART_OFS_NXTBLK,184.size = MTDPART_SIZ_FULL,185},186};187188static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)189{190*num_partitions = ARRAY_SIZE(ek_nand_partition);191return ek_nand_partition;192}193194static struct atmel_nand_data __initdata ek_nand_data = {195.ale = 21,196.cle = 22,197// .det_pin = ... not connected198.rdy_pin = AT91_PIN_PA22,199.enable_pin = AT91_PIN_PD15,200.partition_info = nand_partitions,201};202203static struct sam9_smc_config __initdata ek_nand_smc_config = {204.ncs_read_setup = 0,205.nrd_setup = 1,206.ncs_write_setup = 0,207.nwe_setup = 1,208209.ncs_read_pulse = 3,210.nrd_pulse = 3,211.ncs_write_pulse = 3,212.nwe_pulse = 3,213214.read_cycle = 5,215.write_cycle = 5,216217.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,218.tdf_cycles = 2,219};220221static void __init ek_add_device_nand(void)222{223ek_nand_data.bus_width_16 = board_have_nand_16bit();224/* setup bus-width (8 or 16) */225if (ek_nand_data.bus_width_16)226ek_nand_smc_config.mode |= AT91_SMC_DBW_16;227else228ek_nand_smc_config.mode |= AT91_SMC_DBW_8;229230/* configure chip-select 3 (NAND) */231sam9_smc_configure(3, &ek_nand_smc_config);232233at91_add_device_nand(&ek_nand_data);234}235236237/*238* I2C devices239*/240static struct at24_platform_data at24c512 = {241.byte_len = SZ_512K / 8,242.page_size = 128,243.flags = AT24_FLAG_ADDR16,244};245246247static struct i2c_board_info __initdata ek_i2c_devices[] = {248{249I2C_BOARD_INFO("24c512", 0x50),250.platform_data = &at24c512,251},252/* more devices can be added using expansion connectors */253};254255/*256* LCD Controller257*/258#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)259static struct fb_videomode at91_tft_vga_modes[] = {260{261.name = "TX09D50VM1CCA @ 60",262.refresh = 60,263.xres = 240, .yres = 320,264.pixclock = KHZ2PICOS(4965),265266.left_margin = 1, .right_margin = 33,267.upper_margin = 1, .lower_margin = 0,268.hsync_len = 5, .vsync_len = 1,269270.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,271.vmode = FB_VMODE_NONINTERLACED,272},273};274275static struct fb_monspecs at91fb_default_monspecs = {276.manufacturer = "HIT",277.monitor = "TX09D70VM1CCA",278279.modedb = at91_tft_vga_modes,280.modedb_len = ARRAY_SIZE(at91_tft_vga_modes),281.hfmin = 15000,282.hfmax = 64000,283.vfmin = 50,284.vfmax = 150,285};286287#define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \288| ATMEL_LCDC_DISTYPE_TFT \289| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)290291static void at91_lcdc_power_control(int on)292{293at91_set_gpio_value(AT91_PIN_PA30, on);294}295296/* Driver datas */297static struct atmel_lcdfb_info __initdata ek_lcdc_data = {298.lcdcon_is_backlight = true,299.default_bpp = 16,300.default_dmacon = ATMEL_LCDC_DMAEN,301.default_lcdcon2 = AT91SAM9263_DEFAULT_LCDCON2,302.default_monspecs = &at91fb_default_monspecs,303.atmel_lcdfb_power_control = at91_lcdc_power_control,304.guard_time = 1,305};306307#else308static struct atmel_lcdfb_info __initdata ek_lcdc_data;309#endif310311312/*313* GPIO Buttons314*/315#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)316static struct gpio_keys_button ek_buttons[] = {317{ /* BP1, "leftclic" */318.code = BTN_LEFT,319.gpio = AT91_PIN_PC5,320.active_low = 1,321.desc = "left_click",322.wakeup = 1,323},324{ /* BP2, "rightclic" */325.code = BTN_RIGHT,326.gpio = AT91_PIN_PC4,327.active_low = 1,328.desc = "right_click",329.wakeup = 1,330}331};332333static struct gpio_keys_platform_data ek_button_data = {334.buttons = ek_buttons,335.nbuttons = ARRAY_SIZE(ek_buttons),336};337338static struct platform_device ek_button_device = {339.name = "gpio-keys",340.id = -1,341.num_resources = 0,342.dev = {343.platform_data = &ek_button_data,344}345};346347static void __init ek_add_device_buttons(void)348{349at91_set_GPIO_periph(AT91_PIN_PC5, 1); /* left button */350at91_set_deglitch(AT91_PIN_PC5, 1);351at91_set_GPIO_periph(AT91_PIN_PC4, 1); /* right button */352at91_set_deglitch(AT91_PIN_PC4, 1);353354platform_device_register(&ek_button_device);355}356#else357static void __init ek_add_device_buttons(void) {}358#endif359360361/*362* AC97363* reset_pin is not connected: NRST364*/365static struct ac97c_platform_data ek_ac97_data = {366};367368369/*370* LEDs ... these could all be PWM-driven, for variable brightness371*/372static struct gpio_led ek_leds[] = {373{ /* "right" led, green, userled2 (could be driven by pwm2) */374.name = "ds2",375.gpio = AT91_PIN_PC29,376.active_low = 1,377.default_trigger = "nand-disk",378},379{ /* "power" led, yellow (could be driven by pwm0) */380.name = "ds3",381.gpio = AT91_PIN_PB7,382.default_trigger = "heartbeat",383}384};385386/*387* PWM Leds388*/389static struct gpio_led ek_pwm_led[] = {390/* For now only DS1 is PWM-driven (by pwm1) */391{392.name = "ds1",393.gpio = 1, /* is PWM channel number */394.active_low = 1,395.default_trigger = "none",396}397};398399/*400* CAN401*/402static void sam9263ek_transceiver_switch(int on)403{404if (on) {405at91_set_gpio_output(AT91_PIN_PA18, 1); /* CANRXEN */406at91_set_gpio_output(AT91_PIN_PA19, 0); /* CANRS */407} else {408at91_set_gpio_output(AT91_PIN_PA18, 0); /* CANRXEN */409at91_set_gpio_output(AT91_PIN_PA19, 1); /* CANRS */410}411}412413static struct at91_can_data ek_can_data = {414.transceiver_switch = sam9263ek_transceiver_switch,415};416417static void __init ek_board_init(void)418{419/* Serial */420at91_add_device_serial();421/* USB Host */422at91_add_device_usbh(&ek_usbh_data);423/* USB Device */424at91_add_device_udc(&ek_udc_data);425/* SPI */426at91_set_gpio_output(AT91_PIN_PE20, 1); /* select spi0 clock */427at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));428/* Touchscreen */429ek_add_device_ts();430/* MMC */431at91_add_device_mmc(1, &ek_mmc_data);432/* Ethernet */433at91_add_device_eth(&ek_macb_data);434/* NAND */435ek_add_device_nand();436/* I2C */437at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));438/* LCD Controller */439at91_add_device_lcdc(&ek_lcdc_data);440/* Push Buttons */441ek_add_device_buttons();442/* AC97 */443at91_add_device_ac97(&ek_ac97_data);444/* LEDs */445at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));446at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));447/* CAN */448at91_add_device_can(&ek_can_data);449}450451MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")452/* Maintainer: Atmel */453.timer = &at91sam926x_timer,454.map_io = at91sam9263_map_io,455.init_early = ek_init_early,456.init_irq = ek_init_irq,457.init_machine = ek_board_init,458MACHINE_END459460461