[U-Boot] [PATCH] imx SPL: enable boot from eMMC boot partitions.

2014-12-12 Thread Pierre Aubert
Signed-off-by: Pierre Aubert 
---
 arch/arm/imx-common/spl.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
index 477c38c..ac6e40e 100644
--- a/arch/arm/imx-common/spl.c
+++ b/arch/arm/imx-common/spl.c
@@ -68,8 +68,10 @@ u32 spl_boot_mode(void)
/* for MMC return either RAW or FAT mode */
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
-#ifdef CONFIG_SPL_FAT_SUPPORT
+#if defined(CONFIG_SPL_FAT_SUPPORT)
return MMCSD_MODE_FS;
+#elif defined(CONFIG_SUPPORT_EMMC_BOOT)
+   return MMCSD_MODE_EMMCBOOT;
 #else
return MMCSD_MODE_RAW;
 #endif
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] imx: complete the definition of the I2C_PADS macros

2014-12-05 Thread Pierre Aubert
Complete the definition of the macros I2C_PADS and I2C_PADS_INFO for use
without multiple SoC type. Usefull when the same board have configurations
with or without SPL.

Cc: Stefano Babic 
Cc: Nikita Kiryanov 

Signed-off-by: Pierre Aubert 
---
 arch/arm/include/asm/imx-common/mxc_i2c.h |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/imx-common/mxc_i2c.h 
b/arch/arm/include/asm/imx-common/mxc_i2c.h
index af86163..459a2e9 100644
--- a/arch/arm/include/asm/imx-common/mxc_i2c.h
+++ b/arch/arm/include/asm/imx-common/mxc_i2c.h
@@ -50,6 +50,22 @@ struct i2c_pads_info {
 #define I2C_PADS_INFO(name)\
(is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) ? \
&mx6q_##name : &mx6s_##name
+#else
+#define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \
+   struct i2c_pads_info mx6_##name = { \
+   .scl = {\
+   .i2c_mode = MX6_##scl_i2c,  \
+   .gpio_mode = MX6_##scl_gpio,\
+   .gp = scl_gp,   \
+   },  \
+   .sda = {\
+   .i2c_mode = MX6_##sda_i2c,  \
+   .gpio_mode = MX6_##sda_gpio,\
+   .gp = sda_gp,   \
+   }   \
+   };  \
+
+#define I2C_PADS_INFO(name) &mx6_##name
 #endif
 
 int setup_i2c(unsigned i2c_index, int speed, int slave_addr,
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] imx: fix IOMUX_PADS and SETUP_IOMUX_PAD macros definitions.

2014-12-05 Thread Pierre Aubert
When CONFIG_MX6QDL is undefined, these definitions must be coherent with
those in mx6-pins.h. The prefix is MX6 regardless of the type of SoC.

Cc: Tim Harvey 
Cc: Stefano Babic 

Signed-off-by: Pierre Aubert 
---
 arch/arm/include/asm/imx-common/iomux-v3.h |   10 ++
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/imx-common/iomux-v3.h 
b/arch/arm/include/asm/imx-common/iomux-v3.h
index e0a49be..a1004b5 100644
--- a/arch/arm/include/asm/imx-common/iomux-v3.h
+++ b/arch/arm/include/asm/imx-common/iomux-v3.h
@@ -199,16 +199,10 @@ if (is_cpu_type(MXC_CPU_MX6Q)) {  
\
 }
 #define SETUP_IOMUX_PADS(x)\
imx_iomux_v3_setup_multiple_pads(x, ARRAY_SIZE(x)/2)
-#elif defined(CONFIG_MX6Q) || defined(CONFIG_MX6D)
-#define IOMUX_PADS(x) MX6Q_##x
-#define SETUP_IOMUX_PAD(def)   \
-   imx_iomux_v3_setup_pad(MX6Q_##def);
-#define SETUP_IOMUX_PADS(x)\
-   imx_iomux_v3_setup_multiple_pads(x, ARRAY_SIZE(x))
 #else
-#define IOMUX_PADS(x) MX6DL_##x
+#define IOMUX_PADS(x) MX6_##x
 #define SETUP_IOMUX_PAD(def)   \
-   imx_iomux_v3_setup_pad(MX6DL_##def);
+   imx_iomux_v3_setup_pad(MX6_##def);
 #define SETUP_IOMUX_PADS(x)\
imx_iomux_v3_setup_multiple_pads(x, ARRAY_SIZE(x))
 #endif
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3] fs/ext4/ext4fs.c, fs/fs.c fs/fat/fat_write.c: Adjust 64bit math methods

2014-12-01 Thread Pierre Aubert
Hi,

Tested on an iMX6 SabreSD board. Issue is fixed. There's just a warning
about  trailing whitespaces at line 75 of the patch.

Tested-by: Pierre Aubert 

Thanks
Pierre


Tom Rini wrote
> The changes to introduce loff_t into filesize means that we need to do
> 64bit math on 32bit platforms.  Make sure we use the right wrappers for
> these operations.
> 
> Cc: Daniel Schwierzeck <

> daniel.schwierzeck@

> >
> Cc: Suriyan Ramasami <

> suriyan.r@

> >
> Cc: Simon Glass <

> sjg@

> >
> Signed-off-by: Tom Rini <

> trini@

> >
> 
> ---
> Changes in v3:
> - Fix bug Simon pointed out in fs/fs.c
> 
> Changes in v2:
> - Correct fs/fat/fat_write.c
> ---
>  fs/ext4/ext4fs.c   |   11 ++-
>  fs/fat/fat_write.c |   10 ++
>  fs/fs.c|6 --
>  3 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
> index 943b5bc..258b9379 100644
> --- a/fs/ext4/ext4fs.c
> +++ b/fs/ext4/ext4fs.c
> @@ -25,6 +25,7 @@
>  #include 
> 
>  #include 
> 
>  #include "ext4_common.h"
> +#include 
> 
>  
>  int ext4fs_symlinknest;
>  struct ext_filesystem ext_fs;
> @@ -67,11 +68,11 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t
> pos,
>   if (len > filesize)
>   len = filesize;
>  
> - blockcnt = ((len + pos) + blocksize - 1) / blocksize;
> + blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize);
>  
> - for (i = pos / blocksize; i < blockcnt; i++) {
> + for (i = lldiv(pos, blocksize); i < blockcnt; i++) {
>   lbaint_t blknr;
> - int blockoff = pos % blocksize;
> + int blockoff = pos - (blocksize * i);
>   int blockend = blocksize;
>   int skipfirst = 0;
>   blknr = read_allocated_block(&(node->inode), i);
> @@ -82,7 +83,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t
> pos,
>  
>   /* Last block.  */
>   if (i == blockcnt - 1) {
> - blockend = (len + pos) % blocksize;
> + blockend = (len + pos) - (blocksize * i);
>  
>   /* The last portion is exactly blocksize. */
>   if (!blockend)
> @@ -90,7 +91,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t
> pos,
>   }
>  
>   /* First block. */
> - if (i == pos / blocksize) {
> + if (i == lldiv(pos, blocksize)) {
>   skipfirst = blockoff;
>   blockend -= skipfirst;
>   }
> diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
> index 88dd495..473723b 100644
> --- a/fs/fat/fat_write.c
> +++ b/fs/fat/fat_write.c
> @@ -13,6 +13,8 @@
>  #include <asm/byteorder.h>
>  #include 
> 
>  #include <linux/ctype.h>
> +#include 
> 
> +#include <linux/math64.h>
>  #include "fat.c"
>  
>  static void uppercase(char *str, int len)
> @@ -770,7 +772,7 @@ static void fill_dentry(fsdata *mydata, dir_entry
> *dentptr,
>   */
>  static int check_overflow(fsdata *mydata, __u32 clustnum, loff_t size)
>  {
> - __u32 startsect, sect_num;
> + __u32 startsect, sect_num, offset;
>  
>   if (clustnum > 0) {
>   startsect = mydata->data_begin +
> @@ -779,13 +781,13 @@ static int check_overflow(fsdata *mydata, __u32
> clustnum, loff_t size)
>   startsect = mydata->rootdir_sect;
>   }
>  
> - sect_num = size / mydata->sect_size;
> - if (size % mydata->sect_size)
> + sect_num = div_u64_rem(size, mydata->sect_size, &offset);
> + 
> + if (offset != 0)
>   sect_num++;
>  
>   if (startsect + sect_num > cur_part_info.start + total_sector)
>   return -1;
> -
>   return 0;
>  }
>  
> diff --git a/fs/fs.c b/fs/fs.c
> index 3da7860..ddd751c 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -23,6 +23,8 @@
>  #include 
> 
>  #include 
> 
>  #include <asm/io.h>
> +#include 
> 
> +#include <linux/math64.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -399,7 +401,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char
> * const argv[],
>   printf("%llu bytes read in %lu ms", len_read, time);
>   if (time > 0) {
>   puts(" (");
> - print_size(len_read / time * 1000, "/s");
> + print_size(div_u64(len_read, time) * 1000, "/s");
>   puts(")");
>   }
>   puts("\n");
&

Re: [U-Boot] [ANN] U-Boot v2015.01-rc2 released

2014-12-01 Thread Pierre Aubert
Hello Guillaume,


Guillaume Gardet wrote
> Le 25/11/2014 11:19, Lukasz Majewski a écrit :
>> Hi Guillaume,
>>
>>> Le 24/11/2014 23:13, Tom Rini a écrit :
>>>> Hey all,
>>>>
>>>> I've pushed v2015.01-rc2 out to the repository and tarballs should
>>>> exist soon.
>>>>
>>>> I'm tagging later in the day than I wanted to, but that's OK.
>>>>
>>>> There's a fair number of things that've gone in since -rc1, but I
>>>> think that's OK.  And there's a few things that still need to go in.
>>>>
>>>> For example, I just pushed the changes to allow bigger files to be
>>>> read but that's broken MIPS+private libgcc and ARM+hf toolchain and
>>>> others too.  I posted a patch for this and tested it locally with a
>>>> 32MB file but I'd like others to review too (Thanks Simon!) before
>>>> pushing it in.
>>>>
>>>> As always, if anything else is broken please speak up.
>>>
>>> I guess this the ARM+hf problem you mentioned:
>>> 
>>> LD  u-boot
>>> ld.bfd:
>>> error: /usr/lib/gcc/armv7hl-suse-linux-gnueabi/4.8/libgcc.a(bpabi.o)
>>> uses VFP register arguments, u-boot does not ld.bfd: failed to merge
>>> target specific data of
>>> file /usr/lib/gcc/armv7hl-suse-linux-gnueabi/4.8/libgcc.a(bpabi.o)
>>> ld.bfd:
>>> error: /usr/lib/gcc/armv7hl-suse-linux-gnueabi/4.8/libgcc.a(_divdi3.o)
>>> uses VFP register arguments, u-boot does not ld.bfd: failed to merge
>>> target specific data of
>>> file /usr/lib/gcc/armv7hl-suse-linux-gnueabi/4.8/libgcc.a(_divdi3.o)
>>> ld.bfd:
>>> error: /usr/lib/gcc/armv7hl-suse-linux-gnueabi/4.8/libgcc.a(_udivdi3.o)
>>> uses VFP register arguments, u-boot does not ld.bfd: failed to merge
>>> target specific data of
>>> file /usr/lib/gcc/armv7hl-suse-linux-gnueabi/4.8/libgcc.a(_udivdi3.o)
>>> 
>>>
>> I experience the same issue:
>>
>> Working toolchain:
>> /opt/eldk-5.4/armv7a/sysroots/i686-eldk-linux/usr/bin/armv7a-vfp-neon-linux-gnueabi/arm-linux-gnueabi-
>>
>> Toolchain with errors:
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/arm-linux-gnueabihf-
>>
>> Building smdk2410 board...
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/arm-linux-gnueabihf-ld.bfd:
>> error:
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/libgcc.a(bpabi.o)
>> uses VFP register arguments, u-boot does
>> not
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/arm-linux-gnueabihf-ld.bfd:
>> error:
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/libgcc.a(_divdi3.o)
>> uses VFP register arguments, u-boot does
>> not
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/arm-linux-gnueabihf-ld.bfd:
>> error:
>> /home/DIGITAL/l.majewski/gcc-linaro-arm-linux-gnueabihf-4.8-2013.12_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/libgcc.a(_udivdi3.o)
>> uses VFP register arguments, u-boot does not make: *** [u-boot] Error 1
>>
>>
>>
>>> Is there any pending patch to fix this one?
>> +1
> 
> 
> I got it compiling by removing -msoft-float flag:
> 
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index c339e6d..cd41e48 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -16,7 +16,7 @@ endif
>   LDFLAGS_FINAL += --gc-sections
>   PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \
>-fno-common -ffixed-r9
> -PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
> +PLATFORM_RELFLAGS += \
> $(call cc-option,-mshort-load-bytes,$(call
> cc-option,-malignment-traps,))
> 
>   # Support generic board on ARM
> 
> 
> 
> Is it an acceptable patch? If so, I can send it as a real patch.
> 
> 
> Guillaume

I experimented the same issue while building u-boot for the mx6dlsabresd
platform.
Your patch doesn't solve the issue. The boot is compiling and linking but
raise some hardware exception at runtime while loading files from fat
filesystems.

The patch http://patchwork.ozlabs.org/patch/415336/ solves the issue for the
iMX6.
Regards

Pierre Aubert



--
View this message in context: 
http://u-boot.10912.n7.nabble.com/ANN-U-Boot-v2015-01-rc2-released-tp197341p197861.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V5 3/3] eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

2014-04-24 Thread Pierre Aubert
This sub-command adds support for the RPMB partition of an eMMC:
* mmc rpmb key 
  Programs the authentication key in the eMMC This key can not
  be overwritten.
* mmc rpmb read   <#count> [address of key]
  Reads <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . If the optionnal
  address of the authentication key is provided, the
  Message Authentication Code (MAC) is verified on each
  block.
* mmc rpmb write   <#count> 
  Writes <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . The datas are signed
  with the key provided.
* mmc rpmb counter
  Returns the 'Write counter' of the RPMB partition.

The sub-command is conditional on compilation flag CONFIG_SUPPORT_EMMC_RPMB

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
CC: Wolfgang Denk 
---
Changes in V5: 
- move changelog to the right place

Changes in V4:
- use subcommand table for 'mmc' command and 'mmc rpmb' subcommand.
- add 'mmc info' subcommand, which is the same as mmcinfo.
  mmcinfo is kept for compatibility.
- add changelog in commit comments.

Changes in V3:
- add entries in README for configuration options related to eMMC.
- improved test for existence of RPMB partition.
- fix of coding issues.

V2: no changes

 README   |   10 +
 common/cmd_mmc.c |  806 ++
 2 files changed, 520 insertions(+), 296 deletions(-)

diff --git a/README b/README
index 52a92e7..518e209 100644
--- a/README
+++ b/README
@@ -1493,6 +1493,16 @@ The following options need to be configured:
CONFIG_SH_MMCIF_CLK
Define the clock frequency for MMCIF
 
+   CONFIG_GENERIC_MMC
+   Enable the generic MMC driver
+
+   CONFIG_SUPPORT_EMMC_BOOT
+   Enable some additional features of the eMMC boot partitions.
+
+   CONFIG_SUPPORT_EMMC_RPMB
+   Enable the commands for reading, writing and programming the
+   key for the Replay Protection Memory Block partition in eMMC.
+
 - USB Device Firmware Update (DFU) class support:
CONFIG_DFU_FUNCTION
This enables the USB portion of the DFU USB class
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..55af295 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -71,12 +71,6 @@ U_BOOT_CMD(
 );
 #else /* !CONFIG_GENERIC_MMC */
 
-enum mmc_state {
-   MMC_INVALID,
-   MMC_READ,
-   MMC_WRITE,
-   MMC_ERASE,
-};
 static void print_mmcinfo(struct mmc *mmc)
 {
printf("Device: %s\n", mmc->cfg->name);
@@ -98,7 +92,18 @@ static void print_mmcinfo(struct mmc *mmc)
 
printf("Bus Width: %d-bit\n", mmc->bus_width);
 }
-
+static struct mmc *init_mmc_device(int dev)
+{
+   struct mmc *mmc;
+   mmc = find_mmc_device(dev);
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", dev);
+   return NULL;
+   }
+   if (mmc_init(mmc))
+   return NULL;
+   return mmc;
+}
 static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[])
 {
struct mmc *mmc;
@@ -112,351 +117,546 @@ static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
}
}
 
-   mmc = find_mmc_device(curr_device);
+   mmc = init_mmc_device(curr_device);
+   if (!mmc)
+   return CMD_RET_FAILURE;
 
-   if (mmc) {
-   mmc_init(mmc);
+   print_mmcinfo(mmc);
+   return CMD_RET_SUCCESS;
+}
 
-   print_mmcinfo(mmc);
-   return 0;
-   } else {
-   printf("no mmc device at slot %x\n", curr_device);
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+static int confirm_key_prog(void)
+{
+   puts("Warning: Programming authentication key can be done only once !\n"
+" Use this command only if you are sure of what you are 
doing,\n"
+"Really perform the key programming?  ");
+   if (confirm_yesno())
return 1;
+
+   puts("Authentication key programming aborted\n");
+   return 0;
+}
+static int do_mmcrpmb_key(cmd_tbl_t *cmdtp, int flag,
+ int argc, char * const argv[])
+{
+   void *key_addr;
+   struct mmc *mmc = find_mmc_device(curr_device);
+
+   if (argc != 2)
+   return CMD_RET_USAGE;
+
+   key_addr = (void *)simple_strtoul(argv[1], NULL, 16);
+   if (!confirm_key_prog())
+   return CMD_RET_FAILURE;
+   if (mmc_rpmb_set_key(mmc, key_addr)) {
+   printf("ERROR - Key already programmed ?\n");
+   return CMD_RET_FAILURE;
}
+   return CMD_RET_SUCCESS;
 }
+static int do_mmcrpmb_read(cmd_tbl_t *cmdtp, int flag,
+  int argc, ch

[U-Boot] [PATCH V5 2/3] Add the function 'confirm_yesno' for interactive

2014-04-24 Thread Pierre Aubert
User's confirmation is asked in different commands. This commit adds a
function for such confirmation.

Signed-off-by: Pierre Aubert 
---

V3, V4, V5: no changes

Patch added in V2

 common/cmd_fuse.c |   11 ++-
 common/cmd_nand.c |   16 +---
 common/cmd_otp.c  |   18 +++---
 common/console.c  |   28 +++-
 include/common.h  |2 +-
 5 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/common/cmd_fuse.c b/common/cmd_fuse.c
index 0df57db..abab978 100644
--- a/common/cmd_fuse.c
+++ b/common/cmd_fuse.c
@@ -33,15 +33,8 @@ static int confirm_prog(void)
"what you are doing!\n"
"\nReally perform this fuse programming? \n");
 
-   if (getc() == 'y') {
-   int c;
-
-   putc('y');
-   c = getc();
-   putc('\n');
-   if (c == '\r')
-   return 1;
-   }
+   if (confirm_yesno())
+   return 1;
 
puts("Fuse programming aborted\n");
return 0;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 04ab0f1..a84f7dc 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -605,22 +605,16 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
opts.spread = spread;
 
if (scrub) {
-   if (!scrub_yes)
-   puts(scrub_warn);
-
-   if (scrub_yes)
+   if (scrub_yes) {
opts.scrub = 1;
-   else if (getc() == 'y') {
-   puts("y");
-   if (getc() == '\r')
+   } else {
+   puts(scrub_warn);
+   if (confirm_yesno()) {
opts.scrub = 1;
-   else {
+   } else {
puts("scrub aborted\n");
return 1;
}
-   } else {
-   puts("scrub aborted\n");
-   return 1;
}
}
ret = nand_erase_opts(nand, &opts);
diff --git a/common/cmd_otp.c b/common/cmd_otp.c
index 67808aa..593bb8c 100644
--- a/common/cmd_otp.c
+++ b/common/cmd_otp.c
@@ -158,21 +158,9 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
lowup(half + count - 1), page + (half + count - 1) / 2,
half + count
);
-
-   i = 0;
-   while (1) {
-   if (tstc()) {
-   const char exp_ans[] = "YES\r";
-   char c;
-   putc(c = getc());
-   if (exp_ans[i++] != c) {
-   printf(" Aborting\n");
-   return 1;
-   } else if (!exp_ans[i]) {
-   puts("\n");
-   break;
-   }
-   }
+   if (!confirm_yesno()) {
+   printf(" Aborting\n");
+   return 1;
}
}
 
diff --git a/common/console.c b/common/console.c
index 2dfb788..5453726 100644
--- a/common/console.c
+++ b/common/console.c
@@ -537,7 +537,33 @@ int ctrlc(void)
}
return 0;
 }
-
+/* Reads user's confirmation.
+   Returns 1 if user's input is "y", "Y", "yes" or "YES"
+*/
+int confirm_yesno(void)
+{
+   int i;
+   char str_input[5];
+
+   /* Flush input */
+   while (tstc())
+   getc();
+   i = 0;
+   while (i < sizeof(str_input)) {
+   str_input[i] = getc();
+   putc(str_input[i]);
+   if (str_input[i] == '\r')
+   break;
+   i++;
+   }
+   putc('\n');
+   if (strncmp(str_input, "y\r", 2) == 0 ||
+   strncmp(str_input, "Y\r", 2) == 0 ||
+   strncmp(str_input, "yes\r", 4) == 0 ||
+   strncmp(str_input, "YES\r", 4) == 0)
+   return 1;
+   return 0;
+}
 /* pass 1 to disable ctrlc() checking, 0 to enable.
  * returns previous state
  */
diff --git a/include/common.h b/include/common.h
index baf361b..1d922b9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -838,7 +838,7 @@ int ctrl

[U-Boot] [PATCH V5 0/3] eMMC: support for Read Protected Memory Block (RPMB)

2014-04-24 Thread Pierre Aubert
This serie of patches adds some functions and a sub-command of 'mmc' for  
programming the authentication key and for reading and writing the RPMB 
partition of an eMMC according to the JEDEC standard No. 64-A441

The sub-command rpmb is enabled by the flag CONFIG_SUPPORT_EMMC_RPMB defined
in the board configuration file.
It has been tested on a SabreSDP iMX6 board.

Changes in V5:
- move changelog to the right place for each patches
- add empty changelog for patches with no change
- change lib/Makefile for adding sha256 when CONFIG_SUPPORT_EMMC_RPMB is 
  defined

Changes in V4:
- use subcommand tables for 'mmc' command and 'mmc rpmb' subcommand.
- add 'mmc info' subcommand, which is the same as mmcinfo.
  mmcinfo is kept for compatibility.
- add changelog in commit comments.

Changes in V3:
- add entries in README for configuration options related to eMMC.
- new patch for adding the 'confirm_yesno' function as suggested by W.Denk
- improved test for existence of RPMB partition.
- fix of coding issues.

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the 
  RPMB frames.

Pierre Aubert (3):
  eMMC: add support for operations in RPMB partition
  Add the function 'confirm_yesno' for interactive
  eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

 README   |   10 +
 common/cmd_fuse.c|   11 +-
 common/cmd_mmc.c |  806 +++--
 common/cmd_nand.c|   16 +-
 common/cmd_otp.c |   18 +-
 common/console.c |   28 ++-
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 
 include/common.h |2 +-
 include/mmc.h|   10 +-
 lib/Makefile |1 +
 11 files changed, 892 insertions(+), 334 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V5 1/3] eMMC: add support for operations in RPMB partition

2014-04-24 Thread Pierre Aubert
This patch adds functions for read, write and authentication
key programming for the Replay Protected Memory Block partition
in the eMMC.

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
Changes in V5:
- move changelog to the right place
- change lib/Makefile for adding sha256 when CONFIG_SUPPORT_EMMC_RPMB is 
  defined

V3, V4: no changes

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the
  RPMB frames.

 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 ++
 include/mmc.h|   10 ++-
 lib/Makefile |1 +
 4 files changed, 334 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 931922b..4c6ab9e 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
+obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
new file mode 100644
index 000..05936f5
--- /dev/null
+++ b/drivers/mmc/rpmb.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright 2014, Staubli Faverges
+ * Pierre Aubert
+ *
+ * eMMC- Replay Protected Memory Block
+ * According to JEDEC Standard No. 84-A441
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "mmc_private.h"
+
+/* Request codes */
+#define RPMB_REQ_KEY   1
+#define RPMB_REQ_WCOUNTER  2
+#define RPMB_REQ_WRITE_DATA3
+#define RPMB_REQ_READ_DATA 4
+#define RPMB_REQ_STATUS5
+
+/* Response code */
+#define RPMB_RESP_KEY  0x0100
+#define RPMB_RESP_WCOUNTER 0x0200
+#define RPMB_RESP_WRITE_DATA   0x0300
+#define RPMB_RESP_READ_DATA0x0400
+
+/* Error codes */
+#define RPMB_OK0
+#define RPMB_ERR_GENERAL   1
+#define RPMB_ERR_AUTH  2
+#define RPMB_ERR_COUNTER   3
+#define RPMB_ERR_ADDRESS   4
+#define RPMB_ERR_WRITE 5
+#define RPMB_ERR_READ  6
+#define RPMB_ERR_KEY   7
+#define RPMB_ERR_CNT_EXPIRED   0x80
+#define RPMB_ERR_MSK   0x7
+
+/* Sizes of RPMB data frame */
+#define RPMB_SZ_STUFF  196
+#define RPMB_SZ_MAC32
+#define RPMB_SZ_DATA   256
+#define RPMB_SZ_NONCE  16
+
+#define SHA256_BLOCK_SIZE  64
+
+/* Error messages */
+static const char * const rpmb_err_msg[] = {
+   "",
+   "General failure",
+   "Authentication failure",
+   "Counter failure",
+   "Address failure",
+   "Write failure",
+   "Read failure",
+   "Authentication key not yet programmed",
+};
+
+
+/* Structure of RPMB data frame. */
+struct s_rpmb {
+   unsigned char stuff[RPMB_SZ_STUFF];
+   unsigned char mac[RPMB_SZ_MAC];
+   unsigned char data[RPMB_SZ_DATA];
+   unsigned char nonce[RPMB_SZ_NONCE];
+   unsigned long write_counter;
+   unsigned short address;
+   unsigned short block_count;
+   unsigned short result;
+   unsigned short request;
+};
+
+static int mmc_set_blockcount(struct mmc *mmc, unsigned int blockcount,
+ bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+
+   cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT;
+   cmd.cmdarg = blockcount & 0x;
+   if (is_rel_write)
+   cmd.cmdarg |= 1 << 31;
+   cmd.resp_type = MMC_RSP_R1;
+
+   return mmc_send_cmd(mmc, &cmd, NULL);
+}
+static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
+   unsigned int count, bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, count, is_rel_write);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+
+   cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type = MMC_RSP_R1b;
+
+   data.src = (const char *)s;
+   data.blocks = 1;
+   data.blocksize = MMC_MAX_BLOCK_LEN;
+   data.flags = MMC_DATA_WRITE;
+
+   ret = mmc_send_cmd(mmc, &cmd, &data);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_send_cmd-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+   return 0;
+}
+static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,
+unsigned short expected)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, 

Re: [U-Boot] [PATCH V4 1/3] eMMC: add support for operations in RPMB partition

2014-04-24 Thread Pierre AUBERT

Hello Wolfgang,

Le 24/04/2014 08:59, Wolfgang Denk a écrit :

Dear Pierre.

In message <1398321641-7113-2-git-send-email-p.aub...@staubli.com> you wrote:
...

--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,6 +35,9 @@ obj-y += net_utils.o
  obj-$(CONFIG_PHYSMEM) += physmem.o
  obj-y += qsort.o
  obj-$(CONFIG_SHA1) += sha1.o
+ifdef CONFIG_SUPPORT_EMMC_RPMB
+CONFIG_SHA256 := y
+endif

This is a pretty ugly way to tweak the configuration.  Why do we need
this?

I gess all you really want is

obj-$(CONFIG_SUPPORT_EMMC_RPMB) += sha256.o

?

Yes. I will fix it.

Best regards,

Wolfgang Denk


Best regards
Pierre Aubert
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V4 1/3] eMMC: add support for operations in RPMB partition

2014-04-24 Thread Pierre AUBERT

Hello Wolfgang,

Le 24/04/2014 09:33, Wolfgang Denk a écrit :

Dear Pierre,

In message <5358ba6a.3030...@staubli.com> you wrote:

The changelog goes into the comment section (i. e. below the "---"

I will fix it in V5. I made the same mistake for the patch 3/3.

Thanks.

Actually I cannot see a V4 of patch 3/3 ?

It's strange. On my side, I can see it in the mailing list and in patchwork.



line), not into the commit message.  Also, this being V4 of the patch,
I wonder what was changed in V3 and V4?

There's no change for this patch in V3 and V4. I have resubmitted all
the patchset.

Then the changelog should say so (like: "V3, V4: no changes").

Ok, I will fix it.


Best regards,

Wolfgang Denk


Best regards
Pierre
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V4 1/3] eMMC: add support for operations in RPMB partition

2014-04-24 Thread Pierre AUBERT

Hello Wolfgang,

Le 24/04/2014 08:55, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1398321641-7113-2-git-send-email-p.aub...@staubli.com> you wrote:

This patch adds functions for read, write and authentication
key programming for the Replay Protected Memory Block partition
in the eMMC.

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the
   RPMB frames.

The changelog goes into the comment section (i. e. below the "---"

I will fix it in V5. I made the same mistake for the patch 3/3.

line), not into the commit message.  Also, this being V4 of the patch,
I wonder what was changed in V3 and V4?
There's no change for this patch in V3 and V4. I have resubmitted all 
the patchset.



Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---

Add changelog here!

Ok



  drivers/mmc/Makefile |1 +
  drivers/mmc/rpmb.c   |  323 ++
  include/mmc.h|   10 ++-
  lib/Makefile |3 +
  4 files changed, 336 insertions(+), 1 deletions(-)
  create mode 100644 drivers/mmc/rpmb.c


Best regards,

Wolfgang Denk


Best regards
Pierre Aubert
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V4 3/3] eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

2014-04-23 Thread Pierre Aubert
This sub-command adds support for the RPMB partition of an eMMC:
* mmc rpmb key 
  Programs the authentication key in the eMMC This key can not
  be overwritten.
* mmc rpmb read   <#count> [address of key]
  Reads <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . If the optionnal
  address of the authentication key is provided, the
  Message Authentication Code (MAC) is verified on each
  block.
* mmc rpmb write   <#count> 
  Writes <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . The datas are signed
  with the key provided.
* mmc rpmb counter
  Returns the 'Write counter' of the RPMB partition.

The sub-command is conditional on compilation flag CONFIG_SUPPORT_EMMC_RPMB

Changes in V4:
- use subcommand table for 'mmc' command and 'mmc rpmb' subcommand.
- add 'mmc info' subcommand, which is the same as mmcinfo.
  mmcinfo is kept for compatibility.
- add changelog in commit comments.

Changes in V3:
- add entries in README for configuration options related to eMMC.
- improved test for existence of RPMB partition.
- fix of coding issues.

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
CC: Wolfgang Denk 
---
 README   |   10 +
 common/cmd_mmc.c |  806 ++
 2 files changed, 520 insertions(+), 296 deletions(-)

diff --git a/README b/README
index 52a92e7..518e209 100644
--- a/README
+++ b/README
@@ -1493,6 +1493,16 @@ The following options need to be configured:
CONFIG_SH_MMCIF_CLK
Define the clock frequency for MMCIF
 
+   CONFIG_GENERIC_MMC
+   Enable the generic MMC driver
+
+   CONFIG_SUPPORT_EMMC_BOOT
+   Enable some additional features of the eMMC boot partitions.
+
+   CONFIG_SUPPORT_EMMC_RPMB
+   Enable the commands for reading, writing and programming the
+   key for the Replay Protection Memory Block partition in eMMC.
+
 - USB Device Firmware Update (DFU) class support:
CONFIG_DFU_FUNCTION
This enables the USB portion of the DFU USB class
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..55af295 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -71,12 +71,6 @@ U_BOOT_CMD(
 );
 #else /* !CONFIG_GENERIC_MMC */
 
-enum mmc_state {
-   MMC_INVALID,
-   MMC_READ,
-   MMC_WRITE,
-   MMC_ERASE,
-};
 static void print_mmcinfo(struct mmc *mmc)
 {
printf("Device: %s\n", mmc->cfg->name);
@@ -98,7 +92,18 @@ static void print_mmcinfo(struct mmc *mmc)
 
printf("Bus Width: %d-bit\n", mmc->bus_width);
 }
-
+static struct mmc *init_mmc_device(int dev)
+{
+   struct mmc *mmc;
+   mmc = find_mmc_device(dev);
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", dev);
+   return NULL;
+   }
+   if (mmc_init(mmc))
+   return NULL;
+   return mmc;
+}
 static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[])
 {
struct mmc *mmc;
@@ -112,351 +117,546 @@ static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
}
}
 
-   mmc = find_mmc_device(curr_device);
+   mmc = init_mmc_device(curr_device);
+   if (!mmc)
+   return CMD_RET_FAILURE;
 
-   if (mmc) {
-   mmc_init(mmc);
+   print_mmcinfo(mmc);
+   return CMD_RET_SUCCESS;
+}
 
-   print_mmcinfo(mmc);
-   return 0;
-   } else {
-   printf("no mmc device at slot %x\n", curr_device);
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+static int confirm_key_prog(void)
+{
+   puts("Warning: Programming authentication key can be done only once !\n"
+" Use this command only if you are sure of what you are 
doing,\n"
+"Really perform the key programming?  ");
+   if (confirm_yesno())
return 1;
+
+   puts("Authentication key programming aborted\n");
+   return 0;
+}
+static int do_mmcrpmb_key(cmd_tbl_t *cmdtp, int flag,
+ int argc, char * const argv[])
+{
+   void *key_addr;
+   struct mmc *mmc = find_mmc_device(curr_device);
+
+   if (argc != 2)
+   return CMD_RET_USAGE;
+
+   key_addr = (void *)simple_strtoul(argv[1], NULL, 16);
+   if (!confirm_key_prog())
+   return CMD_RET_FAILURE;
+   if (mmc_rpmb_set_key(mmc, key_addr)) {
+   printf("ERROR - Key already programmed ?\n");
+   return CMD_RET_FAILURE;
}
+   return CMD_RET_SUCCESS;
 }
+static int do_mmcrpmb_read(cmd_tbl_t *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   u16 blk, cnt;
+   void *addr;
+   i

[U-Boot] [PATCH V4 2/3] Add the function 'confirm_yesno' for interactive

2014-04-23 Thread Pierre Aubert
User's confirmation is asked in different commands. This commit adds a
function for such confirmation.

Signed-off-by: Pierre Aubert 
---
 common/cmd_fuse.c |   11 ++-
 common/cmd_nand.c |   16 +---
 common/cmd_otp.c  |   18 +++---
 common/console.c  |   28 +++-
 include/common.h  |2 +-
 5 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/common/cmd_fuse.c b/common/cmd_fuse.c
index 0df57db..abab978 100644
--- a/common/cmd_fuse.c
+++ b/common/cmd_fuse.c
@@ -33,15 +33,8 @@ static int confirm_prog(void)
"what you are doing!\n"
"\nReally perform this fuse programming? \n");
 
-   if (getc() == 'y') {
-   int c;
-
-   putc('y');
-   c = getc();
-   putc('\n');
-   if (c == '\r')
-   return 1;
-   }
+   if (confirm_yesno())
+   return 1;
 
puts("Fuse programming aborted\n");
return 0;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 04ab0f1..a84f7dc 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -605,22 +605,16 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
opts.spread = spread;
 
if (scrub) {
-   if (!scrub_yes)
-   puts(scrub_warn);
-
-   if (scrub_yes)
+   if (scrub_yes) {
opts.scrub = 1;
-   else if (getc() == 'y') {
-   puts("y");
-   if (getc() == '\r')
+   } else {
+   puts(scrub_warn);
+   if (confirm_yesno()) {
opts.scrub = 1;
-   else {
+   } else {
puts("scrub aborted\n");
return 1;
}
-   } else {
-   puts("scrub aborted\n");
-   return 1;
}
}
ret = nand_erase_opts(nand, &opts);
diff --git a/common/cmd_otp.c b/common/cmd_otp.c
index 67808aa..593bb8c 100644
--- a/common/cmd_otp.c
+++ b/common/cmd_otp.c
@@ -158,21 +158,9 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
lowup(half + count - 1), page + (half + count - 1) / 2,
half + count
);
-
-   i = 0;
-   while (1) {
-   if (tstc()) {
-   const char exp_ans[] = "YES\r";
-   char c;
-   putc(c = getc());
-   if (exp_ans[i++] != c) {
-   printf(" Aborting\n");
-   return 1;
-   } else if (!exp_ans[i]) {
-   puts("\n");
-   break;
-   }
-   }
+   if (!confirm_yesno()) {
+   printf(" Aborting\n");
+   return 1;
}
}
 
diff --git a/common/console.c b/common/console.c
index 2dfb788..5453726 100644
--- a/common/console.c
+++ b/common/console.c
@@ -537,7 +537,33 @@ int ctrlc(void)
}
return 0;
 }
-
+/* Reads user's confirmation.
+   Returns 1 if user's input is "y", "Y", "yes" or "YES"
+*/
+int confirm_yesno(void)
+{
+   int i;
+   char str_input[5];
+
+   /* Flush input */
+   while (tstc())
+   getc();
+   i = 0;
+   while (i < sizeof(str_input)) {
+   str_input[i] = getc();
+   putc(str_input[i]);
+   if (str_input[i] == '\r')
+   break;
+   i++;
+   }
+   putc('\n');
+   if (strncmp(str_input, "y\r", 2) == 0 ||
+   strncmp(str_input, "Y\r", 2) == 0 ||
+   strncmp(str_input, "yes\r", 4) == 0 ||
+   strncmp(str_input, "YES\r", 4) == 0)
+   return 1;
+   return 0;
+}
 /* pass 1 to disable ctrlc() checking, 0 to enable.
  * returns previous state
  */
diff --git a/include/common.h b/include/common.h
index baf361b..1d922b9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -838,7 +838,7 @@ int ctrlc (void);
 inthad_ctrlc (void

[U-Boot] [PATCH V4 0/3] eMMC: support for Read Protected Memory Block (RPMB)

2014-04-23 Thread Pierre Aubert
This serie of patches adds some functions and a sub-command of 'mmc' for  
programming the authentication key and for reading and writing the RPMB 
partition of an eMMC according to the JEDEC standard No. 64-A441

The sub-command rpmb is enabled by the flag CONFIG_SUPPORT_EMMC_RPMB defined
in the board configuration file.
It has been tested on a SabreSDP iMX6 board.

Changes in V4:
- use subcommand tables for 'mmc' command and 'mmc rpmb' subcommand.
- add 'mmc info' subcommand, which is the same as mmcinfo.
  mmcinfo is kept for compatibility.
- add changelog in commit comments.

Changes in V3:
- add entries in README for configuration options related to eMMC.
- new patch for adding the 'confirm_yesno' function as suggested by W.Denk
- improved test for existence of RPMB partition.
- fix of coding issues.

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the 
  RPMB frames.

Pierre Aubert (3):
  eMMC: add support for operations in RPMB partition
  Add the function 'confirm_yesno' for interactive
  eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

 README   |   10 +
 common/cmd_fuse.c|   11 +-
 common/cmd_mmc.c |  806 +++--
 common/cmd_nand.c|   16 +-
 common/cmd_otp.c |   18 +-
 common/console.c |   28 ++-
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 
 include/common.h |2 +-
 include/mmc.h|   10 +-
 lib/Makefile |3 +
 11 files changed, 894 insertions(+), 334 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V4 1/3] eMMC: add support for operations in RPMB partition

2014-04-23 Thread Pierre Aubert
This patch adds functions for read, write and authentication
key programming for the Replay Protected Memory Block partition
in the eMMC.

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the
  RPMB frames.

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 ++
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 4 files changed, 336 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 931922b..4c6ab9e 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
+obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
new file mode 100644
index 000..05936f5
--- /dev/null
+++ b/drivers/mmc/rpmb.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright 2014, Staubli Faverges
+ * Pierre Aubert
+ *
+ * eMMC- Replay Protected Memory Block
+ * According to JEDEC Standard No. 84-A441
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "mmc_private.h"
+
+/* Request codes */
+#define RPMB_REQ_KEY   1
+#define RPMB_REQ_WCOUNTER  2
+#define RPMB_REQ_WRITE_DATA3
+#define RPMB_REQ_READ_DATA 4
+#define RPMB_REQ_STATUS5
+
+/* Response code */
+#define RPMB_RESP_KEY  0x0100
+#define RPMB_RESP_WCOUNTER 0x0200
+#define RPMB_RESP_WRITE_DATA   0x0300
+#define RPMB_RESP_READ_DATA0x0400
+
+/* Error codes */
+#define RPMB_OK0
+#define RPMB_ERR_GENERAL   1
+#define RPMB_ERR_AUTH  2
+#define RPMB_ERR_COUNTER   3
+#define RPMB_ERR_ADDRESS   4
+#define RPMB_ERR_WRITE 5
+#define RPMB_ERR_READ  6
+#define RPMB_ERR_KEY   7
+#define RPMB_ERR_CNT_EXPIRED   0x80
+#define RPMB_ERR_MSK   0x7
+
+/* Sizes of RPMB data frame */
+#define RPMB_SZ_STUFF  196
+#define RPMB_SZ_MAC32
+#define RPMB_SZ_DATA   256
+#define RPMB_SZ_NONCE  16
+
+#define SHA256_BLOCK_SIZE  64
+
+/* Error messages */
+static const char * const rpmb_err_msg[] = {
+   "",
+   "General failure",
+   "Authentication failure",
+   "Counter failure",
+   "Address failure",
+   "Write failure",
+   "Read failure",
+   "Authentication key not yet programmed",
+};
+
+
+/* Structure of RPMB data frame. */
+struct s_rpmb {
+   unsigned char stuff[RPMB_SZ_STUFF];
+   unsigned char mac[RPMB_SZ_MAC];
+   unsigned char data[RPMB_SZ_DATA];
+   unsigned char nonce[RPMB_SZ_NONCE];
+   unsigned long write_counter;
+   unsigned short address;
+   unsigned short block_count;
+   unsigned short result;
+   unsigned short request;
+};
+
+static int mmc_set_blockcount(struct mmc *mmc, unsigned int blockcount,
+ bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+
+   cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT;
+   cmd.cmdarg = blockcount & 0x;
+   if (is_rel_write)
+   cmd.cmdarg |= 1 << 31;
+   cmd.resp_type = MMC_RSP_R1;
+
+   return mmc_send_cmd(mmc, &cmd, NULL);
+}
+static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
+   unsigned int count, bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, count, is_rel_write);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+
+   cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type = MMC_RSP_R1b;
+
+   data.src = (const char *)s;
+   data.blocks = 1;
+   data.blocksize = MMC_MAX_BLOCK_LEN;
+   data.flags = MMC_DATA_WRITE;
+
+   ret = mmc_send_cmd(mmc, &cmd, &data);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_send_cmd-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+   return 0;
+}
+static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,
+unsigned short expected)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return 

[U-Boot] [PATCH V3 2/3] Add the function 'confirm_yesno' for interactive confirmation.

2014-04-22 Thread Pierre Aubert
User's confirmation is asked in different commands. This commit adds a
function for such confirmation.

Signed-off-by: Pierre Aubert 
---
 common/cmd_fuse.c |   11 ++-
 common/cmd_nand.c |   16 +---
 common/cmd_otp.c  |   18 +++---
 common/console.c  |   28 +++-
 include/common.h  |2 +-
 5 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/common/cmd_fuse.c b/common/cmd_fuse.c
index 0df57db..abab978 100644
--- a/common/cmd_fuse.c
+++ b/common/cmd_fuse.c
@@ -33,15 +33,8 @@ static int confirm_prog(void)
"what you are doing!\n"
"\nReally perform this fuse programming? \n");
 
-   if (getc() == 'y') {
-   int c;
-
-   putc('y');
-   c = getc();
-   putc('\n');
-   if (c == '\r')
-   return 1;
-   }
+   if (confirm_yesno())
+   return 1;
 
puts("Fuse programming aborted\n");
return 0;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 04ab0f1..a84f7dc 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -605,22 +605,16 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
opts.spread = spread;
 
if (scrub) {
-   if (!scrub_yes)
-   puts(scrub_warn);
-
-   if (scrub_yes)
+   if (scrub_yes) {
opts.scrub = 1;
-   else if (getc() == 'y') {
-   puts("y");
-   if (getc() == '\r')
+   } else {
+   puts(scrub_warn);
+   if (confirm_yesno()) {
opts.scrub = 1;
-   else {
+   } else {
puts("scrub aborted\n");
return 1;
}
-   } else {
-   puts("scrub aborted\n");
-   return 1;
}
}
ret = nand_erase_opts(nand, &opts);
diff --git a/common/cmd_otp.c b/common/cmd_otp.c
index 67808aa..593bb8c 100644
--- a/common/cmd_otp.c
+++ b/common/cmd_otp.c
@@ -158,21 +158,9 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
lowup(half + count - 1), page + (half + count - 1) / 2,
half + count
);
-
-   i = 0;
-   while (1) {
-   if (tstc()) {
-   const char exp_ans[] = "YES\r";
-   char c;
-   putc(c = getc());
-   if (exp_ans[i++] != c) {
-   printf(" Aborting\n");
-   return 1;
-   } else if (!exp_ans[i]) {
-   puts("\n");
-   break;
-   }
-   }
+   if (!confirm_yesno()) {
+   printf(" Aborting\n");
+   return 1;
}
}
 
diff --git a/common/console.c b/common/console.c
index 2dfb788..5453726 100644
--- a/common/console.c
+++ b/common/console.c
@@ -537,7 +537,33 @@ int ctrlc(void)
}
return 0;
 }
-
+/* Reads user's confirmation.
+   Returns 1 if user's input is "y", "Y", "yes" or "YES"
+*/
+int confirm_yesno(void)
+{
+   int i;
+   char str_input[5];
+
+   /* Flush input */
+   while (tstc())
+   getc();
+   i = 0;
+   while (i < sizeof(str_input)) {
+   str_input[i] = getc();
+   putc(str_input[i]);
+   if (str_input[i] == '\r')
+   break;
+   i++;
+   }
+   putc('\n');
+   if (strncmp(str_input, "y\r", 2) == 0 ||
+   strncmp(str_input, "Y\r", 2) == 0 ||
+   strncmp(str_input, "yes\r", 4) == 0 ||
+   strncmp(str_input, "YES\r", 4) == 0)
+   return 1;
+   return 0;
+}
 /* pass 1 to disable ctrlc() checking, 0 to enable.
  * returns previous state
  */
diff --git a/include/common.h b/include/common.h
index baf361b..1d922b9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -838,7 +838,7 @@ int ctrlc (void);
 inthad_ctrlc (void

[U-Boot] [PATCH V3 1/3] eMMC: add support for operations in RPMB partition

2014-04-22 Thread Pierre Aubert
This patch adds functions for read, write and authentication
key programming for the Replay Protected Memory Block partition
in the eMMC.

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 ++
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 4 files changed, 336 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 931922b..4c6ab9e 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
+obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
new file mode 100644
index 000..05936f5
--- /dev/null
+++ b/drivers/mmc/rpmb.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright 2014, Staubli Faverges
+ * Pierre Aubert
+ *
+ * eMMC- Replay Protected Memory Block
+ * According to JEDEC Standard No. 84-A441
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "mmc_private.h"
+
+/* Request codes */
+#define RPMB_REQ_KEY   1
+#define RPMB_REQ_WCOUNTER  2
+#define RPMB_REQ_WRITE_DATA3
+#define RPMB_REQ_READ_DATA 4
+#define RPMB_REQ_STATUS5
+
+/* Response code */
+#define RPMB_RESP_KEY  0x0100
+#define RPMB_RESP_WCOUNTER 0x0200
+#define RPMB_RESP_WRITE_DATA   0x0300
+#define RPMB_RESP_READ_DATA0x0400
+
+/* Error codes */
+#define RPMB_OK0
+#define RPMB_ERR_GENERAL   1
+#define RPMB_ERR_AUTH  2
+#define RPMB_ERR_COUNTER   3
+#define RPMB_ERR_ADDRESS   4
+#define RPMB_ERR_WRITE 5
+#define RPMB_ERR_READ  6
+#define RPMB_ERR_KEY   7
+#define RPMB_ERR_CNT_EXPIRED   0x80
+#define RPMB_ERR_MSK   0x7
+
+/* Sizes of RPMB data frame */
+#define RPMB_SZ_STUFF  196
+#define RPMB_SZ_MAC32
+#define RPMB_SZ_DATA   256
+#define RPMB_SZ_NONCE  16
+
+#define SHA256_BLOCK_SIZE  64
+
+/* Error messages */
+static const char * const rpmb_err_msg[] = {
+   "",
+   "General failure",
+   "Authentication failure",
+   "Counter failure",
+   "Address failure",
+   "Write failure",
+   "Read failure",
+   "Authentication key not yet programmed",
+};
+
+
+/* Structure of RPMB data frame. */
+struct s_rpmb {
+   unsigned char stuff[RPMB_SZ_STUFF];
+   unsigned char mac[RPMB_SZ_MAC];
+   unsigned char data[RPMB_SZ_DATA];
+   unsigned char nonce[RPMB_SZ_NONCE];
+   unsigned long write_counter;
+   unsigned short address;
+   unsigned short block_count;
+   unsigned short result;
+   unsigned short request;
+};
+
+static int mmc_set_blockcount(struct mmc *mmc, unsigned int blockcount,
+ bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+
+   cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT;
+   cmd.cmdarg = blockcount & 0x;
+   if (is_rel_write)
+   cmd.cmdarg |= 1 << 31;
+   cmd.resp_type = MMC_RSP_R1;
+
+   return mmc_send_cmd(mmc, &cmd, NULL);
+}
+static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
+   unsigned int count, bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, count, is_rel_write);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+
+   cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type = MMC_RSP_R1b;
+
+   data.src = (const char *)s;
+   data.blocks = 1;
+   data.blocksize = MMC_MAX_BLOCK_LEN;
+   data.flags = MMC_DATA_WRITE;
+
+   ret = mmc_send_cmd(mmc, &cmd, &data);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_send_cmd-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+   return 0;
+}
+static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,
+unsigned short expected)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return -1;
+   }
+   cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type

[U-Boot] [PATCH V3 3/3] eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

2014-04-22 Thread Pierre Aubert
This sub-command adds support for the RPMB partition of an eMMC:
* mmc rpmb key 
  Programs the authentication key in the eMMC This key can not
  be overwritten.
* mmc rpmb read   <#count> [address of key]
  Reads <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . If the optionnal
  address of the authentication key is provided, the
  Message Authentication Code (MAC) is verified on each
  block.
* mmc rpmb write   <#count> 
  Writes <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . The datas are signed
  with the key provided.
* mmc rpmb counter
  Returns the 'Write counter' of the RPMB partition.

The sub-command is conditional on compilation flag CONFIG_SUPPORT_EMMC_RPMB

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 README   |   10 
 common/cmd_mmc.c |  123 +-
 2 files changed, 132 insertions(+), 1 deletions(-)

diff --git a/README b/README
index 52a92e7..518e209 100644
--- a/README
+++ b/README
@@ -1493,6 +1493,16 @@ The following options need to be configured:
CONFIG_SH_MMCIF_CLK
Define the clock frequency for MMCIF
 
+   CONFIG_GENERIC_MMC
+   Enable the generic MMC driver
+
+   CONFIG_SUPPORT_EMMC_BOOT
+   Enable some additional features of the eMMC boot partitions.
+
+   CONFIG_SUPPORT_EMMC_RPMB
+   Enable the commands for reading, writing and programming the
+   key for the Replay Protection Memory Block partition in eMMC.
+
 - USB Device Firmware Update (DFU) class support:
CONFIG_DFU_FUNCTION
This enables the USB portion of the DFU USB class
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..da8a243 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -130,7 +130,118 @@ U_BOOT_CMD(
"display MMC info",
"- display info of the current MMC device"
 );
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+static int confirm_key_prog(void)
+{
+   puts("Warning: Programming authentication key can be done only once !\n"
+" Use this command only if you are sure of what you are 
doing,\n"
+"Really perform the key programming?  ");
+   if (confirm_yesno())
+   return 1;
+
+   puts("Authentication key programming aborted\n");
+   return 0;
+}
+static int do_mmcrpmb(int argc, char * const argv[])
+{
+   enum rpmb_state {
+   RPMB_INVALID,
+   RPMB_READ,
+   RPMB_WRITE,
+   RPMB_KEY,
+   RPMB_COUNTER,
+   } state;
+   struct mmc *mmc = find_mmc_device(curr_device);
+   void *key_addr;
+   char original_part;
+   int ret;
+
+   state = RPMB_INVALID;
+   if (argc == 4 && strcmp(argv[2], "key") == 0)
+   state = RPMB_KEY;
+   if ((argc == 6 || argc == 7) && strcmp(argv[2], "read") == 0)
+   state = RPMB_READ;
+   else if (argc == 7 && strcmp(argv[2], "write") == 0)
+   state = RPMB_WRITE;
+   else if (argc == 3 && strcmp(argv[2], "counter") == 0)
+   state = RPMB_COUNTER;
+
+   if (state == RPMB_INVALID)
+   return CMD_RET_USAGE;
 
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", curr_device);
+   return CMD_RET_FAILURE;
+   }
+   mmc_init(mmc);
+   if (!(mmc->version & MMC_VERSION_MMC)) {
+   printf("It is not a EMMC device\n");
+   return CMD_RET_FAILURE;
+   }
+   if (mmc->version < MMC_VERSION_4_41) {
+   printf("RPMB not supported before version 4.41\n");
+   return CMD_RET_FAILURE;
+   }
+   /* Switch to the RPMB partition */
+   original_part = mmc->part_num;
+   if (mmc->part_num != MMC_PART_RPMB) {
+   if (mmc_switch_part(curr_device, MMC_PART_RPMB) != 0)
+   return CMD_RET_FAILURE;
+   mmc->part_num = MMC_PART_RPMB;
+   }
+   ret = CMD_RET_SUCCESS;
+   if (state == RPMB_KEY) {
+   key_addr = (void *)simple_strtoul(argv[3], NULL, 16);
+   if (!confirm_key_prog())
+   return CMD_RET_FAILURE;
+   if (mmc_rpmb_set_key(mmc, key_addr)) {
+   printf("ERROR - Key already programmed ?\n");
+   ret = CMD_RET_FAILURE;
+   }
+   } else if (state == RPMB_COUNTER) {
+   unsigned long counter;
+
+   if (mmc_rpmb_get_counter(mmc, &counter))
+   ret = CMD_RET_FAILURE;
+   else
+   printf("Write

[U-Boot] [PATCH V3 0/3] eMMC: support for Read Protected Memory Block (RPMB)

2014-04-22 Thread Pierre Aubert
This serie of patches adds some functions and a sub-command of 'mmc' for  
programming the authentication key and for reading and writing the RPMB 
partition of an eMMC according to the JEDEC standard No. 64-A441

The sub-command rpmb is enabled by the flag CONFIG_SUPPORT_EMMC_RPMB defined
in the board configuration file.
It has been tested on a SabreSDP iMX6 board.

Changes in V3:
- add entries in README for configuration options related to eMMC.
- new patch for adding the 'confirm_yesno' function as suggested by W.Denk
- improved test for existence of RPMB partition.
- fix of coding issues.

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the 
  RPMB frames.

Pierre Aubert (3):
  eMMC: add support for operations in RPMB partition
  Add the function 'confirm_yesno' for interactive confirmation.
  eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

 README   |   10 ++
 common/cmd_fuse.c|   11 +--
 common/cmd_mmc.c |  123 +++-
 common/cmd_nand.c|   16 +--
 common/cmd_otp.c |   18 +---
 common/console.c |   28 -
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 ++
 include/common.h |2 +-
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 11 files changed, 506 insertions(+), 39 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2 2/2] eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

2014-04-17 Thread Pierre AUBERT

Hello Wolfgang,

Le 17/04/2014 21:56, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1397747435-24042-3-git-send-email-p.aub...@staubli.com> you wrote:

This sub-command adds support for the RPMB partition of an eMMC:
* mmc rpmb key 
   Programs the authentication key in the eMMC This key can not
   be overwritten.
* mmc rpmb read   <#count> [address of key]
   Reads <#count> blocks of 256 bytes in the RPMB partition
   beginning at block number . If the optionnal
   address of the authentication key is provided, the
   Message Authentication Code (MAC) is verified on each
   block.
* mmc rpmb write   <#count> 
   Writes <#count> blocks of 256 bytes in the RPMB partition
   beginning at block number . The datas are signed
   with the key provided.
* mmc rpmb counter
   Returns the 'Write counter' of the RPMB partition.

The sub-command is conditional on compilation flag CONFIG_SUPPORT_EMMC_RPMB

Such new options must be documented in the README.

I will add it in a V3



Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
  common/cmd_mmc.c |  128 +-
  1 files changed, 127 insertions(+), 1 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..3cf11e7 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -130,7 +130,123 @@ U_BOOT_CMD(
"display MMC info",
"- display info of the current MMC device"
  );
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+static int confirm_key_prog(void)
+{
+   puts("Warning: Programming authentication key can be done only once !\n"
+" Use this command only if you are sure of what you are 
doing,\n"
+"Really perform the key programming ? ");
+   if (getc() == 'y') {

Would it not makes sense to flush the input before reading the char,
so that you don;t react on any type-ahead that might already be
buffered?


+   int c;
+
+   putc('y');
+   c = getc();
+   putc('\n');
+   if (c == '\r')
+   return 1;
+   }

Should we allow for 'Y"? And for "yes" / "Yes"?

We have getenv_yesno() - maybe we should provide a similar function
that can be used in other places where such interactive confirmation
is needed?
I have found such a confirmation in cmd_fuse, cmd_otp and cmd_mmc. It 
makes sense to provide

a global function. I will try to submit a patch for that.

+   if (state != RPMB_INVALID) {

Change this into

if (state == RPMB_INVALID)
return CMD_RET_USAGE;

and avoid one level of indentation; this will make the code much
easier to read.


+   if (IS_SD(mmc)) {

Is IS_SD() a reliable test for eMMC devics, or would that also return
true in other cases?
You're right, the test must be more restrictive. The RPMB partition is 
available only since the release 4.41 of the Jedec

standard. I will fix it in a V3.



+   if (confirm_key_prog()) {
+   if (mmc_rpmb_set_key(mmc, key_addr)) {
+   printf("ERROR - Key already programmed 
?\n");
+   ret = CMD_RET_FAILURE;
+   }
+   } else {
+   ret = CMD_RET_FAILURE;
+   }

You should really avoid deep nesting and take early exits.
You can write this as:

if (!confirm_key_prog())
return CMD_RET_FAILURE;

if (mmc_rpmb_set_key(mmc, key_addr)) {
printf("ERROR - Key already programmed ?\n");
ret = CMD_RET_FAILURE;
}

Please fix globally.

No problem, it will be fixed globally in V3



+   } else if (state == RPMB_COUNTER) {
+   unsigned long counter;
+   if (mmc_rpmb_get_counter(mmc, &counter))

Please insert a blank line between declarations and code.

Ok



+   printf("%d RPMB blocks %s: %s\n",
+  n, argv[2], (n == cnt) ? "OK" : "ERROR");

As the input is in hex, it is usually also a good idea to (also) print
the count in hex.
For coherency with the mmc read and mmc write, I kept the same output. 
But it can be changed, of course.



  #endif /* CONFIG_SUPPORT_EMMC_BOOT */
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+   } else if (strcmp(argv[1], "rpmb") == 0) {
+   return do_mmcrpmb(argc, argv);
+#endif /*  CONFIG_SUPPORT_EMMC_RPMB */

I think that now, with more subcommands being added, we should
convert the mmc code to proper subcommand handling. [It might even
make sense to do so for &q

[U-Boot] [PATCH V2 1/2] eMMC: add support for operations in RPMB partition

2014-04-17 Thread Pierre Aubert
This patch adds functions for read, write and authentication
key programming for the Replay Protected Memory Block partition
in the eMMC.

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 ++
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 4 files changed, 336 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 931922b..4c6ab9e 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
+obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
new file mode 100644
index 000..05936f5
--- /dev/null
+++ b/drivers/mmc/rpmb.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright 2014, Staubli Faverges
+ * Pierre Aubert
+ *
+ * eMMC- Replay Protected Memory Block
+ * According to JEDEC Standard No. 84-A441
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "mmc_private.h"
+
+/* Request codes */
+#define RPMB_REQ_KEY   1
+#define RPMB_REQ_WCOUNTER  2
+#define RPMB_REQ_WRITE_DATA3
+#define RPMB_REQ_READ_DATA 4
+#define RPMB_REQ_STATUS5
+
+/* Response code */
+#define RPMB_RESP_KEY  0x0100
+#define RPMB_RESP_WCOUNTER 0x0200
+#define RPMB_RESP_WRITE_DATA   0x0300
+#define RPMB_RESP_READ_DATA0x0400
+
+/* Error codes */
+#define RPMB_OK0
+#define RPMB_ERR_GENERAL   1
+#define RPMB_ERR_AUTH  2
+#define RPMB_ERR_COUNTER   3
+#define RPMB_ERR_ADDRESS   4
+#define RPMB_ERR_WRITE 5
+#define RPMB_ERR_READ  6
+#define RPMB_ERR_KEY   7
+#define RPMB_ERR_CNT_EXPIRED   0x80
+#define RPMB_ERR_MSK   0x7
+
+/* Sizes of RPMB data frame */
+#define RPMB_SZ_STUFF  196
+#define RPMB_SZ_MAC32
+#define RPMB_SZ_DATA   256
+#define RPMB_SZ_NONCE  16
+
+#define SHA256_BLOCK_SIZE  64
+
+/* Error messages */
+static const char * const rpmb_err_msg[] = {
+   "",
+   "General failure",
+   "Authentication failure",
+   "Counter failure",
+   "Address failure",
+   "Write failure",
+   "Read failure",
+   "Authentication key not yet programmed",
+};
+
+
+/* Structure of RPMB data frame. */
+struct s_rpmb {
+   unsigned char stuff[RPMB_SZ_STUFF];
+   unsigned char mac[RPMB_SZ_MAC];
+   unsigned char data[RPMB_SZ_DATA];
+   unsigned char nonce[RPMB_SZ_NONCE];
+   unsigned long write_counter;
+   unsigned short address;
+   unsigned short block_count;
+   unsigned short result;
+   unsigned short request;
+};
+
+static int mmc_set_blockcount(struct mmc *mmc, unsigned int blockcount,
+ bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+
+   cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT;
+   cmd.cmdarg = blockcount & 0x;
+   if (is_rel_write)
+   cmd.cmdarg |= 1 << 31;
+   cmd.resp_type = MMC_RSP_R1;
+
+   return mmc_send_cmd(mmc, &cmd, NULL);
+}
+static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
+   unsigned int count, bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, count, is_rel_write);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+
+   cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type = MMC_RSP_R1b;
+
+   data.src = (const char *)s;
+   data.blocks = 1;
+   data.blocksize = MMC_MAX_BLOCK_LEN;
+   data.flags = MMC_DATA_WRITE;
+
+   ret = mmc_send_cmd(mmc, &cmd, &data);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_send_cmd-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+   return 0;
+}
+static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,
+unsigned short expected)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return -1;
+   }
+   cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type

[U-Boot] [PATCH V2 2/2] eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

2014-04-17 Thread Pierre Aubert
This sub-command adds support for the RPMB partition of an eMMC:
* mmc rpmb key 
  Programs the authentication key in the eMMC This key can not
  be overwritten.
* mmc rpmb read   <#count> [address of key]
  Reads <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . If the optionnal
  address of the authentication key is provided, the
  Message Authentication Code (MAC) is verified on each
  block.
* mmc rpmb write   <#count> 
  Writes <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . The datas are signed
  with the key provided.
* mmc rpmb counter
  Returns the 'Write counter' of the RPMB partition.

The sub-command is conditional on compilation flag CONFIG_SUPPORT_EMMC_RPMB

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 common/cmd_mmc.c |  128 +-
 1 files changed, 127 insertions(+), 1 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..3cf11e7 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -130,7 +130,123 @@ U_BOOT_CMD(
"display MMC info",
"- display info of the current MMC device"
 );
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+static int confirm_key_prog(void)
+{
+   puts("Warning: Programming authentication key can be done only once !\n"
+" Use this command only if you are sure of what you are 
doing,\n"
+"Really perform the key programming ? ");
+   if (getc() == 'y') {
+   int c;
+
+   putc('y');
+   c = getc();
+   putc('\n');
+   if (c == '\r')
+   return 1;
+   }
 
+   puts("Authentication key programming aborted\n");
+   return 0;
+}
+static int do_mmcrpmb(int argc, char * const argv[])
+{
+   enum rpmb_state {
+   RPMB_INVALID,
+   RPMB_READ,
+   RPMB_WRITE,
+   RPMB_KEY,
+   RPMB_COUNTER,
+   } state;
+
+   state = RPMB_INVALID;
+   if (argc == 4 && strcmp(argv[2], "key") == 0)
+   state = RPMB_KEY;
+   if ((argc == 6 || argc == 7) && strcmp(argv[2], "read") == 0)
+   state = RPMB_READ;
+   else if (argc == 7 && strcmp(argv[2], "write") == 0)
+   state = RPMB_WRITE;
+   else if (argc == 3 && strcmp(argv[2], "counter") == 0)
+   state = RPMB_COUNTER;
+
+   if (state != RPMB_INVALID) {
+   struct mmc *mmc = find_mmc_device(curr_device);
+   void *key_addr;
+   char original_part;
+   int ret;
+
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", curr_device);
+   return CMD_RET_FAILURE;
+   }
+   mmc_init(mmc);
+   if (IS_SD(mmc)) {
+   printf("It is not a EMMC device\n");
+   return CMD_RET_FAILURE;
+   }
+   /* Switch to the RPMB partition */
+   original_part = mmc->part_num;
+   if (mmc->part_num != MMC_PART_RPMB) {
+   if (mmc_switch_part(curr_device, MMC_PART_RPMB) != 0)
+   return CMD_RET_FAILURE;
+   mmc->part_num = MMC_PART_RPMB;
+   }
+   ret = CMD_RET_SUCCESS;
+   if (state == RPMB_KEY) {
+   key_addr = (void *)simple_strtoul(argv[3], NULL, 16);
+   if (confirm_key_prog()) {
+   if (mmc_rpmb_set_key(mmc, key_addr)) {
+   printf("ERROR - Key already programmed 
?\n");
+   ret = CMD_RET_FAILURE;
+   }
+   } else {
+   ret = CMD_RET_FAILURE;
+   }
+   } else if (state == RPMB_COUNTER) {
+   unsigned long counter;
+   if (mmc_rpmb_get_counter(mmc, &counter))
+   ret = CMD_RET_FAILURE;
+   else
+   printf("Write counter= %lx\n", counter);
+   } else {
+   u16 blk, cnt;
+   void *addr;
+   int n;
+
+   addr = (void *)simple_strtoul(argv[3], NULL, 16);
+   blk = simple_strtoul(argv[4], NULL, 16);
+   cnt = simple_strtoul(argv[5], NULL, 16);
+
+   if (state == RPMB_READ) {
+   key_addr = (argc == 7) ?
+   

[U-Boot] [PATCH V2 0/2] eMMC: support for Read Protected Memory Block (RPMB)

2014-04-17 Thread Pierre Aubert
This serie of patches adds some functions and a sub-command of 'mmc' for  
programming the authentication key and for reading and writing the RPMB 
partition of an eMMC according to the JEDEC standard No. 64-A441

The sub-command rpmb is enabled by the flag CONFIG_SUPPORT_EMMC_RPMB defined
in the board configuration file.
It has been tested on a SabreSDP iMX6 board.

Changes in V2:
- use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the 
  RPMB frames.

Pierre Aubert (2):
  eMMC: add support for operations in RPMB partition
  eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

 common/cmd_mmc.c |  128 -
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  323 ++
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 5 files changed, 463 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

2014-04-11 Thread Pierre Aubert
This sub-command adds support for the RPMB partition of an eMMC:
* mmc rpmb key 
  Programs the authentication key in the eMMC This key can not
  be overwritten.
* mmc rpmb read   <#count> [address of key]
  Reads <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . If the optionnal
  address of the authentication key is provided, the
  Message Authentication Code (MAC) is verified on each
  block.
* mmc rpmb write   <#count> 
  Writes <#count> blocks of 256 bytes in the RPMB partition
  beginning at block number . The datas are signed
  with the key provided.
* mmc rpmb counter
  Returns the 'Write counter' of the RPMB partition.

The sub-command is conditional on compilation flag CONFIG_SUPPORT_EMMC_RPMB

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 common/cmd_mmc.c |  128 +-
 1 files changed, 127 insertions(+), 1 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..3cf11e7 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -130,7 +130,123 @@ U_BOOT_CMD(
"display MMC info",
"- display info of the current MMC device"
 );
+#ifdef CONFIG_SUPPORT_EMMC_RPMB
+static int confirm_key_prog(void)
+{
+   puts("Warning: Programming authentication key can be done only once !\n"
+" Use this command only if you are sure of what you are 
doing,\n"
+"Really perform the key programming ? ");
+   if (getc() == 'y') {
+   int c;
+
+   putc('y');
+   c = getc();
+   putc('\n');
+   if (c == '\r')
+   return 1;
+   }
 
+   puts("Authentication key programming aborted\n");
+   return 0;
+}
+static int do_mmcrpmb(int argc, char * const argv[])
+{
+   enum rpmb_state {
+   RPMB_INVALID,
+   RPMB_READ,
+   RPMB_WRITE,
+   RPMB_KEY,
+   RPMB_COUNTER,
+   } state;
+
+   state = RPMB_INVALID;
+   if (argc == 4 && strcmp(argv[2], "key") == 0)
+   state = RPMB_KEY;
+   if ((argc == 6 || argc == 7) && strcmp(argv[2], "read") == 0)
+   state = RPMB_READ;
+   else if (argc == 7 && strcmp(argv[2], "write") == 0)
+   state = RPMB_WRITE;
+   else if (argc == 3 && strcmp(argv[2], "counter") == 0)
+   state = RPMB_COUNTER;
+
+   if (state != RPMB_INVALID) {
+   struct mmc *mmc = find_mmc_device(curr_device);
+   void *key_addr;
+   char original_part;
+   int ret;
+
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", curr_device);
+   return CMD_RET_FAILURE;
+   }
+   mmc_init(mmc);
+   if (IS_SD(mmc)) {
+   printf("It is not a EMMC device\n");
+   return CMD_RET_FAILURE;
+   }
+   /* Switch to the RPMB partition */
+   original_part = mmc->part_num;
+   if (mmc->part_num != MMC_PART_RPMB) {
+   if (mmc_switch_part(curr_device, MMC_PART_RPMB) != 0)
+   return CMD_RET_FAILURE;
+   mmc->part_num = MMC_PART_RPMB;
+   }
+   ret = CMD_RET_SUCCESS;
+   if (state == RPMB_KEY) {
+   key_addr = (void *)simple_strtoul(argv[3], NULL, 16);
+   if (confirm_key_prog()) {
+   if (mmc_rpmb_set_key(mmc, key_addr)) {
+   printf("ERROR - Key already programmed 
?\n");
+   ret = CMD_RET_FAILURE;
+   }
+   } else {
+   ret = CMD_RET_FAILURE;
+   }
+   } else if (state == RPMB_COUNTER) {
+   unsigned long counter;
+   if (mmc_rpmb_get_counter(mmc, &counter))
+   ret = CMD_RET_FAILURE;
+   else
+   printf("Write counter= %lx\n", counter);
+   } else {
+   u16 blk, cnt;
+   void *addr;
+   int n;
+
+   addr = (void *)simple_strtoul(argv[3], NULL, 16);
+   blk = simple_strtoul(argv[4], NULL, 16);
+   cnt = simple_strtoul(argv[5], NULL, 16);
+
+   if (state == RPMB_READ) {
+   key_addr = (argc == 7) ?
+   

[U-Boot] [PATCH 1/2] eMMC: add support for operations in RPMB partition

2014-04-11 Thread Pierre Aubert
This patch adds functions for read, write and authentication
key programming for the Replay Protected Memory Block partition
in the eMMC.

Signed-off-by: Pierre Aubert 
CC: Pantelis Antoniou 
---
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  317 ++
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 4 files changed, 330 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 931922b..4c6ab9e 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
+obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c
new file mode 100644
index 000..7f9dffc
--- /dev/null
+++ b/drivers/mmc/rpmb.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright 2014, Staubli Faverges
+ * Pierre Aubert
+ *
+ * eMMC- Replay Protected Memory Block
+ * According to JEDEC Standard No. 84-A441
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "mmc_private.h"
+
+/* Request codes */
+#define RPMB_REQ_KEY   1
+#define RPMB_REQ_WCOUNTER  2
+#define RPMB_REQ_WRITE_DATA3
+#define RPMB_REQ_READ_DATA 4
+#define RPMB_REQ_STATUS5
+
+/* Response code */
+#define RPMB_RESP_KEY  0x0100
+#define RPMB_RESP_WCOUNTER 0x0200
+#define RPMB_RESP_WRITE_DATA   0x0300
+#define RPMB_RESP_READ_DATA0x0400
+
+/* Error codes */
+#define RPMB_OK0
+#define RPMB_ERR_GENERAL   1
+#define RPMB_ERR_AUTH  2
+#define RPMB_ERR_COUNTER   3
+#define RPMB_ERR_ADDRESS   4
+#define RPMB_ERR_WRITE 5
+#define RPMB_ERR_READ  6
+#define RPMB_ERR_KEY   7
+#define RPMB_ERR_CNT_EXPIRED   0x80
+#define RPMB_ERR_MSK   0x7
+
+/* Sizes of RPMB data frame */
+#define RPMB_SZ_STUFF  196
+#define RPMB_SZ_MAC32
+#define RPMB_SZ_DATA   256
+#define RPMB_SZ_NONCE  16
+
+#define SHA256_BLOCK_SIZE  64
+
+/* Error messages */
+static const char * const rpmb_err_msg[] = {
+   "",
+   "General failure",
+   "Authentication failure",
+   "Counter failure",
+   "Address failure",
+   "Write failure",
+   "Read failure",
+   "Authentication key not yet programmed",
+};
+
+
+/* Structure of RPMB data frame. */
+static struct s_rpmb {
+   unsigned char stuff[RPMB_SZ_STUFF];
+   unsigned char mac[RPMB_SZ_MAC];
+   unsigned char data[RPMB_SZ_DATA];
+   unsigned char nonce[RPMB_SZ_NONCE];
+   unsigned long write_counter;
+   unsigned short address;
+   unsigned short block_count;
+   unsigned short result;
+   unsigned short request;
+} __aligned(32) rpmb_frame;
+
+static int mmc_set_blockcount(struct mmc *mmc, unsigned int blockcount,
+ bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+
+   cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT;
+   cmd.cmdarg = blockcount & 0x;
+   if (is_rel_write)
+   cmd.cmdarg |= 1 << 31;
+   cmd.resp_type = MMC_RSP_R1;
+
+   return mmc_send_cmd(mmc, &cmd, NULL);
+}
+static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
+   unsigned int count, bool is_rel_write)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, count, is_rel_write);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+
+   cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
+   cmd.cmdarg = 0;
+   cmd.resp_type = MMC_RSP_R1b;
+
+   data.src = (const char *)s;
+   data.blocks = 1;
+   data.blocksize = MMC_MAX_BLOCK_LEN;
+   data.flags = MMC_DATA_WRITE;
+
+   ret = mmc_send_cmd(mmc, &cmd, &data);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_send_cmd-> %d\n", __func__, ret);
+#endif
+   return 1;
+   }
+   return 0;
+}
+static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,
+unsigned short expected)
+{
+   struct mmc_cmd cmd = {0};
+   struct mmc_data data;
+   int ret;
+
+   ret = mmc_set_blockcount(mmc, 1, false);
+   if (ret) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+   printf("%s:mmc_set_blockcount-> %d\n", __func__, ret);
+#endif
+   return -1;
+   }
+   cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK;
+   c

[U-Boot] [PATCH 0/2] eMMC: support for Read Protected Memory Block (RPMB)

2014-04-11 Thread Pierre Aubert

This serie of patches adds some functions and a sub-command of 'mmc' for  
programming the authentication key and for reading and writing the RPMB 
partition of an eMMC according to the JEDEC standard No. 64-A441

The sub-command rpmb is enabled by the flag CONFIG_SUPPORT_EMMC_RPMB defined
in the board configuration file.
It has been tested on a SabreSDP iMX6 board.

Pierre Aubert (2):
  eMMC: add support for operations in RPMB partition
  eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command

 common/cmd_mmc.c |  128 -
 drivers/mmc/Makefile |1 +
 drivers/mmc/rpmb.c   |  317 ++
 include/mmc.h|   10 ++-
 lib/Makefile |3 +
 5 files changed, 457 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mmc/rpmb.c

-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH REPOST] usb: create common header virtual root hub descriptors

2014-03-04 Thread Pierre AUBERT

Hello Stephen,

Sorry for the delay, I wasn't connected during 2 weeks.
I can't comment your patch because I no longer have an MPC5200-based board.

Best regards

Le 21/02/2014 05:19, Stephen Warren a écrit :

On 02/13/2014 09:15 PM, Stephen Warren wrote:

Many USB host controller drivers contain almost identical copies of the
same virtual root hub descriptors. Put these into a common file to avoid
duplication.

Note that there were some very minor differences between the descriptors
in the various files, such as:

- USB 1.0 vs. USB 1.1
- Manufacturer/Device ID
- Max packet size
- String content

I assume these aren't relevant.

Marek, how long do you think we should wait for acks/naks from the CC'd
people?





___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] env export fix: compute the CRC on the real lenght of the exported variables.

2014-03-03 Thread Pierre AUBERT

Dear Tom Rini

Le 26/02/2014 21:02, Tom Rini a écrit :

[ Catching up on some old emails ]

On Fri, Nov 15, 2013 at 08:20:09AM +0100, Pierre AUBERT wrote:

Dear Wolfgang Denk,

Le 14/11/2013 18:24, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1384434720-11214-3-git-send-email-p.aub...@staubli.com> you wrote:

Signed-off-by: Pierre Aubert 
---
  common/cmd_nvedit.c |5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 5bcc324..c32a932 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -922,14 +922,15 @@ NXTARG:   ;
len = hexport_r(&env_htab, '\0',
H_MATCH_KEY | H_MATCH_IDENT,
-   &res, ENV_SIZE, argc, argv);
+   &res, size, argc, argv);
+
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
if (chk) {
-   envp->crc = crc32(0, envp->data, ENV_SIZE);
+   envp->crc = crc32(0, envp->data, len);

This is not correct.  When exporting with CRC, then the CRC
computation should be the same as is done with the persistently
stored environment, i. e. it should be taken over ENV_SIZE bytes.

In this case, there's an inconstisency between the export and the
import. It isn't possible to export some variables and the reimport
them:
U-Boot > env export -c 
U-Boot > env import -c  fails with a CRC error.
The import computes the CRC on the real lenght of the environment
variables. IMO, as the import and the export are done to work
together, it seems to me that the export should compute its CRC on
the real  lenght.

But env import -c  $filesize does work as the export sets
filesize.



You're right, but my purpose wasn't  to export and reimport immediatly 
the same environment.
I thought it was more logical to have the same behaviour between 
"sister" functions.


Best regards

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] imx6 Solo and LAN8720

2014-01-16 Thread Pierre Aubert
Hello Andy,

We use a similar configuration on our custom board. The differences between
your code and ours are :


#define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED   | \
PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_SLOW  | PAD_CTL_HYS)

iomux_v3_cfg_t const enet_pads[] = {
MX6_PAD_ENET_MDC__ENET_MDC  | MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_MDIO__ENET_MDIO| MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_RXD0__ENET_RX_DATA0| MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_RXD1__ENET_RX_DATA1| MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_CRS_DV__ENET_RX_EN | MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_RX_ER__ENET_RX_ER  | MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_TXD0__ENET_TX_DATA0| MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_TXD1__ENET_TX_DATA1| MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_REF_CLK__ENET_TX_CLK   | MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_ENET_TX_EN__ENET_TX_EN  | MUX_PAD_CTRL(ENET_PAD_CTRL),

/* Reference clock 50Mhz */
MX6_PAD_GPIO_16__ENET_REF_CLK | MUX_MODE_SION | 
MUX_PAD_CTRL(ENET_PAD_CTRL
| PAD_CTL_SRE_FAST),

/* LAN Reset   */
MX6_PAD_SD3_DAT3__GPIO7_IO07| MUX_PAD_CTRL(ENET_PAD_CTRL),
};

...
#ifdef CONFIG_FEC_MXC

int board_phy_config(struct phy_device *phydev)
{
if (phydev->drv->config)
phydev->drv->config(phydev);
return 0;
}

int board_eth_init(bd_t *bis)
{
int ret;
struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR;
int reg;

imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
/* Reset the PHY */
gpio_direction_output(GPIO_ENET_PHY_RESET, 0);

/* Select ENET CLK source*/
reg = readl(&iomux->gpr[1]);
reg |= IOMUXC_GPR1_ENET_CLK_SEL;
writel(reg, &iomux->gpr[1]);

/* Configure and Start the ENET PLL  */
/*  diviseur => 50 MHz   */
writel (BM_ANADIG_PLL_ENET_DIV_SELECT, &anatop->pll_enet_clr);
writel (0x1, &anatop->pll_enet_set);

/*  clear bypass et powerdown*/
writel (BM_ANADIG_PLL_ENET_BYPASS |  BM_ANADIG_PLL_ENET_POWERDOWN,
&anatop->pll_enet_clr);
/*  enable   */
writel (BM_ANADIG_PLL_ENET_ENABLE, &anatop->pll_enet_set);

/* Release PHY reset at least 30ms after the clock setup */
mdelay (30);
gpio_set_value(GPIO_ENET_PHY_RESET, 1);

ret = cpu_eth_init(bis);
if (ret)
printf("FEC MXC: %s:failed\n", __func__);

return ret;
}
#endif

The FEC is working on our board.
I hope it helps
Best regards




--
View this message in context: 
http://u-boot.10912.n7.nabble.com/imx6-Solo-and-LAN8720-tp171669p171690.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] mx6: Revert "mx6: soc: Disable VDDPU regulator"

2014-01-16 Thread Pierre AUBERT

Le 16/01/2014 17:01, Fabio Estevam a écrit :

On Thu, Jan 16, 2014 at 1:50 PM, Otavio Salvador
 wrote:


It worked for you probably because you used the ldo bypass mode.


Yes; I did the bypass mode.

We currently don't do LDO bypass mode in mainline U-boot. We do it in
FSL U-boot.

With LDO bypass, lower VDDARM and VDDSOC voltages can be supplied as
per the mx6 datasheet.

I just measured with the scope and the VDDARM/SOC voltages supplied by
the 3.10 FSL kernel are below the minimum for the LDO enabled case. So
setting LDO bypass in U-boot 'fixes' the issue.

We can implement LDO bypass after 2014.01 is out, but for this release
let's just revert the VDDPU disable patch.

Do you agree?

+1


Regards,

Fabio Estevam


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 6/6] mx6: soc: Disable VDDPU regulator

2014-01-16 Thread Pierre AUBERT

Hi Fabio,


Le 16/01/2014 12:19, Fabio Estevam a écrit :

Hi Pierre,

On Thu, Jan 16, 2014 at 6:40 AM, Pierre Aubert  wrote:

=Hello,


Otavio Salvador wrote

It seems this patch makes 3.10.17-1.0.0-beta freeze in a customer board;
reverting this makes this to work again. It freezes when loading Vivante
module.

Can someone reproduce this freeze?

The kernel 3.0.35 freezes also on the SabreSD platform with this commit.

What is the output of "md.l 0x20C8140 1' on your board?

=> md.l 0x20C8140 1
020c8140: 004c0010


What is the mx6 variant (solo, dl, q) and silicon version?

I'm using a SabreSDP with a iMX6DL :

U-Boot 2014.01-rc3-00077-g751be3b (Jan 16 2014 - 08:27:51)

CPU:   Freescale i.MX6DL rev1.1 at 792 MHz
Reset cause: POR
Board: MX6-SabreSD
DRAM:  1 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In:serial
Out:   serial
Err:   serial
Net:   FEC [PRIME]
Hit any key to stop autoboot:  0



Regards,

Fabio Estevam

Best regards
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 6/6] mx6: soc: Disable VDDPU regulator

2014-01-16 Thread Pierre Aubert
=Hello,


Otavio Salvador wrote
> 
> It seems this patch makes 3.10.17-1.0.0-beta freeze in a customer board;
> reverting this makes this to work again. It freezes when loading Vivante
> module.
> 
> Can someone reproduce this freeze?

The kernel 3.0.35 freezes also on the SabreSD platform with this commit. 

Best regards




--
View this message in context: 
http://u-boot.10912.n7.nabble.com/PATCH-v2-1-6-mx6-soc-Staticize-set-vddsoc-tp170344p171610.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] toolchain problems when building iMX6 mx6qsabreauto (and another bootloader tool)

2013-12-06 Thread Pierre Aubert
Dear Måns Rullgård ,

On Wed, Dec 4, 2013 at 9:35 AM, Måns Rullgård <[hidden email]> wrote: 

>> mx6: compute PLL PFD frequencies rather than using defines
>
> That commit introduces a 64-bit division without using the lldiv()
> function, which pulls in previously unused libgcc stuff.

Thank you for the fix. I missed the 64 bits division.

Best regards




--
View this message in context: 
http://u-boot.10912.n7.nabble.com/toolchain-problems-when-building-iMX6-mx6qsabreauto-and-another-bootloader-tool-tp168514p169107.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] env export fix: compute the CRC on the real lenght of the exported variables.

2013-11-14 Thread Pierre AUBERT

Dear Wolfgang Denk,

Le 14/11/2013 18:24, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1384434720-11214-3-git-send-email-p.aub...@staubli.com> you wrote:

Signed-off-by: Pierre Aubert 
---
  common/cmd_nvedit.c |5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 5bcc324..c32a932 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -922,14 +922,15 @@ NXTARG:   ;
  
  	len = hexport_r(&env_htab, '\0',

H_MATCH_KEY | H_MATCH_IDENT,
-   &res, ENV_SIZE, argc, argv);
+   &res, size, argc, argv);
+
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
  
  	if (chk) {

-   envp->crc = crc32(0, envp->data, ENV_SIZE);
+   envp->crc = crc32(0, envp->data, len);

This is not correct.  When exporting with CRC, then the CRC
computation should be the same as is done with the persistently
stored environment, i. e. it should be taken over ENV_SIZE bytes.
In this case, there's an inconstisency between the export and the 
import. It isn't possible to export some variables and the reimport them:

U-Boot > env export -c 
U-Boot > env import -c  fails with a CRC error.
The import computes the CRC on the real lenght of the environment 
variables. IMO, as the import and the export are done to work together, 
it seems to me that the export should compute its CRC on the real  lenght.


Best regards


Best regards,

Wolfgang Denk



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] hashtable: fix the export lenght computation.

2013-11-14 Thread Pierre AUBERT

Dear Wolfgang Denk,

Le 14/11/2013 18:25, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1384434720-11214-2-git-send-email-p.aub...@staubli.com> you wrote:

The room for the '=' and the sep char was reserved twice.

Are you sure?  Keep in mind that the termination of the list is a
_double_ NUL byte.  IIRC this is what we do here.
Yes, I'm sure. The termination of the list (last NULL after the last 
separator) is added at line 666

 666 size = totlen + 1;
In the actual code, the lenght is two large of 2 char for each exported 
variable.


Best regards



Best regards,

Wolfgang Denk



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] hashtable: fix the export lenght computation.

2013-11-14 Thread Pierre Aubert
The room for the '=' and the sep char was reserved twice.

Signed-off-by: Pierre Aubert 
---
 lib/hashtable.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/hashtable.c b/lib/hashtable.c
index 4356b23..480d207 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -623,7 +623,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char 
sep, int flag,
 
list[n++] = ep;
 
-   totlen += strlen(ep->key) + 2;
+   totlen += strlen(ep->key);
 
if (sep == '\0') {
totlen += strlen(ep->data);
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/2] env export fixes

2013-11-14 Thread Pierre Aubert
These patches fix two issues in the export of environment 
variables with CRC calculation.

Pierre Aubert (2):
  hashtable: fix the export lenght computation.
  env export fix: compute the CRC on the real lenght of the exported
variables.

 common/cmd_nvedit.c |5 +++--
 lib/hashtable.c |2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] env export fix: compute the CRC on the real lenght of the exported variables.

2013-11-14 Thread Pierre Aubert
Signed-off-by: Pierre Aubert 
---
 common/cmd_nvedit.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 5bcc324..c32a932 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -922,14 +922,15 @@ NXTARG:   ;
 
len = hexport_r(&env_htab, '\0',
H_MATCH_KEY | H_MATCH_IDENT,
-   &res, ENV_SIZE, argc, argv);
+   &res, size, argc, argv);
+
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
 
if (chk) {
-   envp->crc = crc32(0, envp->data, ENV_SIZE);
+   envp->crc = crc32(0, envp->data, len);
 #ifdef CONFIG_ENV_ADDR_REDUND
envp->flags = ACTIVE_FLAG;
 #endif
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] env: fix the env export varname

2013-10-08 Thread Pierre Aubert
The env export command doesn't export the first variable of the list
since commit 5a31ea04c9ee5544fbb70ad7597ea4b294840eab
"env grep" - reimplement command using hexport_r()

Signed-off-by: Pierre Aubert 
---
 common/cmd_nvedit.c |6 ++
 lib/hashtable.c |2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 778dca5..c249286 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -157,10 +157,8 @@ static int do_env_grep(cmd_tbl_t *cmdtp, int flag,
grep_how  = H_MATCH_SUBSTR; /* default: substring search*/
grep_what = H_MATCH_BOTH;   /* default: grep names and values */
 
-   while (argc > 1 && **(argv + 1) == '-') {
-   char *arg = *++argv;
-
-   --argc;
+   while (--argc > 0 && **++argv == '-') {
+   char *arg = *argv;
while (*++arg) {
switch (*arg) {
 #ifdef CONFIG_REGEX
diff --git a/lib/hashtable.c b/lib/hashtable.c
index c5a2b08..4356b23 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -564,7 +564,7 @@ static int match_entry(ENTRY *ep, int flag,
int arg;
void *priv = NULL;
 
-   for (arg = 1; arg < argc; ++arg) {
+   for (arg = 0; arg < argc; ++arg) {
 #ifdef CONFIG_REGEX
struct slre slre;
 
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: arch-mx6: fix PLL2_PFD2_FREQ

2013-09-25 Thread Pierre AUBERT

Hello Markus,

Le 25/09/2013 09:24, Markus Niebel a écrit :

Hello Pierre,

---
  arch/arm/include/asm/arch-mx6/crm_regs.h |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h
b/arch/arm/include/asm/arch-mx6/crm_regs.h
index 74aefe6..2813593 100644
--- a/arch/arm/include/asm/arch-mx6/crm_regs.h
+++ b/arch/arm/include/asm/arch-mx6/crm_regs.h
@@ -892,7 +892,7 @@ struct mxc_ccm_reg {
  
  #define PLL2_PFD0_FREQ		35200

  #define PLL2_PFD1_FREQ59400
-#define PLL2_PFD2_FREQ 4
+#define PLL2_PFD2_FREQ 39600
  #define PLL2_PFD2_DIV_FREQ2
  #define PLL3_PFD0_FREQ72000
  #define PLL3_PFD1_FREQ54000



Hello Markus, Hello Stephano
I think it's better to compute  this frequencies rather than hard coding
values. The default PFD frequencies are not the same for the Quad and for
the other Socs.

As far as I read the manual for i.MX6Q/D and i.MX6DL/S have the same default 
values.
For the i.MX6Q/D, the PLL2-PFD0 is 352MHz and the PLL2-PFD1 is 594MHz. 
For the i.MX6DL/S, the PLL2-PFD0 is 302.58MHz and the PLL2-PFD1 is 
528MHz. The definitions in the crm_regs.h are for the i.MX6Q/D.



Furthermore, if you modify PLL2_PFD2_FREQ, you must also change
PLL2_PFD2_DIV_FREQ.

Please, see the patch I've submitted yesterday ([PATCH V2] mx6: compute PLL
PFD frequencies rather than using defines)


Hmm. Sounds reasonable.Do you expect any side effects?
(We came accross the mismatch that was fixed with my original
patch when looking over DRAM configuration)
  
I've tested it on the SabreSD with i.MX6DL and on a custom board with 
i.MX6Q and i.MX6S and I didn't noticed any side effects.


Best regards



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] mx6: Fix use of improper value in enable_ipu_clock

2013-09-23 Thread Pierre Aubert
The value MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET that was used to initialize
the CCGR3 register caused an undefined value for CG0.

Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---
 arch/arm/cpu/armv7/mx6/clock.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index 7efb0d2..0f7bcbc 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -457,7 +457,7 @@ void enable_ipu_clock(void)
struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
int reg;
reg = readl(&mxc_ccm->CCGR3);
-   reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET;
+   reg |= MXC_CCM_CCGR3_IPU1_IPU_MASK;
writel(reg, &mxc_ccm->CCGR3);
 }
 /***/
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: arch-mx6: fix PLL2_PFD2_FREQ

2013-09-20 Thread Pierre Aubert
Stefano Babic wrote
> On 11/09/2013 15:30, Markus Niebel wrote:
>> From: Markus Niebel <

> Markus.Niebel@

> >
>> 
>> according to the manual frequency of PLL2 PFD2 is 396.000.000
>> instead of 400.000.000
>> 
>> Signed-off-by: Markus Niebel <

> Markus.Niebel@

> >
>> ---
>>  arch/arm/include/asm/arch-mx6/crm_regs.h |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h
>> b/arch/arm/include/asm/arch-mx6/crm_regs.h
>> index 74aefe6..2813593 100644
>> --- a/arch/arm/include/asm/arch-mx6/crm_regs.h
>> +++ b/arch/arm/include/asm/arch-mx6/crm_regs.h
>> @@ -892,7 +892,7 @@ struct mxc_ccm_reg {
>>  
>>  #define PLL2_PFD0_FREQ  35200
>>  #define PLL2_PFD1_FREQ  59400
>> -#define PLL2_PFD2_FREQ  4
>> +#define PLL2_PFD2_FREQ  39600
>>  #define PLL2_PFD2_DIV_FREQ  2
>>  #define PLL3_PFD0_FREQ  72000
>>  #define PLL3_PFD1_FREQ  54000
>> 
> 
> Acked-by: Stefano Babic <

> sbabic@

> >

Hello Markus, Hello Stephano
I think it's better to compute  this frequencies rather than hard coding
values. The default PFD frequencies are not the same for the Quad and for
the other Socs.
Furthermore, if you modify PLL2_PFD2_FREQ, you must also change
PLL2_PFD2_DIV_FREQ.

Please, see the patch I've submitted yesterday ([PATCH V2] mx6: compute PLL
PFD frequencies rather than using defines)

Best regards




--
View this message in context: 
http://u-boot.10912.n7.nabble.com/PATCH-ARM-arch-mx6-fix-PLL2-PFD2-FREQ-tp162976p163654.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V2] mx6: compute PLL PFD frequencies rather than using defines

2013-09-19 Thread Pierre Aubert
Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---

Change for V2: Use the right macros for computing PFD dividers.


 arch/arm/cpu/armv7/mx6/clock.c   |   56 ++---
 arch/arm/include/asm/arch-mx6/crm_regs.h |   11 --
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index 7a29c9b..d0133e9 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -100,6 +100,32 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq)
}
/* NOTREACHED */
 }
+static u32 mxc_get_pll_pfd(enum pll_clocks pll, int pfd_num)
+{
+   u32 div;
+   u64 freq;
+
+   switch (pll) {
+   case PLL_BUS:
+   if (pfd_num == 3) {
+   /* No PFD3 on PPL2 */
+   return 0;
+   }
+   div = __raw_readl(&imx_ccm->analog_pfd_528);
+   freq = (u64)decode_pll(PLL_BUS, MXC_HCLK);
+   break;
+   case PLL_USBOTG:
+   div = __raw_readl(&imx_ccm->analog_pfd_480);
+   freq = (u64)decode_pll(PLL_USBOTG, MXC_HCLK);
+   break;
+   default:
+   /* No PFD on other PLL   */
+   return 0;
+   }
+
+   return (freq * 18) / ((div & ANATOP_PFD_FRAC_MASK(pfd_num)) >>
+ ANATOP_PFD_FRAC_SHIFT(pfd_num));
+}
 
 static u32 get_mcu_main_clk(void)
 {
@@ -144,13 +170,14 @@ u32 get_periph_clk(void)
freq = decode_pll(PLL_BUS, MXC_HCLK);
break;
case 1:
-   freq = PLL2_PFD2_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 2:
-   freq = PLL2_PFD0_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
case 3:
-   freq = PLL2_PFD2_DIV_FREQ;
+   /* static / 2 divider */
+   freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2;
break;
default:
break;
@@ -184,7 +211,7 @@ static u32 get_ipg_per_clk(void)
 static u32 get_uart_clk(void)
 {
u32 reg, uart_podf;
-   u32 freq = PLL3_80M;
+   u32 freq = decode_pll(PLL_USBOTG, MXC_HCLK) / 6; /* static divider */
reg = __raw_readl(&imx_ccm->cscdr1);
 #ifdef CONFIG_MX6SL
if (reg & MXC_CCM_CSCDR1_UART_CLK_SEL)
@@ -204,7 +231,7 @@ static u32 get_cspi_clk(void)
reg &= MXC_CCM_CSCDR2_ECSPI_CLK_PODF_MASK;
cspi_podf = reg >> MXC_CCM_CSCDR2_ECSPI_CLK_PODF_OFFSET;
 
-   return  PLL3_60M / (cspi_podf + 1);
+   return  decode_pll(PLL_USBOTG, MXC_HCLK) / (8 * (cspi_podf + 1));
 }
 
 static u32 get_axi_clk(void)
@@ -217,9 +244,9 @@ static u32 get_axi_clk(void)
 
if (cbcdr & MXC_CCM_CBCDR_AXI_SEL) {
if (cbcdr & MXC_CCM_CBCDR_AXI_ALT_SEL)
-   root_freq = PLL2_PFD2_FREQ;
+   root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
else
-   root_freq = PLL3_PFD1_FREQ;
+   root_freq = mxc_get_pll_pfd(PLL_USBOTG, 1);
} else
root_freq = get_periph_clk();
 
@@ -244,10 +271,10 @@ static u32 get_emi_slow_clk(void)
root_freq = decode_pll(PLL_USBOTG, MXC_HCLK);
break;
case 2:
-   root_freq = PLL2_PFD2_FREQ;
+   root_freq =  mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 3:
-   root_freq = PLL2_PFD0_FREQ;
+   root_freq =  mxc_get_pll_pfd(PLL_BUS, 0);
break;
}
 
@@ -270,13 +297,14 @@ static u32 get_mmdc_ch0_clk(void)
freq = decode_pll(PLL_BUS, MXC_HCLK);
break;
case 1:
-   freq = PLL2_PFD2_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 2:
-   freq = PLL2_PFD0_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
case 3:
-   freq = PLL2_PFD2_DIV_FREQ;
+   /* static / 2 divider */
+   freq =  mxc_get_pll_pfd(PLL_BUS, 2) / 2;
}
 
return freq / (podf + 1);
@@ -329,9 +357,9 @@ static u32 get_usdhc_clk(u32 port)
}
 
if (clk_sel)
-   root_freq = PLL2_PFD0_FREQ;
+   root_freq = mxc_get_pll_pfd(PLL_BUS, 0);
else
-   root_freq = PLL2_PFD2_FREQ;
+   root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
 
return root_freq / (usdhc_podf + 1);
 }
diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h 
b/arch/arm/include/asm/arch-mx6/crm_regs.h
index 5e6c4da..64f36f9 100644
--- a/arch/arm/include/asm/arch-mx6/crm_regs.h
+++ 

[U-Boot] [PATCH] mx6: compute PLL PFD frequencies rather than using defines

2013-09-19 Thread Pierre Aubert
Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---
 arch/arm/cpu/armv7/mx6/clock.c   |   75 --
 arch/arm/include/asm/arch-mx6/crm_regs.h |   11 
 2 files changed, 61 insertions(+), 25 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index 7a29c9b..0c59541 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -100,6 +100,51 @@ static u32 decode_pll(enum pll_clocks pll, u32 infreq)
}
/* NOTREACHED */
 }
+static u32 mxc_get_pll_pfd(enum pll_clocks pll, int pfd_num)
+{
+   u32 div;
+   u64 freq;
+
+   switch (pll) {
+   case PLL_BUS:
+   div = __raw_readl(&imx_ccm->analog_pfd_528);
+   freq = (u64)decode_pll(PLL_BUS, MXC_HCLK);
+   break;
+   case PLL_USBOTG:
+   div = __raw_readl(&imx_ccm->analog_pfd_480);
+   freq = (u64)decode_pll(PLL_USBOTG, MXC_HCLK);
+   break;
+   default:
+   /* No PFD on other PLL   */
+   return 0;
+   }
+   freq *= 18;
+
+   switch (pfd_num) {
+   case 0:
+   div &= BM_ANADIG_PFD_528_PFD0_FRAC;
+   break;
+   case 1:
+   div &= BM_ANADIG_PFD_528_PFD1_FRAC;
+   div >>= BP_ANADIG_PFD_528_PFD1_FRAC;
+   break;
+   case 2:
+   div &= BM_ANADIG_PFD_528_PFD2_FRAC;
+   div >>= BP_ANADIG_PFD_528_PFD2_FRAC;
+   break;
+   case 3:
+   if (pll == PLL_SYS) {
+   /* No PFD3 on PPL2 */
+   return 0;
+   }
+   div &= BM_ANADIG_PFD_528_PFD3_FRAC;
+   div >>= BP_ANADIG_PFD_528_PFD3_FRAC;
+   break;
+   default:
+   return 0;
+   }
+   return freq / div;
+}
 
 static u32 get_mcu_main_clk(void)
 {
@@ -144,13 +189,14 @@ u32 get_periph_clk(void)
freq = decode_pll(PLL_BUS, MXC_HCLK);
break;
case 1:
-   freq = PLL2_PFD2_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 2:
-   freq = PLL2_PFD0_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
case 3:
-   freq = PLL2_PFD2_DIV_FREQ;
+   /* static / 2 divider */
+   freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2;
break;
default:
break;
@@ -184,7 +230,7 @@ static u32 get_ipg_per_clk(void)
 static u32 get_uart_clk(void)
 {
u32 reg, uart_podf;
-   u32 freq = PLL3_80M;
+   u32 freq = decode_pll(PLL_USBOTG, MXC_HCLK) / 6; /* static divider */
reg = __raw_readl(&imx_ccm->cscdr1);
 #ifdef CONFIG_MX6SL
if (reg & MXC_CCM_CSCDR1_UART_CLK_SEL)
@@ -204,7 +250,7 @@ static u32 get_cspi_clk(void)
reg &= MXC_CCM_CSCDR2_ECSPI_CLK_PODF_MASK;
cspi_podf = reg >> MXC_CCM_CSCDR2_ECSPI_CLK_PODF_OFFSET;
 
-   return  PLL3_60M / (cspi_podf + 1);
+   return  decode_pll(PLL_USBOTG, MXC_HCLK) / (8 * (cspi_podf + 1));
 }
 
 static u32 get_axi_clk(void)
@@ -217,9 +263,9 @@ static u32 get_axi_clk(void)
 
if (cbcdr & MXC_CCM_CBCDR_AXI_SEL) {
if (cbcdr & MXC_CCM_CBCDR_AXI_ALT_SEL)
-   root_freq = PLL2_PFD2_FREQ;
+   root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
else
-   root_freq = PLL3_PFD1_FREQ;
+   root_freq = mxc_get_pll_pfd(PLL_USBOTG, 1);
} else
root_freq = get_periph_clk();
 
@@ -244,10 +290,10 @@ static u32 get_emi_slow_clk(void)
root_freq = decode_pll(PLL_USBOTG, MXC_HCLK);
break;
case 2:
-   root_freq = PLL2_PFD2_FREQ;
+   root_freq =  mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 3:
-   root_freq = PLL2_PFD0_FREQ;
+   root_freq =  mxc_get_pll_pfd(PLL_BUS, 0);
break;
}
 
@@ -270,13 +316,14 @@ static u32 get_mmdc_ch0_clk(void)
freq = decode_pll(PLL_BUS, MXC_HCLK);
break;
case 1:
-   freq = PLL2_PFD2_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 2);
break;
case 2:
-   freq = PLL2_PFD0_FREQ;
+   freq = mxc_get_pll_pfd(PLL_BUS, 0);
break;
case 3:
-   freq = PLL2_PFD2_DIV_FREQ;
+   /* static / 2 divider */
+   freq =  mxc_get_pll_pfd(PLL_BUS, 2) / 2;
}
 
return freq / (podf + 1);
@@ -329,9 +376,9 @@ static u32 get_usdhc_clk(u32 port

Re: [U-Boot] i.MX6DL/S regression in mx6dl_pins.h

2013-09-12 Thread Pierre AUBERT

Hello Eric,


Le 12/09/2013 23:56, Eric Nelson a écrit :

Hi all,

It seems to be all about displays and mux/pad registers for
me these days.

I just tracked down an issue related to commit 87d720e0c that
causes improper display on our RGB displays.

In particular, the pad settings for these two registers lost
their drive-strength value:

MX6_PAD_DISP0_DAT2__IPU1_DISP0_DAT_2
MX6_PAD_DISP0_DAT10__IPU1_DISP0_DAT_10

You're right, it was a mistake for these two pads.




I could make the case that things like pad drive strength
are a board-level tuning function, and belong in board-specific
files, but I think all RGB displays used with i.MX6 need
these values (and they should probably match the 6DQ).

Let me know if you'd like me to send a patch for this.

I have some other notes regarding consolidation of 6DQ and
6DLS that I'll send separately.

Regards,


Eric

Best regards
Pierre
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] usb: add support for the USB Ethernet adapter D-Link DUB-E100 H/W Ver C1

2013-06-27 Thread Pierre Aubert
This trivial patch adds the definition of the vid/pid for the Ver C1 of the
USB Ethernet adapter D-Link DUB-E100.


Signed-off-by: Pierre Aubert 
CC: Marek Vasut 
---
 drivers/usb/eth/asix.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c
index 76624b9..db39bd8 100644
--- a/drivers/usb/eth/asix.c
+++ b/drivers/usb/eth/asix.c
@@ -585,6 +585,7 @@ struct asix_dongle {
 static const struct asix_dongle const asix_dongles[] = {
{ 0x05ac, 0x1402, FLAG_TYPE_AX88772 },  /* Apple USB Ethernet Adapter */
{ 0x07d1, 0x3c05, FLAG_TYPE_AX88772 },  /* D-Link DUB-E100 H/W Ver B1 */
+   { 0x2001, 0x1a02, FLAG_TYPE_AX88772 },  /* D-Link DUB-E100 H/W Ver C1 */
/* Cables-to-Go USB Ethernet Adapter */
{ 0x0b95, 0x772a, FLAG_TYPE_AX88772 },
{ 0x0b95, 0x7720, FLAG_TYPE_AX88772 },  /* Trendnet TU2-ET100 V3.0R */
-- 
1.7.6.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [[PATCH]] imx6: fix GPR2 wrong definition

2013-06-19 Thread Pierre Aubert
Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---
 arch/arm/include/asm/arch-mx6/imx-regs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h 
b/arch/arm/include/asm/arch-mx6/imx-regs.h
index 03abb2a..45824f9 100644
--- a/arch/arm/include/asm/arch-mx6/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
@@ -364,7 +364,7 @@ struct iomuxc {
 
 #define IOMUXC_GPR2_MODE_DISABLED  0
 #define IOMUXC_GPR2_MODE_ENABLED_DI0   1
-#define IOMUXC_GPR2_MODE_ENABLED_DI1   2
+#define IOMUXC_GPR2_MODE_ENABLED_DI1   3
 
 #define IOMUXC_GPR2_LVDS_CH1_MODE_OFFSET   2
 #define IOMUXC_GPR2_LVDS_CH1_MODE_MASK 
(3<http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 2/2] imx: Add support for the SabreSD shipped with i.MX6DL

2013-06-04 Thread Pierre Aubert
The SabreSD platform is available with i.MX6Q or i.MX6DL. This patch adds the
support of the i.MX6DL. The config file and the board directory are renamed
to remove the reference to the MX6Q.


Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---
Changes in v2:
- update MAINTAINERS
- code cleanup
- remove the Soc type from the board name
Changes for v3:
- rebased on u-boot-imx

 MAINTAINERS|2 +-
 .../freescale/{mx6qsabresd => mx6sabresd}/Makefile |2 +-
 .../mx6qsabresd.c => mx6sabresd/mx6sabresd.c}  |7 ++-
 boards.cfg |5 +++--
 include/configs/mx6qsabreauto.h|2 +-
 .../{mx6qsabre_common.h => mx6sabre_common.h}  |1 -
 include/configs/{mx6qsabresd.h => mx6sabresd.h}|2 +-
 7 files changed, 9 insertions(+), 12 deletions(-)
 rename board/freescale/{mx6qsabresd => mx6sabresd}/Makefile (98%)
 rename board/freescale/{mx6qsabresd/mx6qsabresd.c => mx6sabresd/mx6sabresd.c} 
(98%)
 rename include/configs/{mx6qsabre_common.h => mx6sabre_common.h} (99%)
 rename include/configs/{mx6qsabresd.h => mx6sabresd.h} (97%)

diff --git a/MAINTAINERS b/MAINTAINERS
index e4113d8..649c16c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -662,7 +662,7 @@ Fabio Estevam 
mx31pdk i.MX31
mx53ard i.MX53
mx53smd i.MX53
-   mx6qsabresd i.MX6Q
+   mx6sabresd  i.MX6Q/DL
mx6qsabreauto   i.MX6Q
wandboard   i.MX6DL/S
mx6slevki.MX6SL
diff --git a/board/freescale/mx6qsabresd/Makefile 
b/board/freescale/mx6sabresd/Makefile
similarity index 98%
rename from board/freescale/mx6qsabresd/Makefile
rename to board/freescale/mx6sabresd/Makefile
index 5693772..ff3c94b 100644
--- a/board/freescale/mx6qsabresd/Makefile
+++ b/board/freescale/mx6sabresd/Makefile
@@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(BOARD).o
 
-COBJS  := mx6qsabresd.o
+COBJS  := mx6sabresd.o
 
 SRCS   := $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c 
b/board/freescale/mx6sabresd/mx6sabresd.c
similarity index 98%
rename from board/freescale/mx6qsabresd/mx6qsabresd.c
rename to board/freescale/mx6sabresd/mx6sabresd.c
index 2529826..222ee98 100644
--- a/board/freescale/mx6qsabresd/mx6qsabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -17,12 +17,10 @@
  * GNU General Public License for more details.
  */
 
-#include 
-#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -291,7 +289,6 @@ int board_late_init(void)
 
 int checkboard(void)
 {
-   puts("Board: MX6Q-SabreSD\n");
-
+   puts("Board: MX6-SabreSD\n");
return 0;
 }
diff --git a/boards.cfg b/boards.cfg
index 3fdf41e..f322a01 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -257,9 +257,10 @@ mx53smd  arm armv7   
mx53smd freesca
 ima3-mx53arm armv7   ima3-mx53   esg   
 mx5ima3-mx53:IMX_CONFIG=board/esg/ima3-mx53/imximage.cfg
 vision2  arm armv7   vision2 
ttcontrol  mx5
vision2:IMX_CONFIG=board/ttcontrol/vision2/imximage_hynix.cfg
 mx6qarm2 arm armv7   mx6qarm2
freescale  mx6
mx6qarm2:IMX_CONFIG=board/freescale/mx6qarm2/imximage.cfg
-mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg
+mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q
 mx6qsabrelitearm armv7   mx6qsabrelite   
freescale  mx6
mx6qsabrelite:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
-mx6qsabresd  arm armv7   mx6qsabresd 
freescale  mx6
mx6qsabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
+mx6dlsabresd arm armv7   mx6sabresd  
freescale  mx6
mx6sabresd:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl.cfg,MX6DL
+mx6qsabresd  arm armv7   mx6sabresd  
freescale  mx6
mx6sabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg,MX6Q
 mx6slevk arm armv7   mx6slevk
freescale  mx6
mx6slevk:IMX_CONFIG=board/freescale/mx6slevk/imximage.cfg,MX6SL
 titanium arm armv7   titanium
freescale  mx6
titanium:IMX_CONFIG=board/freescale/titanium/imximage.cfg
 vf610twr arm armv7

Re: [U-Boot] [PATCH] imx: Complete the pin definitions for the i.MX6DL / i.MX6Solo

2013-06-03 Thread Pierre AUBERT

Hi Stephano,

Le 03/06/2013 15:03, Stefano Babic a écrit :
...
Patch needs a rebased to be merge. Could you repost them (also 2/2) 
after rebasing on current u-boot-imx ? Thanks ! Best regards, Stefano 
Babic 


I will submit a V3 today.
Best regards
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] imx: Add support for the SabreSD shipped with i.MX6DL

2013-04-21 Thread Pierre Aubert
The SabreSD platform is available with i.MX6Q or i.MX6DL. This patch adds the
support of the i.MX6DL. The config file and the board directory are renamed
to remove the reference to the MX6Q.


Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---
Changes in v2:
- update MAINTAINERS
- code cleanup
- remove the Soc type from the board name

 MAINTAINERS|2 +-
 .../freescale/{mx6qsabresd => mx6sabresd}/Makefile |2 +-
 .../mx6qsabresd.c => mx6sabresd/mx6sabresd.c}  |7 ++-
 boards.cfg |5 +++--
 include/configs/mx6qsabreauto.h|2 +-
 .../{mx6qsabre_common.h => mx6sabre_common.h}  |1 -
 include/configs/{mx6qsabresd.h => mx6sabresd.h}|2 +-
 7 files changed, 9 insertions(+), 12 deletions(-)
 rename board/freescale/{mx6qsabresd => mx6sabresd}/Makefile (98%)
 rename board/freescale/{mx6qsabresd/mx6qsabresd.c => mx6sabresd/mx6sabresd.c} 
(98%)
 rename include/configs/{mx6qsabre_common.h => mx6sabre_common.h} (99%)
 rename include/configs/{mx6qsabresd.h => mx6sabresd.h} (97%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 643a5ac..50ca73c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -661,7 +661,7 @@ Fabio Estevam 
mx31pdk i.MX31
mx53ard i.MX53
mx53smd i.MX53
-   mx6qsabresd i.MX6Q
+   mx6sabresd  i.MX6Q/DL
mx6qsabreauto   i.MX6Q
wandboard   i.MX6DL/S
 
diff --git a/board/freescale/mx6qsabresd/Makefile 
b/board/freescale/mx6sabresd/Makefile
similarity index 98%
rename from board/freescale/mx6qsabresd/Makefile
rename to board/freescale/mx6sabresd/Makefile
index 5693772..ff3c94b 100644
--- a/board/freescale/mx6qsabresd/Makefile
+++ b/board/freescale/mx6sabresd/Makefile
@@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(BOARD).o
 
-COBJS  := mx6qsabresd.o
+COBJS  := mx6sabresd.o
 
 SRCS   := $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c 
b/board/freescale/mx6sabresd/mx6sabresd.c
similarity index 98%
rename from board/freescale/mx6qsabresd/mx6qsabresd.c
rename to board/freescale/mx6sabresd/mx6sabresd.c
index 0d7cb9e..1b6805b 100644
--- a/board/freescale/mx6qsabresd/mx6qsabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -17,12 +17,10 @@
  * GNU General Public License for more details.
  */
 
-#include 
-#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -291,7 +289,6 @@ int board_late_init(void)
 
 int checkboard(void)
 {
-   puts("Board: MX6Q-SabreSD\n");
-
+   puts("Board: MX6-SabreSD\n");
return 0;
 }
diff --git a/boards.cfg b/boards.cfg
index 31483d6..427cb11 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -256,9 +256,10 @@ mx53smd  arm armv7   
mx53smd freesca
 ima3-mx53arm armv7   ima3-mx53   esg   
 mx5ima3-mx53:IMX_CONFIG=board/esg/ima3-mx53/imximage.cfg
 vision2  arm armv7   vision2 
ttcontrol  mx5
vision2:IMX_CONFIG=board/ttcontrol/vision2/imximage_hynix.cfg
 mx6qarm2 arm armv7   mx6qarm2
freescale  mx6
mx6qarm2:IMX_CONFIG=board/freescale/mx6qarm2/imximage.cfg
-mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg
+mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q
 mx6qsabrelitearm armv7   mx6qsabrelite   
freescale  mx6
mx6qsabrelite:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
-mx6qsabresd  arm armv7   mx6qsabresd 
freescale  mx6
mx6qsabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
+mx6qsabresd  arm armv7   mx6sabresd 
freescale  mx6 
mx6sabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg,MX6Q
+mx6dlsabresd  arm armv7   mx6sabresd 
freescale  mx6
mx6sabresd:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl.cfg,MX6DL
 eco5pk   arm armv7   eco5pk  
8dtech omap3
 nitrogen6dl  arm armv7   nitrogen6x  
boundary   mx6
nitrogen6x:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl.cfg,MX6DL,DDR_MB=1024
 nitrogen6dl2garm armv7   nitrogen6x  
boundary   mx6
nitrogen6x:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl2g.cfg,MX

Re: [U-Boot] [PATCH] imx: Add support for the SabreSD shipped with i.MX6DL

2013-04-19 Thread Pierre AUBERT

Le 19/04/2013 10:15, Stefano Babic a écrit :



  int checkboard(void)
  {
-   puts("Board: MX6Q-SabreSD\n");
-
+#ifdef CONFIG_MX6Q
+puts("Board: MX6Q-SabreSD\n");
+#else
+puts("Board: MX6DL-SabreSD\n");
+#endif

Can we please avoid such #ifdef's?  Here, we could for example refer
to the board name (CONFIG_SYS_BOARD if you like the name, or some
custom defined CONFIG_BOARD_NAME like other boards do).

And who does set CONFIG_MX6Q ? You drop it, but I do not see who sets it.

It is set in boards.cfg:

-mx6qsabresd  arm armv7   mx6qsabresd 
freescale  mx6
mx6qsabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
+mx6qsabresd  arm armv7   mx6sabresd 
freescale  mx6 
mx6sabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg,MX6Q




Best regards,
Stefano Babic


Best regards
Pierre Aubert
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: Add support for the SabreSD shipped with i.MX6DL

2013-04-18 Thread Pierre AUBERT

Hello Wolfgang,

Le 18/04/2013 19:37, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1366296086-22394-1-git-send-email-p.aub...@staubli.com> you wrote:

The SabreSD platform is available with i.MX6Q or i.MX6DL. This patch adds the
support of the i.MX6DL. The config file and the board directory are renamed
to remove the reference to the MX6Q.

Formal issues:

- entry to MAINTAINERS file missing
Fabio Estevam is already the maintainer of the SabreSD. I didn't add any 
new boad, I've just add the support for the i.MX6DL on this board. I 
will update the MAINTAINERS file.



- there are 2 checkpatch warnings ("please, no spaces at the start of
   a line") that need to be fixed.

Will be fixed



  int checkboard(void)
  {
-   puts("Board: MX6Q-SabreSD\n");
-
+#ifdef CONFIG_MX6Q
+puts("Board: MX6Q-SabreSD\n");
+#else
+puts("Board: MX6DL-SabreSD\n");
+#endif

Can we please avoid such #ifdef's?  Here, we could for example refer
to the board name (CONFIG_SYS_BOARD if you like the name, or some
custom defined CONFIG_BOARD_NAME like other boards do).

The board name in MX6-SabreSD. The Soc type (dual or quad core) is 
already printed by print_cpuinfo.

Best regards,

Wolfgang Denk


Best regards
Pierre Aubert
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: Add support for the SabreSD shipped with i.MX6DL

2013-04-18 Thread Pierre AUBERT

Hi Fabio,

I can split the patch if you wish, but in this case the compilation 
would be broken for the sabreauto if only one of the two patches is 
applied.


Best regards

Pierre Aubert

Le 18/04/2013 19:51, Fabio Estevam a écrit :

Hi Pierre,

On Thu, Apr 18, 2013 at 11:41 AM, Pierre Aubert  wrote:


diff --git a/boards.cfg b/boards.cfg
index f785da8..c002cf7 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -256,9 +256,10 @@ mx53smd  arm armv7   
mx53smd freesca
  ima3-mx53arm armv7   ima3-mx53   esg  
  mx5ima3-mx53:IMX_CONFIG=board/esg/ima3-mx53/imximage.cfg
  vision2  arm armv7   vision2 
ttcontrol  mx5
vision2:IMX_CONFIG=board/ttcontrol/vision2/imximage_hynix.cfg
  mx6qarm2 arm armv7   mx6qarm2
freescale  mx6
mx6qarm2:IMX_CONFIG=board/freescale/mx6qarm2/imximage.cfg
-mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg
+mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q

mx6qsabreauto changes should be done on a different patch.

Regards,

Fabio Estevam


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: Complete the pin definitions for the i.MX6DL / i.MX6Solo

2013-04-18 Thread Pierre AUBERT

Hello Wolfgang

Le 18/04/2013 19:38, Wolfgang Denk a écrit :

Dear Pierre AUBERT,

In message <51700b80.2090...@staubli.com> you wrote:

What is the purpose of this patch?  Who needs the added definitions?

These new definitions are useful for all boards based on i.MX6DL or
i.MX6Solo.
I just submitted a patch to support SabreSD equipped with i.MX6DL.
I missed the submission of two patches together.

So your SabreSD patch depends on this one?

Yes

I just asked for some cleanup for that other patch, so when
resubmitting you can make this a series.

I will resubmit as a serie today.


Best regards,

Wolfgang Denk


Best regards
Pierre Aubert
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] imx: Complete the pin definitions for the i.MX6DL / i.MX6Solo

2013-04-18 Thread Pierre AUBERT

Hello Wolfgang,

Le 18/04/2013 16:41, Wolfgang Denk a écrit :

Dear Pierre Aubert,

In message <1366286251-17552-1-git-send-email-p.aub...@staubli.com> you wrote:

Signed-off-by: Pierre Aubert 
CC: Stefano Babic 

What is the purpose of this patch?  Who needs the added definitions?

These new definitions are useful for all boards based on i.MX6DL or
i.MX6Solo.
I just submitted a patch to support SabreSD equipped with i.MX6DL.
I missed the submission of two patches together.


The new formatting is less readable than the old one.  We have an
agreement that in this special case we accept lines longer than 80
charcters, so please leave the formatting as is.

That was my concern not exceed 80 characters.


[It's basically imposible to see in your patch what you actually
added.]

Ok, I will revert it.

Best regards
Pierre Aubert
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] imx: Add support for the SabreSD shipped with i.MX6DL

2013-04-18 Thread Pierre Aubert
The SabreSD platform is available with i.MX6Q or i.MX6DL. This patch adds the
support of the i.MX6DL. The config file and the board directory are renamed
to remove the reference to the MX6Q.


Signed-off-by: Pierre Aubert 
CC: Stefano Babic 
---
 .../freescale/{mx6qsabresd => mx6sabresd}/Makefile |2 +-
 .../mx6qsabresd.c => mx6sabresd/mx6sabresd.c}  |   11 ++-
 boards.cfg |5 +++--
 include/configs/mx6qsabreauto.h|2 +-
 .../{mx6qsabre_common.h => mx6sabre_common.h}  |1 -
 include/configs/{mx6qsabresd.h => mx6sabresd.h}|2 +-
 6 files changed, 12 insertions(+), 11 deletions(-)
 rename board/freescale/{mx6qsabresd => mx6sabresd}/Makefile (98%)
 rename board/freescale/{mx6qsabresd/mx6qsabresd.c => mx6sabresd/mx6sabresd.c} 
(98%)
 rename include/configs/{mx6qsabre_common.h => mx6sabre_common.h} (99%)
 rename include/configs/{mx6qsabresd.h => mx6sabresd.h} (97%)

diff --git a/board/freescale/mx6qsabresd/Makefile 
b/board/freescale/mx6sabresd/Makefile
similarity index 98%
rename from board/freescale/mx6qsabresd/Makefile
rename to board/freescale/mx6sabresd/Makefile
index 5693772..ff3c94b 100644
--- a/board/freescale/mx6qsabresd/Makefile
+++ b/board/freescale/mx6sabresd/Makefile
@@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(BOARD).o
 
-COBJS  := mx6qsabresd.o
+COBJS  := mx6sabresd.o
 
 SRCS   := $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c 
b/board/freescale/mx6sabresd/mx6sabresd.c
similarity index 98%
rename from board/freescale/mx6qsabresd/mx6qsabresd.c
rename to board/freescale/mx6sabresd/mx6sabresd.c
index 0d7cb9e..dcefdab 100644
--- a/board/freescale/mx6qsabresd/mx6qsabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -17,12 +17,10 @@
  * GNU General Public License for more details.
  */
 
-#include 
-#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -291,7 +289,10 @@ int board_late_init(void)
 
 int checkboard(void)
 {
-   puts("Board: MX6Q-SabreSD\n");
-
+#ifdef CONFIG_MX6Q
+puts("Board: MX6Q-SabreSD\n");
+#else
+puts("Board: MX6DL-SabreSD\n");
+#endif
return 0;
 }
diff --git a/boards.cfg b/boards.cfg
index f785da8..c002cf7 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -256,9 +256,10 @@ mx53smd  arm armv7   
mx53smd freesca
 ima3-mx53arm armv7   ima3-mx53   esg   
 mx5ima3-mx53:IMX_CONFIG=board/esg/ima3-mx53/imximage.cfg
 vision2  arm armv7   vision2 
ttcontrol  mx5
vision2:IMX_CONFIG=board/ttcontrol/vision2/imximage_hynix.cfg
 mx6qarm2 arm armv7   mx6qarm2
freescale  mx6
mx6qarm2:IMX_CONFIG=board/freescale/mx6qarm2/imximage.cfg
-mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg
+mx6qsabreautoarm armv7   mx6qsabreauto   
freescale  mx6
mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q
 mx6qsabrelitearm armv7   mx6qsabrelite   
freescale  mx6
mx6qsabrelite:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
-mx6qsabresd  arm armv7   mx6qsabresd 
freescale  mx6
mx6qsabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
+mx6qsabresd  arm armv7   mx6sabresd 
freescale  mx6 
mx6sabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg,MX6Q
+mx6dlsabresd  arm armv7   mx6sabresd 
freescale  mx6
mx6sabresd:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl.cfg,MX6DL
 eco5pk   arm armv7   eco5pk  
8dtech omap3
 nitrogen6dl  arm armv7   nitrogen6x  
boundary   mx6
nitrogen6x:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl.cfg,MX6DL,DDR_MB=1024
 nitrogen6dl2garm armv7   nitrogen6x  
boundary   mx6
nitrogen6x:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl2g.cfg,MX6DL,DDR_MB=2048
diff --git a/include/configs/mx6qsabreauto.h b/include/configs/mx6qsabreauto.h
index 1583c11..099839a 100644
--- a/include/configs/mx6qsabreauto.h
+++ b/include/configs/mx6qsabreauto.h
@@ -30,7 +30,7 @@
 #define CONFIG_MXC_USB_PORTSC  (PORT_PTS_UTMI | PORT_PTS_PTW)
 #define CONFIG_MXC_USB_FLAGS   0
 
-#include "mx6qsabre_common.h"
+#include "mx6sabre_common.h"
 
 #define CONFIG_SYS_FSL_USDHC_NUM   2
 #if defined(CONFIG_ENV_IS_