aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2015-07-29 21:36:42 -0400
committerMark Brown <broonie@kernel.org>2015-08-07 09:57:25 -0400
commit6eaa247a5bab775e45a74b52c17bf8bc37fd5f6f (patch)
tree9cb1ba23aab458223295b4290c75e930c5397374
parentb3d8ba746b5109dc890e7480db5d014d19ae6a05 (diff)
Input: max77693: Prepare for adding support for Maxim 77843
Prepare the driver for supporting two devices: Maxim 77693 and 77843: 1. Add table of device ids and store current device type for later usage. 2. Differentiate the haptic device configuration. 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/max77693-haptic.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 8dc43c1ebf0e..4c0f67ab66d9 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -47,6 +47,8 @@ enum max77693_haptic_pwm_divisor {
47}; 47};
48 48
49struct max77693_haptic { 49struct max77693_haptic {
50 enum max77693_types dev_type;
51
50 struct regmap *regmap_pmic; 52 struct regmap *regmap_pmic;
51 struct regmap *regmap_haptic; 53 struct regmap *regmap_haptic;
52 struct device *dev; 54 struct device *dev;
@@ -81,16 +83,23 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic)
81static int max77693_haptic_configure(struct max77693_haptic *haptic, 83static int max77693_haptic_configure(struct max77693_haptic *haptic,
82 bool enable) 84 bool enable)
83{ 85{
84 unsigned int value; 86 unsigned int value, config_reg;
85 int error; 87 int error;
86 88
87 value = ((haptic->type << MAX77693_CONFIG2_MODE) | 89 switch (haptic->dev_type) {
88 (enable << MAX77693_CONFIG2_MEN) | 90 case TYPE_MAX77693:
89 (haptic->mode << MAX77693_CONFIG2_HTYP) | 91 value = ((haptic->type << MAX77693_CONFIG2_MODE) |
90 MAX77693_HAPTIC_PWM_DIVISOR_128); 92 (enable << MAX77693_CONFIG2_MEN) |
93 (haptic->mode << MAX77693_CONFIG2_HTYP) |
94 MAX77693_HAPTIC_PWM_DIVISOR_128);
95 config_reg = MAX77693_HAPTIC_REG_CONFIG2;
96 break;
97 default:
98 return -EINVAL;
99 }
91 100
92 error = regmap_write(haptic->regmap_haptic, 101 error = regmap_write(haptic->regmap_haptic,
93 MAX77693_HAPTIC_REG_CONFIG2, value); 102 config_reg, value);
94 if (error) { 103 if (error) {
95 dev_err(haptic->dev, 104 dev_err(haptic->dev,
96 "failed to update haptic config: %d\n", error); 105 "failed to update haptic config: %d\n", error);
@@ -254,12 +263,23 @@ static int max77693_haptic_probe(struct platform_device *pdev)
254 return -ENOMEM; 263 return -ENOMEM;
255 264
256 haptic->regmap_pmic = max77693->regmap; 265 haptic->regmap_pmic = max77693->regmap;
257 haptic->regmap_haptic = max77693->regmap_haptic;
258 haptic->dev = &pdev->dev; 266 haptic->dev = &pdev->dev;
259 haptic->type = MAX77693_HAPTIC_LRA; 267 haptic->type = MAX77693_HAPTIC_LRA;
260 haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE; 268 haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE;
261 haptic->suspend_state = false; 269 haptic->suspend_state = false;
262 270
271 /* Variant-specific init */
272 haptic->dev_type = platform_get_device_id(pdev)->driver_data;
273 switch (haptic->dev_type) {
274 case TYPE_MAX77693:
275 haptic->regmap_haptic = max77693->regmap_haptic;
276 break;
277 default:
278 dev_err(&pdev->dev, "unsupported device type: %u\n",
279 haptic->dev_type);
280 return -EINVAL;
281 }
282
263 INIT_WORK(&haptic->work, max77693_haptic_play_work); 283 INIT_WORK(&haptic->work, max77693_haptic_play_work);
264 284
265 /* Get pwm and regulatot for haptic device */ 285 /* Get pwm and regulatot for haptic device */
@@ -337,12 +357,19 @@ static int __maybe_unused max77693_haptic_resume(struct device *dev)
337static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, 357static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops,
338 max77693_haptic_suspend, max77693_haptic_resume); 358 max77693_haptic_suspend, max77693_haptic_resume);
339 359
360static const struct platform_device_id max77693_haptic_id[] = {
361 { "max77693-haptic", TYPE_MAX77693 },
362 {},
363};
364MODULE_DEVICE_TABLE(platform, max77693_haptic_id);
365
340static struct platform_driver max77693_haptic_driver = { 366static struct platform_driver max77693_haptic_driver = {
341 .driver = { 367 .driver = {
342 .name = "max77693-haptic", 368 .name = "max77693-haptic",
343 .pm = &max77693_haptic_pm_ops, 369 .pm = &max77693_haptic_pm_ops,
344 }, 370 },
345 .probe = max77693_haptic_probe, 371 .probe = max77693_haptic_probe,
372 .id_table = max77693_haptic_id,
346}; 373};
347module_platform_driver(max77693_haptic_driver); 374module_platform_driver(max77693_haptic_driver);
348 375