[PATCH] From: Andy Green <andy at openmoko.com>
Andy Green
andy at openmoko.com
Wed Apr 2 22:03:56 CEST 2008
add-lis302dl-gta02-a6-int1-only.patch
A6 uses int1 only and no pullup, adapt according to PCB revision
Signed-off-by: Andy Green <andy at openmoko.com>
---
arch/arm/mach-s3c2440/mach-gta02.c | 17 +++++++++++++++--
drivers/input/misc/lis302dl.c | 11 ++++++++---
include/linux/lis302dl.h | 1 +
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index 253bde0..3829bb5 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -968,13 +968,14 @@ void gat02_lis302dl_suspend_io(struct lis302dl_info *lis, int resume)
s3c2410_gpio_pullup(pdata->pin_miso, 0);
}
-const struct lis302dl_platform_data lis302_pdata[] = {
+struct lis302dl_platform_data lis302_pdata[] = {
{
.name = "lis302-1 (top)",
.pin_chip_select= S3C2410_GPD12,
.pin_clk = S3C2410_GPG7,
.pin_mosi = S3C2410_GPG6,
.pin_miso = S3C2410_GPG5,
+ .open_drain = 1, /* altered at runtime by PCB rev */
.lis302dl_bitbang_read = gat02_lis302dl_bitbang_read,
.lis302dl_suspend_io = gat02_lis302dl_suspend_io,
}, {
@@ -983,6 +984,7 @@ const struct lis302dl_platform_data lis302_pdata[] = {
.pin_clk = S3C2410_GPG7,
.pin_mosi = S3C2410_GPG6,
.pin_miso = S3C2410_GPG5,
+ .open_drain = 1, /* altered at runtime by PCB rev */
.lis302dl_bitbang_read = gat02_lis302dl_bitbang_read,
.lis302dl_suspend_io = gat02_lis302dl_suspend_io,
},
@@ -1306,8 +1308,19 @@ static irqreturn_t gta02_modem_irq(int irq, void *param)
static void __init gta02_machine_init(void)
{
int rc;
+ int revision = gta02_get_pcb_revision();
- printk(KERN_INFO"GTA02 PCB rev = 0x%03X\n", gta02_get_pcb_revision());
+ printk(KERN_INFO"GTA02 PCB rev = 0x%03X\n", revision);
+
+ switch (revision) {
+ case 0x001: /* GTA02 A6 */
+ /* we need push-pull interrupt from motion sensors */
+ lis302_pdata[0].open_drain = 0;
+ lis302_pdata[1].open_drain = 0;
+ break;
+ default:
+ break;
+ }
spin_lock_init(&motion_irq_lock);
diff --git a/drivers/input/misc/lis302dl.c b/drivers/input/misc/lis302dl.c
index 32b307f..2be816a 100644
--- a/drivers/input/misc/lis302dl.c
+++ b/drivers/input/misc/lis302dl.c
@@ -357,9 +357,14 @@ static int __devinit lis302dl_probe(struct spi_device *spi)
LIS302DL_CTRL1_Yen |
LIS302DL_CTRL1_Zen);
- /* switch interrupt to open collector, active-low */
- reg_write(lis, LIS302DL_REG_CTRL3, LIS302DL_CTRL3_PP_OD |
- LIS302DL_CTRL3_IHL);
+ if (pdata->open_drain)
+ /* switch interrupt to open collector, active-low */
+ reg_write(lis, LIS302DL_REG_CTRL3, LIS302DL_CTRL3_PP_OD |
+ LIS302DL_CTRL3_IHL);
+ else
+ /* push-pull, active-low */
+ reg_write(lis, LIS302DL_REG_CTRL3, LIS302DL_CTRL3_IHL);
+
lis302dl_int_mode(spi, 1, LIS302DL_INTMODE_DATA_READY);
lis302dl_int_mode(spi, 2, LIS302DL_INTMODE_DATA_READY);
diff --git a/include/linux/lis302dl.h b/include/linux/lis302dl.h
index 06bc1cf..0d6b4c4 100644
--- a/include/linux/lis302dl.h
+++ b/include/linux/lis302dl.h
@@ -14,6 +14,7 @@ struct lis302dl_platform_data {
unsigned long pin_clk;
unsigned long pin_mosi;
unsigned long pin_miso;
+ int open_drain;
void (*lis302dl_bitbang_read)(struct lis302dl_info *);
void (*lis302dl_suspend_io)(struct lis302dl_info *, int resuming);
};
More information about the openmoko-kernel
mailing list