|
@@ -31,6 +31,7 @@
|
|
#include <linux/bitops.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/of_gpio.h>
|
|
#include <linux/of_gpio.h>
|
|
|
|
+#include <linux/acpi.h>
|
|
|
|
|
|
#include <linux/iio/iio.h>
|
|
#include <linux/iio/iio.h>
|
|
#include <linux/iio/sysfs.h>
|
|
#include <linux/iio/sysfs.h>
|
|
@@ -475,6 +476,27 @@ static const struct iio_info ak8975_info = {
|
|
.driver_module = THIS_MODULE,
|
|
.driver_module = THIS_MODULE,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+static const struct acpi_device_id ak_acpi_match[] = {
|
|
|
|
+ {"AK8975", AK8975},
|
|
|
|
+ {"AK8963", AK8963},
|
|
|
|
+ {"INVN6500", AK8963},
|
|
|
|
+ { },
|
|
|
|
+};
|
|
|
|
+MODULE_DEVICE_TABLE(acpi, ak_acpi_match);
|
|
|
|
+
|
|
|
|
+static char *ak8975_match_acpi_device(struct device *dev,
|
|
|
|
+ enum asahi_compass_chipset *chipset)
|
|
|
|
+{
|
|
|
|
+ const struct acpi_device_id *id;
|
|
|
|
+
|
|
|
|
+ id = acpi_match_device(dev->driver->acpi_match_table, dev);
|
|
|
|
+ if (!id)
|
|
|
|
+ return NULL;
|
|
|
|
+ *chipset = (int)id->driver_data;
|
|
|
|
+
|
|
|
|
+ return (char *)dev_name(dev);
|
|
|
|
+}
|
|
|
|
+
|
|
static int ak8975_probe(struct i2c_client *client,
|
|
static int ak8975_probe(struct i2c_client *client,
|
|
const struct i2c_device_id *id)
|
|
const struct i2c_device_id *id)
|
|
{
|
|
{
|
|
@@ -482,6 +504,7 @@ static int ak8975_probe(struct i2c_client *client,
|
|
struct iio_dev *indio_dev;
|
|
struct iio_dev *indio_dev;
|
|
int eoc_gpio;
|
|
int eoc_gpio;
|
|
int err;
|
|
int err;
|
|
|
|
+ char *name = NULL;
|
|
|
|
|
|
/* Grab and set up the supplied GPIO. */
|
|
/* Grab and set up the supplied GPIO. */
|
|
if (client->dev.platform_data)
|
|
if (client->dev.platform_data)
|
|
@@ -519,8 +542,18 @@ static int ak8975_probe(struct i2c_client *client,
|
|
data->eoc_gpio = eoc_gpio;
|
|
data->eoc_gpio = eoc_gpio;
|
|
data->eoc_irq = 0;
|
|
data->eoc_irq = 0;
|
|
|
|
|
|
- data->chipset = (enum asahi_compass_chipset)(id->driver_data);
|
|
|
|
- dev_dbg(&client->dev, "Asahi compass chip %s\n", id->name);
|
|
|
|
|
|
+ /* id will be NULL when enumerated via ACPI */
|
|
|
|
+ if (id) {
|
|
|
|
+ data->chipset =
|
|
|
|
+ (enum asahi_compass_chipset)(id->driver_data);
|
|
|
|
+ name = (char *) id->name;
|
|
|
|
+ } else if (ACPI_HANDLE(&client->dev))
|
|
|
|
+ name = ak8975_match_acpi_device(&client->dev, &data->chipset);
|
|
|
|
+ else {
|
|
|
|
+ err = -ENOSYS;
|
|
|
|
+ goto exit_free_iio;
|
|
|
|
+ }
|
|
|
|
+ dev_dbg(&client->dev, "Asahi compass chip %s\n", name);
|
|
|
|
|
|
/* Perform some basic start-of-day setup of the device. */
|
|
/* Perform some basic start-of-day setup of the device. */
|
|
err = ak8975_setup(client);
|
|
err = ak8975_setup(client);
|
|
@@ -538,7 +571,7 @@ static int ak8975_probe(struct i2c_client *client,
|
|
indio_dev->info = &ak8975_info;
|
|
indio_dev->info = &ak8975_info;
|
|
indio_dev->name = id->name;
|
|
indio_dev->name = id->name;
|
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
|
-
|
|
|
|
|
|
+ indio_dev->name = name;
|
|
err = iio_device_register(indio_dev);
|
|
err = iio_device_register(indio_dev);
|
|
if (err < 0)
|
|
if (err < 0)
|
|
goto exit_free_iio;
|
|
goto exit_free_iio;
|
|
@@ -593,6 +626,7 @@ static struct i2c_driver ak8975_driver = {
|
|
.driver = {
|
|
.driver = {
|
|
.name = "ak8975",
|
|
.name = "ak8975",
|
|
.of_match_table = ak8975_of_match,
|
|
.of_match_table = ak8975_of_match,
|
|
|
|
+ .acpi_match_table = ACPI_PTR(ak_acpi_match),
|
|
},
|
|
},
|
|
.probe = ak8975_probe,
|
|
.probe = ak8975_probe,
|
|
.remove = ak8975_remove,
|
|
.remove = ak8975_remove,
|