Add the I3C subsystem
Subsystems (6)
v8 cover Add the I3C subsystem
Hi,
Sorry for the huge delay between v7 and v8 despite the small amount of things I was asked to fix/rework.
This patch series is adding a new subsystem to support I3C devices.
This is just adding support for basic features. Extra features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is still open to discussion. Please let me know if you think it's worth considering an asynchronous model here
- the I3C bus and I3C master controller are now tightly coupled even though they're still allocated separately. There's now a 1:1 relationship between these objects, and the I3C master is no longer represented under the I3C bus object.
Arnd, let me know if you had something different in mind, and I'll rework the implementation accordingly.
- I2C backward compatibility has been designed to be transparent to I2C drivers and the I2C subsystem. The I3C master just registers an I2C adapter which creates a new I2C bus. I'd say that, from a representation PoV it's not ideal because what should appear as a single I3C bus exposing I3C and I2C devices here appears as 2 different busses connected to each other through the parenting (the I3C master is the parent of the I2C and I3C busses).
On the other hand, I don't see a better solution if we want something that is not invasive.
Missing features (will be added in separate patch series after initial support has been accepted/merged):
- support for HDR modes (has been removed because of lack of real users)
- no support for multi-master and the associated concepts (mastership handover, support for secondary masters, ...)
- I2C devices can only be described using DT because this is the only use case I have. However, the framework can easily be extended with ACPI and board info support
- I3C slave framework. This has been completely omitted, but shouldn't have a huge impact on the I3C framework because I3C slaves don't see the whole bus, it's only about handling master requests and generating IBIs. Some of the struct, constant and enum definitions could be shared, but most of the I3C slave framework logic will be different
Note that this patchset is available on the linux-i3c repo[1].
Main change between v7 and v8:
- The bus object is now embedded in the master_controller object (as suggested by Arnd)
Main changes between v6 and v7:
- I3C bus/master representations have been reworked to match what other subsystems are doing (master implicitly represented by the bus object)
- I3C dev registration has been fixed
- I3C bus mode selection has been fixed
- Calls to readsl/writesl() in the Cadence I3C master driver have been fixed
Main changes between v5 and v6:
- Introduce {i3c,i2c}_dev_desc structures to better match how I3C master controllers (reservation of one HW slot for each device attached to the bus). With this solution, the resource migration that happens when a device lose its dynamic address and is re-assigned a different address is simplified on the driver side, because most of it is now handled in the core (reserve a new dev slot, reserve IBI resources and free all resources attached to the old slot)
- Add I3C error codes (M0 to M2) so that the core and device drivers can have fine grained information on what caused an EIO error.
Only minor things happened between v3 and v5 (you can go check the changelog in each patch for more details).
Main changes between v2 and v3 are:
- Reworked the DT bindings as suggested by Rob
- Reworked the bus initialization step as suggested by Vitor
- Added a driver for an I3C GPIO expander
Main changes between the initial RFC and this v2 are:
- Add a generic infrastructure to support IBIs. It's worth mentioning that I tried exposing IBIs as a regular IRQs, but after several attempts and a discussion with Mark Zyngier, it appeared that it was not really fitting in the Linux IRQ model (the fact that you have payload attached to IBIs, the fact that most of the time an IBI will generate a transfer on the bus which has to be done in an atomic context, ...)
The counterpart of this decision is the latency induced by the workqueue approach, but since I don't have real use cases, I don't know if this can be a problem or not.
- Add helpers to support Hot Join
- Add support for IBIs and Hot Join in Cadence I3C master driver
- Address several issues in how I was using the device model
Thanks,
Boris
[1]https://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git/log/?h=i3c/next
Boris Brezillon (10):
i3c: Add core I3C infrastructure
docs: driver-api: Add I3C documentation
i3c: Add sysfs ABI spec
dt-bindings: i3c: Document core bindings
dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg
property
MAINTAINERS: Add myself as the I3C subsystem maintainer
i3c: master: Add driver for Cadence IP
dt-bindings: i3c: Document Cadence I3C master bindings
gpio: Add a driver for Cadence I3C GPIO expander
dt-bindings: gpio: Add bindings for Cadence I3C gpio expander
Documentation/ABI/testing/sysfs-bus-i3c | 146 ++ .../devicetree/bindings/gpio/gpio-cdns-i3c.txt | 39 + .../devicetree/bindings/i3c/cdns,i3c-master.txt | 44 + Documentation/devicetree/bindings/i3c/i3c.txt | 140 ++ Documentation/driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 + Documentation/driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 ++ Documentation/driver-api/index.rst | 1 + MAINTAINERS | 12 + drivers/Kconfig | 2 + drivers/Makefile | 2 +- drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cdns-i3c.c | 411 +++ drivers/i3c/Kconfig | 24 + drivers/i3c/Makefile | 4 + drivers/i3c/device.c | 233 ++ drivers/i3c/internals.h | 26 + drivers/i3c/master.c | 2644 ++++++++++++++++++++ drivers/i3c/master/Kconfig | 6 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1670 +++++++++++++ include/dt-bindings/i3c/i3c.h | 28 + include/linux/i3c/ccc.h | 385 +++ include/linux/i3c/device.h | 331 +++ include/linux/i3c/master.h | 643 +++++ include/linux/mod_devicetable.h | 17 + 28 files changed, 7053 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-i3c create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt create mode 100644 Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt create mode 100644 Documentation/driver-api/i3c/device-driver-api.rst create mode 100644 Documentation/driver-api/i3c/index.rst create mode 100644 Documentation/driver-api/i3c/master-driver-api.rst create mode 100644 Documentation/driver-api/i3c/protocol.rst create mode 100644 drivers/gpio/gpio-cdns-i3c.c create mode 100644 drivers/i3c/Kconfig create mode 100644 drivers/i3c/Makefile create mode 100644 drivers/i3c/device.c create mode 100644 drivers/i3c/internals.h create mode 100644 drivers/i3c/master.c create mode 100644 drivers/i3c/master/Kconfig create mode 100644 drivers/i3c/master/Makefile create mode 100644 drivers/i3c/master/i3c-master-cdns.c create mode 100644 include/dt-bindings/i3c/i3c.h create mode 100644 include/linux/i3c/ccc.h create mode 100644 include/linux/i3c/device.h create mode 100644 include/linux/i3c/master.h
Signature · 1 line
2.14.1
PATCH v8 1/10 i3c: Add core I3C infrastructure
Add core infrastructure to support I3C in Linux and document it.
This infrastructure adds basic I3C support. Advanced features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is not set in stone, and if anyone needs async support, new functions can be added later on.
- the bus element is a separate object, but it's tightly coupled with the master object. We thus have a 1:1 relationship between i3c_bus and i3c_master_controller objects, and if 2 master controllers are connected to the same bus and both exposed to the same Linux instance they will appear as two distinct busses, and devices on this bus will be exposed twice.
- I2C backward compatibility has been designed to be transparent to I2C drivers and the I2C subsystem. The I3C master just registers an I2C adapter which creates a new I2C bus. I'd say that, from a representation PoV it's not ideal because what should appear as a single I3C bus exposing I3C and I2C devices here appears as 2 different buses connected to each other through the parenting (the I3C master is the parent of the I2C and I3C busses).
On the other hand, I don't see a better solution if we want something that is not invasive.
Missing features:
- I3C HDR modes are not supported
- no support for multi-master and the associated concepts (mastership handover, support for secondary masters, ...)
- I2C devices can only be described using DT because this is the only use case I have. However, the framework can easily be extended with ACPI and board info support
- I3C slave framework. This has been completely omitted, but shouldn't have a huge impact on the I3C framework because I3C slaves don't see the whole bus, it's only about handling master requests and generating IBIs. Some of the struct, constant and enum definitions could be shared, but most of the I3C slave framework logic will be different
---
Changes in v8:
- Embed the i3c_bus object directly in the i3c_master_controller one (suggested by Arnd)
- Move core.c into master.c (suggested by Arnd)
- Replace bool by unsigned int (or u8) in structures (suggested by checkpatch)
Changes in v7:
- Stop representing the I3C master as a device under the I3C bus
- Enforce a 1:1 relationship between i3c_bus and i3c_master_controller objects
- Fix I3C bus mode selection when I2C devices are described in the DT.
- Fix I3C device registration
Changes in v6:
- Add I3C/I2C dev descriptors to simplify I3C driver controllers when migrating resources from on I3C device slot to anoter
- Add I3C error codes and return them when doing SDR/priv and CCC transfers. This allows us to properly detect when no devices acked a CCC command, which in some cases is a valid situation (no I3C devices on the bus)
- Remove __packed specifiers where unneeded
- Allocate all IBI slots in one call using kcalloc()
Changes in v5:
- Rename the address sysfs entry into dynamic_address to clarify things
- Document that we expect buffers passed to i3c_device_do_priv_xfers() to be DMA-able
- Fix DEFSLVS CCC command
- s/2017/2018/ in copyright headers
- Fix SPDX header in internals.h
- Fix coding style issues
Changes in v4:
- none
Changes in v3:
- Fix locking issues
- Explicitly include a bunch of headers (reported by Randy Dunlap)
- Rename {i2c,i3c}-scl-frequency DT prop into {i2c,i3c}-scl-hz
- Do not use BIT() macro in mod_devicetable.h
- Fix typos
- Fix/enhance some kernel doc headers
- Rework the bus initialization code to simplify master drivers
- Assign dynamic address with SETDASA if the device has a static address and the DT has a valid assigned-address property
- Rework the LVR extraction in DT parsing code
- Add code to detect when a device is re-attached to the bus after losing its dynamic address. In this case we know try to re-assign the old address, and most importantly, the I3C device driver sees the same device instance, not a new one
- Add an ->i2c_funcs() hook to let the master declare which I2C features it supports
- Unexport a few functions
- Remove support for HDR mode since we have no real user yet
Changes in v2:
- Fix a bunch of mistake I made with the device model (pointed by GKH)
- Move the documentation out of this commit (pointed by GKH)
- only source drivers/i3c/master/Kconfig when CONFIG_I3C is enabled (pointed by GKH)
- Add IBI infrastructure
- Add helpers to ease support for Hot Join (most of the logic is delegated to I3C controller drivers)
- move the doc out of this commit to improve readability
- Fix a few bugs in device probing/remove (detected after trying to load/unload modules in various orders)
- Add a module_i3c_i2c_driver() macro to ease integration of drivers for devices that support both I3C and I2C mode
--- drivers/Kconfig | 2 + drivers/Makefile | 2 +- drivers/i3c/Kconfig | 24 + drivers/i3c/Makefile | 4 + drivers/i3c/device.c | 233 ++++ drivers/i3c/internals.h | 26 + drivers/i3c/master.c | 2644 +++++++++++++++++++++++++++++++++++++++ drivers/i3c/master/Kconfig | 0 drivers/i3c/master/Makefile | 0 include/linux/i3c/ccc.h | 385 ++++++ include/linux/i3c/device.h | 331 +++++ include/linux/i3c/master.h | 643 ++++++++++ include/linux/mod_devicetable.h | 17 + 13 files changed, 4310 insertions(+), 1 deletion(-) create mode 100644 drivers/i3c/Kconfig create mode 100644 drivers/i3c/Makefile create mode 100644 drivers/i3c/device.c create mode 100644 drivers/i3c/internals.h create mode 100644 drivers/i3c/master.c create mode 100644 drivers/i3c/master/Kconfig create mode 100644 drivers/i3c/master/Makefile create mode 100644 include/linux/i3c/ccc.h create mode 100644 include/linux/i3c/device.h create mode 100644 include/linux/i3c/master.h
drivers/Kconfig +2 -0
@@ -57,6 +57,8 @@ source "drivers/char/Kconfig" source "drivers/i2c/Kconfig" +source "drivers/i3c/Kconfig" + source "drivers/spi/Kconfig" source "drivers/spmi/Kconfig"
drivers/Makefile +1 -1
@@ -111,7 +111,7 @@ obj-$(CONFIG_SERIO) += input/serio/ obj-$(CONFIG_GAMEPORT) += input/gameport/ obj-$(CONFIG_INPUT) += input/ obj-$(CONFIG_RTC_LIB) += rtc/ -obj-y += i2c/ media/ +obj-y += i2c/ i3c/ media/ obj-$(CONFIG_PPS) += pps/ obj-y += ptp/ obj-$(CONFIG_W1) += w1/
drivers/i3c/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 + +menuconfig I3C + tristate "I3C support" + select I2C + help + I3C is a serial protocol standardized by the MIPI alliance. + + It's supposed to be backward compatible with I2C while providing + support for high speed transfers and native interrupt support + without the need for extra pins. + + The I3C protocol also standardizes the slave device types and is + mainly designed to communicate with sensors. + + If you want I3C support, you should say Y here and also to the + specific driver for your bus adapter(s) below. + + This I3C support can also be built as a module. If so, the module + will be called i3c. + +if I3C +source "drivers/i3c/master/Kconfig" +endif # I3C
drivers/i3c/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +i3c-y := device.o master.o +obj-$(CONFIG_I3C) += i3c.o +obj-$(CONFIG_I3C) += master/
drivers/i3c/device.c new file +233 -0
233 lines not on this page · raw message
drivers/i3c/internals.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018 Cadence Design Systems Inc. +* +* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef I3C_INTERNALS_H +#define I3C_INTERNALS_H + +#include <linux/i3c/master.h> + +extern struct bus_type i3c_bus_type; + +void i3c_bus_normaluse_lock (struct i3c_bus *bus); +void i3c_bus_normaluse_unlock (struct i3c_bus *bus); + +int i3c_dev_do_priv_xfers_locked (struct i3c_dev_desc *dev, +struct i3c_priv_xfer *xfers, +int nxfers); +int i3c_dev_disable_ibi_locked (struct i3c_dev_desc *dev); +int i3c_dev_enable_ibi_locked (struct i3c_dev_desc *dev); +int i3c_dev_request_ibi_locked (struct i3c_dev_desc *dev, +const struct i3c_ibi_setup *req); +void i3c_dev_free_ibi_locked (struct i3c_dev_desc *dev); +#endif /* I3C_INTERNAL_H */
drivers/i3c/master.c new file +2644 -0
2,644 lines not on this page · raw message
drivers/i3c/master/Kconfig new file +0 -0
drivers/i3c/master/Makefile new file +0 -0
include/linux/i3c/ccc.h new file +385 -0
53 lines not on this page · raw message
include/linux/i3c/device.h new file +331 -0
331 lines not on this page · raw message
include/linux/i3c/master.h new file +643 -0
643 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.14.1
Part of the diff is not shown here. View the raw message.
PATCH v8 2/10 docs: driver-api: Add I3C documentation
In reply to Boris BrezillonAdd the I3C documentation describing the protocol, the master driver API and the device driver API.
---
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- Fix typos reported by Randy
- Add Randy's R-b
Changes in v5:
- Remove useless conf.py file
- Add SPDX headers
Changes in v2:
- Moved out of patch "i3c: Add core I3C infrastructure"
- Add link to the I3C spec
- Move rst files in Documentation/driver-api/i3c/
--- Documentation/driver-api/i3c/device-driver-api.rst | 9 + Documentation/driver-api/i3c/index.rst | 11 ++ Documentation/driver-api/i3c/master-driver-api.rst | 10 + Documentation/driver-api/i3c/protocol.rst | 203 +++++++++++++++++++++ Documentation/driver-api/index.rst | 1 + 5 files changed, 234 insertions(+) create mode 100644 Documentation/driver-api/i3c/device-driver-api.rst create mode 100644 Documentation/driver-api/i3c/index.rst create mode 100644 Documentation/driver-api/i3c/master-driver-api.rst create mode 100644 Documentation/driver-api/i3c/protocol.rst
Documentation/driver-api/i3c/device-driver-api.rst new file +9 -0
@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================== +I3C device driver API +===================== + +.. kernel-doc:: include/linux/i3c/device.h + +.. kernel-doc:: drivers/i3c/device.c
Documentation/driver-api/i3c/index.rst new file +11 -0
@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============= +I3C subsystem +============= + +.. toctree:: + + protocol + device-driver-api + master-driver-api
Documentation/driver-api/i3c/master-driver-api.rst new file +10 -0
@@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================ +I3C master controller driver API +================================ + +.. kernel-doc:: drivers/i3c/master.c + +.. kernel-doc:: include/linux/i3c/master.h +
Documentation/driver-api/i3c/protocol.rst new file +203 -0
203 lines not on this page · raw message
Documentation/driver-api/index.rst +1 -0
@@ -32,6 +32,7 @@ available subsections can be seen below. pci spi i2c + i3c/index hsi edac scsi
Signature · 1 line
2.14.1
PATCH v8 3/10 i3c: Add sysfs ABI spec
In reply to Boris BrezillonDocument sysfs files/directories/symlinks exposed by the I3C subsystem.
---
Changes in v8:
- None
Changes in v7:
- Bump KernelVersion to 4.20
- Add new entries under i3c-<bus-id> now that the master controller is no longer represented as a device under this directory but implicitly represented by the bus object
Changes in v6:
- none
Changes in v5:
- Fix the kernel version
- Rename address into dynamic_address to match changes done in the code
Changes in v4:
- none
Changes in v3:
- none
Changes in v2:
- new patch
--- Documentation/ABI/testing/sysfs-bus-i3c | 146 ++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i3c
Documentation/ABI/testing/sysfs-bus-i3c new file +146 -0
@@ -0,0 +1,146 @@ +What: /sys/bus/i3c/devices/i3c-<bus-id> +KernelVersion: 4.20 +Contact: [email protected] +Description: + An I3C bus. This directory will contain one sub-directory per + I3C device present on the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/current_master +KernelVersion: 4.20 +Contact: [email protected] +Description: + Expose the master that owns the bus (<bus-id>-<master-pid>) at + the time this file is read. Note that bus ownership can change + overtime, so there's no guarantee that when the read() call + returns, the value returned is still valid. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/mode +KernelVersion: 4.20 +Contact: [email protected] +Description: + I3C bus mode. Can be "pure", "mixed-fast" or "mixed-slow". See + the I3C specification for a detailed description of what each + of these modes implies. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/i3c_scl_frequency +KernelVersion: 4.20 +Contact: [email protected] +Description: + The frequency (expressed in Hz) of the SCL signal when + operating in I3C SDR mode. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/i2c_scl_frequency +KernelVersion: 4.20 +Contact: [email protected] +Description: + The frequency (expressed in Hz) of the SCL signal when + operating in I2C mode. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/dynamic_address +KernelVersion: 4.20 +Contact: [email protected] +Description: + Dynamic address assigned to the master controller. This + address may change if the bus is re-initialized. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/bcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + BCR stands for Bus Characteristics Register and express the + device capabilities in term of speed, maximum read/write + length, etc. See the I3C specification for more details. + This entry describes the BCR of the master controller driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/dcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + DCR stands for Device Characteristics Register and express the + device capabilities in term of exposed features. See the I3C + specification for more details. + This entry describes the DCR of the master controller driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/pid +KernelVersion: 4.20 +Contact: [email protected] +Description: + PID stands for Provisional ID and is used to uniquely identify + a device on a bus. This PID contains information about the + vendor, the part and an instance ID so that several devices of + the same type can be connected on the same bus. + See the I3C specification for more details. + This entry describes the PID of the master controller driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/hdrcap +KernelVersion: 4.20 +Contact: [email protected] +Description: + Expose the HDR (High Data Rate) capabilities of a device. + Returns a list of supported HDR mode, each element is separated + by space. Modes can be "hdr-ddr", "hdr-tsp" and "hdr-tsl". + See the I3C specification for more details about these HDR + modes. + This entry describes the HDRCAP of the master controller + driving the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid> +KernelVersion: 4.20 +Contact: [email protected] +Description: + An I3C device present on I3C bus identified by <bus-id>. Note + that all devices are represented including the master driving + the bus. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dynamic_address +KernelVersion: 4.20 +Contact: [email protected] +Description: + Dynamic address assigned to device <bus-id>-<device-pid>. This + address may change if the bus is re-initialized. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/bcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + BCR stands for Bus Characteristics Register and express the + device capabilities in term of speed, maximum read/write + length, etc. See the I3C specification for more details. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dcr +KernelVersion: 4.20 +Contact: [email protected] +Description: + DCR stands for Device Characteristics Register and express the + device capabilities in term of exposed features. See the I3C + specification for more details. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/pid +KernelVersion: 4.20 +Contact: [email protected] +Description: + PID stands for Provisional ID and is used to uniquely identify + a device on a bus. This PID contains information about the + vendor, the part and an instance ID so that several devices of + the same type can be connected on the same bus. + See the I3C specification for more details. + +What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/hdrcap +KernelVersion: 4.20 +Contact: [email protected] +Description: + Expose the HDR (High Data Rate) capabilities of a device. + Returns a list of supported HDR mode, each element is separated + by space. Modes can be "hdr-ddr", "hdr-tsp" and "hdr-tsl". + See the I3C specification for more details about these HDR + modes. + +What: /sys/bus/i3c/devices/<bus-id>-<device-pid> +KernelVersion: 4.20 +Contact: [email protected] +Description: + These directories are just symbolic links to + /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>.
Signature · 1 line
2.14.1
PATCH v8 4/10 dt-bindings: i3c: Document core bindings
In reply to Boris BrezillonA new I3C subsystem has been added and a generic description has been created to represent the I3C bus and the devices connected on it.
Document this generic representation.
---
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Clarify the fact that static address == I3C address and dynamic address == I3C address
- Use i2c-scl-hz in the example
Changes in v3:
- Rename {i2c,i3c}-scl-frequency DT prop into {i2c,i3c}-scl-hz
- Rework the way we expose the provisional ID and LVR information
- Rename dynamic-address into assigned-address
- Enforce the I3C master node name
Changes in v2:
- Define how to describe I3C devices in the DT and when it should be used. Note that the parsing of I3C devices is not yet implemented in the framework. Will be added when someone really needs it.
--- Documentation/devicetree/bindings/i3c/i3c.txt | 140 ++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/i3c.txt
Documentation/devicetree/bindings/i3c/i3c.txt new file +140 -0
@@ -0,0 +1,140 @@ +Generic device tree bindings for I3C busses +=========================================== + +This document describes generic bindings that should be used to describe I3C +busses in a device tree. + +Required properties +------------------- + +- #address-cells - should be <3>. Read more about addresses below. +- #size-cells - should be <0>. +- compatible - name of the I3C master controller driving the I3C bus + +For other required properties e.g. to describe register sets, +clocks, etc. check the binding documentation of the specific driver. +The node describing an I3C bus should be named i3c-master. + +Optional properties +------------------- + +These properties may not be supported by all I3C master drivers. Each I3C +master bindings should specify which of them are supported. + +- i3c-scl-hz: frequency of the SCL signal used for I3C transfers. + When undefined the core sets it to 12.5MHz. + +- i2c-scl-hz: frequency of the SCL signal used for I2C transfers. + When undefined, the core looks at LVR (Legacy Virtual Register) + values of I2C devices described in the device tree to determine + the maximum I2C frequency. + +I2C devices +=========== + +Each I2C device connected to the bus should be described in a subnode. All +properties described in Documentation/devicetree/bindings/i2c/i2c.txt are +valid here, but several new properties have been added. + +New constraint on existing properties: +-------------------------------------- +- reg: contains 3 cells + + first cell : still encoding the I2C address + + + second cell: should have bit 31 set to 1 to signify that this is an I2C + device. Bits 0 to 7 encode the I3C LVR (Legacy Virtual + Register): + + bit[7:5]: I2C device index. Possible values + * 0: I2C device has a 50 ns spike filter + * 1: I2C device does not have a 50 ns spike filter but supports high + frequency on SCL + * 2: I2C device does not have a 50 ns spike filter and is not tolerant + to high frequencies + * 3-7: reserved + + bit[4]: tell whether the device operates in FM (Fast Mode) or FM+ mode + * 0: FM+ mode + * 1: FM mode + + bit[3:0]: device type + * 0-15: reserved + + + third cell: should be 0 + +I3C devices +=========== + +All I3C devices are supposed to support DAA (Dynamic Address Assignment), and +are thus discoverable. So, by default, I3C devices do not have to be described +in the device tree. +This being said, one might want to attach extra resources to these devices, +and those resources may have to be described in the device tree, which in turn +means we have to describe I3C devices. + +Another use case for describing an I3C device in the device tree is when this +I3C device has a static I2C address and we want to assign it a specific I3C +dynamic address before the DAA takes place (so that other devices on the bus +can't take this dynamic address). + +The I3C device should be names <device-type>@<static-i2c-address>,<i3c-pid>, +where device-type is describing the type of device connected on the bus +(gpio-controller, sensor, ...). + +Required properties +------------------- +- reg: contains 3 cells + + first cell : encodes the static I2C address. Should be 0 if the device does + not have one (0 is not a valid I2C address). + + + second and third cells: should encode the ProvisionalID. The second cell + contains the manufacturer ID left-shifted by 1. + The third cell contains ORing of the part ID + left-shifted by 16, the instance ID left-shifted + by 12 and the extra information. This encoding is + following the PID definition provided by the I3C + specification. + +Optional properties +------------------- +- assigned-address: dynamic address to be assigned to this device. This + property is only valid if the I3C device has a static + address (first cell of the reg property != 0). + + +Example: + + i3c-master@d040000 { + compatible = "cdns,i3c-master"; + clocks = <&coreclock>, <&i3csysclock>; + clock-names = "pclk", "sysclk"; + interrupts = <3 0>; + reg = <0x0d040000 0x1000>; + #address-cells = <3>; + #size-cells = <0>; + + status = "okay"; + i2c-scl-hz = <100000>; + + /* I2C device. */ + nunchuk: nunchuk@52 { + compatible = "nintendo,nunchuk"; + reg = <0x52 0x80000010 0x0>; + }; + + /* I3C device with a static I2C address. */ + thermal_sensor: sensor@68,39200144004 { + reg = <0x68 0x392 0x144004>; + assigned-address = <0xa>; + }; + + /* + * I3C device without a static I2C address but requiring + * resources described in the DT. + */ + sensor@0,39200154004 { + reg = <0x0 0x392 0x154004>; + clocks = <&clock_provider 0>; + }; + }; +
Signature · 1 line
2.14.1
PATCH v8 5/10 dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
In reply to Boris BrezillonThe reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
---
Changes in v8:
- None
Changes in v5:
- none
--- include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/dt-bindings/i3c/i3c.h
include/dt-bindings/i3c/i3c.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2017 Cadence Design Systems Inc. +* +* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef _DT_BINDINGS_I3C_I3C_H +#define _DT_BINDINGS_I3C_I3C_H + +#define IS_I2C_DEV 0x80000000 + +#define I2C_DEV (addr, lvr) \ + (addr) (IS_I2C_DEV | (lvr)) 0x0 + +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo)) + +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo) + +#endif
Signature · 1 line
2.14.1
PATCH v8 6/10 MAINTAINERS: Add myself as the I3C subsystem maintainer
In reply to Boris BrezillonCreate an entry for the I3C subsystem and mark it as maintained by me. There's no official git repository, patchwork instance, mailing list or website yet, but this will be added after the subsystem has been accepted.
---
Changes in v8:
- None
Changes in v7:
- Add a ML (not created yet) and a git repo
Changes in v5:
- Add the sysfs ABI file
--- MAINTAINERS | 12 ++++++++++++ 1 file changed, 12 insertions(+)
MAINTAINERS +12 -0
@@ -6921,6 +6921,18 @@ L: [email protected] S: Maintained F: drivers/i2c/i2c-stub.c +I3C SUBSYSTEM +M: Boris Brezillon <[email protected]> +L: [email protected] +T: git git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux.git +S: Maintained +F: Documentation/ABI/testing/sysfs-bus-i3c +F: Documentation/devicetree/bindings/i3c/ +F: Documentation/driver-api/i3c +F: drivers/i3c/ +F: include/linux/i3c/ +F: include/dt-bindings/i3c/ + IA64 (Itanium) PLATFORM M: Tony Luck <[email protected]> M: Fenghua Yu <[email protected]>
Signature · 1 line
2.14.1
PATCH v8 7/10 i3c: master: Add driver for Cadence IP
In reply to Boris BrezillonAdd a driver for Cadence I3C master IP.
---
Changes in v8:
- Adjust code to match changes done in the core (bus embedded in master)
Changes in v7:
- Fix readsl/writesl() usage
- Add a depends on ARM || ARM64 || XTENSA to forbid selection of this driver on platforms that are not implementing readsl/writesl
Changes in v6:
- Rework the attach/detach logic to match the new way of doing things.
- Use kcalloc() where appropriate
- Simplfy access to the RX/TX/IBI_DATA FIFOs
Changes in v5:
- Drop unused len var in cdns_i3c_master_handle_ibi()
- Get IBIR and CMDR depth from CONF_STATUS0
- s/2017/2018/ in copyright header
- Fix coding style issues
Changes in v4:
- Fix potential unsigned integer underflow
- Add missing static specific on IBI related functions
Changes in v3:
- Adjust to match I3C framework changes
- Implement support the CMD RESPONSE QUEUE and IBI QUEUE added in the latest revision of Cadence master IP
- Remove support for HDR modes
Changes in v2:
- Add basic IBI support. Note that the IP is not really reliable with regards to IBI because you can't extract IBI payloads as soon as you have more than one IBI waiting in the HW queue. This is something that will hopefully be addressed in future revisions of this IP
- Add a simple xfer queueing mechanism to optimize message queuing.
- Fix a few bugs
- Add support for Hot Join
--- drivers/i3c/master/Kconfig | 6 + drivers/i3c/master/Makefile | 1 + drivers/i3c/master/i3c-master-cdns.c | 1670 ++++++++++++++++++++++++++++++++++ 3 files changed, 1677 insertions(+) create mode 100644 drivers/i3c/master/i3c-master-cdns.c
drivers/i3c/master/Kconfig +6 -0
@@ -0,0 +1,6 @@ +config CDNS_I3C_MASTER + tristate "Cadence I3C master driver" + depends on I3C + depends on ARM || ARM64 || XTENSA + help + Enable this driver if you want to support Cadence I3C master block.
drivers/i3c/master/Makefile +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_CDNS_I3C_MASTER) += i3c-master-cdns.o
drivers/i3c/master/i3c-master-cdns.c new file +1670 -0
1,670 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v8 8/10 dt-bindings: i3c: Document Cadence I3C master bindings
In reply to Boris BrezillonDocument Cadence I3C master DT bindings.
---
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Fix example to match the new representation
--- .../devicetree/bindings/i3c/cdns,i3c-master.txt | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt
Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt new file +44 -0
@@ -0,0 +1,44 @@ +Bindings for cadence I3C master block +===================================== + +Required properties: +-------------------- +- compatible: shall be "cdns,i3c-master" +- clocks: shall reference the pclk and sysclk +- clock-names: shall contain "pclk" and "sysclk" +- interrupts: the interrupt line connected to this I3C master +- reg: I3C master registers + +Mandatory properties defined by the generic binding (see +Documentation/devicetree/bindings/i3c/i3c.txt for more details): + +- #address-cells: shall be set to 1 +- #size-cells: shall be set to 0 + +Optional properties defined by the generic binding (see +Documentation/devicetree/bindings/i3c/i3c.txt for more details): + +- i2c-scl-hz +- i3c-scl-hz + +I3C device connected on the bus follow the generic description (see +Documentation/devicetree/bindings/i3c/i3c.txt for more details). + +Example: + + i3c-master@0d040000 { + compatible = "cdns,i3c-master"; + clocks = <&coreclock>, <&i3csysclock>; + clock-names = "pclk", "sysclk"; + interrupts = <3 0>; + reg = <0x0d040000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + i2c-scl-hz = <100000>; + + nunchuk: nunchuk@52 { + compatible = "nintendo,nunchuk"; + reg = <0x52 0x80000010 0>; + }; + }; +
Signature · 1 line
2.14.1
PATCH v8 9/10 gpio: Add a driver for Cadence I3C GPIO expander
In reply to Boris BrezillonAdd a driver for Cadence I3C GPIO expander.
---
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- Use kmalloc_array() instead of kmalloc(N * sizeof(X))
- Add Linus' ack
Changes in v5:
- Use the !! operator to return 0 or 1 in cdns_i3c_gpio_get_direction()
- Use a scratch buffer to make sure the buffers passed to i3c_device_do_priv_xfers() are DMA-able
- Fix errors reported by checkpatch
Changes in v4:
- none
Changes in v3:
- new
--- drivers/gpio/Kconfig | 11 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cdns-i3c.c | 411 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 423 insertions(+) create mode 100644 drivers/gpio/gpio-cdns-i3c.c
drivers/gpio/Kconfig +11 -0
@@ -908,6 +908,17 @@ config GPIO_TS4900 endmenu +menu "I3C GPIO expanders" + depends on I3C + +config GPIO_CDNS_I3C + tristate "Cadence I3C GPIO expander" + select GPIOLIB_IRQCHIP + help + Say yes here to enabled the driver for Cadence I3C GPIO expander. + +endmenu + menu "MFD GPIO expanders" config GPIO_ADP5520
drivers/gpio/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o +obj-$(CONFIG_GPIO_CDNS_I3C) += gpio-cdns-i3c.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o
drivers/gpio/gpio-cdns-i3c.c new file +411 -0
411 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v8 10/10 dt-bindings: gpio: Add bindings for Cadence I3C gpio expander
In reply to Boris BrezillonDocument the Cadence I3C gpio expander bindings.
---
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- Add Rob's R-b
Changes in v4:
- Use GPIO_ and IRQ_TYPE_ macros instead of raw numbers
- Fix the unit-address in the example
--- .../devicetree/bindings/gpio/gpio-cdns-i3c.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt
Documentation/devicetree/bindings/gpio/gpio-cdns-i3c.txt new file +39 -0
@@ -0,0 +1,39 @@ +* Cadence I3C GPIO expander + +The Cadence I3C GPIO expander provides 8 GPIOs controllable over I3C. +This GPIOs can be configured in output or input mode and if they are in input +mode they can generate IBIs (In Band Interrupts). + +Required properties for GPIO node: +- reg : 3 cells encoding the I3C static address (none in our case) and the I3C + Provisional ID. See Documentation/devicetree/bindings/i3c/i3c.txt for + more details. + Should be <0x0 0x392 0x0>. +- gpio-controller : Marks the device node as a gpio controller. +- #gpio-cells : Should be two. The first cell is the pin number and + the second cell is used to specify the gpio polarity (GPIO_ACTIVE_HIGH or + GPIO_ACTIVE_LOW) +- interrupt-controller: Marks the device node as an interrupt controller. +- #interrupt-cells : Should be 2. The first cell is the GPIO number. + The second cell is used to specify trigger type and level flags. + The following trigger types are accepted (see + <dt-bindings/interrupt-controller/irq.h> for their definition): + IRQ_TYPE_EDGE_RISING + IRQ_TYPE_EDGE_FALLING + IRQ_TYPE_EDGE_BOTH + IRQ_TYPE_LEVEL_HIGH + IRQ_TYPE_LEVEL_LOW + +Example: + + i3c-master@xxx { + ... + i3c_gpio_expander: gpio@0,39200000000 { + reg = <0 0x392 0x0>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; + ... + };
Signature · 1 line
2.14.1
Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
In reply to Boris BrezillonQuoted 3 lines · Boris Brezillon
The reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
This patch logic seems excessively fragile.
Quoted 23 lines
Signed-off-by Boris Brezillon <[email protected]>Reviewed-by Rob Herring <[email protected]>---
Changes in v8:
- NoneChanges in v5:
- none--- include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/dt-bindings/i3c/i3c.hinclude/dt-bindings/i3c/i3c.h new file +4
-0@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2017 Cadence Design Systems Inc. +*
include/dt-bindings/i3c/i3c.h line 14
Quoted 10 lines
include/dt-bindings/i3c/i3c.h new file +10
-0+* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef _DT_BINDINGS_I3C_I3C_H +#define _DT_BINDINGS_I3C_I3C_H + +#define IS_I2C_DEV 0x80000000 + +#define I2C_DEV (addr, lvr) \ + (addr) (IS_I2C_DEV | (lvr)) 0x0
This looks to be missing surrounding parentheses.
include/dt-bindings/i3c/i3c.h line 18
Quoted 4 lines
include/dt-bindings/i3c/i3c.h new file +4
-0+ +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo))
This macro doesn't make any sense. Missing a shift and an or?
Quoted 10 lines
include/dt-bindings/i3c/i3c.h new file +10
-0+ +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo) + +#endif
Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
Hi Joe,
Quoted 10 lines · Joe Perches
Quoted 3 lines · Boris Brezillon
The reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
This patch logic seems excessively fragile.
Quoted 2 lines
include/dt-bindings/i3c/i3c.h new file +0
-0
Quoted 6 lines
include/dt-bindings/i3c/i3c.h line 18
Quoted 4 lines
include/dt-bindings/i3c/i3c.h new file +4
-0+ +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo))This macro doesn't make any sense. Missing a shift and an or?
No, it generates two of the three cells.
Quoted 8 lines
include/dt-bindings/i3c/i3c.h line 26
Quoted 8 lines
include/dt-bindings/i3c/i3c.h new file +8
-0+ +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo)
And the above two macros generate all three cells.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
In reply to Joe PerchesQuoted 6 lines · On Wed, 03 Oct 2018 11:37:17 -0700 Joe Perches <[email protected]> wrote:
Quoted 3 lines · Boris Brezillon
The reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
This patch logic seems excessively fragile.
Keep in mind that this header is meant to be include by .dts(i) files, not regular .c files.
Quoted 28 lines
Quoted 28 lines
Signed-off-by Boris Brezillon <[email protected]>Reviewed-by Rob Herring <[email protected]>---
Changes in v8:
- NoneChanges in v5:
- none--- include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/dt-bindings/i3c/i3c.hinclude/dt-bindings/i3c/i3c.h new file +8
-0@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2017 Cadence Design Systems Inc. +* +* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef _DT_BINDINGS_I3C_I3C_H
Quoted 8 lines
include/dt-bindings/i3c/i3c.h line 14
Quoted 6 lines
include/dt-bindings/i3c/i3c.h new file +6
-0+#define _DT_BINDINGS_I3C_I3C_H + +#define IS_I2C_DEV 0x80000000 + +#define I2C_DEV (addr, lvr) \ + (addr) (IS_I2C_DEV | (lvr)) 0x0This looks to be missing surrounding parentheses.
Actually it's not. The macro is supposed to declare 3 u32 integers each of them separated by a space:
reg = <I2C_DEV(0x34, 0x1)>;
is translated into
reg = <0x34 0x80000001 0x0>;
Quoted 7 lines
include/dt-bindings/i3c/i3c.h line 18
Quoted 5 lines
include/dt-bindings/i3c/i3c.h new file +4
-0+ +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo))This macro doesn't make any sense. Missing a shift and an or?
Same here, the PID is taking 2 32-bit entries.
Now, I agree that this is far from obvious, and if Rob is okay, I'd like to propose a different binding to avoid having to define these macros:
reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb>;
If pid_msb and pid_lsb are 0, then the node is defining an I2C device (AFAICT, 0 is not a valid PID), otherwise it's an I3C device. This way we get rid of the IS_I2C_DEV flag, and we can get rid of those macros without making I3C dev node definition too painful (the only part developers will have to get right is the PID)
Quoted 12 lines
Quoted 11 lines
include/dt-bindings/i3c/i3c.h new file +10
-0+ +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo) + +#endif
Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
In reply to Geert UytterhoevenQuoted 20 lines · Geert Uytterhoeven
Hi Joe,
Quoted 6 lines · Joe Perches
Quoted 3 lines · Boris Brezillon
The reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
This patch logic seems excessively fragile.
Quoted 8 lines
include/dt-bindings/i3c/i3c.h line 18
Quoted 6 lines
include/dt-bindings/i3c/i3c.h new file +4
-0+ +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo))This macro doesn't make any sense. Missing a shift and an or?
No, it generates two of the three cells.
Quoted 10 lines
Quoted 8 lines
include/dt-bindings/i3c/i3c.h line 26
Quoted 8 lines
include/dt-bindings/i3c/i3c.h new file +8
-0+ +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo)And the above two macros generate all three cells.
It seems none of the other include/dt-bindings/ .h files have unusual macros like these.
Perhaps this file should not have a .h extension but something be named like i3c_reg_property.macros
Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property
In reply to Boris BrezillonQuoted 69 lines · On Wed, 3 Oct 2018 20:59:53 +0200 Boris Brezillon…
Quoted 6 lines · On Wed, 03 Oct 2018 11:37:17 -0700 Joe Perches <[email protected]> wrote:
Quoted 3 lines · Boris Brezillon
The reg property of devices connected to an I3C bus have 3 cells, and filling them manually is not trivial. Provides macros to help doing that.
This patch logic seems excessively fragile.
Keep in mind that this header is meant to be include by .dts(i) files, not regular .c files.
Quoted 28 lines
Quoted 28 lines
Signed-off-by Boris Brezillon <[email protected]>Reviewed-by Rob Herring <[email protected]>---
Changes in v8:
- NoneChanges in v5:
- none--- include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/dt-bindings/i3c/i3c.hinclude/dt-bindings/i3c/i3c.h new file +8
-0@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2017 Cadence Design Systems Inc. +* +* Author: Boris Brezillon <[email protected]> +*/ + +#ifndef _DT_BINDINGS_I3C_I3C_HQuoted 8 lines
include/dt-bindings/i3c/i3c.h line 14
Quoted 6 lines
include/dt-bindings/i3c/i3c.h new file +6
-0+#define _DT_BINDINGS_I3C_I3C_H + +#define IS_I2C_DEV 0x80000000 + +#define I2C_DEV (addr, lvr) \ + (addr) (IS_I2C_DEV | (lvr)) 0x0This looks to be missing surrounding parentheses.
Actually it's not. The macro is supposed to declare 3 u32 integers each of them separated by a space:
reg = <I2C_DEV(0x34, 0x1)>;is translated into
reg = <0x34 0x80000001 0x0>;Quoted 7 lines
include/dt-bindings/i3c/i3c.h line 18
Quoted 5 lines
include/dt-bindings/i3c/i3c.h new file +4
-0+ +#define I3C_PID (manufid, partid, instid, extrainfo) \ + ((manufid) << 1) \ + (((partid) << 16) | ((instid) << 12) | (extrainfo))This macro doesn't make any sense. Missing a shift and an or?
Same here, the PID is taking 2 32-bit entries.
Quoted 7 lines
Now, I agree that this is far from obvious, and if Rob is okay, I'd like to propose a different binding to avoid having to define these macros:
reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb>;If
pid_msbandpid_lsbare 0, then the node is defining an I2C device
Actually, I meant pid_msb == 0. This part of the PID is encoding the manufacturer, and I don't think 0 is a valid manufacturer (I hope it's not). So, we'd have something like:
reg = <i2c_addr_or_i3c_static_addr pid_msb pid_lsb_or_i2c_lvr>;
Quoted 18 lines
(AFAICT, 0 is not a valid PID), otherwise it's an I3C device. This way we get rid of the
IS_I2C_DEVflag, and we can get rid of those macros without making I3C dev node definition too painful (the only part developers will have to get right is the PID)Quoted 12 lines
Quoted 11 lines
include/dt-bindings/i3c/i3c.h new file +10
-0+ +#define I3C_DEV_WITH_STATIC_ADDR (addr, manufid, partid, \ + instid, extrainfo) \ + (addr) I3C_PID(manufid, partid, instid, extrainfo) + +#define I3C_DEV (manufid, partid, instid, extrainfo) \ + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ + instid, extrainfo) + +#endif
Re: [PATCH v8 10/10] dt-bindings: gpio: Add bindings for Cadence I3C gpio expander
In reply to Boris BrezillonQuoted 7 lines · Boris Brezillon
Document the Cadence I3C gpio expander bindings.
Signed-off-by Boris Brezillon <[email protected]>Reviewed-by Rob Herring <[email protected]>---
Changes in v8:
- None
Yours,
Linus Walleij
Re: [PATCH v8 07/10] i3c: master: Add driver for Cadence IP
In reply to Boris BrezillonQuoted 10 lines · Boris Brezillon
Add a driver for Cadence I3C master IP.
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v7:
- Fix readsl/writesl() usage
- Add a depends on ARM || ARM64 || XTENSA to forbid selection of this driver on platforms that are not implementing readsl/writesl
Most architectures include asm-generic/io.h, which contains a generic implementation of readsl(). Maybe that #ifdef could be extended here? I remember discussing this with you not so long ago, which led to commit 0bbf47eab469 ("ia64: use asm-generic/io.h"). Do we have a list of architectures that don't include asm-generic/io.h? Maybe the 'depends on' could be for the set of architectures that fail here.
drivers/i3c/master/i3c-master-cdns.c line 440
Quoted 10 lines
drivers/i3c/master/i3c-master-cdns.c new file +10
-0+static void cdns_i3c_master_rd_from_rx_fifo (struct cdns_i3c_master *master, +u8 *bytes,int nbytes) +{ +readsl (master->regs +RX_FIFO , bytes, nbytes /4 ); +if (nbytes &3 ) { +u32 tmp =__raw_readl (master->regs +RX_FIFO ); + +memcpy (bytes + (nbytes & ~3 ), &tmp, nbytes &3 ); + } +}
The __raw_readl() is probably correct here (I can't think of any architecture on which it is not), but it still makes me feel uneasy about possible endianess or other issues.
Maybe make this:?
readsl(master->regs + RX_FIFO, &tmp, 1);
ArndRe: [PATCH v8 07/10] i3c: master: Add driver for Cadence IP
Quoted 13 lines · On Mon, 8 Oct 2018 12:06:30 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 10 lines · Boris Brezillon
Add a driver for Cadence I3C master IP.
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v7:
- Fix readsl/writesl() usage
- Add a depends on ARM || ARM64 || XTENSA to forbid selection of this driver on platforms that are not implementing readsl/writesl
Quoted 6 lines
Most architectures include
asm-generic/io.h, which contains a generic implementation ofreadsl(). Maybe that #ifdef could be extended here? I remember discussing this with you not so long ago, which led to commit0bbf47eab469("ia64: useasm-generic/io.h"). Do we have a list of architectures that don't includeasm-generic/io.h? Maybe the 'depends on' could be for the set of architectures that fail here.
Well, we started patching 2 archs (ia64 and sparc) based on kbuild robots failure report, and then I received other reports (still from kbuild robots) long after the initial ones. I can't tell for sure which archs are not implementing those functions, hence the conservative approach taken here.
Quoted 16 lines
drivers/i3c/master/i3c-master-cdns.c line 440
Quoted 11 lines
drivers/i3c/master/i3c-master-cdns.c new file +10
-0+static void cdns_i3c_master_rd_from_rx_fifo (struct cdns_i3c_master *master, +u8 *bytes,int nbytes) +{ +readsl (master->regs +RX_FIFO , bytes, nbytes /4 ); +if (nbytes &3 ) { +u32 tmp =__raw_readl (master->regs +RX_FIFO ); + +memcpy (bytes + (nbytes & ~3 ), &tmp, nbytes &3 ); + } +}The
__raw_readl()is probably correct here (I can't think of any architecture on which it is not), but it still makes me feel uneasy about possible endianess or other issues.
Quoted 3 lines
Maybe make this:?
readsl(master->regs + RX_FIFO, &tmp, 1);
I'm fine with that, assuming it does the same thing :-).
Re: [PATCH v8 07/10] i3c: master: Add driver for Cadence IP
Quoted 24 lines · Boris Brezillon
Quoted 13 lines · On Mon, 8 Oct 2018 12:06:30 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 10 lines · Boris Brezillon
Add a driver for Cadence I3C master IP.
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v7:
- Fix readsl/writesl() usage
- Add a depends on ARM || ARM64 || XTENSA to forbid selection of this driver on platforms that are not implementing readsl/writeslQuoted 6 lines
Most architectures include
asm-generic/io.h, which contains a generic implementation ofreadsl(). Maybe that #ifdef could be extended here? I remember discussing this with you not so long ago, which led to commit0bbf47eab469("ia64: useasm-generic/io.h"). Do we have a list of architectures that don't includeasm-generic/io.h? Maybe the 'depends on' could be for the set of architectures that fail here.
Quoted 5 lines
Well, we started patching 2 archs (ia64 and sparc) based on kbuild robots failure report, and then I received other reports (still from kbuild robots) long after the initial ones. I can't tell for sure which archs are not implementing those functions, hence the conservative approach taken here.
I think it's a fairly safe assumption that architectures which include asm-generic/io.h will be fine here. If one of them is broken, that can be fixed individually. Looking at the ones that don't include this file:
grep -L asm-generic/io.h arch/*/include/asm/io*.harch/alpha/include/asm/io.h # missing readslarch/hexagon/include/asm/io.h # has its own readslarch/mips/include/asm/io.h # missing readsl (but used from ide.h?)arch/parisc/include/asm/io.h # missing readslarch/powerpc/include/asm/io.h # has its own readslarch/sh/include/asm/io.h # has its own readslarch/sparc/include/asm/io.h # has its own readsl
Based on this, I would try what happens on mips, and make it depend on !(ALPHA || PARISC)
Another option is to just use ioread32_rep(), which should be available everywhere and has almost the same behavior as readsl(). The only difference is that on architectures like x86 it takes a few extra cycles to look at the address.
Arnd
Quoted 12 lines · Boris Brezillon
Sorry for the huge delay between v7 and v8 despite the small amount of things I was asked to fix/rework.
This patch series is adding a new subsystem to support I3C devices.
This is just adding support for basic features. Extra features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
Quoted 10 lines
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is still open to discussion. Please let me know if you think it's worth considering an asynchronous model here
- the I3C bus and I3C master controller are now tightly coupled even though they're still allocated separately. There's now a 1:1 relationship between these objects, and the I3C master is no longer represented under the I3C bus object.
Arnd, let me know if you had something different in mind, and I'll rework the implementation accordingly.
I looked at the entire series again and I'm rather happy with how it turned out. I've commented on a tiny issue about the readsl() that should be easy to resolve one way or another, with that you can add my
There is one additional issue that we've talked about previously and that I'd like to hear about from GregKH or maybe other subsystem maintainers: In the current version, you have a single 'bus_type' object, and this is used to represent both a 'host' and a 'device'. I think we concluded that this is done in other subsystems as well, and that this is fitting here because a host (master device) can hand over being a master to another device (slave), which then becomes the host and sees this one as a slave. Also a lot of the sysfs attributes are the same because of this relationship.
It also means that you get a mix of things in sysfs:
/sys/devices/i3c/<bus>
/sys/devices/i3c/<device>
/sys/devices/i3c/<bus>/<device>
which is a bit like what we have on USB where we can have hub devices that are again parents of other USB devices, but I don't think we can have i3c hubs or multiplexers in the same way, so it's only a single level.
I'm ok with this model after our previous discussion and couldn't come up with a better one. If anyone else still sees it as problematic and has a better idea, please let us know now.
Arnd
Re: [PATCH v8 07/10] i3c: master: Add driver for Cadence IP
In reply to Arnd BergmannQuoted 46 lines · On Mon, 8 Oct 2018 12:36:44 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 24 lines · Boris Brezillon
Quoted 13 lines · On Mon, 8 Oct 2018 12:06:30 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 10 lines · Boris Brezillon
Add a driver for Cadence I3C master IP.
Signed-off-by Boris Brezillon <[email protected]>---
Changes in v7:
- Fix readsl/writesl() usage
- Add a depends on ARM || ARM64 || XTENSA to forbid selection of this driver on platforms that are not implementing readsl/writeslQuoted 6 lines
Most architectures include
asm-generic/io.h, which contains a generic implementation ofreadsl(). Maybe that #ifdef could be extended here? I remember discussing this with you not so long ago, which led to commit0bbf47eab469("ia64: useasm-generic/io.h"). Do we have a list of architectures that don't includeasm-generic/io.h? Maybe the 'depends on' could be for the set of architectures that fail here.Quoted 5 lines
Well, we started patching 2 archs (ia64 and sparc) based on kbuild robots failure report, and then I received other reports (still from kbuild robots) long after the initial ones. I can't tell for sure which archs are not implementing those functions, hence the conservative approach taken here.
I think it's a fairly safe assumption that architectures which include
asm-generic/io.hwill be fine here. If one of them is broken, that can be fixed individually. Looking at the ones that don't include this file:grep -L
asm-generic/io.harch/*/include/asm/io*.harch/alpha/include/asm/io.h# missing readslarch/hexagon/include/asm/io.h# has its own readslarch/mips/include/asm/io.h# missing readsl (but used fromide.h?)arch/parisc/include/asm/io.h# missing readslarch/powerpc/include/asm/io.h# has its own readslarch/sh/include/asm/io.h# has its own readslarch/sparc/include/asm/io.h# has its own readsl
Quoted 2 lines
Based on this, I would try what happens on mips, and make it depend on !(ALPHA || PARISC)
Okay, I'll try with that.
Hi Greg,
Quoted 49 lines · On Mon, 8 Oct 2018 12:47:21 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 12 lines · Boris Brezillon
Sorry for the huge delay between v7 and v8 despite the small amount of things I was asked to fix/rework.
This patch series is adding a new subsystem to support I3C devices.
This is just adding support for basic features. Extra features will be added afterwards.
There are a few design choices that are worth mentioning because they impact the way I3C device drivers can interact with their devices:
Quoted 10 lines
- all functions used to send I3C/I2C frames must be called in non-atomic context. Mainly done this way to ease implementation, but this is still open to discussion. Please let me know if you think it's worth considering an asynchronous model here
- the I3C bus and I3C master controller are now tightly coupled even though they're still allocated separately. There's now a 1:1 relationship between these objects, and the I3C master is no longer represented under the I3C bus object.
Arnd, let me know if you had something different in mind, and I'll rework the implementation accordingly.I looked at the entire series again and I'm rather happy with how it turned out. I've commented on a tiny issue about the
readsl()that should be easy to resolve one way or another, with that you can add myReviewed-by Arnd Bergmann <[email protected]>There is one additional issue that we've talked about previously and that I'd like to hear about from GregKH or maybe other subsystem maintainers: In the current version, you have a single '
bus_type' object, and this is used to represent both a 'host' and a 'device'. I think we concluded that this is done in other subsystems as well, and that this is fitting here because a host (master device) can hand over being a master to another device (slave), which then becomes the host and sees this one as a slave. Also a lot of the sysfs attributes are the same because of this relationship.It also means that you get a mix of things in sysfs:
/sys/devices/i3c/<bus>
/sys/devices/i3c/<device>
/sys/devices/i3c/<bus>/<device>
Quoted 8 lines
which is a bit like what we have on USB where we can have hub devices that are again parents of other USB devices, but I don't think we can have i3c hubs or multiplexers in the same way, so it's only a single level.
I'm ok with this model after our previous discussion and couldn't come up with a better one. If anyone else still sees it as problematic and has a better idea, please let us know now.
I know you're quite busy with the 4.19 release, but if you find a bit of time, that'd be great to have your feedback on this.
Thanks,
Boris