mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches
@ 2022-08-03  9:31 yegorslists
  2022-08-03  9:31 ` [PATCH 2/2] ARM: baltos: use GPIO name for mPCIe power enable pin yegorslists
  2022-08-08 13:08 ` [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: yegorslists @ 2022-08-03  9:31 UTC (permalink / raw)
  To: barebox

From: Yegor Yefremov <yegorslists@googlemail.com>

Switch to gpio_find_by_name() method to get the required input lines.

Signed-off-by: Yegor Yefremov <yegorslists@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(-)

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ARM: baltos: use GPIO name for mPCIe power enable pin
  2022-08-03  9:31 [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches yegorslists
@ 2022-08-03  9:31 ` yegorslists
  2022-08-08 13:08 ` [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: yegorslists @ 2022-08-03  9:31 UTC (permalink / raw)
  To: barebox

From: Yegor Yefremov <yegorslists@googlemail.com>

Switch to gpio_find_by_name() method to get the required input line.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 arch/arm/boards/vscom-baltos/board.c   | 4 +++-
 arch/arm/dts/am335x-baltos-minimal.dts | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c
index 30553d1838..b9ce356264 100644
--- a/arch/arm/boards/vscom-baltos/board.c
+++ b/arch/arm/boards/vscom-baltos/board.c
@@ -98,6 +98,7 @@ static int baltos_read_eeprom(void)
 	int rc;
 	unsigned char mac_addr[6];
 	uint8_t dip;
+	int mpcie_pwr_pin;
 
 	if (!of_machine_is_compatible("vscom,onrisc"))
 		return 0;
@@ -145,7 +146,8 @@ static int baltos_read_eeprom(void)
 	globalvar_add_simple("board.id", var_buf);
 
 	/* enable mPCIe slot */
-	gpio_direction_output(100, 1);
+	mpcie_pwr_pin = gpio_find_by_name("3G_PWR_EN");
+	gpio_direction_output(mpcie_pwr_pin, 1);
 
 	/* configure output signals of the external GPIO controller */
 	if (hw_param.SystemId == 210 || hw_param.SystemId == 211) {
diff --git a/arch/arm/dts/am335x-baltos-minimal.dts b/arch/arm/dts/am335x-baltos-minimal.dts
index e9d57696d1..28a550aa84 100644
--- a/arch/arm/dts/am335x-baltos-minimal.dts
+++ b/arch/arm/dts/am335x-baltos-minimal.dts
@@ -540,7 +540,7 @@
 		"NC",
 		"NC",
 		"NC",
-		"NC",
+		"3G_PWR_EN",
 		"NC",
 		"NC",
 		"NC",
-- 
2.17.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches
  2022-08-03  9:31 [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches yegorslists
  2022-08-03  9:31 ` [PATCH 2/2] ARM: baltos: use GPIO name for mPCIe power enable pin yegorslists
@ 2022-08-08 13:08 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-08-08 13:08 UTC (permalink / raw)
  To: yegorslists; +Cc: barebox

On Wed, Aug 03, 2022 at 11:31:09AM +0200, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> Switch to gpio_find_by_name() method to get the required input lines.
> 
> Signed-off-by: Yegor Yefremov <yegorslists@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 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-08 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03  9:31 [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches yegorslists
2022-08-03  9:31 ` [PATCH 2/2] ARM: baltos: use GPIO name for mPCIe power enable pin yegorslists
2022-08-08 13:08 ` [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox