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()
416 if (!i2c_check_functionality(client->adapter, in bu21013_probe()
418 dev_err(&client->dev, "i2c smbus byte data not supported\n"); in bu21013_probe()
419 return -EIO; in bu21013_probe()
422 if (!client->irq) { in bu21013_probe()
423 dev_err(&client->dev, "No IRQ set up\n"); in bu21013_probe()
424 return -EINVAL; in bu21013_probe()
427 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in bu21013_probe()
429 return -ENOMEM; in bu21013_probe()
431 ts->client = client; in bu21013_probe()
433 ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x"); in bu21013_probe()
434 ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y"); in bu21013_probe()
436 in_dev = devm_input_allocate_device(&client->dev); in bu21013_probe()
438 dev_err(&client->dev, "device memory alloc failed\n"); 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(&client->dev, "rohm,touch-max-x", &max_x); in bu21013_probe()
449 device_property_read_u32(&client->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(&client->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(&client->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()
475 dev_err(&client->dev, "failed to initialize MT slots"); in bu21013_probe()
479 ts->regulator = devm_regulator_get(&client->dev, "avdd"); in bu21013_probe()
480 if (IS_ERR(ts->regulator)) { in bu21013_probe()
481 dev_err(&client->dev, "regulator_get failed\n"); in bu21013_probe()
482 return PTR_ERR(ts->regulator); in bu21013_probe()
485 error = regulator_enable(ts->regulator); in bu21013_probe()
487 dev_err(&client->dev, "regulator enable failed\n"); in bu21013_probe()
491 error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts); in bu21013_probe()
493 dev_err(&client->dev, "failed to install power off handler\n"); in bu21013_probe()
497 /* Named "CS" on the chip, DT binding is "reset" */ in bu21013_probe()
498 ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); in bu21013_probe()
499 error = PTR_ERR_OR_ZERO(ts->cs_gpiod); in bu21013_probe()
501 if (error != -EPROBE_DEFER) in bu21013_probe()
502 dev_err(&client->dev, "failed to get CS GPIO\n"); in bu21013_probe()
505 gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS"); in bu21013_probe()
507 error = devm_add_action_or_reset(&client->dev, in bu21013_probe()
510 dev_err(&client->dev, in bu21013_probe()
511 "failed to install chip disable handler\n"); in bu21013_probe()
515 /* Named "INT" on the chip, DT binding is "touch" */ in bu21013_probe()
516 ts->int_gpiod = devm_gpiod_get_optional(&client->dev, in bu21013_probe()
518 error = PTR_ERR_OR_ZERO(ts->int_gpiod); in bu21013_probe()
520 if (error != -EPROBE_DEFER) in bu21013_probe()
521 dev_err(&client->dev, "failed to get INT GPIO\n"); in bu21013_probe()
525 if (ts->int_gpiod) in bu21013_probe()
526 gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT"); in bu21013_probe()
531 dev_err(&client->dev, "error in bu21013 config\n"); in bu21013_probe()
535 error = devm_request_threaded_irq(&client->dev, client->irq, in bu21013_probe()
539 dev_err(&client->dev, "request irq %d failed\n", in bu21013_probe()
540 client->irq); in bu21013_probe()
546 dev_err(&client->dev, "failed to register input device\n"); in bu21013_probe()
560 ts->touch_stopped = true; in bu21013_remove()
571 ts->touch_stopped = true; in bu21013_suspend()
573 disable_irq(client->irq); in bu21013_suspend()
575 if (!device_may_wakeup(&client->dev)) in bu21013_suspend()
576 regulator_disable(ts->regulator); in bu21013_suspend()
587 if (!device_may_wakeup(&client->dev)) { in bu21013_resume()
588 error = regulator_enable(ts->regulator); in bu21013_resume()
590 dev_err(&client->dev, in bu21013_resume()
591 "failed to re-enable regulator when resuming\n"); in bu21013_resume()
597 dev_err(&client->dev, in bu21013_resume()
598 "failed to reinitialize chip when resuming\n"); in bu21013_resume()
603 ts->touch_stopped = false; in bu21013_resume()
605 enable_irq(client->irq); in bu21013_resume()