Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1616502 > unrolled thread
| Started by | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| First post | 2017-04-05 04:10 +0200 |
| Last post | 2017-04-05 04:20 +0200 |
| Articles | 8 on this page of 28 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v5 00/23] FSI device driver implementation Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 03/23] drivers/fsi: Add empty master scan Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 14/23] drivers/fsi: Add sysfs files for FSI master & slave accesses Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 05/23] drivers/fsi: Add slave & master read/write APIs Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 01/23] drivers/fsi: Add fsi master definition Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 08/23] drivers/fsi: Set slave SMODE to init communication Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 07/23] drivers/fsi: Implement slave initialisation Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 02/23] drivers/fsi: Add slave definition Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 13/23] drivers/fsi: Add client driver register utilities Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 16/23] drivers/fsi: Add tracepoints for low-level operations Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 17/23] drivers/fsi: Add error handling for slave communication errors Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 12/23] drivers/fsi: Add documentation for GPIO bindings Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 15/23] drivers/fsi: expose direct-access slave API Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 10/23] drivers/fsi: Add device read/write/peek API Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 04/23] drivers/fsi: Add crc4 helpers Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:10 +0200
[PATCH v5 23/23] drivers/fsi: Use asynchronous slave mode Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
[PATCH v5 19/23] drivers/fsi: Add GPIO based FSI master Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
Re: [PATCH v5 19/23] drivers/fsi: Add GPIO based FSI master Randy Dunlap <rdunlap@infradead.org> - 2017-04-05 18:40 +0200
Re: [PATCH v5 19/23] drivers/fsi: Add GPIO based FSI master Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-09 23:10 +0200
[PATCH v5 22/23] drivers/fsi: Add hub master support Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
Re: [PATCH v5 22/23] drivers/fsi: Add hub master support Randy Dunlap <rdunlap@infradead.org> - 2017-04-05 18:40 +0200
Re: [PATCH v5 22/23] drivers/fsi: Add hub master support Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-09 23:10 +0200
[PATCH v5 18/23] drivers/fsi: Document FSI master sysfs files in ABI Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
[PATCH v5 20/23] drivers/fsi/gpio: Add tracepoints for GPIO master Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
[PATCH v5 21/23] drivers/fsi: Add SCOM FSI client device driver Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
Re: [PATCH v5 21/23] drivers/fsi: Add SCOM FSI client device driver Randy Dunlap <rdunlap@infradead.org> - 2017-04-05 18:40 +0200
Re: [PATCH v5 21/23] drivers/fsi: Add SCOM FSI client device driver Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-09 23:10 +0200
[PATCH v5 11/23] drivers/fsi: Add master unscan Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-04-05 04:20 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Randy Dunlap <rdunlap@infradead.org> |
|---|---|
| Date | 2017-04-05 18:40 +0200 |
| Subject | Re: [PATCH v5 22/23] drivers/fsi: Add hub master support |
| Message-ID | <tsW8q-51d-23@gated-at.bofh.it> |
| In reply to | #1616522 |
On 04/04/17 19:06, Christopher Bostic wrote: > From: Chris Bostic <cbostic@linux.vnet.ibm.com> > > Add an engine driver to expose a "hub" FSI master - which has a set of > control registers in the engine address space, and uses a chunk of the > slave address space for actual FSI communication. > > Additional changes from Jeremy Kerr <jk@ozlabs.org>. > > Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> > Signed-off-by: Jeremy Kerr <jk@ozlabs.org> > Signed-off-by: Joel Stanley <joel@jms.id.au> > --- > drivers/fsi/Kconfig | 9 ++ > drivers/fsi/Makefile | 1 + > drivers/fsi/fsi-master-hub.c | 327 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 337 insertions(+) > create mode 100644 drivers/fsi/fsi-master-hub.c > > diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig > index 0fa265c..e1156b4 100644 > --- a/drivers/fsi/Kconfig > +++ b/drivers/fsi/Kconfig > @@ -18,6 +18,15 @@ config FSI_MASTER_GPIO > ---help--- > This option enables a FSI master driver using GPIO lines. > > +config FSI_MASTER_HUB > + tristate "FSI hub master" > + depends on FSI redundant again. > + ---help--- > + This option enables a FSI hub master driver. Hub is a type of FSI > + master that is connected to the upstream master via a slave. Hubs > + allow chaining of FSI links to an arbitrary depth. This allows for > + a high target device fanout. > + > config FSI_SCOM > tristate "SCOM FSI client device driver" > depends on FSI -- ~Randy
[toc] | [prev] | [next] | [standalone]
| From | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-04-09 23:10 +0200 |
| Subject | Re: [PATCH v5 22/23] drivers/fsi: Add hub master support |
| Message-ID | <tusfT-8ec-9@gated-at.bofh.it> |
| In reply to | #1617129 |
On 4/5/17 11:36 AM, Randy Dunlap wrote: > On 04/04/17 19:06, Christopher Bostic wrote: >> From: Chris Bostic <cbostic@linux.vnet.ibm.com> >> >> Add an engine driver to expose a "hub" FSI master - which has a set of >> control registers in the engine address space, and uses a chunk of the >> slave address space for actual FSI communication. >> >> Additional changes from Jeremy Kerr <jk@ozlabs.org>. >> >> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> >> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> >> Signed-off-by: Joel Stanley <joel@jms.id.au> >> --- >> drivers/fsi/Kconfig | 9 ++ >> drivers/fsi/Makefile | 1 + >> drivers/fsi/fsi-master-hub.c | 327 +++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 337 insertions(+) >> create mode 100644 drivers/fsi/fsi-master-hub.c >> >> diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig >> index 0fa265c..e1156b4 100644 >> --- a/drivers/fsi/Kconfig >> +++ b/drivers/fsi/Kconfig >> @@ -18,6 +18,15 @@ config FSI_MASTER_GPIO >> ---help--- >> This option enables a FSI master driver using GPIO lines. >> >> +config FSI_MASTER_HUB >> + tristate "FSI hub master" >> + depends on FSI > redundant again. Will correct. Thanks, Chris > >> + ---help--- >> + This option enables a FSI hub master driver. Hub is a type of FSI >> + master that is connected to the upstream master via a slave. Hubs >> + allow chaining of FSI links to an arbitrary depth. This allows for >> + a high target device fanout. >> + >> config FSI_SCOM >> tristate "SCOM FSI client device driver" >> depends on FSI >
[toc] | [prev] | [next] | [standalone]
| From | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-04-05 04:20 +0200 |
| Subject | [PATCH v5 18/23] drivers/fsi: Document FSI master sysfs files in ABI |
| Message-ID | <tsIIa-4VI-25@gated-at.bofh.it> |
| In reply to | #1616502 |
From: Chris Bostic <cbostic@linux.vnet.ibm.com> Add info for sysfs scan file in Documentaiton ABI/testing Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> --- Documentation/ABI/testing/sysfs-bus-fsi | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-fsi diff --git a/Documentation/ABI/testing/sysfs-bus-fsi b/Documentation/ABI/testing/sysfs-bus-fsi new file mode 100644 index 0000000..dfcbc1b --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-fsi @@ -0,0 +1,6 @@ +What: /sys/bus/platform/devices/fsi-master/scan +KernelVersion: 4.9 +Contact: cbostic@us.ibm.com +Description: + Initiates a FSI master scan for all connected + slave devices on its links. -- 1.8.2.2
[toc] | [prev] | [next] | [standalone]
| From | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-04-05 04:20 +0200 |
| Subject | [PATCH v5 20/23] drivers/fsi/gpio: Add tracepoints for GPIO master |
| Message-ID | <tsIIa-4VI-17@gated-at.bofh.it> |
| In reply to | #1616502 |
From: Jeremy Kerr <jk@ozlabs.org>
Add trace points for key GPIO operations of the GPIO based FSI
master.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com>
---
drivers/fsi/fsi-master-gpio.c | 9 +++++
include/trace/events/fsi_master_gpio.h | 68 ++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 include/trace/events/fsi_master_gpio.h
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index 9fedfaf..5d9e0b0 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -61,6 +61,9 @@ struct fsi_master_gpio {
struct gpio_desc *gpio_mux; /* Mux control */
};
+#define CREATE_TRACE_POINTS
+#include <trace/events/fsi_master_gpio.h>
+
#define to_fsi_master_gpio(m) container_of(m, struct fsi_master_gpio, master)
struct fsi_gpio_msg {
@@ -128,6 +131,8 @@ static void serial_in(struct fsi_master_gpio *master, struct fsi_gpio_msg *msg,
msg->msg |= ~in_bit & 0x1; /* Data is negative active */
}
msg->bits += num_bits;
+
+ trace_fsi_master_gpio_in(master, num_bits, msg->msg);
}
static void serial_out(struct fsi_master_gpio *master,
@@ -139,6 +144,8 @@ static void serial_out(struct fsi_master_gpio *master,
uint64_t last_bit = ~0;
int next_bit;
+ trace_fsi_master_gpio_out(master, cmd->bits, cmd->msg);
+
if (!cmd->bits) {
dev_warn(master->dev, "trying to output 0 bits\n");
return;
@@ -464,6 +471,8 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link)
if (link != 0)
return -ENODEV;
+ trace_fsi_master_gpio_break(master);
+
set_sda_output(master, 1);
sda_out(master, 1);
clock_toggle(master, FSI_PRE_BREAK_CLOCKS);
diff --git a/include/trace/events/fsi_master_gpio.h b/include/trace/events/fsi_master_gpio.h
new file mode 100644
index 0000000..11b36c1
--- /dev/null
+++ b/include/trace/events/fsi_master_gpio.h
@@ -0,0 +1,68 @@
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM fsi_master_gpio
+
+#if !defined(_TRACE_FSI_MASTER_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_FSI_MASTER_GPIO_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(fsi_master_gpio_in,
+ TP_PROTO(const struct fsi_master_gpio *master, int bits, uint64_t msg),
+ TP_ARGS(master, bits, msg),
+ TP_STRUCT__entry(
+ __field(int, master_idx)
+ __field(int, bits)
+ __field(uint64_t, msg)
+ ),
+ TP_fast_assign(
+ __entry->master_idx = master->master.idx;
+ __entry->bits = bits;
+ __entry->msg = msg & ((1ull<<bits) - 1);
+ ),
+ TP_printk("fsi-gpio%d => %0*llx[%d]",
+ __entry->master_idx,
+ (__entry->bits + 3) / 4,
+ __entry->msg,
+ __entry->bits
+ )
+);
+
+TRACE_EVENT(fsi_master_gpio_out,
+ TP_PROTO(const struct fsi_master_gpio *master, int bits, uint64_t msg),
+ TP_ARGS(master, bits, msg),
+ TP_STRUCT__entry(
+ __field(int, master_idx)
+ __field(int, bits)
+ __field(uint64_t, msg)
+ ),
+ TP_fast_assign(
+ __entry->master_idx = master->master.idx;
+ __entry->bits = bits;
+ __entry->msg = msg & ((1ull<<bits) - 1);
+ ),
+ TP_printk("fsi-gpio%d <= %0*llx[%d]",
+ __entry->master_idx,
+ (__entry->bits + 3) / 4,
+ __entry->msg,
+ __entry->bits
+ )
+);
+
+TRACE_EVENT(fsi_master_gpio_break,
+ TP_PROTO(const struct fsi_master_gpio *master),
+ TP_ARGS(master),
+ TP_STRUCT__entry(
+ __field(int, master_idx)
+ ),
+ TP_fast_assign(
+ __entry->master_idx = master->master.idx;
+ ),
+ TP_printk("fsi-gpio%d ----break---",
+ __entry->master_idx
+ )
+);
+
+#endif /* _TRACE_FSI_MASTER_GPIO_H */
+
+#include <trace/define_trace.h>
--
1.8.2.2
[toc] | [prev] | [next] | [standalone]
| From | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-04-05 04:20 +0200 |
| Subject | [PATCH v5 21/23] drivers/fsi: Add SCOM FSI client device driver |
| Message-ID | <tsIIa-4VI-19@gated-at.bofh.it> |
| In reply to | #1616502 |
From: Chris Bostic <cbostic@linux.vnet.ibm.com>
Create a simple SCOM engine device driver that reads and writes
its control registers via an FSI bus.
Includes changes from Edward A. James <eajames@us.ibm.com>.
Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Edward A. James <eajames@us.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
drivers/fsi/Kconfig | 6 ++
drivers/fsi/Makefile | 1 +
drivers/fsi/fsi-scom.c | 263 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 270 insertions(+)
create mode 100644 drivers/fsi/fsi-scom.c
diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig
index 9cf8345..0fa265c 100644
--- a/drivers/fsi/Kconfig
+++ b/drivers/fsi/Kconfig
@@ -18,6 +18,12 @@ config FSI_MASTER_GPIO
---help---
This option enables a FSI master driver using GPIO lines.
+config FSI_SCOM
+ tristate "SCOM FSI client device driver"
+ depends on FSI
+ ---help---
+ This option enables an FSI based SCOM device driver.
+
endif
endmenu
diff --git a/drivers/fsi/Makefile b/drivers/fsi/Makefile
index ed28ac0..3466f08 100644
--- a/drivers/fsi/Makefile
+++ b/drivers/fsi/Makefile
@@ -1,3 +1,4 @@
obj-$(CONFIG_FSI) += fsi-core.o
obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o
+obj-$(CONFIG_FSI_SCOM) += fsi-scom.o
diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c
new file mode 100644
index 0000000..98d062f
--- /dev/null
+++ b/drivers/fsi/fsi-scom.c
@@ -0,0 +1,263 @@
+/*
+ * SCOM FSI Client device 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
+ * MERGCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/fsi.h>
+#include <linux/module.h>
+#include <linux/cdev.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/slab.h>
+#include <linux/miscdevice.h>
+#include <linux/list.h>
+#include <linux/idr.h>
+
+#define FSI_ENGID_SCOM 0x5
+
+#define SCOM_FSI2PIB_DELAY 50
+
+/* SCOM engine register set */
+#define SCOM_DATA0_REG 0x00
+#define SCOM_DATA1_REG 0x04
+#define SCOM_CMD_REG 0x08
+#define SCOM_RESET_REG 0x1C
+
+#define SCOM_RESET_CMD 0x80000000
+#define SCOM_WRITE_CMD 0x80000000
+
+struct scom_device {
+ struct list_head link;
+ struct fsi_device *fsi_dev;
+ struct miscdevice mdev;
+ char name[32];
+ int idx;
+};
+
+#define to_scom_dev(x) container_of((x), struct scom_device, mdev)
+
+static struct list_head scom_devices;
+
+static DEFINE_IDA(scom_ida);
+
+static int put_scom(struct scom_device *scom_dev, uint64_t value,
+ uint32_t addr)
+{
+ int rc;
+ uint32_t data;
+
+ data = cpu_to_be32(SCOM_RESET_CMD);
+ rc = fsi_device_write(scom_dev->fsi_dev, SCOM_RESET_REG, &data,
+ sizeof(uint32_t));
+ if (rc)
+ return rc;
+
+ data = cpu_to_be32((value >> 32) & 0xffffffff);
+ rc = fsi_device_write(scom_dev->fsi_dev, SCOM_DATA0_REG, &data,
+ sizeof(uint32_t));
+ if (rc)
+ return rc;
+
+ data = cpu_to_be32(value & 0xffffffff);
+ rc = fsi_device_write(scom_dev->fsi_dev, SCOM_DATA1_REG, &data,
+ sizeof(uint32_t));
+ if (rc)
+ return rc;
+
+ data = cpu_to_be32(SCOM_WRITE_CMD | addr);
+ return fsi_device_write(scom_dev->fsi_dev, SCOM_CMD_REG, &data,
+ sizeof(uint32_t));
+}
+
+static int get_scom(struct scom_device *scom_dev, uint64_t *value,
+ uint32_t addr)
+{
+ uint32_t result, data;
+ int rc;
+
+ *value = 0ULL;
+ data = cpu_to_be32(addr);
+ rc = fsi_device_write(scom_dev->fsi_dev, SCOM_CMD_REG, &data,
+ sizeof(uint32_t));
+ if (rc)
+ return rc;
+
+ rc = fsi_device_read(scom_dev->fsi_dev, SCOM_DATA0_REG, &result,
+ sizeof(uint32_t));
+ if (rc)
+ return rc;
+
+ *value |= (uint64_t)cpu_to_be32(result) << 32;
+ rc = fsi_device_read(scom_dev->fsi_dev, SCOM_DATA1_REG, &result,
+ sizeof(uint32_t));
+ if (rc)
+ return rc;
+
+ *value |= cpu_to_be32(result);
+
+ return 0;
+}
+
+static ssize_t scom_read(struct file *filep, char __user *buf, size_t len,
+ loff_t *offset)
+{
+ int rc;
+ struct miscdevice *mdev =
+ (struct miscdevice *)filep->private_data;
+ struct scom_device *scom = to_scom_dev(mdev);
+ struct device *dev = &scom->fsi_dev->dev;
+ uint64_t val;
+
+ if (len != sizeof(uint64_t))
+ return -EINVAL;
+
+ rc = get_scom(scom, &val, *offset);
+ if (rc) {
+ dev_dbg(dev, "get_scom fail:%d\n", rc);
+ return rc;
+ }
+
+ rc = copy_to_user(buf, &val, len);
+ if (rc)
+ dev_dbg(dev, "copy to user failed:%d\n", rc);
+
+ return rc ? rc : len;
+}
+
+static ssize_t scom_write(struct file *filep, const char __user *buf,
+ size_t len, loff_t *offset)
+{
+ int rc;
+ struct miscdevice *mdev = filep->private_data;
+ struct scom_device *scom = to_scom_dev(mdev);
+ struct device *dev = &scom->fsi_dev->dev;
+ uint64_t val;
+
+ if (len != sizeof(uint64_t))
+ return -EINVAL;
+
+ rc = copy_from_user(&val, buf, len);
+ if (rc) {
+ dev_dbg(dev, "copy from user failed:%d\n", rc);
+ return -EINVAL;
+ }
+
+ rc = put_scom(scom, val, *offset);
+ if (rc) {
+ dev_dbg(dev, "put_scom failed with:%d\n", rc);
+ return rc;
+ }
+
+ return len;
+}
+
+static loff_t scom_llseek(struct file *file, loff_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_CUR:
+ break;
+ case SEEK_SET:
+ file->f_pos = offset;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return offset;
+}
+
+static const struct file_operations scom_fops = {
+ .owner = THIS_MODULE,
+ .llseek = scom_llseek,
+ .read = scom_read,
+ .write = scom_write,
+};
+
+static int scom_probe(struct device *dev)
+{
+ struct fsi_device *fsi_dev = to_fsi_dev(dev);
+ struct scom_device *scom;
+
+ scom = devm_kzalloc(dev, sizeof(*scom), GFP_KERNEL);
+ if (!scom)
+ return -ENOMEM;
+
+ scom->idx = ida_simple_get(&scom_ida, 1, INT_MAX, GFP_KERNEL);
+ snprintf(scom->name, sizeof(scom->name), "scom%d", scom->idx);
+ scom->fsi_dev = fsi_dev;
+ scom->mdev.minor = MISC_DYNAMIC_MINOR;
+ scom->mdev.fops = &scom_fops;
+ scom->mdev.name = scom->name;
+ scom->mdev.parent = dev;
+ list_add(&scom->link, &scom_devices);
+
+ return misc_register(&scom->mdev);
+}
+
+static int scom_remove(struct device *dev)
+{
+ struct scom_device *scom, *scom_tmp;
+ struct fsi_device *fsi_dev = to_fsi_dev(dev);
+
+ list_for_each_entry_safe(scom, scom_tmp, &scom_devices, link) {
+ if (scom->fsi_dev == fsi_dev) {
+ list_del(&scom->link);
+ ida_simple_remove(&scom_ida, scom->idx);
+ misc_deregister(&scom->mdev);
+ }
+ }
+
+ return 0;
+}
+
+static struct fsi_device_id scom_ids[] = {
+ {
+ .engine_type = FSI_ENGID_SCOM,
+ .version = FSI_VERSION_ANY,
+ },
+ { 0 }
+};
+
+static struct fsi_driver scom_drv = {
+ .id_table = scom_ids,
+ .drv = {
+ .name = "scom",
+ .bus = &fsi_bus_type,
+ .probe = scom_probe,
+ .remove = scom_remove,
+ }
+};
+
+static int scom_init(void)
+{
+ INIT_LIST_HEAD(&scom_devices);
+ return fsi_driver_register(&scom_drv);
+}
+
+static void scom_exit(void)
+{
+ struct list_head *pos;
+ struct scom_device *scom;
+
+ list_for_each(pos, &scom_devices) {
+ scom = list_entry(pos, struct scom_device, link);
+ misc_deregister(&scom->mdev);
+ devm_kfree(&scom->fsi_dev->dev, scom);
+ }
+ fsi_driver_unregister(&scom_drv);
+}
+
+module_init(scom_init);
+module_exit(scom_exit);
+MODULE_LICENSE("GPL");
--
1.8.2.2
[toc] | [prev] | [next] | [standalone]
| From | Randy Dunlap <rdunlap@infradead.org> |
|---|---|
| Date | 2017-04-05 18:40 +0200 |
| Subject | Re: [PATCH v5 21/23] drivers/fsi: Add SCOM FSI client device driver |
| Message-ID | <tsW8q-51d-7@gated-at.bofh.it> |
| In reply to | #1616526 |
On 04/04/17 19:06, Christopher Bostic wrote: > From: Chris Bostic <cbostic@linux.vnet.ibm.com> > > Create a simple SCOM engine device driver that reads and writes > its control registers via an FSI bus. > > Includes changes from Edward A. James <eajames@us.ibm.com>. > > Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> > Signed-off-by: Joel Stanley <joel@jms.id.au> > Signed-off-by: Edward A. James <eajames@us.ibm.com> > Signed-off-by: Jeremy Kerr <jk@ozlabs.org> > --- > drivers/fsi/Kconfig | 6 ++ > drivers/fsi/Makefile | 1 + > drivers/fsi/fsi-scom.c | 263 +++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 270 insertions(+) > create mode 100644 drivers/fsi/fsi-scom.c > > diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig > index 9cf8345..0fa265c 100644 > --- a/drivers/fsi/Kconfig > +++ b/drivers/fsi/Kconfig > @@ -18,6 +18,12 @@ config FSI_MASTER_GPIO > ---help--- > This option enables a FSI master driver using GPIO lines. > > +config FSI_SCOM > + tristate "SCOM FSI client device driver" > + depends on FSI depends on FSI is redundant. > + ---help--- > + This option enables an FSI based SCOM device driver. > + > endif > -- ~Randy
[toc] | [prev] | [next] | [standalone]
| From | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-04-09 23:10 +0200 |
| Subject | Re: [PATCH v5 21/23] drivers/fsi: Add SCOM FSI client device driver |
| Message-ID | <tusfU-8ec-15@gated-at.bofh.it> |
| In reply to | #1617128 |
On 4/5/17 11:35 AM, Randy Dunlap wrote: > On 04/04/17 19:06, Christopher Bostic wrote: >> From: Chris Bostic <cbostic@linux.vnet.ibm.com> >> >> Create a simple SCOM engine device driver that reads and writes >> its control registers via an FSI bus. >> >> Includes changes from Edward A. James <eajames@us.ibm.com>. >> >> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com> >> Signed-off-by: Joel Stanley <joel@jms.id.au> >> Signed-off-by: Edward A. James <eajames@us.ibm.com> >> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> >> --- >> drivers/fsi/Kconfig | 6 ++ >> drivers/fsi/Makefile | 1 + >> drivers/fsi/fsi-scom.c | 263 +++++++++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 270 insertions(+) >> create mode 100644 drivers/fsi/fsi-scom.c >> >> diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig >> index 9cf8345..0fa265c 100644 >> --- a/drivers/fsi/Kconfig >> +++ b/drivers/fsi/Kconfig >> @@ -18,6 +18,12 @@ config FSI_MASTER_GPIO >> ---help--- >> This option enables a FSI master driver using GPIO lines. >> >> +config FSI_SCOM >> + tristate "SCOM FSI client device driver" >> + depends on FSI > depends on FSI is redundant. Will correct. Thanks, Chris > >> + ---help--- >> + This option enables an FSI based SCOM device driver. >> + >> endif >> >
[toc] | [prev] | [next] | [standalone]
| From | Christopher Bostic <cbostic@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-04-05 04:20 +0200 |
| Subject | [PATCH v5 11/23] drivers/fsi: Add master unscan |
| Message-ID | <tsIIa-4VI-23@gated-at.bofh.it> |
| In reply to | #1616502 |
From: Chris Bostic <cbostic@linux.vnet.ibm.com>
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.
Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/fsi/fsi-core.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 4da0b030..75d2a88 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -69,6 +69,7 @@ struct fsi_slave {
uint32_t size; /* size of slave address space */
};
+#define to_fsi_master(d) container_of(d, struct fsi_master, dev)
#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
static int fsi_master_read(struct fsi_master *master, int link,
@@ -491,6 +492,37 @@ static int fsi_master_scan(struct fsi_master *master)
return 0;
}
+static int __fsi_slave_remove_device(struct device *dev, void *arg)
+{
+ device_unregister(dev);
+ return 0;
+}
+
+static int __fsi_master_remove_slave(struct device *dev, void *arg)
+{
+ device_for_each_child(dev, NULL, __fsi_slave_remove_device);
+ device_unregister(dev);
+ return 0;
+}
+
+static void fsi_master_unscan(struct fsi_master *master)
+{
+ device_for_each_child(&master->dev, NULL, __fsi_master_remove_slave);
+}
+
+static ssize_t master_rescan_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct fsi_master *master = to_fsi_master(dev);
+
+ fsi_master_unscan(master);
+ fsi_master_scan(master);
+
+ return count;
+}
+
+static DEVICE_ATTR(rescan, 0200, NULL, master_rescan_store);
+
int fsi_master_register(struct fsi_master *master)
{
int rc;
@@ -507,7 +539,15 @@ int fsi_master_register(struct fsi_master *master)
return rc;
}
+ rc = device_create_file(&master->dev, &dev_attr_rescan);
+ if (rc) {
+ device_unregister(&master->dev);
+ ida_simple_remove(&master_ida, master->idx);
+ return rc;
+ }
+
fsi_master_scan(master);
+
return 0;
}
EXPORT_SYMBOL_GPL(fsi_master_register);
--
1.8.2.2
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web