Lines Matching +full:flip +full:- +full:chip
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson
140 * struct bu21013_ts_data - touch panel data structure
144 * @chip: pointer to the touch panel controller
154 const struct bu21013_platform_device *chip; member
163 * bu21013_read_block_data(): read the touch co-ordinates
167 * Read the touch co-ordinates using i2c read block into buffer
176 (data->client, BU21013_SENSORS_BTN_0_7_REG, in bu21013_read_block_data()
181 return -EINVAL; in bu21013_read_block_data()
185 * bu21013_do_touch_report(): Get the touch co-ordinates
188 * Get the touch co-ordinates from touch sensor registers and writes
200 return -EINVAL; in bu21013_do_touch_report()
203 return -EINVAL; in bu21013_do_touch_report()
224 (abs(pos_x[0] - pos_x[1]) < DELTA_MIN || in bu21013_do_touch_report()
225 abs(pos_y[0] - pos_y[1]) < DELTA_MIN)) { in bu21013_do_touch_report()
230 if (data->chip->x_flip) in bu21013_do_touch_report()
231 pos_x[i] = data->chip->touch_x_max - pos_x[i]; in bu21013_do_touch_report()
232 if (data->chip->y_flip) in bu21013_do_touch_report()
233 pos_y[i] = data->chip->touch_y_max - pos_y[i]; in bu21013_do_touch_report()
235 input_report_abs(data->in_dev, in bu21013_do_touch_report()
237 input_report_abs(data->in_dev, in bu21013_do_touch_report()
239 input_mt_sync(data->in_dev); in bu21013_do_touch_report()
242 input_mt_sync(data->in_dev); in bu21013_do_touch_report()
244 input_sync(data->in_dev); in bu21013_do_touch_report()
249 * bu21013_gpio_irq() - gpio thread function for touch interrupt
259 struct i2c_client *i2c = data->client; in bu21013_gpio_irq()
265 dev_err(&i2c->dev, "bu21013_do_touch_report failed\n"); in bu21013_gpio_irq()
269 data->intr_pin = gpio_get_value(data->chip->touch_pin); in bu21013_gpio_irq()
270 if (data->intr_pin == PEN_DOWN_INTR) in bu21013_gpio_irq()
271 wait_event_timeout(data->wait, data->touch_stopped, in bu21013_gpio_irq()
273 } while (!data->intr_pin && !data->touch_stopped); in bu21013_gpio_irq()
279 * bu21013_init_chip() - power on sequence for the bu21013 controller
288 struct i2c_client *i2c = data->client; in bu21013_init_chip()
293 dev_err(&i2c->dev, "BU21013_RESET reg write failed\n"); in bu21013_init_chip()
301 dev_err(&i2c->dev, "BU21013_SENSOR_0_7 reg write failed\n"); in bu21013_init_chip()
308 dev_err(&i2c->dev, "BU21013_SENSOR_8_15 reg write failed\n"); in bu21013_init_chip()
315 dev_err(&i2c->dev, "BU21013_SENSOR_16_23 reg write failed\n"); in bu21013_init_chip()
322 dev_err(&i2c->dev, "BU21013_POS_MODE1 reg write failed\n"); in bu21013_init_chip()
331 dev_err(&i2c->dev, "BU21013_POS_MODE2 reg write failed\n"); in bu21013_init_chip()
335 if (data->chip->ext_clk) in bu21013_init_chip()
342 dev_err(&i2c->dev, "BU21013_CLK_MODE reg write failed\n"); in bu21013_init_chip()
349 dev_err(&i2c->dev, "BU21013_IDLE reg write failed\n"); in bu21013_init_chip()
356 dev_err(&i2c->dev, "BU21013_INT_MODE reg write failed\n"); in bu21013_init_chip()
364 dev_err(&i2c->dev, "BU21013_FILTER reg write failed\n"); in bu21013_init_chip()
371 dev_err(&i2c->dev, "BU21013_TH_ON reg write failed\n"); in bu21013_init_chip()
378 dev_err(&i2c->dev, "BU21013_TH_OFF reg write failed\n"); in bu21013_init_chip()
385 dev_err(&i2c->dev, "BU21013_GAIN reg write failed\n"); in bu21013_init_chip()
392 dev_err(&i2c->dev, "BU21013_OFFSET_MODE reg write failed\n"); in bu21013_init_chip()
400 dev_err(&i2c->dev, "BU21013_XY_EDGE reg write failed\n"); in bu21013_init_chip()
407 dev_err(&i2c->dev, "BU21013_REG_DONE reg write failed\n"); in bu21013_init_chip()
415 * bu21013_free_irq() - frees IRQ registered for touchscreen
423 bu21013_data->touch_stopped = true; in bu21013_free_irq()
424 wake_up(&bu21013_data->wait); in bu21013_free_irq()
425 free_irq(bu21013_data->irq, bu21013_data); in bu21013_free_irq()
429 * bu21013_cs_disable() - deconfigures the touch panel controller
432 * This function is used to deconfigure the chip selection
439 error = gpio_direction_output(bu21013_data->chip->cs_pin, 0); in bu21013_cs_disable()
441 dev_warn(&bu21013_data->client->dev, in bu21013_cs_disable()
445 gpio_set_value(bu21013_data->chip->cs_pin, 0); in bu21013_cs_disable()
447 gpio_free(bu21013_data->chip->cs_pin); in bu21013_cs_disable()
454 struct device_node *np = dev->of_node; in bu21013_parse_dt()
459 return ERR_PTR(-EINVAL); in bu21013_parse_dt()
464 return ERR_PTR(-ENOMEM); in bu21013_parse_dt()
466 pdata->y_flip = pdata->x_flip = false; in bu21013_parse_dt()
468 pdata->x_flip = of_property_read_bool(np, "rohm,flip-x"); in bu21013_parse_dt()
469 pdata->y_flip = of_property_read_bool(np, "rohm,flip-y"); in bu21013_parse_dt()
471 of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max); in bu21013_parse_dt()
472 of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max); in bu21013_parse_dt()
474 pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0); in bu21013_parse_dt()
475 pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0); in bu21013_parse_dt()
477 pdata->ext_clk = false; in bu21013_parse_dt()
486 return ERR_PTR(-EINVAL); in bu21013_parse_dt()
491 * bu21013_probe() - initializes the i2c-client touchscreen driver
495 * This function used to initializes the i2c-client touchscreen
502 dev_get_platdata(&client->dev); in bu21013_probe()
507 if (!i2c_check_functionality(client->adapter, in bu21013_probe()
509 dev_err(&client->dev, "i2c smbus byte data not supported\n"); in bu21013_probe()
510 return -EIO; in bu21013_probe()
514 pdata = bu21013_parse_dt(&client->dev); in bu21013_probe()
519 if (!gpio_is_valid(pdata->touch_pin)) { in bu21013_probe()
520 dev_err(&client->dev, "invalid touch_pin supplied\n"); in bu21013_probe()
521 return -EINVAL; in bu21013_probe()
527 dev_err(&client->dev, "device memory alloc failed\n"); in bu21013_probe()
528 error = -ENOMEM; in bu21013_probe()
532 bu21013_data->in_dev = in_dev; in bu21013_probe()
533 bu21013_data->chip = pdata; in bu21013_probe()
534 bu21013_data->client = client; in bu21013_probe()
535 bu21013_data->irq = gpio_to_irq(pdata->touch_pin); in bu21013_probe()
537 bu21013_data->regulator = regulator_get(&client->dev, "avdd"); in bu21013_probe()
538 if (IS_ERR(bu21013_data->regulator)) { in bu21013_probe()
539 dev_err(&client->dev, "regulator_get failed\n"); in bu21013_probe()
540 error = PTR_ERR(bu21013_data->regulator); in bu21013_probe()
544 error = regulator_enable(bu21013_data->regulator); in bu21013_probe()
546 dev_err(&client->dev, "regulator enable failed\n"); in bu21013_probe()
550 bu21013_data->touch_stopped = false; in bu21013_probe()
551 init_waitqueue_head(&bu21013_data->wait); in bu21013_probe()
554 error = gpio_request_one(pdata->cs_pin, GPIOF_OUT_INIT_HIGH, in bu21013_probe()
557 dev_err(&client->dev, "Unable to request gpio reset_pin\n"); in bu21013_probe()
564 dev_err(&client->dev, "error in bu21013 config\n"); in bu21013_probe()
569 in_dev->name = DRIVER_TP; in bu21013_probe()
570 in_dev->id.bustype = BUS_I2C; in bu21013_probe()
571 in_dev->dev.parent = &client->dev; in bu21013_probe()
573 __set_bit(EV_SYN, in_dev->evbit); in bu21013_probe()
574 __set_bit(EV_KEY, in_dev->evbit); in bu21013_probe()
575 __set_bit(EV_ABS, in_dev->evbit); in bu21013_probe()
578 pdata->touch_x_max, 0, 0); in bu21013_probe()
580 pdata->touch_y_max, 0, 0); in bu21013_probe()
583 error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq, in bu21013_probe()
588 dev_err(&client->dev, "request irq %d failed\n", in bu21013_probe()
589 bu21013_data->irq); in bu21013_probe()
595 dev_err(&client->dev, "failed to register input device\n"); in bu21013_probe()
599 device_init_wakeup(&client->dev, pdata->wakeup); in bu21013_probe()
609 regulator_disable(bu21013_data->regulator); in bu21013_probe()
611 regulator_put(bu21013_data->regulator); in bu21013_probe()
619 * bu21013_remove() - removes the i2c-client touchscreen driver
622 * This function uses to remove the i2c-client
633 input_unregister_device(bu21013_data->in_dev); in bu21013_remove()
635 regulator_disable(bu21013_data->regulator); in bu21013_remove()
636 regulator_put(bu21013_data->regulator); in bu21013_remove()
645 * bu21013_suspend() - suspend the touch screen controller
654 struct i2c_client *client = bu21013_data->client; in bu21013_suspend()
656 bu21013_data->touch_stopped = true; in bu21013_suspend()
657 if (device_may_wakeup(&client->dev)) in bu21013_suspend()
658 enable_irq_wake(bu21013_data->irq); in bu21013_suspend()
660 disable_irq(bu21013_data->irq); in bu21013_suspend()
662 regulator_disable(bu21013_data->regulator); in bu21013_suspend()
668 * bu21013_resume() - resume the touch screen controller
677 struct i2c_client *client = bu21013_data->client; in bu21013_resume()
680 retval = regulator_enable(bu21013_data->regulator); in bu21013_resume()
682 dev_err(&client->dev, "bu21013 regulator enable failed\n"); in bu21013_resume()
688 dev_err(&client->dev, "bu21013 controller config failed\n"); in bu21013_resume()
692 bu21013_data->touch_stopped = false; in bu21013_resume()
694 if (device_may_wakeup(&client->dev)) in bu21013_resume()
695 disable_irq_wake(bu21013_data->irq); in bu21013_resume()
697 enable_irq(bu21013_data->irq); in bu21013_resume()