History log of /linux-master/drivers/spi/spi-sprd-adi.c
Revision Date Author Comments
# 0a3d087d 28-Nov-2023 Yang Yingliang <yangyingliang@huawei.com>

spi: sprd-adi: switch to use spi_alloc_host()

Switch to use modern name function spi_alloc_host().

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://msgid.link/r/20231128093031.3707034-2-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8e6a4396 17-Nov-2023 Andrew Davis <afd@ti.com>

spi: sprd: adi: Use devm_register_restart_handler()

Use device life-cycle managed register function to simplify probe error
path and eliminate need for explicit remove function.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20231117161006.87734-5-afd@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 749396cb 14-Jul-2023 Rob Herring <robh@kernel.org>

spi: 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>
Link: https://lore.kernel.org/r/20230714174955.4064174-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7a2b552c 10-Jul-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

spi: Convert to SPI_CONTROLLER_HALF_DUPLEX

Convert the users under SPI subsystem to SPI_CONTROLLER_HALF_DUPLEX.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230710154932.68377-15-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8499d4b5 27-Mar-2023 Yang Li <yang.lee@linux.alibaba.com>

spi: sprd-adi: Use devm_platform_get_and_ioremap_resource()

According to commit 890cc39a8799 ("drivers: provide
devm_platform_get_and_ioremap_resource()"), convert
platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230327060516.93509-1-yang.lee@linux.alibaba.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# f7f785f1 03-Mar-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

spi: sprd-adi: 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/20230303172041.2103336-71-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3b66ca97 26-Aug-2021 Chunyan Zhang <chunyan.zhang@unisoc.com>

spi: sprd: Add ADI r3 support

ADI r3p0 is used on SC9863 and UMS512 SoCs.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
Link: https://lore.kernel.org/r/20210826091549.2138125-3-zhang.lyra@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 245ca2cc 26-Aug-2021 Chunyan Zhang <chunyan.zhang@unisoc.com>

spi: sprd: Fix the wrong WDG_LOAD_VAL

Use 50ms as default timeout value and the time clock is 32768HZ.
The original value of WDG_LOAD_VAL is not correct, so this patch
fixes it.

Fixes: ac1775012058 ("spi: sprd: Add the support of restarting the system")
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Link: https://lore.kernel.org/r/20210826091549.2138125-2-zhang.lyra@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# f674aacd 24-Aug-2021 Chunyan Zhang <chunyan.zhang@unisoc.com>

spi: sprd: fill offset only to RD_CMD register for reading from slave device

RD_CMD can accept slave address offset only, higher bits are reserved.
Writing the whole slave address including slave base seems unnecessary.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Link: https://lore.kernel.org/r/20210824070212.2089255-3-zhang.lyra@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2b961c51 24-Aug-2021 Chunyan Zhang <chunyan.zhang@unisoc.com>

spi: sprd: Make sure offset not equal to slave address size

The slave register offset shouldn't equal to the max slave address
which ADI can support to access.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Link: https://lore.kernel.org/r/20210824070212.2089255-2-zhang.lyra@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5dc349ec 24-Aug-2021 Chunyan Zhang <chunyan.zhang@unisoc.com>

spi: sprd: Pass offset instead of physical address to adi_read/_write()

The register offset would be added a physical address base and then pass to
the function sprd_adt_read()/_write() each time before calling them. So we
can do that within these two functions instead, that would make the code
more clear.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Link: https://lore.kernel.org/r/20210824070212.2089255-1-zhang.lyra@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# e13a870f 24-Mar-2021 Jay Fang <f.fangjian@huawei.com>

spi: sprd: Fix checkpatch spacing error

Fix checkpatch error:

ERROR: space prohibited before that close parenthesis ')'
#213: FILE: spi-sprd-adi.c:213:
+ rd_addr = (val & RD_ADDR_MASK ) >> RD_ADDR_SHIFT;

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-3-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9d99e558 10-Sep-2020 Krzysztof Kozlowski <krzk@kernel.org>

spi: sprd: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>
Link: https://lore.kernel.org/r/20200910160706.5883-1-krzk@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# df561f66 23-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

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>


# 8bdd79da 02-Jun-2020 Lingling Xu <ling_ling.xu@unisoc.com>

spi: sprd: switch the sequence of setting WDG_LOAD_LOW and _HIGH

The watchdog counter consists of WDG_LOAD_LOW and WDG_LOAD_HIGH,
which would be loaded to watchdog counter once writing WDG_LOAD_LOW.

Fixes: ac1775012058 ("spi: sprd: Add the support of restarting the system")
Signed-off-by: Lingling Xu <ling_ling.xu@unisoc.com>
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Link: https://lore.kernel.org/r/20200602082415.5848-1-zhang.lyra@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# bb4bf8d2 13-Apr-2020 Baolin Wang <baolin.wang7@gmail.com>

spi: sprd: adi: Use IS_ENABLED() to validate configs

If the Spreadtrum wachdog is loaded as a module, we still need set default
watchdog reboot mode in case the rebooting is caused by watchdog. But now
we can not set the watchdog reboot mode by using '#ifdef' to validate
the watchdog configuration, thus we can change to use IS_ENABLED() to
fix this issue.

Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
Link: https://lore.kernel.org/r/e38807eadd5550add8eb90dd3f8fbe2cfc39cc13.1586759322.git.baolin.wang7@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1d00a67c 28-Oct-2019 Lingling Xu <ling_ling.xu@unisoc.com>

spi: sprd: adi: Set BIT_WDG_NEW bit when rebooting

When rebooting system, the PMIC watchdog time loading may not be loaded
correctly when another system is feeding the PMIC watchdog, since we did
not check the watchdog busy status before loading time values.

Thus we should set the BIT_WDG_NEW bit before loading time values, that
can support multiple loads without checking busy status to make sure the
time values can be loaded successfully to avoid this potential issue.

Signed-off-by: Lingling Xu <ling_ling.xu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/5655318a7252c9ea518c2f7950a61228ab8f42bf.1572257085.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 91ea1d70 28-Oct-2019 Lingling Xu <ling_ling.xu@unisoc.com>

spi: sprd: adi: Add missing lock protection when rebooting

When rebooting the system, we should lock the watchdog after
configuration to make sure the watchdog can reboot the system
successfully.

Signed-off-by: Lingling Xu <ling_ling.xu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/7b04711127434555e3a1a86bc6be99860cd86668.1572257085.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# f9adf61e 26-Jul-2019 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: adi: Change hwlock to be optional

Now Spreadtrum ADI controller supplies multiple master accessing channel
to support multiple subsystems accessing, instead of using a hardware
spinlock to synchronize between the multiple subsystems.

To keep backward compatibility, we should change the hardware spinlock
to be optional. Moreover change to use of_hwspin_lock_get_id() function
which return -ENOENT error number to indicate no hwlock support.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/2abe7dcf210e4197f8c5ece7fc6d6cc1eda8c655.1564125131.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# e6d722ca 26-Jul-2019 Sherry Zong <sherry.zong@unisoc.com>

spi: sprd: adi: Add a reset reason for watchdog mode

When the system was rebooted by watchdog, now we did not save the watchdog
reset mode which will make system enter a incorrect mode after rebooting.

Thus we should set the watchdog reset mode as default when opening the
watchdog configuration, that means if the system was rebooted by other
reason through the restart_handler(), then we will clear the default
watchdog reset mode to save the correct reset mode.

Signed-off-by: Sherry Zong <sherry.zong@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/1563f3de43c6c2262d597a25d6138b5de61ea23d.1564125131.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9d9aa1cc 26-Jul-2019 Sherry Zong <sherry.zong@unisoc.com>

spi: sprd: adi: Add a reset reason for factory test mode

Add a new reset flag to indicate that the system need enter factory test
mode after restarting system.

Signed-off-by: Sherry Zong <sherry.zong@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/8ae5651e876b527920ff878721a8a8ef47b099ac.1564125131.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# cc6b3431 26-Jul-2019 Chenxu Wei <weicx@spreadst.com>

spi: sprd: adi: Add a reset reason for TOS panic

Add a new reset flag to indicate the reset reason is caused by TOS.

Signed-off-by: Chenxu Wei <weicx@spreadst.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/97583aad1f2b849d69b4e76e8d29113da72a9fff.1564125131.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# c627c58a 26-Jul-2019 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: adi: Remove redundant address bits setting

The ADI default transfer address bits is 12bit on Spreadtrum SC9860
platform, thus there is no need to set again, remove it.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/3cb57b8aadb7747a9f833e9b4fe8596ba738d9f6.1564125131.git.baolin.wang@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# c8d04989 22-Jun-2018 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: Change to use devm_hwspin_lock_request_specific()

Change to use devm_hwspin_lock_request_specific() instead of
freeing the hwlock explicitly when unbound the device.

Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>


# d4942c11 22-Jun-2018 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: Replace of_hwspin_lock_get_id() with of_hwspin_lock_get_id_byname()

Now the hwlock core has supplied new function to get a specific hwlock id
by one hwlock name, which is more clear for users. So change to use
of_hwspin_lock_get_id_byname().

Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>


# ac177501 19-Mar-2018 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: Add the support of restarting the system

On Spreadtrum platform, we use one PMIC watchdog to reset the whole system
with loading one suitable timeout value (usually 50ms) for the watchdog.

In theory, we should implement the restart function in drivers/power/reset
subsystem to access the PMIC watchdog with regmap. When restart the system,
other cores will be stopped by IPI, but if other cores were accessing PMIC
with holding the regmap mutex lock, that will cause dead-lock issue if we
try to access the PMIC watchdog with regmap to restart the whole system.
Thus we can implement the restart function in ADI driver to avoid this
issue.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a61aa683 19-Mar-2018 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: Simplify the transfer function

We can move the hardware spinlock protection into the ADI read/write
functions to simplify the sprd_adi_transfer_one() function. Moreover
this optimization can also help to access PMIC without considering
the hardware spinlock using sprd_adi_read/write() functions.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 54e2fc28 25-Oct-2017 Baolin Wang <baolin.wang@linaro.org>

spi: sprd: Fix the possible negative value of BIT()

When enabling the ADI hardware channels, if the channel id is 31,
then we will get one negative value -1 for BIT() macro, which will
write incorrect value to register.

Fixes: 7e2903cb91df ("spi: Add ADI driver for Spreadtrum platform")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8955b26d 13-Oct-2017 Wu Fengguang <fengguang.wu@intel.com>

spi: sprd-adi: fix platform_no_drv_owner.cocci warnings

drivers/spi/spi-sprd-adi.c:409:3-8: No need to set .owner here. The core will do it.

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Fixes: 7e2903cb91df ("spi: Add ADI driver for Spreadtrum platform")
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b0d6e097 22-Sep-2017 Dan Carpenter <dan.carpenter@oracle.com>

spi: sprd-adi: silence an uninitialized variable warning

If of_get_property() fails then "size" is uninitialized and it leads to
a static checker warning:

drivers/spi/spi-sprd-adi.c:288 sprd_adi_hw_init()
error: uninitialized symbol 'size'.

We can silence the warning by re-arranging the order of these checks.
It obviously doesn't affect runtime at all.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 04063a01 25-Sep-2017 Dan Carpenter <dan.carpenter@oracle.com>

spi: sprd-adi: checking for NULL instead of IS_ERR()

devm_ioremap_resource() returns error pointers, it never returns NULL.

Fixes: 7e2903cb91df ("spi: Add ADI driver for Spreadtrum platform")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7e2903cb 15-Sep-2017 Baolin Wang <baolin.wang@spreadtrum.com>

spi: Add ADI driver for Spreadtrum platform

This patch adds ADI driver based on SPI framework for
Spreadtrum SC9860 platform.

Signed-off-by: Baolin Wang <baolin.wang@spreadtrum.com>
Signed-off-by: Mark Brown <broonie@kernel.org>