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

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>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
56bbc99e 6eaa247a

+48 -6
+3 -3
drivers/input/misc/Kconfig
··· 167 167 depends on M68K 168 168 169 169 config INPUT_MAX77693_HAPTIC 170 - tristate "MAXIM MAX77693 haptic controller support" 171 - depends on MFD_MAX77693 && PWM 170 + tristate "MAXIM MAX77693/MAX77843 haptic controller support" 171 + depends on (MFD_MAX77693 || MFD_MAX77843) && PWM 172 172 select INPUT_FF_MEMLESS 173 173 help 174 174 This option enables support for the haptic controller on 175 - MAXIM MAX77693 chip. 175 + MAXIM MAX77693 and MAX77843 chips. 176 176 177 177 To compile this driver as module, choose M here: the 178 178 module will be called max77693-haptic.
+45 -3
drivers/input/misc/max77693-haptic.c
··· 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 5 * Jaewon Kim <jaewon02.kim@samsung.com> 6 + * Krzysztof Kozlowski <k.kozlowski@samsung.com> 6 7 * 7 8 * This program is not provided / owned by Maxim Integrated Products. 8 9 * ··· 27 26 #include <linux/mfd/max77693.h> 28 27 #include <linux/mfd/max77693-common.h> 29 28 #include <linux/mfd/max77693-private.h> 29 + #include <linux/mfd/max77843-private.h> 30 30 31 31 #define MAX_MAGNITUDE_SHIFT 16 32 32 ··· 82 80 return 0; 83 81 } 84 82 83 + static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on) 84 + { 85 + int error; 86 + 87 + if (haptic->dev_type != TYPE_MAX77843) 88 + return 0; 89 + 90 + error = regmap_update_bits(haptic->regmap_haptic, 91 + MAX77843_SYS_REG_MAINCTRL1, 92 + MAX77843_MAINCTRL1_BIASEN_MASK, 93 + on << MAINCTRL1_BIASEN_SHIFT); 94 + if (error) { 95 + dev_err(haptic->dev, "failed to %s bias: %d\n", 96 + on ? "enable" : "disable", error); 97 + return error; 98 + } 99 + 100 + return 0; 101 + } 102 + 85 103 static int max77693_haptic_configure(struct max77693_haptic *haptic, 86 104 bool enable) 87 105 { ··· 115 93 (haptic->mode << MAX77693_CONFIG2_HTYP) | 116 94 MAX77693_HAPTIC_PWM_DIVISOR_128); 117 95 config_reg = MAX77693_HAPTIC_REG_CONFIG2; 96 + break; 97 + case TYPE_MAX77843: 98 + value = (haptic->type << MCONFIG_MODE_SHIFT) | 99 + (enable << MCONFIG_MEN_SHIFT) | 100 + MAX77693_HAPTIC_PWM_DIVISOR_128; 101 + config_reg = MAX77843_HAP_REG_MCONFIG; 118 102 break; 119 103 default: 120 104 return -EINVAL; ··· 140 112 static int max77693_haptic_lowsys(struct max77693_haptic *haptic, bool enable) 141 113 { 142 114 int error; 115 + 116 + if (haptic->dev_type != TYPE_MAX77693) 117 + return 0; 143 118 144 119 error = regmap_update_bits(haptic->regmap_pmic, 145 120 MAX77693_PMIC_REG_LSCNFG, ··· 259 228 struct max77693_haptic *haptic = input_get_drvdata(dev); 260 229 int error; 261 230 231 + error = max77843_haptic_bias(haptic, true); 232 + if (error) 233 + return error; 234 + 262 235 error = regulator_enable(haptic->motor_reg); 263 236 if (error) { 264 237 dev_err(haptic->dev, ··· 285 250 if (error) 286 251 dev_err(haptic->dev, 287 252 "failed to disable regulator: %d\n", error); 253 + 254 + max77843_haptic_bias(haptic, false); 288 255 } 289 256 290 257 static int max77693_haptic_probe(struct platform_device *pdev) ··· 310 273 switch (haptic->dev_type) { 311 274 case TYPE_MAX77693: 312 275 haptic->regmap_haptic = max77693->regmap_haptic; 276 + break; 277 + case TYPE_MAX77843: 278 + haptic->regmap_haptic = max77693->regmap; 313 279 break; 314 280 default: 315 281 dev_err(&pdev->dev, "unsupported device type: %u\n", ··· 399 359 400 360 static const struct platform_device_id max77693_haptic_id[] = { 401 361 { "max77693-haptic", TYPE_MAX77693 }, 362 + { "max77843-haptic", TYPE_MAX77843 }, 402 363 {}, 403 364 }; 404 365 MODULE_DEVICE_TABLE(platform, max77693_haptic_id); ··· 415 374 module_platform_driver(max77693_haptic_driver); 416 375 417 376 MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>"); 418 - MODULE_DESCRIPTION("MAXIM MAX77693 Haptic driver"); 377 + MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>"); 378 + MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver"); 419 379 MODULE_ALIAS("platform:max77693-haptic"); 420 380 MODULE_LICENSE("GPL");