pinctrl: rmobile: Add support for setting single pins
Subsystems (5)
PATCH 1/4 pinctrl: rmobile: Add support for setting single pins
Add code to handle single pins nodes from DT in addition to already support groups handling.
Signed-off-by Marek Vasut <[email protected]>
Cc Nobuhiro Iwamatsu <[email protected]>
--- drivers/pinctrl/renesas/pfc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/pinctrl/renesas/pfc.c +31 -0
@@ -450,6 +450,22 @@ static const char *sh_pfc_pinctrl_get_function_name(struct udevice *dev,return priv->pfc.info->functions[selector].name; } +static int sh_pfc_pinctrl_pin_set (struct udevice *dev,unsigned pin_selector, +unsigned func_selector) +{ +struct sh_pfc_pinctrl_priv *priv =dev_get_priv (dev); +struct sh_pfc_pinctrl *pmx = &priv->pmx; +struct sh_pfc *pfc = &priv->pfc; +const struct sh_pfc_pin *pin = &priv->pfc.info->pins[pin_selector]; +int idx =sh_pfc_get_pin_index (pfc, pin->pin); +struct sh_pfc_pin_config *cfg = &pmx->configs[idx]; + +if (cfg->type !=PINMUX_TYPE_NONE ) +return -EBUSY ; + +return sh_pfc_config_mux (pfc, pin->enum_id,PINMUX_TYPE_FUNCTION ); +} +static int sh_pfc_pinctrl_group_set (struct udevice *dev,unsigned group_selector,unsigned func_selector) {
@@ -644,6 +660,19 @@ static int sh_pfc_pinconf_set(struct sh_pfc_pinctrl *pmx, unsigned _pin,return 0 ; } +static int sh_pfc_pinconf_pin_set (struct udevice *dev, +unsigned int pin_selector, +unsigned int param,unsigned int arg) +{ +struct sh_pfc_pinctrl_priv *priv =dev_get_priv (dev); +struct sh_pfc_pinctrl *pmx = &priv->pmx; +struct sh_pfc *pfc = &priv->pfc; +const struct sh_pfc_pin *pin = &pfc->info->pins[pin_selector]; + +sh_pfc_pinconf_set (pmx, pin->pin, param, arg); + +return 0 ; +} static int sh_pfc_pinconf_group_set(struct udevice *dev, unsigned int group_selector,
@@ -673,8 +702,10 @@ static struct pinctrl_ops sh_pfc_pinctrl_ops = {#if CONFIG_IS_ENABLED (PINCONF ) .pinconf_num_params = ARRAY_SIZE(sh_pfc_pinconf_params), .pinconf_params = sh_pfc_pinconf_params, + .pinconf_set = sh_pfc_pinconf_pin_set, .pinconf_group_set = sh_pfc_pinconf_group_set, #endif + .pinmux_set = sh_pfc_pinctrl_pin_set, .pinmux_group_set = sh_pfc_pinctrl_group_set, .set_state = pinctrl_generic_set_state, };
Signature · 1 line
2.15.0
PATCH 2/4 pfc: rmobile: Add hook to configure pin as GPIO
Add hook into the PFC driver to allow the GPIO driver to toggle GPSR registers into GPIO mode when GPIO is requested.
Signed-off-by Marek Vasut <[email protected]>
Cc Nobuhiro Iwamatsu <[email protected]>
--- drivers/pinctrl/renesas/pfc.c | 29 +++++++++++++++++++++++++++++ drivers/pinctrl/renesas/sh_pfc.h | 1 + 2 files changed, 30 insertions(+)
drivers/pinctrl/renesas/pfc.c +29 -0
@@ -450,6 +450,35 @@ static const char *sh_pfc_pinctrl_get_function_name(struct udevice *dev,return priv->pfc.info->functions[selector].name; } +int sh_pfc_config_mux_for_gpio (struct udevice *dev,unsigned pin_selector) +{ +struct sh_pfc_pinctrl_priv *priv =dev_get_priv (dev); +struct sh_pfc_pinctrl *pmx = &priv->pmx; +struct sh_pfc *pfc = &priv->pfc; +struct sh_pfc_pin_config *cfg; +const struct sh_pfc_pin *pin =NULL ; +int i, idx; + +for (i =1 ; i < pfc->info->nr_pins; i++) { +if (priv->pfc.info->pins[i].pin != pin_selector) +continue ; + + pin = &priv->pfc.info->pins[i]; +break ; + } + +if (!pin) +return -EINVAL ; + + idx =sh_pfc_get_pin_index (pfc, pin->pin); + cfg = &pmx->configs[idx]; + +if (cfg->type !=PINMUX_TYPE_NONE ) +return -EBUSY ; + +return sh_pfc_config_mux (pfc, pin->enum_id,PINMUX_TYPE_GPIO ); +} +static int sh_pfc_pinctrl_pin_set (struct udevice *dev,unsigned pin_selector,unsigned func_selector) {
drivers/pinctrl/renesas/sh_pfc.h +1 -0
@@ -243,6 +243,7 @@ void sh_pfc_write_reg(struct sh_pfc *pfc, u32 reg, unsigned int width, u32 data)const struct sh_pfc_bias_info *sh_pfc_pin_to_bias_info (const struct sh_pfc_bias_info *info,unsigned int num,unsigned int pin); +int sh_pfc_config_mux_for_gpio (struct udevice *dev,unsigned pin_selector);extern const struct sh_pfc_soc_info r8a7795_pinmux_info;extern const struct sh_pfc_soc_info r8a7796_pinmux_info;
Signature · 1 line
2.15.0
PATCH 3/4 gpio: rmobile: Set GPIO mode in GPSR when requested
In reply to Marek VasutWhen requesting a GPIO, set the PFC GPSR register to GPIO mode, otherwise the GPIO cannot work.
Signed-off-by Marek Vasut <[email protected]>
Cc Nobuhiro Iwamatsu <[email protected]>
--- drivers/gpio/gpio-rcar.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rcar.c +19 -1
@@ -10,6 +10,7 @@#include <errno.h> #include <asm/gpio.h> #include <asm/io.h> +#include "../pinctrl/renesas/sh_pfc.h" #define GPIO_IOINTSEL 0x00/* General IO/Interrupt Switching Register */ #define GPIO_INOUTSEL 0x04/* General Input/Output Switching Register */
@@ -29,7 +30,8 @@DECLARE_GLOBAL_DATA_PTR ;struct rcar_gpio_priv { -void __iomem *regs; +void __iomem *regs; +int pfc_offset; };static int rcar_gpio_get_value (struct udevice *dev,unsigned offset)
@@ -113,7 +115,22 @@ static int rcar_gpio_get_function(struct udevice *dev, unsigned offset)return GPIOF_INPUT ; } +static int rcar_gpio_request (struct udevice *dev,unsigned offset, +const char *label) +{ +struct rcar_gpio_priv *priv =dev_get_priv (dev); +struct udevice *pctldev; +int ret; + + ret =uclass_get_device (UCLASS_PINCTRL ,0 , &pctldev); +if (ret) +return ret; + +return sh_pfc_config_mux_for_gpio (pctldev, priv->pfc_offset + offset); +} +static const struct dm_gpio_ops rcar_gpio_ops = { + .request = rcar_gpio_request, .direction_input = rcar_gpio_direction_input, .direction_output = rcar_gpio_direction_output, .get_value = rcar_gpio_get_value,
@@ -135,6 +152,7 @@ static int rcar_gpio_probe(struct udevice *dev) ret =fdtdec_parse_phandle_with_args (gd->fdt_blob, node,"gpio-ranges" ,NULL ,3 ,0 , &args); + priv->pfc_offset = ret ==0 ? args.args[1 ] :-1 ; uc_priv->gpio_count = ret ==0 ? args.args[2 ] :RCAR_MAX_GPIO_PER_BANK ; ret =clk_get_by_index (dev,0 , &clk);
Signature · 1 line
2.15.0
PATCH 4/4 ARM: rmobile: Rework the ULCB CPLD driver
In reply to Marek VasutRework the ULCB CPLD driver and make it into a sysreset driver, since that is what the ULCB CPLD driver is mostly for.
Signed-off-by Marek Vasut <[email protected]>
Cc Nobuhiro Iwamatsu <[email protected]>
--- arch/arm/dts/ulcb.dtsi | 9 ++ board/renesas/ulcb/cpld.c | 212 +++++++++++++++++++++++------------------ configs/r8a7795_ulcb_defconfig | 1 + configs/r8a7796_ulcb_defconfig | 1 + include/configs/ulcb.h | 13 --- 5 files changed, 129 insertions(+), 107 deletions(-)
arch/arm/dts/ulcb.dtsi +9 -0
@@ -24,6 +24,15 @@ stdout-path = "serial0:115200n8"; }; + cpld { + compatible = "renesas,ulcb-cpld"; + status = "okay"; + gpio-sck = <&gpio6 8 0>; + gpio-mosi = <&gpio6 7 0>; + gpio-miso = <&gpio6 10 0>; + gpio-sstbz = <&gpio2 3 0>; + }; + audio_clkout: audio-clkout { /* * This is same as <&rcar_sound 0>
board/renesas/ulcb/cpld.c +118 -94
261 lines not on this page · raw message
configs/r8a7795_ulcb_defconfig +1 -0
@@ -51,6 +51,7 @@ CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_SCIF_CONSOLE=y +CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y
configs/r8a7796_ulcb_defconfig +1 -0
@@ -52,6 +52,7 @@ CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_SCIF_CONSOLE=y +CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y
include/configs/ulcb.h +0 -13
@@ -25,19 +25,6 @@/* Generic Timer Definitions (use in assembler source) */ #define COUNTER_FREQUENCY 0xFE502A/* 16.66MHz from CPclk */ -/* CPLD SPI */ -#define CONFIG_CMD_SPI -#define CONFIG_SOFT_SPI -#define SPI_DELAY udelay(0) -#define SPI_SDA (val) ulcb_softspi_sda(val) -#define SPI_SCL (val) ulcb_softspi_scl(val) -#define SPI_READ ulcb_softspi_read() -#ifndef __ASSEMBLY__ -void ulcb_softspi_sda (int ); -void ulcb_softspi_scl (int ); -unsigned char ulcb_softspi_read (void ); -#endif -/* Environment in eMMC, at the end of 2nd "boot sector" */ #define CONFIG_ENV_OFFSET (-CONFIG_ENV_SIZE)#define CONFIG_SYS_MMC_ENV_DEV 1
Signature · 1 line
2.15.0