mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-12 00:00:00 +00:00
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>
This commit is contained in:
parent
6eaa247a5b
commit
56bbc99e69
@ -167,12 +167,12 @@ config INPUT_M68K_BEEP
|
|||||||
depends on M68K
|
depends on M68K
|
||||||
|
|
||||||
config INPUT_MAX77693_HAPTIC
|
config INPUT_MAX77693_HAPTIC
|
||||||
tristate "MAXIM MAX77693 haptic controller support"
|
tristate "MAXIM MAX77693/MAX77843 haptic controller support"
|
||||||
depends on MFD_MAX77693 && PWM
|
depends on (MFD_MAX77693 || MFD_MAX77843) && PWM
|
||||||
select INPUT_FF_MEMLESS
|
select INPUT_FF_MEMLESS
|
||||||
help
|
help
|
||||||
This option enables support for the haptic controller on
|
This option enables support for the haptic controller on
|
||||||
MAXIM MAX77693 chip.
|
MAXIM MAX77693 and MAX77843 chips.
|
||||||
|
|
||||||
To compile this driver as module, choose M here: the
|
To compile this driver as module, choose M here: the
|
||||||
module will be called max77693-haptic.
|
module will be called max77693-haptic.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* MAXIM MAX77693 Haptic device driver
|
* MAXIM MAX77693/MAX77843 Haptic device driver
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Samsung Electronics
|
* Copyright (C) 2014,2015 Samsung Electronics
|
||||||
* Jaewon Kim <jaewon02.kim@samsung.com>
|
* Jaewon Kim <jaewon02.kim@samsung.com>
|
||||||
|
* Krzysztof Kozlowski <k.kozlowski@samsung.com>
|
||||||
*
|
*
|
||||||
* This program is not provided / owned by Maxim Integrated Products.
|
* This program is not provided / owned by Maxim Integrated Products.
|
||||||
*
|
*
|
||||||
@ -26,6 +27,7 @@
|
|||||||
#include <linux/mfd/max77693.h>
|
#include <linux/mfd/max77693.h>
|
||||||
#include <linux/mfd/max77693-common.h>
|
#include <linux/mfd/max77693-common.h>
|
||||||
#include <linux/mfd/max77693-private.h>
|
#include <linux/mfd/max77693-private.h>
|
||||||
|
#include <linux/mfd/max77843-private.h>
|
||||||
|
|
||||||
#define MAX_MAGNITUDE_SHIFT 16
|
#define MAX_MAGNITUDE_SHIFT 16
|
||||||
|
|
||||||
@ -80,6 +82,26 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (haptic->dev_type != TYPE_MAX77843)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error = regmap_update_bits(haptic->regmap_haptic,
|
||||||
|
MAX77843_SYS_REG_MAINCTRL1,
|
||||||
|
MAX77843_MAINCTRL1_BIASEN_MASK,
|
||||||
|
on << MAINCTRL1_BIASEN_SHIFT);
|
||||||
|
if (error) {
|
||||||
|
dev_err(haptic->dev, "failed to %s bias: %d\n",
|
||||||
|
on ? "enable" : "disable", error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int max77693_haptic_configure(struct max77693_haptic *haptic,
|
static int max77693_haptic_configure(struct max77693_haptic *haptic,
|
||||||
bool enable)
|
bool enable)
|
||||||
{
|
{
|
||||||
@ -94,6 +116,12 @@ static int max77693_haptic_configure(struct max77693_haptic *haptic,
|
|||||||
MAX77693_HAPTIC_PWM_DIVISOR_128);
|
MAX77693_HAPTIC_PWM_DIVISOR_128);
|
||||||
config_reg = MAX77693_HAPTIC_REG_CONFIG2;
|
config_reg = MAX77693_HAPTIC_REG_CONFIG2;
|
||||||
break;
|
break;
|
||||||
|
case TYPE_MAX77843:
|
||||||
|
value = (haptic->type << MCONFIG_MODE_SHIFT) |
|
||||||
|
(enable << MCONFIG_MEN_SHIFT) |
|
||||||
|
MAX77693_HAPTIC_PWM_DIVISOR_128;
|
||||||
|
config_reg = MAX77843_HAP_REG_MCONFIG;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -113,6 +141,9 @@ static int max77693_haptic_lowsys(struct max77693_haptic *haptic, bool enable)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
if (haptic->dev_type != TYPE_MAX77693)
|
||||||
|
return 0;
|
||||||
|
|
||||||
error = regmap_update_bits(haptic->regmap_pmic,
|
error = regmap_update_bits(haptic->regmap_pmic,
|
||||||
MAX77693_PMIC_REG_LSCNFG,
|
MAX77693_PMIC_REG_LSCNFG,
|
||||||
MAX77693_PMIC_LOW_SYS_MASK,
|
MAX77693_PMIC_LOW_SYS_MASK,
|
||||||
@ -228,6 +259,10 @@ static int max77693_haptic_open(struct input_dev *dev)
|
|||||||
struct max77693_haptic *haptic = input_get_drvdata(dev);
|
struct max77693_haptic *haptic = input_get_drvdata(dev);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
error = max77843_haptic_bias(haptic, true);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
error = regulator_enable(haptic->motor_reg);
|
error = regulator_enable(haptic->motor_reg);
|
||||||
if (error) {
|
if (error) {
|
||||||
dev_err(haptic->dev,
|
dev_err(haptic->dev,
|
||||||
@ -250,6 +285,8 @@ static void max77693_haptic_close(struct input_dev *dev)
|
|||||||
if (error)
|
if (error)
|
||||||
dev_err(haptic->dev,
|
dev_err(haptic->dev,
|
||||||
"failed to disable regulator: %d\n", error);
|
"failed to disable regulator: %d\n", error);
|
||||||
|
|
||||||
|
max77843_haptic_bias(haptic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int max77693_haptic_probe(struct platform_device *pdev)
|
static int max77693_haptic_probe(struct platform_device *pdev)
|
||||||
@ -274,6 +311,9 @@ static int max77693_haptic_probe(struct platform_device *pdev)
|
|||||||
case TYPE_MAX77693:
|
case TYPE_MAX77693:
|
||||||
haptic->regmap_haptic = max77693->regmap_haptic;
|
haptic->regmap_haptic = max77693->regmap_haptic;
|
||||||
break;
|
break;
|
||||||
|
case TYPE_MAX77843:
|
||||||
|
haptic->regmap_haptic = max77693->regmap;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(&pdev->dev, "unsupported device type: %u\n",
|
dev_err(&pdev->dev, "unsupported device type: %u\n",
|
||||||
haptic->dev_type);
|
haptic->dev_type);
|
||||||
@ -359,6 +399,7 @@ static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops,
|
|||||||
|
|
||||||
static const struct platform_device_id max77693_haptic_id[] = {
|
static const struct platform_device_id max77693_haptic_id[] = {
|
||||||
{ "max77693-haptic", TYPE_MAX77693 },
|
{ "max77693-haptic", TYPE_MAX77693 },
|
||||||
|
{ "max77843-haptic", TYPE_MAX77843 },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(platform, max77693_haptic_id);
|
MODULE_DEVICE_TABLE(platform, max77693_haptic_id);
|
||||||
@ -374,6 +415,7 @@ static struct platform_driver max77693_haptic_driver = {
|
|||||||
module_platform_driver(max77693_haptic_driver);
|
module_platform_driver(max77693_haptic_driver);
|
||||||
|
|
||||||
MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
|
MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
|
||||||
MODULE_DESCRIPTION("MAXIM MAX77693 Haptic driver");
|
MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>");
|
||||||
|
MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver");
|
||||||
MODULE_ALIAS("platform:max77693-haptic");
|
MODULE_ALIAS("platform:max77693-haptic");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user