@@ -42,11 +42,27 @@ static void tscadc_writel(struct ti_tscadc_dev *tsadc, unsigned int reg,
regmap_write(tsadc->regmap_tscadc, reg, val);
}
+static void tscadc_lock_spinlock(void *__map)
+{
+ struct ti_tscadc_dev *tsadc = __map;
+
+ spin_lock_irqsave(&tsadc->reg_map_lock, tsadc->reg_map_flags);
+}
+
+static void tscadc_unlock_spinlock(void *__map)
+{
+ struct ti_tscadc_dev *tsadc = __map;
+
+ spin_unlock_irqrestore(&tsadc->reg_map_lock, tsadc->reg_map_flags);
+}
+
static const struct regmap_config tscadc_regmap_config = {
.name = "ti_tscadc",
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 32,
+ .lock = tscadc_lock_spinlock,
+ .unlock = tscadc_unlock_spinlock,
};
static void tscadc_idle_config(struct ti_tscadc_dev *config)
@@ -110,6 +126,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)
} else
tscadc->irq = err;
+ spin_lock_init(&tscadc->reg_map_lock);
res = devm_request_mem_region(&pdev->dev,
res->start, resource_size(res), pdev->name);
if (!res) {
@@ -129,6 +129,8 @@
#define TSCADC_CELLS 2
struct ti_tscadc_dev {
+ spinlock_t reg_map_lock;
+ unsigned long reg_map_flags;
struct device *dev;
struct regmap *regmap_tscadc;
void __iomem *tscadc_base;
Without this, devm_regmap_init_mmio() creates & uses a simple spin_lock() and this should be enough. Within the probe function the registers are read and written in process context. Later they are accessed from the ISR and lockdep complains because now the lock is taken suddenly with IRQs enabled. Currently I don't see any other way to keep lockdep quiet than doing this. Cc: Mark Brown <broonie@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- drivers/mfd/ti_am335x_tscadc.c | 17 +++++++++++++++++ include/linux/mfd/ti_am335x_tscadc.h | 2 ++ 2 files changed, 19 insertions(+)