]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: adc: ad7380: enable regmap cache
authorJulien Stephan <jstephan@baylibre.com>
Wed, 8 Jan 2025 12:49:34 +0000 (13:49 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 3 Feb 2025 19:15:37 +0000 (19:15 +0000)
Enable regmap cache, to avoid useless access on spi bus.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20250108-ad7380-add-alert-support-v4-2-1751802471ba@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7380.c

index bc7d58850a3e2a84a241d81377e3dc14c43fc101..b97d2978289e92ad502cd6a67de43d2b51cdab56 100644 (file)
@@ -663,6 +663,20 @@ static int ad7380_regmap_reg_read(void *context, unsigned int reg,
        return 0;
 }
 
+static const struct reg_default ad7380_reg_defaults[] = {
+       { AD7380_REG_ADDR_ALERT_LOW_TH, 0x800 },
+       { AD7380_REG_ADDR_ALERT_HIGH_TH, 0x7FF },
+};
+
+static const struct regmap_range ad7380_volatile_reg_ranges[] = {
+       regmap_reg_range(AD7380_REG_ADDR_CONFIG2, AD7380_REG_ADDR_ALERT),
+};
+
+static const struct regmap_access_table ad7380_volatile_regs = {
+       .yes_ranges = ad7380_volatile_reg_ranges,
+       .n_yes_ranges = ARRAY_SIZE(ad7380_volatile_reg_ranges),
+};
+
 static const struct regmap_config ad7380_regmap_config = {
        .reg_bits = 3,
        .val_bits = 12,
@@ -670,6 +684,10 @@ static const struct regmap_config ad7380_regmap_config = {
        .reg_write = ad7380_regmap_reg_write,
        .max_register = AD7380_REG_ADDR_ALERT_HIGH_TH,
        .can_sleep = true,
+       .reg_defaults = ad7380_reg_defaults,
+       .num_reg_defaults = ARRAY_SIZE(ad7380_reg_defaults),
+       .volatile_table = &ad7380_volatile_regs,
+       .cache_type = REGCACHE_MAPLE,
 };
 
 static int ad7380_debugfs_reg_access(struct iio_dev *indio_dev, u32 reg,