public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Cc: Chris Packham <judge.packham@gmail.com>,
	Chris Packham <chris.packham@alliedtelesis.co.nz>,
	Stefan Roese <sr@denx.de>, Tom Rini <trini@konsulko.com>
Subject: [PATCH 1/6] ARM: kirkwood: SBx81LIFKW: remove direct access of GPIO registers
Date: Thu,  4 Aug 2022 21:06:23 +1200	[thread overview]
Message-ID: <20220804090629.75183-2-judge.packham@gmail.com> (raw)
In-Reply-To: <20220804090629.75183-1-judge.packham@gmail.com>

Replace code that accessed the GPIO registers directly with code that
makes use of the LED_GPIO driver.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

 arch/arm/dts/kirkwood-atl-sbx81lifkw.dts    | 14 ++++++
 board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c | 50 +++++----------------
 configs/SBx81LIFKW_defconfig                |  2 +
 3 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/arch/arm/dts/kirkwood-atl-sbx81lifkw.dts b/arch/arm/dts/kirkwood-atl-sbx81lifkw.dts
index 4ae74f4316e5..3837c8f77fe2 100644
--- a/arch/arm/dts/kirkwood-atl-sbx81lifkw.dts
+++ b/arch/arm/dts/kirkwood-atl-sbx81lifkw.dts
@@ -70,6 +70,20 @@
 			};
 		};
 	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		ledn {
+			label = "status:ledn";
+			gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
+		};
+
+		ledp {
+			label = "status:ledp";
+			gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>;
+		};
+	};
 };
 
 &spi0 {
diff --git a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
index d8b9fdfe356f..feb8b6b83f00 100644
--- a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
+++ b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
@@ -13,7 +13,7 @@
 #include <linux/io.h>
 #include <miiphy.h>
 #include <netdev.h>
-#include <status_led.h>
+#include <led.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
@@ -41,41 +41,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct led {
-	u32 reg;
-	u32 value;
-	u32 mask;
-};
-
-struct led amber_solid = {
-	MVEBU_GPIO0_BASE,
-	BIT(10),
-	BIT(18) | BIT(10)
-};
-
-struct led green_solid = {
-	MVEBU_GPIO0_BASE,
-	BIT(18) | BIT(10),
-	BIT(18) | BIT(10)
-};
-
-struct led amber_flash = {
-	MVEBU_GPIO0_BASE,
-	0,
-	BIT(18) | BIT(10)
-};
-
-struct led green_flash = {
-	MVEBU_GPIO0_BASE,
-	BIT(18),
-	BIT(18) | BIT(10)
-};
-
-static void status_led_set(struct led *led)
-{
-	clrsetbits_le32(led->reg, led->mask, led->value);
-}
-
 int board_early_init_f(void)
 {
 	/*
@@ -165,8 +130,6 @@ int board_init(void)
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
-	status_led_set(&amber_solid);
-
 	return 0;
 }
 
@@ -196,7 +159,16 @@ int mv88e61xx_hw_reset(struct phy_device *phydev)
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
-	status_led_set(&green_flash);
+	struct udevice *dev;
+	int ret;
+
+	ret = led_get_by_label("status:ledp", &dev);
+	if (!ret)
+		led_set_state(dev, LEDST_ON);
+
+	ret = led_get_by_label("status:ledn", &dev);
+	if (!ret)
+		led_set_state(dev, LEDST_OFF);
 
 	return 0;
 }
diff --git a/configs/SBx81LIFKW_defconfig b/configs/SBx81LIFKW_defconfig
index f186f247eb63..90800e2dd3ee 100644
--- a/configs/SBx81LIFKW_defconfig
+++ b/configs/SBx81LIFKW_defconfig
@@ -46,6 +46,8 @@ CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_MUX_PCA954x=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_DM_SPI_FLASH=y
-- 
2.37.1


  reply	other threads:[~2022-08-04  9:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  9:06 [PATCH 0/6] SBx81LIFKW/SBx81LIFXCAT disable KIRKWOOD_GPIO Chris Packham
2022-08-04  9:06 ` Chris Packham [this message]
2022-08-05 10:47   ` [PATCH 1/6] ARM: kirkwood: SBx81LIFKW: remove direct access of GPIO registers Stefan Roese
2022-08-04  9:06 ` [PATCH 2/6] ARM: kirkwood: SBx81LIFKW: update for DM_GPIO Chris Packham
2022-08-05 10:47   ` Stefan Roese
2022-08-04  9:06 ` [PATCH 3/6] ARM: kirkwood: SBx81LIFKW: enable CMD_GPIO Chris Packham
2022-08-05 10:48   ` Stefan Roese
2022-08-04  9:06 ` [PATCH 4/6] ARM: kirkwood: SBx81LIFKW: disable KIRKWOOD_GPIO Chris Packham
2022-08-05 10:48   ` Stefan Roese
2022-08-04  9:06 ` [PATCH 5/6] ARM: kirkwood: SBx81LIFKW: enable CONFIG_NET_RANDOM_ETHADDR Chris Packham
2022-08-05 10:48   ` Stefan Roese
2022-08-04  9:06 ` [PATCH 6/6] ARM: kirkwood: SBx81LIFXCAT: disable KIRKWOOD_GPIO Chris Packham
2022-08-05 10:49   ` Stefan Roese
2022-08-09 11:35 ` [PATCH 0/6] SBx81LIFKW/SBx81LIFXCAT " Stefan Roese

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=20220804090629.75183-2-judge.packham@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=sr@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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