return 1;
}
+static bool sh_pfc_gpio_is_pin(struct sh_pfc *pfc, unsigned int gpio)
+{
+ return (gpio < pfc->info->nr_pins) &&
+ (pfc->info->gpios[gpio].enum_id != 0);
+}
+
+static bool sh_pfc_gpio_is_function(struct sh_pfc *pfc, unsigned int gpio)
+{
+ return (gpio >= pfc->info->nr_pins) && (gpio < pfc->info->nr_gpios) &&
+ (pfc->info->gpios[gpio].enum_id != 0);
+}
+
static unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg,
unsigned long reg_width)
{
struct pinmux_data_reg *data_reg;
int k, n;
- if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->info->data))
+ if (!sh_pfc_gpio_is_pin(pfc, gpio))
return -1;
k = 0;
struct pinmux_data_reg *drp;
int k;
- for (k = 0; k < pfc->info->nr_gpios; k++)
+ for (k = 0; k < pfc->info->nr_pins; k++)
sh_pfc_setup_data_reg(pfc, k);
k = 0;
struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio];
int k, n;
- if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->info->data))
+ if (!sh_pfc_gpio_is_pin(pfc, gpio))
return -1;
k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT;
pinmux_enum_t *data = pfc->info->gpio_data;
int k;
- if (!sh_pfc_enum_in_range(enum_id, &pfc->info->data)) {
- if (!sh_pfc_enum_in_range(enum_id, &pfc->info->mark)) {
- pr_err("non data/mark enum_id for gpio %d\n", gpio);
- return -1;
- }
+ if (!sh_pfc_gpio_is_pin(pfc, gpio) &&
+ !sh_pfc_gpio_is_function(pfc, gpio)) {
+ pr_err("non data/mark enum_id for gpio %d\n", gpio);
+ return -1;
}
if (pos) {
struct sh_pfc_soc_info r8a7740_pinmux_info = {
.name = "r8a7740_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN,
- PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN,
PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN,
PINMUX_INPUT_PULLDOWN_END },
.output = { PINMUX_OUTPUT_BEGIN,
PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN,
- PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN,
PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PORT211 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
.unlock_reg = 0xfffc0000, /* PMMR */
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_GP_6_8 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7203_pinmux_info = {
.name = "sh7203_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END, FORCE_IN },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END, FORCE_OUT },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PF0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7264_pinmux_info = {
.name = "sh7264_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END, FORCE_IN },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END, FORCE_OUT },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PK0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7269_pinmux_info = {
.name = "sh7269_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END, FORCE_IN },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END, FORCE_OUT },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PJ0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7372_pinmux_info = {
.name = "sh7372_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.input_pd = { PINMUX_INPUT_PULLDOWN_BEGIN, PINMUX_INPUT_PULLDOWN_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PORT190 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh73a0_pinmux_info = {
.name = "sh73a0_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.input_pd = { PINMUX_INPUT_PULLDOWN_BEGIN, PINMUX_INPUT_PULLDOWN_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PORT309 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7720_pinmux_info = {
.name = "sh7720_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PTV0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7722_pinmux_info = {
.name = "sh7722_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pd = { PINMUX_INPUT_PULLDOWN_BEGIN, PINMUX_INPUT_PULLDOWN_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PTZ1 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7723_pinmux_info = {
.name = "sh7723_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PTZ0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7724_pinmux_info = {
.name = "sh7724_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PTZ0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
.unlock_reg = 0xFFFC0000,
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_GP_5_11 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7757_pinmux_info = {
.name = "sh7757_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PTZ7 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7785_pinmux_info = {
.name = "sh7785_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PR0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info sh7786_pinmux_info = {
.name = "sh7786_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN, PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = pinmux_gpios,
+ .nr_pins = GPIO_PJ0 + 1,
.nr_gpios = ARRAY_SIZE(pinmux_gpios),
.cfg_regs = pinmux_config_regs,
struct sh_pfc_soc_info shx3_pinmux_info = {
.name = "shx3_pfc",
.reserved_id = PINMUX_RESERVED,
- .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
.input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
.input_pu = { PINMUX_INPUT_PULLUP_BEGIN,
PINMUX_INPUT_PULLUP_END },
.output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
- .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
.gpios = shx3_pinmux_gpios,
+ .nr_pins = GPIO_PH0 + 1,
.nr_gpios = ARRAY_SIZE(shx3_pinmux_gpios),
.gpio_data = shx3_pinmux_data,
.gpio_data_size = ARRAY_SIZE(shx3_pinmux_data),
struct sh_pfc_soc_info {
char *name;
pinmux_enum_t reserved_id;
- struct pinmux_range data;
struct pinmux_range input;
struct pinmux_range input_pd;
struct pinmux_range input_pu;
struct pinmux_range output;
- struct pinmux_range mark;
struct pinmux_range function;
struct pinmux_gpio *gpios;
+ unsigned int nr_pins;
unsigned int nr_gpios;
struct pinmux_cfg_reg *cfg_regs;