Commit Graph

9 Commits

Author SHA1 Message Date
Baolin Wang c8d0498967 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>
2018-06-26 13:52:27 -07:00
Baolin Wang d4942c119c 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>
2018-06-26 13:52:08 -07:00
Baolin Wang ac17750120
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>
2018-03-21 09:55:19 +08:00
Baolin Wang a61aa68365
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>
2018-03-21 09:49:26 +08:00
Baolin Wang 54e2fc28d9 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: 7e2903cb91 ("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>
2017-10-25 14:00:03 +02:00
Wu Fengguang 8955b26d22 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: 7e2903cb91 ("spi: Add ADI driver for Spreadtrum platform")
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-13 22:15:50 +01:00
Dan Carpenter b0d6e097b9 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>
2017-09-25 17:09:44 +01:00
Dan Carpenter 04063a011f spi: sprd-adi: checking for NULL instead of IS_ERR()
devm_ioremap_resource() returns error pointers, it never returns NULL.

Fixes: 7e2903cb91 ("spi: Add ADI driver for Spreadtrum platform")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-25 17:08:20 +01:00
Baolin Wang 7e2903cb91 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>
2017-09-19 12:53:29 +01:00