[PATCH 1/2] ARM: baltos: use GPIO names for DIP switches
Sascha Hauer
s.hauer at pengutronix.de
Mon Aug 8 06:08:34 PDT 2022
On Wed, Aug 03, 2022 at 11:31:09AM +0200, yegorslists at googlemail.com wrote:
> From: Yegor Yefremov <yegorslists at googlemail.com>
>
> Switch to gpio_find_by_name() method to get the required input lines.
>
> Signed-off-by: Yegor Yefremov <yegorslists at googlemail.com>
> ---
> arch/arm/boards/vscom-baltos/board.c | 25 ++++--
> arch/arm/dts/am335x-baltos-minimal.dts | 120 +++++++++++++++++++++++++
> 2 files changed, 137 insertions(+), 8 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c
> index 9229df09d4..30553d1838 100644
> --- a/arch/arm/boards/vscom-baltos/board.c
> +++ b/arch/arm/boards/vscom-baltos/board.c
> @@ -49,6 +49,7 @@ static uint8_t get_dip_switch(uint16_t id, uint32_t rev)
> {
> uint16_t maj, min;
> uint8_t dip = 0;
> + int inputs[4];
>
> maj = rev >> 16;
> min = rev & 0xffff;
> @@ -59,10 +60,14 @@ static uint8_t get_dip_switch(uint16_t id, uint32_t rev)
> switch(id) {
> case 214:
> case 215:
> - dip = !gpio_get_value(44);
> - dip += !gpio_get_value(45) << 1;
> - dip += !gpio_get_value(46) << 2;
> - dip += !gpio_get_value(47) << 3;
> + inputs[0] = gpio_find_by_name("SW2_0_alt");
> + inputs[1] = gpio_find_by_name("SW2_1_alt");
> + inputs[2] = gpio_find_by_name("SW2_2_alt");
> + inputs[3] = gpio_find_by_name("SW2_3_alt");
> + dip = !gpio_get_value(inputs[0]);
> + dip += !gpio_get_value(inputs[1]) << 1;
> + dip += !gpio_get_value(inputs[2]) << 2;
> + dip += !gpio_get_value(inputs[3]) << 3;
> break;
> case 212:
> case 221:
> @@ -72,10 +77,14 @@ static uint8_t get_dip_switch(uint16_t id, uint32_t rev)
> case 226:
> case 227:
> case 230:
> - dip = !gpio_get_value(82);
> - dip += !gpio_get_value(83) << 1;
> - dip += !gpio_get_value(105) << 2;
> - dip += !gpio_get_value(106) << 3;
> + inputs[0] = gpio_find_by_name("SW2_0");
> + inputs[1] = gpio_find_by_name("SW2_1");
> + inputs[2] = gpio_find_by_name("SW2_2");
> + inputs[3] = gpio_find_by_name("SW2_3");
> + dip = !gpio_get_value(inputs[0]);
> + dip += !gpio_get_value(inputs[1]) << 1;
> + dip += !gpio_get_value(inputs[2]) << 2;
> + dip += !gpio_get_value(inputs[3]) << 3;
> break;
> }
>
> diff --git a/arch/arm/dts/am335x-baltos-minimal.dts b/arch/arm/dts/am335x-baltos-minimal.dts
> index 1544e2cc29..e9d57696d1 100644
> --- a/arch/arm/dts/am335x-baltos-minimal.dts
> +++ b/arch/arm/dts/am335x-baltos-minimal.dts
> @@ -45,6 +45,18 @@
> };
>
> &am33xx_pinmux {
> + pinctrl-names = "default";
> + pinctrl-0 = <&dip_switch_pins>;
> +
> + dip_switch_pins: pinmux_dip_switch_pins {
> + pinctrl-single,pins = <
> + AM33XX_PADCONF(AM335X_PIN_GPMC_AD12, PIN_INPUT_PULLUP, MUX_MODE7)
> + AM33XX_PADCONF(AM335X_PIN_GPMC_AD13, PIN_INPUT_PULLUP, MUX_MODE7)
> + AM33XX_PADCONF(AM335X_PIN_GPMC_AD14, PIN_INPUT_PULLUP, MUX_MODE7)
> + AM33XX_PADCONF(AM335X_PIN_GPMC_AD15, PIN_INPUT_PULLUP, MUX_MODE7)
> + >;
> + };
> +
> mmc1_pins: pinmux_mmc1_pins {
> pinctrl-single,pins = <
> 0xf0 (INPUT_EN | PULL_UP) MUX_MODE0 /* mmc0_dat3.mmc0_dat3 */
> @@ -449,3 +461,111 @@
> &gpio0 {
> ti,no-reset-on-init;
> };
> +
> +&gpio1 {
> + gpio-line-names =
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "SW2_0_alt",
> + "SW2_1_alt",
> + "SW2_2_alt",
> + "SW2_3_alt",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC";
> +};
> +
> +&gpio2 {
> + gpio-line-names =
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "SW2_0",
> + "SW2_1",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC";
> +};
> +
> +&gpio3 {
> + gpio-line-names =
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "SW2_2",
> + "SW2_3",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC",
> + "NC";
> +};
> --
> 2.17.0
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list