Skip to contentSkip to conversation

FSI device driver introduction

PATCH Superseded Chris Bostic 5 participants 19 messages Dec 7, 2016 – Dec 12, 2016

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover FSI device driver introduction

From: Chris Bostic <[email protected]>

Introduction of the IBM 'Flexible Support Interface' (FSI) bus device driver. FSI is a high fan out serial bus consisting of a clock and a serial data line capable of running at speeds up to 166 MHz.

This set provides the basic framework to add FSI extensions to the Linux bus and device models. Master specific implementations are defined to utilize the core FSI function.

In Linux, we have a core FSI "bus type", along with drivers for FSI masters and engines.

The FSI master drivers expose a read/write interface to the bus address space. The master drivers are under drivers/fsi/fsi-master-*.c.

The core handles probing and discovery of slaves and slave engines, using those read/write interfaces. It is responsible for creating the endpoint Linux devices corresponding to the discovered engines on each slave.

Slave engines are identified by an 'engine' type, and an optional version. Engine, a.k.a. client, drivers are matched and bound to these engines during discovery.

This patch set does not include extended FSI function such as:

    *  Hub master support
    *  Cascaded master support
    *  Application layer hot plug notification
    *  Application layer FSI bus status interface

Common FSI terminology:

* Master
Controller of the FSI bus. Only the master is allowed to control the clock line and is the initiator of all transactions on a bus.

* Slave
The receiver or target of a master initiated transaction. The slave cannot initiate communications on a bus and must respond to any master requests for data.

* CFAM
Stands for Common Field replaceable unit Access Macro. A CFAM is an ASIC residing in any device requiring FSI communications. CFAMs consist of an array of hardware 'engines' used for various purposes. I2C masters, UARTs, General Purpose IO hardware are common types of these engines.

* Configuration Space / Table
A table contained at the beginning of each CFAM address space. This table lists information such as the CFAM's ID, which engine types and versions it has available, as well as its addressing range.

* FSI Engine driver
A device driver that registers with the FSI core so that it can access devices it owns on an FSI bus.

Chris Bostic (5):
drivers/fsi: Set up links for slave communication drivers/fsi: Set slave SMODE to init communication drivers/fsi: Add master unscan drivers/fsi: Add documentation for GPIO bindings drivers/fsi: Add GPIO based FSI master

Jeremy Kerr (11):
drivers/fsi: Add empty fsi bus definitions drivers/fsi: Add device & driver definitions drivers/fsi: add driver to device matches drivers/fsi: Add fsi master definition drivers/fsi: Add fake master driver drivers/fsi: Add slave definition drivers/fsi: Add empty master scan drivers/fsi: Add crc4 helpers drivers/fsi: Implement slave initialisation drivers/fsi: scan slaves & register devices drivers/fsi: Add device read/write/peek functions

 .../devicetree/bindings/fsi/fsi-master-gpio.txt    |  21 +
 drivers/Kconfig                                    |   2 +
 drivers/Makefile                                   |   1 +
 drivers/fsi/Kconfig                                |  29 ++
 drivers/fsi/Makefile                               |   4 +
 drivers/fsi/fsi-core.c                             | 514 +++++++++++++++++++
 drivers/fsi/fsi-master-fake.c                      |  95 ++++
 drivers/fsi/fsi-master-gpio.c                      | 552 +++++++++++++++++++++
 drivers/fsi/fsi-master.h                           |  62 +++
 include/linux/fsi.h                                |  60 +++
 10 files changed, 1340 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt
 create mode 100644 drivers/fsi/Kconfig
 create mode 100644 drivers/fsi/Makefile
 create mode 100644 drivers/fsi/fsi-core.c
 create mode 100644 drivers/fsi/fsi-master-fake.c
 create mode 100644 drivers/fsi/fsi-master-gpio.c
 create mode 100644 drivers/fsi/fsi-master.h
 create mode 100644 include/linux/fsi.h
Signature · 1 line
1.8.2.2
#1 lore raw

PATCH 1/16 drivers/fsi: Add empty fsi bus definitions

From: Jeremy Kerr <[email protected]>

This change adds the initial (empty) fsi bus definition, and introduces drivers/fsi/.

---
 drivers/Kconfig        |  2 ++
 drivers/Makefile       |  1 +
 drivers/fsi/Kconfig    | 12 ++++++++++++
 drivers/fsi/Makefile   |  2 ++
 drivers/fsi/fsi-core.c | 38 ++++++++++++++++++++++++++++++++++++++
 include/linux/fsi.h    | 22 ++++++++++++++++++++++
 6 files changed, 77 insertions(+)
 create mode 100644 drivers/fsi/Kconfig
 create mode 100644 drivers/fsi/Makefile
 create mode 100644 drivers/fsi/fsi-core.c
 create mode 100644 include/linux/fsi.h
drivers/Kconfig +2 -0
index e1e2066..117ca14c 100644
@@ -202,4 +202,6 @@ source "drivers/hwtracing/intel_th/Kconfig"
 
 source "drivers/fpga/Kconfig"
 
+source "drivers/fsi/Kconfig"
+
 endmenu
drivers/Makefile +1 -0
index f0afdfb..126e109 100644
@@ -173,3 +173,4 @@ obj-$(CONFIG_STM)		+= hwtracing/stm/
 obj-$(CONFIG_ANDROID)		+= android/
 obj-$(CONFIG_NVMEM)		+= nvmem/
 obj-$(CONFIG_FPGA)		+= fpga/
+obj-$(CONFIG_FSI)		+= fsi/
drivers/fsi/Kconfig new file +12 -0
new file mode 100644
index 0000000..04c1a0e
@@ -0,0 +1,12 @@
+#
+# FSI subsystem
+#
+
+menu "FSI support"
+
+config FSI
+	tristate "FSI support"
+	---help---
+	  FSI - the FRU Support Interface - is a simple bus for low-level
+	  access to POWER-based hardware.
+endmenu
drivers/fsi/Makefile new file +2 -0
new file mode 100644
index 0000000..db0e5e7
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_FSI) += fsi-core.o
drivers/fsi/fsi-core.c new file +38 -0
new file mode 100644
index 0000000..3e45306
@@ -0,0 +1,38 @@
+/*
+ * FSI core driver
+ *
+ * Copyright (C) IBM Corporation 2016
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/device.h>
+#include <linux/fsi.h>
+#include <linux/module.h>
+
+/* FSI core & Linux bus type definitions */
+
+struct bus_type fsi_bus_type = {
+	.name		= "fsi",
+};
+EXPORT_SYMBOL_GPL(fsi_bus_type);
+
+static int fsi_init(void)
+{
+	return bus_register(&fsi_bus_type);
+}
+
+static void fsi_exit(void)
+{
+	bus_unregister(&fsi_bus_type);
+}
+
+module_init(fsi_init);
+module_exit(fsi_exit);
include/linux/fsi.h new file +22 -0
new file mode 100644
index 0000000..47aa181
@@ -0,0 +1,22 @@
+/* FSI device & driver interfaces
+ *
+ * Copyright (C) IBM Corporation 2016
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef LINUX_FSI_H
+#define LINUX_FSI_H
+
+#include <linux/device.h>
+
+extern struct bus_type fsi_bus_type;
+
+#endif /* LINUX_FSI_H */
Signature · 1 line
1.8.2.2
#2 lore raw

PATCH 2/16 drivers/fsi: Add device & driver definitions

In reply to Chris Bostic

From: Jeremy Kerr <[email protected]>

Add structs for fsi devices & drivers, and struct device conversion functions.

---
 include/linux/fsi.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/linux/fsi.h +11 -0
index 47aa181..f73886a 100644
@@ -17,6 +17,17 @@
 
 #include <linux/device.h>
 
+struct fsi_device {
+	struct device dev;
+};
+
+struct fsi_driver {
+	struct device_driver drv;
+};
+
+#define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)
+#define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv)
+
 extern struct bus_type fsi_bus_type;
 
 #endif /* LINUX_FSI_H */
Signature · 1 line
1.8.2.2
#3 lore raw

PATCH 3/16 drivers/fsi: add driver to device matches

In reply to Chris Bostic

From: Jeremy Kerr <[email protected]>

Driver bind to devices based on the engine types & (optional) versions.

---
 drivers/fsi/fsi-core.c | 21 +++++++++++++++++++++
 include/linux/fsi.h    | 21 +++++++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +21 -0
index 3e45306..3d55bd5 100644
@@ -19,8 +19,29 @@
 
 /* FSI core & Linux bus type definitions */
 
+static int fsi_bus_match(struct device *dev, struct device_driver *drv)
+{
+	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct fsi_driver *fsi_drv = to_fsi_drv(drv);
+	const struct fsi_device_id *id;
+
+	if (!fsi_drv->id_table)
+		return 0;
+
+	for (id = fsi_drv->id_table; id->engine_type; id++) {
+		if (id->engine_type != fsi_dev->engine_type)
+			continue;
+		if (id->version == FSI_VERSION_ANY ||
+				id->version == fsi_dev->version)
+			return 1;
+	}
+
+	return 0;
+}
+
 struct bus_type fsi_bus_type = {
 	.name		= "fsi",
+	.match		= fsi_bus_match,
 };
 EXPORT_SYMBOL_GPL(fsi_bus_type);
 
include/linux/fsi.h +19 -2
index f73886a..273cbf6 100644
@@ -18,11 +18,28 @@
 #include <linux/device.h>
 
 struct fsi_device {
-	struct device dev;
+	struct device		dev;
+	u8			engine_type;
+	u8			version;
 };
 
+struct fsi_device_id {
+	u8	engine_type;
+	u8	version;
+};
+
+#define FSI_VERSION_ANY		0
+
+#define FSI_DEVICE(t) \
+	.engine_type = (t), .version = FSI_VERSION_ANY,
+
+#define FSI_DEVICE_VERSIONED(t, v) \
+	.engine_type = (t), .version = (v),
+
+
 struct fsi_driver {
-	struct device_driver drv;
+	struct device_driver		drv;
+	const struct fsi_device_id	*id_table;
 };
 
 #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)
Signature · 1 line
1.8.2.2
#4 lore raw

PATCH 5/16 drivers/fsi: Add fake master driver

In reply to Chris Bostic

From: Jeremy Kerr <[email protected]>

For debugging, add a fake master driver, that only supports reads, returning a fixed set of data.

Includes changes from Chris Bostic <[email protected]>.

---
 drivers/fsi/Kconfig           | 10 +++++
 drivers/fsi/Makefile          |  1 +
 drivers/fsi/fsi-master-fake.c | 95 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+)
 create mode 100644 drivers/fsi/fsi-master-fake.c
drivers/fsi/Kconfig +10 -0
index 04c1a0e..f065dbe 100644
@@ -9,4 +9,14 @@ config FSI
 	---help---
 	  FSI - the FRU Support Interface - is a simple bus for low-level
 	  access to POWER-based hardware.
+
+if FSI
+
+config FSI_MASTER_FAKE
+	tristate "Fake FSI master"
+	depends on FSI
+	---help---
+	This option enables a fake FSI master driver for debugging.
+endif
+
 endmenu
drivers/fsi/Makefile +1 -0
index db0e5e7..847c00c 100644
@@ -1,2 +1,3 @@
 
 obj-$(CONFIG_FSI) += fsi-core.o
+obj-$(CONFIG_FSI_MASTER_FAKE) += fsi-master-fake.o
drivers/fsi/fsi-master-fake.c new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#5 lore raw

Re: [PATCH 05/16] drivers/fsi: Add fake master driver

Quoted 6 lines · Chris Bostic

From: Jeremy Kerr <[email protected]>

For debugging, add a fake master driver, that only supports reads, returning a fixed set of data.

drivers/fsi/Kconfig +1 -0
+config FSI_MASTER_FAKE

drivers/fsi/Kconfig config FSI

Quoted 10 lines
drivers/fsi/Kconfig +9 -0
+	tristate "Fake FSI master"
+	depends on FSI
+	---help---
+	This option enables a fake FSI master driver for debugging.
+endif
 
+static const struct of_device_id fsi_master_fake_match[] = {
+	{ .compatible = "ibm,fsi-master-fake" },
+	{ },
+};

NAK.

DT should be treated as an ABI, and should describe the HW explicitly. This makes no sense. This is also missing a binding document.

Have your module take a module parameter allowing you to bind it to arbitrary devices, or do something like what PCI does where you can bind/unbind arbitrary drivers to devices using sysfs.

Quoted 7 lines
drivers/fsi/fsi-master-fake.c new file +7 -0
+
+static struct platform_driver fsi_master_fake_driver = {
+	.driver = {
+		.name		= "fsi-master-fake",
+		.of_match_table	= fsi_master_fake_match,
+	},
+	.probe	= fsi_master_fake_probe,

drivers/fsi/fsi-master-fake.c line 90

Quoted 10 lines
drivers/fsi/fsi-master-fake.c new file +10 -0
+};
+
+static int __init fsi_master_fake_init(void)
+{
+	struct device_node *np;
+
+	platform_driver_register(&fsi_master_fake_driver);
+
+	for_each_compatible_node(np, NULL, "ibm,fsi-master-fake")
+		of_platform_device_create(np, NULL, NULL);

As a general note, please use for_each_matching_node in situations like this. That way you can reuse your existing of_device_id table, and not reproduce the string.

That said, this is not necessary. The platform driver has an of_match_table, so presumes the parent bus registers children, and hence they should already have platform devices.

Thanks,
Mark.

#6 lore raw

Re: [PATCH 05/16] drivers/fsi: Add fake master driver

Hi Mark & Chris,

Quoted 20 lines · Chris Bostic
Quoted 6 lines

From: Jeremy Kerr <[email protected]>

For debugging, add a fake master driver, that only supports reads, returning a fixed set of data.

drivers/fsi/Kconfig +1 -0
+config FSI_MASTER_FAKE

drivers/fsi/Kconfig config FSI

Quoted 10 lines
drivers/fsi/Kconfig +9 -0
+	tristate "Fake FSI master"
+	depends on FSI
+	---help---
+	This option enables a fake FSI master driver for debugging.
+endif
 
+static const struct of_device_id fsi_master_fake_match[] = {
+	{ .compatible = "ibm,fsi-master-fake" },
+	{ },
+};

NAK.

Quoted 6 lines

DT should be treated as an ABI, and should describe the HW explicitly. This makes no sense. This is also missing a binding document.

Have your module take a module parameter allowing you to bind it to arbitrary devices, or do something like what PCI does where you can bind/unbind arbitrary drivers to devices using sysfs.

This driver is purely for testing the FSI engine scan code; we could probably just drop this patch since I suspect that it's no longer useful (now that we have an actual master driver).

If we do want to keep it though, I'd say we remove the device tree dependency; all this is doing at the moment is triggering the ->probe, and there are better ways to do that.

Cheers,

Jeremy

#7 lore raw

PATCH 6/16 drivers/fsi: Add slave definition

In reply to Chris Bostic

From: Jeremy Kerr <[email protected]>

Add the initial fsi slave device, which is private to the core code. This will be a child of the master, and parent to endpoint devices.

---
 drivers/fsi/fsi-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/fsi/fsi-core.c +9 -0
index ce9428d..60a6d91 100644
@@ -21,6 +21,15 @@
 
 static atomic_t master_idx = ATOMIC_INIT(-1);
 
+struct fsi_slave {
+	struct device		dev;
+	struct fsi_master	*master;
+	int			link;
+	uint8_t			id;
+};
+
+#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
+
 /* FSI master support */
 
 int fsi_master_register(struct fsi_master *master)
Signature · 1 line
1.8.2.2
#8 lore raw

PATCH 7/16 drivers/fsi: Add empty master scan

In reply to Chris Bostic

From: Jeremy Kerr <[email protected]>

When a new fsi master is added, we will need to scan its links, and slaves attached to those links. This change introduces a little shell to iterate the links, which we will populate with the actual slave scan in a later change.

---
 drivers/fsi/fsi-core.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/fsi/fsi-core.c +24 -0
index 60a6d91..ceaf536 100644
@@ -19,6 +19,8 @@
 
 #include "fsi-master.h"
 
+#define FSI_N_SLAVES	4
+
 static atomic_t master_idx = ATOMIC_INIT(-1);
 
 struct fsi_slave {
@@ -30,12 +32,34 @@ struct fsi_slave {
 
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
+/* FSI slave support */
+static int fsi_slave_init(struct fsi_master *master,
+		int link, uint8_t slave_id)
+{
+	/* todo: initialise slave device, perform engine scan */
+
+	return -ENODEV;
+}
+
 /* FSI master support */
 
+static int fsi_master_scan(struct fsi_master *master)
+{
+	int link, slave_id;
+
+	for (link = 0; link < master->n_links; link++)
+		for (slave_id = 0; slave_id < FSI_N_SLAVES; slave_id++)
+			fsi_slave_init(master, link, slave_id);
+
+	return 0;
+
+}
+
 int fsi_master_register(struct fsi_master *master)
 {
 	master->idx = atomic_inc_return(&master_idx);
 	get_device(master->dev);
+	fsi_master_scan(master);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(fsi_master_register);
Signature · 1 line
1.8.2.2
#9 lore raw

PATCH 10/16 drivers/fsi: scan slaves & register devices

In reply to Chris Bostic

From: Jeremy Kerr <[email protected]>

Now that we have fsi_slave devices, scan each for endpoints, and register them on the fsi bus.

Includes contributions from Chris Bostic <[email protected]>

---
 drivers/fsi/fsi-core.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/fsi.h    |   4 ++
 2 files changed, 136 insertions(+), 4 deletions(-)
drivers/fsi/fsi-core.c +132 -4
index aa4330a..b51ea35 100644
@@ -21,9 +21,19 @@
 #include "fsi-master.h"
 
 #define FSI_N_SLAVES	4
-#define FSI_SLAVE_CONF_CRC_SHIFT        4
-#define FSI_SLAVE_CONF_CRC_MASK         0x0000000f
-#define FSI_SLAVE_CONF_DATA_BITS        28
+
+#define FSI_SLAVE_CONF_NEXT_MASK	0x80000000
+#define FSI_SLAVE_CONF_SLOTS_MASK	0x00ff0000
+#define FSI_SLAVE_CONF_SLOTS_SHIFT	16
+#define FSI_SLAVE_CONF_VERSION_MASK	0x0000f000
+#define FSI_SLAVE_CONF_VERSION_SHIFT	12
+#define FSI_SLAVE_CONF_TYPE_MASK	0x00000ff0
+#define FSI_SLAVE_CONF_TYPE_SHIFT	4
+#define FSI_SLAVE_CONF_CRC_SHIFT	4
+#define FSI_SLAVE_CONF_CRC_MASK		0x0000000f
+#define FSI_SLAVE_CONF_DATA_BITS	28
+
+static const int engine_page_size = 0x400;
 
 static atomic_t master_idx = ATOMIC_INIT(-1);
 
@@ -36,6 +46,30 @@ struct fsi_slave {
 
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
+/* FSI endpoint-device support */
+
+static void fsi_device_release(struct device *_device)
+{
+	struct fsi_device *device = to_fsi_dev(_device);
+
+	kfree(device);
+}
+
+static struct fsi_device *fsi_create_device(struct fsi_slave *slave)
+{
+	struct fsi_device *dev;
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	dev->dev.parent = &slave->dev;
+	dev->dev.bus = &fsi_bus_type;
+	dev->dev.release = fsi_device_release;
+
+	return dev;
+}
+
 /* crc helpers */
 static const uint8_t crc4_tab[] = {
 	0x0, 0x7, 0xe, 0x9, 0xb, 0xc, 0x5, 0x2,
@@ -59,6 +93,99 @@ uint8_t fsi_crc4(uint8_t c, uint64_t x, int bits)
 
 /* FSI slave support */
 
+static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
+			void *val, size_t size)
+{
+	return slave->master->read(slave->master, slave->link,
+			slave->id, addr, val, size);
+}
+
+static int fsi_slave_scan(struct fsi_slave *slave)
+{
+	uint32_t engine_addr;
+	uint32_t conf;
+	int rc, i;
+
+	/*
+	 * scan engines
+	 *
+	 * We keep the peek mode and slave engines for the core; so start
+	 * at the third slot in the configuration table. We also need to
+	 * skip the chip ID entry at the start of the address space.
+	 */
+	engine_addr = engine_page_size * 3;
+	for (i = 2; i < engine_page_size / sizeof(uint32_t); i++) {
+		uint8_t slots, version, type, crc;
+		struct fsi_device *dev;
+
+		rc = fsi_slave_read(slave, (i + 1) * sizeof(conf),
+				&conf, sizeof(conf));
+		if (rc) {
+			dev_warn(&slave->dev,
+				"error reading slave registers\n");
+			return -1;
+		}
+
+		crc = fsi_crc4(0, conf >> FSI_SLAVE_CONF_CRC_SHIFT,
+				FSI_SLAVE_CONF_DATA_BITS);
+		if (crc != (conf & FSI_SLAVE_CONF_CRC_MASK)) {
+			dev_warn(&slave->dev,
+				"crc error in slave register at 0x%04x\n",
+				i);
+			return -1;
+		}
+
+		slots = (conf & FSI_SLAVE_CONF_SLOTS_MASK)
+			>> FSI_SLAVE_CONF_SLOTS_SHIFT;
+		version = (conf & FSI_SLAVE_CONF_VERSION_MASK)
+			>> FSI_SLAVE_CONF_VERSION_SHIFT;
+		type = (conf & FSI_SLAVE_CONF_TYPE_MASK)
+			>> FSI_SLAVE_CONF_TYPE_SHIFT;
+
+		/*
+		 * Unused address areas are marked by a zero type value; this
+		 * skips the defined address areas
+		 */
+		if (type != 0) {
+
+			/* create device */
+			dev = fsi_create_device(slave);
+			if (!dev)
+				return -ENOMEM;
+
+			dev->slave = slave;
+			dev->engine_type = type;
+			dev->version = version;
+			dev->unit = i;
+			dev->addr = engine_addr;
+			dev->size = slots * engine_page_size;
+
+			dev_info(&slave->dev,
+			"engine[%i]: type %x, version %x, addr %x size %x\n",
+					dev->unit, dev->engine_type, version,
+					dev->addr, dev->size);
+
+			device_initialize(&dev->dev);
+			dev_set_name(&dev->dev, "%02x:%02x:%02x:%02x",
+					slave->master->idx, slave->link,
+					slave->id, i - 2);
+
+			rc = device_add(&dev->dev);
+			if (rc) {
+				dev_warn(&slave->dev, "add failed: %d\n", rc);
+				put_device(&dev->dev);
+			}
+		}
+
+		engine_addr += slots * engine_page_size;
+
+		if (!(conf & FSI_SLAVE_CONF_NEXT_MASK))
+			break;
+	}
+
+	return 0;
+}
+
 static void fsi_slave_release(struct device *dev)
 {
 	struct fsi_slave *slave = to_fsi_slave(dev);
@@ -110,7 +237,8 @@ static int fsi_slave_init(struct fsi_master *master,
 		return rc;
 	}
 
-	return rc;
+	fsi_slave_scan(slave);
+	return 0;
 }
 
 /* FSI master support */
include/linux/fsi.h +4 -0
index 273cbf6..efa55ba 100644
@@ -21,6 +21,10 @@ struct fsi_device {
 	struct device		dev;
 	u8			engine_type;
 	u8			version;
+	u8			unit;
+	struct fsi_slave	*slave;
+	uint32_t		addr;
+	uint32_t		size;
 };
 
 struct fsi_device_id {
Signature · 1 line
1.8.2.2
#10 lore raw

PATCH 13/16 drivers/fsi: Set slave SMODE to init communication

In reply to Chris Bostic

From: Chris Bostic <[email protected]>

Set CFAM to appropriate ID so that the controlling master can manage link memory ranges. Add slave engine register definitions.

---
 drivers/fsi/fsi-core.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 89 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +89 -1
index 93de0f1..a28434b 100644
@@ -34,6 +34,7 @@
 #define FSI_SLAVE_CONF_DATA_BITS	28
 
 #define FSI_PEEK_BASE			0x410
+#define	FSI_SLAVE_BASE			0x800
 
 static const int engine_page_size = 0x400;
 
@@ -53,8 +54,26 @@ static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 		const void *val, size_t size);
 
-/* FSI endpoint-device support */
+/*
+ * FSI slave engine control register offsets
+ */
+#define	FSI_SMODE		0x0	/* R/W: Mode register */
+
+/*
+ * SMODE fields
+ */
+#define	FSI_SMODE_WSC		0x80000000	/* Warm start done */
+#define	FSI_SMODE_ECRC		0x20000000	/* Hw CRC check */
+#define	FSI_SMODE_SID_SHIFT	24		/* ID shift */
+#define	FSI_SMODE_SID_MASK	3		/* ID Mask */
+#define	FSI_SMODE_ED_SHIFT	20		/* Echo delay shift */
+#define	FSI_SMODE_ED_MASK	0xf		/* Echo delay mask */
+#define	FSI_SMODE_SD_SHIFT	16		/* Send delay shift */
+#define	FSI_SMODE_SD_MASK	0xf		/* Send delay mask */
+#define	FSI_SMODE_LBCRR_SHIFT	8		/* Clk ratio shift */
+#define	FSI_SMODE_LBCRR_MASK	0xf		/* Clk ratio mask */
 
+/* FSI endpoint-device support */
 int fsi_device_read(struct fsi_device *dev, uint32_t addr, void *val,
 		size_t size)
 {
@@ -133,6 +152,30 @@ uint8_t fsi_crc4(uint8_t c, uint64_t x, int bits)
 
 /* FSI slave support */
 
+/* Encode slave local bus echo delay */
+static inline uint32_t fsi_smode_echodly(int x)
+{
+	return (x & FSI_SMODE_ED_MASK) << FSI_SMODE_ED_SHIFT;
+}
+
+/* Encode slave local bus send delay */
+static inline uint32_t fsi_smode_senddly(int x)
+{
+	return (x & FSI_SMODE_SD_MASK) << FSI_SMODE_SD_SHIFT;
+}
+
+/* Encode slave local bus clock rate ratio */
+static inline uint32_t fsi_smode_lbcrr(int x)
+{
+	return (x & FSI_SMODE_LBCRR_MASK) << FSI_SMODE_LBCRR_SHIFT;
+}
+
+/* Encode slave ID */
+static inline uint32_t fsi_smode_sid(int x)
+{
+	return (x & FSI_SMODE_SID_MASK) << FSI_SMODE_SID_SHIFT;
+}
+
 static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 			void *val, size_t size)
 {
@@ -240,6 +283,22 @@ static void fsi_slave_release(struct device *dev)
 	kfree(slave);
 }
 
+static uint32_t set_smode_defaults(struct fsi_master *master)
+{
+	return FSI_SMODE_WSC | FSI_SMODE_ECRC
+		| fsi_smode_echodly(0xf) | fsi_smode_senddly(0xf)
+		| fsi_smode_lbcrr(1);
+}
+
+static int fsi_slave_set_smode(struct fsi_master *master, int link, int id)
+{
+	uint32_t smode = set_smode_defaults(master);
+
+	smode |= fsi_smode_sid(id);
+	return master->write(master, link, 3, FSI_SLAVE_BASE + FSI_SMODE,
+				&smode, sizeof(smode));
+}
+
 static int fsi_slave_init(struct fsi_master *master,
 		int link, uint8_t slave_id)
 {
@@ -248,6 +307,21 @@ static int fsi_slave_init(struct fsi_master *master,
 	int rc;
 	uint8_t crc;
 
+	/*
+	 * todo: Due to CFAM hardware issues related to BREAK commands we're
+	 * limited to only one CFAM per link.  Once issues are resolved this
+	 * restriction can be removed.
+	 */
+	if (slave_id > 0)
+		return 0;
+
+	rc = fsi_slave_set_smode(master, link, slave_id);
+	if (rc) {
+		dev_warn(master->dev, "can't set smode on slave:%02x:%02x %d\n",
+				link, slave_id, rc);
+		return -ENODEV;
+	}
+
 	rc = master->read(master, link, slave_id, 0, &chip_id, sizeof(chip_id));
 	if (rc) {
 		dev_warn(master->dev, "can't read slave %02x:%02x: %d\n",
@@ -312,6 +386,7 @@ static int fsi_master_break(struct fsi_master *master, int link)
 static int fsi_master_scan(struct fsi_master *master)
 {
 	int link, slave_id, rc;
+	uint32_t smode;
 
 	for (link = 0; link < master->n_links; link++) {
 		rc = fsi_master_link_enable(master, link);
@@ -327,6 +402,19 @@ static int fsi_master_scan(struct fsi_master *master)
 			continue;
 		}
 
+		/*
+		 * Verify can read slave at default ID location. If fails
+		 * there must be nothing on other end of link
+		 */
+		rc = master->read(master, link, 3, FSI_SLAVE_BASE + FSI_SMODE,
+				&smode, sizeof(smode));
+		if (rc) {
+			dev_dbg(master->dev,
+				"Read link:%d smode default id failed:%d\n",
+				link, rc);
+			continue;
+		}
+
 		for (slave_id = 0; slave_id < FSI_N_SLAVES; slave_id++)
 			fsi_slave_init(master, link, slave_id);
 
Signature · 1 line
1.8.2.2
#11 lore raw

PATCH 14/16 drivers/fsi: Add master unscan

In reply to Chris Bostic

From: Chris Bostic <[email protected]>

Allow a master to undo a previous scan. Should a master scan a bus twice it will need to ensure it doesn't double register any previously detected device.

---
 drivers/fsi/fsi-core.c   | 36 +++++++++++++++++++++++++++++++++++-
 drivers/fsi/fsi-master.h |  2 ++
 include/linux/fsi.h      |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +35 -1
index a28434b..8ccfe50 100644
@@ -41,6 +41,8 @@
 static atomic_t master_idx = ATOMIC_INIT(-1);
 
 struct fsi_slave {
+	struct list_head	list_link;	/* Master's list of slaves */
+	struct list_head	my_engines;
 	struct device		dev;
 	struct fsi_master	*master;
 	int			link;
@@ -196,6 +198,8 @@ static int fsi_slave_scan(struct fsi_slave *slave)
 	uint32_t conf;
 	int rc, i;
 
+	INIT_LIST_HEAD(&slave->my_engines);
+
 	/*
 	 * scan engines
 	 *
@@ -264,7 +268,9 @@ static int fsi_slave_scan(struct fsi_slave *slave)
 			if (rc) {
 				dev_warn(&slave->dev, "add failed: %d\n", rc);
 				put_device(&dev->dev);
+				continue;
 			}
+			list_add(&dev->link, &slave->my_engines);
 		}
 
 		engine_addr += slots * engine_page_size;
@@ -357,7 +363,7 @@ static int fsi_slave_init(struct fsi_master *master,
 		put_device(&slave->dev);
 		return rc;
 	}
-
+	list_add(&slave->list_link, &master->my_slaves);
 	fsi_slave_scan(slave);
 	return 0;
 }
@@ -388,6 +394,11 @@ static int fsi_master_scan(struct fsi_master *master)
 	int link, slave_id, rc;
 	uint32_t smode;
 
+	if (!master->slave_list) {
+		INIT_LIST_HEAD(&master->my_slaves);
+		master->slave_list = true;
+	}
+
 	for (link = 0; link < master->n_links; link++) {
 		rc = fsi_master_link_enable(master, link);
 		if (rc) {
@@ -423,9 +434,31 @@ static int fsi_master_scan(struct fsi_master *master)
 	return 0;
 }
 
+static void fsi_master_unscan(struct fsi_master *master)
+{
+	struct fsi_slave *slave, *slave_tmp;
+	struct fsi_device *fsi_dev, *fsi_dev_tmp;
+
+	if (!master->slave_list)
+		return;
+
+	list_for_each_entry_safe(slave, slave_tmp, &master->my_slaves,
+							list_link) {
+		list_del(&slave->list_link);
+		list_for_each_entry_safe(fsi_dev, fsi_dev_tmp,
+					&slave->my_engines, link) {
+			list_del(&fsi_dev->link);
+			put_device(&fsi_dev->dev);
+		}
+		device_unregister(&slave->dev);
+	}
+	master->slave_list = false;
+}
+
 int fsi_master_register(struct fsi_master *master)
 {
 	master->idx = atomic_inc_return(&master_idx);
+	master->slave_list = false;
 	get_device(master->dev);
 	fsi_master_scan(master);
 	return 0;
@@ -434,6 +467,7 @@ int fsi_master_register(struct fsi_master *master)
 
 void fsi_master_unregister(struct fsi_master *master)
 {
+	fsi_master_unscan(master);
 	put_device(master->dev);
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
drivers/fsi/fsi-master.h +2 -0
index 56aad0e..454af2b 100644
@@ -20,6 +20,8 @@
 #include <linux/device.h>
 
 struct fsi_master {
+	struct list_head my_slaves;
+	bool		slave_list;
 	struct device	*dev;
 	int		idx;
 	int		n_links;
include/linux/fsi.h +1 -0
index 66bce48..924502b 100644
@@ -18,6 +18,7 @@
 #include <linux/device.h>
 
 struct fsi_device {
+	struct list_head	link;	/* for slave's list */
 	struct device		dev;
 	u8			engine_type;
 	u8			version;
Signature · 1 line
1.8.2.2
#12 lore raw

Re: [PATCH 14/16] drivers/fsi: Add master unscan

Quoted 124 lines · Chris Bostic

From: Chris Bostic <[email protected]>

Allow a master to undo a previous scan. Should a master scan a bus twice it will need to ensure it doesn't double register any previously detected device.

---
 drivers/fsi/fsi-core.c   | 36 +++++++++++++++++++++++++++++++++++-
 drivers/fsi/fsi-master.h |  2 ++
 include/linux/fsi.h      |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +35 -1
index a28434b..8ccfe50 100644
@@ -41,6 +41,8 @@
 static atomic_t master_idx = ATOMIC_INIT(-1);
 
 struct fsi_slave {
+	struct list_head	list_link;	/* Master's list of slaves */
+	struct list_head	my_engines;
 	struct device		dev;
 	struct fsi_master	*master;
 	int			link;
@@ -196,6 +198,8 @@ static int fsi_slave_scan(struct fsi_slave *slave)
 	uint32_t conf;
 	int rc, i;
 
+	INIT_LIST_HEAD(&slave->my_engines);
+
 	/*
 	 * scan engines
 	 *
@@ -264,7 +268,9 @@ static int fsi_slave_scan(struct fsi_slave *slave)
 			if (rc) {
 				dev_warn(&slave->dev, "add failed: %d\n", rc);
 				put_device(&dev->dev);
+				continue;
 			}
+			list_add(&dev->link, &slave->my_engines);
 		}
 
 		engine_addr += slots * engine_page_size;
@@ -357,7 +363,7 @@ static int fsi_slave_init(struct fsi_master *master,
 		put_device(&slave->dev);
 		return rc;
 	}
-
+	list_add(&slave->list_link, &master->my_slaves);
 	fsi_slave_scan(slave);
 	return 0;
 }
@@ -388,6 +394,11 @@ static int fsi_master_scan(struct fsi_master *master)
 	int link, slave_id, rc;
 	uint32_t smode;
 
+	if (!master->slave_list) {
+		INIT_LIST_HEAD(&master->my_slaves);
+		master->slave_list = true;
+	}
+
 	for (link = 0; link < master->n_links; link++) {
 		rc = fsi_master_link_enable(master, link);
 		if (rc) {
@@ -423,9 +434,31 @@ static int fsi_master_scan(struct fsi_master *master)
 	return 0;
 }
 
+static void fsi_master_unscan(struct fsi_master *master)
+{
+	struct fsi_slave *slave, *slave_tmp;
+	struct fsi_device *fsi_dev, *fsi_dev_tmp;
+
+	if (!master->slave_list)
+		return;
+
+	list_for_each_entry_safe(slave, slave_tmp, &master->my_slaves,
+							list_link) {
+		list_del(&slave->list_link);
+		list_for_each_entry_safe(fsi_dev, fsi_dev_tmp,
+					&slave->my_engines, link) {
+			list_del(&fsi_dev->link);
+			put_device(&fsi_dev->dev);
+		}
+		device_unregister(&slave->dev);
+	}
+	master->slave_list = false;
+}
+
 int fsi_master_register(struct fsi_master *master)
 {
 	master->idx = atomic_inc_return(&master_idx);
+	master->slave_list = false;
 	get_device(master->dev);
 	fsi_master_scan(master);
 	return 0;
@@ -434,6 +467,7 @@ int fsi_master_register(struct fsi_master *master)
 
 void fsi_master_unregister(struct fsi_master *master)
 {
+	fsi_master_unscan(master);
 	put_device(master->dev);
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
drivers/fsi/fsi-master.h +2 -0
index 56aad0e..454af2b 100644
@@ -20,6 +20,8 @@
 #include <linux/device.h>
 
 struct fsi_master {
+	struct list_head my_slaves;
+	bool		slave_list;
 	struct device	*dev;
 	int		idx;
 	int		n_links;
include/linux/fsi.h +0 -0
index 66bce48..924502b 100644

include/linux/fsi.h line 21

Quoted 4 lines
include/linux/fsi.h +1 -0
@@ -18,6 +18,7 @@
 #include <linux/device.h>
 
 struct fsi_device {
+	struct list_head	link;	/* for slave's list */

Can't you use the device list on the bus instead? Putting a device on multiple lists gets tricky very quickly :(

thanks,

greg k-h

#13 lore raw

PATCH 15/16 drivers/fsi: Add documentation for GPIO bindings

In reply to Chris Bostic

From: Chris Bostic <[email protected]>

Add fsi master gpio device tree binding documentation

---
 .../devicetree/bindings/fsi/fsi-master-gpio.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +21 -0
new file mode 100644
index 0000000..ff3a62e
@@ -0,0 +1,21 @@
+Device-tree bindings for gpio-based FSI master driver
+-----------------------------------------------------
+
+Required properties:
+	- compatible = "ibm,fsi-master-gpio";
+	- clk-gpios;
+	- data-gpios;
+
+Optional properties:
+	- enable-gpios;
+	- trans-gpios;
+	- mux-gpios;
+
+fsi-master {
+	compatible = "ibm,fsi-master", "ibm,fsi-master-gpio";
+	clk-gpios = <&gpio 0 &gpio 6>;
+	data-gpios = <&gpio 1 &gpio 7>;
+	enable-gpios = <&gpio 2 &gpio 8>;	/* Enable FSI data in/out */
+	trans-gpios = <&gpio 3 &gpio 9>;	/* Volts translator direction */
+	mux-gpios = <&gpio 4> &gpio 10>;	/* Multiplexer for FSI pins */
+}
Signature · 1 line
1.8.2.2
#14 lore raw

Re: [PATCH 15/16] drivers/fsi: Add documentation for GPIO bindings

Quoted 3 lines · Chris Bostic

From: Chris Bostic <[email protected]>

Add fsi master gpio device tree binding documentation

Please see Documentation/devicetree/bindings/submitting-patches.txt.

Specifically:

* Please put binding documents earlier in the series than code implementing the binding.

* Please document _all_ compatible strings used in the series.

Please also write the binding documents in terms of the hardware, rather then the driver (e.g. introduce what the hardware is in the document, don't mention the driver). The bindings are there to describe the former to the latter, and the latter may change arbitrarily.

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt

Quoted 7 lines
---
 .../devicetree/bindings/fsi/fsi-master-gpio.txt     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt +0 -0

AFAICT, this is the first use of this directory. We should have a general FSI binding document in there, covering what FSI is, the "ibm,fsi-master" binding, etc.

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt line 1

Quoted 6 lines

new file mode 100644
index 0000000..ff3a62e

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +1 -0
@@ -0,0 +1,21 @@
+Device-tree bindings for gpio-based FSI master driver

There's very little information here, so I'm not sure what to make of this. Can you please elaborate on the above to make it clear what this means?

IIUC, this is an FSI controller/master that we only communicate with via GPIOs, right?

Or is this a *virtual* master? i.e. the GPIOs themselves form the master and are directly connected to slaves?

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt line 7

Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +6 -0
+-----------------------------------------------------
+
+Required properties:
+	- compatible = "ibm,fsi-master-gpio";
+	- clk-gpios;
+	- data-gpios;

Please give a description of what each of these are used for, how many are required, and what order elements must come in.

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt line 12

Quoted 4 lines
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +4 -0
+Optional properties:
+	- enable-gpios;
+	- trans-gpios;
+	- mux-gpios;

Likewise.

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt line 15

Quoted 3 lines
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +3 -0
+
+fsi-master {
+	compatible = "ibm,fsi-master", "ibm,fsi-master-gpio";

This is backwards. The most specific string must come first.

Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt line 20

Quoted 5 lines
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +5 -0
+	clk-gpios = <&gpio 0 &gpio 6>;
+	data-gpios = <&gpio 1 &gpio 7>;
+	enable-gpios = <&gpio 2 &gpio 8>;	/* Enable FSI data in/out */
+	trans-gpios = <&gpio 3 &gpio 9>;	/* Volts translator direction */
+	mux-gpios = <&gpio 4> &gpio 10>;	/* Multiplexer for FSI pins */

If this were described above, we don't need the comment here.

I note that in the patch, the mux-gpios property has an unmatched '>' and won't compile.

As a general nit, please bracket elements of a list individually, e.g.

	trans-gpios = <&gpio 3>, <&gpio 9>;
	mux-gpios = <&gpio 4>, <&gpio 10>;

Thanks,
Mark.

#15 lore raw

PATCH 16/16 drivers/fsi: Add GPIO based FSI master

In reply to Chris Bostic

From: Chris Bostic <[email protected]>

Implement a FSI master using GPIO. Will generate FSI protocol for read and write commands to particular addresses. Sends master command and waits for and decodes a slave response.

Includes Jeremy Kerr's original GPIO master base commit.

---
 drivers/fsi/Kconfig           |   7 +
 drivers/fsi/Makefile          |   1 +
 drivers/fsi/fsi-master-gpio.c | 552 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 560 insertions(+)
 create mode 100644 drivers/fsi/fsi-master-gpio.c
drivers/fsi/Kconfig +7 -0
index f065dbe..9530459 100644
@@ -17,6 +17,13 @@ config FSI_MASTER_FAKE
 	depends on FSI
 	---help---
 	This option enables a fake FSI master driver for debugging.
+
+config FSI_MASTER_GPIO
+	tristate "GPIO-based FSI master"
+	depends on FSI && GPIOLIB
+	---help---
+	This option enables a FSI master driver using GPIO lines.
+
 endif
 
 endmenu
drivers/fsi/Makefile +1 -0
index 847c00c..2021ce5 100644
@@ -1,3 +1,4 @@
 
 obj-$(CONFIG_FSI) += fsi-core.o
 obj-$(CONFIG_FSI_MASTER_FAKE) += fsi-master-fake.o
+obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o
drivers/fsi/fsi-master-gpio.c new file +552 -0

552 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#16 lore raw

Re: [PATCH 16/16] drivers/fsi: Add GPIO based FSI master

Hi Chris,

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c new file +7 -0
+static ssize_t store_scan(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf,
+				size_t count)
+{
+	struct fsi_master_gpio *master = dev_get_drvdata(dev);
+

drivers/fsi/fsi-master-gpio.c line 464

Quoted 10 lines
drivers/fsi/fsi-master-gpio.c new file +10 -0
+	fsi_master_gpio_init(master);
+
+	/* clear out any old scan data if present */
+	fsi_master_unregister(&master->master);
+	fsi_master_register(&master->master);
+
+	return count;
+}
+
+static DEVICE_ATTR(scan, 0200, NULL, store_scan);

I think it would make more sense to have the scan attribute populated by the fsi core; we want this on all masters, not just GPIO.

Currently, the only GPIO-master-specific functionality here is the fsi_master_gpio_init() - but isn't this something that we can do at probe time instead?

drivers/fsi/fsi-master-gpio.c line 473

Quoted 8 lines
drivers/fsi/fsi-master-gpio.c new file +8 -0
+static int fsi_master_gpio_probe(struct platform_device *pdev)
+{
+	struct fsi_master_gpio *master;
+	struct gpio_desc *gpio;
+
+	master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL);
+	if (!master)
+		return -ENOMEM;

We should be populating master->dev.parent, see

https://github.com/jk-ozlabs/linux/commit/5225d6c47

drivers/fsi/fsi-master-gpio.c line 495

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c new file +7 -0
+	/* Optional pins */
+
+	gpio = devm_gpiod_get(&pdev->dev, "trans", 0);
+	if (IS_ERR(gpio))
+		dev_dbg(&pdev->dev, "probe: failed to get trans pin\n");
+	else
+		master->gpio_trans = gpio;

I found devm_gpiod_get_optional(), which might make this a little neater.

Cheers,

Jeremy

#17 lore raw

Re: [PATCH 16/16] drivers/fsi: Add GPIO based FSI master

Quoted 14 lines · Jeremy Kerr

Hi Chris,

Quoted 12 lines
drivers/fsi/fsi-master-gpio.c new file +12 -0
+static ssize_t store_scan(struct device *dev,
+                             struct device_attribute *attr,
+                             const char *buf,
+                             size_t count)
+{
+     struct fsi_master_gpio *master = dev_get_drvdata(dev);
+
+     fsi_master_gpio_init(master);
+
+     /* clear out any old scan data if present */
+     fsi_master_unregister(&master->master);
+     fsi_master_register(&master->master);
Quoted 9 lines

drivers/fsi/fsi-master-gpio.c line 464

Quoted 5 lines
drivers/fsi/fsi-master-gpio.c new file +5 -0
+
+     return count;
+}
+
+static DEVICE_ATTR(scan, 0200, NULL, store_scan);

I think it would make more sense to have the scan attribute populated by the fsi core; we want this on all masters, not just GPIO.

Hi Jeremy,

Sure, will move that to the core.

Quoted 4 lines

Currently, the only GPIO-master-specific functionality here is the fsi_master_gpio_init() - but isn't this something that we can do at probe time instead?

Yes that can be done at probe time. Will change.

Quoted 11 lines

drivers/fsi/fsi-master-gpio.c line 473

Quoted 8 lines
drivers/fsi/fsi-master-gpio.c new file +8 -0
+static int fsi_master_gpio_probe(struct platform_device *pdev)
+{
+     struct fsi_master_gpio *master;
+     struct gpio_desc *gpio;
+
+     master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL);
+     if (!master)
+             return -ENOMEM;

We should be populating master->dev.parent, see

Quoted 3 lines

https://github.com/jk-ozlabs/linux/commit/5225d6c47

Will make the change.

Quoted 10 lines

drivers/fsi/fsi-master-gpio.c line 495

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c new file +7 -0
+     /* Optional pins */
+
+     gpio = devm_gpiod_get(&pdev->dev, "trans", 0);
+     if (IS_ERR(gpio))
+             dev_dbg(&pdev->dev, "probe: failed to get trans pin\n");
+     else
+             master->gpio_trans = gpio;

I found devm_gpiod_get_optional(), which might make this a little neater.

Will make this change.

Thanks,
Chris

Quoted 5 lines

Cheers,

Jeremy

#18 lore raw
In reply to Chris Bostic

Hi.

Quoted 7 lines · Chris Bostic

[...]

Introduction of the IBM 'Flexible Support Interface' (FSI) bus device driver. FSI is a high fan out serial bus consisting of a clock and a serial data line capable of running at speeds up to 166 MHz.

[...]

I would expect, that this information is added to Documentation/ and there should be Documentation/ABI/<stable or testing>/sysfs-bus-fsi

P.S.: I'm not sure, why I'm Cc'd.

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161207/fdc6ee6c/attachment.sig>