]> err.no Git - linux-2.6/blobdiff - arch/arm/mach-pxa/magician.c
[ARM] 5032/1: Added cpufreq support for pxa27x CPU
[linux-2.6] / arch / arm / mach-pxa / magician.c
index 9e126a90113709512a26ca670a1384e19677980e..badba064dc0400326e74a3e874d9366aa6519c52 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/mfd/htc-egpio.h>
+#include <linux/mfd/htc-pasic3.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/physmap.h>
@@ -30,6 +31,7 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/arch/magician.h>
+#include <asm/arch/mfp-pxa27x.h>
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/pxafb.h>
 #include <asm/arch/i2c.h>
 
 #include "generic.h"
 
+static unsigned long magician_pin_config[] = {
+
+       /* SDRAM and Static Memory I/O Signals */
+       GPIO20_nSDCS_2,
+       GPIO21_nSDCS_3,
+       GPIO15_nCS_1,
+       GPIO78_nCS_2,   /* PASIC3 */
+       GPIO79_nCS_3,   /* EGPIO CPLD */
+       GPIO80_nCS_4,
+       GPIO33_nCS_5,
+
+       /* I2C */
+       GPIO117_I2C_SCL,
+       GPIO118_I2C_SDA,
+
+       /* PWM 0 */
+       GPIO16_PWM0_OUT,
+
+       /* I2S */
+       GPIO28_I2S_BITCLK_OUT,
+       GPIO29_I2S_SDATA_IN,
+       GPIO31_I2S_SYNC,
+       GPIO113_I2S_SYSCLK,
+
+       /* SSP 2 */
+       GPIO19_SSP2_SCLK,
+       GPIO14_SSP2_SFRM,
+       GPIO89_SSP2_TXD,
+       GPIO88_SSP2_RXD,
+
+       /* MMC */
+       GPIO32_MMC_CLK,
+       GPIO92_MMC_DAT_0,
+       GPIO109_MMC_DAT_1,
+       GPIO110_MMC_DAT_2,
+       GPIO111_MMC_DAT_3,
+       GPIO112_MMC_CMD,
+
+       /* LCD */
+       GPIO58_LCD_LDD_0,
+       GPIO59_LCD_LDD_1,
+       GPIO60_LCD_LDD_2,
+       GPIO61_LCD_LDD_3,
+       GPIO62_LCD_LDD_4,
+       GPIO63_LCD_LDD_5,
+       GPIO64_LCD_LDD_6,
+       GPIO65_LCD_LDD_7,
+       GPIO66_LCD_LDD_8,
+       GPIO67_LCD_LDD_9,
+       GPIO68_LCD_LDD_10,
+       GPIO69_LCD_LDD_11,
+       GPIO70_LCD_LDD_12,
+       GPIO71_LCD_LDD_13,
+       GPIO72_LCD_LDD_14,
+       GPIO73_LCD_LDD_15,
+       GPIO74_LCD_FCLK,
+       GPIO75_LCD_LCLK,
+       GPIO76_LCD_PCLK,
+       GPIO77_LCD_BIAS,
+
+       /* QCI */
+       GPIO12_CIF_DD_7,
+       GPIO17_CIF_DD_6,
+       GPIO50_CIF_DD_3,
+       GPIO51_CIF_DD_2,
+       GPIO52_CIF_DD_4,
+       GPIO53_CIF_MCLK,
+       GPIO54_CIF_PCLK,
+       GPIO55_CIF_DD_1,
+       GPIO81_CIF_DD_0,
+       GPIO82_CIF_DD_5,
+       GPIO84_CIF_FV,
+       GPIO85_CIF_LV,
+
+       /* Magician specific input GPIOs */
+       GPIO9_GPIO,     /* unknown */
+       GPIO10_GPIO,    /* GSM_IRQ */
+       GPIO13_GPIO,    /* CPLD_IRQ */
+       GPIO107_GPIO,   /* DS1WM_IRQ */
+       GPIO108_GPIO,   /* GSM_READY */
+       GPIO115_GPIO,   /* nPEN_IRQ */
+};
+
 /*
  * IRDA
  */
@@ -299,6 +384,107 @@ static struct platform_device backlight = {
        .id   = -1,
 };
 
