motor: ztm620: set dc motor dt and add switch motor type 93/233193/1
authorwoochul.shin <woochul.shin@samsung.com>
Wed, 6 May 2020 09:56:00 +0000 (18:56 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 7 May 2020 06:18:06 +0000 (15:18 +0900)
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: If584ffab5c265f56266536b50d9fdab468cb0044
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>
drivers/motor/ztm620_motor.c
include/linux/ztm620_motor.h

index c85f609..1fad3cf 100644 (file)
@@ -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);
index 9efa64d..97c8dc6 100644 (file)
 
 #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 {