[ARM] pxa/em-x270: don't use pxa_camera init() callback
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / tosa.c
index 4bd7d4f..c854c16 100644 (file)
 #include <linux/mfd/tmio.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
 #include <linux/pm.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/gpio.h>
 #include <linux/pda_power.h>
-#include <linux/rfkill.h>
+#include <linux/spi/spi.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
-#include <asm/arch/pxa2xx-regs.h>
-#include <asm/arch/mfp-pxa25x.h>
-#include <asm/arch/reset.h>
-#include <asm/arch/irda.h>
-#include <asm/arch/i2c.h>
-#include <asm/arch/mmc.h>
-#include <asm/arch/udc.h>
-#include <asm/arch/tosa_bt.h>
+
+#include <mach/pxa25x.h>
+#include <mach/reset.h>
+#include <mach/irda.h>
+#include <plat/i2c.h>
+#include <mach/mmc.h>
+#include <mach/udc.h>
+#include <mach/tosa_bt.h>
+#include <mach/pxa2xx_spi.h>
+#include <mach/audio.h>
 
 #include <asm/mach/arch.h>
-#include <asm/arch/tosa.h>
+#include <mach/tosa.h>
 
 #include <asm/hardware/scoop.h>
 #include <asm/mach/sharpsl_param.h>
 
 #include "generic.h"
