Messages in this thread Patches in this message | | | Date | Fri, 16 Feb 2007 18:37:07 +0100 | From | Nicolas Ferre <> | Subject | [PATCH] input/spi: add ads7843 support to ads7846 touchscreen driver |
| |
David Brownell : [..] > Thanks! I'll be glad to see fewer versions of this driver floating around. > And to see the next version of the ads7843 patches ... :)
Hi,
Here is the ads7843 support for the ads7846 touchscreen driver. It is very little and takes great advantage of the previous rework.
Tested on Atmel at91sam926[13]ek board with atmel_spi underlying driver.
I also put a use case based on the at91sam9263ek init code. This code is just sent as an example, I will send those init patches trough AT91 maintainer.
Index: linux-2.6.20-at91/drivers/input/touchscreen/ads7846.c =================================================================== --- linux-2.6.20-at91.orig/drivers/input/touchscreen/ads7846.c +++ linux-2.6.20-at91/drivers/input/touchscreen/ads7846.c @@ -39,7 +39,8 @@ /* * This code has been heavily tested on a Nokia 770, and lightly * tested on other ads7846 devices (OSK/Mistral, Lubbock). - * Support for ads7843 and ads7845 has only been stubbed in. + * Support for ads7843 tested on Atmel at91sam926x-EK. + * Support for ads7845 has only been stubbed in. * * IRQ handling needs a workaround because of a shortcoming in handling * edge triggered IRQs on some platforms like the OMAP1/2. These @@ -246,18 +247,15 @@ static int ads7846_read12_ser(struct dev /* REVISIT: take a few more samples, and compare ... */ - /* maybe off internal vREF */ - if (use_internal) { - req->ref_off = REF_OFF; - req->xfer[4].tx_buf = &req->ref_off; - req->xfer[4].len = 1; - spi_message_add_tail(&req->xfer[4], &req->msg); - - req->xfer[5].rx_buf = &req->scratch; - req->xfer[5].len = 2; - CS_CHANGE(req->xfer[5]); - spi_message_add_tail(&req->xfer[5], &req->msg); - } + req->ref_off = REF_OFF; + req->xfer[4].tx_buf = &req->ref_off; + req->xfer[4].len = 1; + spi_message_add_tail(&req->xfer[4], &req->msg); + + req->xfer[5].rx_buf = &req->scratch; + req->xfer[5].len = 2; + CS_CHANGE(req->xfer[5]); + spi_message_add_tail(&req->xfer[5], &req->msg); ts->irq_disabled = 1; disable_irq(spi->irq); @@ -536,6 +534,10 @@ static void ads7846_rx(void *ads) } else Rt = 0; + if (ts->model == 7843) + Rt = ts->pressure_max / 2; + + /* Sample found inconsistent by debouncing or pressure is beyond * the maximum. Don't report it to user space, repeat at least * once more the measurement
Index: linux-2.6.20-at91/arch/arm/mach-at91rm9200/board-sam9263ek.c =================================================================== --- linux-2.6.20-at91.orig/arch/arm/mach-at91rm9200/board-sam9263ek.c +++ linux-2.6.20-at91/arch/arm/mach-at91rm9200/board-sam9263ek.c @@ -25,6 +25,7 @@ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/spi/spi.h> +#include <linux/spi/ads7846.h> #include <asm/hardware.h> #include <asm/setup.h> @@ -84,6 +85,40 @@ static struct at91_udc_data __initdata e .pullup_pin = 0, /* pull-up driven by UDC */ }; +/* + * Touchscreen ads7843 + */ +#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) + +int ads7843_pendown_state(void) +{ + return !at91_get_gpio_value(AT91_PIN_PA15); +} + +static struct ads7846_platform_data ads_info = { + .model = 7843, + .x_min = 150, .x_max = 3830, + .y_min = 190, .y_max = 3830, + .vref_delay_usecs = 100, + .x_plate_ohms = 450, + .y_plate_ohms = 250, + .pressure_max = 15000, + .debounce_max = 1, + .debounce_rep = 0, + .debounce_tol = (~0), + .get_pendown_state = ads7843_pendown_state, +}; + +void __init at91_add_device_ts(void) +{ + /* Configure Interrupt 1 as external IRQ, with pullup */ + at91_set_B_periph(AT91_PIN_PA15, 1); /* IRQ1 */ + /* ts busy */ + at91_set_gpio_input(AT91_PIN_PA31, 1); +} +#else +void __init at91_add_device_ts(void) {} +#endif /* * SPI devices. @@ -97,6 +132,17 @@ static struct spi_board_info ek_spi_devi .bus_num = 0, }, #endif +#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) + { + .modalias = "ads7846", + .chip_select = 3, + .max_speed_hz = 125000 /* max sample rate at 3V */ + * 26, /* command + data + overhead */ + .bus_num = 0, + .platform_data = &ads_info, + .irq = AT91SAM9263_ID_IRQ1, + }, +#endif }; @@ -164,6 +210,8 @@ static void __init ek_board_init(void) at91_add_device_mmc(1, &ek_mmc_data); /* NAND */ at91_add_device_nand(&ek_nand_data); + /* Touchscreen */ + at91_add_device_ts(); } MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |