aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>2016-11-12 11:04:25 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-19 14:17:57 -0500
commit9229336861cbe0f0c81dbe884d5721b4d81c21b2 (patch)
tree2f981f4428af98ecf4a49613fe236842064d8228 /drivers/pinctrl
parent5e1595223a2c703b810c567b3071a6cc87af5890 (diff)
pinctrl: sh-pfc: Add helper to handle bias lookup table
commit c314c9f15aa5f43f0e5c0e2602cc65798dbd1598 upstream. On some SoC there are no simple mapping of pins to bias register bits and a lookup table is needed. This logic is already implemented in some SoC specific drivers that could benefit from a generic implementation. Add helpers to deal with the lookup which later can be used by the SoC specific drivers. The logic used to lookup are different from the one it aims to replace, this is intentional. This new method reduces the memory consumption at the cost of increased CPU usage and fix a bug where a WARN() would incorrectly be triggered if the register offset is 0. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/sh-pfc/core.c15
-rw-r--r--drivers/pinctrl/sh-pfc/core.h4
-rw-r--r--drivers/pinctrl/sh-pfc/sh_pfc.h6
3 files changed, 25 insertions, 0 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index f3a8897d4e8f..cf80ce1dd7ce 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -389,6 +389,21 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
389 return 0; 389 return 0;
390} 390}
391 391
392const struct sh_pfc_bias_info *
393sh_pfc_pin_to_bias_info(const struct sh_pfc_bias_info *info,
394 unsigned int num, unsigned int pin)
395{
396 unsigned int i;
397
398 for (i = 0; i < num; i++)
399 if (info[i].pin == pin)
400 return &info[i];
401
402 WARN_ONCE(1, "Pin %u is not in bias info list\n", pin);
403
404 return NULL;
405}
406
392static int sh_pfc_init_ranges(struct sh_pfc *pfc) 407static int sh_pfc_init_ranges(struct sh_pfc *pfc)
393{ 408{
394 struct sh_pfc_pin_range *range; 409 struct sh_pfc_pin_range *range;
diff --git a/drivers/pinctrl/sh-pfc/core.h b/drivers/pinctrl/sh-pfc/core.h
index 0bbdea5849f4..6d598dd63720 100644
--- a/drivers/pinctrl/sh-pfc/core.h
+++ b/drivers/pinctrl/sh-pfc/core.h
@@ -33,4 +33,8 @@ void sh_pfc_write_reg(struct sh_pfc *pfc, u32 reg, unsigned int width,
33int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin); 33int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin);
34int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type); 34int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type);
35 35
36const struct sh_pfc_bias_info *
37sh_pfc_pin_to_bias_info(const struct sh_pfc_bias_info *info,
38 unsigned int num, unsigned int pin);
39
36#endif /* __SH_PFC_CORE_H__ */ 40#endif /* __SH_PFC_CORE_H__ */
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h
index 2345421103db..9556c172e3d2 100644
--- a/drivers/pinctrl/sh-pfc/sh_pfc.h
+++ b/drivers/pinctrl/sh-pfc/sh_pfc.h
@@ -189,6 +189,12 @@ struct sh_pfc_window {
189 unsigned long size; 189 unsigned long size;
190}; 190};
191 191
192struct sh_pfc_bias_info {
193 u16 pin;
194 u16 reg : 11;
195 u16 bit : 5;
196};
197
192struct sh_pfc_pin_range; 198struct sh_pfc_pin_range;
193 199
194struct sh_pfc { 200struct sh_pfc {