Skip to contentSkip to conversation

ThunderX i2c driver

RFC PATCH New Jan Glauber 1 participant 3 messages Feb 24, 2016

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

RFC PATCH 1/2 i2c: Split i2c-octeon driver and add ThunderX support

In reply to Jan Glauber

The ThunderX SOC uses the same i2c block as the Octeon SOC. The main difference is that on ThunderX the device is a PCI device so device probing is done via PCI.

Split the current Octeon driver into an Octeon and a common part and add the ThunderX support.

---
 drivers/i2c/busses/Kconfig             |   10 +
 drivers/i2c/busses/Makefile            |    3 +
 drivers/i2c/busses/i2c-cavium.c        |  828 +++++++++++++++++++++
 drivers/i2c/busses/i2c-cavium.h        |  187 +++++
 drivers/i2c/busses/i2c-octeon-core.c   |  302 ++++++++
 drivers/i2c/busses/i2c-octeon.c        | 1283 --------------------------------
 drivers/i2c/busses/i2c-thunderx-core.c |  263 +++++++
 7 files changed, 1593 insertions(+), 1283 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
drivers/i2c/busses/Kconfig +10 -0
index 7b0aa82..97614b3 100644
@@ -952,6 +952,16 @@ config I2C_OCTEON
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-octeon.
 
+config I2C_THUNDERX
+	tristate "Cavium ThunderX I2C bus support"
+	depends on 64BIT && PCI
+	help
+	  Say yes if you want to support the I2C serial bus on Cavium
+	  ThunderX SOC.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-thunderx.
+
 config I2C_XILINX
 	tristate "Xilinx I2C Controller"
 	depends on HAS_IOMEM
drivers/i2c/busses/Makefile +3 -0
index 37f2819..a32ff14 100644
@@ -91,7 +91,10 @@ obj-$(CONFIG_I2C_UNIPHIER)	+= i2c-uniphier.o
 obj-$(CONFIG_I2C_UNIPHIER_F)	+= i2c-uniphier-f.o
 obj-$(CONFIG_I2C_VERSATILE)	+= i2c-versatile.o
 obj-$(CONFIG_I2C_WMT)		+= i2c-wmt.o
+i2c-octeon-objs := i2c-cavium.o i2c-octeon-core.o
 obj-$(CONFIG_I2C_OCTEON)	+= i2c-octeon.o
+i2c-thunderx-objs := i2c-cavium.o i2c-thunderx-core.o
+obj-$(CONFIG_I2C_THUNDERX)	+= i2c-thunderx.o
 obj-$(CONFIG_I2C_XILINX)	+= i2c-xiic.o
 obj-$(CONFIG_I2C_XLR)		+= i2c-xlr.o
 obj-$(CONFIG_I2C_XLP9XX)	+= i2c-xlp9xx.o
drivers/i2c/busses/i2c-cavium.c new file +828 -0

828 lines not on this page · raw message

drivers/i2c/busses/i2c-cavium.h new file +187 -0

187 lines not on this page · raw message

drivers/i2c/busses/i2c-octeon-core.c new file +302 -0

302 lines not on this page · raw message

drivers/i2c/busses/i2c-octeon.c deleted +0 -1283

1,283 lines not on this page · raw message

drivers/i2c/busses/i2c-thunderx-core.c new file +263 -0

263 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

RFC PATCH 2/2 i2c: thunderx: Add smbus support

In reply to Jan Glauber

Add smbus alert interrupt support.

---
 drivers/i2c/busses/i2c-cavium.h        |  4 ++++
 drivers/i2c/busses/i2c-thunderx-core.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
drivers/i2c/busses/i2c-cavium.h +4 -0
index db80c0f..8357997 100644
@@ -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)
drivers/i2c/busses/i2c-thunderx-core.c +31 -0
index 0a95891..396c8bc 100644
@@ -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);
Signature · 1 line
1.9.1
#0 lore raw

cover ThunderX i2c driver

Hi,

these two patches add support for the Cavium ThunderX SOC. The patches are on-top of the previous i2c-octeon series.

Please review, feedback welcome!

Jan

------------------------------------------------

Jan Glauber (2):
i2c: Split i2c-octeon driver and add ThunderX support
i2c: thunderx: Add smbus support

 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        | 1283 --------------------------------
 drivers/i2c/busses/i2c-thunderx-core.c |  294 ++++++++
 7 files changed, 1628 insertions(+), 1283 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
Signature · 1 line
1.9.1