+/*
+ * LEDs
+ */
+
+struct gpio_led gpio_leds[] = {
+       {
+               .name = "magician::vibra",
+               .default_trigger = "none",
+               .gpio = GPIO22_MAGICIAN_VIBRA_EN,
+       },
+       {
+               .name = "magician::phone_bl",
+               .default_trigger = "none",
+               .gpio = GPIO103_MAGICIAN_LED_KP,
+       },
+};
+
+static struct gpio_led_platform_data gpio_led_info = {
+       .leds = gpio_leds,
+       .num_leds = ARRAY_SIZE(gpio_leds),
+};
+
+static struct platform_device leds_gpio = {
+       .name = "leds-gpio",
+       .id   = -1,
+       .dev  = {
+               .platform_data = &gpio_led_info,
+       },
+};
+
+static struct pasic3_led pasic3_leds[] = {
+       {
+               .led = {
+                       .name            = "magician:red",
+                       .default_trigger = "ds2760-battery.0-charging",
+               },
+               .hw_num = 0,
+               .bit2   = PASIC3_BIT2_LED0,
+               .mask   = PASIC3_MASK_LED0,
+       },
+       {
+               .led = {
+                       .name            = "magician:green",
+                       .default_trigger = "ds2760-battery.0-charging-or-full",
+               },
+               .hw_num = 1,
+               .bit2   = PASIC3_BIT2_LED1,
+               .mask   = PASIC3_MASK_LED1,
+       },
+       {
+               .led = {
+                       .name            = "magician:blue",
+                       .default_trigger = "bluetooth",
+               },
+               .hw_num = 2,
+               .bit2   = PASIC3_BIT2_LED2,
+               .mask   = PASIC3_MASK_LED2,
+       },
+};
+
+static struct platform_device pasic3;
+
+static struct pasic3_leds_machinfo pasic3_leds_info = {
+       .num_leds   = ARRAY_SIZE(pasic3_leds),
+       .power_gpio = EGPIO_MAGICIAN_LED_POWER,
+       .leds       = pasic3_leds,
+};
+
+/*
+ * PASIC3 with DS1WM
+ */
+
+static struct resource pasic3_resources[] = {
+       [0] = {
+               .start  = PXA_CS2_PHYS,
+               .end    = PXA_CS2_PHYS + 0x1b,
+               .flags  = IORESOURCE_MEM,
+       },
+       /* No IRQ handler in the PASIC3, DS1WM needs an external IRQ */
+       [1] = {
+               .start  = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ),
+               .end    = gpio_to_irq(GPIO107_MAGICIAN_DS1WM_IRQ),
+               .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
+       }
+};
+
+static struct pasic3_platform_data pasic3_platform_data = {
+       .bus_shift  = 2,
+       .led_pdata  = &pasic3_leds_info,
+       .clock_rate = 4000000,
+};
+
+static struct platform_device pasic3 = {
+       .name           = "pasic3",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(pasic3_resources),
+       .resource       = pasic3_resources,
+       .dev = {
+               .platform_data = &pasic3_platform_data,
+       },
+};
 
 /*
  * External power
@@ -320,10 +506,16 @@ static void magician_set_charge(int flags)
        gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags);
 }
 
+static char *magician_supplicants[] = {
+       "ds2760-battery.0", "backup-battery"
+};
+
 static struct pda_power_pdata power_supply_info = {
-       .is_ac_online = magician_is_ac_online,
-       .is_usb_online = magician_is_usb_online,
-       .set_charge = magician_set_charge,
+       .is_ac_online    = magician_is_ac_online,
+       .is_usb_online   = magician_is_usb_online,
+       .set_charge      = magician_set_charge,
+       .supplied_to     = magician_supplicants,
+       .num_supplicants = ARRAY_SIZE(magician_supplicants),
 };
 
 static struct resource power_supply_resources[] = {
@@ -359,9 +551,28 @@ static struct platform_device power_supply = {
 static int magician_mci_init(struct device *dev,
                                irq_handler_t detect_irq, void *data)
 {
-       return request_irq(IRQ_MAGICIAN_SD, detect_irq,
+       int err;
+
+       err = request_irq(IRQ_MAGICIAN_SD, detect_irq,
                                IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
                                "MMC card detect", data);
+       if (err)
+               goto err_request_irq;
+       err = gpio_request(EGPIO_MAGICIAN_SD_POWER, "SD_POWER");
+       if (err)
+               goto err_request_power;
+       err = gpio_request(EGPIO_MAGICIAN_nSD_READONLY, "nSD_READONLY");
+       if (err)
+               goto err_request_readonly;
+
+       return 0;
+
+err_request_readonly:
+       gpio_free(EGPIO_MAGICIAN_SD_POWER);
+err_request_power:
+       free_irq(IRQ_MAGICIAN_SD, data);
+err_request_irq:
+       return err;
 }
 
 static void magician_mci_setpower(struct device *dev, unsigned int vdd)
@@ -378,6 +589,8 @@ static int magician_mci_get_ro(struct device *dev)
 
 static void magician_mci_exit(struct device *dev, void *data)
 {
+       gpio_free(EGPIO_MAGICIAN_nSD_READONLY);
+       gpio_free(EGPIO_MAGICIAN_SD_POWER);
        free_irq(IRQ_MAGICIAN_SD, data);
 }
 
@@ -449,34 +662,52 @@ static struct platform_device *devices[] __initdata = {
        &gpio_keys,
        &egpio,
        &backlight,
+       &pasic3,
        &power_supply,
        &strataflash,
+       &leds_gpio,
 };
 
 static void __init magician_init(void)
 {
        void __iomem *cpld;
        int lcd_select;
+       int err;
+
+       gpio_request(GPIO13_MAGICIAN_CPLD_IRQ, "CPLD_IRQ");
+       gpio_request(GPIO107_MAGICIAN_DS1WM_IRQ, "DS1WM_IRQ");
+
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config));
 
        platform_add_devices(devices, ARRAY_SIZE(devices));
+
+       err = gpio_request(GPIO83_MAGICIAN_nIR_EN, "nIR_EN");
+       if (!err) {
+               gpio_direction_output(GPIO83_MAGICIAN_nIR_EN, 1);
+               pxa_set_ficp_info(&magician_ficp_info);
+       }
        pxa_set_i2c_info(NULL);
        pxa_set_mci_info(&magician_mci_info);
        pxa_set_ohci_info(&magician_ohci_info);
-       pxa_set_ficp_info(&magician_ficp_info);
 
        /* Check LCD type we have */
        cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000);
        if (cpld) {
                u8 board_id = __raw_readb(cpld+0x14);
+               iounmap(cpld);
                system_rev = board_id & 0x7;
                lcd_select = board_id & 0x8;
-               iounmap(cpld);
                pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly");
-               if (lcd_select && (system_rev < 3))
-                       pxa_gpio_mode(GPIO75_MAGICIAN_SAMSUNG_POWER_MD);
-               pxa_gpio_mode(GPIO104_MAGICIAN_LCD_POWER_1_MD);
-               pxa_gpio_mode(GPIO105_MAGICIAN_LCD_POWER_2_MD);
-               pxa_gpio_mode(GPIO106_MAGICIAN_LCD_POWER_3_MD);
+               if (lcd_select && (system_rev < 3)) {
+                       gpio_request(GPIO75_MAGICIAN_SAMSUNG_POWER, "SAMSUNG_POWER");
+                       gpio_direction_output(GPIO75_MAGICIAN_SAMSUNG_POWER, 0);
+               }
+               gpio_request(GPIO104_MAGICIAN_LCD_POWER_1, "LCD_POWER_1");
+               gpio_request(GPIO105_MAGICIAN_LCD_POWER_2, "LCD_POWER_2");
+               gpio_request(GPIO106_MAGICIAN_LCD_POWER_3, "LCD_POWER_3");
+               gpio_direction_output(GPIO104_MAGICIAN_LCD_POWER_1, 0);
+               gpio_direction_output(GPIO105_MAGICIAN_LCD_POWER_2, 0);
+               gpio_direction_output(GPIO106_MAGICIAN_LCD_POWER_3, 0);
                set_pxa_fb_info(lcd_select ? &samsung_info : &toppoly_info);
        } else
                pr_err("LCD detection: CPLD mapping failed\n");