From 04dae3acbff184204760f1afa464a19db061ed7b Mon Sep 17 00:00:00 2001 From: Ricardo Rivera-Matos Date: Thu, 15 Aug 2024 19:09:32 +0000 Subject: [PATCH] drivers: haptics: drv2605: Hard codes open loop mode for LRA mode Enables open loop operation when initializing into LRA mode. Open loop operation is enabled by default for ERM mode. This is hard coded for LRA mode because calibration is currently unsupported. Signed-off-by: Ricardo Rivera-Matos --- drivers/haptics/drv2605.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/haptics/drv2605.c b/drivers/haptics/drv2605.c index bc8c2f3a8c0..a1de61512f2 100644 --- a/drivers/haptics/drv2605.c +++ b/drivers/haptics/drv2605.c @@ -90,6 +90,9 @@ LOG_MODULE_REGISTER(DRV2605, CONFIG_HAPTICS_LOG_LEVEL); #define DRV2605_LOOP_GAIN GENMASK(3, 2) #define DRV2605_BEMF_GAIN GENMASK(1, 0) +#define DRV2605_ACTUATOR_MODE_ERM 0 +#define DRV2605_ACTUATOR_MODE_LRA 1 + #define DRV2605_REG_CONTROL1 0x1b #define DRV2605_STARTUP_BOOST BIT(7) #define DRV2605_AC_COUPLE BIT(5) @@ -467,6 +470,14 @@ static int drv2605_hw_config(const struct device *dev) return ret; } + if (config->actuator_mode == DRV2605_ACTUATOR_MODE_LRA) { + ret = i2c_reg_update_byte_dt(&config->i2c, DRV2605_REG_CONTROL3, + DRV2605_LRA_OPEN_LOOP, DRV2605_LRA_OPEN_LOOP); + if (ret < 0) { + return ret; + } + } + return 0; }