MLK-17061-1 sensor: set sensor interrupt pins as open-drain
authorGao Pan <pandy.gao@nxp.com>
Mon, 4 Dec 2017 05:27:00 +0000 (13:27 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:49:52 +0000 (14:49 -0500)
The sensors share an interrupt pin on imx8qm/imx8qxp mek.
As a result, the interrupt signals will be interfered by
each other in default push-pull status.

This patch sets sensor interrupt pins as open-drain when
necessary.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
(cherry-picked from 48bcb7aafa2a3ced923d1a1753bb19d89a9fc273)

drivers/input/misc/mpl3115.c
drivers/misc/fxas2100x.c
drivers/misc/fxos8700.c

index b272cf3..4bd5420 100644 (file)
@@ -157,6 +157,13 @@ static const struct attribute_group mpl3115_attr_group = {
 static void mpl3115_device_init(struct i2c_client *client)
 {
        u8 val[8];
+       struct device_node *np = client->dev.of_node;
+
+       /* set interrupt pin as open-drain */
+       if (of_get_property(np, "interrupt-open-drain", NULL)) {
+               val[0] = 0x11;
+               mpl3115_i2c_write(client, MPL3115_CTRL_REG3, val, 1);
+       }
 
        val[0] = 0x28;
        mpl3115_i2c_write(client, MPL3115_CTRL_REG1, val, 1);
@@ -204,6 +211,7 @@ static int mpl3115_probe(struct i2c_client *client,
        struct input_dev *idev;
        struct i2c_adapter *adapter;
        struct mpl3115_data *pdata;
+
        adapter = to_i2c_adapter(client->dev.parent);
        result = i2c_check_functionality(adapter,
                                         I2C_FUNC_SMBUS_BYTE |
index 3ac7180..04541cf 100644 (file)
@@ -147,6 +147,8 @@ static int fxas2100x_device_init(struct i2c_client *client)
 {
        int result;
        u8 val;
+       struct device_node *np = client->dev.of_node;
+
        struct fxas2100x_data *pdata = i2c_get_clientdata(client);
        if (pdata->chip_id == FXAS21000_CHIP_ID)
                val = (0x01 << 2); /* fxas21000 dr 200HZ */
@@ -155,6 +157,14 @@ static int fxas2100x_device_init(struct i2c_client *client)
        result = i2c_smbus_write_byte_data(client, FXAS2100X_CTRL_REG1, val);
        if (result < 0)
                goto out;
+
+       /* set interrupt pin as open-drain */
+       if (of_get_property(np, "interrupt-open-drain", NULL)) {
+               result = i2c_smbus_write_byte_data(client, FXAS2100X_CTRL_REG2, 0x01);
+               if (result < 0)
+                       goto out;
+       }
+
        atomic_set(&pdata->active, STANDBY);
        return 0;
 out:
index 326e2ac..e9a0711 100644 (file)
@@ -283,8 +283,16 @@ static int fxos8700_set_odr(struct i2c_client *client, int type, int delay)
 static int fxos8700_device_init(struct i2c_client *client)
 {
        int result;
+       struct device_node *np = client->dev.of_node;
        struct fxos8700_data *pdata =  i2c_get_clientdata(client);
 
+       /* set interrupt pin as open-drain */
+       if (of_get_property(np, "interrupt-open-drain", NULL)) {
+               result = i2c_smbus_write_byte_data(client, FXOS8700_CTRL_REG3, 0x01);
+               if (result < 0)
+                       goto out;
+       }
+
        /* standby mode */
        result = i2c_smbus_write_byte_data(client, FXOS8700_CTRL_REG1, 0x00);
        if (result < 0)