[ARM] pxa/corgi: use generic GPIO API for SCOOP GPIOs
authorEric Miao <eric.miao@marvell.com>
Fri, 5 Sep 2008 10:15:22 +0000 (18:15 +0800)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 23 Sep 2008 21:04:39 +0000 (22:04 +0100)
Original patch from Dmitry Baryshkov's inital scoop gpio conversion
work at http://git.infradead.org/users/dbaryshkov/zaurus-2.6.git.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-pxa/corgi.c
arch/arm/mach-pxa/corgi_pm.c
arch/arm/mach-pxa/include/mach/corgi.h
sound/soc/pxa/corgi.c

index 68765636bfce1e5b3f7205db9b444f87d966dfaa..da1e601907061cf00bb442ec45aa85d44a9df47b 100644 (file)
@@ -127,6 +127,7 @@ static struct resource corgi_scoop_resources[] = {
 static struct scoop_config corgi_scoop_setup = {
        .io_dir         = CORGI_SCOOP_IO_DIR,
        .io_out         = CORGI_SCOOP_IO_OUT,
+       .gpio_base      = CORGI_SCOOP_GPIO_BASE,
 };
 
 struct platform_device corgiscoop_device = {
@@ -426,10 +427,7 @@ static struct pxa2xx_spi_chip corgi_ads7846_chip = {
 static void corgi_notify_intensity(int intensity)
 {
        /* Bit 5 is via SCOOP */
-       if (intensity & 0x0020)
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
-       else
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
+       gpio_set_value(CORGI_GPIO_BACKLIGHT_CONT, !!(intensity & 0x0020));
 }
 
 static void corgi_bl_kick_battery(void)
@@ -539,7 +537,8 @@ static void corgi_poweroff(void)
 {
        if (!machine_is_corgi())
                /* Green LED off tells the bootloader to halt */
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
+               gpio_set_value(CORGI_GPIO_LED_GREEN, 0);
+
        arm_machine_restart('h');
 }
 
@@ -547,7 +546,8 @@ static void corgi_restart(char mode)
 {
        if (!machine_is_corgi())
                /* Green LED on tells the bootloader to reboot */
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
+               gpio_set_value(CORGI_GPIO_LED_GREEN, 1);
+
        arm_machine_restart('h');
 }
 
index 35bbfccd2df30fb1c4217a940839f26dad272279..eb7d6c94aa425bf23778efd92293dfa1737fd6df 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/irq.h>
 #include <asm/mach-types.h>
 #include <mach/hardware.h>
-#include <asm/hardware/scoop.h>
 
 #include <mach/sharpsl.h>
 #include <mach/corgi.h>
index 7f4de3df5afc8cea3e8a0e7b1c05c641d6f0178d..585970ef08cec208b3f70779f87cb85001ea5859 100644 (file)
                        CORGI_SCP_MIC_BIAS )
 #define CORGI_SCOOP_IO_OUT     ( CORGI_SCP_MUTE_L | CORGI_SCP_MUTE_R )
 
+#define CORGI_SCOOP_GPIO_BASE          (NR_BUILTIN_GPIO)
+#define CORGI_GPIO_LED_GREEN           (CORGI_SCOOP_GPIO_BASE + 0)
+#define CORGI_GPIO_SWA                 (CORGI_SCOOP_GPIO_BASE + 1)  /* Hinge Switch A */
+#define CORGI_GPIO_SWB                 (CORGI_SCOOP_GPIO_BASE + 2)  /* Hinge Switch B */
+#define CORGI_GPIO_MUTE_L              (CORGI_SCOOP_GPIO_BASE + 3)
+#define CORGI_GPIO_MUTE_R              (CORGI_SCOOP_GPIO_BASE + 4)
+#define CORGI_GPIO_AKIN_PULLUP         (CORGI_SCOOP_GPIO_BASE + 5)
+#define CORGI_GPIO_APM_ON              (CORGI_SCOOP_GPIO_BASE + 6)
+#define CORGI_GPIO_BACKLIGHT_CONT      (CORGI_SCOOP_GPIO_BASE + 7)
+#define CORGI_GPIO_MIC_BIAS            (CORGI_SCOOP_GPIO_BASE + 8)
 
 /*
  * Shared data structures
index 0a53f72077fdc97b5797960dc84e8db9177d28ce..fa69faa886efaeb8409f0d6940cd0d702fe03b1e 100644 (file)
 #include <linux/timer.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/gpio.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 
 #include <asm/mach-types.h>
-#include <asm/hardware/scoop.h>
 #include <mach/pxa-regs.h>
 #include <mach/hardware.h>
 #include <mach/corgi.h>
@@ -54,8 +54,8 @@ static void corgi_ext_control(struct snd_soc_codec *codec)
        switch (corgi_jack_func) {
        case CORGI_HP:
                /* set = unmute headphone */
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               gpio_set_value(CORGI_GPIO_MUTE_L, 1);
+               gpio_set_value(CORGI_GPIO_MUTE_R, 1);
                snd_soc_dapm_disable_pin(codec, "Mic Jack");
                snd_soc_dapm_disable_pin(codec, "Line Jack");
                snd_soc_dapm_enable_pin(codec, "Headphone Jack");
@@ -63,24 +63,24 @@ static void corgi_ext_control(struct snd_soc_codec *codec)
                break;
        case CORGI_MIC:
                /* reset = mute headphone */
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               gpio_set_value(CORGI_GPIO_MUTE_L, 0);
+               gpio_set_value(CORGI_GPIO_MUTE_R, 0);
                snd_soc_dapm_enable_pin(codec, "Mic Jack");
                snd_soc_dapm_disable_pin(codec, "Line Jack");
                snd_soc_dapm_disable_pin(codec, "Headphone Jack");
                snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case CORGI_LINE:
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               gpio_set_value(CORGI_GPIO_MUTE_L, 0);
+               gpio_set_value(CORGI_GPIO_MUTE_R, 0);
                snd_soc_dapm_disable_pin(codec, "Mic Jack");
                snd_soc_dapm_enable_pin(codec, "Line Jack");
                snd_soc_dapm_disable_pin(codec, "Headphone Jack");
                snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case CORGI_HEADSET:
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               gpio_set_value(CORGI_GPIO_MUTE_L, 0);
+               gpio_set_value(CORGI_GPIO_MUTE_R, 1);
                snd_soc_dapm_enable_pin(codec, "Mic Jack");
                snd_soc_dapm_disable_pin(codec, "Line Jack");
                snd_soc_dapm_disable_pin(codec, "Headphone Jack");
@@ -114,8 +114,8 @@ static int corgi_shutdown(struct snd_pcm_substream *substream)
        struct snd_soc_codec *codec = rtd->socdev->codec;
 
        /* set = unmute headphone */
-       set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
-       set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+       gpio_set_value(CORGI_GPIO_MUTE_L, 1);
+       gpio_set_value(CORGI_GPIO_MUTE_R, 1);
        return 0;
 }
 
@@ -218,22 +218,14 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol,
 static int corgi_amp_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *k, int event)
 {
-       if (SND_SOC_DAPM_EVENT_ON(event))
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
-       else
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
-
+       gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event));
        return 0;
 }
 
 static int corgi_mic_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *k, int event)
 {
-       if (SND_SOC_DAPM_EVENT_ON(event))
-               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS);
-       else
-               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS);
-
+       gpio_set_value(CORGI_GPIO_MIC_BIAS, SND_SOC_DAPM_EVENT_ON(event));
        return 0;
 }