Commit Graph

54 Commits

Author SHA1 Message Date
Tom Rix 13462ba181 i3c: master: dw: check return of dw_i3c_master_get_free_pos()
Clang static analysis reports this problem
dw-i3c-master.c:799:9: warning: The result of the left shift is
  undefined because the left operand is negative
                      COMMAND_PORT_DEV_INDEX(pos) |
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~

pos can be negative because dw_i3c_master_get_free_pos() can return an
error.  So check for an error.

Fixes: 1dd728f5d4 ("i3c: master: Add driver for Synopsys DesignWare IP")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220108150948.3988790-1-trix@redhat.com
2022-01-13 02:05:50 +01:00
Lukas Bulwahn 7a2bccd1a2 i3c: master: mipi-i3c-hci: correct the config reference for endianness
The referred config BIG_ENDIAN does not exist. The config for the
endianness of the CPU architecture is called CPU_BIG_ENDIAN.

Correct the config name to the existing config for the endianness.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220103094504.3602-1-lukas.bulwahn@gmail.com
2022-01-05 09:54:54 +01:00
Clark Wang 7ff730ca45 i3c: master: svc: enable the interrupt in the enable ibi function
If enable interrupt in the svc_i3c_master_bus_init() but do not call
enable ibi in the device driver, it will cause a kernel dump in the
svc_i3c_master_handle_ibi() when a slave start occurs on the i3c bus,
because the data->ibi_pool is not initialized.
So only enable the interrupt in svc_i3c_master_enable_ibi() function.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-9-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang c5d4587bb9 i3c: master: svc: add the missing module device table
The missing MODULE_DEVICE_TABLE() will cause the svc-i3c-master cannot
be auto probed when it is built in moudle.
So add it.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-8-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang 05be23ef78 i3c: master: svc: add runtime pm support
Add runtime pm support to dynamically manage the clock.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-7-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang 173fcb2721 i3c: master: svc: set ODSTOP to let I2C device see the STOP signal
If using I2C/I3C mixed mode, need to set ODSTOP. Otherwise, the I2C
devices cannot see the stop signal. It may cause message sending errors.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-6-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang d5e512574d i3c: master: svc: add support for slave to stop returning data
When i3c controller reads data from slave device, slave device can stop
returning data with an ACK after any byte.
Add this support for svc i3c controller. Otherwise, it will timeout
when the slave device ends the read operation early.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-5-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang 9fd6b5ce85 i3c: master: svc: separate err, fifo and disable interrupt of reset function
Sometimes only need to reset err and fifo regs, so split the origin
reset function to three functions.
Put them at the top of the file, to let more functions can call them.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-4-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang a84a9222b2 i3c: master: svc: fix atomic issue
do_daa_locked() function is in a spin lock environment, use
readl_poll_timeout_atomic() to replace the origin
readl_poll_timeout().

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-3-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Clark Wang 57d8d3fc06 i3c: master: svc: move module reset behind clk enable
Reset I3C module will R/W its regs, so enable its clocks first.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211227074529.1660398-2-xiaoning.wang@nxp.com
2022-01-05 09:53:44 +01:00
Christophe JAILLET 3f43926f27 i3c/master/mipi-i3c-hci: Fix a potentially infinite loop in 'hci_dat_v1_get_index()'
The code in 'hci_dat_v1_get_index()' really looks like a hand coded version
of 'for_each_set_bit()', except that a +1 is missing when searching for the
next set bit.

This really looks odd and it seems that it will loop until 'dat_w0_read()'
returns the expected result.

So use 'for_each_set_bit()' instead. It is less verbose and should be more
correct.

Fixes: 9ad9a52cce ("i3c/master: introduce the mipi-i3c-hci driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/0cdf3cb10293ead1acd271fdb8a70369c298c082.1637186628.git.christophe.jaillet@wanadoo.fr
2021-12-10 15:55:41 +01:00
Len Baker 313ece2260 i3c/master/mipi-i3c-hci: Prefer kcalloc over open coded arithmetic
As noted in the "Deprecated Interfaces, Language Features, Attributes,
and Conventions" documentation [1], size calculations (especially
multiplication) should not be performed in memory allocator (or similar)
function arguments due to the risk of them overflowing. This could lead
to values wrapping around and a smaller allocation being made than the
caller was expecting. Using those allocations could lead to linear
overflows of heap memory and other misbehaviors.

So, use the purpose specific kcalloc() function instead of the argument
size * count in the kzalloc() function.

[1] https://www.kernel.org/doc/html/v5.14/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Signed-off-by: Len Baker <len.baker@gmx.com>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210912155135.7541-1-len.baker@gmx.com
2021-12-10 15:54:46 +01:00
Len Baker f96b2e77f6 i3c/master/mipi-i3c-hci: Prefer struct_size over open coded arithmetic
As noted in the "Deprecated Interfaces, Language Features, Attributes,
and Conventions" documentation [1], size calculations (especially
multiplication) should not be performed in memory allocator (or similar)
function arguments due to the risk of them overflowing. This could lead
to values wrapping around and a smaller allocation being made than the
caller was expecting. Using those allocations could lead to linear
overflows of heap memory and other misbehaviors.

So, use the struct_size() helper to do the arithmetic instead of the
argument "size + count * size" in the kzalloc() function.

[1] https://www.kernel.org/doc/html/v5.14/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Signed-off-by: Len Baker <len.baker@gmx.com>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210905144054.5124-1-len.baker@gmx.com
2021-12-10 15:54:45 +01:00
Linus Torvalds 88bbd8a031 I3C for 5.14
Drivers:
  - svc: two small fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEBqsFVZXh8s/0O5JiY6TcMGxwOjIFAmDo0P0ACgkQY6TcMGxw
 OjLWxA//R11pYCjXStl1hJnLJkvFahxTL4SQ/QPS6fW9K9BXnmt8cV7w65YFFuzf
 SbXVud00ybP2NDpcfNkmir/leLt0Q5mwJrkcG9MXm6XnprQB4VQehpV+lZe7SgRX
 cHvFpKFoG4p/4+CwWb7NDGm7r3GDzcdsx/pEaMmqnd2cK79ZAtZYcsf1VxythQCg
 CnSHFz7bNPzkAAsqVIaDNU0Beh4V4YsDlh9yxfvVT4fNNtG4HgOxD3uzXj09iDco
 KdZQ/Fj0WNpFzm2rO3GkFVabyscp5x/lPSeKjdPfoGuNdK7vqUUpRtF9sSLMIB7f
 nas8d+ybyqUNogPTPrUSJ8oTRiWDeAcL+QUY2T1V6QvkvpibkfQVPONUo7LX4+U8
 xNC8wQvWxKzakf4sCKClvir6PhWV5aq3WFnJtNIlYMXOEIQom85tHfUoTVRGP/nE
 sQGCaoS4/VyUWOF1y3LcSAxyMlulmIhDZj5OlQpAvpU+YguC2vMfU4h1aofDq/YB
 h2rUs6dWujf93gEhhuFCJSW8Dfi6fWEA3VoHYkgdMnBHBAQYjG8I5tWHRezXX48b
 Cp9tmPbVprqk6gW0EyoO7+c9x0n8MnKYNxpVQM9KQvqtkFCE7mt3QWuLR13gbfoO
 oVzGLYsOTCQOLlpm0LdvtXeIzW4woRtardddnvODJ69PtOGHPQ8=
 =iMi5
 -----END PGP SIGNATURE-----

Merge tag 'i3c/for-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux

Pull i3c updates from Alexandre Belloni:

 - two small fixes to the svc driver

* tag 'i3c/for-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
  i3c: master: svc: fix doc warning in svc-i3c-master.c
  i3c: master: svc: drop free_irq of devm_request_irq allocated irq
2021-07-10 11:53:06 -07:00
Gustavo A. R. Silva ba3fea5472 i3c: master: cdns: Fix fall-through warning for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2021-06-29 08:37:04 -05:00
Yang Yingliang 3e5feb11a8 i3c: master: svc: fix doc warning in svc-i3c-master.c
Fix the following make W=1 warning:

  drivers/i3c/master/svc-i3c-master.c:207: warning: expecting prototype for struct svc_i3c_i3c_dev_data. Prototype was for struct svc_i3c_i2c_dev_data instead

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210602085544.4101980-1-yangyingliang@huawei.com
2021-06-09 02:02:45 +02:00
Yang Yingliang 59a61e69c4 i3c: master: svc: drop free_irq of devm_request_irq allocated irq
irq allocated with devm_request_irq() will be freed in devm_irq_release(),
using free_irq() in ->remove() will causes a dangling pointer, and a
subsequent double free. So remove the free_irq() in svc_i3c_master_remove().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210602084935.3977636-1-yangyingliang@huawei.com
2021-06-09 02:02:22 +02:00
Colin Ian King 436cb709f8 i3c: master: svc: remove redundant assignment to cmd->read_len
The assignment of xfer_len to cmd->read_len appears to be redundant
as the next statement re-assigns the value 0 to it.  Clean up the
code by removing the redundant first assignment.

Addresses-Coverity: ("Unused value")
Fixes: dd3c52846d ("i3c: master: svc: Add Silvaco I3C master driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210224151349.202332-1-colin.king@canonical.com
2021-03-09 21:13:31 +01:00
Linus Torvalds 36c1b20d15 I3C for 5.12
Subsystem:
  - Handle drivers without probe or remove callback
  - Remove callback now returns void
  - DT documentation is now in yaml
 
 New driver:
  - Silvaco I3C master
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAmAy+ycACgkQ2wIijOdR
 NOUDRg/+KPaE8MQMXh/YrnN4VXX+QZe8Yt5WynVThG8GGwDC0PrPtMcepwkd9GGA
 3EsBtuNVE7uvcUX59rmi2VrMlc6e3fRZ6g2Ub2vH5NXDZIeEXjbmq+vk6PlXNgKf
 k7LvVaQLkBCqsBoV1kraR7lPyi7rf2ZFFOYJuObj8yxADhmkpbRFQCbkWkeYGpMn
 2DN3cN2+jybmNBCh5SDDneJn/Bdr0/mBp0bLffOT+uAQ4bu6HbDOrlyZ9gY8rx8y
 TqbOT1JDhTCW0EC6IPw4SSkKXcew20XRmYSax4bx233cTCCjzsXG7vNHtv0KBide
 JlGvKEnE+WDfvPaSoxUjxtmwWfEki/qBzAZ3Mrs8/G9NRWRvE9qDU/x71hduog0g
 pqcRb0plreR7j3XusFaFu83HJtTfwHKVzWb12ExuNfzS4T/uZKs8vM0MFcedIRur
 wJg7+Qv+NGzGegELOaRkquc56x4IjXx+vYj3tbvnOrFdKgAuRU4YBn220QfYwI6d
 zx+6msuzIT/XroH6aq92Ds50hVLMQpNosuJPNsZto57hBShJgA6cmGMj79L9GldM
 CbdOu8ZBgHi4kpCWb9nunNqY0cctlQ0lEV6/1SYhCqRGLS7etS0IaUiWXNDge22N
 kzmeg5+RaA0AlAbzJHi+JOR6OnxxAhvZyys5nfQ4/X08R8JY9iY=
 =282r
 -----END PGP SIGNATURE-----

Merge tag 'i3c/for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux

Pull i3c update from Alexandre Belloni:
 "Subsystem:
   - Handle drivers without probe or remove callback
   - Remove callback now returns void
   - DT documentation is now in yaml

  New driver:
   - Silvaco I3C master"

* tag 'i3c/for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
  i3c: master: dw: Drop redundant disec call
  MAINTAINERS: Add Silvaco I3C master
  i3c: master: svc: Add Silvaco I3C master driver
  dt-bindings: i3c: Describe Silvaco master binding
  dt-bindings: Add vendor prefix for Silvaco
  dt-bindings: i3c: mipi-hci: Include the bus binding
  dt-bindings: i3c: Convert the bus description to yaml
  i3c: Make remove callback return void
  i3c: Handle drivers without probe or remove callback
  i3c/master/mipi-i3c-hci: Specify HAS_IOMEM dependency
2021-02-22 09:52:55 -08:00
Miquel Raynal 5c34b8e7e8 i3c: master: dw: Drop redundant disec call
Disabling all event calls is already handled by the core right before
starting the DAA process. Do not do it again when the DAA process
completes, it is redundant.

Fixes: 1dd728f5d4 ("i3c: master: Add driver for Synopsys DesignWare IP")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201228105501.6104-1-miquel.raynal@bootlin.com
2021-02-06 00:44:15 +01:00
Miquel Raynal dd3c52846d i3c: master: svc: Add Silvaco I3C master driver
Add support for Silvaco I3C dual-role IP. The master role is supported
in SDR mode only. I2C transfers have not been tested but are shared
because they are very close to the I3C transfers in terms of register
configuration.

The IBI processing follows this logic:
- When a slave advertizes an interrupt (SDA pulled low) an interrupt
  gets generated by the master. This time is unbounded and may be
  deferred.
- The IRQ handler itself does not process anything: it only queues a
  work that will be run in non-atomic context. This is needed because
  short wait periods must be experienced.
- The IBI job is divided in two parts: the first one is "critical" in
  the sense that it may not support getting interrupted. If this
  happens, after this first section the driver checks the master error
  register and depending on its content either flushes everything and
  errors out, or ends the processing (this second section may be
  interrupted).
- If the critical section got interrupted, the slave will
  automatically respin it's IBI request when it will be allowed to.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210121101808.14654-6-miquel.raynal@bootlin.com
2021-02-06 00:43:29 +01:00
David Gow 9d909f1b1e i3c/master/mipi-i3c-hci: Specify HAS_IOMEM dependency
The MIPI i3c HCI driver makes use of IOMEM functions like
devm_platform_ioremap_resource(), which are only available if
CONFIG_HAS_IOMEM is defined.

This causes the driver to be enabled under make ARCH=um allyesconfig,
even though it won't build.

By adding a dependency on HAS_IOMEM, the driver will not be enabled on
architectures which don't support it.

Fixes: 9ad9a52cce ("i3c/master: introduce the mipi-i3c-hci driver")
Signed-off-by: David Gow <davidgow@google.com>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210127040636.1535722-1-davidgow@google.com
2021-02-01 23:39:17 +01:00
Nathan Chancellor 291b5c9870 i3c/master/mipi-i3c-hci: Fix position of __maybe_unused in i3c_hci_of_match
Clang warns:

 ../drivers/i3c/master/mipi-i3c-hci/core.c:780:21: warning: attribute
 declaration must precede definition [-Wignored-attributes]
 static const struct __maybe_unused of_device_id i3c_hci_of_match[] = {
                     ^
 ../include/linux/compiler_attributes.h:267:56: note: expanded from macro
 '__maybe_unused'
 #define __maybe_unused                  __attribute__((__unused__))
                                                        ^
 ../include/linux/mod_devicetable.h:262:8: note: previous definition is
 here
 struct of_device_id {
        ^
1 warning generated.

'struct of_device_id' should not be split, as it is a type. Move the
__maybe_unused attribute after the static and const qualifiers so that
there are no warnings about this variable, period.

Fixes: 95393f3e07 ("i3c/master/mipi-i3c-hci: quiet maybe-unused variable warning")
Link: https://github.com/ClangBuiltLinux/linux/issues/1221
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201222025931.3043480-1-natechancellor@gmail.com
2020-12-31 18:41:37 +01:00
Nicolas Pitre 95393f3e07 i3c/master/mipi-i3c-hci: quiet maybe-unused variable warning
If CONFIG_OF is disabled then the matching table is notreferenced.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2020-12-17 10:31:30 +01:00
Colin Ian King 8e3457372c i3c/master: Fix uninitialized variable next_addr
The variable next_addr is not initialized and is being used in a call
to i3c_master_get_free_addr as a starting point to find the next address.
Fix this by initializing next_addr to 0 to avoid an uninitialized garbage
starting address from being used.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 9ad9a52cce ("i3c/master: introduce the mipi-i3c-hci driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-i3c/20201124123504.396249-1-colin.king@canonical.com
2020-11-25 11:02:43 +01:00
Nicolas Pitre 9ad9a52cce i3c/master: introduce the mipi-i3c-hci driver
This adds basic support for hardware implementing the MIPI I3C HCI
specification. This driver is currently limited by the capabilities
of the I3C subsystem, meaning things like scheduled commands,
auto-commands and NCM mode are not yet supported.

This supports version 1.0 of the MIPI I3C HCI spec, as well as the
imminent release of version 1.1. Support for draft version 2.0 of the
spec is also largely included with the caveat that future adjustments
to this code are likely as the spec is still a work in progress.

This is also lightly tested as actual hardware is still very scarce,
even for HCI v1.0. Hence the EXPERIMENTAL tag. Further contributions
to this driver are expected once vendor implementations and new I3C
devices become available.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-i3c/20201111220510.3622216-3-nico@fluxnic.net
2020-11-23 10:22:18 +01:00
Linus Torvalds 2a934b38c0 * Fix DAA for the pre-reserved address case
* Fix an error path in the cadence driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEKmCqpbOU668PNA69Ze02AX4ItwAFAl+Ko/gACgkQZe02AX4I
 twAcKg//d6FTKiiphDXB7o3cNIcfV+1bbOxxl0JTqIW1kaRXvCVA7L0KQDDttefW
 VyjJTDLU+A3xauuC9kEOJCbX+oO3CEKtBQ5IjAaVgHirtz8E0gqJ2YV6X9zkfF86
 A94Z2e4vK79OpvfFmn+odYx8iFbXWR3q5ip9vMXRzXxGYJU0UwjLNSulvA3wSVAI
 uZzWeuLPxZalPQpp544fx+8AB2vuFOKu80yrPZnIBPCtH4luLlIVOXR18VMEXwaC
 ZAT4QlMNzAbqEOWe4ZFrddoyqj7b/enAjUflGkBpb+ZcsKGHzEQKe7s5Fg5PiJfF
 aWmWDsUh6/8et8sx//RCS442s/ZMIDxEvwgbUe/U19z94yW80rTWC0mbJnpO8KsU
 9doNmkZpjygwCnxc2fj6Sa+PlZt69SqDArWj3KOk/5UMqTh7fRDbB8DuvsTEBCiX
 VKOHbk44Fqdaov6g4JAg/u073ZyvI6jjlbDPuPBUVi++hqCxXk7TZ1U16xgwOsyg
 qiASKtQwztLvvuyHYyQNhpV9yHvSxzzUJHbL/3V3FQkGtVRTPP5+5ctCbndY1C46
 im+o0nlS2OpkYyw8A0AQuI6rnypuerbcafPw1ruvSTaWv60OebneyD9mLJm5pO4D
 zs6XtAoyO99+IEKDz+mvVckTxaj8cyrO5pQhjbyQoIr5ZvE2OPM=
 =yC+2
 -----END PGP SIGNATURE-----

Merge tag 'i3c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux

Pull i3c updates from Boris Brezillon:

 - Fix DAA for the pre-reserved address case

 - Fix an error path in the cadence driver

* tag 'i3c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
  i3c: master: Fix error return in cdns_i3c_master_probe()
  i3c: master: fix for SETDASA and DAA process
  i3c: master add i3c_master_attach_boardinfo to preserve boardinfo
2020-10-17 11:01:01 -07:00
Jing Xiangfeng abea14bfde i3c: master: Fix error return in cdns_i3c_master_probe()
Fix to return negative error code -ENOMEM from the error handling
case instead of 0.

Fixes: 603f2bee2c ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-i3c/20200911033350.23904-1-jingxiangfeng@huawei.com
2020-10-07 15:14:07 +02:00
Gustavo A. R. Silva df561f6688 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-23 17:36:59 -05:00
Gustavo A. R. Silva cd851485ef i3c: master: Replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-i3c/20200227131307.GA24935@embeddedor
2020-02-28 09:36:01 +01:00
Vitor Soares 3952cf8ff2 i3c: master: dw: reattach device on first available location of address table
For today the reattach function only update the device address on the
controller.

Update the location to the first available too, will optimize the
enumeration process avoiding additional checks to keep the available
positions on address table consecutive.

Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2020-01-13 10:00:05 +01:00
Yangtao Li 3c67166dc5 i3c: master: cdns: convert to devm_platform_ioremap_resource
Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2020-01-13 09:48:46 +01:00
Yangtao Li fae04237e8 i3c: master: dw: convert to devm_platform_ioremap_resource
Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Acked-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2020-01-13 09:46:12 +01:00
Przemyslaw Gaj dbd6654329 i3c: master: cdns: add data hold delay support
This patch adds support for THD_DEL (Data Hold Delay) to Cadence
I3C master constoller driver.

As per MIPI I3C Specification 1.0, Table 75 (page 142) defines
non-zero minimal tHD_PP timing on master output (Fig 65). This
setting allows to meet this timing on master's soc outputs,
regardless of PCB balancing.

Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-12-09 16:07:21 +01:00
Przemyslaw Gaj b1ac3a4b9a i3c: add addr and lvr to i2c_dev_desc structure
I need to store address and lvr value for I2C devices without static definition
in DT. This allows secondary master to transmit DEFSLVS command properly.

Main changes between v4 and v5:
- Change in defslvs to use addr and lvr from i2c_dev_desc structure
- Change in CDNS and DW drivers to use addr and lvr from i2c_dev_desc structure

Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-08-11 10:48:28 +02:00
Andy Shevchenko fd3f8f3118 i3c: master: cdns: Use for_each_set_bit()
This simplifies and standardizes slot manipulation code
by using for_each_set_bit() library function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-08-11 10:45:52 +02:00
Linus Torvalds 96407298ff * Drop support for 10-bit I2C addresses
* Add support for limited bus mode
 * Fix the Cadence DT binding doc
 * Use struct_size() to allocate a DEFSLVS packet
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEKmCqpbOU668PNA69Ze02AX4ItwAFAl0gTH0ACgkQZe02AX4I
 twCTwRAAhuaDKLP5fI16392s0G+66V82u9Kdn1pF8bD6r8wcyRjkBsp2p73VPu4D
 ASIKH+XDDegy8H9+N7kZ7w4dYPqei/Rb4VhsUuaaC608iDvN8DCYG2ciMOr5eggv
 ejFt56MeMiON9BYUbk9KQJvNfaiN4d4dtFGuRETpYEGR9NG9V8Y3oQhWOG+EcWO3
 RBKYNi6QDo1y5NEhrsr8m7fdz0S1F8A7DgPirwkARYAAl9LBmdUllt8+h+WHUt7I
 1GJwA4ZCgXJYSGXw6Vf2p8RYakzAz6G7fTqx9maMRCwMqYKvucb0Opxe7jRnhS3s
 JPBVqwMdk3Dn4EWpWENgbGHIdJVwqOGxueKf1vtP64+WaUxG7AioS1QFcgPgSqPg
 7yRbGreO0nCPmW1v2X+2DEYE4iTyB5Sf2xcRrNYyLjAyO2elVjNuzx+IMA2d3nK3
 BS0kMaKjanSP1INCUsIiE/ISRQxQypTrYcoD4jpo/wV43MnOLDn93M9KrlhY5dOn
 M4rQg3FXiLeBhj+1NQPs6ac7LKkUgIIVl8+z2C8z+4DoY1LT+DsxI31YGqRly/H3
 quRtBIpCXVDxd69V9bPWpINZhXeP9ccgHDBTwfQJQk8bNfdJk4dh5ydntnO9rqmp
 nXhBPKgww0BlHecihrIf+RpxH4q6XmvFdpCDNTH1pgdtLCwblcQ=
 =Uj8o
 -----END PGP SIGNATURE-----

Merge tag 'i3c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux

Pull ic3 updates from Boris Brezillon:

 - Drop support for 10-bit I2C addresses

 - Add support for limited bus mode

 - Fix the Cadence DT binding doc

 - Use struct_size() to allocate a DEFSLVS packet

* tag 'i3c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
  i3c: master: Use struct_size() helper
  dt-bindings: i3c: cdns: Use correct cells for I2C device
  i3c: dw: add limited bus mode support
  i3c: add mixed limited bus mode
  i3c: fix i2c and i3c scl rate by bus mode
  dt-bindings: i3c: Document dropped support for I2C 10 bit devices
  i3c: Drop support for I2C 10 bit addresing
2019-07-09 09:04:31 -07:00
Vitor Soares f467907c1c i3c: dw: add limited bus mode support
This patch add limited bus mode support for DesignWare i3c master

Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Cc: Boris Brezillon <bbrezillon@kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-06-20 09:23:22 +02:00
Przemyslaw Gaj 88c5032244 i3c: Drop support for I2C 10 bit addresing
This patch drops support for I2C devices with 10 bit addressing. When I2C
device with 10 bit address is defined in DT, I3C master registration fails.

Address space for I2C devices has been reduced and ->i2c_funcs() hook has been
removed.

Because this patch series dropped support for 10 bit I2C devices, support is
also dropped in Cadence I3C master driver and Synopsys DesignWare I3C master
driver.

Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-05-28 09:39:53 +02:00
Thomas Gleixner ec8f24b7fa treewide: Add SPDX license identifier - Makefile/Kconfig
Add SPDX license identifiers to all Make/Kconfig files which:

 - Have no license information of any form

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:46 +02:00
Linus Torvalds 80104bb06b * Fix a shift wrap bug in the core
* Remove dead code in the DW driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJcz9pLAAoJEGXtNgF+CLcAi3AP/3pjOrrJ0G+G3hry40Zr12NO
 JvbUmRPr0YUmcg479iIxgwuJ4Pj5GNGmczGGvfc6ZIKJdDCZEeu8aLIh/KLDzXPX
 nQ0SlcXBYCIk8gOwtZs/zxB+Oi8DVoiT4iz0Q3vvcqCho1K09IfFCDC1S8CZPUho
 72+KapR1nYBhm5gPKpunFn/II7l9UNAzeF1uWLjREm6pCG2/2UNHgzPYGVdp2Pf/
 i2lm6PXTMJyca6pqSDbMRWyDNeMva5SURoTkavvvBTwnTQTJaPukMi/jgWElHJ3C
 ajMJdDtbLBXKWv7La+G2LtlwbbFCDa5wf/V5G7LH4RnszLNWud2BdUhbLEUJWBSr
 /+VpAyYSUuz3vAGAHVaC+Fe7NtYXIxODKEGlSTqwl1Ns31P8fAwX6n+RuHdFNxpl
 wwIVaJZHeU62e5Z7nujQ9buJMDea2msqi5EqmtWubjN59C3rLRWZhwiL7YG3bjLc
 NbcaL5+Fz1IByKiOq7BGrI2w2uV8fK2/hE2mgw4yuNXvo7G0oKloHnSjB9zOxacJ
 HNCSDx6TnoWWfWCzGfXBKzc1ycTXyYY5vmk45qVA78H4a9LY0KG8WGDfsTPXmp44
 +PGQ+GKvvuPMzyYC+ENx1LN5OLkiZqU5c69++pFqkEXHiyPin+Ig4qm4XKbWy5FZ
 mwd5URtCnn2s0vD5DrDH
 =/U9S
 -----END PGP SIGNATURE-----

Merge tag 'i3c/for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux

Pull i3c update from Boris Brezillon:

 - Fix a shift wrap bug in the core

 - Remove dead code in the DW driver

* tag 'i3c/for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
  i3c: Fix a shift wrap bug in i3c_bus_set_addr_slot_status()
  i3c: master: dw: remove dead code from dw_i3c_master_*_xfers()
2019-05-07 08:50:40 -07:00
Vitor Soares 907621e94d i3c: dw: Fix dw_i3c_master_disable controller by using correct mask
The controller was being disabled incorrectly. The correct way is to clear
the DEV_CTRL_ENABLE bit.

Fix this by clearing this bit.

Cc: Boris Brezillon <bbrezillon@kernel.org>
Cc: <stable@vger.kernel.org>
Fixes: 1dd728f5d4 ("i3c: master: Add driver for Synopsys DesignWare IP")
Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-04-10 12:46:20 +02:00
Vitor Soares 124dbd750d i3c: master: dw: remove dead code from dw_i3c_master_*_xfers()
Detected by CoverityScan (Event result_independent_of_operands):
"(i3c_xfers + i).len > 65536" is always false regardless of the values
of its operands. This occurs as the logical operand of "if"

"(i2c_xfers + i).len > 65536" is always false regardless of the values
of its operands. This occurs as the logical operand of "if"

Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-03-30 08:41:44 +01:00
Linus Torvalds c8d950ab24 - Add a /* fall-through */ comment in the dw-i3c-master driver
- Update the I3C entries in MAINTAINERS to add an IRC chan
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJcePoGAAoJEGXtNgF+CLcA5AkQAJqu55WdGQBgEd7q4ENQIRpi
 3Q23SL2FQ0UXxFUc2fYMA/WH1nNzMWBonOQLHFxMaGY0jIDF7HFMtY2FWSSoORHd
 ZBXEoTxGooOFr+x6xUfggeGHIK4Mfwni8/PNFmvSJ7l9dO/Wdv0mn+BPnNgdqZk1
 F2lFpeFLPyd4ijhvcMZkajyCuiV+Nld76GOtEJcgwqYyUJYuIL+rshOd0mIKas+o
 W2F+EcSh5A3In9/vRFXkz9vER59WOzPOM6ZbpBcX7ou5MKTMQtLIu0EygtsX2dwW
 A1yHecEDWIFhzbKBt9XW5ZNmbS/LlmCwA7qw63gR8P1kDKBF3hqxCdHwdDEhFrRx
 Np+Kgev3PQCLEZ0tmiVYIWRirSGXVZYH8RXjO/nEe0XDAMqK3x4NfQU8Ki0cRkDO
 aYIKMe8HMIqALiKoRg9RjXSR5rYUYVvF2vuTKx7Sfcc7WDm9VUvqpLC16wQytIcH
 we+73gUzy1ILmjbzKkjHjH9l+YafDzhxOP5mxeVY2uCCzinv123RMOw+phUeDhV7
 BR+gpaksEnQ0PbvmFCH0OG/4neE8iYGvG4ZkVvdqGAIZaAxEIsJJPxWax2n3oV8W
 l4n2vlB5LVpkGQN1OI/clfifbp05S2PHbqF4xBeuRSL46XXuCKCxeYPr1WnrwH+a
 AgC/crDxDmOQqc8JaiRf
 =Ijxi
 -----END PGP SIGNATURE-----

Merge tag 'i3c/for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux

Pull i3c updates from Boris Brezillon:

 - Add a /* fall-through */ comment in the dw-i3c-master driver

 - Update the I3C entries in MAINTAINERS to add an IRC chan

* tag 'i3c/for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux:
  i3c: master: dw-i3c-master: mark expected switch fall-through
  MAINTAINERS: Add an IRC channel for the I3C subsystem
2019-03-04 19:05:02 -08:00
Gustavo A. R. Silva 988bb4a193 i3c: master: dw-i3c-master: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch
cases where we are expecting to fall through.

This patch fixes the following warning:

drivers/i3c/master/dw-i3c-master.c: In function ‘dw_i3c_master_bus_init’:
drivers/i3c/master/dw-i3c-master.c:603:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (ret)
      ^
drivers/i3c/master/dw-i3c-master.c:605:2: note: here
  case I3C_BUS_MODE_PURE:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
2019-02-28 09:47:53 +01:00
Jisheng Zhang f36c1f9a8d i3c: master: dw: fix deadlock
In dw_i3c_master_irq_handler(), we already have gotten
&master->xferqueue.lock, if we try to get the same lock again in
dw_i3c_master_dequeue_xfer(), deadlock happens.

We fix this issue by introduing dw_i3c_master_dequeue_xfer_locked()
which does all what dw_i3c_master_dequeue_xfer() does without trying
to lock &master->xferqueue.lock.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
2019-01-26 11:14:25 +01:00
Vitor Soares f29fd331aa i3c: master: dw-i3c-master: fix i3c_attach/reattach
This patch fix i3c_attach/reattach functions.

During the i3c_attach the driver ignores the static address used for
SETDASA CCC command.

During the i3c_reattach the driver doesn't update master->addrs[data->index]
with new address if old_dyn_addr = 0.

Fixes: 1dd728f5d4 ("i3c: master: Add driver for Synopsys DesignWare IP")
Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
2019-01-15 11:15:11 +01:00
Christophe JAILLET 0fac32f24c i3c: master: Fix an error checking typo in 'cdns_i3c_master_probe()'
Fix a cut'n'paste typo.
Checking 'master->sysclk' is expected here.

Fixes: 603f2bee2c ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
2019-01-07 14:18:17 +01:00
Przemyslaw Gaj 25ac3da61b i3c: master: cdns: fix I2C transfers in Cadence I3C master driver
This patch fixes I2C transfers in Cadence I3C master driver.
There was no way to queue more than one I2C transfer before.

Fixes: 603f2bee2c ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
2018-12-12 17:08:32 +01:00
Colin Ian King 2b2b283c05 i3c: master: dw: fix mask operation by using the correct operator
The masking operation on status is using a bitwise 'or' rather than
a bitwise 'and' operator, and hence the result is always non-zero
which is probably not what is intended. Fix this by using the correct
operator.

Detected by CoverityScan, CID#1475523 ("Wrong operator used")

Fixes: 88acc98a712a ("i3c: master: Add driver for Synopsys DesignWare IP")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Vitor Soares <vitor.soares@synopsys.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
2018-12-05 17:22:58 +01:00