From: yegorslists@googlemail.com
To: barebox@lists.infradead.org
Subject: [PATCH 1/2] ARM: baltos: use GPIO names for DIP switches
Date: Wed, 3 Aug 2022 11:31:09 +0200 [thread overview]
Message-ID: <20220803093110.20915-1-yegorslists@googlemail.com> (raw)
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
next reply other threads:[~2022-08-03 9:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 9:31 yegorslists [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220803093110.20915-1-yegorslists@googlemail.com \
--to=yegorslists@googlemail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox