[PATCH 2/2] mfd: syscon: Add hardware spinlock support

From: Baolin Wang
Date: Tue Oct 31 2017 - 02:37:11 EST


Some system control registers need hardware spinlock to synchronize
between the multiple subsystems, so we should add hardware spinlock
support for syscon.

Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxx>
---
drivers/mfd/syscon.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index b93fe4c..adc1c9c 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -25,6 +25,8 @@
#include <linux/mfd/syscon.h>
#include <linux/slab.h>

+#define SYSCON_HWSPINLOCK_TIMEOUT (~0U)
+
static struct platform_driver syscon_driver;

static DEFINE_SPINLOCK(syscon_list_slock);
@@ -87,6 +89,13 @@ static struct syscon *of_syscon_register(struct device_node *np)
if (ret)
reg_io_width = 4;

+ ret = of_hwspin_lock_get_id(np, 0);
+ if (ret > 0) {
+ syscon_config.hwlock_id = ret;
+ syscon_config.hwlock_mode = HWLOCK_IRQSTATE;
+ syscon_config.hwlock_timeout = SYSCON_HWSPINLOCK_TIMEOUT;
+ }
+
syscon_config.reg_stride = reg_io_width;
syscon_config.val_bits = reg_io_width * 8;
syscon_config.max_register = resource_size(&res) - reg_io_width;
--
1.7.9.5