Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345840 > unrolled thread
| Started by | Jan Glauber <jglauber@cavium.com> |
|---|---|
| First post | 2016-02-29 14:50 +0100 |
| Last post | 2016-02-29 14:50 +0100 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[Resend PATCH 00/10] i2c-octeon and i2c-thunderx drivers Jan Glauber <jglauber@cavium.com> - 2016-02-29 14:50 +0100
[Resend PATCH 04/10] dt-bindings: i2c: add Octeon cn78xx TWSI Jan Glauber <jglauber@cavium.com> - 2016-02-29 14:50 +0100
[Resend PATCH 08/10] i2c-octeon: Add workaround for chips with broken irqs Jan Glauber <jglauber@cavium.com> - 2016-02-29 14:50 +0100
[Resend PATCH 10/10] i2c: thunderx: add smbus support Jan Glauber <jglauber@cavium.com> - 2016-02-29 14:50 +0100
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-02-29 14:50 +0100 |
| Subject | [Resend PATCH 00/10] i2c-octeon and i2c-thunderx drivers |
| Message-ID | <r7wmZ-3Hf-9@gated-at.bofh.it> |
I'm resending both patch series as one since the thunderx driver depends on the octeon driver patches. Also (subtly) dropping the RFC in the hope of getting the patches reviewed. This series for the Octeon i2c driver is an attempt to upstream some bug fixes and features that accumulated for some time. I tried to split the cleanup from the other patches and updated the patch descriptions according to my humble i2c knowledge. Patches are on top of 4.5-rc6 and were tested on OCTEON, OCTEON-78 and ThunderX. Jan ---------------------------------------------------------------------- David Daney (4): i2c-octeon: Support I2C_M_RECV_LEN i2c-octeon: Enable high-level controller and improve on bus contention i2c-octeon: Add support for cn78XX chips i2c-octeon: Add workaround for chips with broken irqs Jan Glauber (4): i2c-octeon: Cleanup i2c-octeon driver dt-bindings: i2c: add Octeon cn78xx TWSI i2c: split i2c-octeon driver and add ThunderX support i2c: thunderx: add smbus support Peter Swain (2): i2c-octeon: Flush TWSI writes with readback i2c-octeon: Faster operation when IFLG signals late .../devicetree/bindings/i2c/i2c-octeon.txt | 6 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 3 + drivers/i2c/busses/i2c-cavium.c | 828 +++++++++++++++++++++ drivers/i2c/busses/i2c-cavium.h | 191 +++++ drivers/i2c/busses/i2c-octeon-core.c | 302 ++++++++ drivers/i2c/busses/i2c-octeon.c | 633 ---------------- drivers/i2c/busses/i2c-thunderx-core.c | 294 ++++++++ 8 files changed, 1634 insertions(+), 633 deletions(-) create mode 100644 drivers/i2c/busses/i2c-cavium.c create mode 100644 drivers/i2c/busses/i2c-cavium.h create mode 100644 drivers/i2c/busses/i2c-octeon-core.c delete mode 100644 drivers/i2c/busses/i2c-octeon.c create mode 100644 drivers/i2c/busses/i2c-thunderx-core.c -- 1.9.1
[toc] | [next] | [standalone]
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-02-29 14:50 +0100 |
| Subject | [Resend PATCH 04/10] dt-bindings: i2c: add Octeon cn78xx TWSI |
| Message-ID | <r7wn1-3Hf-43@gated-at.bofh.it> |
| In reply to | #1345840 |
Add compatible string for Cavium Octeon cn78XX SOCs TWSI. Cc: Rob Herring <robh+dt@kernel.org> Cc: Pawel Moll <pawel.moll@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Ian Campbell <ijc+devicetree@hellion.org.uk> Cc: Kumar Gala <galak@codeaurora.org> Signed-off-by: Jan Glauber <jglauber@cavium.com> Acked-by: David Daney <ddaney@caviumnetworks.com> --- Documentation/devicetree/bindings/i2c/i2c-octeon.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-octeon.txt b/Documentation/devicetree/bindings/i2c/i2c-octeon.txt index dced82e..872d485 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-octeon.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-octeon.txt @@ -4,6 +4,12 @@ Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs. + or + + compatible: "cavium,octeon-7890-twsi" + + Compatibility with cn78XX SOCs. + - reg: The base address of the TWSI/I2C bus controller register bank. - #address-cells: Must be <1>. -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-02-29 14:50 +0100 |
| Subject | [Resend PATCH 08/10] i2c-octeon: Add workaround for chips with broken irqs |
| Message-ID | <r7wn1-3Hf-45@gated-at.bofh.it> |
| In reply to | #1345840 |
From: David Daney <ddaney@caviumnetworks.com>
CN3860 does not interrupt the CPU when the i2c status changes. If
we get a timeout, and see the status has in fact changed, we know we
have this problem, and drop back to polling.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
drivers/i2c/busses/i2c-octeon.c | 46 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index e3552e5..3c2f848 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -115,6 +115,7 @@ struct octeon_i2c {
int sys_freq;
void __iomem *twsi_base;
struct device *dev;
+ int broken_irq_mode;
bool hlc_enabled;
void (*int_en) (struct octeon_i2c *);
void (*int_dis) (struct octeon_i2c *);
@@ -382,10 +383,33 @@ static int octeon_i2c_wait(struct octeon_i2c *i2c)
int first = 1;
long result;
+ if (i2c->broken_irq_mode) {
+ /*
+ * Some chip revisions seem to not assert the irq in
+ * the interrupt controller. So we must poll for the
+ * IFLG change.
+ */
+ u64 end = get_jiffies_64() + i2c->adap.timeout;
+
+ while (!octeon_i2c_test_iflg(i2c) &&
+ time_before64(get_jiffies_64(), end))
+ udelay(50);
+
+ return octeon_i2c_test_iflg(i2c) ? 0 : -ETIMEDOUT;
+ }
+
i2c->int_en(i2c);
result = wait_event_timeout(i2c->queue, poll_iflg(i2c, &first),
i2c->adap.timeout);
i2c->int_dis(i2c);
+
+ if (result <= 0 && OCTEON_IS_MODEL(OCTEON_CN38XX) &&
+ octeon_i2c_test_iflg(i2c)) {
+ dev_err(i2c->dev,
+ "broken irq connection detected, switching to polling mode.\n");
+ i2c->broken_irq_mode = 1;
+ return 0;
+ }
if (!result) {
dev_dbg(i2c->dev, "%s: timeout\n", __func__);
return -ETIMEDOUT;
@@ -740,6 +764,21 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
{
int result;
+ if (i2c->broken_irq_mode) {
+ /*
+ * Some cn38xx boards did not assert the irq in
+ * the interrupt controller. So we must poll for the
+ * IFLG change.
+ */
+ u64 end = get_jiffies_64() + i2c->adap.timeout;
+
+ while (!octeon_i2c_hlc_test_ready(i2c) &&
+ time_before64(get_jiffies_64(), end))
+ udelay(50);
+
+ return octeon_i2c_hlc_test_ready(i2c) ? 0 : -ETIMEDOUT;
+ }
+
i2c->hlc_int_en(i2c);
result = wait_event_interruptible_timeout(i2c->queue,
octeon_i2c_hlc_test_ready(i2c), i2c->adap.timeout);
@@ -747,6 +786,13 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
if (!result)
octeon_i2c_hlc_int_clear(i2c);
+ if (result <= 0 && OCTEON_IS_MODEL(OCTEON_CN38XX) &&
+ octeon_i2c_hlc_test_ready(i2c)) {
+ dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n");
+ i2c->broken_irq_mode = 1;
+ return 0;
+ }
+
if (result < 0) {
dev_dbg(i2c->dev, "%s: wait interrupted\n", __func__);
return result;
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-02-29 14:50 +0100 |
| Subject | [Resend PATCH 10/10] i2c: thunderx: add smbus support |
| Message-ID | <r7wn0-3Hf-37@gated-at.bofh.it> |
| In reply to | #1345840 |
Add smbus alert interrupt support.
Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
drivers/i2c/busses/i2c-cavium.h | 4 ++++
drivers/i2c/busses/i2c-thunderx-core.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/drivers/i2c/busses/i2c-cavium.h b/drivers/i2c/busses/i2c-cavium.h
index db80c0f..8357997 100644
--- a/drivers/i2c/busses/i2c-cavium.h
+++ b/drivers/i2c/busses/i2c-cavium.h
@@ -119,6 +119,10 @@ struct octeon_i2c {
#ifdef CONFIG_ARCH_THUNDER
struct msix_entry i2c_msix;
#endif
+#ifdef CONFIG_I2C_SMBUS
+ struct i2c_smbus_alert_setup alert_data;
+ struct i2c_client *ara;
+#endif
};
static inline void writeqflush(u64 val, void __iomem *addr)
diff --git a/drivers/i2c/busses/i2c-thunderx-core.c b/drivers/i2c/busses/i2c-thunderx-core.c
index 0a95891..396c8bc 100644
--- a/drivers/i2c/busses/i2c-thunderx-core.c
+++ b/drivers/i2c/busses/i2c-thunderx-core.c
@@ -9,6 +9,7 @@
#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>
@@ -104,6 +105,34 @@ static void thunder_i2c_clock_disable(struct device *dev, struct clk *clk)
devm_clk_put(dev, clk);
}
+static void thunder_i2c_smbus_setup(struct octeon_i2c *i2c,
+ struct device_node *node)
+{
+#ifdef CONFIG_I2C_SMBUS
+ u32 type;
+
+ i2c->alert_data.irq = irq_of_parse_and_map(node, 0);
+ if (!i2c->alert_data.irq)
+ return;
+
+ 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)
+ dev_err(dev, "Failed to setup smbalert\n");
+#endif
+}
+
+static void thunder_i2c_smbus_remove(struct octeon_i2c *i2c)
+{
+#ifdef 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)
{
@@ -202,6 +231,7 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
goto out_irq;
}
+ thunder_i2c_smbus_setup(i2c, node);
dev_info(i2c->dev, "probed\n");
return 0;
@@ -232,6 +262,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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web