Commit 6168cda9 authored by Eric Miao's avatar Eric Miao Committed by Russell King

[ARM] pxa/corgi: use generic GPIO API for SCOOP GPIOs

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: default avatarDmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: default avatarEric Miao <eric.miao@marvell.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 2d91f941
...@@ -127,6 +127,7 @@ static struct resource corgi_scoop_resources[] = { ...@@ -127,6 +127,7 @@ static struct resource corgi_scoop_resources[] = {
static struct scoop_config corgi_scoop_setup = { static struct scoop_config corgi_scoop_setup = {
.io_dir = CORGI_SCOOP_IO_DIR, .io_dir = CORGI_SCOOP_IO_DIR,
.io_out = CORGI_SCOOP_IO_OUT, .io_out = CORGI_SCOOP_IO_OUT,
.gpio_base = CORGI_SCOOP_GPIO_BASE,
}; };
struct platform_device corgiscoop_device = { struct platform_device corgiscoop_device = {
...@@ -426,10 +427,7 @@ static struct pxa2xx_spi_chip corgi_ads7846_chip = { ...@@ -426,10 +427,7 @@ static struct pxa2xx_spi_chip corgi_ads7846_chip = {
static void corgi_notify_intensity(int intensity) static void corgi_notify_intensity(int intensity)
{ {
/* Bit 5 is via SCOOP */ /* Bit 5 is via SCOOP */
if (intensity & 0x0020) gpio_set_value(CORGI_GPIO_BACKLIGHT_CONT, !!(intensity & 0x0020));
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
else
reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
} }
static void corgi_bl_kick_battery(void) static void corgi_bl_kick_battery(void)
...@@ -539,7 +537,8 @@ static void corgi_poweroff(void) ...@@ -539,7 +537,8 @@ static void corgi_poweroff(void)
{ {
if (!machine_is_corgi()) if (!machine_is_corgi())
/* Green LED off tells the bootloader to halt */ /* 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'); arm_machine_restart('h');
} }
...@@ -547,7 +546,8 @@ static void corgi_restart(char mode) ...@@ -547,7 +546,8 @@ static void corgi_restart(char mode)
{ {
if (!machine_is_corgi()) if (!machine_is_corgi())
/* Green LED on tells the bootloader to reboot */ /* 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'); arm_machine_restart('h');
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <asm/hardware/scoop.h>
#include <mach/sharpsl.h> #include <mach/sharpsl.h>
#include <mach/corgi.h> #include <mach/corgi.h>
......
...@@ -98,6 +98,16 @@ ...@@ -98,6 +98,16 @@
CORGI_SCP_MIC_BIAS ) CORGI_SCP_MIC_BIAS )
#define CORGI_SCOOP_IO_OUT ( CORGI_SCP_MUTE_L | CORGI_SCP_MUTE_R ) #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 * Shared data structures
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/gpio.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/hardware/scoop.h>
#include <mach/pxa-regs.h> #include <mach/pxa-regs.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <mach/corgi.h> #include <mach/corgi.h>
...@@ -54,8 +54,8 @@ static void corgi_ext_control(struct snd_soc_codec *codec) ...@@ -54,8 +54,8 @@ static void corgi_ext_control(struct snd_soc_codec *codec)
switch (corgi_jack_func) { switch (corgi_jack_func) {
case CORGI_HP: case CORGI_HP:
/* set = unmute headphone */ /* set = unmute headphone */
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); gpio_set_value(CORGI_GPIO_MUTE_L, 1);
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); gpio_set_value(CORGI_GPIO_MUTE_R, 1);
snd_soc_dapm_disable_pin(codec, "Mic Jack"); snd_soc_dapm_disable_pin(codec, "Mic Jack");
snd_soc_dapm_disable_pin(codec, "Line Jack"); snd_soc_dapm_disable_pin(codec, "Line Jack");
snd_soc_dapm_enable_pin(codec, "Headphone Jack"); snd_soc_dapm_enable_pin(codec, "Headphone Jack");
...@@ -63,24 +63,24 @@ static void corgi_ext_control(struct snd_soc_codec *codec) ...@@ -63,24 +63,24 @@ static void corgi_ext_control(struct snd_soc_codec *codec)
break; break;
case CORGI_MIC: case CORGI_MIC:
/* reset = mute headphone */ /* reset = mute headphone */
reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); gpio_set_value(CORGI_GPIO_MUTE_L, 0);
reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); gpio_set_value(CORGI_GPIO_MUTE_R, 0);
snd_soc_dapm_enable_pin(codec, "Mic Jack"); snd_soc_dapm_enable_pin(codec, "Mic Jack");
snd_soc_dapm_disable_pin(codec, "Line Jack"); snd_soc_dapm_disable_pin(codec, "Line Jack");
snd_soc_dapm_disable_pin(codec, "Headphone Jack"); snd_soc_dapm_disable_pin(codec, "Headphone Jack");
snd_soc_dapm_disable_pin(codec, "Headset Jack"); snd_soc_dapm_disable_pin(codec, "Headset Jack");
break; break;
case CORGI_LINE: case CORGI_LINE:
reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); gpio_set_value(CORGI_GPIO_MUTE_L, 0);
reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); gpio_set_value(CORGI_GPIO_MUTE_R, 0);
snd_soc_dapm_disable_pin(codec, "Mic Jack"); snd_soc_dapm_disable_pin(codec, "Mic Jack");
snd_soc_dapm_enable_pin(codec, "Line Jack"); snd_soc_dapm_enable_pin(codec, "Line Jack");
snd_soc_dapm_disable_pin(codec, "Headphone Jack"); snd_soc_dapm_disable_pin(codec, "Headphone Jack");
snd_soc_dapm_disable_pin(codec, "Headset Jack"); snd_soc_dapm_disable_pin(codec, "Headset Jack");
break; break;
case CORGI_HEADSET: case CORGI_HEADSET:
reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); gpio_set_value(CORGI_GPIO_MUTE_L, 0);
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); gpio_set_value(CORGI_GPIO_MUTE_R, 1);
snd_soc_dapm_enable_pin(codec, "Mic Jack"); snd_soc_dapm_enable_pin(codec, "Mic Jack");
snd_soc_dapm_disable_pin(codec, "Line Jack"); snd_soc_dapm_disable_pin(codec, "Line Jack");
snd_soc_dapm_disable_pin(codec, "Headphone Jack"); snd_soc_dapm_disable_pin(codec, "Headphone Jack");
...@@ -114,8 +114,8 @@ static int corgi_shutdown(struct snd_pcm_substream *substream) ...@@ -114,8 +114,8 @@ static int corgi_shutdown(struct snd_pcm_substream *substream)
struct snd_soc_codec *codec = rtd->socdev->codec; struct snd_soc_codec *codec = rtd->socdev->codec;
/* set = unmute headphone */ /* set = unmute headphone */
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); gpio_set_value(CORGI_GPIO_MUTE_L, 1);
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); gpio_set_value(CORGI_GPIO_MUTE_R, 1);
return 0; return 0;
} }
...@@ -218,22 +218,14 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol, ...@@ -218,22 +218,14 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol,
static int corgi_amp_event(struct snd_soc_dapm_widget *w, static int corgi_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
if (SND_SOC_DAPM_EVENT_ON(event)) gpio_set_value(CORGI_GPIO_APM_ON, 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);
return 0; return 0;
} }
static int corgi_mic_event(struct snd_soc_dapm_widget *w, static int corgi_mic_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
if (SND_SOC_DAPM_EVENT_ON(event)) gpio_set_value(CORGI_GPIO_MIC_BIAS, 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);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment