Commit 6eaa247a authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

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: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b3d8ba74
...@@ -47,6 +47,8 @@ enum max77693_haptic_pwm_divisor { ...@@ -47,6 +47,8 @@ enum max77693_haptic_pwm_divisor {
}; };
struct max77693_haptic { struct max77693_haptic {
enum max77693_types dev_type;
struct regmap *regmap_pmic; struct regmap *regmap_pmic;
struct regmap *regmap_haptic; struct regmap *regmap_haptic;
struct device *dev; struct device *dev;
...@@ -81,16 +83,23 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) ...@@ -81,16 +83,23 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic)
static int max77693_haptic_configure(struct max77693_haptic *haptic, static int max77693_haptic_configure(struct max77693_haptic *haptic,
bool enable) bool enable)
{ {
unsigned int value; unsigned int value, config_reg;
int error; int error;
value = ((haptic->type << MAX77693_CONFIG2_MODE) | switch (haptic->dev_type) {
(enable << MAX77693_CONFIG2_MEN) | case TYPE_MAX77693:
(haptic->mode << MAX77693_CONFIG2_HTYP) | value = ((haptic->type << MAX77693_CONFIG2_MODE) |
MAX77693_HAPTIC_PWM_DIVISOR_128); (enable << MAX77693_CONFIG2_MEN) |
(haptic->mode << MAX77693_CONFIG2_HTYP) |
MAX77693_HAPTIC_PWM_DIVISOR_128);
config_reg = MAX77693_HAPTIC_REG_CONFIG2;
break;
default:
return -EINVAL;
}
error = regmap_write(haptic->regmap_haptic, error = regmap_write(haptic->regmap_haptic,
MAX77693_HAPTIC_REG_CONFIG2, value); config_reg, value);
if (error) { if (error) {
dev_err(haptic->dev, dev_err(haptic->dev,
"failed to update haptic config: %d\n", error); "failed to update haptic config: %d\n", error);
...@@ -254,12 +263,23 @@ static int max77693_haptic_probe(struct platform_device *pdev) ...@@ -254,12 +263,23 @@ static int max77693_haptic_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
haptic->regmap_pmic = max77693->regmap; haptic->regmap_pmic = max77693->regmap;
haptic->regmap_haptic = max77693->regmap_haptic;
haptic->dev = &pdev->dev; haptic->dev = &pdev->dev;
haptic->type = MAX77693_HAPTIC_LRA; haptic->type = MAX77693_HAPTIC_LRA;
haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE; haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE;
haptic->suspend_state = false; haptic->suspend_state = false;
/* Variant-specific init */
haptic->dev_type = platform_get_device_id(pdev)->driver_data;
switch (haptic->dev_type) {
case TYPE_MAX77693:
haptic->regmap_haptic = max77693->regmap_haptic;
break;
default:
dev_err(&pdev->dev, "unsupported device type: %u\n",
haptic->dev_type);
return -EINVAL;
}
INIT_WORK(&haptic->work, max77693_haptic_play_work); INIT_WORK(&haptic->work, max77693_haptic_play_work);
/* Get pwm and regulatot for haptic device */ /* Get pwm and regulatot for haptic device */
...@@ -337,12 +357,19 @@ static int __maybe_unused max77693_haptic_resume(struct device *dev) ...@@ -337,12 +357,19 @@ static int __maybe_unused max77693_haptic_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops,
max77693_haptic_suspend, max77693_haptic_resume); max77693_haptic_suspend, max77693_haptic_resume);
static const struct platform_device_id max77693_haptic_id[] = {
{ "max77693-haptic", TYPE_MAX77693 },
{},
};
MODULE_DEVICE_TABLE(platform, max77693_haptic_id);
static struct platform_driver max77693_haptic_driver = { static struct platform_driver max77693_haptic_driver = {
.driver = { .driver = {
.name = "max77693-haptic", .name = "max77693-haptic",
.pm = &max77693_haptic_pm_ops, .pm = &max77693_haptic_pm_ops,
}, },
.probe = max77693_haptic_probe, .probe = max77693_haptic_probe,
.id_table = max77693_haptic_id,
}; };
module_platform_driver(max77693_haptic_driver); module_platform_driver(max77693_haptic_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment