|
43 | 43 | #define AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK GENMASK(6, 0) |
44 | 44 | #define AW86927_PLAYCFG1_BST_8500MV 0x50 |
45 | 45 |
|
| 46 | +#define AW86938_PLAYCFG1_REG 0x06 |
| 47 | +#define AW86938_PLAYCFG1_BST_MODE_MASK GENMASK(5, 5) |
| 48 | +#define AW86938_PLAYCFG1_BST_MODE_BYPASS 0 |
| 49 | +#define AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK GENMASK(4, 0) |
| 50 | +#define AW86938_PLAYCFG1_BST_7000MV 0x11 |
| 51 | + |
46 | 52 | #define AW86927_PLAYCFG2_REG 0x07 |
47 | 53 |
|
48 | 54 | #define AW86927_PLAYCFG3_REG 0x08 |
|
140 | 146 | #define AW86927_CHIPIDH_REG 0x57 |
141 | 147 | #define AW86927_CHIPIDL_REG 0x58 |
142 | 148 | #define AW86927_CHIPID 0x9270 |
| 149 | +#define AW86938_CHIPID 0x9380 |
143 | 150 |
|
144 | 151 | #define AW86927_TMCFG_REG 0x5b |
145 | 152 | #define AW86927_TMCFG_UNLOCK 0x7d |
@@ -173,7 +180,13 @@ enum aw86927_work_mode { |
173 | 180 | AW86927_RAM_MODE, |
174 | 181 | }; |
175 | 182 |
|
| 183 | +enum aw86927_model { |
| 184 | + AW86927, |
| 185 | + AW86938, |
| 186 | +}; |
| 187 | + |
176 | 188 | struct aw86927_data { |
| 189 | + enum aw86927_model model; |
177 | 190 | struct work_struct play_work; |
178 | 191 | struct device *dev; |
179 | 192 | struct input_dev *input_dev; |
@@ -565,13 +578,26 @@ static int aw86927_haptic_init(struct aw86927_data *haptics) |
565 | 578 | if (err) |
566 | 579 | return err; |
567 | 580 |
|
568 | | - err = regmap_update_bits(haptics->regmap, |
569 | | - AW86927_PLAYCFG1_REG, |
570 | | - AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK, |
571 | | - FIELD_PREP(AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK, |
572 | | - AW86927_PLAYCFG1_BST_8500MV)); |
573 | | - if (err) |
574 | | - return err; |
| 581 | + switch (haptics->model) { |
| 582 | + case AW86927: |
| 583 | + err = regmap_update_bits(haptics->regmap, |
| 584 | + AW86927_PLAYCFG1_REG, |
| 585 | + AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK, |
| 586 | + FIELD_PREP(AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK, |
| 587 | + AW86927_PLAYCFG1_BST_8500MV)); |
| 588 | + if (err) |
| 589 | + return err; |
| 590 | + break; |
| 591 | + case AW86938: |
| 592 | + err = regmap_update_bits(haptics->regmap, |
| 593 | + AW86938_PLAYCFG1_REG, |
| 594 | + AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK, |
| 595 | + FIELD_PREP(AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK, |
| 596 | + AW86938_PLAYCFG1_BST_7000MV)); |
| 597 | + if (err) |
| 598 | + return err; |
| 599 | + break; |
| 600 | + } |
575 | 601 |
|
576 | 602 | err = regmap_update_bits(haptics->regmap, |
577 | 603 | AW86927_PLAYCFG3_REG, |
@@ -599,6 +625,9 @@ static int aw86927_ram_init(struct aw86927_data *haptics) |
599 | 625 | FIELD_PREP(AW86927_SYSCTRL3_EN_RAMINIT_MASK, |
600 | 626 | AW86927_SYSCTRL3_EN_RAMINIT_ON)); |
601 | 627 |
|
| 628 | + /* AW86938 wants a 1ms delay here */ |
| 629 | + usleep_range(1000, 1500); |
| 630 | + |
602 | 631 | /* Set base address for the start of the SRAM waveforms */ |
603 | 632 | err = regmap_write(haptics->regmap, |
604 | 633 | AW86927_BASEADDRH_REG, AW86927_BASEADDRH_VAL); |
@@ -717,7 +746,14 @@ static int aw86927_detect(struct aw86927_data *haptics) |
717 | 746 |
|
718 | 747 | chip_id = be16_to_cpu(read_buf); |
719 | 748 |
|
720 | | - if (chip_id != AW86927_CHIPID) { |
| 749 | + switch (chip_id) { |
| 750 | + case AW86927_CHIPID: |
| 751 | + haptics->model = AW86927; |
| 752 | + break; |
| 753 | + case AW86938_CHIPID: |
| 754 | + haptics->model = AW86938; |
| 755 | + break; |
| 756 | + default: |
721 | 757 | dev_err(haptics->dev, "Unexpected CHIPID value 0x%x\n", chip_id); |
722 | 758 | return -ENODEV; |
723 | 759 | } |
|
0 commit comments