Lines Matching +full:deep +full:- +full:touch

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Input driver for Microchip CAP11xx based capacitive touch sensors
185 ret = regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL, 1, 0); in cap11xx_thread_func()
189 ret = regmap_read(priv->regmap, CAP11XX_REG_SENSOR_INPUT, &status); in cap11xx_thread_func()
193 for (i = 0; i < priv->idev->keycodemax; i++) in cap11xx_thread_func()
194 input_report_key(priv->idev, priv->keycodes[i], in cap11xx_thread_func()
197 input_sync(priv->idev); in cap11xx_thread_func()
208 if (IS_ENABLED(CONFIG_LEDS_CLASS) && priv->num_leds) in cap11xx_set_sleep()
211 return regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL, in cap11xx_set_sleep()
235 struct cap11xx_priv *priv = led->priv; in cap11xx_led_set()
242 return regmap_update_bits(priv->regmap, in cap11xx_led_set()
244 BIT(led->reg), in cap11xx_led_set()
245 value ? BIT(led->reg) : 0); in cap11xx_led_set()
251 struct device_node *node = dev->of_node, *child; in cap11xx_init_leds()
260 return -EINVAL; in cap11xx_init_leds()
264 return -ENOMEM; in cap11xx_init_leds()
266 priv->leds = led; in cap11xx_init_leds()
268 error = regmap_update_bits(priv->regmap, in cap11xx_init_leds()
273 error = regmap_update_bits(priv->regmap, CAP11XX_REG_LED_DUTY_CYCLE_4, in cap11xx_init_leds()
283 led->cdev.name = in cap11xx_init_leds()
284 of_get_property(child, "label", NULL) ? : child->name; in cap11xx_init_leds()
285 led->cdev.default_trigger = in cap11xx_init_leds()
286 of_get_property(child, "linux,default-trigger", NULL); in cap11xx_init_leds()
287 led->cdev.flags = 0; in cap11xx_init_leds()
288 led->cdev.brightness_set_blocking = cap11xx_led_set; in cap11xx_init_leds()
289 led->cdev.max_brightness = 1; in cap11xx_init_leds()
290 led->cdev.brightness = LED_OFF; in cap11xx_init_leds()
295 return -EINVAL; in cap11xx_init_leds()
298 led->reg = reg; in cap11xx_init_leds()
299 led->priv = priv; in cap11xx_init_leds()
301 error = devm_led_classdev_register(dev, &led->cdev); in cap11xx_init_leds()
307 priv->num_leds++; in cap11xx_init_leds()
324 struct device *dev = &i2c_client->dev; in cap11xx_i2c_probe()
332 if (id->driver_data >= ARRAY_SIZE(cap11xx_devices)) { in cap11xx_i2c_probe()
333 dev_err(dev, "Invalid device ID %lu\n", id->driver_data); in cap11xx_i2c_probe()
334 return -EINVAL; in cap11xx_i2c_probe()
337 cap = &cap11xx_devices[id->driver_data]; in cap11xx_i2c_probe()
338 if (!cap || !cap->num_channels) { in cap11xx_i2c_probe()
340 return -EINVAL; in cap11xx_i2c_probe()
344 struct_size(priv, keycodes, cap->num_channels), in cap11xx_i2c_probe()
347 return -ENOMEM; in cap11xx_i2c_probe()
349 priv->regmap = devm_regmap_init_i2c(i2c_client, &cap11xx_regmap_config); in cap11xx_i2c_probe()
350 if (IS_ERR(priv->regmap)) in cap11xx_i2c_probe()
351 return PTR_ERR(priv->regmap); in cap11xx_i2c_probe()
353 error = regmap_read(priv->regmap, CAP11XX_REG_PRODUCT_ID, &val); in cap11xx_i2c_probe()
357 if (val != cap->product_id) { in cap11xx_i2c_probe()
359 val, cap->product_id); in cap11xx_i2c_probe()
360 return -ENXIO; in cap11xx_i2c_probe()
363 error = regmap_read(priv->regmap, CAP11XX_REG_MANUFACTURER_ID, &val); in cap11xx_i2c_probe()
370 return -ENXIO; in cap11xx_i2c_probe()
373 error = regmap_read(priv->regmap, CAP11XX_REG_REVISION, &rev); in cap11xx_i2c_probe()
378 node = dev->of_node; in cap11xx_i2c_probe()
380 if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) { in cap11xx_i2c_probe()
384 dev_err(dev, "Invalid sensor-gain value %d\n", gain32); in cap11xx_i2c_probe()
387 if (of_property_read_bool(node, "microchip,irq-active-high")) { in cap11xx_i2c_probe()
388 error = regmap_update_bits(priv->regmap, CAP11XX_REG_CONFIG2, in cap11xx_i2c_probe()
395 for (i = 0; i < cap->num_channels; i++) in cap11xx_i2c_probe()
396 priv->keycodes[i] = KEY_A + i; in cap11xx_i2c_probe()
399 priv->keycodes, cap->num_channels); in cap11xx_i2c_probe()
401 error = regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL, in cap11xx_i2c_probe()
408 error = regmap_write(priv->regmap, CAP11XX_REG_REPEAT_RATE, 0); in cap11xx_i2c_probe()
412 priv->idev = devm_input_allocate_device(dev); in cap11xx_i2c_probe()
413 if (!priv->idev) in cap11xx_i2c_probe()
414 return -ENOMEM; in cap11xx_i2c_probe()
416 priv->idev->name = "CAP11XX capacitive touch sensor"; in cap11xx_i2c_probe()
417 priv->idev->id.bustype = BUS_I2C; in cap11xx_i2c_probe()
418 priv->idev->evbit[0] = BIT_MASK(EV_KEY); in cap11xx_i2c_probe()
421 __set_bit(EV_REP, priv->idev->evbit); in cap11xx_i2c_probe()
423 for (i = 0; i < cap->num_channels; i++) in cap11xx_i2c_probe()
424 __set_bit(priv->keycodes[i], priv->idev->keybit); in cap11xx_i2c_probe()
426 __clear_bit(KEY_RESERVED, priv->idev->keybit); in cap11xx_i2c_probe()
428 priv->idev->keycode = priv->keycodes; in cap11xx_i2c_probe()
429 priv->idev->keycodesize = sizeof(priv->keycodes[0]); in cap11xx_i2c_probe()
430 priv->idev->keycodemax = cap->num_channels; in cap11xx_i2c_probe()
432 priv->idev->id.vendor = CAP11XX_MANUFACTURER_ID; in cap11xx_i2c_probe()
433 priv->idev->id.product = cap->product_id; in cap11xx_i2c_probe()
434 priv->idev->id.version = rev; in cap11xx_i2c_probe()
436 priv->idev->open = cap11xx_input_open; in cap11xx_i2c_probe()
437 priv->idev->close = cap11xx_input_close; in cap11xx_i2c_probe()
439 error = cap11xx_init_leds(dev, priv, cap->num_leds); in cap11xx_i2c_probe()
443 input_set_drvdata(priv->idev, priv); in cap11xx_i2c_probe()
446 * Put the device in deep sleep mode for now. in cap11xx_i2c_probe()
447 * ->open() will bring it back once the it is actually needed. in cap11xx_i2c_probe()
451 error = input_register_device(priv->idev); in cap11xx_i2c_probe()
458 return -ENXIO; in cap11xx_i2c_probe()