+#include "clock.h"
 #include "devices.h"
 
 static unsigned long tosa_pin_config[] = {
@@ -243,49 +247,10 @@ static struct pxa2xx_udc_mach_info udc_info __initdata = {
 /*
  * MMC/SD Device
  */
-static struct pxamci_platform_data tosa_mci_platform_data;
-
 static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
 {
        int err;
 
-       tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
-
-       err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
-       if (err) {
-               printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
-               goto err_gpio_detect;
-       }
-       err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
-       if (err)
-               goto err_gpio_detect_dir;
-
-       err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
-                         IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-                               "MMC/SD card detect", data);
-       if (err) {
-               printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
-               goto err_irq;
-       }
-
-       err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
-       if (err) {
-               printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
-               goto err_gpio_wp;
-       }
-       err = gpio_direction_input(TOSA_GPIO_SD_WP);
-       if (err)
-               goto err_gpio_wp_dir;
-
-       err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
-       if (err) {
-               printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
-               goto err_gpio_pwr;
-       }
-       err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
-       if (err)
-               goto err_gpio_pwr_dir;
-
        err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
        if (err) {
                printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
@@ -300,51 +265,21 @@ static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void
 err_gpio_int_dir:
        gpio_free(TOSA_GPIO_nSD_INT);
 err_gpio_int:
-err_gpio_pwr_dir:
-       gpio_free(TOSA_GPIO_PWR_ON);
-err_gpio_pwr:
-err_gpio_wp_dir:
-       gpio_free(TOSA_GPIO_SD_WP);
-err_gpio_wp:
-       free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
-err_irq:
-err_gpio_detect_dir:
-       gpio_free(TOSA_GPIO_nSD_DETECT);
-err_gpio_detect:
        return err;
 }
 
-static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
-{
-       struct pxamci_platform_data* p_d = dev->platform_data;
-
-       if (( 1 << vdd) & p_d->ocr_mask) {
-               gpio_set_value(TOSA_GPIO_PWR_ON, 1);
-       } else {
-               gpio_set_value(TOSA_GPIO_PWR_ON, 0);
-       }
-}
-
-static int tosa_mci_get_ro(struct device *dev)
-{
-       return gpio_get_value(TOSA_GPIO_SD_WP);
-}
-
 static void tosa_mci_exit(struct device *dev, void *data)
 {
        gpio_free(TOSA_GPIO_nSD_INT);
-       gpio_free(TOSA_GPIO_PWR_ON);
-       gpio_free(TOSA_GPIO_SD_WP);
-       free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
-       gpio_free(TOSA_GPIO_nSD_DETECT);
 }
 
 static struct pxamci_platform_data tosa_mci_platform_data = {
-       .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
-       .init           = tosa_mci_init,
-       .get_ro         = tosa_mci_get_ro,
-       .setpower       = tosa_mci_setpower,
-       .exit           = tosa_mci_exit,
+       .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
+       .init                   = tosa_mci_init,
+       .exit                   = tosa_mci_exit,
+       .gpio_card_detect       = TOSA_GPIO_nSD_DETECT,
+       .gpio_card_ro           = TOSA_GPIO_SD_WP,
+       .gpio_power             = TOSA_GPIO_PWR_ON,
 };
 
 /*
@@ -402,10 +337,11 @@ static void tosa_irda_shutdown(struct device *dev)
 }
 
 static struct pxaficp_platform_data tosa_ficp_platform_data = {
-       .transceiver_cap  = IR_SIRMODE | IR_OFF,
-       .transceiver_mode = tosa_irda_transceiver_mode,
-       .startup = tosa_irda_startup,
-       .shutdown = tosa_irda_shutdown,
+       .gpio_pwdown            = -1,
+       .transceiver_cap        = IR_SIRMODE | IR_OFF,
+       .transceiver_mode       = tosa_irda_transceiver_mode,
+       .startup                = tosa_irda_startup,
+       .shutdown               = tosa_irda_shutdown,
 };
 
 /*
@@ -521,6 +457,14 @@ static struct gpio_keys_button tosa_gpio_keys[] = {
                .wakeup = 1,
                .active_low = 1,
        },
+       {
+               .type   = EV_SW,
+               .code   = SW_HEADPHONE_INSERT,
+               .gpio   = TOSA_GPIO_EAR_IN,
+               .desc   = "HeadPhone insert",
+               .active_low = 1,
+               .debounce_interval = 300,
+       },
 };
 
 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
@@ -603,7 +547,7 @@ static int tosa_tc6393xb_enable(struct platform_device *dev)
        rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
        if (rc)
                goto err_req_suspend;
-       rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
+       rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
        if (rc)
                goto err_req_l3v;
        rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
@@ -697,16 +641,78 @@ static struct tmio_nand_data tosa_tc6393xb_nand_config = {
        .badblock_pattern = &tosa_tc6393xb_nand_bbt,
 };
 
-static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
+static int tosa_tc6393xb_setup(struct platform_device *dev)
+{
+       int rc;
+
+       rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
+       if (rc)
+               goto err_req;
+
+       rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
+       if (rc)
+               goto err_dir;
+
+       return rc;
+
+err_dir:
+       gpio_free(TOSA_GPIO_CARD_VCC_ON);
+err_req:
+       return rc;
+}
+
+static void tosa_tc6393xb_teardown(struct platform_device *dev)
+{
+       gpio_free(TOSA_GPIO_CARD_VCC_ON);
+}
+
+#ifdef CONFIG_MFD_TC6393XB
+static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
+       {
+               .xres = 480,
+               .yres = 640,
+               .pixclock = 0x002cdf00,/* PLL divisor */
+               .left_margin = 0x004c,
+               .right_margin = 0x005b,
+               .upper_margin = 0x0001,
+               .lower_margin = 0x000d,
+               .hsync_len = 0x0002,
+               .vsync_len = 0x0001,
+               .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+               .vmode = FB_VMODE_NONINTERLACED,
+       },{
+               .xres = 240,
+               .yres = 320,
+               .pixclock = 0x00e7f203,/* PLL divisor */
+               .left_margin = 0x0024,
+               .right_margin = 0x002f,
+               .upper_margin = 0x0001,
+               .lower_margin = 0x000d,
+               .hsync_len = 0x0002,
+               .vsync_len = 0x0001,
+               .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+               .vmode = FB_VMODE_NONINTERLACED,
+       }
+};
+
+static struct tmio_fb_data tosa_tc6393xb_fb_config = {
+       .lcd_set_power  = tc6393xb_lcd_set_power,
+       .lcd_mode       = tc6393xb_lcd_mode,
+       .num_modes      = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
+       .modes          = &tosa_tc6393xb_lcd_mode[0],
+       .height         = 82,
+       .width          = 60,
+};
+#endif
+
+static struct tc6393xb_platform_data tosa_tc6393xb_data = {
        .scr_pll2cr     = 0x0cc1,
        .scr_gper       = 0x3300,
-       .scr_gpo_dsr    =
-               TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
-       .scr_gpo_doecr  =
-               TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
 
        .irq_base       = IRQ_BOARD_START,
        .gpio_base      = TOSA_TC6393XB_GPIO_BASE,
+       .setup          = tosa_tc6393xb_setup,
+       .teardown       = tosa_tc6393xb_teardown,
 
        .enable         = tosa_tc6393xb_enable,
        .disable        = tosa_tc6393xb_disable,
@@ -714,6 +720,11 @@ static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
        .resume         = tosa_tc6393xb_resume,
 
        .nand_data      = &tosa_tc6393xb_nand_config,
+#ifdef CONFIG_MFD_TC6393XB
+       .fb_data        = &tosa_tc6393xb_fb_config,
+#endif
+
+       .resume_restore = 1,
 };
 
 
