123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- /*
- * linux/arch/arm/mach-omap2/board-n8x0.c
- *
- * Copyright (C) 2005-2009 Nokia Corporation
- * Author: Juha Yrjola <juha.yrjola@nokia.com>
- *
- * Modified from mach-omap2/board-generic.c
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
- #include <linux/clk.h>
- #include <linux/delay.h>
- #include <linux/gpio.h>
- #include <linux/init.h>
- #include <linux/io.h>
- #include <linux/irq.h>
- #include <linux/stddef.h>
- #include <linux/i2c.h>
- #include <linux/spi/spi.h>
- #include <linux/usb/musb.h>
- #include <linux/platform_data/i2c-cbus-gpio.h>
- #include <linux/platform_data/spi-omap2-mcspi.h>
- #include <linux/platform_data/mtd-onenand-omap2.h>
- #include <linux/mfd/menelaus.h>
- #include <sound/tlv320aic3x.h>
- #include <asm/mach/arch.h>
- #include <asm/mach-types.h>
- #include "common.h"
- #include "mmc.h"
- #include "mux.h"
- #include "gpmc-onenand.h"
- #define TUSB6010_ASYNC_CS 1
- #define TUSB6010_SYNC_CS 4
- #define TUSB6010_GPIO_INT 58
- #define TUSB6010_GPIO_ENABLE 0
- #define TUSB6010_DMACHAN 0x3f
- #if defined(CONFIG_I2C_CBUS_GPIO) || defined(CONFIG_I2C_CBUS_GPIO_MODULE)
- static struct i2c_cbus_platform_data n8x0_cbus_data = {
- .clk_gpio = 66,
- .dat_gpio = 65,
- .sel_gpio = 64,
- };
- static struct platform_device n8x0_cbus_device = {
- .name = "i2c-cbus-gpio",
- .id = 3,
- .dev = {
- .platform_data = &n8x0_cbus_data,
- },
- };
- static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
- {
- I2C_BOARD_INFO("retu-mfd", 0x01),
- },
- };
- static void __init n8x0_cbus_init(void)
- {
- const int retu_irq_gpio = 108;
- if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
- return;
- irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
- n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
- i2c_register_board_info(3, n8x0_i2c_board_info_3,
- ARRAY_SIZE(n8x0_i2c_board_info_3));
- platform_device_register(&n8x0_cbus_device);
- }
- #else /* CONFIG_I2C_CBUS_GPIO */
- static void __init n8x0_cbus_init(void)
- {
- }
- #endif /* CONFIG_I2C_CBUS_GPIO */
- #if defined(CONFIG_USB_MUSB_TUSB6010) || defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
- /*
- * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
- * 1.5 V voltage regulators of PM companion chip. Companion chip will then
- * provide then PGOOD signal to TUSB6010 which will release it from reset.
- */
- static int tusb_set_power(int state)
- {
- int i, retval = 0;
- if (state) {
- gpio_set_value(TUSB6010_GPIO_ENABLE, 1);
- msleep(1);
- /* Wait until TUSB6010 pulls INT pin down */
- i = 100;
- while (i && gpio_get_value(TUSB6010_GPIO_INT)) {
- msleep(1);
- i--;
- }
- if (!i) {
- printk(KERN_ERR "tusb: powerup failed\n");
- retval = -ENODEV;
- }
- } else {
- gpio_set_value(TUSB6010_GPIO_ENABLE, 0);
- msleep(10);
- }
- return retval;
- }
- static struct musb_hdrc_config musb_config = {
- .multipoint = 1,
- .dyn_fifo = 1,
- .num_eps = 16,
- .ram_bits = 12,
- };
- static struct musb_hdrc_platform_data tusb_data = {
- #ifdef CONFIG_USB_GADGET_MUSB_HDRC
- .mode = MUSB_OTG,
- #else
- .mode = MUSB_HOST,
- #endif
- .set_power = tusb_set_power,
- .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */
- .power = 100, /* Max 100 mA VBUS for host mode */
- .config = &musb_config,
- };
- static void __init n8x0_usb_init(void)
- {
- int ret = 0;
- static char announce[] __initdata = KERN_INFO "TUSB 6010\n";
- /* PM companion chip power control pin */
- ret = gpio_request_one(TUSB6010_GPIO_ENABLE, GPIOF_OUT_INIT_LOW,
- "TUSB6010 enable");
- if (ret != 0) {
- printk(KERN_ERR "Could not get TUSB power GPIO%i\n",
- TUSB6010_GPIO_ENABLE);
- return;
- }
- tusb_set_power(0);
- ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2,
- TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS,
- TUSB6010_GPIO_INT, TUSB6010_DMACHAN);
- if (ret != 0)
- goto err;
- printk(announce);
- return;
- err:
- gpio_free(TUSB6010_GPIO_ENABLE);
- }
- #else
- static void __init n8x0_usb_init(void) {}
- #endif /*CONFIG_USB_MUSB_TUSB6010 */
- static struct omap2_mcspi_device_config p54spi_mcspi_config = {
- .turbo_mode = 0,
- };
- static struct spi_board_info n800_spi_board_info[] __initdata = {
- {
- .modalias = "p54spi",
- .bus_num = 2,
- .chip_select = 0,
- .max_speed_hz = 48000000,
- .controller_data = &p54spi_mcspi_config,
- },
- };
- #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
- defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
- static struct mtd_partition onenand_partitions[] = {
- {
- .name = "bootloader",
- .offset = 0,
- .size = 0x20000,
- .mask_flags = MTD_WRITEABLE, /* Force read-only */
- },
- {
- .name = "config",
- .offset = MTDPART_OFS_APPEND,
- .size = 0x60000,
- },
- {
- .name = "kernel",
- .offset = MTDPART_OFS_APPEND,
- .size = 0x200000,
- },
- {
- .name = "initfs",
- .offset = MTDPART_OFS_APPEND,
- .size = 0x400000,
- },
- {
- .name = "rootfs",
- .offset = MTDPART_OFS_APPEND,
- .size = MTDPART_SIZ_FULL,
- },
- };
- static struct omap_onenand_platform_data board_onenand_data[] = {
- {
- .cs = 0,
- .gpio_irq = 26,
- .parts = onenand_partitions,
- .nr_parts = ARRAY_SIZE(onenand_partitions),
- .flags = ONENAND_SYNC_READ,
- }
- };
- #endif
- #if defined(CONFIG_MENELAUS) && \
- (defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE))
- /*
- * On both N800 and N810, only the first of the two MMC controllers is in use.
- * The two MMC slots are multiplexed via Menelaus companion chip over I2C.
- * On N800, both slots are powered via Menelaus. On N810, only one of the
- * slots is powered via Menelaus. The N810 EMMC is powered via GPIO.
- *
- * VMMC slot 1 on both N800 and N810
- * VDCDC3_APE and VMCS2_APE slot 2 on N800
- * GPIO23 and GPIO9 slot 2 EMMC on N810
- *
- */
- #define N8X0_SLOT_SWITCH_GPIO 96
- #define N810_EMMC_VSD_GPIO 23
- #define N810_EMMC_VIO_GPIO 9
- static int slot1_cover_open;
- static int slot2_cover_open;
- static struct device *mmc_device;
- static int n8x0_mmc_switch_slot(struct device *dev, int slot)
- {
- #ifdef CONFIG_MMC_DEBUG
- dev_dbg(dev, "Choose slot %d\n", slot + 1);
- #endif
- gpio_set_value(N8X0_SLOT_SWITCH_GPIO, slot);
- return 0;
- }
- static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
- int power_on, int vdd)
- {
- int mV;
- #ifdef CONFIG_MMC_DEBUG
- dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
- power_on ? "on" : "off", vdd);
- #endif
- if (slot == 0) {
- if (!power_on)
- return menelaus_set_vmmc(0);
- switch (1 << vdd) {
- case MMC_VDD_33_34:
- case MMC_VDD_32_33:
- case MMC_VDD_31_32:
- mV = 3100;
- break;
- case MMC_VDD_30_31:
- mV = 3000;
- break;
- case MMC_VDD_28_29:
- mV = 2800;
- break;
- case MMC_VDD_165_195:
- mV = 1850;
- break;
- default:
- BUG();
|