From: "André Przywara" <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [PATCH 4/8] sunxi: board: Add PinePhone DT selection logic
Date: Tue, 22 Sep 2020 01:41:09 +0100 [thread overview]
Message-ID: <986e467b-91fd-1ffc-d395-b3fb341e496b@arm.com> (raw)
In-Reply-To: <20200903050716.48488-5-samuel@sholland.org>
On 03/09/2020 06:07, Samuel Holland wrote:
Hi,
> There are two different publicly-released revisions of the PinePhone
> hardware, versions 1.1 and 1.2; and they need different device trees.
> Since some GPIO pins were rerouted, we can use that to distinguish
> between them.
Nice one. I once had a similar solution to differentiate between the
(otherwise very similar) Pinebook and Pine64-LTS.
>
> Signed-off-by: Samuel Holland <samuel@sholland.org>
With the "else" down below removed:
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
> ---
> arch/arm/mach-sunxi/Kconfig | 7 +++++++
> board/sunxi/board.c | 21 +++++++++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> index be0822bfb7d..8421f3b6854 100644
> --- a/arch/arm/mach-sunxi/Kconfig
> +++ b/arch/arm/mach-sunxi/Kconfig
> @@ -1010,4 +1010,11 @@ config PINE64_DT_SELECTION
> option, the device tree selection code specific to Pine64 which
> utilizes the DRAM size will be enabled.
>
> +config PINEPHONE_DT_SELECTION
> + bool "Enable PinePhone device tree selection code"
> + depends on MACH_SUN50I
> + help
> + Enable this option to automatically select the device tree for the
> + correct PinePhone hardware revision during boot.
> +
> endif
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index fb0d5bf4743..3d64ed18664 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -27,6 +27,7 @@
> #include <asm/arch/dram.h>
> #include <asm/arch/gpio.h>
> #include <asm/arch/mmc.h>
> +#include <asm/arch/prcm.h>
> #include <asm/arch/spl.h>
> #include <linux/delay.h>
> #include <u-boot/crc.h>
> @@ -920,6 +921,26 @@ int board_fit_config_name_match(const char *name)
> best_dt_name = "sun50i-a64-pine64";
> }
> #endif
> +#ifdef CONFIG_PINEPHONE_DT_SELECTION
> + else if (strstr(best_dt_name, "-pinephone")) {
I think to improve readability and increase robustness against future
changes you can lose the "else" here. Even if both selection methods
should be selected, only one will realistically match the strstr()
comparison.
> + /* Differentiate the PinePhone revisions by GPIO inputs. */
> + prcm_apb0_enable(PRCM_APB0_GATE_PIO);
> + sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_UP);
> + sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_INPUT);
> + udelay(100);
> +
> + /* PL6 is pulled low by the modem on v1.2. */
> + if (gpio_get_value(SUNXI_GPL(6)) == 0)
> + best_dt_name = "sun50i-a64-pinephone-1.2";
> + else
> + best_dt_name = "sun50i-a64-pinephone-1.1";
> +
> + sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_DISABLE);
> + sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_DISABLE);
> + prcm_apb0_disable(PRCM_APB0_GATE_PIO);
Looking forward, this should probably restore the former state, in case
some code elsewhere had enabled the PIO gate already. But for now, with
the current code state, this is fine.
Cheers,
Andre
> + }
> +#endif
> +
> return strcmp(name, best_dt_name);
> }
> #endif
>
next prev parent reply other threads:[~2020-09-22 0:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 5:07 [PATCH 0/8] PinePhone automatic device tree selection Samuel Holland
2020-09-03 5:07 ` [PATCH 1/8] sunxi: board: Use a more descriptive variable name Samuel Holland
2020-09-22 0:37 ` André Przywara
2020-09-03 5:07 ` [PATCH 2/8] sunxi: board: Add a helper to get the SPL DT name Samuel Holland
2020-09-22 0:38 ` André Przywara
2020-09-03 5:07 ` [PATCH 3/8] sunxi: board: Simplify Pine A64 DT selection logic Samuel Holland
2020-09-22 0:40 ` André Przywara
2020-09-03 5:07 ` [PATCH 4/8] sunxi: board: Add PinePhone " Samuel Holland
2020-09-22 0:41 ` André Przywara [this message]
2020-10-21 18:56 ` Jagan Teki
2020-10-22 1:38 ` Samuel Holland
2020-10-22 6:26 ` Jagan Teki
2020-10-22 15:50 ` Maxime Ripard
2020-09-03 5:07 ` [PATCH 5/8] sunxi: board: Save the chosen DT name in the SPL header Samuel Holland
2020-09-22 0:41 ` André Przywara
2020-09-22 1:12 ` Samuel Holland
2020-09-22 7:46 ` André Przywara
2020-09-03 5:07 ` [PATCH 6/8] sunxi: board: Set fdtfile to match the DT chosen by SPL Samuel Holland
2020-09-22 0:43 ` André Przywara
2020-09-22 1:33 ` Samuel Holland
2020-09-24 14:22 ` Andre Przywara
2020-09-03 5:07 ` [PATCH 7/8] sunxi: DT: A64: update device tree files Samuel Holland
2020-09-03 5:07 ` [PATCH 8/8] sunxi: a64: Add a defconfig for the PinePhone Samuel Holland
2020-09-03 7:31 ` [PATCH 0/8] PinePhone automatic device tree selection Maxime Ripard
2020-09-07 0:01 ` André Przywara
2020-10-24 16:50 ` Peter Robinson
2020-10-24 14:45 ` Jagan Teki
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=986e467b-91fd-1ffc-d395-b3fb341e496b@arm.com \
--to=andre.przywara@arm.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