aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/keyboard/sun4i-lradc-keys.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-13 15:21:48 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-13 15:21:48 -0700
commit0aed4b28187078565cafbfe86b62f941d580d840 (patch)
treee6abfddcf201ade40510be9f8a60f3e2cd06388a /drivers/input/keyboard/sun4i-lradc-keys.c
parenta3958f5e13e23f6e68c3cc1210639f63728a950f (diff)
parent14e0c7317ed58bcd15af5c3d09818ee0f2e3984c (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov: "A few new drivers: - driver for Azoteq IQS550/572/525 touch controllers - driver for Microchip AT42QT1050 keys - driver for GPIO controllable vibrators - support for GT5663 in Goodix driver ... along with miscellaneous driver fixes" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: libps2 - mark expected switch fall-through Input: qt1050 - add Microchip AT42QT1050 support Input: add support for Azoteq IQS550/572/525 Input: add a driver for GPIO controllable vibrators Input: synaptics-rmi4 - fix enum_fmt Input: synaptics-rmi4 - fill initial format HID: input: add mapping for KEY_KBD_LAYOUT_NEXT Input: add KEY_KBD_LAYOUT_NEXT Input: hyperv-keyboard - add module description Input: olpc_apsp - depend on ARCH_MMP Input: sun4i-a10-lradc-keys - add support for A83T Input: snvs_pwrkey - use dev_pm_set_wake_irq() to simplify code Input: lpc32xx-key - add clocks property and fix DT binding example Input: i8042 - signal wakeup from atkbd/psmouse Input: goodix - add GT5663 CTP support Input: goodix - add regulators suppot Input: evdev - use struct_size() in kzalloc() and vzalloc() Input: edt-ft5x06 - convert to use SPDX identifier Input: edt-ft5x06 - enable ACPI enumeration
Diffstat (limited to 'drivers/input/keyboard/sun4i-lradc-keys.c')
-rw-r--r--drivers/input/keyboard/sun4i-lradc-keys.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c
index 57272df34cd5..df3eec72a9b2 100644
--- a/drivers/input/keyboard/sun4i-lradc-keys.c
+++ b/drivers/input/keyboard/sun4i-lradc-keys.c
@@ -46,6 +46,7 @@
#define CONTINUE_TIME_SEL(x) ((x) << 16) /* 4 bits */
#define KEY_MODE_SEL(x) ((x) << 12) /* 2 bits */
#define LEVELA_B_CNT(x) ((x) << 8) /* 4 bits */
+#define HOLD_KEY_EN(x) ((x) << 7)
#define HOLD_EN(x) ((x) << 6)
#define LEVELB_VOL(x) ((x) << 4) /* 2 bits */
#define SAMPLE_RATE(x) ((x) << 2) /* 2 bits */
@@ -63,6 +64,25 @@
#define CHAN0_KEYDOWN_IRQ BIT(1)
#define CHAN0_DATA_IRQ BIT(0)
+/* struct lradc_variant - Describe sun4i-a10-lradc-keys hardware variant
+ * @divisor_numerator: The numerator of lradc Vref internally divisor
+ * @divisor_denominator: The denominator of lradc Vref internally divisor
+ */
+struct lradc_variant {
+ u8 divisor_numerator;
+ u8 divisor_denominator;
+};
+
+static const struct lradc_variant lradc_variant_a10 = {
+ .divisor_numerator = 2,
+ .divisor_denominator = 3
+};
+
+static const struct lradc_variant r_lradc_variant_a83t = {
+ .divisor_numerator = 3,
+ .divisor_denominator = 4
+};
+
struct sun4i_lradc_keymap {
u32 voltage;
u32 keycode;
@@ -74,6 +94,7 @@ struct sun4i_lradc_data {
void __iomem *base;
struct regulator *vref_supply;
struct sun4i_lradc_keymap *chan0_map;
+ const struct lradc_variant *variant;
u32 chan0_map_count;
u32 chan0_keycode;
u32 vref;
@@ -128,9 +149,9 @@ static int sun4i_lradc_open(struct input_dev *dev)
if (error)
return error;
- /* lradc Vref internally is divided by 2/3 */
- lradc->vref = regulator_get_voltage(lradc->vref_supply) * 2 / 3;
-
+ lradc->vref = regulator_get_voltage(lradc->vref_supply) *
+ lradc->variant->divisor_numerator /
+ lradc->variant->divisor_denominator;
/*
* Set sample time to 4 ms / 250 Hz. Wait 2 * 4 ms for key to
* stabilize on press, wait (1 + 1) * 4 ms for key release
@@ -222,6 +243,12 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
if (error)
return error;
+ lradc->variant = of_device_get_match_data(&pdev->dev);
+ if (!lradc->variant) {
+ dev_err(&pdev->dev, "Missing sun4i-a10-lradc-keys variant\n");
+ return -EINVAL;
+ }
+
lradc->vref_supply = devm_regulator_get(dev, "vref");
if (IS_ERR(lradc->vref_supply))
return PTR_ERR(lradc->vref_supply);
@@ -265,7 +292,10 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
}
static const struct of_device_id sun4i_lradc_of_match[] = {
- { .compatible = "allwinner,sun4i-a10-lradc-keys", },
+ { .compatible = "allwinner,sun4i-a10-lradc-keys",
+ .data = &lradc_variant_a10 },
+ { .compatible = "allwinner,sun8i-a83t-r-lradc",
+ .data = &r_lradc_variant_a83t },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, sun4i_lradc_of_match);