All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Glauber <jglauber@cavium.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	David Daney <ddaney@caviumnetworks.com>,
	Jan Glauber <jglauber@cavium.com>
Subject: [PATCH v7 15/15] i2c: thunderx: Add smbus alert support
Date: Mon, 25 Apr 2016 16:33:44 +0200	[thread overview]
Message-ID: <1461594824-7215-16-git-send-email-jglauber@cavium.com> (raw)
In-Reply-To: <1461594824-7215-1-git-send-email-jglauber@cavium.com>

Add smbus alert interrupt support.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
 drivers/i2c/busses/i2c-cavium.h        |  6 ++++++
 drivers/i2c/busses/i2c-thunderx-core.c | 35 ++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/i2c/busses/i2c-cavium.h b/drivers/i2c/busses/i2c-cavium.h
index ad57b03..749dffc 100644
--- a/drivers/i2c/busses/i2c-cavium.h
+++ b/drivers/i2c/busses/i2c-cavium.h
@@ -3,6 +3,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/i2c.h>
+#include <linux/i2c-smbus.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
@@ -120,6 +121,11 @@ struct octeon_i2c {
 #if IS_ENABLED(CONFIG_I2C_THUNDERX)
 	struct msix_entry i2c_msix;
 #endif
+
+#if IS_ENABLED(CONFIG_I2C_SMBUS)
+	struct i2c_smbus_alert_setup alert_data;
+	struct i2c_client *ara;
+#endif
 };
 
 static inline void octeon_i2c_writeq_flush(u64 val, void __iomem *addr)
diff --git a/drivers/i2c/busses/i2c-thunderx-core.c b/drivers/i2c/busses/i2c-thunderx-core.c
index 8fcd26c..e1a111d 100644
--- a/drivers/i2c/busses/i2c-thunderx-core.c
+++ b/drivers/i2c/busses/i2c-thunderx-core.c
@@ -9,9 +9,11 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
+#include <linux/i2c-smbus.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_irq.h>
 #include <linux/pci.h>
 
 #include "i2c-cavium.h"
@@ -106,6 +108,35 @@ static void thunder_i2c_clock_disable(struct device *dev, struct clk *clk)
 	devm_clk_put(dev, clk);
 }
 
+static int thunder_i2c_smbus_setup(struct octeon_i2c *i2c,
+				   struct device_node *node)
+{
+#if IS_ENABLED(CONFIG_I2C_SMBUS)
+	u32 type;
+
+	i2c->alert_data.irq = irq_of_parse_and_map(node, 0);
+	if (!i2c->alert_data.irq)
+		return -EINVAL;
+
+	type = irqd_get_trigger_type(irq_get_irq_data(i2c->alert_data.irq));
+	i2c->alert_data.alert_edge_triggered =
+		(type & IRQ_TYPE_LEVEL_MASK) ? 1 : 0;
+
+	i2c->ara = i2c_setup_smbus_alert(&i2c->adap, &i2c->alert_data);
+	if (!i2c->ara)
+		return -ENODEV;
+#endif
+	return 0;
+}
+
+static void thunder_i2c_smbus_remove(struct octeon_i2c *i2c)
+{
+#if IS_ENABLED(CONFIG_I2C_SMBUS)
+	if (i2c->ara)
+		i2c_unregister_device(i2c->ara);
+#endif
+}
+
 static void thunder_i2c_set_name(struct pci_dev *pdev, struct octeon_i2c *i2c,
 				 char *name)
 {
@@ -210,6 +241,9 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
 		goto out_irq;
 	}
 
+	ret = thunder_i2c_smbus_setup(i2c, node);
+	if (ret < 0)
+		dev_info(dev, "Failed to setup smbus alert\n");
 	dev_info(i2c->dev, "probed\n");
 	return 0;
 
@@ -240,6 +274,7 @@ static void thunder_i2c_remove_pci(struct pci_dev *pdev)
 
 	dev = i2c->dev;
 	thunder_i2c_clock_disable(dev, i2c->clk);
+	thunder_i2c_smbus_remove(i2c);
 	i2c_del_adapter(&i2c->adap);
 	devm_free_irq(dev, i2c->i2c_msix.vector, i2c);
 	pci_disable_msix(pdev);
-- 
1.9.1

      parent reply	other threads:[~2016-04-25 14:35 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 14:33 [PATCH v7 00/15] i2c-octeon and i2c-thunderx drivers Jan Glauber
2016-04-25 14:33 ` [PATCH v7 01/15] i2c: octeon: Improve error status checking Jan Glauber
2016-04-25 21:20   ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 02/15] i2c: octeon: Use i2c recovery framework Jan Glauber
2016-04-25 21:29   ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Jan Glauber
2016-04-25 22:16   ` Wolfram Sang
2016-04-25 22:28     ` David Daney
2016-04-25 22:28       ` David Daney
2016-04-26  5:58     ` Jan Glauber
2016-04-26  5:58       ` Jan Glauber
2016-04-26  6:42       ` Jan Glauber
2016-04-26  6:42         ` Jan Glauber
2016-04-26  7:36         ` Wolfram Sang
2016-04-26 12:34           ` Jan Glauber
2016-04-26 12:34             ` Jan Glauber
2016-04-26 12:53             ` Wolfram Sang
2016-04-26 14:26               ` [PATCH] i2c: octeon: Remove zero-length message support Jan Glauber
2016-04-26 21:04                 ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 04/15] i2c: octeon: Add flush writeq helper function Jan Glauber
2016-04-25 21:33   ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 05/15] i2c: octeon: Enable High-Level Controller Jan Glauber
2016-04-25 21:44   ` Wolfram Sang
2016-04-26  5:51     ` Jan Glauber
2016-04-26  5:51       ` Jan Glauber
2016-04-25 14:33 ` [PATCH v7 06/15] dt-bindings: i2c: Add Octeon cn78xx TWSI Jan Glauber
2016-04-25 21:47   ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 07/15] i2c: octeon: Add support for cn78xx chips Jan Glauber
2016-04-25 21:47   ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 08/15] i2c: octeon: Improve performance if interrupt is early Jan Glauber
2016-04-26 21:10   ` Wolfram Sang
2016-04-26 21:19     ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 Jan Glauber
2016-04-26 21:17   ` Wolfram Sang
2016-04-27  9:37     ` Jan Glauber
2016-04-27  9:37       ` Jan Glauber
2016-04-27  9:44     ` [PATCH] " Jan Glauber
2016-04-27 16:56       ` Wolfram Sang
2016-04-25 14:33 ` [PATCH v7 10/15] i2c: octeon: Move read function before write Jan Glauber
2016-04-25 14:33 ` [PATCH v7 11/15] i2c: octeon: Rename driver to prepare for split Jan Glauber
2016-04-25 14:33 ` [PATCH v7 12/15] i2c: octeon: Split the driver into two parts Jan Glauber
2016-04-25 14:33 ` [PATCH v7 13/15] i2c: thunderx: Add i2c driver for ThunderX SOC Jan Glauber
2016-04-25 14:33 ` [PATCH v7 14/15] i2c: octeon,thunderx: Move register offsets to struct Jan Glauber
2016-04-25 14:33 ` Jan Glauber [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461594824-7215-16-git-send-email-jglauber@cavium.com \
    --to=jglauber@cavium.com \
    --cc=ddaney@caviumnetworks.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.