diff options
author | Samuel Holland <samuel@sholland.org> | 2020-10-24 18:21:52 +0300 |
---|---|---|
committer | Andre Przywara <andre.przywara@arm.com> | 2020-11-17 03:42:20 +0300 |
commit | 8a8b73b6d714c740c1e2387c3474cc65cafd47aa (patch) | |
tree | cb1667a67dd8519294d02331474b9a5cb897b12e /board | |
parent | 54ac5aa17461b404ff514c0276c05693069937b6 (diff) | |
download | u-boot-8a8b73b6d714c740c1e2387c3474cc65cafd47aa.tar.xz |
sunxi: board: Add PinePhone DT selection logic
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.
Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/sunxi/board.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 3ea34bc7eb..3243e16a84 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> @@ -922,6 +923,26 @@ int board_fit_config_name_match(const char *name) best_dt_name = "sun50i-a64-pine64"; } #endif +#ifdef CONFIG_PINEPHONE_DT_SELECTION + if (strstr(best_dt_name, "-pinephone")) { + /* 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); + } +#endif + return strcmp(name, best_dt_name); } #endif |