Commit 7b1425f0 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

pinctrl: renesas: Protect GPIO leftovers by CONFIG_PINCTRL_SH_FUNC_GPIO

On SuperH and ARM SH/R-Mobile SoCs, the pin control driver handles
GPIOs, too.  To reduce code size when compiling a kernel supporting only
modern SoCs, most, but not all, of the GPIO functionality is protected
by checks for CONFIG_PINCTRL_SH_FUNC_GPIO.

Factor out the remaining parts when not needed:
  1. sh_pfc_soc_info.{in,out}put describe GPIO pins that have input
     resp. output capabilities (SuperH and SH/R-Mobile).
  2. sh_pfc_soc_info.gpio_irq{,_size} describe the mapping from GPIO
     pins to interrupt numbers (SH/R-Mobile).
  3. sh_pfc_gpio_set_direction() configures GPIO direction, called from
     the GPIO driver through pinctrl_gpio_direction_{in,out}put()
     (SH/R-Mobile).  Unfortunately this function cannot just be moved to
     drivers/pinctrl/renesas/gpio.c, as it relies on knowledge of
     sh_pfc_pinctrl, which is internal to
     drivers/pinctrl/renesas/pinctrl.c.

While code size reduction is minimal, this does help in documenting
depencies.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20201028151637.1734130-9-geert+renesas@glider.be
parent a3ee0a24
...@@ -315,6 +315,7 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type) ...@@ -315,6 +315,7 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
range = NULL; range = NULL;
break; break;
#ifdef CONFIG_PINCTRL_SH_PFC_GPIO
case PINMUX_TYPE_OUTPUT: case PINMUX_TYPE_OUTPUT:
range = &pfc->info->output; range = &pfc->info->output;
break; break;
...@@ -322,6 +323,7 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type) ...@@ -322,6 +323,7 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
case PINMUX_TYPE_INPUT: case PINMUX_TYPE_INPUT:
range = &pfc->info->input; range = &pfc->info->input;
break; break;
#endif /* CONFIG_PINCTRL_SH_PFC_GPIO */
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -435,6 +435,7 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev, ...@@ -435,6 +435,7 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev,
spin_unlock_irqrestore(&pfc->lock, flags); spin_unlock_irqrestore(&pfc->lock, flags);
} }
#ifdef CONFIG_PINCTRL_SH_PFC_GPIO
static int sh_pfc_gpio_set_direction(struct pinctrl_dev *pctldev, static int sh_pfc_gpio_set_direction(struct pinctrl_dev *pctldev,
struct pinctrl_gpio_range *range, struct pinctrl_gpio_range *range,
unsigned offset, bool input) unsigned offset, bool input)
...@@ -462,6 +463,9 @@ static int sh_pfc_gpio_set_direction(struct pinctrl_dev *pctldev, ...@@ -462,6 +463,9 @@ static int sh_pfc_gpio_set_direction(struct pinctrl_dev *pctldev,
spin_unlock_irqrestore(&pfc->lock, flags); spin_unlock_irqrestore(&pfc->lock, flags);
return ret; return ret;
} }
#else
#define sh_pfc_gpio_set_direction NULL
#endif
static const struct pinmux_ops sh_pfc_pinmux_ops = { static const struct pinmux_ops sh_pfc_pinmux_ops = {
.get_functions_count = sh_pfc_get_functions_count, .get_functions_count = sh_pfc_get_functions_count,
......
...@@ -270,8 +270,13 @@ struct sh_pfc_soc_info { ...@@ -270,8 +270,13 @@ struct sh_pfc_soc_info {
const char *name; const char *name;
const struct sh_pfc_soc_operations *ops; const struct sh_pfc_soc_operations *ops;
#ifdef CONFIG_PINCTRL_SH_PFC_GPIO
struct pinmux_range input; struct pinmux_range input;
struct pinmux_range output; struct pinmux_range output;
const struct pinmux_irq *gpio_irq;
unsigned int gpio_irq_size;
#endif
struct pinmux_range function; struct pinmux_range function;
const struct sh_pfc_pin *pins; const struct sh_pfc_pin *pins;
...@@ -295,9 +300,6 @@ struct sh_pfc_soc_info { ...@@ -295,9 +300,6 @@ struct sh_pfc_soc_info {
const u16 *pinmux_data; const u16 *pinmux_data;
unsigned int pinmux_data_size; unsigned int pinmux_data_size;
const struct pinmux_irq *gpio_irq;
unsigned int gpio_irq_size;
u32 unlock_reg; u32 unlock_reg;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment