public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode
@ 2013-01-28 10:39 Vivek Gautam
  2013-02-04 21:26 ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Vivek Gautam @ 2013-01-28 10:39 UTC (permalink / raw)
  To: u-boot

Exynos5250 supports secondary USB device boot mode. If the iROM fails
to download u-boot from the primary boot device (such as SD or eMMC),
it will try to retrieve from the secondary boot device (such as USB).

Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
---

NOTE:
 - Based on 'master' branch of u-boot-samsung.
 - Tested with smdk5250 for usb download mode.

 board/samsung/smdk5250/spl_boot.c |   40 +++++++++++++++++++++++++++++++++++-
 include/configs/exynos5250-dt.h   |    5 ++++
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c
index d8f3c1e..c0bcf46 100644
--- a/board/samsung/smdk5250/spl_boot.c
+++ b/board/samsung/smdk5250/spl_boot.c
@@ -32,6 +32,21 @@ enum boot_mode {
 };
 
 	typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+	typedef u32 (*usb_copy_func_t)(void);
+
+/*
+ * Set/clear program flow prediction and return the previous state.
+ */
+static int config_branch_prediction(int set_cr_z)
+{
+	unsigned int cr;
+
+	/* System Control Register: 11th bit Z Branch prediction enable */
+	cr = get_cr();
+	set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
+
+	return cr & CR_Z;
+}
 
 /*
 * Copy U-boot from mmc to RAM:
@@ -41,10 +56,20 @@ enum boot_mode {
 void copy_uboot_to_ram(void)
 {
 	spi_copy_func_t spi_copy;
-	enum boot_mode bootmode;
+	usb_copy_func_t usb_copy;
+
+	int is_cr_z_set;
+	unsigned int sec_boot_check;
+	enum boot_mode bootmode = BOOT_MODE_OM;
 	u32 (*copy_bl2)(u32, u32, u32);
 
-	bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
+	/* Read iRAM location to check for secondary USB boot mode */
+	sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
+	if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
+		bootmode = BOOT_MODE_USB;
+
+	if (bootmode == BOOT_MODE_OM)
+		bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
 
 	switch (bootmode) {
 	case BOOT_MODE_SERIAL:
@@ -57,6 +82,17 @@ void copy_uboot_to_ram(void)
 		copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
 						CONFIG_SYS_TEXT_BASE);
 		break;
+	case BOOT_MODE_USB:
+		/*
+		 * iROM needs program flow prediction to be disabled
+		 * before copy from USB device to RAM
+		 */
+		is_cr_z_set = config_branch_prediction(0);
+		usb_copy = *(usb_copy_func_t *)
+				EXYNOS_COPY_USB_FNPTR_ADDR;
+		usb_copy();
+		config_branch_prediction(is_cr_z_set);
+		break;
 	default:
 		break;
 	}
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index cabd2f2..6728b0e 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -123,6 +123,11 @@
 #define CONFIG_USB_EHCI_EXYNOS
 #define CONFIG_USB_STORAGE
 
+/* USB boot mode */
+#define EXYNOS_COPY_USB_FNPTR_ADDR	0x02020070
+#define EXYNOS_USB_SECONDARY_BOOT	0xfeed0002
+#define EXYNOS_IRAM_SECONDARY_BASE	0x02020018
+
 /* MMC SPL */
 #define CONFIG_SPL
 #define COPY_BL2_FNPTR_ADDR	0x02020030
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode
  2013-01-28 10:39 [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode Vivek Gautam
@ 2013-02-04 21:26 ` Simon Glass
  2013-02-06  5:04   ` Vivek Gautam
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2013-02-04 21:26 UTC (permalink / raw)
  To: u-boot

Hi,

On Mon, Jan 28, 2013 at 2:39 AM, Vivek Gautam <gautam.vivek@samsung.com> wrote:
> Exynos5250 supports secondary USB device boot mode. If the iROM fails
> to download u-boot from the primary boot device (such as SD or eMMC),
> it will try to retrieve from the secondary boot device (such as USB).
>
> Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>

Acked-by: Simon Glass <sjg@chromium.org>

But please see comment below.

> ---
>
> NOTE:
>  - Based on 'master' branch of u-boot-samsung.
>  - Tested with smdk5250 for usb download mode.
>
>  board/samsung/smdk5250/spl_boot.c |   40 +++++++++++++++++++++++++++++++++++-
>  include/configs/exynos5250-dt.h   |    5 ++++
>  2 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c
> index d8f3c1e..c0bcf46 100644
> --- a/board/samsung/smdk5250/spl_boot.c
> +++ b/board/samsung/smdk5250/spl_boot.c
> @@ -32,6 +32,21 @@ enum boot_mode {
>  };
>
>         typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
> +       typedef u32 (*usb_copy_func_t)(void);
> +
> +/*
> + * Set/clear program flow prediction and return the previous state.
> + */
> +static int config_branch_prediction(int set_cr_z)
> +{
> +       unsigned int cr;
> +
> +       /* System Control Register: 11th bit Z Branch prediction enable */
> +       cr = get_cr();
> +       set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
> +
> +       return cr & CR_Z;
> +}
>
>  /*
>  * Copy U-boot from mmc to RAM:
> @@ -41,10 +56,20 @@ enum boot_mode {
>  void copy_uboot_to_ram(void)
>  {
>         spi_copy_func_t spi_copy;
> -       enum boot_mode bootmode;
> +       usb_copy_func_t usb_copy;
> +
> +       int is_cr_z_set;
> +       unsigned int sec_boot_check;
> +       enum boot_mode bootmode = BOOT_MODE_OM;
>         u32 (*copy_bl2)(u32, u32, u32);
>
> -       bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
> +       /* Read iRAM location to check for secondary USB boot mode */
> +       sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
> +       if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
> +               bootmode = BOOT_MODE_USB;
> +
> +       if (bootmode == BOOT_MODE_OM)
> +               bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>
>         switch (bootmode) {
>         case BOOT_MODE_SERIAL:
> @@ -57,6 +82,17 @@ void copy_uboot_to_ram(void)
>                 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
>                                                 CONFIG_SYS_TEXT_BASE);
>                 break;
> +       case BOOT_MODE_USB:
> +               /*
> +                * iROM needs program flow prediction to be disabled
> +                * before copy from USB device to RAM
> +                */
> +               is_cr_z_set = config_branch_prediction(0);
> +               usb_copy = *(usb_copy_func_t *)
> +                               EXYNOS_COPY_USB_FNPTR_ADDR;
> +               usb_copy();
> +               config_branch_prediction(is_cr_z_set);
> +               break;
>         default:
>                 break;
>         }
> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
> index cabd2f2..6728b0e 100644
> --- a/include/configs/exynos5250-dt.h
> +++ b/include/configs/exynos5250-dt.h
> @@ -123,6 +123,11 @@
>  #define CONFIG_USB_EHCI_EXYNOS
>  #define CONFIG_USB_STORAGE
>
> +/* USB boot mode */
> +#define EXYNOS_COPY_USB_FNPTR_ADDR     0x02020070
> +#define EXYNOS_USB_SECONDARY_BOOT      0xfeed0002
> +#define EXYNOS_IRAM_SECONDARY_BASE     0x02020018


What happened to the function pointer table patch?

> +
>  /* MMC SPL */
>  #define CONFIG_SPL
>  #define COPY_BL2_FNPTR_ADDR    0x02020030
> --
> 1.7.6.5
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode
  2013-02-04 21:26 ` Simon Glass
@ 2013-02-06  5:04   ` Vivek Gautam
  2013-04-13 14:20     ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Vivek Gautam @ 2013-02-06  5:04 UTC (permalink / raw)
  To: u-boot

Hi Simon,


On Tue, Feb 5, 2013 at 2:56 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi,
>
> On Mon, Jan 28, 2013 at 2:39 AM, Vivek Gautam <gautam.vivek@samsung.com> wrote:
>> Exynos5250 supports secondary USB device boot mode. If the iROM fails
>> to download u-boot from the primary boot device (such as SD or eMMC),
>> it will try to retrieve from the secondary boot device (such as USB).
>>
>> Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>
> Acked-by: Simon Glass <sjg@chromium.org>
>

Thanks for reviewing.

> But please see comment below.
>
>> ---
>>
>> NOTE:
>>  - Based on 'master' branch of u-boot-samsung.
>>  - Tested with smdk5250 for usb download mode.
>>
>>  board/samsung/smdk5250/spl_boot.c |   40 +++++++++++++++++++++++++++++++++++-
>>  include/configs/exynos5250-dt.h   |    5 ++++
>>  2 files changed, 43 insertions(+), 2 deletions(-)
>>
>> diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c
>> index d8f3c1e..c0bcf46 100644
>> --- a/board/samsung/smdk5250/spl_boot.c
>> +++ b/board/samsung/smdk5250/spl_boot.c
>> @@ -32,6 +32,21 @@ enum boot_mode {
>>  };
>>
>>         typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
>> +       typedef u32 (*usb_copy_func_t)(void);
>> +
>> +/*
>> + * Set/clear program flow prediction and return the previous state.
>> + */
>> +static int config_branch_prediction(int set_cr_z)
>> +{
>> +       unsigned int cr;
>> +
>> +       /* System Control Register: 11th bit Z Branch prediction enable */
>> +       cr = get_cr();
>> +       set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
>> +
>> +       return cr & CR_Z;
>> +}
>>
>>  /*
>>  * Copy U-boot from mmc to RAM:
>> @@ -41,10 +56,20 @@ enum boot_mode {
>>  void copy_uboot_to_ram(void)
>>  {
>>         spi_copy_func_t spi_copy;
>> -       enum boot_mode bootmode;
>> +       usb_copy_func_t usb_copy;
>> +
>> +       int is_cr_z_set;
>> +       unsigned int sec_boot_check;
>> +       enum boot_mode bootmode = BOOT_MODE_OM;
>>         u32 (*copy_bl2)(u32, u32, u32);
>>
>> -       bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>> +       /* Read iRAM location to check for secondary USB boot mode */
>> +       sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
>> +       if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
>> +               bootmode = BOOT_MODE_USB;
>> +
>> +       if (bootmode == BOOT_MODE_OM)
>> +               bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>
>>         switch (bootmode) {
>>         case BOOT_MODE_SERIAL:
>> @@ -57,6 +82,17 @@ void copy_uboot_to_ram(void)
>>                 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
>>                                                 CONFIG_SYS_TEXT_BASE);
>>                 break;
>> +       case BOOT_MODE_USB:
>> +               /*
>> +                * iROM needs program flow prediction to be disabled
>> +                * before copy from USB device to RAM
>> +                */
>> +               is_cr_z_set = config_branch_prediction(0);
>> +               usb_copy = *(usb_copy_func_t *)
>> +                               EXYNOS_COPY_USB_FNPTR_ADDR;
>> +               usb_copy();
>> +               config_branch_prediction(is_cr_z_set);
>> +               break;
>>         default:
>>                 break;
>>         }
>> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
>> index cabd2f2..6728b0e 100644
>> --- a/include/configs/exynos5250-dt.h
>> +++ b/include/configs/exynos5250-dt.h
>> @@ -123,6 +123,11 @@
>>  #define CONFIG_USB_EHCI_EXYNOS
>>  #define CONFIG_USB_STORAGE
>>
>> +/* USB boot mode */
>> +#define EXYNOS_COPY_USB_FNPTR_ADDR     0x02020070
>> +#define EXYNOS_USB_SECONDARY_BOOT      0xfeed0002
>> +#define EXYNOS_IRAM_SECONDARY_BASE     0x02020018
>
>
> What happened to the function pointer table patch?
>
I think i missed that patch from Amar, :-(
will remove these #defines and use the function pointer table instead.

>> +
>>  /* MMC SPL */
>>  #define CONFIG_SPL
>>  #define COPY_BL2_FNPTR_ADDR    0x02020030
>> --
>> 1.7.6.5
>>
>


-- 
Thanks & Regards
Vivek

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode
  2013-02-06  5:04   ` Vivek Gautam
@ 2013-04-13 14:20     ` Simon Glass
  2013-04-15  5:36       ` Vivek Gautam
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2013-04-13 14:20 UTC (permalink / raw)
  To: u-boot

Hi,

On Tue, Feb 5, 2013 at 9:04 PM, Vivek Gautam <gautamvivek1987@gmail.com> wrote:
> Hi Simon,
>
>
> On Tue, Feb 5, 2013 at 2:56 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi,
>>
>> On Mon, Jan 28, 2013 at 2:39 AM, Vivek Gautam <gautam.vivek@samsung.com> wrote:
>>> Exynos5250 supports secondary USB device boot mode. If the iROM fails
>>> to download u-boot from the primary boot device (such as SD or eMMC),
>>> it will try to retrieve from the secondary boot device (such as USB).
>>>
>>> Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>>
>> Acked-by: Simon Glass <sjg@chromium.org>
>>
>
> Thanks for reviewing.
>
>> But please see comment below.
>>
>>> ---
>>>
>>> NOTE:
>>>  - Based on 'master' branch of u-boot-samsung.
>>>  - Tested with smdk5250 for usb download mode.
>>>
>>>  board/samsung/smdk5250/spl_boot.c |   40 +++++++++++++++++++++++++++++++++++-
>>>  include/configs/exynos5250-dt.h   |    5 ++++
>>>  2 files changed, 43 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c
>>> index d8f3c1e..c0bcf46 100644
>>> --- a/board/samsung/smdk5250/spl_boot.c
>>> +++ b/board/samsung/smdk5250/spl_boot.c
>>> @@ -32,6 +32,21 @@ enum boot_mode {
>>>  };
>>>
>>>         typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
>>> +       typedef u32 (*usb_copy_func_t)(void);
>>> +
>>> +/*
>>> + * Set/clear program flow prediction and return the previous state.
>>> + */
>>> +static int config_branch_prediction(int set_cr_z)
>>> +{
>>> +       unsigned int cr;
>>> +
>>> +       /* System Control Register: 11th bit Z Branch prediction enable */
>>> +       cr = get_cr();
>>> +       set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
>>> +
>>> +       return cr & CR_Z;
>>> +}
>>>
>>>  /*
>>>  * Copy U-boot from mmc to RAM:
>>> @@ -41,10 +56,20 @@ enum boot_mode {
>>>  void copy_uboot_to_ram(void)
>>>  {
>>>         spi_copy_func_t spi_copy;
>>> -       enum boot_mode bootmode;
>>> +       usb_copy_func_t usb_copy;
>>> +
>>> +       int is_cr_z_set;
>>> +       unsigned int sec_boot_check;
>>> +       enum boot_mode bootmode = BOOT_MODE_OM;
>>>         u32 (*copy_bl2)(u32, u32, u32);
>>>
>>> -       bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>> +       /* Read iRAM location to check for secondary USB boot mode */
>>> +       sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
>>> +       if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
>>> +               bootmode = BOOT_MODE_USB;
>>> +
>>> +       if (bootmode == BOOT_MODE_OM)
>>> +               bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>>
>>>         switch (bootmode) {
>>>         case BOOT_MODE_SERIAL:
>>> @@ -57,6 +82,17 @@ void copy_uboot_to_ram(void)
>>>                 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
>>>                                                 CONFIG_SYS_TEXT_BASE);
>>>                 break;
>>> +       case BOOT_MODE_USB:
>>> +               /*
>>> +                * iROM needs program flow prediction to be disabled
>>> +                * before copy from USB device to RAM
>>> +                */
>>> +               is_cr_z_set = config_branch_prediction(0);
>>> +               usb_copy = *(usb_copy_func_t *)
>>> +                               EXYNOS_COPY_USB_FNPTR_ADDR;
>>> +               usb_copy();
>>> +               config_branch_prediction(is_cr_z_set);
>>> +               break;
>>>         default:
>>>                 break;
>>>         }
>>> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
>>> index cabd2f2..6728b0e 100644
>>> --- a/include/configs/exynos5250-dt.h
>>> +++ b/include/configs/exynos5250-dt.h
>>> @@ -123,6 +123,11 @@
>>>  #define CONFIG_USB_EHCI_EXYNOS
>>>  #define CONFIG_USB_STORAGE
>>>
>>> +/* USB boot mode */
>>> +#define EXYNOS_COPY_USB_FNPTR_ADDR     0x02020070
>>> +#define EXYNOS_USB_SECONDARY_BOOT      0xfeed0002
>>> +#define EXYNOS_IRAM_SECONDARY_BASE     0x02020018
>>
>>
>> What happened to the function pointer table patch?
>>
> I think i missed that patch from Amar, :-(
> will remove these #defines and use the function pointer table instead.

I notice that this patch has not made it to mainline. It really should
be there since without it it is not possible to USB boot on snow,
which makes development awkward.

Can we get this applied in time for the release? The comment made
above can be dealt with later perhaps.

Regards,
Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode
  2013-04-13 14:20     ` Simon Glass
@ 2013-04-15  5:36       ` Vivek Gautam
  2013-04-17  2:09         ` Minkyu Kang
  0 siblings, 1 reply; 6+ messages in thread
From: Vivek Gautam @ 2013-04-15  5:36 UTC (permalink / raw)
  To: u-boot

Hi,


On Sat, Apr 13, 2013 at 7:50 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi,
>
> On Tue, Feb 5, 2013 at 9:04 PM, Vivek Gautam <gautamvivek1987@gmail.com> wrote:
>> Hi Simon,
>>
>>
>> On Tue, Feb 5, 2013 at 2:56 AM, Simon Glass <sjg@chromium.org> wrote:
>>> Hi,
>>>
>>> On Mon, Jan 28, 2013 at 2:39 AM, Vivek Gautam <gautam.vivek@samsung.com> wrote:
>>>> Exynos5250 supports secondary USB device boot mode. If the iROM fails
>>>> to download u-boot from the primary boot device (such as SD or eMMC),
>>>> it will try to retrieve from the secondary boot device (such as USB).
>>>>
>>>> Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>>>
>>> Acked-by: Simon Glass <sjg@chromium.org>
>>>
>>
>> Thanks for reviewing.
>>
>>> But please see comment below.
>>>
>>>> ---
>>>>
>>>> NOTE:
>>>>  - Based on 'master' branch of u-boot-samsung.
>>>>  - Tested with smdk5250 for usb download mode.
>>>>
>>>>  board/samsung/smdk5250/spl_boot.c |   40 +++++++++++++++++++++++++++++++++++-
>>>>  include/configs/exynos5250-dt.h   |    5 ++++
>>>>  2 files changed, 43 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c
>>>> index d8f3c1e..c0bcf46 100644
>>>> --- a/board/samsung/smdk5250/spl_boot.c
>>>> +++ b/board/samsung/smdk5250/spl_boot.c
>>>> @@ -32,6 +32,21 @@ enum boot_mode {
>>>>  };
>>>>
>>>>         typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
>>>> +       typedef u32 (*usb_copy_func_t)(void);
>>>> +
>>>> +/*
>>>> + * Set/clear program flow prediction and return the previous state.
>>>> + */
>>>> +static int config_branch_prediction(int set_cr_z)
>>>> +{
>>>> +       unsigned int cr;
>>>> +
>>>> +       /* System Control Register: 11th bit Z Branch prediction enable */
>>>> +       cr = get_cr();
>>>> +       set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
>>>> +
>>>> +       return cr & CR_Z;
>>>> +}
>>>>
>>>>  /*
>>>>  * Copy U-boot from mmc to RAM:
>>>> @@ -41,10 +56,20 @@ enum boot_mode {
>>>>  void copy_uboot_to_ram(void)
>>>>  {
>>>>         spi_copy_func_t spi_copy;
>>>> -       enum boot_mode bootmode;
>>>> +       usb_copy_func_t usb_copy;
>>>> +
>>>> +       int is_cr_z_set;
>>>> +       unsigned int sec_boot_check;
>>>> +       enum boot_mode bootmode = BOOT_MODE_OM;
>>>>         u32 (*copy_bl2)(u32, u32, u32);
>>>>
>>>> -       bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>>> +       /* Read iRAM location to check for secondary USB boot mode */
>>>> +       sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
>>>> +       if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
>>>> +               bootmode = BOOT_MODE_USB;
>>>> +
>>>> +       if (bootmode == BOOT_MODE_OM)
>>>> +               bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>>>
>>>>         switch (bootmode) {
>>>>         case BOOT_MODE_SERIAL:
>>>> @@ -57,6 +82,17 @@ void copy_uboot_to_ram(void)
>>>>                 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
>>>>                                                 CONFIG_SYS_TEXT_BASE);
>>>>                 break;
>>>> +       case BOOT_MODE_USB:
>>>> +               /*
>>>> +                * iROM needs program flow prediction to be disabled
>>>> +                * before copy from USB device to RAM
>>>> +                */
>>>> +               is_cr_z_set = config_branch_prediction(0);
>>>> +               usb_copy = *(usb_copy_func_t *)
>>>> +                               EXYNOS_COPY_USB_FNPTR_ADDR;
>>>> +               usb_copy();
>>>> +               config_branch_prediction(is_cr_z_set);
>>>> +               break;
>>>>         default:
>>>>                 break;
>>>>         }
>>>> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
>>>> index cabd2f2..6728b0e 100644
>>>> --- a/include/configs/exynos5250-dt.h
>>>> +++ b/include/configs/exynos5250-dt.h
>>>> @@ -123,6 +123,11 @@
>>>>  #define CONFIG_USB_EHCI_EXYNOS
>>>>  #define CONFIG_USB_STORAGE
>>>>
>>>> +/* USB boot mode */
>>>> +#define EXYNOS_COPY_USB_FNPTR_ADDR     0x02020070
>>>> +#define EXYNOS_USB_SECONDARY_BOOT      0xfeed0002
>>>> +#define EXYNOS_IRAM_SECONDARY_BASE     0x02020018
>>>
>>>
>>> What happened to the function pointer table patch?
>>>
>> I think i missed that patch from Amar, :-(
>> will remove these #defines and use the function pointer table instead.
>
> I notice that this patch has not made it to mainline. It really should
> be there since without it it is not possible to USB boot on snow,
> which makes development awkward.
>
> Can we get this applied in time for the release? The comment made
> above can be dealt with later perhaps.

Sorry for not responding to this patch for long, but was still waiting
for Amar's emmc booting patch
to get merged (which carries the funtion pointer table).

Hi Minkyu,
Is it fine with you if we pull this in for now, and post a patch later
to make things aligned
with funtion-pointer table ?

This patch cleanly applies on u-boot-samsung/master.


-- 
Thanks & Regards
Vivek

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode
  2013-04-15  5:36       ` Vivek Gautam
@ 2013-04-17  2:09         ` Minkyu Kang
  0 siblings, 0 replies; 6+ messages in thread
From: Minkyu Kang @ 2013-04-17  2:09 UTC (permalink / raw)
  To: u-boot

On 15/04/13 14:36, Vivek Gautam wrote:
> Hi,
> 
> 
> On Sat, Apr 13, 2013 at 7:50 PM, Simon Glass <sjg@chromium.org> wrote:
>> Hi,
>>
>> On Tue, Feb 5, 2013 at 9:04 PM, Vivek Gautam <gautamvivek1987@gmail.com> wrote:
>>> Hi Simon,
>>>
>>>
>>> On Tue, Feb 5, 2013 at 2:56 AM, Simon Glass <sjg@chromium.org> wrote:
>>>> Hi,
>>>>
>>>> On Mon, Jan 28, 2013 at 2:39 AM, Vivek Gautam <gautam.vivek@samsung.com> wrote:
>>>>> Exynos5250 supports secondary USB device boot mode. If the iROM fails
>>>>> to download u-boot from the primary boot device (such as SD or eMMC),
>>>>> it will try to retrieve from the secondary boot device (such as USB).
>>>>>
>>>>> Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
>>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>>>>
>>>> Acked-by: Simon Glass <sjg@chromium.org>
>>>>
>>>
>>> Thanks for reviewing.
>>>
>>>> But please see comment below.
>>>>
>>>>> ---
>>>>>
>>>>> NOTE:
>>>>>  - Based on 'master' branch of u-boot-samsung.
>>>>>  - Tested with smdk5250 for usb download mode.
>>>>>
>>>>>  board/samsung/smdk5250/spl_boot.c |   40 +++++++++++++++++++++++++++++++++++-
>>>>>  include/configs/exynos5250-dt.h   |    5 ++++
>>>>>  2 files changed, 43 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c
>>>>> index d8f3c1e..c0bcf46 100644
>>>>> --- a/board/samsung/smdk5250/spl_boot.c
>>>>> +++ b/board/samsung/smdk5250/spl_boot.c
>>>>> @@ -32,6 +32,21 @@ enum boot_mode {
>>>>>  };
>>>>>
>>>>>         typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
>>>>> +       typedef u32 (*usb_copy_func_t)(void);
>>>>> +
>>>>> +/*
>>>>> + * Set/clear program flow prediction and return the previous state.
>>>>> + */
>>>>> +static int config_branch_prediction(int set_cr_z)
>>>>> +{
>>>>> +       unsigned int cr;
>>>>> +
>>>>> +       /* System Control Register: 11th bit Z Branch prediction enable */
>>>>> +       cr = get_cr();
>>>>> +       set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
>>>>> +
>>>>> +       return cr & CR_Z;
>>>>> +}
>>>>>
>>>>>  /*
>>>>>  * Copy U-boot from mmc to RAM:
>>>>> @@ -41,10 +56,20 @@ enum boot_mode {
>>>>>  void copy_uboot_to_ram(void)
>>>>>  {
>>>>>         spi_copy_func_t spi_copy;
>>>>> -       enum boot_mode bootmode;
>>>>> +       usb_copy_func_t usb_copy;
>>>>> +
>>>>> +       int is_cr_z_set;
>>>>> +       unsigned int sec_boot_check;
>>>>> +       enum boot_mode bootmode = BOOT_MODE_OM;
>>>>>         u32 (*copy_bl2)(u32, u32, u32);
>>>>>
>>>>> -       bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>>>> +       /* Read iRAM location to check for secondary USB boot mode */
>>>>> +       sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
>>>>> +       if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
>>>>> +               bootmode = BOOT_MODE_USB;
>>>>> +
>>>>> +       if (bootmode == BOOT_MODE_OM)
>>>>> +               bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
>>>>>
>>>>>         switch (bootmode) {
>>>>>         case BOOT_MODE_SERIAL:
>>>>> @@ -57,6 +82,17 @@ void copy_uboot_to_ram(void)
>>>>>                 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
>>>>>                                                 CONFIG_SYS_TEXT_BASE);
>>>>>                 break;
>>>>> +       case BOOT_MODE_USB:
>>>>> +               /*
>>>>> +                * iROM needs program flow prediction to be disabled
>>>>> +                * before copy from USB device to RAM
>>>>> +                */
>>>>> +               is_cr_z_set = config_branch_prediction(0);
>>>>> +               usb_copy = *(usb_copy_func_t *)
>>>>> +                               EXYNOS_COPY_USB_FNPTR_ADDR;
>>>>> +               usb_copy();
>>>>> +               config_branch_prediction(is_cr_z_set);
>>>>> +               break;
>>>>>         default:
>>>>>                 break;
>>>>>         }
>>>>> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
>>>>> index cabd2f2..6728b0e 100644
>>>>> --- a/include/configs/exynos5250-dt.h
>>>>> +++ b/include/configs/exynos5250-dt.h
>>>>> @@ -123,6 +123,11 @@
>>>>>  #define CONFIG_USB_EHCI_EXYNOS
>>>>>  #define CONFIG_USB_STORAGE
>>>>>
>>>>> +/* USB boot mode */
>>>>> +#define EXYNOS_COPY_USB_FNPTR_ADDR     0x02020070
>>>>> +#define EXYNOS_USB_SECONDARY_BOOT      0xfeed0002
>>>>> +#define EXYNOS_IRAM_SECONDARY_BASE     0x02020018
>>>>
>>>>
>>>> What happened to the function pointer table patch?
>>>>
>>> I think i missed that patch from Amar, :-(
>>> will remove these #defines and use the function pointer table instead.
>>
>> I notice that this patch has not made it to mainline. It really should
>> be there since without it it is not possible to USB boot on snow,
>> which makes development awkward.
>>
>> Can we get this applied in time for the release? The comment made
>> above can be dealt with later perhaps.
> 
> Sorry for not responding to this patch for long, but was still waiting
> for Amar's emmc booting patch
> to get merged (which carries the funtion pointer table).
> 
> Hi Minkyu,
> Is it fine with you if we pull this in for now, and post a patch later
> to make things aligned
> with funtion-pointer table ?
> 
> This patch cleanly applies on u-boot-samsung/master.
> 
> 

applied to u-boot-samsung

Thanks,
Minkyu Kang.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-17  2:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-28 10:39 [U-Boot] [PATCH] Exynos5: Add support for USB download boot mode Vivek Gautam
2013-02-04 21:26 ` Simon Glass
2013-02-06  5:04   ` Vivek Gautam
2013-04-13 14:20     ` Simon Glass
2013-04-15  5:36       ` Vivek Gautam
2013-04-17  2:09         ` Minkyu Kang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox