Re: [PATCH] iio: magnetometer: ak8975: add AK09116 support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 25 Aug 2021 05:07:38 +0300
Matt Ranostay <matt.ranostay@xxxxxxxxxxxx> wrote:

> 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@xxxxxxxxxxxx>
Hi Matt,

There are a few odd bits of formatting and ordering in here, but they are in
keeping with the existing code so fair enough!

Applied to the togreg branch of iio.git and pushed out as testing for
0-day to have fun with it.

Thanks,

Jonathan

> ---
>  .../iio/magnetometer/asahi-kasei,ak8975.yaml  |  2 ++
>  drivers/iio/magnetometer/Kconfig              |  2 +-
>  drivers/iio/magnetometer/ak8975.c             | 35 +++++++++++++++++++
>  3 files changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml b/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
> index a0a1ffe017df..c552b2b7751a 100644
> --- a/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
> +++ b/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
> @@ -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:
> diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig
> index 74ad5701c6c2..565ee41ccb3a 100644
> --- a/drivers/iio/magnetometer/Kconfig
> +++ b/drivers/iio/magnetometer/Kconfig
> @@ -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.
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index 42b8a2680e3a..6e82dc54a417 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -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
>  
> @@ -208,6 +209,7 @@ enum asahi_compass_chipset {
>  	AK8963,
>  	AK09911,
>  	AK09912,
> +	AK09916,
>  };
>  
>  enum ak_ctrl_reg_addr {
> @@ -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},
>  	}
>  };
>  
> @@ -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
> @@ -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);
>  	}
> @@ -1057,6 +1089,7 @@ static const struct i2c_device_id ak8975_id[] = {
>  	{"AK8963", AK8963},
>  	{"ak09911", AK09911},
>  	{"ak09912", AK09912},
> +	{"ak09916", AK09916},
>  	{}
>  };
>  
> @@ -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);




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux