diff options
author | woochul.shin <woochul.shin@samsung.com> | 2020-05-06 18:56:00 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2020-05-11 00:40:59 +0000 |
commit | 369116e2550a19bf0a1e2e771e3da610c6dfa3ee (patch) | |
tree | c9b943bc8bcee50854ebeb74050a241d0f98e697 | |
parent | ca00f833a0a8183799fef88716c42ac58e9102eb (diff) | |
download | linux-4.9-exynos9110-369116e2550a19bf0a1e2e771e3da610c6dfa3ee.tar.gz linux-4.9-exynos9110-369116e2550a19bf0a1e2e771e3da610c6dfa3ee.tar.bz2 linux-4.9-exynos9110-369116e2550a19bf0a1e2e771e3da610c6dfa3ee.zip |
motor: ztm620: set dc motor dt and add switch motor type
Modify the motor data such as motor_start_data and motor_stop_dat
according to the motor type. Each h/w device is able to select
the their own motor type in devicetree.
Example of the motor type,
- TW3's motor type is LRA
Change-Id: I2d2f830ff787ab7a9d5f042a0a7ba139b4401258
Signed-off-by: woochul.shin <woochul.shin@samsung.com>
[cw00.choi: Add commig-msg as the public style]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r-- | drivers/motor/ztm620_motor.c | 16 | ||||
-rw-r--r-- | include/linux/ztm620_motor.h | 8 |
2 files changed, 17 insertions, 7 deletions
diff --git a/drivers/motor/ztm620_motor.c b/drivers/motor/ztm620_motor.c index c85f6091db92..1fad3cf464e6 100644 --- a/drivers/motor/ztm620_motor.c +++ b/drivers/motor/ztm620_motor.c @@ -208,7 +208,7 @@ static int ztm620_motor_run(void) { } ret = ztm620_motor_reg_write(pMotorData, - MOTOR_REG_MODE_00, MODE_00_I2C); + MOTOR_REG_MODE_00, pMotorPdata->motor_start_data); if (ret < 0) { pr_err("[VIB] %s MODE_00 write fail %d\n", __func__, ret); @@ -247,7 +247,7 @@ static void vibrator_work_routine(struct work_struct *work) } } else if (pMotorData->running) { - err = ztm620_motor_reg_write(pMotorData, MOTOR_REG_MODE_00, MODE_00_STOP); + err = ztm620_motor_reg_write(pMotorData, MOTOR_REG_MODE_00, pMotorPdata->motor_stop_data); if (err < 0) { pr_err("[VIB] %s MODE_00 write fail %d\n", __func__, err); goto out; @@ -457,7 +457,7 @@ static int ztm620_motor_pm_notifier(struct notifier_block *notifier, } err = ztm620_motor_reg_write(pMotorData, - MOTOR_REG_MODE_00, MODE_00_STOP); + MOTOR_REG_MODE_00, pMotorData->msPlatData.motor_stop_data); if (err < 0) { pr_err("[VIB] %s MODE_00 write fail %d", __func__, err); goto out_err; @@ -576,10 +576,16 @@ static int of_ztm620_motor_dt(struct i2c_client* client, struct ztm620_motor_pla __func__, err); return -ENODEV; } - if (!strcmp(motor_type, "LRA")) + if (!strcmp(motor_type, "LRA")) { pdata->motor_type = ACTUATOR_LRA; - else if (!strcmp(motor_type, "ERM")) + pdata->motor_start_data = MODE_00_I2C_LRA; + pdata->motor_stop_data = MODE_00_STOP_LRA; + } + else if (!strcmp(motor_type, "ERM")) { pdata->motor_type = ACTUATOR_ERM; + pdata->motor_start_data = MODE_00_I2C_ERM; + pdata->motor_stop_data = MODE_00_STOP_ERM; + } else { dev_err(&client->dev, "[VIB] %s Wrong motor type: %s\n", __func__, motor_type); diff --git a/include/linux/ztm620_motor.h b/include/linux/ztm620_motor.h index 9efa64d1c31d..97c8dc67f192 100644 --- a/include/linux/ztm620_motor.h +++ b/include/linux/ztm620_motor.h @@ -58,8 +58,10 @@ #define MOTOR_REG_MODE_00_MASK 0x17 #define MODE_00_PWM 0x14 -#define MODE_00_I2C 0x15 -#define MODE_00_STOP 0x16 +#define MODE_00_I2C_LRA 0x15 +#define MODE_00_STOP_LRA 0x16 +#define MODE_00_I2C_ERM 0x05 +#define MODE_00_STOP_ERM 0x00 #define MOTOR_REG_MODE_01_MASK 0x1B #define MODE_01_SHIFT_DRV_MODE 0x04 @@ -125,6 +127,8 @@ struct ztm620_motor_platform_data { int freq_weak; int strength_strong; int strength_weak; + int motor_start_data; + int motor_stop_data; }; struct ztm620_motor_data { |