|
Edited by Jacaranda at 2015-10-19 18:53
You need compile ADS7846 touchscreen as a module.
fex:- [spi0]
- spi_used = 1
- spi_cs_bitmap = 1
- spi_mosi = port:PC00<3><default><default><default>
- spi_miso = port:PC01<3><default><default><default>
- spi_sclk = port:PC02<3><default><default><default>
- spi_cs0 = port:PA21<1><1><default><default>
- [spi_devices]
- spi_dev_num = 1
- [spi_board0]
- modalias = "ads7846"
- max_speed_hz = 1500000
- bus_num = 0
- chip_select = 0
- mode = 0
- full_duplex = 1
- manual_cs = 0
Copy code
drivers/input/touchscreen/ads7846.c:
- diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads
- index f02028e..0a3f610 100644
- --- a/drivers/input/touchscreen/ads7846.c
- +++ b/drivers/input/touchscreen/ads7846.c
- @@ -59,6 +59,22 @@
- #define TS_POLL_DELAY 1 /* ms delay before the first sample */
- #define TS_POLL_PERIOD 5 /* ms delay between samples */
-
- +
- +static struct ads7846_platform_data ads7846_chip_info =
- +{
- + .gpio_pendown = 2,
- + .pressure_max = 255,
- + .x_plate_ohms = 180,
- + .x_min = 176,
- + .x_max = 3913,
- + .y_min = 300,
- + .y_max = 3947,
- + .debounce_max = 10,
- + .debounce_tol = 3,
- + .debounce_rep = 1,
- + .keep_vref_on = 1
- +};
- +
- /* this driver doesn't aim at the peak continuous sample rate */
- #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after
-
- @@ -970,6 +986,7 @@ static int __devinit ads7846_setup_pendown(struct spi_device
- ts->get_pendown_state = pdata->get_pendown_state;
- } else if (gpio_is_valid(pdata->gpio_pendown)) {
-
- + // try to get gpio for pendown
- err = gpio_request_one(pdata->gpio_pendown, GPIOF_IN,
- "ads7846_pendown");
- if (err) {
- @@ -1197,17 +1214,27 @@ static int __devinit ads7846_probe(struct spi_device *sp
- struct ads7846 *ts;
- struct ads7846_packet *packet;
- struct input_dev *input_dev;
- +
- + if (!spi->dev.platform_data) {
- + spi->dev.platform_data = &ads7846_chip_info;
- + }
- +
- struct ads7846_platform_data *pdata = spi->dev.platform_data;
- unsigned long irq_flags;
- int err;
-
- - if (!spi->irq) {
- - dev_dbg(&spi->dev, "no IRQ?\n");
- + if (!pdata) {
- + dev_dbg(&spi->dev, "no platform data?\n");
- return -ENODEV;
- }
-
- - if (!pdata) {
- - dev_dbg(&spi->dev, "no platform data?\n");
- + // try to grab irq for pendown
- + if (pdata->gpio_pendown) {
- + spi->irq = gpio_to_irq(pdata->gpio_pendown);
- + }
- +
- + if (!spi->irq) {
- + dev_dbg(&spi->dev, "no IRQ?\n");
- return -ENODEV;
- }
-
Copy code
worked with PA21 - CS0 and PA02 - IRQ pendown.
Need some trics with platform_data, touch worked but no so cool.
|
|