From f15cd6d99198e9c15229aefec639a34a6e8174c6 Mon Sep 17 00:00:00 2001 From: Sean Wang Date: Mon, 23 Apr 2018 14:42:44 +0800 Subject: [PATCH 1/4] regmap: include from include/linux/regmap.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the readx_poll_timeout() macro calling ktime_* and using ktime_t type, which is declared in . So, make include/linux/regmap.h explicitly include , like include/linux/iopoll.h does. Otherwise, users of the macro will see below errors. error: implicit declaration of function ‘ktime_add_us’ [-Werror=implicit-function-declaration] error: implicit declaration of function ‘ktime_get’ [-Werror=implicit-function-declaration] error: implicit declaration of function ‘ktime_compare’ [-Werror=implicit-function-declaration] include/linux/regmap.h:128:2: error: unknown type name ‘ktime_t’ ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ Signed-off-by: Sean Wang Signed-off-by: Mark Brown --- include/linux/regmap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 5f7ad0552c03..b6865f070464 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include From eb4a219d19fde99616f120f5655a7121c918cd49 Mon Sep 17 00:00:00 2001 From: James Kelly Date: Tue, 15 May 2018 10:59:58 +1000 Subject: [PATCH 2/4] regmap: Skip clk_put for attached clocks when freeing context Capability to attach an existing clk to a MMIO regmap was introduced in 4.17rc1. However, when using attached clk, regmap does not do the clk_get. Therefore it should not do the clk_put when freeing the MMIO regmap context. There does not appear to be any users of attached clocks yet so this would be a good time to make this change before anything depends on the existing behaviour. Signed-off-by: James Kelly Acked-by: Maxime Ripard Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-mmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 5cadfd3394d8..8741fb5f8f54 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -206,7 +206,8 @@ static void regmap_mmio_free_context(void *context) if (!IS_ERR(ctx->clk)) { clk_unprepare(ctx->clk); - clk_put(ctx->clk); + if (!ctx->attached_clk) + clk_put(ctx->clk); } kfree(context); } From ed24d568bd9190cee046ae64df5890494dea2ca4 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Fri, 25 May 2018 14:50:36 +0100 Subject: [PATCH 3/4] regmap: add missing prototype for devm_init_slimbus For some reason the devm variant of slimbus init is not added into the header eventhough this __devm_regmap_init_slimbus() is an exported function. This patch adds this. This also fixes below warning in regmap-slimbus.c regmap-slimbus.c:65:15: warning: symbol '__devm_regmap_init_slimbus' was not declared. Should it be static? regmap-slimbus.c:65:16: warning: no previous prototype for '__devm_regmap_init_slimbus' [-Wmissing-prototypes] Fixes: 7d6f7fb053ad ("regmap: add SLIMbus support") Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- include/linux/regmap.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index b6865f070464..4f38068ffb71 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -588,7 +588,10 @@ struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw, const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name); - +struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name); /* * Wrapper for regmap_init macros to include a unique lockdep key and name * for each call. No-op if CONFIG_LOCKDEP is not set. @@ -907,6 +910,19 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ sdw, config) +/** + * devm_regmap_init_slimbus() - Initialise managed register map + * + * @slimbus: Device that will be interacted with + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer + * to a struct regmap. The regmap will be automatically freed by the + * device management code. + */ +#define devm_regmap_init_slimbus(slimbus, config) \ + __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ + slimbus, config) int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); void regmap_mmio_detach_clk(struct regmap *map); void regmap_exit(struct regmap *map); From cbdd39ca498f6b2b221614d9c1d105f2948f1dbb Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Fri, 25 May 2018 14:50:37 +0100 Subject: [PATCH 4/4] regmap: slimbus: allow register offsets up to 16 bits As per SLIMBus specs Value Elements and Information Elements address map ranges from 0x000 - 0xFFF. So allow register addresses up to 16 bits Fixes: 7d6f7fb053ad ("regmap: add SLIMbus support") Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-slimbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap-slimbus.c b/drivers/base/regmap/regmap-slimbus.c index c90bee81d954..91d501eda8a9 100644 --- a/drivers/base/regmap/regmap-slimbus.c +++ b/drivers/base/regmap/regmap-slimbus.c @@ -41,7 +41,7 @@ static struct regmap_bus regmap_slimbus_bus = { static const struct regmap_bus *regmap_get_slimbus(struct slim_device *slim, const struct regmap_config *config) { - if (config->val_bits == 8 && config->reg_bits == 8) + if (config->val_bits == 8 && config->reg_bits == 16) return ®map_slimbus_bus; return ERR_PTR(-ENOTSUPP);