diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-07-29 21:36:43 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-08-07 09:57:25 -0400 |
commit | 56bbc99e6914eb183fb083f737178a1757083d41 (patch) | |
tree | 165ad97939a324b04a74e9a08acf4b4999e6f959 | |
parent | 6eaa247a5bab775e45a74b52c17bf8bc37fd5f6f (diff) |
Input: max77693: Add support for Maxim 77843
The Maxim 77843 haptic driver differs from 77693 by:
1. Setting the bias.
2. Different configuration register.
3. Not enabling the low-sys DAC.
4. Using same regmap for PMIC and haptic blocks.
Incorporate all differences into max77693 haptic driver so both devices
can be supported.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/input/misc/Kconfig | 6 | ||||
-rw-r--r-- | drivers/input/misc/max77693-haptic.c | 48 |
2 files changed, 48 insertions, 6 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index d4f0a817e858..f5d7a98a329d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -167,12 +167,12 @@ config INPUT_M68K_BEEP | |||
167 | depends on M68K | 167 | depends on M68K |
168 | 168 | ||
169 | config INPUT_MAX77693_HAPTIC | 169 | config INPUT_MAX77693_HAPTIC |
170 | tristate "MAXIM MAX77693 haptic controller support" | 170 | tristate "MAXIM MAX77693/MAX77843 haptic controller support" |
171 | depends on MFD_MAX77693 && PWM | 171 | depends on (MFD_MAX77693 || MFD_MAX77843) && PWM |
172 | select INPUT_FF_MEMLESS | 172 | select INPUT_FF_MEMLESS |
173 | help | 173 | help |
174 | This option enables support for the haptic controller on | 174 | This option enables support for the haptic controller on |
175 | MAXIM MAX77693 chip. | 175 | MAXIM MAX77693 and MAX77843 chips. |
176 | 176 | ||
177 | To compile this driver as module, choose M here: the | 177 | To compile this driver as module, choose M here: the |
178 | module will be called max77693-haptic. | 178 | module will be called max77693-haptic. |
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 4c0f67ab66d9..6d96bff32a0e 100644 --- a/drivers/input/misc/max77693-haptic.c +++ b/drivers/input/misc/max77693-haptic.c | |||
@@ -1,8 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * MAXIM MAX77693 Haptic device driver | 2 | * MAXIM MAX77693/MAX77843 Haptic device driver |
3 | * | 3 | * |
4 | * Copyright (C) 2014 Samsung Electronics | 4 | * Copyright (C) 2014,2015 Samsung Electronics |
5 | * Jaewon Kim <jaewon02.kim@samsung.com> | 5 | * Jaewon Kim <jaewon02.kim@samsung.com> |
6 | * Krzysztof Kozlowski <k.kozlowski@samsung.com> | ||
6 | * | 7 | * |
7 | * This program is not provided / owned by Maxim Integrated Products. | 8 | * This program is not provided / owned by Maxim Integrated Products. |
8 | * | 9 | * |
@@ -26,6 +27,7 @@ | |||
26 | #include <linux/mfd/max77693.h> | 27 | #include <linux/mfd/max77693.h> |
27 | #include <linux/mfd/max77693-common.h> | 28 | #include <linux/mfd/max77693-common.h> |
28 | #include <linux/mfd/max77693-private.h> | 29 | #include <linux/mfd/max77693-private.h> |
30 | #include <linux/mfd/max77843-private.h> | ||
29 | 31 | ||
30 | #define MAX_MAGNITUDE_SHIFT 16 | 32 | #define MAX_MAGNITUDE_SHIFT 16 |
31 | 33 | ||
@@ -80,6 +82,26 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) | |||
80 | return 0; | 82 | return 0; |
81 | } | 83 | } |
82 | 84 | ||
85 | static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on) | ||
86 | { | ||
87 | int error; | ||
88 | |||
89 | if (haptic->dev_type != TYPE_MAX77843) | ||
90 | return 0; | ||
91 | |||
92 | error = regmap_update_bits(haptic->regmap_haptic, | ||
93 | MAX77843_SYS_REG_MAINCTRL1, | ||
94 | MAX77843_MAINCTRL1_BIASEN_MASK, | ||
95 | on << MAINCTRL1_BIASEN_SHIFT); | ||
96 | if (error) { | ||
97 | dev_err(haptic->dev, "failed to %s bias: %d\n", | ||
98 | on ? "enable" : "disable", error); | ||
99 | return error; | ||
100 | } | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
83 | static int max77693_haptic_configure(struct max77693_haptic *haptic, | 105 | static int max77693_haptic_configure(struct max77693_haptic *haptic, |
84 | bool enable) | 106 | bool enable) |
85 | { | 107 | { |
@@ -94,6 +116,12 @@ static int max77693_haptic_configure(struct max77693_haptic *haptic, | |||
94 | MAX77693_HAPTIC_PWM_DIVISOR_128); | 116 | MAX77693_HAPTIC_PWM_DIVISOR_128); |
95 | config_reg = MAX77693_HAPTIC_REG_CONFIG2; | 117 | config_reg = MAX77693_HAPTIC_REG_CONFIG2; |
96 | break; | 118 | break; |
119 | case TYPE_MAX77843: | ||
120 | value = (haptic->type << MCONFIG_MODE_SHIFT) | | ||
121 | (enable << MCONFIG_MEN_SHIFT) | | ||
122 | MAX77693_HAPTIC_PWM_DIVISOR_128; | ||
123 | config_reg = MAX77843_HAP_REG_MCONFIG; | ||
124 | break; | ||
97 | default: | 125 | default: |
98 | return -EINVAL; | 126 | return -EINVAL; |
99 | } | 127 | } |
@@ -113,6 +141,9 @@ static int max77693_haptic_lowsys(struct max77693_haptic *haptic, bool enable) | |||
113 | { | 141 | { |
114 | int error; | 142 | int error; |
115 | 143 | ||
144 | if (haptic->dev_type != TYPE_MAX77693) | ||
145 | return 0; | ||
146 | |||
116 | error = regmap_update_bits(haptic->regmap_pmic, | 147 | error = regmap_update_bits(haptic->regmap_pmic, |
117 | MAX77693_PMIC_REG_LSCNFG, | 148 | MAX77693_PMIC_REG_LSCNFG, |
118 | MAX77693_PMIC_LOW_SYS_MASK, | 149 | MAX77693_PMIC_LOW_SYS_MASK, |
@@ -228,6 +259,10 @@ static int max77693_haptic_open(struct input_dev *dev) | |||
228 | struct max77693_haptic *haptic = input_get_drvdata(dev); | 259 | struct max77693_haptic *haptic = input_get_drvdata(dev); |
229 | int error; | 260 | int error; |
230 | 261 | ||
262 | error = max77843_haptic_bias(haptic, true); | ||
263 | if (error) | ||
264 | return error; | ||
265 | |||
231 | error = regulator_enable(haptic->motor_reg); | 266 | error = regulator_enable(haptic->motor_reg); |
232 | if (error) { | 267 | if (error) { |
233 | dev_err(haptic->dev, | 268 | dev_err(haptic->dev, |
@@ -250,6 +285,8 @@ static void max77693_haptic_close(struct input_dev *dev) | |||
250 | if (error) | 285 | if (error) |
251 | dev_err(haptic->dev, | 286 | dev_err(haptic->dev, |
252 | "failed to disable regulator: %d\n", error); | 287 | "failed to disable regulator: %d\n", error); |
288 | |||
289 | max77843_haptic_bias(haptic, false); | ||
253 | } | 290 | } |
254 | 291 | ||
255 | static int max77693_haptic_probe(struct platform_device *pdev) | 292 | static int max77693_haptic_probe(struct platform_device *pdev) |
@@ -274,6 +311,9 @@ static int max77693_haptic_probe(struct platform_device *pdev) | |||
274 | case TYPE_MAX77693: | 311 | case TYPE_MAX77693: |
275 | haptic->regmap_haptic = max77693->regmap_haptic; | 312 | haptic->regmap_haptic = max77693->regmap_haptic; |
276 | break; | 313 | break; |
314 | case TYPE_MAX77843: | ||
315 | haptic->regmap_haptic = max77693->regmap; | ||
316 | break; | ||
277 | default: | 317 | default: |
278 | dev_err(&pdev->dev, "unsupported device type: %u\n", | 318 | dev_err(&pdev->dev, "unsupported device type: %u\n", |
279 | haptic->dev_type); | 319 | haptic->dev_type); |
@@ -359,6 +399,7 @@ static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, | |||
359 | 399 | ||
360 | static const struct platform_device_id max77693_haptic_id[] = { | 400 | static const struct platform_device_id max77693_haptic_id[] = { |
361 | { "max77693-haptic", TYPE_MAX77693 }, | 401 | { "max77693-haptic", TYPE_MAX77693 }, |
402 | { "max77843-haptic", TYPE_MAX77843 }, | ||
362 | {}, | 403 | {}, |
363 | }; | 404 | }; |
364 | MODULE_DEVICE_TABLE(platform, max77693_haptic_id); | 405 | MODULE_DEVICE_TABLE(platform, max77693_haptic_id); |
@@ -374,6 +415,7 @@ static struct platform_driver max77693_haptic_driver = { | |||
374 | module_platform_driver(max77693_haptic_driver); | 415 | module_platform_driver(max77693_haptic_driver); |
375 | 416 | ||
376 | MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>"); | 417 | MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>"); |
377 | MODULE_DESCRIPTION("MAXIM MAX77693 Haptic driver"); | 418 | MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>"); |
419 | MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver"); | ||
378 | MODULE_ALIAS("platform:max77693-haptic"); | 420 | MODULE_ALIAS("platform:max77693-haptic"); |
379 | MODULE_LICENSE("GPL"); | 421 | MODULE_LICENSE("GPL"); |