Skip to content

Commit f2e6a24

Browse files
mranostayRobertCNelson
authored andcommitted
iio: magnetometer: ak8975: add AK09116 support to driver
Signed-off-by: Matt Ranostay <[email protected]>
1 parent c01ea8c commit f2e6a24

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

drivers/iio/magnetometer/ak8975.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
*/
9595
#define AK09912_REG_WIA1 0x00
9696
#define AK09912_REG_WIA2 0x01
97+
#define AK09916_DEVICE_ID 0x09
9798
#define AK09912_DEVICE_ID 0x04
9899
#define AK09911_DEVICE_ID 0x05
99100

@@ -223,6 +224,7 @@ enum asahi_compass_chipset {
223224
AK8963,
224225
AK09911,
225226
AK09912,
227+
AK09916,
226228
AK_MAX_TYPE
227229
};
228230

@@ -361,6 +363,31 @@ static const struct ak_def ak_def_array[AK_MAX_TYPE] = {
361363
AK09912_REG_HXL,
362364
AK09912_REG_HYL,
363365
AK09912_REG_HZL},
366+
},
367+
{
368+
.type = AK09916,
369+
.raw_to_gauss = ak09912_raw_to_gauss,
370+
.range = 32752,
371+
.ctrl_regs = {
372+
AK09912_REG_ST1,
373+
AK09912_REG_ST2,
374+
AK09912_REG_CNTL2,
375+
AK09912_REG_ASAX,
376+
AK09912_MAX_REGS},
377+
.ctrl_masks = {
378+
AK09912_REG_ST1_DRDY_MASK,
379+
AK09912_REG_ST2_HOFL_MASK,
380+
0,
381+
AK09912_REG_CNTL2_MODE_MASK},
382+
.ctrl_modes = {
383+
AK09912_REG_CNTL_MODE_POWER_DOWN,
384+
AK09912_REG_CNTL_MODE_ONCE,
385+
AK09912_REG_CNTL_MODE_SELF_TEST,
386+
AK09912_REG_CNTL_MODE_FUSE_ROM},
387+
.data_regs = {
388+
AK09912_REG_HXL,
389+
AK09912_REG_HYL,
390+
AK09912_REG_HZL},
364391
}
365392
};
366393

@@ -435,6 +462,7 @@ static int ak8975_who_i_am(struct i2c_client *client,
435462
/*
436463
* Signature for each device:
437464
* Device | WIA1 | WIA2
465+
* AK09916 | DEVICE_ID_| AK09916_DEVICE_ID
438466
* AK09912 | DEVICE_ID | AK09912_DEVICE_ID
439467
* AK09911 | DEVICE_ID | AK09911_DEVICE_ID
440468
* AK8975 | DEVICE_ID | NA
@@ -462,6 +490,9 @@ static int ak8975_who_i_am(struct i2c_client *client,
462490
if (wia_val[1] == AK09912_DEVICE_ID)
463491
return 0;
464492
break;
493+
case AK09916:
494+
if (wia_val[1] == AK09916_DEVICE_ID)
495+
return 0;
465496
default:
466497
dev_err(&client->dev, "Type %d unknown\n", type);
467498
}
@@ -1084,6 +1115,7 @@ static const struct i2c_device_id ak8975_id[] = {
10841115
{"AK8963", AK8963},
10851116
{"ak09911", AK09911},
10861117
{"ak09912", AK09912},
1118+
{"ak09916", AK09916},
10871119
{}
10881120
};
10891121

@@ -1098,6 +1130,8 @@ static const struct of_device_id ak8975_of_match[] = {
10981130
{ .compatible = "ak09911", },
10991131
{ .compatible = "asahi-kasei,ak09912", },
11001132
{ .compatible = "ak09912", },
1133+
{ .compatible = "asahi-kasei,ak09916", },
1134+
{ .compatible = "ak09916", },
11011135
{}
11021136
};
11031137
MODULE_DEVICE_TABLE(of, ak8975_of_match);

0 commit comments

Comments
 (0)