Path: blob/master/arch/arm/mach-at91/board-cap9adk.c
10817 views
/*1* linux/arch/arm/mach-at91/board-cap9adk.c2*3* Copyright (C) 2007 Stelian Pop <[email protected]>4* Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>5* Copyright (C) 2005 SAN People6* Copyright (C) 2007 Atmel Corporation.7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or11* (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 of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21*/2223#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/spi/spi.h>29#include <linux/spi/ads7846.h>30#include <linux/fb.h>31#include <linux/mtd/physmap.h>3233#include <video/atmel_lcdc.h>3435#include <mach/hardware.h>36#include <asm/setup.h>37#include <asm/mach-types.h>3839#include <asm/mach/arch.h>40#include <asm/mach/map.h>4142#include <mach/board.h>43#include <mach/gpio.h>44#include <mach/at91cap9_matrix.h>45#include <mach/at91sam9_smc.h>46#include <mach/system_rev.h>4748#include "sam9_smc.h"49#include "generic.h"505152static void __init cap9adk_init_early(void)53{54/* Initialize processor: 12 MHz crystal */55at91cap9_initialize(12000000);5657/* Setup the LEDs: USER1 and USER2 LED for cpu/timer... */58at91_init_leds(AT91_PIN_PA10, AT91_PIN_PA11);59/* ... POWER LED always on */60at91_set_gpio_output(AT91_PIN_PC29, 1);6162/* Setup the serial ports and console */63at91_register_uart(0, 0, 0); /* DBGU = ttyS0 */64at91_set_serial_console(0);65}6667static void __init cap9adk_init_irq(void)68{69at91cap9_init_interrupts(NULL);70}717273/*74* USB Host port75*/76static struct at91_usbh_data __initdata cap9adk_usbh_data = {77.ports = 2,78};7980/*81* USB HS Device port82*/83static struct usba_platform_data __initdata cap9adk_usba_udc_data = {84.vbus_pin = AT91_PIN_PB31,85};8687/*88* ADS7846 Touchscreen89*/90#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)91static int ads7843_pendown_state(void)92{93return !at91_get_gpio_value(AT91_PIN_PC4); /* Touchscreen PENIRQ */94}9596static struct ads7846_platform_data ads_info = {97.model = 7843,98.x_min = 150,99.x_max = 3830,100.y_min = 190,101.y_max = 3830,102.vref_delay_usecs = 100,103.x_plate_ohms = 450,104.y_plate_ohms = 250,105.pressure_max = 15000,106.debounce_max = 1,107.debounce_rep = 0,108.debounce_tol = (~0),109.get_pendown_state = ads7843_pendown_state,110};111112static void __init cap9adk_add_device_ts(void)113{114at91_set_gpio_input(AT91_PIN_PC4, 1); /* Touchscreen PENIRQ */115at91_set_gpio_input(AT91_PIN_PC5, 1); /* Touchscreen BUSY */116}117#else118static void __init cap9adk_add_device_ts(void) {}119#endif120121122/*123* SPI devices.124*/125static struct spi_board_info cap9adk_spi_devices[] = {126#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)127{ /* DataFlash card */128.modalias = "mtd_dataflash",129.chip_select = 0,130.max_speed_hz = 15 * 1000 * 1000,131.bus_num = 0,132},133#endif134#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)135{136.modalias = "ads7846",137.chip_select = 3, /* can be 2 or 3, depending on J2 jumper */138.max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */139.bus_num = 0,140.platform_data = &ads_info,141.irq = AT91_PIN_PC4,142},143#endif144};145146147/*148* MCI (SD/MMC)149*/150static struct at91_mmc_data __initdata cap9adk_mmc_data = {151.wire4 = 1,152// .det_pin = ... not connected153// .wp_pin = ... not connected154// .vcc_pin = ... not connected155};156157158/*159* MACB Ethernet device160*/161static struct at91_eth_data __initdata cap9adk_macb_data = {162.is_rmii = 1,163};164165166/*167* NAND flash168*/169static struct mtd_partition __initdata cap9adk_nand_partitions[] = {170{171.name = "NAND partition",172.offset = 0,173.size = MTDPART_SIZ_FULL,174},175};176177static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)178{179*num_partitions = ARRAY_SIZE(cap9adk_nand_partitions);180return cap9adk_nand_partitions;181}182183static struct atmel_nand_data __initdata cap9adk_nand_data = {184.ale = 21,185.cle = 22,186// .det_pin = ... not connected187// .rdy_pin = ... not connected188.enable_pin = AT91_PIN_PD15,189.partition_info = nand_partitions,190};191192static struct sam9_smc_config __initdata cap9adk_nand_smc_config = {193.ncs_read_setup = 1,194.nrd_setup = 2,195.ncs_write_setup = 1,196.nwe_setup = 2,197198.ncs_read_pulse = 6,199.nrd_pulse = 4,200.ncs_write_pulse = 6,201.nwe_pulse = 4,202203.read_cycle = 8,204.write_cycle = 8,205206.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,207.tdf_cycles = 1,208};209210static void __init cap9adk_add_device_nand(void)211{212unsigned long csa;213214csa = at91_sys_read(AT91_MATRIX_EBICSA);215at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);216217cap9adk_nand_data.bus_width_16 = board_have_nand_16bit();218/* setup bus-width (8 or 16) */219if (cap9adk_nand_data.bus_width_16)220cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_16;221else222cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_8;223224/* configure chip-select 3 (NAND) */225sam9_smc_configure(3, &cap9adk_nand_smc_config);226227at91_add_device_nand(&cap9adk_nand_data);228}229230231/*232* NOR flash233*/234static struct mtd_partition cap9adk_nor_partitions[] = {235{236.name = "NOR partition",237.offset = 0,238.size = MTDPART_SIZ_FULL,239},240};241242static struct physmap_flash_data cap9adk_nor_data = {243.width = 2,244.parts = cap9adk_nor_partitions,245.nr_parts = ARRAY_SIZE(cap9adk_nor_partitions),246};247248#define NOR_BASE AT91_CHIPSELECT_0249#define NOR_SIZE SZ_8M250251static struct resource nor_flash_resources[] = {252{253.start = NOR_BASE,254.end = NOR_BASE + NOR_SIZE - 1,255.flags = IORESOURCE_MEM,256}257};258259static struct platform_device cap9adk_nor_flash = {260.name = "physmap-flash",261.id = 0,262.dev = {263.platform_data = &cap9adk_nor_data,264},265.resource = nor_flash_resources,266.num_resources = ARRAY_SIZE(nor_flash_resources),267};268269static struct sam9_smc_config __initdata cap9adk_nor_smc_config = {270.ncs_read_setup = 2,271.nrd_setup = 4,272.ncs_write_setup = 2,273.nwe_setup = 4,274275.ncs_read_pulse = 10,276.nrd_pulse = 8,277.ncs_write_pulse = 10,278.nwe_pulse = 8,279280.read_cycle = 16,281.write_cycle = 16,282283.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,284.tdf_cycles = 1,285};286287static __init void cap9adk_add_device_nor(void)288{289unsigned long csa;290291csa = at91_sys_read(AT91_MATRIX_EBICSA);292at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);293294/* configure chip-select 0 (NOR) */295sam9_smc_configure(0, &cap9adk_nor_smc_config);296297platform_device_register(&cap9adk_nor_flash);298}299300301/*302* LCD Controller303*/304#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)305static struct fb_videomode at91_tft_vga_modes[] = {306{307.name = "TX09D50VM1CCA @ 60",308.refresh = 60,309.xres = 240, .yres = 320,310.pixclock = KHZ2PICOS(4965),311312.left_margin = 1, .right_margin = 33,313.upper_margin = 1, .lower_margin = 0,314.hsync_len = 5, .vsync_len = 1,315316.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,317.vmode = FB_VMODE_NONINTERLACED,318},319};320321static struct fb_monspecs at91fb_default_monspecs = {322.manufacturer = "HIT",323.monitor = "TX09D70VM1CCA",324325.modedb = at91_tft_vga_modes,326.modedb_len = ARRAY_SIZE(at91_tft_vga_modes),327.hfmin = 15000,328.hfmax = 64000,329.vfmin = 50,330.vfmax = 150,331};332333#define AT91CAP9_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \334| ATMEL_LCDC_DISTYPE_TFT \335| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)336337static void at91_lcdc_power_control(int on)338{339if (on)340at91_set_gpio_value(AT91_PIN_PC0, 0); /* power up */341else342at91_set_gpio_value(AT91_PIN_PC0, 1); /* power down */343}344345/* Driver datas */346static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data = {347.default_bpp = 16,348.default_dmacon = ATMEL_LCDC_DMAEN,349.default_lcdcon2 = AT91CAP9_DEFAULT_LCDCON2,350.default_monspecs = &at91fb_default_monspecs,351.atmel_lcdfb_power_control = at91_lcdc_power_control,352.guard_time = 1,353};354355#else356static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data;357#endif358359360/*361* AC97362*/363static struct ac97c_platform_data cap9adk_ac97_data = {364// .reset_pin = ... not connected365};366367368static void __init cap9adk_board_init(void)369{370/* Serial */371at91_add_device_serial();372/* USB Host */373at91_add_device_usbh(&cap9adk_usbh_data);374/* USB HS */375at91_add_device_usba(&cap9adk_usba_udc_data);376/* SPI */377at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));378/* Touchscreen */379cap9adk_add_device_ts();380/* MMC */381at91_add_device_mmc(1, &cap9adk_mmc_data);382/* Ethernet */383at91_add_device_eth(&cap9adk_macb_data);384/* NAND */385cap9adk_add_device_nand();386/* NOR Flash */387cap9adk_add_device_nor();388/* I2C */389at91_add_device_i2c(NULL, 0);390/* LCD Controller */391at91_add_device_lcdc(&cap9adk_lcdc_data);392/* AC97 */393at91_add_device_ac97(&cap9adk_ac97_data);394}395396MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK")397/* Maintainer: Stelian Pop <[email protected]> */398.timer = &at91sam926x_timer,399.map_io = at91cap9_map_io,400.init_early = cap9adk_init_early,401.init_irq = cap9adk_init_irq,402.init_machine = cap9adk_board_init,403MACHINE_END404405406