diff mbox series

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

Message ID af057a852faf8859266409303e4043edbfe0d356.1509425993.git.baolin.wang@linaro.org
State New
Headers show
Series [1/2] regmap: Add hardware spinlock support | expand

Commit Message

(Exiting) Baolin Wang Oct. 31, 2017, 6:35 a.m. UTC
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@linaro.org>

---
 drivers/mfd/syscon.c |    9 +++++++++
 1 file changed, 9 insertions(+)

-- 
1.7.9.5
diff mbox series

Patch

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;