History log of /linux-master/drivers/i3c/master/i3c-master-cdns.c
Revision Date Author Comments
# 374c13f9 30-Dec-2023 Harshit Shah <harshitshah.opendev@gmail.com>

i3c: master: cdns: Update maximum prescaler value for i2c clock

As per the Cadence IP document fixed the I2C clock divider value limit from
16 bits instead of 10 bits. Without this change setting up the I2C clock to
low frequencies will not work as the prescaler value might be greater than
10 bit number.

I3C clock divider value is 10 bits only. Updating the macro names for both.

Signed-off-by: Harshit Shah <harshitshah.opendev@gmail.com>
Link: https://lore.kernel.org/r/1703927483-28682-1-git-send-email-harshitshah.opendev@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 49f33846 22-Sep-2023 Kees Cook <keescook@chromium.org>

i3c: master: cdns: Annotate struct cdns_i3c_xfer with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cdns_i3c_xfer.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: "Przemysław Gaj" <pgaj@cadence.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-i3c@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20230922175014.work.637-kees@kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 4bd84052 12-Sep-2023 Joshua Yeong <joshua.yeong@starfivetech.com>

i3c: master: cdns: Fix reading status register

IBIR_DEPTH and CMDR_DEPTH should read from status0 instead of status1.

Cc: stable@vger.kernel.org
Fixes: 603f2bee2c54 ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20230913031743.11439-2-joshua.yeong@starfivetech.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 574ca75f 14-Jul-2023 Rob Herring <robh@kernel.org>

i3c: Explicitly include correct DT includes

The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20230714174623.4057784-1-robh@kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 3f8ad583 18-Mar-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

i3c: cdns: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230318233311.265186-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 0f74f8b6 18-Mar-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

i3c: Make i3c_master_unregister() return void

The function returned zero unconditionally. Switch the return type to void
and simplify the callers accordingly.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20230318233311.265186-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# ba3fea54 29-Jun-2021 Gustavo A. R. Silva <gustavoars@kernel.org>

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>


# abea14bf 10-Sep-2020 Jing Xiangfeng <jingxiangfeng@huawei.com>

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: 603f2bee2c54 ("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


# cd851485 27-Feb-2020 Gustavo A. R. Silva <gustavo@embeddedor.com>

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 76497732932f ("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


# 3c67166d 28-Dec-2019 Yangtao Li <tiny.windzz@gmail.com>

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>


# dbd66543 18-Nov-2019 Przemyslaw Gaj <pgaj@cadence.com>

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>


# b1ac3a4b 22-Jun-2019 Przemyslaw Gaj <pgaj@cadence.com>

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>


# fd3f8f31 25-Jul-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

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>


# 88c50322 16-Apr-2019 Przemyslaw Gaj <pgaj@cadence.com>

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>


# 52768f32 28-Dec-2018 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

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: 603f2bee2c54 ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0fac32f2 28-Dec-2018 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

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: 603f2bee2c54 ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>


# 25ac3da6 12-Dec-2018 Przemyslaw Gaj <pgaj@cadence.com>

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: 603f2bee2c54 ("i3c: master: Add driver for Cadence IP")
Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>


# ad15e8c0 13-Nov-2018 YueHaibing <yuehaibing@huawei.com>

i3c: master: Remove set but not used variable 'old_i3c_scl_lim'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/i3c/master/i3c-master-cdns.c: In function 'cdns_i3c_master_do_daa':
drivers/i3c/master/i3c-master-cdns.c:1137:16: warning:
variable 'old_i3c_scl_lim' set but not used [-Wunused-but-set-variable]

It never used since introdution in commit
acfab7d324b2 ("i3c: master: Add driver for Cadence IP")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>


# 603f2bee 19-Jul-2017 Boris Brezillon <bbrezillon@kernel.org>

i3c: master: Add driver for Cadence IP

Add a driver for Cadence I3C master IP.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>