Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1386540 > unrolled thread
| Started by | Jan Glauber <jglauber@cavium.com> |
|---|---|
| First post | 2016-04-25 16:40 +0200 |
| Last post | 2016-04-25 23:40 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v7 00/15] i2c-octeon and i2c-thunderx drivers Jan Glauber <jglauber@cavium.com> - 2016-04-25 16:40 +0200
[PATCH v7 15/15] i2c: thunderx: Add smbus alert support Jan Glauber <jglauber@cavium.com> - 2016-04-25 16:40 +0200
[PATCH v7 10/15] i2c: octeon: Move read function before write Jan Glauber <jglauber@cavium.com> - 2016-04-25 16:40 +0200
[PATCH v7 04/15] i2c: octeon: Add flush writeq helper function Jan Glauber <jglauber@cavium.com> - 2016-04-25 16:40 +0200
Re: [PATCH v7 04/15] i2c: octeon: Add flush writeq helper function Wolfram Sang <wsa@the-dreams.de> - 2016-04-25 23:40 +0200
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-04-25 16:40 +0200 |
| Subject | [PATCH v7 00/15] i2c-octeon and i2c-thunderx drivers |
| Message-ID | <rrPQ6-7se-7@gated-at.bofh.it> |
Hi Wolfram, v7 implements the changes from your review plus some comments from David. I've moved the flush writeq patch before the HLC patch, because it is already needed there and seems quite trivial and I've added a new patch to disable the SMBUS QUICK support as discussed. This series for the Octeon i2c driver is an attempt to upstream some bug fixes and features that accumulated for some time. On top of the Octeon changes a i2c driver for the ThunderX SOC is added which uses the same functional block as the Octeon driver. Patches are on top of next-20160422 and were tested on OCTEON, OCTEON-78 and ThunderX. Changes to v6: - Fixed read_int kerneldoc - Removed udelay after write-int in recovery - Killed retries in recovery, use EAGAIN - Disable SMBUS QUICK and remove unneeded length check - Spell out enable/disable - Switch to wait_event_timeout - Removed superfluous status check in HLC write - Optimize wait-queue also for HLC - Use readq/writeq instead of __raw_* in some places - Add STAT_IDLE to status check (valid after a write) Changes to v5: - Switch to i2c recovery framework - Clean-up register access, introduce new helper functions - Fixed ready bit check in combined write - Fixed IFLG clear in hlc_enable - Removed complicated last phase logic, not needed when we send START for every message part Changes to v4: - Splitted the High-Level Controller patch into several patches - Reworded some commit messages Changes to v3: - Added more functionality flags for SMBUS - Removed both module parameters - Make xfer return also other errors than EGAIN - Return EPROTO on invalid SMBUS block length - Use devm_ioremap_resource - Added rename-only patch - Removed kerneldoc patch from series - Improved defines Changes to v2: - Split clenaup patch into several patches - Strictly moved functional changes to later patches - Fixed do-while checkpatch errors - Moved defines to the patches that use them - Use BIT_ULL macro - Split ThunderX patch into 2 patches Changes to v1: - Fixed compile error on x86_64 - Disabled thunderx driver on MIPS - Re-ordered some thunderx probe functions for readability - Fix missing of_irq.h and i2c-smbus.h includes - Use IS_ENABLED for CONFIG options Jan ------------------------------------------------- David Daney (3): i2c: octeon: Enable High-Level Controller i2c: octeon: Add support for cn78xx chips i2c: octeon: Add workaround for broken irqs on CN3860 Jan Glauber (10): i2c: octeon: Improve error status checking i2c: octeon: Use i2c recovery framework i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support dt-bindings: i2c: Add Octeon cn78xx TWSI i2c: octeon: Move read function before write i2c: octeon: Rename driver to prepare for split i2c: octeon: Split the driver into two parts i2c: thunderx: Add i2c driver for ThunderX SOC i2c: octeon,thunderx: Move register offsets to struct i2c: thunderx: Add smbus alert support Peter Swain (2): i2c: octeon: Add flush writeq helper function i2c: octeon: Improve performance if interrupt is early .../devicetree/bindings/i2c/i2c-octeon.txt | 6 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 3 + drivers/i2c/busses/i2c-cavium.c | 799 +++++++++++++++++++++ drivers/i2c/busses/i2c-cavium.h | 214 ++++++ drivers/i2c/busses/i2c-octeon-core.c | 288 ++++++++ drivers/i2c/busses/i2c-octeon.c | 606 ---------------- drivers/i2c/busses/i2c-thunderx-core.c | 306 ++++++++ 8 files changed, 1626 insertions(+), 606 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-04-25 16:40 +0200 |
| Subject | [PATCH v7 15/15] i2c: thunderx: Add smbus alert support |
| Message-ID | <rrPQ7-7se-55@gated-at.bofh.it> |
| In reply to | #1386540 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-04-25 16:40 +0200 |
| Subject | [PATCH v7 10/15] i2c: octeon: Move read function before write |
| Message-ID | <rrPQ8-7se-59@gated-at.bofh.it> |
| In reply to | #1386540 |
Just sorting the functions to be consistent with the other
read/write variants.
Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
drivers/i2c/busses/i2c-octeon.c | 78 ++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 009cc33..2bc32b9 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -864,45 +864,6 @@ static void octeon_i2c_stop(struct octeon_i2c *i2c)
}
/**
- * octeon_i2c_write - send data to the bus via low-level controller
- * @i2c: The struct octeon_i2c
- * @target: Target address
- * @data: Pointer to the data to be sent
- * @length: Length of the data
- *
- * The address is sent over the bus, then the data.
- *
- * Returns 0 on success, otherwise a negative errno.
- */
-static int octeon_i2c_write(struct octeon_i2c *i2c, int target,
- const u8 *data, int length)
-{
- int i, result;
-
- octeon_i2c_data_write(i2c, target << 1);
- octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
-
- result = octeon_i2c_wait(i2c);
- if (result)
- return result;
-
- for (i = 0; i < length; i++) {
- result = octeon_i2c_check_status(i2c, false);
- if (result)
- return result;
-
- octeon_i2c_data_write(i2c, data[i]);
- octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
-
- result = octeon_i2c_wait(i2c);
- if (result)
- return result;
- }
-
- return 0;
-}
-
-/**
* octeon_i2c_read - receive data from the bus via low-level controller
* @i2c: The struct octeon_i2c
* @target: Target address
@@ -967,6 +928,45 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
}
/**
+ * octeon_i2c_write - send data to the bus via low-level controller
+ * @i2c: The struct octeon_i2c
+ * @target: Target address
+ * @data: Pointer to the data to be sent
+ * @length: Length of the data
+ *
+ * The address is sent over the bus, then the data.
+ *
+ * Returns 0 on success, otherwise a negative errno.
+ */
+static int octeon_i2c_write(struct octeon_i2c *i2c, int target,
+ const u8 *data, int length)
+{
+ int i, result;
+
+ octeon_i2c_data_write(i2c, target << 1);
+ octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
+
+ result = octeon_i2c_wait(i2c);
+ if (result)
+ return result;
+
+ for (i = 0; i < length; i++) {
+ result = octeon_i2c_check_status(i2c, false);
+ if (result)
+ return result;
+
+ octeon_i2c_data_write(i2c, data[i]);
+ octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
+
+ result = octeon_i2c_wait(i2c);
+ if (result)
+ return result;
+ }
+
+ return 0;
+}
+
+/**
* octeon_i2c_xfer - The driver's master_xfer function
* @adap: Pointer to the i2c_adapter structure
* @msgs: Pointer to the messages to be processed
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-04-25 16:40 +0200 |
| Subject | [PATCH v7 04/15] i2c: octeon: Add flush writeq helper function |
| Message-ID | <rrPQ8-7se-61@gated-at.bofh.it> |
| In reply to | #1386540 |
From: Peter Swain <pswain@cavium.com>
Add helper function that reads back a value after writing to
make sure the write is finished and use it in octeon_i2c_write_int().
Signed-off-by: Peter Swain <pswain@cavium.com>
Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
drivers/i2c/busses/i2c-octeon.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index ad563cf..60a02b2 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -103,6 +103,12 @@ struct octeon_i2c {
struct device *dev;
};
+static void octeon_i2c_writeq_flush(u64 val, void __iomem *addr)
+{
+ __raw_writeq(val, addr);
+ __raw_readq(addr); /* wait for write to land */
+}
+
/**
* octeon_i2c_reg_write - write an I2C core register
* @i2c: The struct octeon_i2c
@@ -173,8 +179,7 @@ static u64 octeon_i2c_read_int(struct octeon_i2c *i2c)
*/
static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data)
{
- __raw_writeq(data, i2c->twsi_base + TWSI_INT);
- __raw_readq(i2c->twsi_base + TWSI_INT);
+ octeon_i2c_writeq_flush(data, i2c->twsi_base + TWSI_INT);
}
/**
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-04-25 23:40 +0200 |
| Subject | Re: [PATCH v7 04/15] i2c: octeon: Add flush writeq helper function |
| Message-ID | <rrWoy-4fh-29@gated-at.bofh.it> |
| In reply to | #1386545 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Apr 25, 2016 at 04:33:33PM +0200, Jan Glauber wrote: > From: Peter Swain <pswain@cavium.com> > > Add helper function that reads back a value after writing to > make sure the write is finished and use it in octeon_i2c_write_int(). > > Signed-off-by: Peter Swain <pswain@cavium.com> > Signed-off-by: Jan Glauber <jglauber@cavium.com> Applied to for-next, thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web