Skip to content

Commit df53055

Browse files
Griffin Kroah-Hartmandtor
authored andcommitted
Input: aw86927 - add support for Awinic AW86938
Add support for the I2C-connected Awinic AW86938 LRA haptic controller. The AW86938 has a similar but slightly different register layout. In particular, the boost mode register values. The AW86938 also has some extra features that aren't implemented in this driver yet. Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com> Link: https://patch.msgid.link/20260302-aw86938-driver-v4-3-92c865df9cca@fairphone.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent b73724b commit df53055

1 file changed

Lines changed: 44 additions & 8 deletions

File tree

drivers/input/misc/aw86927.c

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
#define AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK GENMASK(6, 0)
4444
#define AW86927_PLAYCFG1_BST_8500MV 0x50
4545

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+
4652
#define AW86927_PLAYCFG2_REG 0x07
4753

4854
#define AW86927_PLAYCFG3_REG 0x08
@@ -140,6 +146,7 @@
140146
#define AW86927_CHIPIDH_REG 0x57
141147
#define AW86927_CHIPIDL_REG 0x58
142148
#define AW86927_CHIPID 0x9270
149+
#define AW86938_CHIPID 0x9380
143150

144151
#define AW86927_TMCFG_REG 0x5b
145152
#define AW86927_TMCFG_UNLOCK 0x7d
@@ -173,7 +180,13 @@ enum aw86927_work_mode {
173180
AW86927_RAM_MODE,
174181
};
175182

183+
enum aw86927_model {
184+
AW86927,
185+
AW86938,
186+
};
187+
176188
struct aw86927_data {
189+
enum aw86927_model model;
177190
struct work_struct play_work;
178191
struct device *dev;
179192
struct input_dev *input_dev;
@@ -565,13 +578,26 @@ static int aw86927_haptic_init(struct aw86927_data *haptics)
565578
if (err)
566579
return err;
567580

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+
}
575601

576602
err = regmap_update_bits(haptics->regmap,
577603
AW86927_PLAYCFG3_REG,
@@ -599,6 +625,9 @@ static int aw86927_ram_init(struct aw86927_data *haptics)
599625
FIELD_PREP(AW86927_SYSCTRL3_EN_RAMINIT_MASK,
600626
AW86927_SYSCTRL3_EN_RAMINIT_ON));
601627

628+
/* AW86938 wants a 1ms delay here */
629+
usleep_range(1000, 1500);
630+
602631
/* Set base address for the start of the SRAM waveforms */
603632
err = regmap_write(haptics->regmap,
604633
AW86927_BASEADDRH_REG, AW86927_BASEADDRH_VAL);
@@ -717,7 +746,14 @@ static int aw86927_detect(struct aw86927_data *haptics)
717746

718747
chip_id = be16_to_cpu(read_buf);
719748

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:
721757
dev_err(haptics->dev, "Unexpected CHIPID value 0x%x\n", chip_id);
722758
return -ENODEV;
723759
}

0 commit comments

Comments
 (0)