[Meego-kernel] [PATCH] ak8974: Add detect function and ami304 support.

Gram_Hsieh at wistron.com Gram_Hsieh at wistron.com
Mon Dec 20 23:20:28 PST 2010


Add detect function and ami304 support.

Sign-off-by: Gram Hsieh <gram_hsieh at wistron.com>
Sign-off-by: Major Lee <major_lee at wistron.com>
---
 Kconfig  |    4 ++--
 ak8974.c |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff -pruN a/drivers/staging/mfld-sensors/ak8974.c
b/drivers/staging/mfld-sensors/ak8974.c
--- a/drivers/staging/mfld-sensors/ak8974.c	2010-11-23
13:40:51.260749000 +0800
+++ b/drivers/staging/mfld-sensors/ak8974.c	2010-12-16
17:13:30.117382000 +0800
@@ -166,6 +166,26 @@ compass_error1:
 	return res;
 }
 
+static int ak8974_detect(struct i2c_client *client,
+			struct i2c_board_info *info)
+{
+	u8 device_id;
+
+	/* Check device ID (WIA register) */
+	device_id = i2c_smbus_read_byte_data(client, DEVICE_ID);
+	switch (device_id) {
+		case 0x47:
+			strlcpy(info->type, "ami304", I2C_NAME_SIZE);
+			break;
+		case 0x48:
+			strlcpy(info->type, "ak8974", I2C_NAME_SIZE);
+			break;
+		default:
+			return -ENODEV;
+	}
+	return 0;
+}
+
 static int __devexit ak8974_remove(struct i2c_client *client)
 {
 	struct compass_data *data = i2c_get_clientdata(client);
@@ -219,6 +239,7 @@ static const struct dev_pm_ops ak8974_pm
 
 static struct i2c_device_id ak8974_id[] = {
 	{ "ak8974", 0 },
+	{ "ami304", 0 },
 	{ }
 };
 
@@ -228,6 +249,7 @@ static struct i2c_driver ak8974_driver =
 		.pm = &ak8974_pm_ops,
 	},
 	.probe = ak8974_probe,
+	.detect = ak8974_detect,
 	.remove = __devexit_p(ak8974_remove),
 	.suspend = ak8974_suspend,
 	.resume = ak8974_resume,
diff -pruN a/drivers/staging/mfld-sensors/Kconfig
b/drivers/staging/mfld-sensors/Kconfig
--- a/drivers/staging/mfld-sensors/Kconfig	2010-11-23
13:40:50.118248000 +0800
+++ b/drivers/staging/mfld-sensors/Kconfig	2010-12-16
17:08:30.079650000 +0800
@@ -10,10 +10,10 @@ menuconfig MFLD_SENSORS
 
 if MFLD_SENSORS
 config SENSORS_AK8974COMPASS
-	tristate "Ak8974 Compass Module"
+	tristate "Ak8974/AMI304 Compass Module"
 	depends on I2C
 	help
-	  To get Compass Sensor output from AK8974 sensor.
+	  To get Compass Sensor output from AK8974/AMI304 sensor.
 
 config SENSORS_APDS9802PSPROXIMITY
         tristate "Medfield Avago APDS9802 Proximity Sensor Module"


More information about the MeeGo-kernel mailing list