Skip to content

Commit

Permalink
iio: magnetometer: ak8975: add AK09116 support
Browse files Browse the repository at this point in the history
Add additional AK09116 to the magnetometer driver which has the same
register mapping and scaling as the AK09112 device.

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20210825020738.35877-1-matt.ranostay@konsulko.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
mranostay authored and jic23 committed Sep 14, 2021
1 parent c5dc9e3 commit 76e28aa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ properties:
- asahi-kasei,ak8963
- asahi-kasei,ak09911
- asahi-kasei,ak09912
- asahi-kasei,ak09916
- enum:
- ak8975
- ak8963
- ak09911
- ak09912
- ak09916
deprecated: true

reg:
Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/magnetometer/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ config AK8975
select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Asahi Kasei AK8975, AK8963,
AK09911 or AK09912 3-Axis Magnetometer.
AK09911, AK09912 or AK09916 3-Axis Magnetometer.

To compile this driver as a module, choose M here: the module
will be called ak8975.
Expand Down
35 changes: 35 additions & 0 deletions drivers/iio/magnetometer/ak8975.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
*/
#define AK09912_REG_WIA1 0x00
#define AK09912_REG_WIA2 0x01
#define AK09916_DEVICE_ID 0x09
#define AK09912_DEVICE_ID 0x04
#define AK09911_DEVICE_ID 0x05

Expand Down Expand Up @@ -208,6 +209,7 @@ enum asahi_compass_chipset {
AK8963,
AK09911,
AK09912,
AK09916,
};

enum ak_ctrl_reg_addr {
Expand Down Expand Up @@ -345,6 +347,31 @@ static const struct ak_def ak_def_array[] = {
AK09912_REG_HXL,
AK09912_REG_HYL,
AK09912_REG_HZL},
},
{
.type = AK09916,
.raw_to_gauss = ak09912_raw_to_gauss,
.range = 32752,
.ctrl_regs = {
AK09912_REG_ST1,
AK09912_REG_ST2,
AK09912_REG_CNTL2,
AK09912_REG_ASAX,
AK09912_MAX_REGS},
.ctrl_masks = {
AK09912_REG_ST1_DRDY_MASK,
AK09912_REG_ST2_HOFL_MASK,
0,
AK09912_REG_CNTL2_MODE_MASK},
.ctrl_modes = {
AK09912_REG_CNTL_MODE_POWER_DOWN,
AK09912_REG_CNTL_MODE_ONCE,
AK09912_REG_CNTL_MODE_SELF_TEST,
AK09912_REG_CNTL_MODE_FUSE_ROM},
.data_regs = {
AK09912_REG_HXL,
AK09912_REG_HYL,
AK09912_REG_HZL},
}
};

Expand Down Expand Up @@ -425,6 +452,7 @@ static int ak8975_who_i_am(struct i2c_client *client,
/*
* Signature for each device:
* Device | WIA1 | WIA2
* AK09916 | DEVICE_ID_| AK09916_DEVICE_ID
* AK09912 | DEVICE_ID | AK09912_DEVICE_ID
* AK09911 | DEVICE_ID | AK09911_DEVICE_ID
* AK8975 | DEVICE_ID | NA
Expand Down Expand Up @@ -452,6 +480,10 @@ static int ak8975_who_i_am(struct i2c_client *client,
if (wia_val[1] == AK09912_DEVICE_ID)
return 0;
break;
case AK09916:
if (wia_val[1] == AK09916_DEVICE_ID)
return 0;
break;
default:
dev_err(&client->dev, "Type %d unknown\n", type);
}
Expand Down Expand Up @@ -1057,6 +1089,7 @@ static const struct i2c_device_id ak8975_id[] = {
{"AK8963", AK8963},
{"ak09911", AK09911},
{"ak09912", AK09912},
{"ak09916", AK09916},
{}
};

Expand All @@ -1071,6 +1104,8 @@ static const struct of_device_id ak8975_of_match[] = {
{ .compatible = "ak09911", },
{ .compatible = "asahi-kasei,ak09912", },
{ .compatible = "ak09912", },
{ .compatible = "asahi-kasei,ak09916", },
{ .compatible = "ak09916", },
{}
};
MODULE_DEVICE_TABLE(of, ak8975_of_match);
Expand Down

0 comments on commit 76e28aa

Please sign in to comment.