From 06777c562a50a09c4a2becfb2bf63c762a45df17 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Sep 2016 19:35:32 +0200 Subject: iio: accel: mxc6255 add support for the mxc6225 The mxc6225 is fully compatible with the existing mxc6255 driver, add support for it. Signed-off-by: Hans de Goede Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mxc6255.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/iio/accel') diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c index 97ccde722e7b..50343a7818d6 100644 --- a/drivers/iio/accel/mxc6255.c +++ b/drivers/iio/accel/mxc6255.c @@ -26,6 +26,7 @@ #define MXC6255_REG_YOUT 0x01 #define MXC6255_REG_CHIP_ID 0x08 +#define MXC6225_CHIP_ID 0xe5 #define MXC6255_CHIP_ID 0x05 /* @@ -154,7 +155,11 @@ static int mxc6255_probe(struct i2c_client *client, return ret; } - if (chip_id != MXC6255_CHIP_ID) { + switch (chip_id) { + case MXC6225_CHIP_ID: + case MXC6255_CHIP_ID: + break; + default: dev_err(&client->dev, "Invalid chip id %x\n", chip_id); return -ENODEV; } @@ -171,12 +176,14 @@ static int mxc6255_probe(struct i2c_client *client, } static const struct acpi_device_id mxc6255_acpi_match[] = { + {"MXC6225", 0}, {"MXC6255", 0}, { } }; MODULE_DEVICE_TABLE(acpi, mxc6255_acpi_match); static const struct i2c_device_id mxc6255_id[] = { + {"mxc6225", 0}, {"mxc6255", 0}, { } }; -- cgit v1.2.3 From 1696566f995cfd4ddf3f167b4097cdc83f1458f2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 11 Sep 2016 18:29:16 +0200 Subject: iio: accel: mxc6255: Fix chip-id check The initial commit adding support for the mxc6225 assumed the mxc6225 has a chip-id of 0xe5 based on testing on a single Allwinner A23 tablet with a mxc6225. Testing on a bunch of other Allwinner tablets have shown that the chip-id for the mxc6225 is not constant. A datasheet for the MXC6255 which I've found online says that bits 7 and 6 of the chip-id register are undefined (for the mxc6255), testing on 5 different tablets with a mxc6225 has found the following ids: 0x25, 0x45, 0x65, 0x85, 0xe5. So it seems that for the mxc6225 bits 7, 6 and 5 of the chip-id register are undefined. This commit adjusts the chip-id check so that the mxc6255 driver properly recognizes the mxc6225 in all these tablets. Signed-off-by: Hans de Goede Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mxc6255.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/iio/accel') diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c index 50343a7818d6..0abad6948201 100644 --- a/drivers/iio/accel/mxc6255.c +++ b/drivers/iio/accel/mxc6255.c @@ -26,7 +26,6 @@ #define MXC6255_REG_YOUT 0x01 #define MXC6255_REG_CHIP_ID 0x08 -#define MXC6225_CHIP_ID 0xe5 #define MXC6255_CHIP_ID 0x05 /* @@ -155,11 +154,7 @@ static int mxc6255_probe(struct i2c_client *client, return ret; } - switch (chip_id) { - case MXC6225_CHIP_ID: - case MXC6255_CHIP_ID: - break; - default: + if ((chip_id & 0x1f) != MXC6255_CHIP_ID) { dev_err(&client->dev, "Invalid chip id %x\n", chip_id); return -ENODEV; } -- cgit v1.2.3