[xburst] Fix usb gadget driver build
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / arch / arm / mach-s3c2442 / mach-gta02.c
index 88377da..49ab6c4 100644 (file)
@@ -38,6 +38,8 @@
 #include <linux/spi/spi_gpio.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/mmc/host.h>
+#include <linux/leds.h>
+#include <linux/gpio_keys.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -89,6 +91,7 @@
 #include <plat/iic.h>
 #include <plat/usb-control.h>
 #include <plat/regs-timer.h>
+#include <plat/gpio-core.h>
 
 #include <mach/gta02-pm-gsm.h>
 #include <mach/gta02-pm-gps.h>
@@ -1079,7 +1082,7 @@ static struct platform_device gta02_bl_dev = {
 
 static void gta02_jbt6k74_reset(int devidx, int level)
 {
-    gpio_set_value(GTA02_GPIO_GLAMO(4), level);
+       gpio_set_value(GTA02_GPIO_GLAMO(4), level);
 }
 
 static void gta02_jbt6k74_probe_completed(struct device *dev)
@@ -1246,62 +1249,64 @@ static struct platform_device gta02_spi_gpio_dev = {
 
 /*----------- / SPI: Accelerometers attached to SPI of s3c244x ----------------- */
 
-static struct resource gta02_led_resources[] = {
+static struct gpio_led gta02_gpio_leds[] = {
        {
                .name   = "gta02-power:orange",
-               .start  = GTA02_GPIO_PWR_LED1,
-               .end    = GTA02_GPIO_PWR_LED1,
+               .gpio   = GTA02_GPIO_PWR_LED1,
        }, {
                .name   = "gta02-power:blue",
-               .start  = GTA02_GPIO_PWR_LED2,
-               .end    = GTA02_GPIO_PWR_LED2,
+               .gpio   = GTA02_GPIO_PWR_LED2,
        }, {
                .name   = "gta02-aux:red",
-               .start  = GTA02_GPIO_AUX_LED,
-               .end    = GTA02_GPIO_AUX_LED,
+               .gpio   = GTA02_GPIO_AUX_LED,
        },
 };
 
-struct platform_device gta02_led_dev = {
-       .name           = "gta02-led",
-       .num_resources  = ARRAY_SIZE(gta02_led_resources),
-       .resource       = gta02_led_resources,
+static struct gpio_led_platform_data gta02_gpio_leds_pdata = {
+       .leds = gta02_gpio_leds,
+       .num_leds = ARRAY_SIZE(gta02_gpio_leds),
 };
 
-static struct resource gta02_button_resources[] = {
-       [0] = {
-               .start = GTA02_GPIO_AUX_KEY,
-               .end   = GTA02_GPIO_AUX_KEY,
-       },
-       [1] = {
-               .start = GTA02_GPIO_HOLD_KEY,
-               .end   = GTA02_GPIO_HOLD_KEY,
-       },
-       [2] = {
-               .start = GTA02_GPIO_JACK_INSERT,
-               .end   = GTA02_GPIO_JACK_INSERT,
+struct platform_device gta02_led_dev = {
+       .name = "leds-gpio",
+       .id   = -1,
+       .dev = {
+               .platform_data = &gta02_gpio_leds_pdata,
        },
-       [3] = {
-               .start = 0,
-               .end   = 0,
+};
+
+static struct gpio_keys_button gta02_buttons[] = {
+       {
+               .gpio = GTA02_GPIO_AUX_KEY,
+               .code = KEY_PHONE,
+               .desc = "Aux",
+               .type = EV_KEY,
        },
-       [4] = {
-               .start = 0,
-               .end   = 0,
+       {
+               .gpio = GTA02_GPIO_HOLD_KEY,
+               .code = KEY_PAUSE,
+               .desc = "Hold",
+               .type = EV_KEY,
        },
 };
 
+static struct gpio_keys_platform_data gta02_buttons_pdata = {
+       .buttons = gta02_buttons,
+       .nbuttons = ARRAY_SIZE(gta02_buttons),
+};
+
 static struct platform_device gta02_button_dev = {
-       .name           = "gta02-button",
-       .num_resources  = ARRAY_SIZE(gta02_button_resources),
-       .resource       = gta02_button_resources,
+       .name = "gpio-keys",
+       .id = -1,
+       .dev = {
+               .platform_data = &gta02_buttons_pdata,
+       },
 };
 
 static struct platform_device gta02_pm_usbhost_dev = {
        .name           = "gta02-pm-host",
 };
 
-
 /* USB */
 static struct s3c2410_hcd_info gta02_usb_info = {
        .port[0]        = {
@@ -1433,9 +1438,9 @@ static struct glamo_mmc_platform_data gta02_glamo_mmc_pdata = {
 static struct glamo_platform_data gta02_glamo_pdata = {
        .fb_data   = &gta02_glamo_fb_pdata,
        .mmc_data  = &gta02_glamo_mmc_pdata,
-    .gpio_base = GTA02_GPIO_GLAMO_BASE,
+       .gpio_base = GTA02_GPIO_GLAMO_BASE,
 
-    .osci_clock_rate = 32768,
+       .osci_clock_rate = 32768,
 
        .glamo_irq_is_wired = glamo_irq_is_wired,
        .glamo_external_reset = gta02_glamo_external_reset,
@@ -1500,10 +1505,10 @@ struct spi_gpio_platform_data spigpio_platform_data = {
 
 static struct platform_device spigpio_device = {
        .name = "spi_gpio",
-    .id   = 2,
+       .id   = 2,
        .dev = {
                .platform_data = &spigpio_platform_data,
-        .parent        = &gta02_glamo_dev.dev,
+               .parent        = &gta02_glamo_dev.dev,
        },
 };
 
@@ -1572,10 +1577,10 @@ static struct platform_device *gta02_devices_pmu_children[] = {
 static void gta02_register_glamo(void)
 {
        platform_device_register(&gta02_glamo_dev);
-    if (gpio_request(GTA02_GPIO_GLAMO(4), "jbt6k74 reset"))
-        printk("gta02: Failed to request jbt6k74 reset pin\n");
-    if (gpio_direction_output(GTA02_GPIO_GLAMO(4), 1))
-        printk("gta02: Failed to configure jbt6k74 reset pin\n");
+       if (gpio_request(GTA02_GPIO_GLAMO(4), "jbt6k74 reset"))
+               printk("gta02: Failed to request jbt6k74 reset pin\n");
+       if (gpio_direction_output(GTA02_GPIO_GLAMO(4), 1))
+               printk("gta02: Failed to configure jbt6k74 reset pin\n");
        platform_device_register(&spigpio_device);
 }
 
@@ -1595,8 +1600,8 @@ static void gta02_pmu_regulator_registered(struct pcf50633 *pcf, int id)
                        pdev = &gta02_pm_gps_dev;
                        break;
                case PCF50633_REGULATOR_HCLDO:
-            gta02_register_glamo();
-            return;
+                       gta02_register_glamo();
+                       return;
                default:
                        return;
        }
@@ -1623,7 +1628,7 @@ static void gta02_pmu_attach_child_devices(struct pcf50633 *pcf)
        platform_add_devices(gta02_devices_pmu_children,
                                        ARRAY_SIZE(gta02_devices_pmu_children));
 
-    regulator_has_full_constraints();
+       regulator_has_full_constraints();
 }
 
 static void gta02_poweroff(void)
@@ -1632,6 +1637,57 @@ static void gta02_poweroff(void)
                  PCF50633_OOCSHDWN_GOSTDBY, PCF50633_OOCSHDWN_GOSTDBY);
 }
 
+
+/* On hardware rev 5 and earlier the leds are missing a resistor and reading
+ * from their gpio pins will always return 0, so we have to shadow the
+ * led states software */
+static unsigned long gpb_shadow;
+extern struct s3c_gpio_chip s3c24xx_gpios[];
+
+static void gta02_gpb_set(struct gpio_chip *chip,
+                           unsigned offset, int value)
+{
+       void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB0);
+       unsigned long flags;
+       unsigned long dat;
+
+       local_irq_save(flags);
+
+       dat = __raw_readl(base + 0x04) | gpb_shadow;
+       dat &= ~(1 << offset);
+       gpb_shadow &= ~(1 << offset);
+       if (value) {
+               dat |= 1 << offset;
+               switch (offset) {
+               case 0 ... 2:
+                       gpb_shadow |= 1 << offset;
+                       break;
+               default:
+                       break;
+               }
+       }
+       __raw_writel(dat, base + 0x04);
+
+       local_irq_restore(flags);
+}
+
+static int gta02_gpb_get(struct gpio_chip *chip, unsigned offset)
+{
+       void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB0);
+       unsigned long val;
+
+       val = __raw_readl(base + 0x04) | gpb_shadow;
+       val >>= offset;
+       val &= 1;
+
+       return val;
+}
+
+static void gta02_hijack_gpb(void) {
+    s3c24xx_gpios[1].chip.set = gta02_gpb_set;
+    s3c24xx_gpios[1].chip.get = gta02_gpb_get;
+}
+
 static void __init gta02_machine_init(void)
 {
        int rc;
@@ -1648,6 +1704,8 @@ static void __init gta02_machine_init(void)
        default:
                break;
        }
+       if (S3C_SYSTEM_REV_ATAG <= GTA02v5_SYSTEM_REV)
+               gta02_hijack_gpb();
 
        spin_lock_init(&motion_irq_lock);
 
This page took 0.03118 seconds and 4 git commands to generate.