Lines Matching +full:flip +full:- +full:chip
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2010
4 * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson
140 * struct bu21013_ts - touch panel data structure
145 * @cs_gpiod: chip select GPIO line
176 ret = i2c_smbus_read_i2c_block_data(ts->client, in bu21013_read_block_data()
183 return -EINVAL; in bu21013_read_block_data()
188 struct input_dev *input = ts->in_dev; in bu21013_do_touch_report()
197 return -EINVAL; in bu21013_do_touch_report()
213 &ts->props, x, y); in bu21013_do_touch_report()
217 (abs(pos[0].x - pos[1].x) < DELTA_MIN || in bu21013_do_touch_report()
218 abs(pos[0].y - pos[1].y) < DELTA_MIN)) { in bu21013_do_touch_report()
245 dev_err(&ts->client->dev, "%s failed\n", __func__); in bu21013_gpio_irq()
249 if (unlikely(ts->touch_stopped)) in bu21013_gpio_irq()
252 keep_polling = ts->int_gpiod ? in bu21013_gpio_irq()
253 gpiod_get_value(ts->int_gpiod) : false; in bu21013_gpio_irq()
263 struct i2c_client *client = ts->client; in bu21013_init_chip()
269 dev_err(&client->dev, "BU21013_RESET reg write failed\n"); in bu21013_init_chip()
277 dev_err(&client->dev, "BU21013_SENSOR_0_7 reg write failed\n"); in bu21013_init_chip()
284 dev_err(&client->dev, "BU21013_SENSOR_8_15 reg write failed\n"); in bu21013_init_chip()
291 dev_err(&client->dev, "BU21013_SENSOR_16_23 reg write failed\n"); in bu21013_init_chip()
299 dev_err(&client->dev, "BU21013_POS_MODE1 reg write failed\n"); in bu21013_init_chip()
310 dev_err(&client->dev, "BU21013_POS_MODE2 reg write failed\n"); in bu21013_init_chip()
318 dev_err(&client->dev, "BU21013_CLK_MODE reg write failed\n"); in bu21013_init_chip()
326 dev_err(&client->dev, "BU21013_IDLE reg write failed\n"); in bu21013_init_chip()
333 dev_err(&client->dev, "BU21013_INT_MODE reg write failed\n"); in bu21013_init_chip()
341 dev_err(&client->dev, "BU21013_FILTER reg write failed\n"); in bu21013_init_chip()
348 dev_err(&client->dev, "BU21013_TH_ON reg write failed\n"); in bu21013_init_chip()
355 dev_err(&client->dev, "BU21013_TH_OFF reg write failed\n"); in bu21013_init_chip()
362 dev_err(&client->dev, "BU21013_GAIN reg write failed\n"); in bu21013_init_chip()
369 dev_err(&client->dev, "BU21013_OFFSET_MODE reg write failed\n"); in bu21013_init_chip()
379 dev_err(&client->dev, "BU21013_XY_EDGE reg write failed\n"); in bu21013_init_chip()
386 dev_err(&client->dev, "BU21013_REG_DONE reg write failed\n"); in bu21013_init_chip()
397 regulator_disable(ts->regulator); in bu21013_power_off()
404 gpiod_set_value(ts->cs_gpiod, 0); in bu21013_disable_chip()
413 struct device *dev = &client->dev; in bu21013_probe()
416 if (!i2c_check_functionality(client->adapter, in bu21013_probe()
419 return -EIO; in bu21013_probe()
422 if (!client->irq) { in bu21013_probe()
424 return -EINVAL; in bu21013_probe()
429 return -ENOMEM; in bu21013_probe()
431 ts->client = client; in bu21013_probe()
433 ts->x_flip = device_property_read_bool(dev, "rohm,flip-x"); in bu21013_probe()
434 ts->y_flip = device_property_read_bool(dev, "rohm,flip-y"); in bu21013_probe()
439 return -ENOMEM; in bu21013_probe()
441 ts->in_dev = in_dev; in bu21013_probe()
445 in_dev->name = DRIVER_TP; in bu21013_probe()
446 in_dev->id.bustype = BUS_I2C; in bu21013_probe()
448 device_property_read_u32(dev, "rohm,touch-max-x", &max_x); in bu21013_probe()
449 device_property_read_u32(dev, "rohm,touch-max-y", &max_y); in bu21013_probe()
454 touchscreen_parse_properties(in_dev, true, &ts->props); in bu21013_probe()
456 /* Adjust for the legacy "flip" properties, if present */ in bu21013_probe()
457 if (!ts->props.invert_x && in bu21013_probe()
458 device_property_read_bool(dev, "rohm,flip-x")) { in bu21013_probe()
459 info = &in_dev->absinfo[ABS_MT_POSITION_X]; in bu21013_probe()
460 info->maximum -= info->minimum; in bu21013_probe()
461 info->minimum = 0; in bu21013_probe()
464 if (!ts->props.invert_y && in bu21013_probe()
465 device_property_read_bool(dev, "rohm,flip-y")) { in bu21013_probe()
466 info = &in_dev->absinfo[ABS_MT_POSITION_Y]; in bu21013_probe()
467 info->maximum -= info->minimum; in bu21013_probe()
468 info->minimum = 0; in bu21013_probe()
479 ts->regulator = devm_regulator_get(dev, "avdd"); in bu21013_probe()
480 if (IS_ERR(ts->regulator)) { in bu21013_probe()
482 return PTR_ERR(ts->regulator); in bu21013_probe()
485 error = regulator_enable(ts->regulator); in bu21013_probe()
497 /* Named "CS" on the chip, DT binding is "reset" */ in bu21013_probe()
498 ts->cs_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in bu21013_probe()
499 if (IS_ERR(ts->cs_gpiod)) in bu21013_probe()
500 return dev_err_probe(dev, PTR_ERR(ts->cs_gpiod), "failed to get CS GPIO\n"); in bu21013_probe()
502 gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS"); in bu21013_probe()
506 dev_err(dev, "failed to install chip disable handler\n"); in bu21013_probe()
510 /* Named "INT" on the chip, DT binding is "touch" */ in bu21013_probe()
511 ts->int_gpiod = devm_gpiod_get_optional(dev, "touch", GPIOD_IN); in bu21013_probe()
512 error = PTR_ERR_OR_ZERO(ts->int_gpiod); in bu21013_probe()
516 if (ts->int_gpiod) in bu21013_probe()
517 gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); in bu21013_probe()
526 error = devm_request_threaded_irq(dev, client->irq, NULL, bu21013_gpio_irq, in bu21013_probe()
529 dev_err(dev, "request irq %d failed\n", client->irq); in bu21013_probe()
549 ts->touch_stopped = true; in bu21013_remove()
558 ts->touch_stopped = true; in bu21013_suspend()
560 disable_irq(client->irq); in bu21013_suspend()
562 if (!device_may_wakeup(&client->dev)) in bu21013_suspend()
563 regulator_disable(ts->regulator); in bu21013_suspend()
574 if (!device_may_wakeup(&client->dev)) { in bu21013_resume()
575 error = regulator_enable(ts->regulator); in bu21013_resume()
577 dev_err(&client->dev, in bu21013_resume()
578 "failed to re-enable regulator when resuming\n"); in bu21013_resume()
584 dev_err(&client->dev, in bu21013_resume()
585 "failed to reinitialize chip when resuming\n"); in bu21013_resume()
590 ts->touch_stopped = false; in bu21013_resume()
592 enable_irq(client->irq); in bu21013_resume()