Commit fff14720 authored by Eric Miao's avatar Eric Miao Committed by Russell King

[ARM] pxa/spitz: use generic GPIO API for SCOOP1/SCOOP2 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 60cf711d
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#endif #endif
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/gpio.h>
/* Spitz/Akita GPIOs */ /* Spitz/Akita GPIOs */
...@@ -107,6 +108,17 @@ ...@@ -107,6 +108,17 @@
#define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON) #define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON)
#define SPITZ_SCP_SUS_SET 0 #define SPITZ_SCP_SUS_SET 0
#define SPITZ_SCP_GPIO_BASE (NR_BUILTIN_GPIO)
#define SPITZ_GPIO_LED_GREEN (SPITZ_SCP_GPIO_BASE + 0)
#define SPITZ_GPIO_JK_B (SPITZ_SCP_GPIO_BASE + 1)
#define SPITZ_GPIO_CHRG_ON (SPITZ_SCP_GPIO_BASE + 2)
#define SPITZ_GPIO_MUTE_L (SPITZ_SCP_GPIO_BASE + 3)
#define SPITZ_GPIO_MUTE_R (SPITZ_SCP_GPIO_BASE + 4)
#define SPITZ_GPIO_CF_POWER (SPITZ_SCP_GPIO_BASE + 5)
#define SPITZ_GPIO_LED_ORANGE (SPITZ_SCP_GPIO_BASE + 6)
#define SPITZ_GPIO_JK_A (SPITZ_SCP_GPIO_BASE + 7)
#define SPITZ_GPIO_ADC_TEMP_ON (SPITZ_SCP_GPIO_BASE + 8)
/* Spitz Scoop Device (No. 2) GPIOs */ /* Spitz Scoop Device (No. 2) GPIOs */
/* Suspend States in comments */ /* Suspend States in comments */
#define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */ #define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */
...@@ -128,6 +140,16 @@ ...@@ -128,6 +140,16 @@
SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS) SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS)
#define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1) #define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1)
#define SPITZ_SCP2_GPIO_BASE (NR_BUILTIN_GPIO + 12)
#define SPITZ_GPIO_IR_ON (SPITZ_SCP2_GPIO_BASE + 0)
#define SPITZ_GPIO_AKIN_PULLUP (SPITZ_SCP2_GPIO_BASE + 1
#define SPITZ_GPIO_RESERVED_1 (SPITZ_SCP2_GPIO_BASE + 2)
#define SPITZ_GPIO_RESERVED_2 (SPITZ_SCP2_GPIO_BASE + 3)
#define SPITZ_GPIO_RESERVED_3 (SPITZ_SCP2_GPIO_BASE + 4)
#define SPITZ_GPIO_RESERVED_4 (SPITZ_SCP2_GPIO_BASE + 5)
#define SPITZ_GPIO_BACKLIGHT_CONT (SPITZ_SCP2_GPIO_BASE + 6)
#define SPITZ_GPIO_BACKLIGHT_ON (SPITZ_SCP2_GPIO_BASE + 7)
#define SPITZ_GPIO_MIC_BIAS (SPITZ_SCP2_GPIO_BASE + 8)
/* Spitz IRQ Definitions */ /* Spitz IRQ Definitions */
......
...@@ -134,10 +134,11 @@ static struct resource spitz_scoop_resources[] = { ...@@ -134,10 +134,11 @@ static struct resource spitz_scoop_resources[] = {
}; };
static struct scoop_config spitz_scoop_setup = { static struct scoop_config spitz_scoop_setup = {
.io_dir = SPITZ_SCP_IO_DIR, .io_dir = SPITZ_SCP_IO_DIR,
.io_out = SPITZ_SCP_IO_OUT, .io_out = SPITZ_SCP_IO_OUT,
.suspend_clr = SPITZ_SCP_SUS_CLR, .suspend_clr = SPITZ_SCP_SUS_CLR,
.suspend_set = SPITZ_SCP_SUS_SET, .suspend_set = SPITZ_SCP_SUS_SET,
.gpio_base = SPITZ_SCP_GPIO_BASE,
}; };
struct platform_device spitzscoop_device = { struct platform_device spitzscoop_device = {
...@@ -162,10 +163,11 @@ static struct resource spitz_scoop2_resources[] = { ...@@ -162,10 +163,11 @@ static struct resource spitz_scoop2_resources[] = {
}; };
static struct scoop_config spitz_scoop2_setup = { static struct scoop_config spitz_scoop2_setup = {
.io_dir = SPITZ_SCP2_IO_DIR, .io_dir = SPITZ_SCP2_IO_DIR,
.io_out = SPITZ_SCP2_IO_OUT, .io_out = SPITZ_SCP2_IO_OUT,
.suspend_clr = SPITZ_SCP2_SUS_CLR, .suspend_clr = SPITZ_SCP2_SUS_CLR,
.suspend_set = SPITZ_SCP2_SUS_SET, .suspend_set = SPITZ_SCP2_SUS_SET,
.gpio_base = SPITZ_SCP2_GPIO_BASE,
}; };
struct platform_device spitzscoop2_device = { struct platform_device spitzscoop2_device = {
...@@ -187,7 +189,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) ...@@ -187,7 +189,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
if (new_cpr & 0x0007) { if (new_cpr & 0x0007) {
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
if (!(cpr & 0x0002) && !(cpr & 0x0004)) if (!(cpr & 0x0002) && !(cpr & 0x0004))
mdelay(5); mdelay(5);
if (device == SPITZ_PWR_CF) if (device == SPITZ_PWR_CF)
...@@ -203,7 +205,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) ...@@ -203,7 +205,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
if (!(cpr & 0x0002) && !(cpr & 0x0004)) { if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
mdelay(1); mdelay(1);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
} else { } else {
write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
} }
...@@ -283,16 +285,8 @@ static struct pxa2xx_spi_chip spitz_ads7846_chip = { ...@@ -283,16 +285,8 @@ static struct pxa2xx_spi_chip spitz_ads7846_chip = {
static void spitz_notify_intensity(int intensity) static void spitz_notify_intensity(int intensity)
{ {
if (machine_is_spitz() || machine_is_borzoi()) { if (machine_is_spitz() || machine_is_borzoi()) {
/* Bit 5 is via SCOOP */ gpio_set_value(SPITZ_GPIO_BACKLIGHT_CONT, !(intensity & 0x20));
if (intensity & 0x0020) gpio_set_value(SPITZ_GPIO_BACKLIGHT_ON, intensity);
reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
else
set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
if (intensity)
set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
else
reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
return; return;
} }
...@@ -515,12 +509,34 @@ static struct pxaohci_platform_data spitz_ohci_platform_data = { ...@@ -515,12 +509,34 @@ static struct pxaohci_platform_data spitz_ohci_platform_data = {
/* /*
* Irda * Irda
*/ */
static int spitz_irda_startup(struct device *dev)
{
int rc;
rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
if (rc)
goto err;
rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
if (rc)
goto err_dir;
return 0;
err_dir:
gpio_free(SPITZ_GPIO_IR_ON);
err:
return rc;
}
static void spitz_irda_shutdown(struct device *dev)
{
gpio_free(SPITZ_GPIO_IR_ON);
}
static void spitz_irda_transceiver_mode(struct device *dev, int mode) static void spitz_irda_transceiver_mode(struct device *dev, int mode)
{ {
if (mode & IR_OFF) gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
else
reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
pxa2xx_transceiver_mode(dev, mode); pxa2xx_transceiver_mode(dev, mode);
} }
...@@ -536,8 +552,10 @@ static void akita_irda_transceiver_mode(struct device *dev, int mode) ...@@ -536,8 +552,10 @@ static void akita_irda_transceiver_mode(struct device *dev, int mode)
#endif #endif
static struct pxaficp_platform_data spitz_ficp_platform_data = { static struct pxaficp_platform_data spitz_ficp_platform_data = {
.transceiver_cap = IR_SIRMODE | IR_OFF, .transceiver_cap = IR_SIRMODE | IR_OFF,
.transceiver_mode = spitz_irda_transceiver_mode, .transceiver_mode = spitz_irda_transceiver_mode,
.startup = spitz_irda_startup,
.shutdown = spitz_irda_shutdown,
}; };
......
...@@ -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/spitz.h> #include <mach/spitz.h>
...@@ -48,44 +47,35 @@ static void spitz_charger_init(void) ...@@ -48,44 +47,35 @@ static void spitz_charger_init(void)
static void spitz_measure_temp(int on) static void spitz_measure_temp(int on)
{ {
if (on) gpio_set_value(SPITZ_GPIO_ADC_TEMP_ON, on);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
else
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
} }
static void spitz_charge(int on) static void spitz_charge(int on)
{ {
if (on) { if (on) {
if (sharpsl_pm.flags & SHARPSL_SUSPENDED) { if (sharpsl_pm.flags & SHARPSL_SUSPENDED) {
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); gpio_set_value(SPITZ_GPIO_JK_B, 1);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
} else { } else {
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); gpio_set_value(SPITZ_GPIO_JK_B, 0);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
} }
} else { } else {
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); gpio_set_value(SPITZ_GPIO_JK_B, 0);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); gpio_set_value(SPITZ_GPIO_CHRG_ON, 1);
} }
} }
static void spitz_discharge(int on) static void spitz_discharge(int on)
{ {
if (on) gpio_set_value(SPITZ_GPIO_JK_A, on);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
else
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
} }
/* HACK - For unknown reasons, accurate voltage readings are only made with a load /* HACK - For unknown reasons, accurate voltage readings are only made with a load
on the power bus which the green led on spitz provides */ on the power bus which the green led on spitz provides */
static void spitz_discharge1(int on) static void spitz_discharge1(int on)
{ {
if (on) gpio_set_value(SPITZ_GPIO_LED_GREEN, on);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
else
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
} }
static void spitz_presuspend(void) static void spitz_presuspend(void)
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,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/akita.h> #include <mach/akita.h>
...@@ -63,8 +63,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec) ...@@ -63,8 +63,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec)
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");
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); gpio_set_value(SPITZ_GPIO_MUTE_L, 1);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
break; break;
case SPITZ_MIC: case SPITZ_MIC:
/* enable mic jack and bias, mute hp */ /* enable mic jack and bias, mute hp */
...@@ -72,8 +72,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec) ...@@ -72,8 +72,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec)
snd_soc_dapm_disable_pin(codec, "Headset Jack"); snd_soc_dapm_disable_pin(codec, "Headset Jack");
snd_soc_dapm_disable_pin(codec, "Line Jack"); snd_soc_dapm_disable_pin(codec, "Line Jack");
snd_soc_dapm_enable_pin(codec, "Mic Jack"); snd_soc_dapm_enable_pin(codec, "Mic Jack");
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
break; break;
case SPITZ_LINE: case SPITZ_LINE:
/* enable line jack, disable mic bias and mute hp */ /* enable line jack, disable mic bias and mute hp */
...@@ -81,8 +81,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec) ...@@ -81,8 +81,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec)
snd_soc_dapm_disable_pin(codec, "Headset Jack"); snd_soc_dapm_disable_pin(codec, "Headset Jack");
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");
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
break; break;
case SPITZ_HEADSET: case SPITZ_HEADSET:
/* enable and unmute headset jack enable mic bias, mute L hp */ /* enable and unmute headset jack enable mic bias, mute L hp */
...@@ -90,8 +90,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec) ...@@ -90,8 +90,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec)
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_enable_pin(codec, "Headset Jack"); snd_soc_dapm_enable_pin(codec, "Headset Jack");
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
break; break;
case SPITZ_HP_OFF: case SPITZ_HP_OFF:
...@@ -100,8 +100,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec) ...@@ -100,8 +100,8 @@ static void spitz_ext_control(struct snd_soc_codec *codec)
snd_soc_dapm_disable_pin(codec, "Headset Jack"); snd_soc_dapm_disable_pin(codec, "Headset Jack");
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");
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L); gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R); gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
break; break;
} }
snd_soc_dapm_sync(codec); snd_soc_dapm_sync(codec);
...@@ -215,14 +215,9 @@ static int spitz_set_spk(struct snd_kcontrol *kcontrol, ...@@ -215,14 +215,9 @@ static int spitz_set_spk(struct snd_kcontrol *kcontrol,
static int spitz_mic_bias(struct snd_soc_dapm_widget *w, static int spitz_mic_bias(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
if (machine_is_borzoi() || machine_is_spitz()) { if (machine_is_borzoi() || machine_is_spitz())
if (SND_SOC_DAPM_EVENT_ON(event)) gpio_set_value(SPITZ_GPIO_MIC_BIAS,
set_scoop_gpio(&spitzscoop2_device.dev, SND_SOC_DAPM_EVENT_ON(event));
SPITZ_SCP2_MIC_BIAS);
else
reset_scoop_gpio(&spitzscoop2_device.dev,
SPITZ_SCP2_MIC_BIAS);
}
if (machine_is_akita()) { if (machine_is_akita()) {
if (SND_SOC_DAPM_EVENT_ON(event)) if (SND_SOC_DAPM_EVENT_ON(event))
......
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