Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
6eaa247a b3d8ba74

+34 -7
+34 -7
drivers/input/misc/max77693-haptic.c
··· 47 47 }; 48 48 49 49 struct max77693_haptic { 50 + enum max77693_types dev_type; 51 + 50 52 struct regmap *regmap_pmic; 51 53 struct regmap *regmap_haptic; 52 54 struct device *dev; ··· 83 81 static int max77693_haptic_configure(struct max77693_haptic *haptic, 84 82 bool enable) 85 83 { 86 - unsigned int value; 84 + unsigned int value, config_reg; 87 85 int error; 88 86 89 - value = ((haptic->type << MAX77693_CONFIG2_MODE) | 90 - (enable << MAX77693_CONFIG2_MEN) | 91 - (haptic->mode << MAX77693_CONFIG2_HTYP) | 92 - MAX77693_HAPTIC_PWM_DIVISOR_128); 87 + switch (haptic->dev_type) { 88 + case TYPE_MAX77693: 89 + value = ((haptic->type << MAX77693_CONFIG2_MODE) | 90 + (enable << MAX77693_CONFIG2_MEN) | 91 + (haptic->mode << MAX77693_CONFIG2_HTYP) | 92 + MAX77693_HAPTIC_PWM_DIVISOR_128); 93 + config_reg = MAX77693_HAPTIC_REG_CONFIG2; 94 + break; 95 + default: 96 + return -EINVAL; 97 + } 93 98 94 99 error = regmap_write(haptic->regmap_haptic, 95 - MAX77693_HAPTIC_REG_CONFIG2, value); 100 + config_reg, value); 96 101 if (error) { 97 102 dev_err(haptic->dev, 98 103 "failed to update haptic config: %d\n", error); ··· 263 254 return -ENOMEM; 264 255 265 256 haptic->regmap_pmic = max77693->regmap; 266 - haptic->regmap_haptic = max77693->regmap_haptic; 267 257 haptic->dev = &pdev->dev; 268 258 haptic->type = MAX77693_HAPTIC_LRA; 269 259 haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE; 270 260 haptic->suspend_state = false; 261 + 262 + /* Variant-specific init */ 263 + haptic->dev_type = platform_get_device_id(pdev)->driver_data; 264 + switch (haptic->dev_type) { 265 + case TYPE_MAX77693: 266 + haptic->regmap_haptic = max77693->regmap_haptic; 267 + break; 268 + default: 269 + dev_err(&pdev->dev, "unsupported device type: %u\n", 270 + haptic->dev_type); 271 + return -EINVAL; 272 + } 271 273 272 274 INIT_WORK(&haptic->work, max77693_haptic_play_work); 273 275 ··· 357 337 static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, 358 338 max77693_haptic_suspend, max77693_haptic_resume); 359 339 340 + static const struct platform_device_id max77693_haptic_id[] = { 341 + { "max77693-haptic", TYPE_MAX77693 }, 342 + {}, 343 + }; 344 + MODULE_DEVICE_TABLE(platform, max77693_haptic_id); 345 + 360 346 static struct platform_driver max77693_haptic_driver = { 361 347 .driver = { 362 348 .name = "max77693-haptic", 363 349 .pm = &max77693_haptic_pm_ops, 364 350 }, 365 351 .probe = max77693_haptic_probe, 352 + .id_table = max77693_haptic_id, 366 353 }; 367 354 module_platform_driver(max77693_haptic_driver); 368 355