Path: blob/master/arch/arm/mach-davinci/board-da850-evm.c
10699 views
/*1* TI DA850/OMAP-L138 EVM board2*3* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/4*5* Derived from: arch/arm/mach-davinci/board-da830-evm.c6* Original Copyrights follow:7*8* 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under9* the terms of the GNU General Public License version 2. This program10* is licensed "as is" without any warranty of any kind, whether express11* or implied.12*/13#include <linux/kernel.h>14#include <linux/init.h>15#include <linux/console.h>16#include <linux/i2c.h>17#include <linux/i2c/at24.h>18#include <linux/i2c/pca953x.h>19#include <linux/input.h>20#include <linux/mfd/tps6507x.h>21#include <linux/gpio.h>22#include <linux/gpio_keys.h>23#include <linux/platform_device.h>24#include <linux/mtd/mtd.h>25#include <linux/mtd/nand.h>26#include <linux/mtd/partitions.h>27#include <linux/mtd/physmap.h>28#include <linux/regulator/machine.h>29#include <linux/regulator/tps6507x.h>30#include <linux/input/tps6507x-ts.h>31#include <linux/spi/spi.h>32#include <linux/spi/flash.h>3334#include <asm/mach-types.h>35#include <asm/mach/arch.h>3637#include <mach/cp_intc.h>38#include <mach/da8xx.h>39#include <mach/nand.h>40#include <mach/mux.h>41#include <mach/aemif.h>42#include <mach/spi.h>4344#define DA850_EVM_PHY_ID "0:00"45#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)46#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)4748#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)49#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)5051#define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)5253static struct mtd_partition da850evm_spiflash_part[] = {54[0] = {55.name = "UBL",56.offset = 0,57.size = SZ_64K,58.mask_flags = MTD_WRITEABLE,59},60[1] = {61.name = "U-Boot",62.offset = MTDPART_OFS_APPEND,63.size = SZ_512K,64.mask_flags = MTD_WRITEABLE,65},66[2] = {67.name = "U-Boot-Env",68.offset = MTDPART_OFS_APPEND,69.size = SZ_64K,70.mask_flags = MTD_WRITEABLE,71},72[3] = {73.name = "Kernel",74.offset = MTDPART_OFS_APPEND,75.size = SZ_2M + SZ_512K,76.mask_flags = 0,77},78[4] = {79.name = "Filesystem",80.offset = MTDPART_OFS_APPEND,81.size = SZ_4M,82.mask_flags = 0,83},84[5] = {85.name = "MAC-Address",86.offset = SZ_8M - SZ_64K,87.size = SZ_64K,88.mask_flags = MTD_WRITEABLE,89},90};9192static struct flash_platform_data da850evm_spiflash_data = {93.name = "m25p80",94.parts = da850evm_spiflash_part,95.nr_parts = ARRAY_SIZE(da850evm_spiflash_part),96.type = "m25p64",97};9899static struct davinci_spi_config da850evm_spiflash_cfg = {100.io_type = SPI_IO_TYPE_DMA,101.c2tdelay = 8,102.t2cdelay = 8,103};104105static struct spi_board_info da850evm_spi_info[] = {106{107.modalias = "m25p80",108.platform_data = &da850evm_spiflash_data,109.controller_data = &da850evm_spiflash_cfg,110.mode = SPI_MODE_0,111.max_speed_hz = 30000000,112.bus_num = 1,113.chip_select = 0,114},115};116117static struct mtd_partition da850_evm_norflash_partition[] = {118{119.name = "bootloaders + env",120.offset = 0,121.size = SZ_512K,122.mask_flags = MTD_WRITEABLE,123},124{125.name = "kernel",126.offset = MTDPART_OFS_APPEND,127.size = SZ_2M,128.mask_flags = 0,129},130{131.name = "filesystem",132.offset = MTDPART_OFS_APPEND,133.size = MTDPART_SIZ_FULL,134.mask_flags = 0,135},136};137138static struct physmap_flash_data da850_evm_norflash_data = {139.width = 2,140.parts = da850_evm_norflash_partition,141.nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),142};143144static struct resource da850_evm_norflash_resource[] = {145{146.start = DA8XX_AEMIF_CS2_BASE,147.end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,148.flags = IORESOURCE_MEM,149},150};151152static struct platform_device da850_evm_norflash_device = {153.name = "physmap-flash",154.id = 0,155.dev = {156.platform_data = &da850_evm_norflash_data,157},158.num_resources = 1,159.resource = da850_evm_norflash_resource,160};161162static struct davinci_pm_config da850_pm_pdata = {163.sleepcount = 128,164};165166static struct platform_device da850_pm_device = {167.name = "pm-davinci",168.dev = {169.platform_data = &da850_pm_pdata,170},171.id = -1,172};173174/* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash175* (128K blocks). It may be used instead of the (default) SPI flash176* to boot, using TI's tools to install the secondary boot loader177* (UBL) and U-Boot.178*/179static struct mtd_partition da850_evm_nandflash_partition[] = {180{181.name = "u-boot env",182.offset = 0,183.size = SZ_128K,184.mask_flags = MTD_WRITEABLE,185},186{187.name = "UBL",188.offset = MTDPART_OFS_APPEND,189.size = SZ_128K,190.mask_flags = MTD_WRITEABLE,191},192{193.name = "u-boot",194.offset = MTDPART_OFS_APPEND,195.size = 4 * SZ_128K,196.mask_flags = MTD_WRITEABLE,197},198{199.name = "kernel",200.offset = 0x200000,201.size = SZ_2M,202.mask_flags = 0,203},204{205.name = "filesystem",206.offset = MTDPART_OFS_APPEND,207.size = MTDPART_SIZ_FULL,208.mask_flags = 0,209},210};211212static struct davinci_aemif_timing da850_evm_nandflash_timing = {213.wsetup = 24,214.wstrobe = 21,215.whold = 14,216.rsetup = 19,217.rstrobe = 50,218.rhold = 0,219.ta = 20,220};221222static struct davinci_nand_pdata da850_evm_nandflash_data = {223.parts = da850_evm_nandflash_partition,224.nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),225.ecc_mode = NAND_ECC_HW,226.ecc_bits = 4,227.options = NAND_USE_FLASH_BBT,228.timing = &da850_evm_nandflash_timing,229};230231static struct resource da850_evm_nandflash_resource[] = {232{233.start = DA8XX_AEMIF_CS3_BASE,234.end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,235.flags = IORESOURCE_MEM,236},237{238.start = DA8XX_AEMIF_CTL_BASE,239.end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,240.flags = IORESOURCE_MEM,241},242};243244static struct platform_device da850_evm_nandflash_device = {245.name = "davinci_nand",246.id = 1,247.dev = {248.platform_data = &da850_evm_nandflash_data,249},250.num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),251.resource = da850_evm_nandflash_resource,252};253254static struct platform_device *da850_evm_devices[] __initdata = {255&da850_evm_nandflash_device,256&da850_evm_norflash_device,257};258259#define DA8XX_AEMIF_CE2CFG_OFFSET 0x10260#define DA8XX_AEMIF_ASIZE_16BIT 0x1261262static void __init da850_evm_init_nor(void)263{264void __iomem *aemif_addr;265266aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);267268/* Configure data bus width of CS2 to 16 bit */269writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |270DA8XX_AEMIF_ASIZE_16BIT,271aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);272273iounmap(aemif_addr);274}275276static const short da850_evm_nand_pins[] = {277DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,278DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,279DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,280DA850_NEMA_WE, DA850_NEMA_OE,281-1282};283284static const short da850_evm_nor_pins[] = {285DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,286DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,287DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,288DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,289DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,290DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,291DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,292DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,293DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,294DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,295DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,296DA850_EMA_A_22, DA850_EMA_A_23,297-1298};299300#if defined(CONFIG_MMC_DAVINCI) || \301defined(CONFIG_MMC_DAVINCI_MODULE)302#define HAS_MMC 1303#else304#define HAS_MMC 0305#endif306307static inline void da850_evm_setup_nor_nand(void)308{309int ret = 0;310311if (!HAS_MMC) {312ret = davinci_cfg_reg_list(da850_evm_nand_pins);313if (ret)314pr_warning("da850_evm_init: nand mux setup failed: "315"%d\n", ret);316317ret = davinci_cfg_reg_list(da850_evm_nor_pins);318if (ret)319pr_warning("da850_evm_init: nor mux setup failed: %d\n",320ret);321322da850_evm_init_nor();323324platform_add_devices(da850_evm_devices,325ARRAY_SIZE(da850_evm_devices));326}327}328329#ifdef CONFIG_DA850_UI_RMII330static inline void da850_evm_setup_emac_rmii(int rmii_sel)331{332struct davinci_soc_info *soc_info = &davinci_soc_info;333334soc_info->emac_pdata->rmii_en = 1;335gpio_set_value_cansleep(rmii_sel, 0);336}337#else338static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }339#endif340341342#define DA850_KEYS_DEBOUNCE_MS 10343/*344* At 200ms polling interval it is possible to miss an345* event by tapping very lightly on the push button but most346* pushes do result in an event; longer intervals require the347* user to hold the button whereas shorter intervals require348* more CPU time for polling.349*/350#define DA850_GPIO_KEYS_POLL_MS 200351352enum da850_evm_ui_exp_pins {353DA850_EVM_UI_EXP_SEL_C = 5,354DA850_EVM_UI_EXP_SEL_B,355DA850_EVM_UI_EXP_SEL_A,356DA850_EVM_UI_EXP_PB8,357DA850_EVM_UI_EXP_PB7,358DA850_EVM_UI_EXP_PB6,359DA850_EVM_UI_EXP_PB5,360DA850_EVM_UI_EXP_PB4,361DA850_EVM_UI_EXP_PB3,362DA850_EVM_UI_EXP_PB2,363DA850_EVM_UI_EXP_PB1,364};365366static const char const *da850_evm_ui_exp[] = {367[DA850_EVM_UI_EXP_SEL_C] = "sel_c",368[DA850_EVM_UI_EXP_SEL_B] = "sel_b",369[DA850_EVM_UI_EXP_SEL_A] = "sel_a",370[DA850_EVM_UI_EXP_PB8] = "pb8",371[DA850_EVM_UI_EXP_PB7] = "pb7",372[DA850_EVM_UI_EXP_PB6] = "pb6",373[DA850_EVM_UI_EXP_PB5] = "pb5",374[DA850_EVM_UI_EXP_PB4] = "pb4",375[DA850_EVM_UI_EXP_PB3] = "pb3",376[DA850_EVM_UI_EXP_PB2] = "pb2",377[DA850_EVM_UI_EXP_PB1] = "pb1",378};379380#define DA850_N_UI_PB 8381382static struct gpio_keys_button da850_evm_ui_keys[] = {383[0 ... DA850_N_UI_PB - 1] = {384.type = EV_KEY,385.active_low = 1,386.wakeup = 0,387.debounce_interval = DA850_KEYS_DEBOUNCE_MS,388.code = -1, /* assigned at runtime */389.gpio = -1, /* assigned at runtime */390.desc = NULL, /* assigned at runtime */391},392};393394static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {395.buttons = da850_evm_ui_keys,396.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),397.poll_interval = DA850_GPIO_KEYS_POLL_MS,398};399400static struct platform_device da850_evm_ui_keys_device = {401.name = "gpio-keys-polled",402.id = 0,403.dev = {404.platform_data = &da850_evm_ui_keys_pdata405},406};407408static void da850_evm_ui_keys_init(unsigned gpio)409{410int i;411struct gpio_keys_button *button;412413for (i = 0; i < DA850_N_UI_PB; i++) {414button = &da850_evm_ui_keys[i];415button->code = KEY_F8 - i;416button->desc = (char *)417da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];418button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;419}420}421422static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,423unsigned ngpio, void *c)424{425int sel_a, sel_b, sel_c, ret;426427sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;428sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;429sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;430431ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);432if (ret) {433pr_warning("Cannot open UI expander pin %d\n", sel_a);434goto exp_setup_sela_fail;435}436437ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);438if (ret) {439pr_warning("Cannot open UI expander pin %d\n", sel_b);440goto exp_setup_selb_fail;441}442443ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);444if (ret) {445pr_warning("Cannot open UI expander pin %d\n", sel_c);446goto exp_setup_selc_fail;447}448449/* deselect all functionalities */450gpio_direction_output(sel_a, 1);451gpio_direction_output(sel_b, 1);452gpio_direction_output(sel_c, 1);453454da850_evm_ui_keys_init(gpio);455ret = platform_device_register(&da850_evm_ui_keys_device);456if (ret) {457pr_warning("Could not register UI GPIO expander push-buttons");458goto exp_setup_keys_fail;459}460461pr_info("DA850/OMAP-L138 EVM UI card detected\n");462463da850_evm_setup_nor_nand();464465da850_evm_setup_emac_rmii(sel_a);466467return 0;468469exp_setup_keys_fail:470gpio_free(sel_c);471exp_setup_selc_fail:472gpio_free(sel_b);473exp_setup_selb_fail:474gpio_free(sel_a);475exp_setup_sela_fail:476return ret;477}478479static int da850_evm_ui_expander_teardown(struct i2c_client *client,480unsigned gpio, unsigned ngpio, void *c)481{482platform_device_unregister(&da850_evm_ui_keys_device);483484/* deselect all functionalities */485gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);486gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);487gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);488489gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);490gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);491gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);492493return 0;494}495496/* assign the baseboard expander's GPIOs after the UI board's */497#define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)498#define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)499500enum da850_evm_bb_exp_pins {501DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,502DA850_EVM_BB_EXP_SW_RST,503DA850_EVM_BB_EXP_TP_23,504DA850_EVM_BB_EXP_TP_22,505DA850_EVM_BB_EXP_TP_21,506DA850_EVM_BB_EXP_USER_PB1,507DA850_EVM_BB_EXP_USER_LED2,508DA850_EVM_BB_EXP_USER_LED1,509DA850_EVM_BB_EXP_USER_SW1,510DA850_EVM_BB_EXP_USER_SW2,511DA850_EVM_BB_EXP_USER_SW3,512DA850_EVM_BB_EXP_USER_SW4,513DA850_EVM_BB_EXP_USER_SW5,514DA850_EVM_BB_EXP_USER_SW6,515DA850_EVM_BB_EXP_USER_SW7,516DA850_EVM_BB_EXP_USER_SW8517};518519static const char const *da850_evm_bb_exp[] = {520[DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",521[DA850_EVM_BB_EXP_SW_RST] = "sw_rst",522[DA850_EVM_BB_EXP_TP_23] = "tp_23",523[DA850_EVM_BB_EXP_TP_22] = "tp_22",524[DA850_EVM_BB_EXP_TP_21] = "tp_21",525[DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",526[DA850_EVM_BB_EXP_USER_LED2] = "user_led2",527[DA850_EVM_BB_EXP_USER_LED1] = "user_led1",528[DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",529[DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",530[DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",531[DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",532[DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",533[DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",534[DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",535[DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",536};537538#define DA850_N_BB_USER_SW 8539540static struct gpio_keys_button da850_evm_bb_keys[] = {541[0] = {542.type = EV_KEY,543.active_low = 1,544.wakeup = 0,545.debounce_interval = DA850_KEYS_DEBOUNCE_MS,546.code = KEY_PROG1,547.desc = NULL, /* assigned at runtime */548.gpio = -1, /* assigned at runtime */549},550[1 ... DA850_N_BB_USER_SW] = {551.type = EV_SW,552.active_low = 1,553.wakeup = 0,554.debounce_interval = DA850_KEYS_DEBOUNCE_MS,555.code = -1, /* assigned at runtime */556.desc = NULL, /* assigned at runtime */557.gpio = -1, /* assigned at runtime */558},559};560561static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {562.buttons = da850_evm_bb_keys,563.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),564.poll_interval = DA850_GPIO_KEYS_POLL_MS,565};566567static struct platform_device da850_evm_bb_keys_device = {568.name = "gpio-keys-polled",569.id = 1,570.dev = {571.platform_data = &da850_evm_bb_keys_pdata572},573};574575static void da850_evm_bb_keys_init(unsigned gpio)576{577int i;578struct gpio_keys_button *button;579580button = &da850_evm_bb_keys[0];581button->desc = (char *)582da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];583button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;584585for (i = 0; i < DA850_N_BB_USER_SW; i++) {586button = &da850_evm_bb_keys[i + 1];587button->code = SW_LID + i;588button->desc = (char *)589da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];590button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;591}592}593594#define DA850_N_BB_USER_LED 2595596static struct gpio_led da850_evm_bb_leds[] = {597[0 ... DA850_N_BB_USER_LED - 1] = {598.active_low = 1,599.gpio = -1, /* assigned at runtime */600.name = NULL, /* assigned at runtime */601},602};603604static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {605.leds = da850_evm_bb_leds,606.num_leds = ARRAY_SIZE(da850_evm_bb_leds),607};608609static struct platform_device da850_evm_bb_leds_device = {610.name = "leds-gpio",611.id = -1,612.dev = {613.platform_data = &da850_evm_bb_leds_pdata614}615};616617static void da850_evm_bb_leds_init(unsigned gpio)618{619int i;620struct gpio_led *led;621622for (i = 0; i < DA850_N_BB_USER_LED; i++) {623led = &da850_evm_bb_leds[i];624625led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;626led->name =627da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];628}629}630631static int da850_evm_bb_expander_setup(struct i2c_client *client,632unsigned gpio, unsigned ngpio,633void *c)634{635int ret;636637/*638* Register the switches and pushbutton on the baseboard as a gpio-keys639* device.640*/641da850_evm_bb_keys_init(gpio);642ret = platform_device_register(&da850_evm_bb_keys_device);643if (ret) {644pr_warning("Could not register baseboard GPIO expander keys");645goto io_exp_setup_sw_fail;646}647648da850_evm_bb_leds_init(gpio);649ret = platform_device_register(&da850_evm_bb_leds_device);650if (ret) {651pr_warning("Could not register baseboard GPIO expander LEDS");652goto io_exp_setup_leds_fail;653}654655return 0;656657io_exp_setup_leds_fail:658platform_device_unregister(&da850_evm_bb_keys_device);659io_exp_setup_sw_fail:660return ret;661}662663static int da850_evm_bb_expander_teardown(struct i2c_client *client,664unsigned gpio, unsigned ngpio, void *c)665{666platform_device_unregister(&da850_evm_bb_leds_device);667platform_device_unregister(&da850_evm_bb_keys_device);668669return 0;670}671672static struct pca953x_platform_data da850_evm_ui_expander_info = {673.gpio_base = DAVINCI_N_GPIO,674.setup = da850_evm_ui_expander_setup,675.teardown = da850_evm_ui_expander_teardown,676.names = da850_evm_ui_exp,677};678679static struct pca953x_platform_data da850_evm_bb_expander_info = {680.gpio_base = DA850_BB_EXPANDER_GPIO_BASE,681.setup = da850_evm_bb_expander_setup,682.teardown = da850_evm_bb_expander_teardown,683.names = da850_evm_bb_exp,684};685686static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {687{688I2C_BOARD_INFO("tlv320aic3x", 0x18),689},690{691I2C_BOARD_INFO("tca6416", 0x20),692.platform_data = &da850_evm_ui_expander_info,693},694{695I2C_BOARD_INFO("tca6416", 0x21),696.platform_data = &da850_evm_bb_expander_info,697},698};699700static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {701.bus_freq = 100, /* kHz */702.bus_delay = 0, /* usec */703};704705static struct davinci_uart_config da850_evm_uart_config __initdata = {706.enabled_uarts = 0x7,707};708709/* davinci da850 evm audio machine driver */710static u8 da850_iis_serializer_direction[] = {711INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,712INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,713INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,714RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,715};716717static struct snd_platform_data da850_evm_snd_data = {718.tx_dma_offset = 0x2000,719.rx_dma_offset = 0x2000,720.op_mode = DAVINCI_MCASP_IIS_MODE,721.num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),722.tdm_slots = 2,723.serial_dir = da850_iis_serializer_direction,724.asp_chan_q = EVENTQ_1,725.version = MCASP_VERSION_2,726.txnumevt = 1,727.rxnumevt = 1,728};729730static const short da850_evm_mcasp_pins[] __initconst = {731DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,732DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,733DA850_AXR_11, DA850_AXR_12,734-1735};736737static int da850_evm_mmc_get_ro(int index)738{739return gpio_get_value(DA850_MMCSD_WP_PIN);740}741742static int da850_evm_mmc_get_cd(int index)743{744return !gpio_get_value(DA850_MMCSD_CD_PIN);745}746747static struct davinci_mmc_config da850_mmc_config = {748.get_ro = da850_evm_mmc_get_ro,749.get_cd = da850_evm_mmc_get_cd,750.wires = 4,751.max_freq = 50000000,752.caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,753.version = MMC_CTLR_VERSION_2,754};755756static const short da850_evm_mmcsd0_pins[] __initconst = {757DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,758DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,759DA850_GPIO4_0, DA850_GPIO4_1,760-1761};762763static void da850_panel_power_ctrl(int val)764{765/* lcd backlight */766gpio_set_value(DA850_LCD_BL_PIN, val);767768/* lcd power */769gpio_set_value(DA850_LCD_PWR_PIN, val);770}771772static int da850_lcd_hw_init(void)773{774int status;775776status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");777if (status < 0)778return status;779780status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");781if (status < 0) {782gpio_free(DA850_LCD_BL_PIN);783return status;784}785786gpio_direction_output(DA850_LCD_BL_PIN, 0);787gpio_direction_output(DA850_LCD_PWR_PIN, 0);788789/* Switch off panel power and backlight */790da850_panel_power_ctrl(0);791792/* Switch on panel power and backlight */793da850_panel_power_ctrl(1);794795return 0;796}797798/* TPS65070 voltage regulator support */799800/* 3.3V */801static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {802{803.supply = "usb0_vdda33",804},805{806.supply = "usb1_vdda33",807},808};809810/* 3.3V or 1.8V */811static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {812{813.supply = "dvdd3318_a",814},815{816.supply = "dvdd3318_b",817},818{819.supply = "dvdd3318_c",820},821};822823/* 1.2V */824static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {825{826.supply = "cvdd",827},828};829830/* 1.8V LDO */831static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {832{833.supply = "sata_vddr",834},835{836.supply = "usb0_vdda18",837},838{839.supply = "usb1_vdda18",840},841{842.supply = "ddr_dvdd18",843},844};845846/* 1.2V LDO */847static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {848{849.supply = "sata_vdd",850},851{852.supply = "pll0_vdda",853},854{855.supply = "pll1_vdda",856},857{858.supply = "usbs_cvdd",859},860{861.supply = "vddarnwa1",862},863};864865/* We take advantage of the fact that both defdcdc{2,3} are tied high */866static struct tps6507x_reg_platform_data tps6507x_platform_data = {867.defdcdc_default = true,868};869870static struct regulator_init_data tps65070_regulator_data[] = {871/* dcdc1 */872{873.constraints = {874.min_uV = 3150000,875.max_uV = 3450000,876.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |877REGULATOR_CHANGE_STATUS),878.boot_on = 1,879},880.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),881.consumer_supplies = tps65070_dcdc1_consumers,882},883884/* dcdc2 */885{886.constraints = {887.min_uV = 1710000,888.max_uV = 3450000,889.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |890REGULATOR_CHANGE_STATUS),891.boot_on = 1,892},893.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),894.consumer_supplies = tps65070_dcdc2_consumers,895.driver_data = &tps6507x_platform_data,896},897898/* dcdc3 */899{900.constraints = {901.min_uV = 950000,902.max_uV = 1350000,903.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |904REGULATOR_CHANGE_STATUS),905.boot_on = 1,906},907.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),908.consumer_supplies = tps65070_dcdc3_consumers,909.driver_data = &tps6507x_platform_data,910},911912/* ldo1 */913{914.constraints = {915.min_uV = 1710000,916.max_uV = 1890000,917.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |918REGULATOR_CHANGE_STATUS),919.boot_on = 1,920},921.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),922.consumer_supplies = tps65070_ldo1_consumers,923},924925/* ldo2 */926{927.constraints = {928.min_uV = 1140000,929.max_uV = 1320000,930.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |931REGULATOR_CHANGE_STATUS),932.boot_on = 1,933},934.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),935.consumer_supplies = tps65070_ldo2_consumers,936},937};938939static struct touchscreen_init_data tps6507x_touchscreen_data = {940.poll_period = 30, /* ms between touch samples */941.min_pressure = 0x30, /* minimum pressure to trigger touch */942.vref = 0, /* turn off vref when not using A/D */943.vendor = 0, /* /sys/class/input/input?/id/vendor */944.product = 65070, /* /sys/class/input/input?/id/product */945.version = 0x100, /* /sys/class/input/input?/id/version */946};947948static struct tps6507x_board tps_board = {949.tps6507x_pmic_init_data = &tps65070_regulator_data[0],950.tps6507x_ts_init_data = &tps6507x_touchscreen_data,951};952953static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {954{955I2C_BOARD_INFO("tps6507x", 0x48),956.platform_data = &tps_board,957},958};959960static int __init pmic_tps65070_init(void)961{962return i2c_register_board_info(1, da850_evm_tps65070_info,963ARRAY_SIZE(da850_evm_tps65070_info));964}965966static const short da850_evm_lcdc_pins[] = {967DA850_GPIO2_8, DA850_GPIO2_15,968-1969};970971static const short da850_evm_mii_pins[] = {972DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,973DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,974DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,975DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,976DA850_MDIO_D,977-1978};979980static const short da850_evm_rmii_pins[] = {981DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,982DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,983DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,984DA850_MDIO_D,985-1986};987988static int __init da850_evm_config_emac(void)989{990void __iomem *cfg_chip3_base;991int ret;992u32 val;993struct davinci_soc_info *soc_info = &davinci_soc_info;994u8 rmii_en = soc_info->emac_pdata->rmii_en;995996if (!machine_is_davinci_da850_evm())997return 0;998999cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);10001001val = __raw_readl(cfg_chip3_base);10021003if (rmii_en) {1004val |= BIT(8);1005ret = davinci_cfg_reg_list(da850_evm_rmii_pins);1006pr_info("EMAC: RMII PHY configured, MII PHY will not be"1007" functional\n");1008} else {1009val &= ~BIT(8);1010ret = davinci_cfg_reg_list(da850_evm_mii_pins);1011pr_info("EMAC: MII PHY configured, RMII PHY will not be"1012" functional\n");1013}10141015if (ret)1016pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",1017ret);10181019/* configure the CFGCHIP3 register for RMII or MII */1020__raw_writel(val, cfg_chip3_base);10211022ret = davinci_cfg_reg(DA850_GPIO2_6);1023if (ret)1024pr_warning("da850_evm_init:GPIO(2,6) mux setup "1025"failed\n");10261027ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");1028if (ret) {1029pr_warning("Cannot open GPIO %d\n",1030DA850_MII_MDIO_CLKEN_PIN);1031return ret;1032}10331034/* Enable/Disable MII MDIO clock */1035gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);10361037soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;10381039ret = da8xx_register_emac();1040if (ret)1041pr_warning("da850_evm_init: emac registration failed: %d\n",1042ret);10431044return 0;1045}1046device_initcall(da850_evm_config_emac);10471048/*1049* The following EDMA channels/slots are not being used by drivers (for1050* example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence1051* they are being reserved for codecs on the DSP side.1052*/1053static const s16 da850_dma0_rsv_chans[][2] = {1054/* (offset, number) */1055{ 8, 6},1056{24, 4},1057{30, 2},1058{-1, -1}1059};10601061static const s16 da850_dma0_rsv_slots[][2] = {1062/* (offset, number) */1063{ 8, 6},1064{24, 4},1065{30, 50},1066{-1, -1}1067};10681069static const s16 da850_dma1_rsv_chans[][2] = {1070/* (offset, number) */1071{ 0, 28},1072{30, 2},1073{-1, -1}1074};10751076static const s16 da850_dma1_rsv_slots[][2] = {1077/* (offset, number) */1078{ 0, 28},1079{30, 90},1080{-1, -1}1081};10821083static struct edma_rsv_info da850_edma_cc0_rsv = {1084.rsv_chans = da850_dma0_rsv_chans,1085.rsv_slots = da850_dma0_rsv_slots,1086};10871088static struct edma_rsv_info da850_edma_cc1_rsv = {1089.rsv_chans = da850_dma1_rsv_chans,1090.rsv_slots = da850_dma1_rsv_slots,1091};10921093static struct edma_rsv_info *da850_edma_rsv[2] = {1094&da850_edma_cc0_rsv,1095&da850_edma_cc1_rsv,1096};10971098#ifdef CONFIG_CPU_FREQ1099static __init int da850_evm_init_cpufreq(void)1100{1101switch (system_rev & 0xF) {1102case 3:1103da850_max_speed = 456000;1104break;1105case 2:1106da850_max_speed = 408000;1107break;1108case 1:1109da850_max_speed = 372000;1110break;1111}11121113return da850_register_cpufreq("pll0_sysclk3");1114}1115#else1116static __init int da850_evm_init_cpufreq(void) { return 0; }1117#endif11181119static __init void da850_evm_init(void)1120{1121int ret;11221123ret = pmic_tps65070_init();1124if (ret)1125pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",1126ret);11271128ret = da850_register_edma(da850_edma_rsv);1129if (ret)1130pr_warning("da850_evm_init: edma registration failed: %d\n",1131ret);11321133ret = davinci_cfg_reg_list(da850_i2c0_pins);1134if (ret)1135pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",1136ret);11371138ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);1139if (ret)1140pr_warning("da850_evm_init: i2c0 registration failed: %d\n",1141ret);114211431144ret = da8xx_register_watchdog();1145if (ret)1146pr_warning("da830_evm_init: watchdog registration failed: %d\n",1147ret);11481149if (HAS_MMC) {1150ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);1151if (ret)1152pr_warning("da850_evm_init: mmcsd0 mux setup failed:"1153" %d\n", ret);11541155ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");1156if (ret)1157pr_warning("da850_evm_init: can not open GPIO %d\n",1158DA850_MMCSD_CD_PIN);1159gpio_direction_input(DA850_MMCSD_CD_PIN);11601161ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");1162if (ret)1163pr_warning("da850_evm_init: can not open GPIO %d\n",1164DA850_MMCSD_WP_PIN);1165gpio_direction_input(DA850_MMCSD_WP_PIN);11661167ret = da8xx_register_mmcsd0(&da850_mmc_config);1168if (ret)1169pr_warning("da850_evm_init: mmcsd0 registration failed:"1170" %d\n", ret);1171}11721173davinci_serial_init(&da850_evm_uart_config);11741175i2c_register_board_info(1, da850_evm_i2c_devices,1176ARRAY_SIZE(da850_evm_i2c_devices));11771178/*1179* shut down uart 0 and 1; they are not used on the board and1180* accessing them causes endless "too much work in irq53" messages1181* with arago fs1182*/1183__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);1184__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);11851186ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);1187if (ret)1188pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",1189ret);11901191da8xx_register_mcasp(0, &da850_evm_snd_data);11921193ret = davinci_cfg_reg_list(da850_lcdcntl_pins);1194if (ret)1195pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",1196ret);11971198/* Handle board specific muxing for LCD here */1199ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);1200if (ret)1201pr_warning("da850_evm_init: evm specific lcd mux setup "1202"failed: %d\n", ret);12031204ret = da850_lcd_hw_init();1205if (ret)1206pr_warning("da850_evm_init: lcd initialization failed: %d\n",1207ret);12081209sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,1210ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);1211if (ret)1212pr_warning("da850_evm_init: lcdc registration failed: %d\n",1213ret);12141215ret = da8xx_register_rtc();1216if (ret)1217pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);12181219ret = da850_evm_init_cpufreq();1220if (ret)1221pr_warning("da850_evm_init: cpufreq registration failed: %d\n",1222ret);12231224ret = da8xx_register_cpuidle();1225if (ret)1226pr_warning("da850_evm_init: cpuidle registration failed: %d\n",1227ret);12281229ret = da850_register_pm(&da850_pm_device);1230if (ret)1231pr_warning("da850_evm_init: suspend registration failed: %d\n",1232ret);12331234ret = da8xx_register_spi(1, da850evm_spi_info,1235ARRAY_SIZE(da850evm_spi_info));1236if (ret)1237pr_warning("da850_evm_init: spi 1 registration failed: %d\n",1238ret);1239}12401241#ifdef CONFIG_SERIAL_8250_CONSOLE1242static int __init da850_evm_console_init(void)1243{1244if (!machine_is_davinci_da850_evm())1245return 0;12461247return add_preferred_console("ttyS", 2, "115200");1248}1249console_initcall(da850_evm_console_init);1250#endif12511252static void __init da850_evm_map_io(void)1253{1254da850_init();1255}12561257MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")1258.boot_params = (DA8XX_DDR_BASE + 0x100),1259.map_io = da850_evm_map_io,1260.init_irq = cp_intc_init,1261.timer = &davinci_timer,1262.init_machine = da850_evm_init,1263MACHINE_END126412651266