Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Board-specific setup code for the AT91SAM9M10G45 Evaluation Kit family
- *
- * Covers: * AT91SAM9G45-EKES board
- * * AT91SAM9M10G45-EK board
- *
- * Copyright (C) 2009 Atmel Corporation.
- *
- * 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.
- *
- */
- #include <linux/types.h>
- #include <linux/init.h>
- #include <linux/mm.h>
- #include <linux/module.h>
- #include <linux/platform_device.h>
- #include <linux/spi/spi.h>
- #include <linux/spi/ads7846.h>
- #include <linux/fb.h>
- #include <linux/gpio_keys.h>
- #include <linux/input.h>
- #include <linux/leds.h>
- #include <linux/clk.h>
- #include <linux/i2c/pcf857x.h>
- #include <mach/hardware.h>
- #include <video/atmel_lcdc.h>
- #include <asm/setup.h>
- #include <linux/i2c/at24.h>
- #include <asm/mach-types.h>
- #include <asm/irq.h>
- #include <asm/mach/arch.h>
- #include <asm/mach/map.h>
- #include <asm/mach/irq.h>
- #include <mach/hardware.h>
- #include <mach/board.h>
- #include <mach/gpio.h>
- #include <mach/at91sam9_smc.h>
- #include <mach/at91_shdwc.h>
- #include <linux/i2c/tsc2007.h>
- #include <linux/w1-gpio.h>
- #include "sam9_smc.h"
- #include "generic.h"
- static struct w1_gpio_platform_data sn_w1_gpio_pdata = {
- .pin = AT91_PIN_PD12,
- .is_open_drain = 1,
- };
- static struct platform_device sn_w1_device = {
- .name = "w1-gpio",
- .id = -1,
- .dev.platform_data = &sn_w1_gpio_pdata,
- };
- static void __init ek_map_io(void)
- {
- /* Initialize processor: 12.000 MHz crystal */
- at91sam9g45_initialize(12000000);
- /* DGBU on ttyS0. (Rx & Tx only) */
- at91_register_uart(0, 0, 0);
- // For RS485 you might enable ATMEL_UART_RTS instead of 0
- // at91_register_uart(AT91SAM9G45_ID_US0, 1, 0);
- at91_register_uart(AT91SAM9G45_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
- at91_register_uart(AT91SAM9G45_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
- at91_register_uart(AT91SAM9G45_ID_US3, 4, ATMEL_UART_CTS | ATMEL_UART_RTS);
- /* set serial console to ttyS0 (ie, DBGU) */
- at91_set_serial_console(0);
- }
- static void __init ek_init_irq(void)
- {
- at91sam9g45_init_interrupts(NULL);
- }
- /*
- * USB HS Host port (common to OHCI & EHCI)
- */
- static struct at91_usbh_data __initdata ek_usbh_hs_data = {
- .ports = 2,
- // .vbus_pin = {AT91_PIN_PB12, AT91_PIN_PB13, },
- };
- /*
- * I2C devices
- */
- static struct tsc2007_platform_data tsc2007_info = {
- .model = 2007,
- .x_plate_ohms = 180,
- //.get_pendown_state = ts_get_pendown_state,
- };
- static struct at24_platform_data at24c32 = {
- .byte_len = SZ_32K / 8,
- .page_size = 32,
- .flags = AT24_FLAG_ADDR16,
- };
- static struct i2c_board_info icnova_i2c[] = {
- { I2C_BOARD_INFO("m41t82", 0x68) },
- { I2C_BOARD_INFO("tsc2007", 0x49),
- .type = "tsc2007",
- .platform_data = &tsc2007_info,
- },
- };
- static struct pcf857x_platform_data pcf23_pdata = {
- .gpio_base = NR_BUILTIN_GPIO,
- .n_latch = 0,
- .setup = NULL,
- .teardown = NULL,
- .context = NULL,
- };
- static struct i2c_board_info icnova_i2c2[] = {
- { I2C_BOARD_INFO("apds9300", 0x39) },
- { I2C_BOARD_INFO("tmp102", 0x48),
- .irq = AT91_PIN_PD27,
- },
- { I2C_BOARD_INFO("isl12022", 0x6f),
- .irq = AT91_PIN_PA26,
- },
- { I2C_BOARD_INFO("24c32", 0x50),
- .platform_data = &at24c32,
- },
- { I2C_BOARD_INFO("pcf8574", 0x22),
- .platform_data = &pcf23_pdata,
- },
- };
- /*
- * SPI devices.
- */
- #define CONFIG_BOARD_ICNOVA_ADS7846_IRQ AT91_PIN_PC30
- #define CONFIG_BOARD_ICNOVA_ADS7846_CS 1
- static struct ads7846_platform_data ads_info = {
- .model = 7846,
- .vref_delay_usecs = 100,
- .gpio_pendown = CONFIG_BOARD_ICNOVA_ADS7846_IRQ,
- .x_min = 180,//330,
- .y_min = 3827,//3700,
- .x_max = 3900,//3700,
- .y_max = 150,//330,
- .xy_fuzz = 40,
- .pressure_max = 0xFFF0,
- .pressure_min = 0xF100,
- .settle_delay_usecs = 200,
- .debounce_rep = 4,
- .debounce_tol = 40,
- .debounce_max = 10,
- };
- static struct spi_board_info ek_spi_devices[] = {
- {
- .modalias = "ads7846",
- .max_speed_hz = 125000 * 26,
- .chip_select = CONFIG_BOARD_ICNOVA_ADS7846_CS,
- .platform_data = &ads_info,
- .bus_num = 0,
- .controller_data = (void *) AT91_PIN_PD24,
- },
- {
- .modalias = "supervisor",
- .max_speed_hz = 550000,
- .chip_select = 0,
- .platform_data = NULL,
- .bus_num = 0,
- },
- };
- /*
- * MACB Ethernet device
- */
- static struct at91_eth_data __initdata ek_macb_data = {
- .phy_irq_pin = AT91_PIN_PA27,
- };
- /*
- * NAND flash
- */
- static struct mtd_partition __initdata ek_nand_partition[] = {
- {
- .name = "Kernel",
- .offset = 0,
- .size = SZ_4M,
- },
- {
- .name = "Data",
- .offset = MTDPART_OFS_NXTBLK,
- .size = MTDPART_SIZ_FULL,
- },
- };
- static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
- {
- *num_partitions = ARRAY_SIZE(ek_nand_partition);
- return ek_nand_partition;
- }
- /* det_pin is not connected */
- static struct atmel_nand_data __initdata ek_nand_data = {
- .ale = 21,
- .cle = 22,
- .rdy_pin = AT91_PIN_PC8,
- .enable_pin = AT91_PIN_PC14,
- .partition_info = nand_partitions,
- .bus_width_16 = 0,
- };
- static struct sam9_smc_config __initdata ek_nand_smc_config = {
- .ncs_read_setup = 0,
- .nrd_setup = 10,
- .ncs_write_setup = 0,
- .nwe_setup = 10,
- .ncs_read_pulse = 50,
- .nrd_pulse = 30,
- .ncs_write_pulse = 50,
- .nwe_pulse = 30,
- .read_cycle = 60,
- .write_cycle = 60,
- .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
- .tdf_cycles = 4,
- };
- static void __init ek_add_device_nand(void)
- {
- /* configure chip-select 3 (NAND) */
- sam9_smc_configure(3, &ek_nand_smc_config);
- at91_add_device_nand(&ek_nand_data);
- }
- /*
- * MCI (SD/MMC)
- */
- static struct mci_platform_data __initdata ek_mmc_data = {
- .slot[0] = {
- .bus_width = 4,
- .detect_pin = AT91_PIN_PC6,
- .wp_pin = -1,
- },
- };
- static struct mci_platform_data __initdata ek_mmc_data1 = {
- .slot[0] = {
- .bus_width = 4,
- .detect_pin = AT91_PIN_PC7,
- .wp_pin = -1,
- },
- };
- /*
- * LCD Controller
- */
- #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
- static struct fb_videomode at91_tft_vga_modes[] = {
- {
- .name = "VGA",
- .refresh = 50,
- .xres = 800, .yres = 480,
- .pixclock = 25000,
- .left_margin = 178, .right_margin = 38,
- .upper_margin = 35, .lower_margin = 8,
- .hsync_len = 40, .vsync_len = 2,
- .vmode = FB_VMODE_NONINTERLACED,
- }
- };
- static struct fb_monspecs at91fb_default_monspecs = {
- .manufacturer = "Hita",
- .monitor = "TX20D26VM0APA",
- .modedb = at91_tft_vga_modes,
- .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
- .hfmin = 16700,
- .hfmax = 41700,
- .vfmin = 47,
- .vfmax = 75,
- };
- #define AT91SAM9G45_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
- | ATMEL_LCDC_DISTYPE_TFT \
- | ATMEL_LCDC_INVCLK \
- | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
- //| ATMEL_LCDC_INVDVAL
- /* Driver datas */
- static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
- .lcdcon_is_backlight = true,
- .default_bpp = /*24*/16,
- .default_dmacon = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
- .default_lcdcon2 = AT91SAM9G45_DEFAULT_LCDCON2,
- .default_monspecs = &at91fb_default_monspecs,
- .guard_time = 9,
- .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
- };
- #else
- static struct atmel_lcdfb_info __initdata ek_lcdc_data;
- #endif
- #if 0
- static struct platform_device icnova_pwmdev = {
- .name = "atmel-pwm-hwmon",
- .id = 0,
- };
- #endif
- /*
- * Btns
- */
- static struct gpio_keys_button buttons[] = {
- #ifdef CONFIG_SUPERVISOR_IRQ
- {
- .code = KEY_BACK,
- .gpio = 240,
- .active_low = 1,
- .desc = "back",
- .wakeup = 1,
- },
- {
- .code = KEY_HOME,
- .gpio = 241,
- .active_low = 1,
- .desc = "home",
- .wakeup = 1,
- },
- {
- .code = KEY_MENU,
- .gpio = 242,
- .active_low = 1,
- .desc = "menu",
- .wakeup = 1,
- },
- #endif
- };
- static struct gpio_keys_platform_data button_data = {
- .buttons = buttons,
- .nbuttons = ARRAY_SIZE(buttons),
- };
- static struct platform_device button_device = {
- .name = "gpio-keys",
- .id = -1,
- .num_resources = 0,
- .dev = {
- .platform_data = &button_data,
- },
- };
- #if 1
- static struct platform_device at91_adc_device = {
- .name = "at91_adc_test",
- .id = -1,
- .num_resources = 0,
- };
- void __init at91_add_device_adc()
- {
- at91_set_gpio_input(AT91_PIN_PD24, 0); /* ADC channel 5 *//* 1-4 used for Touch*/
- platform_device_register(&at91_adc_device);
- // printk("ANKUR: Under at91_add_device_adc \n");
- }
- #endif
- static void __init ek_board_init(void)
- {
- /* Serial */
- at91_add_device_serial();
- /* USB HS Host */
- gpio_request(AT91_PIN_PB8, "usbhub.reset");
- gpio_direction_output(AT91_PIN_PB8, 1);
- at91_add_device_usbh_ehci(&ek_usbh_hs_data);
- at91_add_device_usbh_ohci(&ek_usbh_hs_data);
- /* USB HS Device */
- at91_add_device_usba(NULL);
- /* Ethernet */
- at91_add_device_eth(&ek_macb_data);
- /* NAND */
- ek_add_device_nand();
- /* I2C */
- at91_set_gpio_input(AT91_PIN_PD4, 0);
- at91_add_device_i2c(0, icnova_i2c, ARRAY_SIZE(icnova_i2c));
- at91_add_device_i2c(1, icnova_i2c2, ARRAY_SIZE(icnova_i2c2));
- /* LCD Controller */
- gpio_request(AT91_PIN_PE1, "lcdc.mode");
- gpio_direction_output(AT91_PIN_PE1, 1);
- gpio_request(AT91_PIN_PE0, "lcdc.pwr");
- gpio_direction_output(AT91_PIN_PE0, 1);
- at91_add_device_lcdc(&ek_lcdc_data);
- /* BTN */
- platform_device_register(&button_device);
- /* W1 */
- at91_set_GPIO_periph(sn_w1_gpio_pdata.pin, 1);
- at91_set_multi_drive(sn_w1_gpio_pdata.pin, 1);
- platform_device_register(&sn_w1_device);
- /* PWM */
- at91_add_device_pwm(4);
- setup_atmel_pwm_bl();
- /* RTC INTERRUPT */
- at91_set_gpio_input(AT91_PIN_PA26, 0);
- at91_set_deglitch(AT91_PIN_PA26, 1);
- /* Temperature Sensor INTERRUPT */
- at91_set_gpio_input(AT91_PIN_PD27, 0);
- at91_set_deglitch(AT91_PIN_PD27, 1);
- // printk("ABOVE ADCDEVICE \n");
- /*ADC Controller */
- at91_add_device_adc();
- }
- MACHINE_START(AT91SAM9G45EKES, "In-Circuit ICnova SAM9G45 SO-DIMM")
- /* Maintainer: Atmel */
- .phys_io = AT91_BASE_SYS,
- .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
- .boot_params = AT91_SDRAM_BASE + 0x100,
- .timer = &at91sam926x_timer,
- .map_io = ek_map_io,
- .init_irq = ek_init_irq,
- .init_machine = ek_board_init,
- MACHINE_END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement