Skip to contentSkip to conversation

mx6: add function to determine boot device

PATCH New Edward Lin 2 participants 2 messages Nov 8, 2013 1 message not in the archive Arm (32-bit)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1383902813.3157.481.camel@edward-x220-laptop

Edward Lin

author
#1 lore raw

PATCH 1/4 mx6: add function to determine boot device

During boot the boot pin configuration is copied to the SBMR registers. This patch adds a function to read the boot device from SBMR.

---
 arch/arm/cpu/armv7/mx6/soc.c              | 43
+++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx6/sys_proto.h | 17 ++++++++++++
 2 files changed, 60 insertions(+)
arch/arm/cpu/armv7/mx6/soc.c +43 -0
index a390296..6bacdab 100644
@@ -243,6 +243,49 @@ void s_init(void)
        writel(mask528, &anatop->pfd_528_clr);
 }
 
+enum mx6_boot_device imx_get_boot_device(void)
+{
+       uint soc_sbmr = readl(SRC_BASE_ADDR + 0x4);
+       uint bt_mem_ctl = (soc_sbmr & 0x000000FF) >> 4 ;
+       uint bt_mem_type = (soc_sbmr & 0x00000008) >> 3;
+       uint bt_mem_mmc = (soc_sbmr & 0x00001000) >> 12;
+
+       switch (bt_mem_ctl) {
+       case 0x0:
+               if (bt_mem_type)
+                       return MX6_ONE_NAND_BOOT;
+               else
+                       return MX6_WEIM_NOR_BOOT;
+               break;
+       case 0x2:
+                       return MX6_SATA_BOOT;
+               break;
+       case 0x3:
+               if (bt_mem_type)
+                       return MX6_I2C_BOOT;
+               else
+                       return MX6_SPI_NOR_BOOT;
+               break;
+       case 0x4:
+       case 0x5:
+               if (bt_mem_mmc)
+                       return MX6_SD0_BOOT;
+               else
+                       return MX6_SD1_BOOT;
+               break;
+       case 0x6:
+       case 0x7:
+               return MX6_MMC_BOOT;
+               break;
+       case 0x8 ... 0xf:
+               return MX6_NAND_BOOT;
+               break;
+       default:
+               return MX6_UNKNOWN_BOOT;
+               break;
+       }
+}
+
 #ifdef CONFIG_IMX_HDMI
 void imx_enable_hdmi_phy(void)
 {
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 8c21364..b26955e 100644

arch/arm/include/asm/arch-mx6/sys_proto.h +17 -0
@@ -17,6 +17,21 @@
 #define MXC_CPU_MX6SOLO                0x62
 #define MXC_CPU_MX6Q           0x63
 
+enum mx6_boot_device {
+        MX6_SD0_BOOT,
+        MX6_SD1_BOOT,
+        MX6_MMC_BOOT,
+        MX6_NAND_BOOT,
+        MX6_SATA_BOOT,
+        MX6_WEIM_NOR_BOOT,
+        MX6_ONE_NAND_BOOT,
+        MX6_PATA_BOOT,
+        MX6_I2C_BOOT,
+        MX6_SPI_NOR_BOOT,
+        MX6_UNKNOWN_BOOT,
+        MX6_BOOT_DEV_NUM = MX6_UNKNOWN_BOOT,
+};
+
 #define is_soc_rev(rev)        ((get_cpu_rev() & 0xFF) - rev)
 u32 get_cpu_rev(void);
 
@@ -31,6 +46,8 @@ unsigned imx_ddr_size(void);
 
 void set_vddsoc(u32 mv);
 
+enum mx6_boot_device imx_get_boot_device(void);
+
 /*
  * Initializes on-chip ethernet controllers.
  * to override, implement board_eth_init()
Signature · 1 line
1.8.0
#2 lore raw

PATCH 1/4 mx6: add function to determine boot device

Hi Edward,

Quoted 17 lines · Edward Lin

During boot the boot pin configuration is copied to the SBMR registers. This patch adds a function to read the boot device from SBMR.

---
  arch/arm/cpu/armv7/mx6/soc.c              | 43
+++++++++++++++++++++++++++++++
  arch/arm/include/asm/arch-mx6/sys_proto.h | 17 ++++++++++++
  2 files changed, 60 insertions(+)
arch/arm/cpu/armv7/mx6/soc.c +0 -0
index a390296..6bacdab 100644

arch/arm/cpu/armv7/mx6/soc.c void s_init(void) · line 248

Quoted 6 lines
arch/arm/cpu/armv7/mx6/soc.c +3 -0
@@ -243,6 +243,49 @@ void s_init(void)
         writel(mask528, &anatop->pfd_528_clr);
  }
 
+enum mx6_boot_device imx_get_boot_device(void)
+{
+       uint soc_sbmr = readl(SRC_BASE_ADDR + 0x4);

(struct src)->sbmr1? (from imx-regs.h)

arch/arm/cpu/armv7/mx6/soc.c void s_init(void) · line 249

Quoted 1 line
arch/arm/cpu/armv7/mx6/soc.c +1 -0
+       uint bt_mem_ctl = (soc_sbmr & 0x000000FF) >> 4 ;

You may want a macro here, but certainly don't need the low four bits set.

Quoted 29 lines
arch/arm/cpu/armv7/mx6/soc.c +29 -0
+       uint bt_mem_type = (soc_sbmr & 0x00000008) >> 3;
+       uint bt_mem_mmc = (soc_sbmr & 0x00001000) >> 12;
+
+       switch (bt_mem_ctl) {
+       case 0x0:
+               if (bt_mem_type)
+                       return MX6_ONE_NAND_BOOT;
+               else
+                       return MX6_WEIM_NOR_BOOT;
+               break;
+       case 0x2:
+                       return MX6_SATA_BOOT;
+               break;
+       case 0x3:
+               if (bt_mem_type)
+                       return MX6_I2C_BOOT;
+               else
+                       return MX6_SPI_NOR_BOOT;
+               break;
+       case 0x4:
+       case 0x5:
+               if (bt_mem_mmc)
+                       return MX6_SD0_BOOT;
+               else
+                       return MX6_SD1_BOOT;
+               break;
+       case 0x6:
+       case 0x7:
+               return MX6_MMC_BOOT;

arch/arm/cpu/armv7/mx6/soc.c void s_init(void) · line 288

Quoted 10 lines
arch/arm/cpu/armv7/mx6/soc.c +10 -0
+               break;
+       case 0x8 ... 0xf:
+               return MX6_NAND_BOOT;
+               break;
+       default:
+               return MX6_UNKNOWN_BOOT;
+               break;
+       }
+}
+

These magic values are the same as those used in arch/arm/cpu/armv7/mx6/soc.c for the "bmode" command, so I'd personally like to see some constants...

I'd also like to know where the definitive reference for these is. I have a spreadsheet of dubious ancestry, and the current RM has the very helpful comment "Refer to the fusemap", and the fuse map is similarly opaque.

Troy? Anyone?

Quoted 17 lines
arch/arm/cpu/armv7/mx6/soc.c +0 -0
  #ifdef CONFIG_IMX_HDMI
  void imx_enable_hdmi_phy(void)
  {
arch/arm/include/asm/arch-mx6/sys_proto.h +5 -0
index 8c21364..b26955e 100644
@@ -17,6 +17,21 @@
  #define MXC_CPU_MX6SOLO                0x62
  #define MXC_CPU_MX6Q           0x63
 
+enum mx6_boot_device {
+        MX6_SD0_BOOT,
+        MX6_SD1_BOOT,
+        MX6_MMC_BOOT,
+        MX6_NAND_BOOT,

arch/arm/include/asm/arch-mx6/sys_proto.h line 34

Quoted 10 lines
arch/arm/include/asm/arch-mx6/sys_proto.h +10 -0
+        MX6_SATA_BOOT,
+        MX6_WEIM_NOR_BOOT,
+        MX6_ONE_NAND_BOOT,
+        MX6_PATA_BOOT,
+        MX6_I2C_BOOT,
+        MX6_SPI_NOR_BOOT,
+        MX6_UNKNOWN_BOOT,
+        MX6_BOOT_DEV_NUM = MX6_UNKNOWN_BOOT,
+};
+

It might make sense to just place these into the soc_boot_modes table, gain "bmode" support for all of them, and have imx_get_boot_device() walk the table.

At the moment, it appears that only USB, SATA, SPI-NOR, and SD card are supported by "bmode".

Regards,

Eric