From: Christopher Bostic <cbostic@linux.vnet.ibm.com>
To: Joel Stanley <joel@jms.id.au>
Cc: Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Russell King <linux@armlinux.org.uk>,
rostedt@goodmis.org, mingo@redhat.com,
Greg KH <gregkh@linuxfoundation.org>,
devicetree <devicetree@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org, Jeremy Kerr <jk@ozlabs.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Jeffery <andrew@aj.id.au>,
Alistair Popple <alistair@popple.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH v6 09/23] drivers/fsi: scan slaves & register devices
Date: Wed, 10 May 2017 13:24:41 -0500 [thread overview]
Message-ID: <277d5a2d-b78d-11da-3986-0cc42914b149@linux.vnet.ibm.com> (raw)
In-Reply-To: <CACPK8XfAtMzXnfS4TD7QXXwvrqgnwmpoQWoZcTbD2Hj2Dcnwgw@mail.gmail.com>
On 5/10/17 2:30 AM, Joel Stanley wrote:
> On Tue, Apr 11, 2017 at 5:16 AM, Christopher Bostic
> <cbostic@linux.vnet.ibm.com> wrote:
>> From: Jeremy Kerr <jk@ozlabs.org>
>>
>> Now that we have fsi_slave devices, scan each for endpoints, and
>> register them on the fsi bus.
>>
>> Includes contributions from Chris Bostic <cbostic@linux.vnet.ibm.com>
>>
>> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
>> Signed-off-by: Chris Bostic <cbostic@linux.vnet.ibm.com>
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> ---
>> drivers/fsi/fsi-core.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++--
>> include/linux/fsi.h | 4 ++
>> 2 files changed, 128 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
>> index b7b138b..a8faa89 100644
>> --- a/drivers/fsi/fsi-core.c
>> +++ b/drivers/fsi/fsi-core.c
>> @@ -21,6 +21,19 @@
>>
>> #include "fsi-master.h"
>>
>> +#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
> You could use GENAMSK for these. It would make it easier to check eg.
> that 0x00ff0000 needs to be shifted by 16.
Hi Joel,
OK will update to use GENMASK.
>
>> +
>> +static const int engine_page_size = 0x400;
>> +
>> #define FSI_SLAVE_BASE 0x800
>>
>> /*
>> @@ -61,6 +74,30 @@ static int fsi_master_read(struct fsi_master *master, int link,
>> static int fsi_master_write(struct fsi_master *master, int link,
>> uint8_t slave_id, uint32_t addr, const void *val, size_t size);
>>
>> +/* 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,
>> @@ -138,6 +175,91 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
>> 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;
>> + }
>> + conf = be32_to_cpu(conf);
>> +
>> + crc = fsi_crc4(0, conf, 32);
>> + if (crc) {
>> + 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 && slots != 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);
> This produces a lot of noise in the kernel log. I suggest making it
> drv_dbg if you require it. If you don't then remove it.
Will need for debug purposes so will change to dev_dbg( ).
>
>> +
>> + dev_set_name(&dev->dev, "%02x:%02x:%02x:%02x",
>> + slave->master->idx, slave->link,
>> + slave->id, i - 2);
>> +
>> + rc = device_register(&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;
>> +}
>> +
>> /* Encode slave local bus echo delay */
>> static inline uint32_t fsi_smode_echodly(int x)
>> {
>> @@ -253,9 +375,8 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
>> return rc;
>> }
>>
>> - /* todo: perform engine scan */
>> -
>> - return rc;
>> + fsi_slave_scan(slave);
>> + return 0;
> You don't check the return value of fsi_slave_scan.
Will correct.
Thanks,
-Chris
>> }
>>
>> /* FSI master support */
>> diff --git a/include/linux/fsi.h b/include/linux/fsi.h
>> index 273cbf6..efa55ba 100644
>> --- a/include/linux/fsi.h
>> +++ b/include/linux/fsi.h
>> @@ -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 {
>> --
>> 1.8.2.2
>>
next prev parent reply other threads:[~2017-05-10 18:24 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 19:46 [PATCH v6 00/23] FSI device driver implementation Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 01/23] drivers/fsi: Add fsi master definition Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 02/23] drivers/fsi: Add slave definition Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 03/23] drivers/fsi: Add empty master scan Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 04/23] drivers/fsi: Add crc4 helpers Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 05/23] drivers/fsi: Add slave & master read/write APIs Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 06/23] drivers/fsi: Set up links for slave communication Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 07/23] drivers/fsi: Implement slave initialisation Christopher Bostic
2017-05-02 6:24 ` Joel Stanley
2017-05-02 18:58 ` Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 08/23] drivers/fsi: Set slave SMODE to init communication Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 09/23] drivers/fsi: scan slaves & register devices Christopher Bostic
2017-05-10 7:30 ` Joel Stanley
2017-05-10 18:24 ` Christopher Bostic [this message]
2017-04-10 19:46 ` [PATCH v6 10/23] drivers/fsi: Add device read/write/peek API Christopher Bostic
2017-05-02 5:25 ` [v6,10/23] " Brad Bishop
2017-05-10 8:13 ` [PATCH v6 10/23] " Joel Stanley
2017-05-10 18:38 ` Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 11/23] drivers/fsi: Add master unscan Christopher Bostic
2017-05-10 7:31 ` Joel Stanley
2017-05-10 18:33 ` Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 12/23] drivers/fsi: Add documentation for GPIO bindings Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 13/23] drivers/fsi: Add client driver register utilities Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 14/23] drivers/fsi: Add sysfs files for FSI master & slave accesses Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 15/23] drivers/fsi: expose direct-access slave API Christopher Bostic
2017-04-10 19:46 ` [PATCH v6 16/23] drivers/fsi: Add tracepoints for low-level operations Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 17/23] drivers/fsi: Add error handling for slave communication errors Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 18/23] drivers/fsi: Document FSI master sysfs files in ABI Christopher Bostic
2017-05-10 7:30 ` Joel Stanley
2017-05-10 18:20 ` Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 19/23] drivers/fsi: Add GPIO based FSI master Christopher Bostic
2017-05-10 7:30 ` Joel Stanley
2017-05-10 18:15 ` Christopher Bostic
2017-05-11 1:58 ` Jeremy Kerr
2017-05-11 16:14 ` Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 20/23] drivers/fsi/gpio: Add tracepoints for GPIO master Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 21/23] drivers/fsi: Add SCOM FSI client device driver Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 22/23] drivers/ fsi: Add hub master support Christopher Bostic
2017-04-10 19:47 ` [PATCH v6 23/23] drivers/fsi: Use asynchronous slave mode Christopher Bostic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=277d5a2d-b78d-11da-3986-0cc42914b149@linux.vnet.ibm.com \
--to=cbostic@linux.vnet.ibm.com \
--cc=alistair@popple.id.au \
--cc=andrew@aj.id.au \
--cc=benh@kernel.crashing.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=robh+dt@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).