All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Linus Walleij <linusw@kernel.org>
Cc: u-boot@lists.u-boot-project.org, Tom Rini <trini@konsulko.com>,
	Stefan Hansson <newbyte@postmarketos.org>
Subject: Re: [PATCH v2] board: stemmy: Read persistent radio addresses
Date: Fri, 27 Nov 2026 20:00:04 +0100	[thread overview]
Message-ID: <awnTNNVRsSbl1FvU@linaro.org> (raw)
In-Reply-To: <20261124-ux500-efs-v2-1-796a522177f9@kernel.org>

On Tue, Nov 24, 2026 at 10:42:24AM +0100, Linus Walleij wrote:
> Samsung stores persistent Wi-Fi and Bluetooth addresses in several
> locations depending on the device and firmware. The eMMC partition
> numbers also differ between devices.
> 
> Locate the EFS and DATAFS partitions by name. Search the known Samsung
> Wi-Fi address files in priority order and support both Bluetooth EFS
> layouts. Accept colon-separated and compact addresses, including Codina's
> bt_macaddr: record, while rejecting known firmware placeholders.
> 
> Pass valid addresses to the operating system through the radio device
> tree nodes from ft_board_setup().
> 
> Signed-off-by: Linus Walleij <linusw@kernel.org>
> ---
> Changes in v2:
> - The code was overly cautious, use exact EFS and DATAFS names and
>   drop both partition lookup fallbacks.
> - Clarify that fs_read() closes the filesystem even on failure.
> - Use log_warning() and log_info() for radio address messages.
> - Link to v1: https://patch.msgid.link/20261120-ux500-efs-v1-1-58147e2eae41@kernel.org
> ---
>  MAINTAINERS                     |   1 +
>  board/ste/stemmy/Makefile       |   2 +-
>  board/ste/stemmy/stemmy-radio.c | 287 ++++++++++++++++++++++++++++++++++++++++
>  board/ste/stemmy/stemmy-radio.h |   8 ++
>  board/ste/stemmy/stemmy.c       |   4 +
>  5 files changed, 301 insertions(+), 1 deletion(-)
> 
> [...]
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6edf740a9ceb..ceb474751906 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -772,6 +772,7 @@ R:	Linus Walleij <linusw@kernel.org>

I think you should swap our M/R roles nowadays. :')

> [...]
> diff --git a/board/ste/stemmy/stemmy-radio.c b/board/ste/stemmy/stemmy-radio.c
> new file mode 100644
> index 000000000000..4a09ebcfe994
> --- /dev/null
> +++ b/board/ste/stemmy/stemmy-radio.c
> @@ -0,0 +1,287 @@
> [...]
> +static struct blk_desc *stemmy_radio_device(void)
> +{
> +	struct blk_desc *desc;
> +	struct udevice *dev;
> +	struct uclass *uc;
> +	struct mmc *mmc;
> +
> +	if (uclass_get(UCLASS_MMC, &uc))
> +		return NULL;
> +
> +	uclass_foreach_dev(dev, uc) {
> +		/* Android's mmcblk0 is not necessarily U-Boot's mmc 0. */
> +		if (!dev_read_bool(dev, "non-removable") || device_probe(dev))
> +			continue;

non-removable doesn't tell us much because the devices also have
non-removable SDIO and sometimes SD slots. Maybe check for "no-sdio" +
"no-sd", so we don't unnecessarily search the SD card or try to probe
the SDIO card?

> +
> +		mmc = mmc_get_mmc_dev(dev);
> +		if (!mmc || mmc_init(mmc) || !IS_MMC(mmc))
> +			continue;
> +
> +		/* Persistent data is in the user area, not an eMMC boot area. */
> +		desc = mmc_get_blk_desc(mmc);
> +		if (!desc || blk_dselect_hwpart(desc, 0))
> +			continue;
> +
> +		return desc;
> +	}
> +
> +	return NULL;
> +}
> [...]
> +static void stemmy_fixup_radio_addr(void *fdt,
> +				    struct stemmy_radio_storage *storage,
> +				    const struct stemmy_radio_source *sources,
> +				    size_t count, const char *compatible,
> +				    bool bluetooth)
> +{
> +	const char *property = bluetooth ? "local-bd-address" :
> +					       "local-mac-address";
> +	const char *name = bluetooth ? "Bluetooth BD" : "WiFi MAC";
> +	u8 addr[ETH_ALEN];
> +	int node, ret, i;
> +
> +	ret = stemmy_find_radio_addr(storage, sources, count, bluetooth, addr);
> +	if (ret) {
> +		log_warning("Persistent %s missing\n", name);
> +		return;
> +	}
> +
> +	log_info("Persistent %s: %pM\n", name, addr);
> +
> +	node = fdt_node_offset_by_compatible(fdt, -1, compatible);
> +	if (node < 0)
> +		return;
> +
> +	/* local-bd-address uses Bluetooth (least significant byte first) order. */
> +	if (bluetooth) {
> +		for (i = 0; i < ETH_ALEN / 2; i++)
> +			swap(addr[i], addr[ETH_ALEN - i - 1]);
> +	} else if (fdt_getprop(fdt, node, "mac-address", NULL)) {
> +		/* Linux prefers mac-address if it is already present. */
> +		ret = fdt_setprop(fdt, node, "mac-address", addr, sizeof(addr));
> +		if (ret)
> +			goto err;

It is true that Linux prefers "mac-address" over "local-mac-address",
but I don't think we should override that property given the definition
in the dt-bindings:

  mac-address:
    description:
      Specifies the MAC address that was last used by the boot program. This
      property should be used in cases where the MAC address assigned to the
      device by the boot program is different from the
      local-mac-address property. This property shall be used only if the value
      differs from local-mac-address property value.

We're not "using" the mac-address. (I don't think this property should
be already set by anything...)

Thanks,
Stephan

      reply	other threads:[~2026-11-27 19:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  9:42 [PATCH v2] board: stemmy: Read persistent radio addresses Linus Walleij
2026-11-27 19:00 ` Stephan Gerhold [this message]

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=awnTNNVRsSbl1FvU@linaro.org \
    --to=stephan.gerhold@linaro.org \
    --cc=linusw@kernel.org \
    --cc=newbyte@postmarketos.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.