diff mbox series

[U-Boot,RESEND,01/14] imx: i.MX7ULP: add get_boot_device

Message ID 20190722013941.30857-1-peng.fan@nxp.com
State Accepted
Commit e92fca66a3966c54d86977539fabe57596b62d76
Delegated to: Stefano Babic
Headers show
Series [U-Boot,RESEND,01/14] imx: i.MX7ULP: add get_boot_device | expand

Commit Message

Peng Fan July 22, 2019, 1:24 a.m. UTC
Add get_boot_device for i.MX7ULP

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/include/asm/arch-mx7ulp/imx-regs.h  | 13 +++++++++++++
 arch/arm/include/asm/arch-mx7ulp/sys_proto.h |  1 +
 arch/arm/mach-imx/mx7ulp/soc.c               | 27 +++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)

Comments

Fabio Estevam July 22, 2019, 1:43 a.m. UTC | #1
On Sun, Jul 21, 2019 at 10:24 PM Peng Fan <peng.fan@nxp.com> wrote:
>
> Add get_boot_device for i.MX7ULP
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

For the entire series:

Tested-by: Fabio Estevam <festevam@gmail.com>

Without this series I cannot boot Linux on imx7ulp-evk. With this
series applied I can.

Thanks
Fabio Estevam Aug. 2, 2019, 5:46 p.m. UTC | #2
Hi Stefano,

On Sun, Jul 21, 2019 at 10:43 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> On Sun, Jul 21, 2019 at 10:24 PM Peng Fan <peng.fan@nxp.com> wrote:
> >
> > Add get_boot_device for i.MX7ULP
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>
> For the entire series:
>
> Tested-by: Fabio Estevam <festevam@gmail.com>
>
> Without this series I cannot boot Linux on imx7ulp-evk. With this
> series applied I can.

Any comments about this series, please?

I need to upstream one i.MX7ULP based board, which depends on this series.

Thanks
Stefano Babic Aug. 5, 2019, 9:10 a.m. UTC | #3
On 02/08/19 19:46, Fabio Estevam wrote:
> Hi Stefano,
> 
> On Sun, Jul 21, 2019 at 10:43 PM Fabio Estevam <festevam@gmail.com> wrote:
>>
>> On Sun, Jul 21, 2019 at 10:24 PM Peng Fan <peng.fan@nxp.com> wrote:
>>>
>>> Add get_boot_device for i.MX7ULP
>>>
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>
>> For the entire series:
>>
>> Tested-by: Fabio Estevam <festevam@gmail.com>
>>
>> Without this series I cannot boot Linux on imx7ulp-evk. With this
>> series applied I can.
> 
> Any comments about this series, please?
> 
> I need to upstream one i.MX7ULP based board, which depends on this series.

I merge it into -master today.

Thanks,
Stefano
diff mbox series

Patch

diff --git a/arch/arm/include/asm/arch-mx7ulp/imx-regs.h b/arch/arm/include/asm/arch-mx7ulp/imx-regs.h
index 63b02de087..d58ed43199 100644
--- a/arch/arm/include/asm/arch-mx7ulp/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx7ulp/imx-regs.h
@@ -10,6 +10,8 @@ 
 
 #define ARCH_MXC
 
+#define ROM_SW_INFO_ADDR        0x000001E8
+
 #define CAAM_SEC_SRAM_BASE      (0x26000000)
 #define CAAM_SEC_SRAM_SIZE      (SZ_32K)
 #define CAAM_SEC_SRAM_END       (CAAM_SEC_SRAM_BASE + CAAM_SEC_SRAM_SIZE - 1)
@@ -1112,6 +1114,17 @@  struct usbphy_regs {
 	u32	usb1_pfda_ctrl1_tog;		/* 0x14c */
 };
 
+struct bootrom_sw_info {
+	u8 reserved_1;
+	u8 boot_dev_instance;
+	u8 boot_dev_type;
+	u8 reserved_2;
+	u32 core_freq;
+	u32 axi_freq;
+	u32 ddr_freq;
+	u32 rom_tick_freq;
+	u32 reserved_3[3];
+};
 
 #define	is_boot_from_usb(void)		(!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
 #define	disconnect_from_pc(void)	writel(0x0, USBOTG0_RBASE + 0x140)
diff --git a/arch/arm/include/asm/arch-mx7ulp/sys_proto.h b/arch/arm/include/asm/arch-mx7ulp/sys_proto.h
index 6ecde7db93..0e4c8ad15d 100644
--- a/arch/arm/include/asm/arch-mx7ulp/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx7ulp/sys_proto.h
@@ -17,4 +17,5 @@  enum bt_mode {
 	SINGLE_BOOT		/* LP_BT = 0, DUAL_BT = 0 */
 };
 
+enum boot_device get_boot_device(void);
 #endif
diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c
index c72f0ed3fc..6015c11869 100644
--- a/arch/arm/mach-imx/mx7ulp/soc.c
+++ b/arch/arm/mach-imx/mx7ulp/soc.c
@@ -6,6 +6,7 @@ 
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/hab.h>
 
 static char *get_reset_cause(char *);
@@ -244,3 +245,29 @@  int mmc_get_env_dev(void)
 	return board_mmc_get_env_dev(devno);
 }
 #endif
+
+enum boot_device get_boot_device(void)
+{
+	struct bootrom_sw_info **p =
+		(struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
+
+	enum boot_device boot_dev = SD1_BOOT;
+	u8 boot_type = (*p)->boot_dev_type;
+	u8 boot_instance = (*p)->boot_dev_instance;
+
+	switch (boot_type) {
+	case BOOT_TYPE_SD:
+		boot_dev = boot_instance + SD1_BOOT;
+		break;
+	case BOOT_TYPE_MMC:
+		boot_dev = boot_instance + MMC1_BOOT;
+		break;
+	case BOOT_TYPE_USB:
+		boot_dev = USB_BOOT;
+		break;
+	default:
+		break;
+	}
+
+	return boot_dev;
+}