public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Marek Behún" <marek.behun@nic.cz>
Cc: Stefan Roese <sr@denx.de>, u-boot@lists.denx.de
Subject: Re: [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
Date: Tue, 8 Jun 2021 11:49:41 +0200	[thread overview]
Message-ID: <20210608094941.luv7zii7typbykxp@pali> (raw)
In-Reply-To: <20210607143451.5343-4-marek.behun@nic.cz>

On Monday 07 June 2021 16:34:48 Marek Behún wrote:
> Configure blinking on ethernet PHY LEDs on the MOX A board when entering
> rescue mode via reset button.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  board/CZ.NIC/turris_mox/turris_mox.c | 35 ++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
> index a78f33661e..44c272c7cb 100644
> --- a/board/CZ.NIC/turris_mox/turris_mox.c
> +++ b/board/CZ.NIC/turris_mox/turris_mox.c
> @@ -377,6 +377,38 @@ int misc_init_r(void)
>  	return 0;
>  }
>  
> +static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
> +			   u16 mask, u16 set)
> +{
> +	int val;
> +
> +	val = phydev->drv->readext(phydev, MDIO_DEVAD_NONE, page, reg);
> +	val &= ~mask;
> +	val |= set;
> +	phydev->drv->writeext(phydev, MDIO_DEVAD_NONE, page, reg, val);
> +}
> +
> +static void mox_phy_leds_start_blinking(void)
> +{
> +	struct phy_device *phydev;
> +	struct mii_dev *bus;
> +
> +	bus = miiphy_get_dev_by_name("neta@30000");
> +	if (!bus) {
> +		printf("Cannot get MDIO bus device!\n");
> +		return;
> +	}
> +
> +	phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII);
> +	if (!phydev) {
> +		printf("Cannot get ethernet PHY!\n");
> +		return;
> +	}
> +
> +	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
> +	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
> +}
> +
>  static bool read_reset_button(void)
>  {
>  	struct udevice *button, *led;
> @@ -424,6 +456,9 @@ static void handle_reset_button(void)
>  		/* Ensure bootcmd_rescue is used by distroboot */
>  		env_set("boot_targets", "rescue");
>  
> +		/* start blinking PHY LEDs */
> +		mox_phy_leds_start_blinking();
> +
>  		printf("RESET button was pressed, overwriting boot_targets!\n");
>  	} else {
>  		/*
> -- 
> 2.31.1
> 

  reply	other threads:[~2021-06-08  9:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 1/7] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
2021-06-03 15:18   ` Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 3/7] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 4/7] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 5/7] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
2021-06-02 17:10 ` [PATCH u-boot-marvell 6/7] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
2021-06-02 17:10 ` [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node Marek Behún
2021-06-03 15:20   ` Marek Behún
2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
2021-06-08  9:47     ` Pali Rohár
2021-06-10  5:06     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
2021-06-08  9:48     ` Pali Rohár
2021-06-10  5:09     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
2021-06-08  9:49     ` Pali Rohár [this message]
2021-06-10  5:09     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
2021-06-08  9:50     ` Pali Rohár
2021-06-10  5:10     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
2021-06-08  9:51     ` Pali Rohár
2021-06-10  5:12       ` Stefan Roese
2021-06-10 14:07         ` Pali Rohár
2021-06-10 14:28           ` Marek Behun
2021-06-11  4:14             ` Stefan Roese
2021-06-10  5:11     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
2021-06-08  9:52     ` Pali Rohár
2021-06-10  5:11     ` Stefan Roese
2021-06-10  7:54   ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX 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=20210608094941.luv7zii7typbykxp@pali \
    --to=pali@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=sr@denx.de \
    --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