]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
i2c: xlp9xx: Add support for SMBAlert
authorGeorge Cherian <george.cherian@cavium.com>
Tue, 14 Aug 2018 16:57:27 +0000 (11:57 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 27 Aug 2018 14:40:05 +0000 (16:40 +0200)
Add support for SMBus alert mechanism to i2c-xlp9xx driver.
The second interrupt is parsed to use for SMBus alert.
The first interrupt is the i2c controller main interrupt.

BugLink: https://launchpad.net/bugs/1786981
Signed-off-by: Kamlakant Patel <kamlakant.patel@cavium.com>
Signed-off-by: George Cherian <george.cherian@cavium.com>
Reviewed-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
(cherry picked from commit 40f4e372cba8a6729c997c0bda1fa03adf7f956e)
Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/i2c/busses/i2c-xlp9xx.c

index 7c170eba4495cb5689371d0cb0d443ffd014540d..8a873975cf1252006e91d437893b2aff2791e843 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/completion.h>
 #include <linux/i2c.h>
+#include <linux/i2c-smbus.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -84,6 +85,8 @@ struct xlp9xx_i2c_dev {
        struct device *dev;
        struct i2c_adapter adapter;
        struct completion msg_complete;
+       struct i2c_smbus_alert_setup alert_data;
+       struct i2c_client *ara;
        int irq;
        bool msg_read;
        bool len_recv;
@@ -485,6 +488,19 @@ static int xlp9xx_i2c_get_frequency(struct platform_device *pdev,
        return 0;
 }
 
+static int xlp9xx_i2c_smbus_setup(struct xlp9xx_i2c_dev *priv,
+                                 struct platform_device *pdev)
+{
+       if (!priv->alert_data.irq)
+               return -EINVAL;
+
+       priv->ara = i2c_setup_smbus_alert(&priv->adapter, &priv->alert_data);
+       if (!priv->ara)
+               return -ENODEV;
+
+       return 0;
+}
+
 static int xlp9xx_i2c_probe(struct platform_device *pdev)
 {
        struct xlp9xx_i2c_dev *priv;
@@ -505,6 +521,10 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "invalid irq!\n");
                return priv->irq;
        }
+       /* SMBAlert irq */
+       priv->alert_data.irq = platform_get_irq(pdev, 1);
+       if (priv->alert_data.irq <= 0)
+               priv->alert_data.irq = 0;
 
        xlp9xx_i2c_get_frequency(pdev, priv);
        xlp9xx_i2c_init(priv);
@@ -531,6 +551,10 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
        if (err)
                return err;
 
+       err = xlp9xx_i2c_smbus_setup(priv, pdev);
+       if (err)
+               dev_dbg(&pdev->dev, "No active SMBus alert %d\n", err);
+
        platform_set_drvdata(pdev, priv);
        dev_dbg(&pdev->dev, "I2C bus:%d added\n", priv->adapter.nr);