Skip to content

Commit 7c94a8b

Browse files
linuswjic23
authored andcommitted
iio: magn: add a driver for AK8974
This adds a driver for the Asahi Kasei AK8974 and its sibling AMI305 magnetometers. It was deployed on scale in 2009 on a multitude of devices. It is distincly different from AK8973 and AK8975 and needs its own driver. This patch is based on the long lost work of Samu Onkalo at Nokia, who made a misc character device driver for the Maemo/MeeGo Nokia devices, before the time of the IIO subsystem. It was mounted in e.g. the Nokia N950, N8, N86, N97 etc. It is also mounted on the ST-Ericsson HREF reference designs. It works nicely in sysfs: $ cat in_magn_x_raw && cat in_magn_y_raw && cat in_magn_z_raw -55 -101 161 And with buffered reads using a simple HRTimer trigger: $ generic_buffer -c10 -a -n ak8974 -t foo iio device number being used is 3 iio trigger number being used is 2 No channels are enabled, enabling all channels Enabling: in_magn_x_en Enabling: in_magn_y_en Enabling: in_magn_z_en Enabling: in_timestamp_en /sys/bus/iio/devices/iio:device3 foo -58.000000 -102.000000 157.000000 946684970985321044 -60.000000 -98.000000 159.000000 946684971012237548 -60.000000 -106.000000 163.000000 946684971032257080 -62.000000 -94.000000 169.000000 946684971052185058 -58.000000 -98.000000 163.000000 946684971072204589 -54.000000 -100.000000 163.000000 946684971092224121 -53.000000 -103.000000 164.000000 946684971112731933 -50.000000 -102.000000 165.000000 946684971132232666 -61.000000 -101.000000 164.000000 946684971152191162 -57.000000 -99.000000 168.000000 946684971172210693 Disabling: in_magn_x_en Disabling: in_magn_y_en Disabling: in_magn_z_en Disabling: in_timestamp_en I cannot currently scale these raw values to gauss. This is because of lack of documentation. I have sent a request for a datasheet to Asahi Kasei. The driver can optionally use a DRDY line IRQ to capture data, else it will sleep and poll. Cc: Samu Onkalo <[email protected]> Cc: Sebastian Reichel <[email protected]> Cc: Peter Meerwald-Stadler <[email protected]> Tested-By: Sebastian Reichel <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent bcdf177 commit 7c94a8b

File tree

4 files changed

+886
-1
lines changed

4 files changed

+886
-1
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,13 @@ S: Maintained
19301930
F: drivers/media/i2c/as3645a.c
19311931
F: include/media/i2c/as3645a.h
19321932

1933+
ASAHI KASEI AK8974 DRIVER
1934+
M: Linus Walleij <[email protected]>
1935+
1936+
W: http://www.akm.com/
1937+
S: Supported
1938+
F: drivers/iio/magnetometer/ak8974.c
1939+
19331940
ASC7621 HARDWARE MONITOR DRIVER
19341941
M: George Joseph <[email protected]>
19351942

drivers/iio/magnetometer/Kconfig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@
55

66
menu "Magnetometer sensors"
77

8+
config AK8974
9+
tristate "Asahi Kasei AK8974 3-Axis Magnetometer"
10+
depends on I2C
11+
depends on OF
12+
select REGMAP_I2C
13+
select IIO_BUFFER
14+
select IIO_TRIGGERED_BUFFER
15+
help
16+
Say yes here to build support for Asahi Kasei AK8974 or
17+
AMI305 I2C-based 3-axis magnetometer chips.
18+
19+
To compile this driver as a module, choose M here: the module
20+
will be called ak8974.
21+
822
config AK8975
9-
tristate "Asahi Kasei AK 3-Axis Magnetometer"
23+
tristate "Asahi Kasei AK8975 3-Axis Magnetometer"
1024
depends on I2C
1125
depends on GPIOLIB || COMPILE_TEST
1226
select IIO_BUFFER

drivers/iio/magnetometer/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
# When adding new entries keep the list in alphabetical order
6+
obj-$(CONFIG_AK8974) += ak8974.o
67
obj-$(CONFIG_AK8975) += ak8975.o
78
obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o
89
obj-$(CONFIG_BMC150_MAGN_I2C) += bmc150_magn_i2c.o

0 commit comments

Comments
 (0)