/* * linux/arch/arm/mach-at91/board-yl-9200.c * * Adapted from: *various board files in * /arch/arm/mach-at91 * modifications to convert to YL-9200 platform * Copyright (C) 2007 S.Birtles * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include /*#include */ #include #include /*#include */ #include #include #include #include #include #include #include #include #include #include #include #include #include "generic.h" #include #define YL_9200_FLASH_BASE AT91_CHIPSELECT_0 #define YL_9200_FLASH_SIZE 0x800000 /* * Serial port configuration. * 0 .. 3 = USART0 .. USART3 * 4 = DBGU *atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL *atmel_usart.1: ttyS1 at MMIO 0xfffc0000 (irq = 6) is a ATMEL_SERIAL *atmel_usart.2: ttyS2 at MMIO 0xfffc4000 (irq = 7) is a ATMEL_SERIAL *atmel_usart.3: ttyS3 at MMIO 0xfffc8000 (irq = 8) is a ATMEL_SERIAL *atmel_usart.4: ttyS4 at MMIO 0xfffcc000 (irq = 9) is a ATMEL_SERIAL * on the YL-9200 we are sitting at the following *ttyS0 at MMIO 0xfefff200 (irq = 1) is a AT91_SERIAL *ttyS1 at MMIO 0xfefc4000 (irq = 7) is a AT91_SERIAL */ /* extern void __init yl_9200_add_device_sounder(struct gpio_sounder *sounders, int nr);*/ static struct at91_uart_config __initdata yl_9200_uart_config = { .console_tty = 0, /* ttyS0 */ .nr_tty = 3, .tty_map = { 4, 1, 0, -1, -1 } /* ttyS0, ..., ttyS4 */ }; static void __init yl_9200_map_io(void) { /* Initialize processor: 18.432 MHz crystal */ /*Also initialises register clocks & gpio*/ at91rm9200_initialize(18432000, AT91RM9200_PQFP); /*we have a 3 bank system*/ /* Setup the serial ports and console */ at91_init_serial(&yl_9200_uart_config); /* Setup the LEDs D2=PB17,D3=PB16 */ at91_init_leds(AT91_PIN_PB16,AT91_PIN_PB17); /*cpu-led,timer-led*/ } static void __init yl_9200_init_irq(void) { at91rm9200_init_interrupts(NULL); } static struct at91_eth_data __initdata yl_9200_eth_data = { .phy_irq_pin = AT91_PIN_PB28, .is_rmii = 1, }; static struct at91_usbh_data __initdata yl_9200_usbh_data = { .ports = 1, /* this should be 1 not 2 for the Yl9200*/ }; static struct at91_udc_data __initdata yl_9200_udc_data = { /*on sheet 7 Schemitic rev 1.0*/ .pullup_pin = AT91_PIN_PC4, .vbus_pin= AT91_PIN_PC5, .pullup_active_low = 1, /*ACTIVE LOW!! due to PNP transistor on page 7*/ }; /* static struct at91_cf_data __initdata yl_9200_cf_data = { TODO S.BIRTLES .det_pin = AT91_PIN_xxx, .rst_pin = AT91_PIN_xxx, .irq_pin = ... not connected .vcc_pin = ... always powered }; */ static struct at91_mmc_data __initdata yl_9200_mmc_data = { .det_pin = AT91_PIN_PB9, /*THIS LOOKS CORRECT SHEET7*/ /* .wp_pin = ... not connected SHEET7*/ .slot_b = 0, .wire4 = 1, }; /* -------------------------------------------------------------------- * Touch screen * -------------------------------------------------------------------- */ #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) static int ads7843_pendown_state(void) { return !at91_get_gpio_value(AT91_PIN_PB11); /* Touchscreen PENIRQ */ } static void __init at91_init_device_ts(void) { /*IMPORTANT NOTE THE SPI INTERFACE IS ALREADY CONFIGURED BY XXX_DEVICES.C THAT IS TO SAY THAT MISO,MOSI,SPCK AND CS are already configured we only need to enable the other datapins which are: PB10/RK1 BUSY */ /* Touchscreen BUSY signal , pin,use pullup ( TODO not currently used in the ADS7843/6.c driver)*/ at91_set_gpio_input(AT91_PIN_PB10, 1); } #else static void __init at91_init_device_ts(void) {} #endif static struct ads7846_platform_data ads_info = { .model = 7843, .x_min = 150, .x_max = 3830, .y_min = 190, .y_max = 3830, .vref_delay_usecs = 100, /* for a 8" touch screen*/ //.x_plate_ohms = 603, //= 450, S.Birtles TODO //.y_plate_ohms = 332, //= 250, S.Birtles TODO /*for a 10.4" touch screen*/ //.x_plate_ohms =611, //.y_plate_ohms =325, .x_plate_ohms = 576, .y_plate_ohms = 366, // .pressure_max = 15000, /*generally nonsense on the 7843*/ /*number of times to send query to chip in a given run 0 equals one time (do not set to 0!! ,there is a bug in ADS 7846 code)*/ .debounce_max = 1, .debounce_rep = 0, .debounce_tol = (~0), .get_pendown_state = ads7843_pendown_state, }; /*static struct canbus_platform_data can_info = { .model = 2510, }; */ static struct spi_board_info yl_9200_spi_devices[] = { /*this sticks it at: /sys/devices/platform/atmel_spi.0/spi0.0 /sys/bus/platform/devices/ Documentation/spi IIRC*/ #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) /*(this IS correct 04-NOV-2007)*/ { .modalias = "ads7846", /* because the driver is called ads7846*/ .chip_select = 0, /*THIS MUST BE AN INDEX INTO AN ARRAY OF pins */ /*this is ONLY TO BE USED if chipselect above is not used, it passes a pin directly for the chip select*/ /*.controller_data =AT91_PIN_PA3 ,*/ .max_speed_hz = 5000*26, /*(4700 * 26)-125000 * 26, (max sample rate @ 3V) * (cmd + data + overhead) */ .bus_num = 0, .platform_data = &ads_info, .irq = AT91_PIN_PB11, }, #endif /*we need to put our CAN driver data here!!*/ /*THIS IS ALL DUMMY DATA*/ /* { .modalias = "mcp2510", //DUMMY for MCP2510 chip .chip_select = 1,*/ /*THIS MUST BE AN INDEX INTO AN ARRAY OF pins */ /*this is ONLY TO BE USED if chipselect above is not used, it passes a pin directly for the chip select */ /* .controller_data =AT91_PIN_PA4 , .max_speed_hz = 25000 * 26, .bus_num = 0, .platform_data = &can_info, .irq = AT91_PIN_PC0, }, */ //max SPI chip needs to go here }; static struct mtd_partition __initdata yl_9200_nand_partition[] = { { .name = "AT91 NAND partition 1, boot", .offset = 0, .size = 1 * SZ_256K }, { .name = "AT91 NAND partition 2, kernel", .offset = 1 * SZ_256K, .size = 2 * SZ_1M - 1 * SZ_256K }, { .name = "AT91 NAND partition 3, filesystem", .offset = 2 * SZ_1M, .size = 14 * SZ_1M }, { .name = "AT91 NAND partition 4, storage", .offset = 16 * SZ_1M, .size = 16 * SZ_1M }, { .name = "AT91 NAND partition 5, ext-fs", .offset = 32 * SZ_1M, .size = 32 * SZ_1M }, }; static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) { *num_partitions = ARRAY_SIZE(yl_9200_nand_partition); return yl_9200_nand_partition; } static struct at91_nand_data __initdata yl_9200_nand_data = { .ale= 6, .cle= 7, /*.det_pin = AT91_PIN_PCxx,*/ /*we don't have a det pin because NandFlash is fixed to board*/ .rdy_pin = AT91_PIN_PC14, /*R/!B Sheet10*/ .enable_pin = AT91_PIN_PC15, /*!CE Sheet10 */ .partition_info = nand_partitions, }; /* TODO S.Birtles potentially a problem with the size above physmap platform flash device: 00800000 at 10000000 physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank NOR chip too large to fit in mapping. Attempting to cope... Intel/Sharp Extended Query Table at 0x0031 Using buffer write method cfi_cmdset_0001: Erase suspend on write enabled Reducing visibility of 16384KiB chip to 8192KiB */ static struct mtd_partition yl_9200_flash_partitions[] = { { .name = "Bootloader", .size = 0x00040000, .offset = 0, .mask_flags = MTD_WRITEABLE /* force read-only */ },{ .name = "Kernel", .size = 0x001C0000, .offset = 0x00040000, },{ .name = "Filesystem", .size = MTDPART_SIZ_FULL, .offset = 0x00200000 } }; static struct physmap_flash_data yl_9200_flash_data = { .width = 2, .parts = yl_9200_flash_partitions, .nr_parts = ARRAY_SIZE(yl_9200_flash_partitions), }; static struct resource yl_9200_flash_resources[] = { { .start = YL_9200_FLASH_BASE, .end = YL_9200_FLASH_BASE + YL_9200_FLASH_SIZE - 1, .flags = IORESOURCE_MEM, } }; static struct platform_device yl_9200_flash = { .name = "physmap-flash", .id = 0, .dev = { .platform_data = &yl_9200_flash_data, }, .resource = yl_9200_flash_resources, .num_resources = ARRAY_SIZE(yl_9200_flash_resources), }; static struct gpio_led yl_9200_leds[] = { /*D2 &D3 are passed directly in via at91_init_leds*/ { .name = "led4", /*D4*/ .gpio = AT91_PIN_PB15, .active_low = 1, .default_trigger = "heartbeat", /*.default_trigger = "timer",*/ }, { .name = "led5", /*D5*/ .gpio = AT91_PIN_PB8, .active_low = 1, .default_trigger = "heartbeat", } }; //static struct gpio_sounder yl_9200_sounder[] = {*/ /*This is a simple speaker attached to a gpo line*/ // { // .name = "Speaker", /*LS1*/ // .gpio = AT91_PIN_PA22, // .active_low = 0, // .default_trigger = "heartbeat", /*.default_trigger = "timer",*/ // }, //}; static struct i2c_board_info __initdata yl_9200_i2c_devices[] = { { /*TODO*/ I2C_BOARD_INFO("CS4334", 0x00), } }; /* * GPIO Buttons */ #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) static struct gpio_keys_button yl_9200_buttons[] = { { .gpio = AT91_PIN_PA24, .code = BTN_2, .desc = "SW2", .active_low = 1, .wakeup = 1, }, { .gpio = AT91_PIN_PB1, .code = BTN_3, .desc = "SW3", .active_low = 1, .wakeup = 1, }, { .gpio = AT91_PIN_PB2, .code = BTN_4, .desc = "SW4", .active_low = 1, .wakeup = 1, }, { .gpio = AT91_PIN_PB6, .code = BTN_5, .desc = "SW5", .active_low = 1, .wakeup = 1, }, }; static struct gpio_keys_platform_data yl_9200_button_data = { .buttons = yl_9200_buttons, .nbuttons = ARRAY_SIZE(yl_9200_buttons), }; static struct platform_device yl_9200_button_device = { .name = "gpio-keys", .id = -1, .num_resources = 0, .dev = { .platform_data = &yl_9200_button_data, } }; static void __init yl_9200_add_device_buttons(void) { //SW2 at91_set_gpio_input(AT91_PIN_PA24, 0); at91_set_deglitch(AT91_PIN_PA24, 1); //SW3 at91_set_gpio_input(AT91_PIN_PB1, 0); at91_set_deglitch(AT91_PIN_PB1, 1); //SW4 at91_set_gpio_input(AT91_PIN_PB2, 0); at91_set_deglitch(AT91_PIN_PB2, 1); //SW5 at91_set_gpio_input(AT91_PIN_PB6, 0); at91_set_deglitch(AT91_PIN_PB6, 1); at91_set_gpio_output(AT91_PIN_PB7, 1); /* #TURN BUTTONS ON, SHEET 5 of schematics */ platform_device_register(&yl_9200_button_device); } #else static void __init yl_9200_add_device_buttons(void) {} #endif #if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE) #include