@@ -721,7 +732,7 @@ static struct platform_device tc6393xb_device = {
        .name   = "tc6393xb",
        .id     = -1,
        .dev    = {
-               .platform_data  = &tosa_tc6393xb_setup,
+               .platform_data  = &tosa_tc6393xb_data,
        },
        .num_resources  = ARRAY_SIZE(tc6393xb_resources),
        .resource       = tc6393xb_resources,
@@ -738,6 +749,50 @@ static struct platform_device tosa_bt_device = {
        .dev.platform_data = &tosa_bt_data,
 };
 
+static struct pxa2xx_spi_master pxa_ssp_master_info = {
+       .num_chipselect = 1,
+};
+
+static struct spi_board_info spi_board_info[] __initdata = {
+       {
+               .modalias       = "tosa-lcd",
+               // .platform_data
+               .max_speed_hz   = 28750,
+               .bus_num        = 2,
+               .chip_select    = 0,
+               .mode           = SPI_MODE_0,
+       },
+};
+
+static struct mtd_partition sharpsl_rom_parts[] = {
+       {
+               .name   ="Boot PROM Filesystem",
+               .offset = 0x00160000,
+               .size   = MTDPART_SIZ_FULL,
+       },
+};
+
+static struct physmap_flash_data sharpsl_rom_data = {
+       .width          = 2,
+       .nr_parts       = ARRAY_SIZE(sharpsl_rom_parts),
+       .parts          = sharpsl_rom_parts,
+};
+
+static struct resource sharpsl_rom_resources[] = {
+       {
+               .start  = 0x00000000,
+               .end    = 0x007fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device sharpsl_rom_device = {
+       .name   = "physmap-flash",
+       .id     = -1,
+       .resource = sharpsl_rom_resources,
+       .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
+       .dev.platform_data = &sharpsl_rom_data,
+};
 
 static struct platform_device *devices[] __initdata = {
        &tosascoop_device,
@@ -748,14 +803,15 @@ static struct platform_device *devices[] __initdata = {
        &tosa_gpio_keys_device,
        &tosaled_device,
        &tosa_bt_device,
+       &sharpsl_rom_device,
 };
 
 static void tosa_poweroff(void)
 {
-       arm_machine_restart('g');
+       arm_machine_restart('g', NULL);
 }
 
-static void tosa_restart(char mode)
+static void tosa_restart(char mode, const char *cmd)
 {
        /* Bootloader magic for a reboot */
        if((MSC0 & 0xffff0000) == 0x7ff00000)
@@ -769,10 +825,15 @@ static void __init tosa_init(void)
        int dummy;
 
        pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
+
+       pxa_set_ffuart_info(NULL);
+       pxa_set_btuart_info(NULL);
+       pxa_set_stuart_info(NULL);
+
        gpio_set_wake(MFP_PIN_GPIO1, 1);
        /* We can't pass to gpio-keys since it will drop the Reset altfunc */
 
-       init_gpio_reset(TOSA_GPIO_ON_RESET);
+       init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
 
        pm_power_off = tosa_poweroff;
        arm_pm_restart = tosa_restart;
@@ -786,12 +847,19 @@ static void __init tosa_init(void)
        dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
        dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
 
+       tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
        pxa_set_mci_info(&tosa_mci_platform_data);
        pxa_set_udc_info(&udc_info);
        pxa_set_ficp_info(&tosa_ficp_platform_data);
        pxa_set_i2c_info(NULL);
+       pxa_set_ac97_info(NULL);
        platform_scoop_config = &tosa_pcmcia_config;
 
+       pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
+       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
+
+       clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
+
        platform_add_devices(devices, ARRAY_SIZE(devices));
 }