Skip to content

Commit 89cf93b

Browse files
JIaxygajic23
authored andcommitted
iio: magnetometer: ak8975: Add AK09118 support
Add additional AK09118 to the magnetometer driver which has the same register mapping and scaling as the AK09112 device. Signed-off-by: Danila Tikhonov <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Barnabás Czémán <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent c19bf7f commit 89cf93b

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

drivers/iio/magnetometer/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ config AK8975
3939
select IIO_TRIGGERED_BUFFER
4040
help
4141
Say yes here to build support for Asahi Kasei AK8975, AK8963,
42-
AK09911, AK09912 or AK09916 3-Axis Magnetometer.
42+
AK09911, AK09912, AK09916 or AK09918 3-Axis Magnetometer.
4343

4444
To compile this driver as a module, choose M here: the module
4545
will be called ak8975.

drivers/iio/magnetometer/ak8975.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
*/
7979
#define AK09912_REG_WIA1 0x00
8080
#define AK09912_REG_WIA2 0x01
81+
#define AK09918_DEVICE_ID 0x0C
8182
#define AK09916_DEVICE_ID 0x09
8283
#define AK09912_DEVICE_ID 0x04
8384
#define AK09911_DEVICE_ID 0x05
@@ -209,6 +210,7 @@ enum asahi_compass_chipset {
209210
AK09911,
210211
AK09912,
211212
AK09916,
213+
AK09918,
212214
};
213215

214216
enum ak_ctrl_reg_addr {
@@ -371,6 +373,34 @@ static const struct ak_def ak_def_array[] = {
371373
AK09912_REG_HXL,
372374
AK09912_REG_HYL,
373375
AK09912_REG_HZL},
376+
},
377+
[AK09918] = {
378+
/* ak09918 is register compatible with ak09912 this is for avoid
379+
* unknown id messages.
380+
*/
381+
.type = AK09918,
382+
.raw_to_gauss = ak09912_raw_to_gauss,
383+
.range = 32752,
384+
.ctrl_regs = {
385+
AK09912_REG_ST1,
386+
AK09912_REG_ST2,
387+
AK09912_REG_CNTL2,
388+
AK09912_REG_ASAX,
389+
AK09912_MAX_REGS},
390+
.ctrl_masks = {
391+
AK09912_REG_ST1_DRDY_MASK,
392+
AK09912_REG_ST2_HOFL_MASK,
393+
0,
394+
AK09912_REG_CNTL2_MODE_MASK},
395+
.ctrl_modes = {
396+
AK09912_REG_CNTL_MODE_POWER_DOWN,
397+
AK09912_REG_CNTL_MODE_ONCE,
398+
AK09912_REG_CNTL_MODE_SELF_TEST,
399+
AK09912_REG_CNTL_MODE_FUSE_ROM},
400+
.data_regs = {
401+
AK09912_REG_HXL,
402+
AK09912_REG_HYL,
403+
AK09912_REG_HZL},
374404
}
375405
};
376406

@@ -452,6 +482,7 @@ static int ak8975_who_i_am(struct i2c_client *client,
452482
/*
453483
* Signature for each device:
454484
* Device | WIA1 | WIA2
485+
* AK09918 | DEVICE_ID_| AK09918_DEVICE_ID
455486
* AK09916 | DEVICE_ID_| AK09916_DEVICE_ID
456487
* AK09912 | DEVICE_ID | AK09912_DEVICE_ID
457488
* AK09911 | DEVICE_ID | AK09911_DEVICE_ID
@@ -484,6 +515,10 @@ static int ak8975_who_i_am(struct i2c_client *client,
484515
if (wia_val[1] == AK09916_DEVICE_ID)
485516
return 0;
486517
break;
518+
case AK09918:
519+
if (wia_val[1] == AK09918_DEVICE_ID)
520+
return 0;
521+
break;
487522
}
488523

489524
dev_info(&client->dev, "Device ID %x is unknown.\n", wia_val[1]);
@@ -1071,6 +1106,7 @@ static const struct i2c_device_id ak8975_id[] = {
10711106
{"ak09911", (kernel_ulong_t)&ak_def_array[AK09911] },
10721107
{"ak09912", (kernel_ulong_t)&ak_def_array[AK09912] },
10731108
{"ak09916", (kernel_ulong_t)&ak_def_array[AK09916] },
1109+
{"ak09918", (kernel_ulong_t)&ak_def_array[AK09918] },
10741110
{}
10751111
};
10761112
MODULE_DEVICE_TABLE(i2c, ak8975_id);
@@ -1085,6 +1121,7 @@ static const struct of_device_id ak8975_of_match[] = {
10851121
{ .compatible = "asahi-kasei,ak09912", .data = &ak_def_array[AK09912] },
10861122
{ .compatible = "ak09912", .data = &ak_def_array[AK09912] },
10871123
{ .compatible = "asahi-kasei,ak09916", .data = &ak_def_array[AK09916] },
1124+
{ .compatible = "asahi-kasei,ak09918", .data = &ak_def_array[AK09918] },
10881125
{}
10891126
};
10901127
MODULE_DEVICE_TABLE(of, ak8975_of_match);

0 commit comments

Comments
 (0)