/*
- * drivers/input/touchscreen/xpt2046_ts.c - driver for rk2818 spi xpt2046 device and console
+ * drivers/input/touchscreen/xpt2046_ts.c - driver for rk29 spi xpt2046 device and console
*
- * Copyright (C) 2010 ROCKCHIP, Inc.
+ * Copyright (C) 2011 ROCKCHIP, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
struct spi_transfer xfer[4];
};
-static struct xpt2046_platform_data xpt2046_info = {
- .model = 2046,
- .keep_vref_on = 1,
- .swap_xy = 0,
- .x_min = 0,
- .x_max = 320,
- .y_min = 0,
- .y_max = 480,
- .debounce_max = 7,
- .debounce_rep = DEBOUNCE_REPTIME,
- .debounce_tol = 20,
- .gpio_pendown = RK2818_PIN_PE1,//RK2818_PIN_PE3, //modify by zhao
- .penirq_recheck_delay_usecs = 1,
-
-};
-
//add by zhao
#define LEN_TO_PIX(x) (unsigned int)( 320 * (x) / 47 )
#define KEY1_X 6.3
{KEY1_LEFT, KEY1_RIGHT, KEY_HOME, 0},
{KEY2_LEFT, KEY2_RIGHT, KEY_MENU, 0},
{KEY3_LEFT, KEY3_RIGHT, KEY_BACK, 0},
-{KEY4_LEFT, KEY4_RIGHT, KEY_FIND, 0},
+{KEY4_LEFT, KEY4_RIGHT, KEY_SEARCH, 0},
};
//end by zhao
static void xpt2046_rx(void *xpt)
{
- struct xpt2046 *ts = xpt;
+ struct xpt2046 *ts = xpt;
+ struct xpt2046_platform_data *pdata = ts->spi->dev.platform_data;
struct xpt2046_packet *packet = ts->packet;
unsigned Rt = 1;
u16 x, y;
}
}
- else if (y <= xpt2046_info.y_max)
+ else if (y <= pdata->y_max)
{
if (!ts->pendown) {
input_report_key(input, BTN_TOUCH, 1);
ts->get_pendown_state = pdata->get_pendown_state;
return 0;
}
-
+
+ if (pdata->io_init) {
+ err = pdata->io_init();
+ if (err)
+ dev_err(&spi->dev, "xpt2046 io_init fail\n");
+ }
+
err = gpio_request(pdata->gpio_pendown, "xpt2046_pendown");
if (err) {
dev_err(&spi->dev, "failed to request pendown GPIO%d\n",
return err;
}
+ err = gpio_direction_input(pdata->gpio_pendown);
+ if (err) {
+ dev_err(&spi->dev, "failed to switch GPIO to input%d\n",
+ pdata->gpio_pendown);
+ return err;
+ }
+
+ gpio_pull_updown(pdata->gpio_pendown,GPIOPullUp);
+
ts->gpio_pendown = pdata->gpio_pendown;
return 0;
}
spi->irq = gpio_to_irq(spi->irq);
dev_dbg(&spi->dev, "no IRQ?\n");
}
-
- if (!pdata) {
- xpt2046printk("-----------------pdata is null -------------------------\n");
- spi->dev.platform_data = &xpt2046_info;
- pdata = spi->dev.platform_data;
- }
+
+ if (!pdata) {
+ dev_err(&spi->dev, "empty platform_data\n");
+ return -EFAULT;
+ }
/* don't exceed max specified sample rate */
if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
ts->filter_cleanup = pdata->filter_cleanup;
} else if (pdata->debounce_max) {
ts->debounce_max = pdata->debounce_max;
- if (ts->debounce_max < DEBOUNCE_REPTIME)
- ts->debounce_max = DEBOUNCE_REPTIME;
+ if (ts->debounce_max < pdata->debounce_rep)
+ ts->debounce_max = pdata->debounce_rep;
ts->debounce_tol = pdata->debounce_tol;
ts->debounce_rep = pdata->debounce_rep;
ts->filter = xpt2046_debounce;
{
return spi_register_driver(&xpt2046_driver);
}
-module_init(xpt2046_init);
+late_initcall_sync(xpt2046_init);
static void __exit xpt2046_exit(void)
{