Re: [U-Boot] [PATCH v2] nios2: convert nios2 cpu to driver model

2015-09-29 Thread Thomas Chou

Hi Marek,

On 09/29/2015 10:45 AM, Marek Vasut wrote:

--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -64,6 +64,9 @@ config NIOS2
select HAVE_GENERIC_BOARD
select SYS_GENERIC_BOARD
select SUPPORT_OF_CONTROL
+   select OF_CONTROL
+   select DM
+   select CPU


What's this CONFIG_CPU for please ?


drivers/cpu/Kconfig

It is "Enable CPU drivers using Driver Model". I think it should have 
been named as CONFIG_DM_CPU to avoid confusion.



-int arch_cpu_init(void)
+int arch_cpu_init_dm(void)
  {
-   gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
+   struct udevice *dev;
+
+   uclass_first_device(UCLASS_CPU, );
+   if (!dev)
+   return -ENODEV;
+
+   gd->cpu_clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "clock-frequency", 0);
+   gd->arch.dcache_line_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "dcache-line-size", 0);
+   gd->arch.icache_line_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "icache-line-size", 0);
+   gd->arch.dcache_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "dcache-size", 0);
+   gd->arch.icache_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "icache-size", 0);
+   gd->arch.reset_addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "altr,reset-addr", 0);
+   gd->arch.exception_addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "altr,exception-addr", 0);
+   gd->arch.has_mmu = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "altr,has-mmu", 0);


Shouldn't there be some sort of return value checking here ?


There might be some. Though I would like to depend upon the sopc2dts 
which generates the dts. I don't think these values should be tweaked by 
a human. :)





+   info->features = 1 << CPU_FEAT_L1_CACHE
+   | (gd->arch.has_mmu ? 1 << CPU_FEAT_MMU : 0);


I'd add parenthesis around the bitshifts, for the sake of clarity.
Also, please put the ORR operator at the end of the line.


Will do as suggested.

Thanks a lot for your review.

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


Re: [U-Boot] [PATCH v2 06/13] cmd: Convert CONFIG_CMD_ELF to Kconfig

2015-09-29 Thread Hannes Schmelzer

Tested-by: Hannes Schmelzer  on B kwb board.

On 28.09.2015 11:12, Bin Meng wrote:

Convert CONFIG_CMD_ELF to Kconfig and tidy up affected boards.

Signed-off-by: Bin Meng 

---

Changes in v2:
- Split the defconfig reorder to another patch, making this patch
   as CONFIG_CMD_ELF mods only
- Update sparc and avr32 boards to unset CONFIG_CMD_ELF

  common/Kconfig  | 6 ++
  configs/atngw100_defconfig  | 1 +
  configs/atngw100mkii_defconfig  | 1 +
  configs/atstk1002_defconfig | 1 +
  configs/dbau1000_defconfig  | 1 +
  configs/dbau1100_defconfig  | 1 +
  configs/dbau1500_defconfig  | 1 +
  configs/dbau1550_defconfig  | 1 +
  configs/dbau1550_el_defconfig   | 1 +
  configs/dlvision-10g_defconfig  | 1 +
  configs/dlvision_defconfig  | 1 +
  configs/gr_cpci_ax2000_defconfig| 1 +
  configs/gr_ep2s60_defconfig | 1 +
  configs/gr_xc3s_1500_defconfig  | 1 +
  configs/grasshopper_defconfig   | 1 +
  configs/grsim_defconfig | 1 +
  configs/grsim_leon2_defconfig   | 1 +
  configs/io_defconfig| 1 +
  configs/iocon_defconfig | 1 +
  configs/neo_defconfig   | 1 +
  configs/pb1000_defconfig| 1 +
  configs/sandbox_defconfig   | 1 +
  configs/vct_platinum_onenand_small_defconfig| 1 +
  configs/vct_platinum_small_defconfig| 1 +
  configs/vct_platinumavc_onenand_small_defconfig | 1 +
  configs/vct_platinumavc_small_defconfig | 1 +
  configs/vct_premium_onenand_small_defconfig | 1 +
  configs/vct_premium_small_defconfig | 1 +
  include/config_cmd_all.h| 1 -
  include/config_distro_defaults.h| 1 -
  include/configs/B4860QDS.h  | 1 -
  include/configs/BSC9131RDB.h| 1 -
  include/configs/BSC9132QDS.h| 1 -
  include/configs/C29XPCIE.h  | 1 -
  include/configs/CPCI2DP.h   | 1 -
  include/configs/CPCI4052.h  | 1 -
  include/configs/M5208EVBE.h | 1 -
  include/configs/M52277EVB.h | 1 -
  include/configs/M5235EVB.h  | 1 -
  include/configs/M5272C3.h   | 1 -
  include/configs/M5275EVB.h  | 1 -
  include/configs/M53017EVB.h | 1 -
  include/configs/M5329EVB.h  | 1 -
  include/configs/M5373EVB.h  | 1 -
  include/configs/M54418TWR.h | 1 -
  include/configs/M54451EVB.h | 1 -
  include/configs/M54455EVB.h | 1 -
  include/configs/M5475EVB.h  | 1 -
  include/configs/M5485EVB.h  | 1 -
  include/configs/MIP405.h| 1 -
  include/configs/MPC8536DS.h | 1 -
  include/configs/MPC8540ADS.h| 1 -
  include/configs/MPC8541CDS.h| 1 -
  include/configs/MPC8544DS.h | 1 -
  include/configs/MPC8548CDS.h| 1 -
  include/configs/MPC8555CDS.h| 1 -
  include/configs/MPC8560ADS.h| 1 -
  include/configs/MPC8568MDS.h| 1 -
  include/configs/MPC8569MDS.h| 1 -
  include/configs/MPC8572DS.h | 1 -
  include/configs/P1010RDB.h  | 1 -
  include/configs/P1022DS.h   | 1 -
  include/configs/P2041RDB.h  | 1 -
  include/configs/PIP405.h| 1 -
  include/configs/PLU405.h| 1 -
  include/configs/PMC405DE.h  | 1 -
  include/configs/PMC440.h| 1 -
  include/configs/T102xQDS.h  | 1 -
  include/configs/T102xRDB.h  | 1 -
  include/configs/T1040QDS.h  | 1 -
  include/configs/T104xRDB.h  | 1 -
  include/configs/T208xQDS.h  | 1 -
  include/configs/T208xRDB.h  | 1 -
  include/configs/T4240RDB.h  | 1 -
  include/configs/TQM823L.h   | 1 -
  include/configs/TQM823M.h   | 1 -
  include/configs/TQM850L.h   | 1 -
  include/configs/TQM850M.h   | 1 -
  include/configs/TQM855L.h   | 1 -
  include/configs/TQM855M.h   | 1 -
  include/configs/TQM860L.h   | 1 -
  include/configs/TQM860M.h   | 1 -
  

Re: [U-Boot] [PATCH] net: bootp fix vci string on SPL-Boot

2015-09-29 Thread Hannes Schmelzer

Hi,

just checked my upstream branch and noticed that this patch is outstanding.
How about merge?

regards,
Hannes


On 25.08.2015 18:01, Joe Hershberger wrote:

Hi Hannes,

On Tue, Aug 25, 2015 at 5:17 AM, Hannes Schmelzer  wrote:

If CONFIG_CMD_DHCP is enabled, the vci (vendor-class-identifier) string
isn't inserted into the bootp-packet during SPL stage because the

CONFIG_BOOTP_VCI_STRING
instead
CONFIG_SPL_NET_VCI_STRING

We fix this with testing for CONFIG_SPL_BUILD and testing for existing
CONFIG_SPL_NET_VCI_STRING.

Signed-off-by: Hannes Schmelzer 

Acked-by: Joe Hershberger 




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


Re: [U-Boot] [ANN] U-Boot v2015.10-rc4 released

2015-09-29 Thread Wolfgang Denk
Dear Tom,

In message <20150928210901.GH22966@bill-the-cat> you wrote:
> 
> I've pushed v2015.10-rc4 out to the repository and tarballs should exist
> soon.

Tarballs are both on the FTP server [1] and the ACD [2].

[1] ftp://ftp.denx.de/pub/u-boot/
[2] 
https://www.amazon.com/clouddrive/share/9JvNre5ZS9KVI3kRyTjEQNYO5x9R5ai-CRXFuHdnWgs?ref_=cd_share_link_copy

> We're coming up on the release date and I think things are in reasonable
> shape overall.  Please speak up if there's some fixes I'm still
> overlooking, I thought I grabbed them all by now but I may have still
> missed something.

Thanks a lot!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Yes, it's a technical challenge, and  you  have  to  kind  of  admire
people  who go to the lengths of actually implementing it, but at the
same time you wonder about their IQ...
 --  Linus Torvalds in <5phda5$ml6$1...@palladium.transmeta.com>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 07/13] cmd: Clean up cmd_elf a little bit

2015-09-29 Thread Hannes Schmelzer

Tested-by: Hannes Schmelzer  on B kwb board.

On 28.09.2015 11:12, Bin Meng wrote:

This commit cleans up cmd_elf.c per U-Boot coding convention,
and removes the unnecessary DECLARE_GLOBAL_DATA_PTR and out-of-date
powerpc comments (it actually supports not only powerpc targets).

Signed-off-by: Bin Meng 
Reviewed-by: Tom Rini 
---



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


[U-Boot] [PATCH] tools: kwboot: Add support for UART boot mode patching for Armada XP/38x

2015-09-29 Thread Stefan Roese
Currently, kwboot only allows dynamic UART boot mode patching for SoCs
with header version 0 (Orion, Kirkwood). This patch now enables this "-p"
feature also for SoCs with header version 1 (Armada XP / 38x etc). With
this its possible now to use the UART boot mode without on images that
are generated for other boot devices, like SPI. So no need to change
BOOT_FROM to "uart" for UART xmodem booting any more.

Signed-off-by: Stefan Roese 
Cc: Luka Perkov 
Cc: Kevin Smith 
Cc: Dirk Eibach 
---
 tools/kwbimage.c |  94 ---
 tools/kwbimage.h | 133 ---
 tools/kwboot.c   |  37 +++-
 3 files changed, 125 insertions(+), 139 deletions(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 886682d..d33f1b6 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -17,89 +17,6 @@
 #include 
 #include "kwbimage.h"
 
-#define ALIGN_SUP(x, a) (((x) + (a - 1)) & ~(a - 1))
-
-/* Structure of the main header, version 0 (Kirkwood, Dove) */
-struct main_hdr_v0 {
-   uint8_t  blockid;   /*0 */
-   uint8_t  nandeccmode;   /*1 */
-   uint16_t nandpagesize;  /*2-3   */
-   uint32_t blocksize; /*4-7   */
-   uint32_t rsvd1; /*8-11  */
-   uint32_t srcaddr;   /*12-15 */
-   uint32_t destaddr;  /*16-19 */
-   uint32_t execaddr;  /*20-23 */
-   uint8_t  satapiomode;   /*24*/
-   uint8_t  rsvd3; /*25*/
-   uint16_t ddrinitdelay;  /*26-27 */
-   uint16_t rsvd2; /*28-29 */
-   uint8_t  ext;   /*30*/
-   uint8_t  checksum;  /*31*/
-};
-
-struct ext_hdr_v0_reg {
-   uint32_t raddr;
-   uint32_t rdata;
-};
-
-#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg))
-
-struct ext_hdr_v0 {
-   uint32_t  offset;
-   uint8_t   reserved[0x20 - sizeof(uint32_t)];
-   struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT];
-   uint8_t   reserved2[7];
-   uint8_t   checksum;
-};
-
-/* Structure of the main header, version 1 (Armada 370, Armada XP) */
-struct main_hdr_v1 {
-   uint8_t  blockid;   /* 0 */
-   uint8_t  reserved1; /* 1 */
-   uint16_t reserved2; /* 2-3 */
-   uint32_t blocksize; /* 4-7 */
-   uint8_t  version;   /* 8 */
-   uint8_t  headersz_msb;  /* 9 */
-   uint16_t headersz_lsb;  /* A-B */
-   uint32_t srcaddr;   /* C-F */
-   uint32_t destaddr;  /* 10-13 */
-   uint32_t execaddr;  /* 14-17 */
-   uint8_t  reserved3; /* 18 */
-   uint8_t  nandblocksize; /* 19 */
-   uint8_t  nandbadblklocation;/* 1A */
-   uint8_t  reserved4; /* 1B */
-   uint16_t reserved5; /* 1C-1D */
-   uint8_t  ext;   /* 1E */
-   uint8_t  checksum;  /* 1F */
-};
-
-/*
- * Header for the optional headers, version 1 (Armada 370, Armada XP)
- */
-struct opt_hdr_v1 {
-   uint8_t  headertype;
-   uint8_t  headersz_msb;
-   uint16_t headersz_lsb;
-   char data[0];
-};
-
-/*
- * Various values for the opt_hdr_v1->headertype field, describing the
- * different types of optional headers. The "secure" header contains
- * informations related to secure boot (encryption keys, etc.). The
- * "binary" header contains ARM binary code to be executed prior to
- * executing the main payload (usually the bootloader). This is
- * typically used to execute DDR3 training code. The "register" header
- * allows to describe a set of (address, value) tuples that are
- * generally used to configure the DRAM controller.
- */
-#define OPT_HDR_V1_SECURE_TYPE   0x1
-#define OPT_HDR_V1_BINARY_TYPE   0x2
-#define OPT_HDR_V1_REGISTER_TYPE 0x3
-
-#define KWBHEADER_V1_SIZE(hdr) \
-   (((hdr)->headersz_msb << 16) | (hdr)->headersz_lsb)
-
 static struct image_cfg_element *image_cfg;
 static int cfgn;
 
@@ -174,17 +91,6 @@ struct image_cfg_element {
 #define IMAGE_CFG_ELEMENT_MAX 256
 
 /*
- * Byte 8 of the image header contains the version number. In the v0
- * header, byte 8 was reserved, and always set to 0. In the v1 header,
- * byte 8 has been changed to a proper field, set to 1.
- */
-static unsigned int image_version(void *header)
-{
-   unsigned char *ptr = header;
-   return ptr[8];
-}
-
-/*
  * Utility functions to manipulate boot mode and ecc modes (convert
  * them back and forth between description strings and the
  * corresponding numerical identifiers).
diff --git a/tools/kwbimage.h b/tools/kwbimage.h
index 8e4a4e2..9d2585c 100644
--- a/tools/kwbimage.h
+++ b/tools/kwbimage.h
@@ -29,57 

Re: [U-Boot] [PATCH v2 2/2] spi: Add SPI NOR protection mechanism

2015-09-29 Thread Jagan Teki
On 29 September 2015 at 17:37, Fabio Estevam
 wrote:
> Many SPI flashes have protection bits (BP2, BP1 and BP0) in the
> status register that can protect selected regions of the SPI NOR.
>
> Take these bits into account when performing erase operations,
> making sure that the protected areas are skipped.
>
> Introduce the CONFIG_SPI_FLASH_STM_PROTECT option that can be
> selectedby systems that want to protect regions of SPI NOR flash
> using the same programming model as in the ST Micro SPI NOR flashes,
> like for example the M25P32.
>
> Based on the implementation from Brian Norris 
> for the Linux kernel:
> https://patchwork.ozlabs.org/patch/513041/

This patch is still under review, will see how it moves.

>
> Tested on a mx6qsabresd:
>
> => sf probe
> SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
> => sf protect on  0x3f 0x1
> => sf erase 0x3f 0x1
> offset 0x3f is protected and cannot be erased
> SF: 65536 bytes @ 0x3f Erased: ERROR
> => sf protect off  0x3f 0x1
> => sf erase 0x3f 0x1
> SF: 65536 bytes @ 0x3f Erased: OK

What if sf erase 0x3f 0x2 - it should skip first 0x1 from
0x3f and then erase next 0x1 from (0x3f+0x1) did you
verify this?

>
> Signed-off-by: Fabio Estevam 
> ---
> Changes since v1:
> - Add CONFIG_SPI_FLASH_STM_PROTECT in the Kconfig as suggested by
> Stefan Roese
>
>  common/cmd_sf.c   |  30 +++
>  drivers/mtd/spi/Kconfig   |  15 
>  drivers/mtd/spi/sf_internal.h |   6 --
>  drivers/mtd/spi/sf_ops.c  | 188 
> ++
>  include/spi_flash.h   |  25 +-
>  5 files changed, 256 insertions(+), 8 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index ac7f5df..a31243f 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -348,6 +348,28 @@ static int do_spi_flash_erase(int argc, char * const 
> argv[])
> return ret == 0 ? 0 : 1;
>  }
>
> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT
> +static int do_spi_protect(int argc, char * const argv[])
> +{
> +   int start, len, ret = 0;
> +
> +   if (argc != 4)
> +   return -1;
> +
> +   start = simple_strtoull(argv[2], NULL, 16);
> +   len = simple_strtoull(argv[3], NULL, 16);
> +
> +   if (strcmp(argv[1], "on") == 0)
> +   ret = stm_lock(flash, start, len);
> +   else if (strcmp(argv[1], "off") == 0)
> +   ret = stm_unlock(flash, start, len);
> +   else
> +   return -1;  /* Unknown parameter */
> +
> +   return ret == 0 ? 0 : 1;
> +}
> +#endif
> +
>  #ifdef CONFIG_CMD_SF_TEST
>  enum {
> STAGE_ERASE,
> @@ -540,6 +562,10 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int 
> argc,
> ret = do_spi_flash_read_write(argc, argv);
> else if (strcmp(cmd, "erase") == 0)
> ret = do_spi_flash_erase(argc, argv);
> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT
> +   else if (strcmp(cmd, "protect") == 0)
> +   ret = do_spi_protect(argc, argv);
> +#endif
>  #ifdef CONFIG_CMD_SF_TEST
> else if (!strcmp(cmd, "test"))
> ret = do_spi_flash_test(argc, argv);
> @@ -579,5 +605,9 @@ U_BOOT_CMD(
> "sf update addr offset|partition len- erase and write `len' bytes 
> from memory\n"
> " at `addr' to flash at 
> `offset'\n"
> " or to start of mtd 
> `partition'\n"
> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT
> +   "sf protect on/off sector len   - protect/unprotect 'len' 
> bytes starting\n"
> +   " at address 'sector'\n"
> +#endif
> SF_TEST_HELP
>  );
> diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
> index 3f7433c..2ee1089 100644
> --- a/drivers/mtd/spi/Kconfig
> +++ b/drivers/mtd/spi/Kconfig
> @@ -101,6 +101,21 @@ config SPI_FLASH_USE_4K_SECTORS
>   Please note that some tools/drivers/filesystems may not work with
>   4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
>
> +config SPI_FLASH_STM_PROTECT
> +   bool "Use STM flash protection mechanism"
> +   depends on SPI_FLASH
> +   help
> + Enable the built-in protection mechanism provided by the
> + BP2, BP1 and BP0 bits from the status register present
> + on ST-Micro flashes such as M25P32. Please refer to the
> + M25P32 datasheet to understand how to program these bits
> + in order to protect a selected region of the SPI NOR flash.
> +
> + This same bit protection programming model applies to SPI
> + NOR flashes from other manufacturers such as:
> + - Micron M25P32
> + - SST SST25V32B
> +
>  config SPI_FLASH_DATAFLASH
> bool "AT45xxx DataFlash support"
> depends on 

Re: [U-Boot] [PATCH] board/BuR/kwb: implement board-specific do_go_exec to form vxWorks bootline

2015-09-29 Thread Bin Meng
Hi Hannes,

On Tue, Sep 29, 2015 at 1:58 PM, Hannes Schmelzer
 wrote:
> Hi Bin,
>
> works now well.
> Also the thing with bootvx and the bootline works fine.

Great to hear! Maybe you can add a 'Tested-by' tag to my series if you like.

>
> I will send some v2 of my patch today.
>
> many thanks and best regards,
> Hannes
>
>
> On 29.09.2015 04:46, Bin Meng wrote:
>>
>> Hi Hannes,
>>
>> On Mon, Sep 28, 2015 at 8:01 PM, Bin Meng  wrote:
>>>
>>> Hi Hannes,
>>>
>>> On Mon, Sep 28, 2015 at 7:08 PM, Hannes Schmelzer
>>>  wrote:

 Hi Bin,

 i am not able to apply your patch from
 http://patchwork.ozlabs.org/patch/523289/
 to most current master.

 schmelzerh@hpm-debian ~/work/u-boot $ git am
 U-Boot-v2-01-13-Reorder-defconfigs-with-savedefconfig.patch
 Applying: Reorder defconfigs with 'savedefconfig'
 error: patch failed: configs/e2220-1170_defconfig:9
 error: configs/e2220-1170_defconfig: patch does not apply
 error: patch failed: configs/p2371-_defconfig:9
 error: configs/p2371-_defconfig: patch does not apply
 error: patch failed: configs/p2571_defconfig:9
 error: configs/p2571_defconfig: patch does not apply
 Patch failed at 0001 Reorder defconfigs with 'savedefconfig'

 maybe you've to rebase your working branch.

>>> Sorry. Yes, I forgot to rebase. Will send a new patch soon.
>>>
>> The patch#1 has been merged into u-boot/master. Please apply patch
>> 2-13 on top of latest mainline in the series and have a try.
>>

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


[U-Boot] [PATCH v2] board/BuR/kwb: use bootvx(...) (with bootline feature) instead go(...)

2015-09-29 Thread Hannes Schmelzer
Since we don't have for sure a valid IP-setup during
board_late_init(...) because it maybe allready stored in environment or
not, we cannot form a proper vxWorks bootline at this place.

So we move to the way, forming the bootline just before
executing/launching vxWorks. To do this we use the bootvx command
instead go.

We only have to form the "othbootargs" environment variable, the rest is
done pretty good by the "bootvx" commannd.

Signed-off-by: Hannes Schmelzer 
--
---

Changes in v2:
- form only othbootargs instead whole bootline within board-code
- depends now on Bin Mengs changes belong CMD_ELF
http://patchwork.ozlabs.org/patch/523289/
- adapt kwb_defconfig to the new Kconfig defaults
- use bootvx ... instead go ... to launch vxWorks kernel

 board/BuR/kwb/board.c | 27 +--
 configs/kwb_defconfig |  3 +++
 include/configs/kwb.h |  8 +---
 3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/board/BuR/kwb/board.c b/board/BuR/kwb/board.c
index 039ec20..ad74ff2 100644
--- a/board/BuR/kwb/board.c
+++ b/board/BuR/kwb/board.c
@@ -47,10 +47,6 @@
 #defineRSTCTRL_FORCE_PWR_NEN   0x0404
 #defineRSTCTRL_CAN_STB 0x4040
 
-#define VXWORKS_BOOTLINE   0x80001100
-#define DEFAULT_BOOTLINE   "cpsw(0,0):pme/vxWorks"
-#define VXWORKS_USER   "u=vxWorksFTP pw=vxWorks tn=vxtarget"
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(CONFIG_SPL_BUILD)
@@ -281,20 +277,15 @@ int board_late_init(void)
} else {
puts("ERROR: i2c_set_bus_speed failed! (scratchregister)\n");
}
-   /* setup vxworks bootline */
-   char *vxworksbootline = (char *)VXWORKS_BOOTLINE;
-   sprintf(vxworksbootline,
-   "%s h=%s e=%s:%s g=%s %s o=0x%08x;0x%08x;0x%08x;0x%08x",
-   DEFAULT_BOOTLINE,
-   getenv("serverip"),
-   getenv("ipaddr"), getenv("netmask"),
-   getenv("gatewayip"),
-   VXWORKS_USER,
-   (unsigned int) gd->fb_base-0x20,
-   (u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
-   (u32)getenv_ulong("vx_romfsbase", 16, 0),
-   (u32)getenv_ulong("vx_romfssize", 16, 0));
-
+   /* setup othbootargs for bootvx-command (vxWorks bootline) */
+   char othbootargs[128];
+   snprintf(othbootargs, sizeof(othbootargs),
+"u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x",
+(unsigned int) gd->fb_base-0x20,
+(u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
+(u32)getenv_ulong("vx_romfsbase", 16, 0),
+(u32)getenv_ulong("vx_romfssize", 16, 0));
+   setenv("othbootargs", othbootargs);
/*
 * reset VBAR registers to its reset location, VxWorks 6.9.3.2 does
 * expect that vectors are there, original u-boot moves them to _start
diff --git a/configs/kwb_defconfig b/configs/kwb_defconfig
index f82fcf3..0bbe0a7 100644
--- a/configs/kwb_defconfig
+++ b/configs/kwb_defconfig
@@ -3,6 +3,9 @@ CONFIG_TARGET_KWB=y
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1"
 CONFIG_SYS_PROMPT="U-Boot (BuR V2.0)# "
+# CONFIG_CMD_BOOTD is not set
+# CONFIG_CMD_BOOTM is not set
+# CONFIG_CMD_GO is not set
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_XIMG is not set
diff --git a/include/configs/kwb.h b/include/configs/kwb.h
index 96f2e9d..45253b8 100644
--- a/include/configs/kwb.h
+++ b/include/configs/kwb.h
@@ -57,6 +57,8 @@
 #ifndef CONFIG_SPL_BUILD
 #define CONFIG_EXTRA_ENV_SETTINGS \
 BUR_COMMON_ENV \
+"bootaddr=0x80001100\0" \
+"bootdev=cpsw(0,0)\0" \
 "vx_romfsbase=0x800E\0" \
 "vx_romfssize=0x2\0" \
 "vx_memtop=0x8FBEF000\0" \
@@ -66,7 +68,7 @@ BUR_COMMON_ENV \
 "logoaddr=0x8200\0" \
 "defaultARlen=0x8000\0" \
 "loaddefaultAR=mmc read ${loadaddr} 800 ${defaultARlen}\0" \
-"defaultAR=run loadromfs; run loaddefaultAR; go ${loadaddr}\0" \
+"defaultAR=run loadromfs; run loaddefaultAR; bootvx ${loadaddr}\0" \
 "logo0=fatload mmc 0:1 ${logoaddr} SYSTEM/ADDON/Bootlogo/Bootlogo.bmp.gz && " \
"bmp display ${logoaddr} 0 0\0" \
 "logo1=fatload mmc 0:1 ${logoaddr} SYSTEM/BASE/Bootlogo/Bootlogo.bmp.gz && " \
@@ -74,11 +76,11 @@ BUR_COMMON_ENV \
 "mmcboot=echo booting AR from eMMC-flash ...; "\
"run logo0 || run logo1; " \
"run loadromfs; " \
-   "fatload mmc 0:1 ${loadaddr} arimg && go ${loadaddr}; " \
+   "fatload mmc 0:1 ${loadaddr} arimg && bootvx ${loadaddr}; " \
"run defaultAR;\0" \
 "netboot=echo booting AR from network ...; " \
"run loadromfs; " \
-   "tftp ${loadaddr} arimg && go ${loadaddr}; " \
+   "tftp ${loadaddr} arimg && bootvx ${loadaddr}; " \
"puts 'networkboot failed!';\0" \
 "netscript=echo running script from network (tftp) ...; " \
"tftp 0x8000 netscript.img && source; " \
-- 
1.9.1


Re: [U-Boot] [PATCH v2 10/13] cmd: bootvx: Always get VxWorks bootline from env

2015-09-29 Thread Hannes Schmelzer

Tested-by: Hannes Schmelzer  on B kwb board.

On 28.09.2015 11:12, Bin Meng wrote:

So far VxWorks bootline can be contructed from various environment
variables, but when these variables do not exist we get these from
corresponding config macros. This is not helpful as it requires
rebuilding U-Boot, and to make sure these config macros take effect
we should not have these environment variables. This is a little
bit complex and confusing.

Now we change the logic to always contruct the bootline from
environments (the only single source), by adding two new variables
"bootdev" and "othbootargs", and adding some comments about network
related settings mentioning they are optional. The doc about the
bootline handling is also updated.

Signed-off-by: Bin Meng 
Reviewed-by: Tom Rini 
---

Changes in v2: None

  README|  12 +-
  common/cmd_elf.c  | 121 +++---
  include/vxworks.h |  22 --
  3 files changed, 72 insertions(+), 83 deletions(-)


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


Re: [U-Boot] [PATCH 2/2] spi: Add SPI NOR protection mechanism

2015-09-29 Thread Stefan Roese

Hi Fabio,

On 29.09.2015 04:45, Fabio Estevam wrote:

From: Fabio Estevam 

Many SPI flashes have protection bits (BP2, BP1 and BP0) in the
status register that can protect selected regions of the SPI NOR.

Take these bits into account when performing erase operations,
making sure that the protected areas are skipped.

Introduce the CONFIG_SF_STM_PROTECT option that can be selected
by systems that want to protect regions of SPI NOR flash using
the same programming model as in the ST Micro SPI NOR flashes, like
for example the M25P32.

Based on the implementation from Brian Norris 
for the Linux kernel:
https://patchwork.ozlabs.org/patch/513041/

Tested on a mx6qsabresd:

=> sf probe
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
=> sf protect on  0x3f 0x1
=> sf erase 0x3f 0x1
offset 0x3f is protected and cannot be erased
SF: 65536 bytes @ 0x3f Erased: ERROR
=> sf protect off  0x3f 0x1
=> sf erase 0x3f 0x1
SF: 65536 bytes @ 0x3f Erased: OK

Signed-off-by: Fabio Estevam 
---

  README|  12 +++
  common/cmd_sf.c   |  30 +++
  drivers/mtd/spi/sf_internal.h |   6 --
  drivers/mtd/spi/sf_ops.c  | 188 ++
  include/spi_flash.h   |  25 +-
  5 files changed, 253 insertions(+), 8 deletions(-)

diff --git a/README b/README
index a13705a..3411ea9 100644
--- a/README
+++ b/README
@@ -3068,6 +3068,18 @@ CBFS (Coreboot Filesystem) support
memories can be connected with a given cs line.
Currently Xilinx Zynq qspi supports these type of connections.

+   CONFIG_SF_STM_PROTECT
+
+   Enable the built-in protection mechanism provided by the
+   BP2, BP1 and BP0 bits from the status register present
+   on ST-Micro flashes such as M25P32. Please refer to the
+   M25P32 datasheet to understand how to program these bits
+   in order to protect a selected region of the SPI NOR flash.
+   This same bit protection programming model applies to SPI
+   NOR flashes from other manufacturers such as:
+   - Micron M25P32
+   - SST SST25V32B


We should not add more CONFIG_ descriptions to this README. Please
add this option via Kconfig (in drivers/mtd/spi/Kconfig) and add
its description there as well.

Thanks,
Stefan

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


[U-Boot] [PATCH 2/2] nios2: convert altera sysid to driver model

2015-09-29 Thread Thomas Chou
Convert altera sysid to driver model with misc uclass.

Signed-off-by: Thomas Chou 
---
 arch/nios2/cpu/Makefile|  2 +-
 arch/nios2/cpu/cpu.c   | 15 +
 arch/nios2/cpu/sysid.c | 46 --
 arch/nios2/dts/3c120_devboard.dts  |  8 +++
 board/altera/nios2-generic/nios2-generic.c |  6 +-
 configs/nios2-generic_defconfig|  2 +
 drivers/misc/Kconfig   |  7 +++
 drivers/misc/Makefile  |  1 +
 drivers/misc/altera_sysid.c| 99 ++
 include/configs/nios2-generic.h|  3 +-
 10 files changed, 126 insertions(+), 63 deletions(-)
 delete mode 100644 arch/nios2/cpu/sysid.c
 create mode 100644 drivers/misc/altera_sysid.c

diff --git a/arch/nios2/cpu/Makefile b/arch/nios2/cpu/Makefile
index 3fe7847..185ca3c 100644
--- a/arch/nios2/cpu/Makefile
+++ b/arch/nios2/cpu/Makefile
@@ -7,5 +7,5 @@
 
 extra-y= start.o
 obj-y  = exceptions.o
-obj-y  += cpu.o interrupts.o sysid.o traps.o
+obj-y  += cpu.o interrupts.o traps.o
 obj-y  += fdt.o
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 88984e2..7b1717c 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -13,22 +13,11 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
-extern void display_sysid (void);
-#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
-
-#ifdef CONFIG_DISPLAY_CPUINFO
 int print_cpuinfo(void)
 {
-   printf ("CPU   : Nios-II\n");
-#if !defined(CONFIG_SYS_NIOS_SYSID_BASE)
-   printf ("SYSID : \n");
-#else
-   display_sysid ();
-#endif
-   return (0);
+   printf("CPU:   Nios-II\n");
+   return 0;
 }
-#endif /* CONFIG_DISPLAY_CPUINFO */
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/arch/nios2/cpu/sysid.c b/arch/nios2/cpu/sysid.c
deleted file mode 100644
index 50819b2..000
--- a/arch/nios2/cpu/sysid.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * (C) Copyright 2004, Psyent Corporation 
- * Scott McNutt 
- *
- * SPDX-License-Identifier:GPL-2.0+
- */
-
-#include 
-
-#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
-
-#include 
-#include 
-#include 
-
-typedef volatile struct {
-   unsignedid; /* The system build id */
-   unsignedtimestamp;  /* Timestamp */
-} nios_sysid_t;
-
-void display_sysid (void)
-{
-   nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
-   struct tm t;
-   char asc[32];
-   time_t stamp;
-
-   stamp = readl (>timestamp);
-   localtime_r (, );
-   asctime_r (, asc);
-   printf ("SYSID : %08lx, %s", readl (>id), asc);
-
-}
-
-int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-   display_sysid ();
-   return (0);
-}
-
-U_BOOT_CMD(
-   sysid,  1,  1,  do_sysid,
-   "display Nios-II system id",
-   ""
-);
-#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
diff --git a/arch/nios2/dts/3c120_devboard.dts 
b/arch/nios2/dts/3c120_devboard.dts
index 2e2956f..2eb339c 100644
--- a/arch/nios2/dts/3c120_devboard.dts
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -72,6 +72,7 @@
<0x4cc0 0x08004cc0 0x0010>,
<0x4ce0 0x08004ce0 0x0010>,
<0x4d00 0x08004d00 0x0010>,
+   <0x4d40 0x08004d40 0x0008>,
<0x4d50 0x08004d50 0x0008>,
<0x8000 0x08008000 0x0020>,
<0x0040 0x0840 0x0020>;
@@ -92,6 +93,13 @@
clock-frequency = < 12500 >;
};
 
+   sysid: sysid@0x4d40 {
+   compatible = "altr,sysid-1.0";
+   reg = <0x4d40 0x0008>;
+   id = <0>;
+   timestamp = <1440939556>;
+   };
+
jtag_uart: serial@0x4d50 {
compatible = "altr,juart-1.0";
reg = <0x4d50 0x0008>;
diff --git a/board/altera/nios2-generic/nios2-generic.c 
b/board/altera/nios2-generic/nios2-generic.c
index 61d32c7..e08b8f7 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -42,7 +42,11 @@ int board_early_init_r(void)
 
 int checkboard(void)
 {
-   printf("BOARD : %s\n", CONFIG_BOARD_NAME);
+#ifdef CONFIG_ALTERA_SYSID
+   extern void display_sysid(void);
+   display_sysid();
+#endif
+   printf("BOARD: %s\n", CONFIG_BOARD_NAME);
return 0;
 }
 
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index 1aa2d9e..d8d26e5 100644
--- a/configs/nios2-generic_defconfig
+++ 

[U-Boot] [PATCH 1/2] dm: implement a Miscellaneous uclass

2015-09-29 Thread Thomas Chou
Implement a Miscellaneous uclass with generic read or
write operations. This class is used only for those
do not fit other more general classes.

Signed-off-by: Thomas Chou 
---
 drivers/misc/Kconfig   |  6 ++
 drivers/misc/Makefile  |  1 +
 drivers/misc/misc-uclass.c | 14 ++
 include/dm/uclass-id.h |  1 +
 4 files changed, 22 insertions(+)
 create mode 100644 drivers/misc/misc-uclass.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8b38a84..51c2a08 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -4,6 +4,12 @@
 
 menu "Multifunction device drivers"
 
+config DM_MISC
+   bool "Enable Driver Model for Misc drivers"
+   depends on DM
+   help
+ Enable driver model for miscellaneous devices.
+
 config CMD_CROS_EC
bool "Enable crosec command"
depends on CROS_EC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 8d0fc3c..b285946 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+obj-$(CONFIG_DM_MISC) += misc-uclass.o
 obj-$(CONFIG_ALI152X) += ali512x.o
 obj-$(CONFIG_DS4510)  += ds4510.o
 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
new file mode 100644
index 000..40fe947
--- /dev/null
+++ b/drivers/misc/misc-uclass.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2010 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+UCLASS_DRIVER(misc) = {
+   .id = UCLASS_MISC,
+   .name   = "misc",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index aff34a4..a6982ab 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -39,6 +39,7 @@ enum uclass_id {
UCLASS_LED, /* Light-emitting diode (LED) */
UCLASS_LPC, /* x86 'low pin count' interface */
UCLASS_MASS_STORAGE,/* Mass storage device */
+   UCLASS_MISC,/* Miscellaneous device */
UCLASS_MMC, /* SD / MMC card or chip */
UCLASS_MOD_EXP, /* RSA Mod Exp device */
UCLASS_PCH, /* x86 platform controller hub */
-- 
2.1.4

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


Re: [U-Boot] [PATCH 03/11] Kconfig: add CONFIG_SYS_BOOTM_LEN

2015-09-29 Thread Hans de Goede

Hi,

On 28-09-15 23:12, Tom Rini wrote:

On Mon, Sep 28, 2015 at 09:22:35PM +0200, Hans de Goede wrote:

Hi,

On 28-09-15 17:10, Tom Rini wrote:

On Wed, Sep 23, 2015 at 10:25:35AM -0700, Ryan Harkin wrote:


As config migrates from board config files to Kconfig, when adding
CONFIG_SYS_BOOTM_LEN to a platform, I decided to add
Kconfig support for CONFIG_SYS_BOOTM_LEN.

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
CC: Masahiro Yamada 
CC: Simon Glass 
CC: Linus Walleij 


Thanks for trying to do this.  The problem however is that you need to
use tools/moveconfig.py so that all of the other boards (which is a lot)
get updated too, otherwise they fail to build.


No, just no, not more polluting of defconfig files with things which really
belong in a per SoC file not a per board file.


Well, we should be putting SoC/arch-specific stuff into the defaults


Agreed, but where, do we add a long list of:

default FOO if ARCH_BAR

To the Kconfig file where the actual CONFIG_SOMETHING gets defined, or
do we add it to board/bar/Kconfig ? Currently we've a bit of a mix,
I personally prefer the board/bar/Kconfig version as that puts everything for
one SoC(-family) in one place and it helps avoiding merge conflicts.


and
also using this as a chance to look at places where defaults differ
pointlessly.

But, I also hear your concern.  I see Masahiro has been working with
merge_config.sh from the kernel in the kernel.   How crazy would it be
to re-work things (in some cases..) to have a merge in the config
process so that there could be a sunxi-common config fragment.


Either we then ask the user to take an extra step during building
(not a good idea IMHO), or we somehow need to automate this, which is
hard because figuring out which foo_common_config fragment belongs
to which board_defconfig file is going to be hard and / or will
involve a long list of hardcoded values in a Makefile or some such.


Or
can/should we really just use default foo if Y in more places.


I believe that this is the better option, currently board/sunxi/Kconfig
already has:

config SYS_CLK_FREQ
default 91200 if MACH_SUN7I
default 100800 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || 
MACH_SUN8I

config SYS_CONFIG_NAME
default "sun4i" if MACH_SUN4I
default "sun5i" if MACH_SUN5I
default "sun6i" if MACH_SUN6I
default "sun7i" if MACH_SUN7I
default "sun8i" if MACH_SUN8I
default "sun9i" if MACH_SUN9I

Apparently these are not a problem for the script which is used to rewrite all
the defconfig-s, where as in the past having:

config CMD_FOO
default y

in board/sunxi/Kconfig was a problem (it caused the script to emit
a ton of warnings IIRC) so I guess that doing something like:

config FOO
default bar if ARCH_SUNXI

Will workaround the script issuing all kind of warnings, and then we
can keep per SoC(-family) defaults in board/foo/Kconfig.

Regards,

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


[U-Boot] [PATCH v2 2/2] nios2: convert altera timer to driver model

2015-09-29 Thread Thomas Chou
Convert altera timer to driver model.

Signed-off-by: Thomas Chou 
---
v2
  fix coding style.

 arch/nios2/cpu/Makefile |   2 +-
 arch/nios2/cpu/timer.c  |  65 
 common/board_f.c|   3 +-
 configs/nios2-generic_defconfig |   2 +
 drivers/timer/Kconfig   |   7 +++
 drivers/timer/Makefile  |   1 +
 drivers/timer/altera_timer.c| 110 
 include/configs/nios2-generic.h |   6 ---
 8 files changed, 122 insertions(+), 74 deletions(-)
 delete mode 100644 arch/nios2/cpu/timer.c
 create mode 100644 drivers/timer/altera_timer.c

diff --git a/arch/nios2/cpu/Makefile b/arch/nios2/cpu/Makefile
index c85e261..3fe7847 100644
--- a/arch/nios2/cpu/Makefile
+++ b/arch/nios2/cpu/Makefile
@@ -7,5 +7,5 @@
 
 extra-y= start.o
 obj-y  = exceptions.o
-obj-y  += cpu.o interrupts.o sysid.o timer.o traps.o
+obj-y  += cpu.o interrupts.o sysid.o traps.o
 obj-y  += fdt.o
diff --git a/arch/nios2/cpu/timer.c b/arch/nios2/cpu/timer.c
deleted file mode 100644
index b8aa9dd..000
--- a/arch/nios2/cpu/timer.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * (C) Copyright 2000-2002
- * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
- *
- * (C) Copyright 2004, Psyent Corporation 
- * Scott McNutt 
- *
- * SPDX-License-Identifier:GPL-2.0+
- */
-
-#include 
-#include 
-#include 
-#include 
-
-struct nios_timer {
-   u32 status; /* Timer status reg */
-   u32 control;/* Timer control reg */
-   u32 periodl;/* Timeout period low */
-   u32 periodh;/* Timeout period high */
-   u32 snapl;  /* Snapshot low */
-   u32 snaph;  /* Snapshot high */
-};
-
-/* status register */
-#define NIOS_TIMER_TO  (1 << 0)/* Timeout */
-#define NIOS_TIMER_RUN (1 << 1)/* Timer running */
-
-/* control register */
-#define NIOS_TIMER_ITO (1 << 0)/* Timeout interrupt enable */
-#define NIOS_TIMER_CONT(1 << 1)/* Continuous mode */
-#define NIOS_TIMER_START   (1 << 2)/* Start timer */
-#define NIOS_TIMER_STOP(1 << 3)/* Stop timer */
-
-/*/
-unsigned long notrace timer_read_counter(void)
-{
-   struct nios_timer *tmr = (struct nios_timer *)CONFIG_SYS_TIMER_BASE;
-   u32 val;
-
-   /* Trigger update */
-   writel(0x0, >snapl);
-
-   /* Read timer value */
-   val = readl(>snapl) & 0x;
-   val |= (readl(>snaph) & 0x) << 16;
-
-   return ~val;
-}
-
-int timer_init(void)
-{
-   struct nios_timer *tmr = (struct nios_timer *)CONFIG_SYS_TIMER_BASE;
-
-   writel(0, >status);
-   writel(0, >control);
-   writel(NIOS_TIMER_STOP, >control);
-
-   writel(0x, >periodl);
-   writel(0x, >periodh);
-
-   writel(NIOS_TIMER_CONT | NIOS_TIMER_START, >control);
-
-   return 0;
-}
diff --git a/common/board_f.c b/common/board_f.c
index d0a9ff7..613332e 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -795,8 +795,7 @@ static init_fnc_t init_sequence_f[] = {
init_timebase,
 #endif
 #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || \
-defined(CONFIG_BLACKFIN) || defined(CONFIG_NDS32) || \
-defined(CONFIG_NIOS2)
+   defined(CONFIG_BLACKFIN) || defined(CONFIG_NDS32)
timer_init, /* initialize timer */
 #endif
 #ifdef CONFIG_SYS_ALLOC_DPRAM
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index 707ee33..dac0b62 100644
--- a/configs/nios2-generic_defconfig
+++ b/configs/nios2-generic_defconfig
@@ -18,3 +18,5 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_ALTERA_PIO=y
 CONFIG_ALTERA_JTAG_UART=y
 CONFIG_ALTERA_JTAG_UART_BYPASS=y
+CONFIG_DM_TIMER=y
+CONFIG_ALTERA_TIMER=y
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index 97014f3..70fbcda 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -6,4 +6,11 @@ config DM_TIMER
help
  Enable driver model for Timer access.
 
+config ALTERA_TIMER
+   bool "Altera Timer support"
+   depends on DM_TIMER
+   help
+ Select this to enable an timer for Altera devices. Please find
+ details on the "Embedded Peripherals IP User Guide" of Altera.
+
 endmenu
diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
index 58acd7c..db8fa2b 100644
--- a/drivers/timer/Makefile
+++ b/drivers/timer/Makefile
@@ -5,3 +5,4 @@
 #
 
 obj-$(CONFIG_DM_TIMER) += timer-uclass.o timer.o
+obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
diff --git a/drivers/timer/altera_timer.c b/drivers/timer/altera_timer.c
new file mode 100644
index 000..8128eb6
--- /dev/null
+++ b/drivers/timer/altera_timer.c
@@ -0,0 +1,110 @@
+/*
+ * (C) Copyright 2000-2002
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * (C) 

[U-Boot] [PATCH v2 1/2] dm: implement a Timer uclass

2015-09-29 Thread Thomas Chou
Implement a Timer uclass to work with lib/time.c.

Signed-off-by: Thomas Chou 
---
v2
  fix coding style.

 common/board_r.c |  5 +++--
 drivers/Kconfig  |  2 ++
 drivers/Makefile |  1 +
 drivers/timer/Kconfig|  9 
 drivers/timer/Makefile   |  7 ++
 drivers/timer/timer-uclass.c | 35 ++
 drivers/timer/timer.c| 51 
 include/dm/uclass-id.h   |  1 +
 include/timer.h  | 36 +++
 9 files changed, 145 insertions(+), 2 deletions(-)
 create mode 100644 drivers/timer/Kconfig
 create mode 100644 drivers/timer/Makefile
 create mode 100644 drivers/timer/timer-uclass.c
 create mode 100644 drivers/timer/timer.c
 create mode 100644 include/timer.h

diff --git a/common/board_r.c b/common/board_r.c
index f8c1baa..64b0577 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -828,8 +828,9 @@ init_fnc_t init_sequence_r[] = {
 #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
initr_enable_interrupts,
 #endif
-#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) 
\
-   || defined(CONFIG_M68K)
+#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || \
+   defined(CONFIG_AVR32) || defined(CONFIG_M68K) || \
+   defined(CONFIG_DM_TIMER)
timer_init, /* initialize timer */
 #endif
 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 63c92c5..f9496f7 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -56,6 +56,8 @@ source "drivers/spi/Kconfig"
 
 source "drivers/thermal/Kconfig"
 
+source "drivers/timer/Kconfig"
+
 source "drivers/tpm/Kconfig"
 
 source "drivers/usb/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 9d0a595..692da78 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -48,6 +48,7 @@ obj-y += pcmcia/
 obj-y += dfu/
 obj-y += rtc/
 obj-y += sound/
+obj-y += timer/
 obj-y += tpm/
 obj-y += twserial/
 obj-y += video/
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
new file mode 100644
index 000..97014f3
--- /dev/null
+++ b/drivers/timer/Kconfig
@@ -0,0 +1,9 @@
+menu "Timer Support"
+
+config DM_TIMER
+   bool "Enable Driver Model for Timer drivers"
+   depends on DM
+   help
+ Enable driver model for Timer access.
+
+endmenu
diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
new file mode 100644
index 000..58acd7c
--- /dev/null
+++ b/drivers/timer/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2015 Thomas Chou 
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_DM_TIMER) += timer-uclass.o timer.o
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
new file mode 100644
index 000..1f088bf
--- /dev/null
+++ b/drivers/timer/timer-uclass.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2015 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+int timer_get_count(struct udevice *dev, unsigned long *count)
+{
+   const struct dm_timer_ops *ops = device_get_ops(dev);
+
+   if (!ops->get_count)
+   return -ENOSYS;
+
+   return ops->get_count(dev, count);
+}
+
+int timer_get_rate(struct udevice *dev, unsigned long *rate)
+{
+   const struct dm_timer_ops *ops = device_get_ops(dev);
+
+   if (!ops->get_rate)
+   return -ENOSYS;
+
+   return ops->get_rate(dev, rate);
+}
+
+UCLASS_DRIVER(timer) = {
+   .id = UCLASS_TIMER,
+   .name   = "timer",
+};
diff --git a/drivers/timer/timer.c b/drivers/timer/timer.c
new file mode 100644
index 000..766eabf
--- /dev/null
+++ b/drivers/timer/timer.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+unsigned long notrace get_tbclk(void)
+{
+   struct udevice *dev;
+   unsigned long rate;
+
+   uclass_first_device(UCLASS_TIMER, );
+   if (!dev)
+   return -ENODEV;
+
+   timer_get_rate(dev, );
+
+   return rate;
+}
+
+unsigned long notrace timer_read_counter(void)
+{
+   struct udevice *dev;
+   unsigned long count;
+
+   uclass_first_device(UCLASS_TIMER, );
+   if (!dev)
+   return -ENODEV;
+
+   timer_get_count(dev, );
+
+   return count;
+}
+
+int timer_init(void)
+{
+   struct udevice *dev;
+
+   uclass_first_device(UCLASS_TIMER, );
+   if (!dev)
+   return -ENODEV;
+
+   return 0;
+}
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 1eeec74..aff34a4 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -56,6 +56,7 @@ enum uclass_id {
UCLASS_SPI_GENERIC, /* Generic SPI flash 

Re: [U-Boot] [PATCH v2 2/2] spi: Add SPI NOR protection mechanism

2015-09-29 Thread Fabio Estevam
On Tue, Sep 29, 2015 at 10:54 AM, Jagan Teki  wrote:

> What if sf erase 0x3f 0x2 - it should skip first 0x1 from
> 0x3f and then erase next 0x1 from (0x3f+0x1) did you
> verify this?

On my case (M25P32) the 0x3f is the last sector (sector size is
0x1), so we cannot pass 0x2.

Doing so we correctly get the error below:

=> sf erase 0x3f 0x2
ERROR: attempting erase past flash size (0x40)

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 1/2] dm: implement a Timer uclass

2015-09-29 Thread Simon Glass
Hi Thomas,

On 29 September 2015 at 06:39, Thomas Chou  wrote:
> Implement a Timer uclass to work with lib/time.c.
>
> Signed-off-by: Thomas Chou 

Thanks for doing this work! I have some comments below.

> ---
> v2
>   fix coding style.
>
>  common/board_r.c |  5 +++--
>  drivers/Kconfig  |  2 ++
>  drivers/Makefile |  1 +
>  drivers/timer/Kconfig|  9 
>  drivers/timer/Makefile   |  7 ++
>  drivers/timer/timer-uclass.c | 35 ++
>  drivers/timer/timer.c| 51 
> 
>  include/dm/uclass-id.h   |  1 +
>  include/timer.h  | 36 +++
>  9 files changed, 145 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/timer/Kconfig
>  create mode 100644 drivers/timer/Makefile
>  create mode 100644 drivers/timer/timer-uclass.c
>  create mode 100644 drivers/timer/timer.c
>  create mode 100644 include/timer.h
>
> diff --git a/common/board_r.c b/common/board_r.c
> index f8c1baa..64b0577 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -828,8 +828,9 @@ init_fnc_t init_sequence_r[] = {
>  #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
> initr_enable_interrupts,
>  #endif
> -#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || 
> defined(CONFIG_AVR32) \
> -   || defined(CONFIG_M68K)
> +#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || \
> +   defined(CONFIG_AVR32) || defined(CONFIG_M68K) || \
> +   defined(CONFIG_DM_TIMER)
> timer_init, /* initialize timer */
>  #endif
>  #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 63c92c5..f9496f7 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -56,6 +56,8 @@ source "drivers/spi/Kconfig"
>
>  source "drivers/thermal/Kconfig"
>
> +source "drivers/timer/Kconfig"
> +
>  source "drivers/tpm/Kconfig"
>
>  source "drivers/usb/Kconfig"
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 9d0a595..692da78 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -48,6 +48,7 @@ obj-y += pcmcia/
>  obj-y += dfu/
>  obj-y += rtc/
>  obj-y += sound/
> +obj-y += timer/
>  obj-y += tpm/
>  obj-y += twserial/
>  obj-y += video/
> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
> new file mode 100644
> index 000..97014f3
> --- /dev/null
> +++ b/drivers/timer/Kconfig
> @@ -0,0 +1,9 @@
> +menu "Timer Support"
> +
> +config DM_TIMER
> +   bool "Enable Driver Model for Timer drivers"
> +   depends on DM
> +   help
> + Enable driver model for Timer access.

Can you expand this a little bit?

- Uses the same API
- But now implemented by the uclass
- The first timer is used

> +
> +endmenu
> diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
> new file mode 100644
> index 000..58acd7c
> --- /dev/null
> +++ b/drivers/timer/Makefile
> @@ -0,0 +1,7 @@
> +#
> +# Copyright (C) 2015 Thomas Chou 
> +#
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +
> +obj-$(CONFIG_DM_TIMER) += timer-uclass.o timer.o
> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
> new file mode 100644
> index 000..1f088bf
> --- /dev/null
> +++ b/drivers/timer/timer-uclass.c
> @@ -0,0 +1,35 @@
> +/*
> + * Copyright (C) 2015 Thomas Chou 
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +int timer_get_count(struct udevice *dev, unsigned long *count)
> +{
> +   const struct dm_timer_ops *ops = device_get_ops(dev);
> +
> +   if (!ops->get_count)
> +   return -ENOSYS;
> +
> +   return ops->get_count(dev, count);
> +}
> +
> +int timer_get_rate(struct udevice *dev, unsigned long *rate)
> +{
> +   const struct dm_timer_ops *ops = device_get_ops(dev);
> +
> +   if (!ops->get_rate)
> +   return -ENOSYS;
> +
> +   return ops->get_rate(dev, rate);
> +}
> +
> +UCLASS_DRIVER(timer) = {
> +   .id = UCLASS_TIMER,
> +   .name   = "timer",
> +};
> diff --git a/drivers/timer/timer.c b/drivers/timer/timer.c
> new file mode 100644
> index 000..766eabf
> --- /dev/null
> +++ b/drivers/timer/timer.c

I think these functions should go in lib/time.c.

At some point we should look at implementing udelay() also.

> @@ -0,0 +1,51 @@
> +/*
> + * Copyright (C) 2015 Thomas Chou 
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +unsigned long notrace get_tbclk(void)
> +{
> +   struct udevice *dev;
> +   unsigned long rate;
> +
> +   uclass_first_device(UCLASS_TIMER, );
> +   if (!dev)
> +   return -ENODEV;
> +
> +   timer_get_rate(dev, );
> +
> +   

Re: [U-Boot] [PATCH v3] nios2: convert nios2 cpu to driver model

2015-09-29 Thread Simon Glass
Hi Thomas,

On 29 September 2015 at 06:15, Thomas Chou  wrote:
> Convert nios2 cpu to driver model. The cpu parameters are
> extracted from device tree and saved to global data structure.
> We will use them to replace the custom_fpga.h .
>
> Signed-off-by: Thomas Chou 
> ---
> v2
>   move cpu param setup to arch_cpu_init_dm, remove probe.
> v3
>   fix coding style as Marek suggested.
>   select CMD_CPU.
>
>  arch/Kconfig |  3 ++
>  arch/nios2/cpu/cpu.c | 75 
> ++--
>  arch/nios2/dts/3c120_devboard.dts|  1 +
>  arch/nios2/include/asm/global_data.h |  8 
>  configs/nios2-generic_defconfig  |  3 +-
>  5 files changed, 85 insertions(+), 5 deletions(-)

Looks good, a few minor comments below.

>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 207c778..9be1538 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -64,6 +64,9 @@ config NIOS2
> select HAVE_GENERIC_BOARD
> select SYS_GENERIC_BOARD
> select SUPPORT_OF_CONTROL
> +   select OF_CONTROL
> +   select DM
> +   select CPU
>
>  config OPENRISC
> bool "OpenRISC architecture"
> diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
> index 39ae972..9e98742 100644
> --- a/arch/nios2/cpu/cpu.c
> +++ b/arch/nios2/cpu/cpu.c
> @@ -6,7 +6,9 @@
>   */
>
>  #include 
> -#include 
> +#include 
> +#include 
> +#include 
>  #include 
>
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -51,10 +53,77 @@ void dcache_disable(void)
> flush_dcache(CONFIG_SYS_DCACHE_SIZE, CONFIG_SYS_DCACHELINE_SIZE);
>  }
>
> -int arch_cpu_init(void)
> +int arch_cpu_init_dm(void)
>  {
> -   gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
> +   struct udevice *dev;
> +
> +   uclass_first_device(UCLASS_CPU, );

Should check the error return too.

ret = uclass_first_device(...)
if (ret)
   return ret;

> +   if (!dev)
> +   return -ENODEV;
> +
> +   gd->cpu_clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,

This code should go in a probe() method in this driver. Then when the
device is probed (by your arch_cpu_init_dm() function this code will
be executed. The problem here is that you are looking at
dev->of_offset, which is the drivers's responsibility. I know this
code is in the same file, but this is not a driver method function.

You could make this briefer by declaring a few locals:

const void *blob = gd->fdt_blob;
int node = dev->of_offset;

> +   "clock-frequency", 0);
> +   gd->arch.dcache_line_size = fdtdec_get_int(gd->fdt_blob, 
> dev->of_offset,
> +   "dcache-line-size", 0);
> +   gd->arch.icache_line_size = fdtdec_get_int(gd->fdt_blob, 
> dev->of_offset,
> +   "icache-line-size", 0);
> +   gd->arch.dcache_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> +   "dcache-size", 0);
> +   gd->arch.icache_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> +   "icache-size", 0);
> +   gd->arch.reset_addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> +   "altr,reset-addr", 0);
> +   gd->arch.exception_addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> +   "altr,exception-addr", 0);
> +   gd->arch.has_mmu = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> +   "altr,has-mmu", 0);

Should that be fdtdec_get_bool()? Also is there a device tree binding
file for these settings?

> +   gd->arch.io_region_base = gd->arch.has_mmu ? 0xe000 : 0x800;
> gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
>
> return 0;
>  }
> +
> +static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size)
> +{
> +   const char *cpu_name = "Nios-II";
> +
> +   if (size < strlen(cpu_name))
> +   return -ENOSPC;
> +   strcpy(buf, cpu_name);
> +
> +   return 0;
> +}
> +
> +static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info)
> +{
> +   info->cpu_freq = gd->cpu_clk;
> +   info->features = (1 << CPU_FEAT_L1_CACHE) |
> +   (gd->arch.has_mmu ? (1 << CPU_FEAT_MMU) : 0);
> +
> +   return 0;
> +}
> +
> +static int altera_nios2_get_count(struct udevice *dev)
> +{
> +   return 1;
> +}
> +
> +static const struct cpu_ops altera_nios2_ops = {
> +   .get_desc   = altera_nios2_get_desc,
> +   .get_info   = altera_nios2_get_info,
> +   .get_count  = altera_nios2_get_count,
> +};
> +
> +static const struct udevice_id altera_nios2_ids[] = {
> +   { .compatible = "altr,nios2-1.0" },
> +   { .compatible = "altr,nios2-1.1" },
> +   { }
> +};
> +
> +U_BOOT_DRIVER(altera_nios2) = {
> +   .name   = "altera_nios2",
> +   .id = UCLASS_CPU,
> +   .of_match   = altera_nios2_ids,
> +   .ops= _nios2_ops,
> +   .flags  = DM_FLAG_PRE_RELOC,
> +};
> diff --git a/arch/nios2/dts/3c120_devboard.dts 
> b/arch/nios2/dts/3c120_devboard.dts
> 

Re: [U-Boot] [PATCH 2/3] hab: rework support for imx6/imx7

2015-09-29 Thread Stefano Babic
Hi Adrian,

On 21/09/2015 22:44, Adrian Alonso wrote:
> Signed-off-by: Adrian Alonso 
> ---
>  arch/arm/cpu/armv7/mx6/Makefile |   1 -
>  arch/arm/cpu/armv7/mx6/hab.c| 502 ---
>  arch/arm/imx-common/Makefile|   1 +
>  arch/arm/imx-common/hab.c   | 515 
> 
>  include/imx_hab.h   | 140 +++
>  5 files changed, 656 insertions(+), 503 deletions(-)
>  delete mode 100644 arch/arm/cpu/armv7/mx6/hab.c
>  create mode 100644 arch/arm/imx-common/hab.c
>  create mode 100644 include/imx_hab.h
> 

I find nice that cod in hab.c is factorized, but merging this together
with the changes for mx7 makes a review difficult and does not allow a
real diff between version. I will propose you split this patch in two parts:

- first patch simply move hab.c from cpu/armv7 to arm/imx-common/
- second patch add changes for mx7

Then it is also easy in case of git bisect to track what is changed.

Best regards,
Stefano Babic


> diff --git a/arch/arm/cpu/armv7/mx6/Makefile b/arch/arm/cpu/armv7/mx6/Makefile
> index bf6effc..8af191d 100644
> --- a/arch/arm/cpu/armv7/mx6/Makefile
> +++ b/arch/arm/cpu/armv7/mx6/Makefile
> @@ -9,5 +9,4 @@
>  
>  obj-y:= soc.o clock.o
>  obj-$(CONFIG_SPL_BUILD)   += ddr.o
> -obj-$(CONFIG_SECURE_BOOT)+= hab.o
>  obj-$(CONFIG_MP) += mp.o
> diff --git a/arch/arm/cpu/armv7/mx6/hab.c b/arch/arm/cpu/armv7/mx6/hab.c
> deleted file mode 100644
> index 27cabe4..000
> --- a/arch/arm/cpu/armv7/mx6/hab.c
> +++ /dev/null
> @@ -1,502 +0,0 @@
> -/*
> - * Copyright (C) 2010-2015 Freescale Semiconductor, Inc.
> - *
> - * SPDX-License-Identifier:GPL-2.0+
> - */
> -
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -/*  start of HAB API updates */
> -
> -#define hab_rvt_report_event_p   \
> -(\
> - ((is_cpu_type(MXC_CPU_MX6Q) ||  \
> -   is_cpu_type(MXC_CPU_MX6D)) && \
> -   (soc_rev() >= CHIP_REV_1_5)) ?\
> - ((hab_rvt_report_event_t *)HAB_RVT_REPORT_EVENT_NEW) :  \
> - (is_cpu_type(MXC_CPU_MX6DL) &&  \
> -  (soc_rev() >= CHIP_REV_1_2)) ? \
> - ((hab_rvt_report_event_t *)HAB_RVT_REPORT_EVENT_NEW) :  \
> - ((hab_rvt_report_event_t *)HAB_RVT_REPORT_EVENT)\
> -)
> -
> -#define hab_rvt_report_status_p  \
> -(\
> - ((is_cpu_type(MXC_CPU_MX6Q) ||  \
> -   is_cpu_type(MXC_CPU_MX6D)) && \
> -   (soc_rev() >= CHIP_REV_1_5)) ?\
> - ((hab_rvt_report_status_t *)HAB_RVT_REPORT_STATUS_NEW) :\
> - (is_cpu_type(MXC_CPU_MX6DL) &&  \
> -  (soc_rev() >= CHIP_REV_1_2)) ? \
> - ((hab_rvt_report_status_t *)HAB_RVT_REPORT_STATUS_NEW) :\
> - ((hab_rvt_report_status_t *)HAB_RVT_REPORT_STATUS)  \
> -)
> -
> -#define hab_rvt_authenticate_image_p \
> -(\
> - ((is_cpu_type(MXC_CPU_MX6Q) ||  \
> -   is_cpu_type(MXC_CPU_MX6D)) && \
> -   (soc_rev() >= CHIP_REV_1_5)) ?\
> - ((hab_rvt_authenticate_image_t *)HAB_RVT_AUTHENTICATE_IMAGE_NEW) : \
> - (is_cpu_type(MXC_CPU_MX6DL) &&  \
> -  (soc_rev() >= CHIP_REV_1_2)) ? \
> - ((hab_rvt_authenticate_image_t *)HAB_RVT_AUTHENTICATE_IMAGE_NEW) : \
> - ((hab_rvt_authenticate_image_t *)HAB_RVT_AUTHENTICATE_IMAGE)\
> -)
> -
> -#define hab_rvt_entry_p  \
> -(\
> - ((is_cpu_type(MXC_CPU_MX6Q) ||  \
> -   is_cpu_type(MXC_CPU_MX6D)) && \
> -   (soc_rev() >= CHIP_REV_1_5)) ?\
> - ((hab_rvt_entry_t *)HAB_RVT_ENTRY_NEW) :\
> - (is_cpu_type(MXC_CPU_MX6DL) &&  \
> -  (soc_rev() >= CHIP_REV_1_2)) ? \
> - ((hab_rvt_entry_t *)HAB_RVT_ENTRY_NEW) :\
> - ((hab_rvt_entry_t *)HAB_RVT_ENTRY)  \
> -)
> -
> -#define hab_rvt_exit_p   \
> -(\
> - ((is_cpu_type(MXC_CPU_MX6Q) ||  \
> -   is_cpu_type(MXC_CPU_MX6D)) && \
> -   (soc_rev() >= CHIP_REV_1_5)) ?\
> - ((hab_rvt_exit_t *)HAB_RVT_EXIT_NEW) :  

[U-Boot] [PATCH v3 2/2] nios2: convert altera sysid to driver model

2015-09-29 Thread Thomas Chou
Convert altera sysid to driver model with misc uclass.

Signed-off-by: Thomas Chou 
---
v2
  remove trailing whitespace in altera_sysid.c.
v3
  fix coding style as suggested by Stefan.

 arch/nios2/cpu/Makefile|  2 +-
 arch/nios2/cpu/cpu.c   | 13 +---
 arch/nios2/cpu/sysid.c | 46 --
 arch/nios2/dts/3c120_devboard.dts  |  8 +++
 board/altera/nios2-generic/nios2-generic.c |  6 +-
 configs/nios2-generic_defconfig|  2 +
 drivers/misc/Kconfig   |  7 +++
 drivers/misc/Makefile  |  1 +
 drivers/misc/altera_sysid.c| 99 ++
 include/configs/nios2-generic.h|  2 +-
 10 files changed, 126 insertions(+), 60 deletions(-)
 delete mode 100644 arch/nios2/cpu/sysid.c
 create mode 100644 drivers/misc/altera_sysid.c

diff --git a/arch/nios2/cpu/Makefile b/arch/nios2/cpu/Makefile
index 3fe7847..185ca3c 100644
--- a/arch/nios2/cpu/Makefile
+++ b/arch/nios2/cpu/Makefile
@@ -7,5 +7,5 @@
 
 extra-y= start.o
 obj-y  = exceptions.o
-obj-y  += cpu.o interrupts.o sysid.o traps.o
+obj-y  += cpu.o interrupts.o traps.o
 obj-y  += fdt.o
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 88984e2..1d497ab 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -13,20 +13,11 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
-extern void display_sysid (void);
-#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
-
 #ifdef CONFIG_DISPLAY_CPUINFO
 int print_cpuinfo(void)
 {
-   printf ("CPU   : Nios-II\n");
-#if !defined(CONFIG_SYS_NIOS_SYSID_BASE)
-   printf ("SYSID : \n");
-#else
-   display_sysid ();
-#endif
-   return (0);
+   printf("CPU:   Nios-II\n");
+   return 0;
 }
 #endif /* CONFIG_DISPLAY_CPUINFO */
 
diff --git a/arch/nios2/cpu/sysid.c b/arch/nios2/cpu/sysid.c
deleted file mode 100644
index 50819b2..000
--- a/arch/nios2/cpu/sysid.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * (C) Copyright 2004, Psyent Corporation 
- * Scott McNutt 
- *
- * SPDX-License-Identifier:GPL-2.0+
- */
-
-#include 
-
-#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
-
-#include 
-#include 
-#include 
-
-typedef volatile struct {
-   unsignedid; /* The system build id */
-   unsignedtimestamp;  /* Timestamp */
-} nios_sysid_t;
-
-void display_sysid (void)
-{
-   nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
-   struct tm t;
-   char asc[32];
-   time_t stamp;
-
-   stamp = readl (>timestamp);
-   localtime_r (, );
-   asctime_r (, asc);
-   printf ("SYSID : %08lx, %s", readl (>id), asc);
-
-}
-
-int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-   display_sysid ();
-   return (0);
-}
-
-U_BOOT_CMD(
-   sysid,  1,  1,  do_sysid,
-   "display Nios-II system id",
-   ""
-);
-#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
diff --git a/arch/nios2/dts/3c120_devboard.dts 
b/arch/nios2/dts/3c120_devboard.dts
index 2e2956f..2eb339c 100644
--- a/arch/nios2/dts/3c120_devboard.dts
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -72,6 +72,7 @@
<0x4cc0 0x08004cc0 0x0010>,
<0x4ce0 0x08004ce0 0x0010>,
<0x4d00 0x08004d00 0x0010>,
+   <0x4d40 0x08004d40 0x0008>,
<0x4d50 0x08004d50 0x0008>,
<0x8000 0x08008000 0x0020>,
<0x0040 0x0840 0x0020>;
@@ -92,6 +93,13 @@
clock-frequency = < 12500 >;
};
 
+   sysid: sysid@0x4d40 {
+   compatible = "altr,sysid-1.0";
+   reg = <0x4d40 0x0008>;
+   id = <0>;
+   timestamp = <1440939556>;
+   };
+
jtag_uart: serial@0x4d50 {
compatible = "altr,juart-1.0";
reg = <0x4d50 0x0008>;
diff --git a/board/altera/nios2-generic/nios2-generic.c 
b/board/altera/nios2-generic/nios2-generic.c
index 61d32c7..e08b8f7 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -42,7 +42,11 @@ int board_early_init_r(void)
 
 int checkboard(void)
 {
-   printf("BOARD : %s\n", CONFIG_BOARD_NAME);
+#ifdef CONFIG_ALTERA_SYSID
+   extern void display_sysid(void);
+   display_sysid();
+#endif
+   printf("BOARD: %s\n", CONFIG_BOARD_NAME);
return 0;
 }
 
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index 1aa2d9e..d8d26e5 100644
--- 

Re: [U-Boot] [PATCH v2 2/2] nios2: convert altera sysid to driver model

2015-09-29 Thread Thomas Chou

Hi Stefan,

On 09/29/2015 05:30 PM, Stefan Roese wrote:

+void display_sysid (void)
+{


Even though you have copied this code, please fix the coding style
above (space before "("). For all occurrences in this patch, so
that it is checkpatch clean.


Thanks a lot for reminding.

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


[U-Boot] [PATCH v3 1/2] dm: implement a Miscellaneous uclass

2015-09-29 Thread Thomas Chou
Implement a Miscellaneous uclass with generic read or
write operations. This class is used only for those
do not fit other more general classes.

Signed-off-by: Thomas Chou 
---
v2
  add missing misc.h.
v3
  no change.

 drivers/misc/Kconfig   |  6 ++
 drivers/misc/Makefile  |  1 +
 drivers/misc/misc-uclass.c | 14 ++
 include/dm/uclass-id.h |  1 +
 include/misc.h | 22 ++
 5 files changed, 44 insertions(+)
 create mode 100644 drivers/misc/misc-uclass.c
 create mode 100644 include/misc.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8b38a84..51c2a08 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -4,6 +4,12 @@
 
 menu "Multifunction device drivers"
 
+config DM_MISC
+   bool "Enable Driver Model for Misc drivers"
+   depends on DM
+   help
+ Enable driver model for miscellaneous devices.
+
 config CMD_CROS_EC
bool "Enable crosec command"
depends on CROS_EC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 8d0fc3c..b285946 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+obj-$(CONFIG_DM_MISC) += misc-uclass.o
 obj-$(CONFIG_ALI152X) += ali512x.o
 obj-$(CONFIG_DS4510)  += ds4510.o
 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
new file mode 100644
index 000..40fe947
--- /dev/null
+++ b/drivers/misc/misc-uclass.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2010 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+UCLASS_DRIVER(misc) = {
+   .id = UCLASS_MISC,
+   .name   = "misc",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index aff34a4..a6982ab 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -39,6 +39,7 @@ enum uclass_id {
UCLASS_LED, /* Light-emitting diode (LED) */
UCLASS_LPC, /* x86 'low pin count' interface */
UCLASS_MASS_STORAGE,/* Mass storage device */
+   UCLASS_MISC,/* Miscellaneous device */
UCLASS_MMC, /* SD / MMC card or chip */
UCLASS_MOD_EXP, /* RSA Mod Exp device */
UCLASS_PCH, /* x86 platform controller hub */
diff --git a/include/misc.h b/include/misc.h
new file mode 100644
index 000..dfca41f
--- /dev/null
+++ b/include/misc.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _DM_MISC_H_
+#define _DM_MISC_H_
+
+/*
+ * struct dm_misc_ops - Driver model Misc operations
+ *
+ * The uclass interface is implemented by all miscellaneous devices which
+ * use driver model.
+ */
+struct dm_misc_ops {
+   int (*read)(struct udevice *dev, int offset, void *buf, int size);
+   int (*write)(struct udevice *dev, int offset, const void *buf,
+int size);
+};
+
+#endif /* _DM_MISC_H_ */
-- 
2.1.4

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


[U-Boot] [PATCH v2] Revert "env_eeprom: Assign default environment during board_init_f"

2015-09-29 Thread Ludger Dreier
The crc-check and decision on which environment to use is now moved to
env_relocate_spec. This is done for both the "redundant env" and the
"single env" case.
This also solves problems introduced from the commit "env_eeprom: Assign
default environment during board_init_f"
(ed6a5d4f880ac248530dbf64683b2257dbe54b64) due to the use of
ENV_IS_EMBEDDED.

Signed-off-by: Ludger Dreier 
---
Changes for v2:
  -instead of reverting the patch, the disabled, but needed code
   was moved from env_init to env_relocate_spec
---
 common/env_eeprom.c |  166 ---
 1 files changed, 77 insertions(+), 89 deletions(-)

diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 905d39a..eea169d 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -82,75 +82,13 @@ uchar env_get_char_spec(int index)
  void env_relocate_spec(void)
 {
-   char buf[CONFIG_ENV_SIZE];
+   char buf_env[CONFIG_ENV_SIZE];
unsigned int off = CONFIG_ENV_OFFSET;
  #ifdef CONFIG_ENV_OFFSET_REDUND
-   if (gd->env_valid == 2)
-   off = CONFIG_ENV_OFFSET_REDUND;
-#endif
-   eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
-   off, (uchar *)buf, CONFIG_ENV_SIZE);
-
-   env_import(buf, 1);
-}
-
-int saveenv(void)
-{
-   env_t   env_new;
-   int rc;
-   unsigned int off= CONFIG_ENV_OFFSET;
-#ifdef CONFIG_ENV_OFFSET_REDUND
-   unsigned int off_red= CONFIG_ENV_OFFSET_REDUND;
-   char flag_obsolete  = OBSOLETE_FLAG;
-#endif
-
-   BUG_ON(env_ptr != NULL);
-
-   rc = env_export(_new);
-   if (rc)
-   return rc;
-
-#ifdef CONFIG_ENV_OFFSET_REDUND
-   if (gd->env_valid == 1) {
-   off = CONFIG_ENV_OFFSET_REDUND;
-   off_red = CONFIG_ENV_OFFSET;
-   }
-
-   env_new.flags = ACTIVE_FLAG;
-#endif
-
-   rc = eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
- off, (uchar *)_new, CONFIG_ENV_SIZE);
-
-#ifdef CONFIG_ENV_OFFSET_REDUND
-   if (rc == 0) {
-   eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
-off_red + offsetof(env_t, flags),
-(uchar *)_obsolete, 1);
-
-   if (gd->env_valid == 1)
-   gd->env_valid = 2;
-   else
-   gd->env_valid = 1;
-   }
-#endif
-   return rc;
-}
-
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-#ifdef CONFIG_ENV_OFFSET_REDUND
-int env_init(void)
-{
-#ifdef ENV_IS_EMBEDDED
ulong len, crc[2], crc_tmp;
-   unsigned int off, off_env[2];
-   uchar buf[64], flags[2];
+   unsigned int off_env[2];
+   uchar rdbuf[64], flags[2];
int i, crc_ok[2] = {0, 0};
eeprom_init();  /* prepare for EEPROM read/write */
@@ -172,12 +110,12 @@ int env_init(void)
len = ENV_SIZE;
off = off_env[i] + offsetof(env_t, data);
while (len > 0) {
-   int n = (len > sizeof(buf)) ? sizeof(buf) : len;
+   int n = (len > sizeof(rdbuf)) ? sizeof(rdbuf) : len;
eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR, off,
-   buf, n);
+   rdbuf, n);
 -  crc_tmp = crc32(crc_tmp, buf, n);
+   crc_tmp = crc32(crc_tmp, rdbuf, n);
len -= n;
off += n;
}
@@ -189,8 +127,6 @@ int env_init(void)
if (!crc_ok[0] && !crc_ok[1]) {
gd->env_addr= 0;
gd->env_valid   = 0;
-
-   return 0;
} else if (crc_ok[0] && !crc_ok[1]) {
gd->env_valid = 1;
} else if (!crc_ok[0] && crc_ok[1]) {
@@ -213,19 +149,10 @@ int env_init(void)
gd->env_addr = off_env[1] + offsetof(env_t, data);
else if (gd->env_valid == 1)
gd->env_addr = off_env[0] + offsetof(env_t, data);
-#else
-   gd->env_addr = (ulong)_environment[0];
-   gd->env_valid = 1;
-#endif
-   return 0;
-}
-#else
-int env_init(void)
-{
-#ifdef ENV_IS_EMBEDDED
+
+#else /* CONFIG_ENV_OFFSET_REDUND */
ulong crc, len, new;
-   unsigned off;
-   uchar buf[64];
+   uchar rdbuf[64];
eeprom_init();  /* prepare for EEPROM read/write */
 @@ -237,13 +164,12 @@ int env_init(void)
new = 0;
len = ENV_SIZE;
off = offsetof(env_t, data);
-
while (len > 0) {
-   int n = (len > sizeof(buf)) ? sizeof(buf) : len;
+   int n = (len > sizeof(rdbuf)) ? sizeof(rdbuf) : len;
eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
-   CONFIG_ENV_OFFSET + off, buf, n);
-   new = crc32(new, buf, n);
+  

[U-Boot] [PATCH] arndale: Apply Cortex-A15 errata #773022 and #774769

2015-09-29 Thread Ian Campbell
We run 4 Arndale boards in our automated test framework, they have
been running quite happily for quite some time using a Debian Wheezy
userspace.

However when upgrading to a Debian Jessie we started seeing frequent
segmentation faults from gcc when building the kernel, to the extent
that it is unable to successfully build the kernel twice in a row, and
often fails on the first attempt.

Searching around I found https://bugs.launchpad.net/arndale/+bug/1081417
which pointed towards http://www.spinics.net/lists/kvm-arm/msg03723.html
and CPU Errata 773022 and 774769.

This errata needs to be applied to all processors in an SMP system,
meaning that the usual strategy of applying them in
arch/arm/cpu/armv7/start.S is not appropriate (since that applies to
the boot processor only). Instead we apply these errata in the secure
monitor which is code that is traversed by all processors as they are
brought up.

The net affect on Arndale is that ACTLR changes from 0x40 to
0x242. I ran 17 kernel compile iterations overnight with no
segfaults.

Runtime testing was done on our v2014.10 based branch and forward
ported (with only minimal and trivial contextual conflicts) to current
master, where it has been build tested only.

I suppose in theory these errata apply to any Exynos5250 based boards,
but Arndale is the only one I have access to and I have therefore
chosen to be conservative and only apply it there.

Also, reorder CONFIG_ARM_ERRATA_794072 in README to make the list
numerically sorted.

Signed-off-by: Ian Campbell 
---
Our v2014.10 based branch:
http://xenbits.xen.org/gitweb/?p=people/ianc/osstest/u-boot.git;a=shortlog;h=refs/heads/arndale
---
 README   |  4 +++-
 arch/arm/cpu/armv7/nonsec_virt.S | 14 ++
 include/configs/arndale.h|  4 
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/README b/README
index a13705a..f8546cf 100644
--- a/README
+++ b/README
@@ -681,8 +681,10 @@ The following options need to be configured:
CONFIG_ARM_ERRATA_742230
CONFIG_ARM_ERRATA_743622
CONFIG_ARM_ERRATA_751472
-   CONFIG_ARM_ERRATA_794072
CONFIG_ARM_ERRATA_761320
+   CONFIG_ARM_ERRATA_773022
+   CONFIG_ARM_ERRATA_774769
+   CONFIG_ARM_ERRATA_794072
 
If set, the workarounds for these ARM errata are applied early
during U-Boot startup. Note that these options force the
diff --git a/arch/arm/cpu/armv7/nonsec_virt.S b/arch/arm/cpu/armv7/nonsec_virt.S
index 30d81db..31d1c9e 100644
--- a/arch/arm/cpu/armv7/nonsec_virt.S
+++ b/arch/arm/cpu/armv7/nonsec_virt.S
@@ -53,6 +53,20 @@ _secure_monitor:
bl  psci_arch_init
 #endif
 
+#ifdef CONFIG_ARM_ERRATA_773022
+   mrc p15, 0, r5, c1, c0, 1
+   orr r5, r5, #(1 << 1)
+   mcr p15, 0, r5, c1, c0, 1
+   isb
+#endif
+
+#ifdef CONFIG_ARM_ERRATA_774769
+   mrc p15, 0, r5, c1, c0, 1
+   orr r5, r5, #(1 << 25)
+   mcr p15, 0, r5, c1, c0, 1
+   isb
+#endif
+
mrc p15, 0, r5, c1, c1, 0   @ read SCR
bic r5, r5, #0x4a   @ clear IRQ, EA, nET bits
orr r5, r5, #0x31   @ enable NS, AW, FW bits
diff --git a/include/configs/arndale.h b/include/configs/arndale.h
index 437a745..b08f341 100644
--- a/include/configs/arndale.h
+++ b/include/configs/arndale.h
@@ -49,6 +49,10 @@
 /* The PERIPHBASE in the CBAR register is wrong on the Arndale, so override it 
*/
 #define CONFIG_ARM_GIC_BASE_ADDRESS0x1048
 
+/* CPU Errata */
+#define CONFIG_ARM_ERRATA_773022
+#define CONFIG_ARM_ERRATA_774769
+
 /* Power */
 #define CONFIG_POWER
 #define CONFIG_POWER_I2C
-- 
2.5.3

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


[U-Boot] [PATCH 2/2] am437x: Add am57xx_evm_defconfig using CONFIG_DM

2015-09-29 Thread Mugunthan V N
Import various DT files for am57xx-beagle-x15 from
Linux Kernel v4.2
Add config file for this board, enable DM, DM_GPIO,
DM_SERIAL and DM_MMC.

Signed-off-by: Mugunthan V N 
---
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/am57xx-beagle-x15.dts | 699 +
 configs/am57xx_evm_defconfig   |  19 +
 3 files changed, 719 insertions(+)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15.dts
 create mode 100644 configs/am57xx_evm_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c391f3b..55d5150 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -70,6 +70,7 @@ dtb-$(CONFIG_ARCH_SOCFPGA) += \
socfpga_cyclone5_sockit.dtb \
socfpga_cyclone5_socrates.dtb
 dtb-$(CONFIG_TARGET_DRA7XX_EVM) += dra72-evm.dtb dra7-evm.dtb
+dtb-$(CONFIG_TARGET_BEAGLE_X15) += am57xx-beagle-x15.dtb
 dtb-$(CONFIG_TARGET_STV0991) += stv0991.dtb
 
 dtb-$(CONFIG_LS102XA) += ls1021a-qds.dtb \
diff --git a/arch/arm/dts/am57xx-beagle-x15.dts 
b/arch/arm/dts/am57xx-beagle-x15.dts
new file mode 100644
index 000..e424562
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15.dts
@@ -0,0 +1,699 @@
+/*
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+#include "dra74x.dtsi"
+#include 
+#include 
+
+/ {
+   model = "TI AM5728 BeagleBoard-X15";
+   compatible = "ti,am572x-beagle-x15", "ti,am5728", "ti,dra742", 
"ti,dra74", "ti,dra7";
+
+   chosen {
+   stdout-path = 
+   };
+
+   aliases {
+   rtc0 = _rtc;
+   rtc1 = _rtc;
+   rtc2 = 
+   display0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x8000>;
+   };
+
+   vdd_3v3: fixedregulator-vdd_3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_3v3";
+   vin-supply = <>;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
+   vtt_fixed: fixedregulator-vtt {
+   /* TPS51200 */
+   compatible = "regulator-fixed";
+   regulator-name = "vtt_fixed";
+   vin-supply = <_reg>;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   regulator-boot-on;
+   enable-active-high;
+   gpio = < 11 GPIO_ACTIVE_HIGH>;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins_default>;
+
+   led@0 {
+   label = "beagle-x15:usr0";
+   gpios = < 9 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   default-state = "off";
+   };
+
+   led@1 {
+   label = "beagle-x15:usr1";
+   gpios = < 8 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "cpu0";
+   default-state = "off";
+   };
+
+   led@2 {
+   label = "beagle-x15:usr2";
+   gpios = < 14 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "mmc0";
+   default-state = "off";
+   };
+
+   led@3 {
+   label = "beagle-x15:usr3";
+   gpios = < 15 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "ide-disk";
+   default-state = "off";
+   };
+   };
+
+   gpio_fan: gpio_fan {
+   /* Based on 5v 500mA AFB02505HHB */
+   compatible = "gpio-fan";
+   gpios =  <_gpio 2 GPIO_ACTIVE_HIGH>;
+   gpio-fan,speed-map = <0 0>,
+<13000 1>;
+   #cooling-cells = <2>;
+   };
+
+   extcon_usb1: extcon_usb1 {
+   compatible = "linux,extcon-usb-gpio";
+   id-gpio = < 25 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb1_pins>;
+   };
+
+   extcon_usb2: extcon_usb2 {
+   compatible = "linux,extcon-usb-gpio";
+   id-gpio = < 24 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb2_pins>;
+   };
+
+   hdmi0: connector {
+   compatible = "hdmi-connector";
+   label = "hdmi";
+
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint 

[U-Boot] [PATCH 0/2] device model bringup of am57xx platform on am57xx-evm

2015-09-29 Thread Mugunthan V N
This patch series enables Driver Model and Devitree usage for
am57xx platform and tested it on am57xx-evm (Loga [1]). Also
pushed a branch [2] for referrence.

This patch series depends on [3] (MMC DM patch series),
[4] OMAP5 SERIAL DM fix nad [5] DRA74x bringup patch for
dra74x dtsi files.

[1]: http://pastebin.ubuntu.com/12610054/
[2]: git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git am57xx-dm
[3]: https://www.mail-archive.com/u-boot@lists.denx.de/msg186964.html
[4]: http://patchwork.ozlabs.org/patch/519024/
[5]: http://patchwork.ozlabs.org/patch/521035/

Mugunthan V N (2):
  ti_omap5_common: mmc: do not define DM_MMC for spl
  am437x: Add am57xx_evm_defconfig using CONFIG_DM

 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/am57xx-beagle-x15.dts | 699 +
 configs/am57xx_evm_defconfig   |  19 +
 include/configs/ti_omap5_common.h  |   8 +
 4 files changed, 727 insertions(+)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15.dts
 create mode 100644 configs/am57xx_evm_defconfig

-- 
2.6.0.rc2.10.gf4d9753

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


[U-Boot] [PATCH 1/2] ti_omap5_common: mmc: do not define DM_MMC for spl

2015-09-29 Thread Mugunthan V N
Since spl doesn't support DM currently, do not define DM_MMC
for spl build.

Signed-off-by: Mugunthan V N 

asdfsadf
---
 include/configs/ti_omap5_common.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index 9fc33aa..5acbc92 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -161,4 +161,12 @@
 #define CONFIG_SPL_NAND_AM33XX_BCH /* ELM support */
 #endif
 
+/*
+ * Disable MMC DM for SPL build and can be re-enabled after adding
+ * DM support in SPL
+ */
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_DM_MMC
+#endif
+
 #endif /* __CONFIG_TI_OMAP5_COMMON_H */
-- 
2.6.0.rc2.10.gf4d9753

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


[U-Boot] Please pull u-boot-sunxi master

2015-09-29 Thread Hans de Goede

Hi Tom,

Here is a (the final?) sunxi pull-req for v2015.10, highlights:

-Misc fixes / tweaks
-Add support for 2 new boards

The following changes since commit 1f8836396de8215b7f460616926052b32597bb29:

  Prepare v2015.10-rc4 (2015-09-28 16:57:42 -0400)

are available in the git repository at:

  http://git.denx.de/u-boot-sunxi.git master

for you to fetch changes up to 46f166caad48ed38f6ccc0c2fc6d1828d15dacb2:

  sunxi: Add generic defconfigs for A33 Q8 tablets with 1024x600 / 800x480 LCD 
(2015-09-29 11:50:44 +0200)


Bernhard Nortmann (4):
  sunxi: move SPL-related definitions to platform-specific include
  sunxi: (mksunxiboot) signature to indicate "sunxi" SPL variant
  sunxi: retrieve FEL-provided values to environment variables
  sunxi: add "fel" boot target

Hans de Goede (7):
  sunxi: Rename A10s-Wobo-i5_defconfig to Wobo_i5_defconfig
  sunxi: sunxi-common.h cleanup
  sunxi: Tweak various memory addresses
  sunxi: Simplify spl board_init_f function
  sunxi_nand_spl: Be smarter about where to look for backup u-boot.bin
  sunxi: mmc: Fix clk-delay settings
  sunxi: Add generic defconfigs for A33 Q8 tablets with 1024x600 / 800x480 
LCD

 arch/arm/cpu/armv7/sunxi/board.c   |  8 +--
 arch/arm/dts/Makefile  |  1 +
 arch/arm/dts/sun8i-a33-q8-tablet.dts   | 65 +
 arch/arm/dts/sun8i-q8-common.dtsi  | 84 ++
 arch/arm/include/asm/arch-sunxi/spl.h  | 54 ++
 board/sunxi/MAINTAINERS|  5 +-
 board/sunxi/board.c| 35 +
 .../{A10s-Wobo-i5_defconfig => Wobo_i5_defconfig}  |  0
 configs/q8_a33_tablet_1024x600_defconfig   | 25 +++
 configs/q8_a33_tablet_800x480_defconfig| 25 +++
 drivers/mmc/sunxi_mmc.c| 16 -
 drivers/mtd/nand/sunxi_nand_spl.c  | 26 +--
 include/configs/sunxi-common.h | 42 +--
 tools/mksunxiboot.c| 21 ++
 14 files changed, 341 insertions(+), 66 deletions(-)
 create mode 100644 arch/arm/dts/sun8i-a33-q8-tablet.dts
 create mode 100644 arch/arm/dts/sun8i-q8-common.dtsi
 rename configs/{A10s-Wobo-i5_defconfig => Wobo_i5_defconfig} (100%)
 create mode 100644 configs/q8_a33_tablet_1024x600_defconfig
 create mode 100644 configs/q8_a33_tablet_800x480_defconfig

Regards,

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


Re: [U-Boot] [PATCH v3 07/13] sf: Add FSR support to spi_flash_cmd_wait_ready

2015-09-29 Thread Jagan Teki
On 2 September 2015 at 13:30, Marek Vasut  wrote:
> On Wednesday, September 02, 2015 at 08:09:51 AM, Jagan Teki wrote:
>> This patch adds flag status register reading support to
>> spi_flash_cmd_wait_ready.
>>
>> Signed-off-by: Jagan Teki 
>> Cc: Simon Glass 
>> Cc: Marek Vasut 
>> Cc: Michal Simek 
>> Cc: Siva Durga Prasad Paladugu 
>> Cc: Stefan Roese 
>> Cc: Tom Warren 
>> Cc: Bin Meng 
>> Cc: Tom Rini 
>> Cc: Hou Zhiqiang 
>> Tested-by: Jagan Teki 
>> ---
>> Changes for v3:
>>   - none
>> Changes for v2:
>>   - Optime code for fsr
>>
>>  drivers/mtd/spi/sf_internal.h |  1 +
>>  drivers/mtd/spi/sf_ops.c  | 60
>> ++- drivers/mtd/spi/sf_probe.c
>> |  4 +--
>>  include/spi_flash.h   |  2 --
>>  4 files changed, 56 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
>> index 53998fc..8a3e5ec 100644
>> --- a/drivers/mtd/spi/sf_internal.h
>> +++ b/drivers/mtd/spi/sf_internal.h
>> @@ -53,6 +53,7 @@ enum {
>>
>>  enum spi_nor_option_flags {
>>   SNOR_F_SST_WR   = (1 << 0),
>> + SNOR_F_USE_FSR  = (1 << 1),
>>  };
>>
>>  #define SPI_FLASH_3B_ADDR_LEN3
>> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
>> index c1cdde7..85e15b9 100644
>> --- a/drivers/mtd/spi/sf_ops.c
>> +++ b/drivers/mtd/spi/sf_ops.c
>> @@ -41,6 +41,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash,
>> u8 *rs) return 0;
>>  }
>>
>> +static int read_fsr(struct spi_flash *flash, u8 *fsr)
>> +{
>> + int ret;
>> + u8 cmd;
>> +
>> + cmd = CMD_FLAG_STATUS;
>
> You can use const u8 cmd = CMD_...
>
>> + ret = spi_flash_read_common(flash, , 1, fsr, 1);
>> + if (ret < 0) {
>> + debug("SF: fail to read flag status register\n");
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>> +
>>  int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws)
>>  {
>>   u8 cmd;
>> @@ -139,20 +154,53 @@ static void spi_flash_dual_flash(struct spi_flash
>> *flash, u32 *addr) }
>>  #endif
>>
>> +static inline int spi_flash_sr_ready(struct spi_flash *flash)
>
> Drop the bogus inline keyword, compiler will handle this better.

Does this means it requires -finline-small-functions optimization flag?

Based on the function-definition-size it will optimize using this flag
w/o need of 'inline' keyword, is this the case here?

>
>> +{
>> + u8 sr;
>> + int ret;
>> +
>> + ret = spi_flash_cmd_read_status(flash, );
>> + if (ret < 0)
>> + return ret;
>> +
>> + return !(sr & STATUS_WIP);
>> +}
>> +
>> +static inline int spi_flash_fsr_ready(struct spi_flash *flash)
>> +{
>> + u8 fsr;
>> + int ret;
>> +
>> + ret = read_fsr(flash, );
>> + if (ret < 0)
>> + return ret;
>> +
>> + return fsr & STATUS_PEC;
>> +}
>> +
>> +static int spi_flash_ready(struct spi_flash *flash)
>> +{
>> + int sr, fsr;
>> + sr = spi_flash_sr_ready(flash);
>> + if (sr < 0)
>> + return sr;
>> + fsr = flash->flags & SNOR_F_USE_FSR ? spi_flash_fsr_ready(flash) : 1;
>
> The ternary operator is just making the code more confusing, don't use it.
>
>> + if (fsr < 0)
>> + return fsr;
>> + return sr && fsr;
>> +}
>> +
>>  int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long
>> timeout) {
>> - int timebase, ret, sr;
>> + int timebase, ret;
>>
>>   timebase = get_timer(0);
>>
>>   while (get_timer(timebase) < timeout) {
>> - ret = spi_flash_cmd_read_status(flash, );
>> + ret = spi_flash_ready(flash);
>>   if (ret < 0)
>>   return ret;
>> -
>> - if (sr < 0)
>> - break;
>> - else if (!(sr & STATUS_WIP))
>> + if (ret)
>>   return 0;
>>   }
>>
>> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
>> index 85390d4..758347b 100644
>> --- a/drivers/mtd/spi/sf_probe.c
>> +++ b/drivers/mtd/spi/sf_probe.c
>> @@ -255,11 +255,9 @@ static int spi_flash_validate_params(struct spi_slave
>> *spi, u8 *idcode, flash->dummy_byte = 1;
>>   }
>>
>> - /* Poll cmd selection */
>> - flash->poll_cmd = CMD_READ_STATUS;
>>  #ifdef CONFIG_SPI_FLASH_STMICRO
>>   if (params->flags & E_FSR)
>> - flash->poll_cmd = CMD_FLAG_STATUS;
>> + flash->flags |= SNOR_F_USE_FSR;
>>  #endif
>>
>>   /* Configure the BAR - discover bank cmds and read current bank */
>> diff --git a/include/spi_flash.h b/include/spi_flash.h
>> index 8d85468..4312d3d 100644
>> --- a/include/spi_flash.h
>> +++ b/include/spi_flash.h
>> @@ -49,7 +49,6 @@ struct spi_slave;
>>   * @bank_read_cmd:   

Re: [U-Boot] [PATCH v2 2/2] nios2: convert altera sysid to driver model

2015-09-29 Thread Stefan Roese
Hi Thomas,

On 29.09.2015 11:04, Thomas Chou wrote:
> Convert altera sysid to driver model with misc uclass.
> 
> Signed-off-by: Thomas Chou 
> ---
> v2
>remove trailing whitespace in altera_sysid.c.
> 
>   arch/nios2/cpu/Makefile|  2 +-
>   arch/nios2/cpu/cpu.c   | 15 +
>   arch/nios2/cpu/sysid.c | 46 --
>   arch/nios2/dts/3c120_devboard.dts  |  8 +++
>   board/altera/nios2-generic/nios2-generic.c |  6 +-
>   configs/nios2-generic_defconfig|  2 +
>   drivers/misc/Kconfig   |  7 +++
>   drivers/misc/Makefile  |  1 +
>   drivers/misc/altera_sysid.c| 99 
> ++
>   include/configs/nios2-generic.h|  3 +-
>   10 files changed, 126 insertions(+), 63 deletions(-)
>   delete mode 100644 arch/nios2/cpu/sysid.c
>   create mode 100644 drivers/misc/altera_sysid.c
> 
> diff --git a/arch/nios2/cpu/Makefile b/arch/nios2/cpu/Makefile
> index 3fe7847..185ca3c 100644
> --- a/arch/nios2/cpu/Makefile
> +++ b/arch/nios2/cpu/Makefile
> @@ -7,5 +7,5 @@
>   
>   extra-y = start.o
>   obj-y   = exceptions.o
> -obj-y+= cpu.o interrupts.o sysid.o traps.o
> +obj-y+= cpu.o interrupts.o traps.o
>   obj-y   += fdt.o
> diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
> index 88984e2..7b1717c 100644
> --- a/arch/nios2/cpu/cpu.c
> +++ b/arch/nios2/cpu/cpu.c
> @@ -13,22 +13,11 @@
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> -#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
> -extern void display_sysid (void);
> -#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
> -
> -#ifdef CONFIG_DISPLAY_CPUINFO
>   int print_cpuinfo(void)
>   {
> - printf ("CPU   : Nios-II\n");
> -#if !defined(CONFIG_SYS_NIOS_SYSID_BASE)
> - printf ("SYSID : \n");
> -#else
> - display_sysid ();
> -#endif
> - return (0);
> + printf("CPU:   Nios-II\n");
> + return 0;
>   }
> -#endif /* CONFIG_DISPLAY_CPUINFO */
>   
>   int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   {
> diff --git a/arch/nios2/cpu/sysid.c b/arch/nios2/cpu/sysid.c
> deleted file mode 100644
> index 50819b2..000
> --- a/arch/nios2/cpu/sysid.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/*
> - * (C) Copyright 2004, Psyent Corporation 
> - * Scott McNutt 
> - *
> - * SPDX-License-Identifier:  GPL-2.0+
> - */
> -
> -#include 
> -
> -#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
> -
> -#include 
> -#include 
> -#include 
> -
> -typedef volatile struct {
> - unsignedid; /* The system build id */
> - unsignedtimestamp;  /* Timestamp */
> -} nios_sysid_t;
> -
> -void display_sysid (void)
> -{
> - nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
> - struct tm t;
> - char asc[32];
> - time_t stamp;
> -
> - stamp = readl (>timestamp);
> - localtime_r (, );
> - asctime_r (, asc);
> - printf ("SYSID : %08lx, %s", readl (>id), asc);
> -
> -}
> -
> -int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> -{
> - display_sysid ();
> - return (0);
> -}
> -
> -U_BOOT_CMD(
> - sysid,  1,  1,  do_sysid,
> - "display Nios-II system id",
> - ""
> -);
> -#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
> diff --git a/arch/nios2/dts/3c120_devboard.dts 
> b/arch/nios2/dts/3c120_devboard.dts
> index 2e2956f..2eb339c 100644
> --- a/arch/nios2/dts/3c120_devboard.dts
> +++ b/arch/nios2/dts/3c120_devboard.dts
> @@ -72,6 +72,7 @@
>   <0x4cc0 0x08004cc0 0x0010>,
>   <0x4ce0 0x08004ce0 0x0010>,
>   <0x4d00 0x08004d00 0x0010>,
> + <0x4d40 0x08004d40 0x0008>,
>   <0x4d50 0x08004d50 0x0008>,
>   <0x8000 0x08008000 0x0020>,
>   <0x0040 0x0840 0x0020>;
> @@ -92,6 +93,13 @@
>   clock-frequency = < 12500 >;
>   };
>   
> + sysid: sysid@0x4d40 {
> + compatible = "altr,sysid-1.0";
> + reg = <0x4d40 0x0008>;
> + id = <0>;
> + timestamp = <1440939556>;
> + };
> +
>   jtag_uart: serial@0x4d50 {
>   compatible = "altr,juart-1.0";
>   reg = <0x4d50 0x0008>;
> diff --git a/board/altera/nios2-generic/nios2-generic.c 
> b/board/altera/nios2-generic/nios2-generic.c
> index 61d32c7..e08b8f7 100644
> --- a/board/altera/nios2-generic/nios2-generic.c
> +++ b/board/altera/nios2-generic/nios2-generic.c
> @@ -42,7 +42,11 @@ int board_early_init_r(void)
>   
>   int checkboard(void)
>   {
> - 

[U-Boot] [PATCH v2 1/2] dm: implement a Miscellaneous uclass

2015-09-29 Thread Thomas Chou
Implement a Miscellaneous uclass with generic read or
write operations. This class is used only for those
do not fit other more general classes.

Signed-off-by: Thomas Chou 
---
v2
  add missing misc.h.

 drivers/misc/Kconfig   |  6 ++
 drivers/misc/Makefile  |  1 +
 drivers/misc/misc-uclass.c | 14 ++
 include/dm/uclass-id.h |  1 +
 include/misc.h | 22 ++
 5 files changed, 44 insertions(+)
 create mode 100644 drivers/misc/misc-uclass.c
 create mode 100644 include/misc.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8b38a84..51c2a08 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -4,6 +4,12 @@
 
 menu "Multifunction device drivers"
 
+config DM_MISC
+   bool "Enable Driver Model for Misc drivers"
+   depends on DM
+   help
+ Enable driver model for miscellaneous devices.
+
 config CMD_CROS_EC
bool "Enable crosec command"
depends on CROS_EC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 8d0fc3c..b285946 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+obj-$(CONFIG_DM_MISC) += misc-uclass.o
 obj-$(CONFIG_ALI152X) += ali512x.o
 obj-$(CONFIG_DS4510)  += ds4510.o
 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
new file mode 100644
index 000..40fe947
--- /dev/null
+++ b/drivers/misc/misc-uclass.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2010 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+UCLASS_DRIVER(misc) = {
+   .id = UCLASS_MISC,
+   .name   = "misc",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index aff34a4..a6982ab 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -39,6 +39,7 @@ enum uclass_id {
UCLASS_LED, /* Light-emitting diode (LED) */
UCLASS_LPC, /* x86 'low pin count' interface */
UCLASS_MASS_STORAGE,/* Mass storage device */
+   UCLASS_MISC,/* Miscellaneous device */
UCLASS_MMC, /* SD / MMC card or chip */
UCLASS_MOD_EXP, /* RSA Mod Exp device */
UCLASS_PCH, /* x86 platform controller hub */
diff --git a/include/misc.h b/include/misc.h
new file mode 100644
index 000..dfca41f
--- /dev/null
+++ b/include/misc.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _DM_MISC_H_
+#define _DM_MISC_H_
+
+/*
+ * struct dm_misc_ops - Driver model Misc operations
+ *
+ * The uclass interface is implemented by all miscellaneous devices which
+ * use driver model.
+ */
+struct dm_misc_ops {
+   int (*read)(struct udevice *dev, int offset, void *buf, int size);
+   int (*write)(struct udevice *dev, int offset, const void *buf,
+int size);
+};
+
+#endif /* _DM_MISC_H_ */
-- 
2.1.4

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


[U-Boot] [PATCH v2 2/2] nios2: convert altera sysid to driver model

2015-09-29 Thread Thomas Chou
Convert altera sysid to driver model with misc uclass.

Signed-off-by: Thomas Chou 
---
v2
  remove trailing whitespace in altera_sysid.c.

 arch/nios2/cpu/Makefile|  2 +-
 arch/nios2/cpu/cpu.c   | 15 +
 arch/nios2/cpu/sysid.c | 46 --
 arch/nios2/dts/3c120_devboard.dts  |  8 +++
 board/altera/nios2-generic/nios2-generic.c |  6 +-
 configs/nios2-generic_defconfig|  2 +
 drivers/misc/Kconfig   |  7 +++
 drivers/misc/Makefile  |  1 +
 drivers/misc/altera_sysid.c| 99 ++
 include/configs/nios2-generic.h|  3 +-
 10 files changed, 126 insertions(+), 63 deletions(-)
 delete mode 100644 arch/nios2/cpu/sysid.c
 create mode 100644 drivers/misc/altera_sysid.c

diff --git a/arch/nios2/cpu/Makefile b/arch/nios2/cpu/Makefile
index 3fe7847..185ca3c 100644
--- a/arch/nios2/cpu/Makefile
+++ b/arch/nios2/cpu/Makefile
@@ -7,5 +7,5 @@
 
 extra-y= start.o
 obj-y  = exceptions.o
-obj-y  += cpu.o interrupts.o sysid.o traps.o
+obj-y  += cpu.o interrupts.o traps.o
 obj-y  += fdt.o
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 88984e2..7b1717c 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -13,22 +13,11 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
-extern void display_sysid (void);
-#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
-
-#ifdef CONFIG_DISPLAY_CPUINFO
 int print_cpuinfo(void)
 {
-   printf ("CPU   : Nios-II\n");
-#if !defined(CONFIG_SYS_NIOS_SYSID_BASE)
-   printf ("SYSID : \n");
-#else
-   display_sysid ();
-#endif
-   return (0);
+   printf("CPU:   Nios-II\n");
+   return 0;
 }
-#endif /* CONFIG_DISPLAY_CPUINFO */
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/arch/nios2/cpu/sysid.c b/arch/nios2/cpu/sysid.c
deleted file mode 100644
index 50819b2..000
--- a/arch/nios2/cpu/sysid.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * (C) Copyright 2004, Psyent Corporation 
- * Scott McNutt 
- *
- * SPDX-License-Identifier:GPL-2.0+
- */
-
-#include 
-
-#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
-
-#include 
-#include 
-#include 
-
-typedef volatile struct {
-   unsignedid; /* The system build id */
-   unsignedtimestamp;  /* Timestamp */
-} nios_sysid_t;
-
-void display_sysid (void)
-{
-   nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
-   struct tm t;
-   char asc[32];
-   time_t stamp;
-
-   stamp = readl (>timestamp);
-   localtime_r (, );
-   asctime_r (, asc);
-   printf ("SYSID : %08lx, %s", readl (>id), asc);
-
-}
-
-int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-   display_sysid ();
-   return (0);
-}
-
-U_BOOT_CMD(
-   sysid,  1,  1,  do_sysid,
-   "display Nios-II system id",
-   ""
-);
-#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
diff --git a/arch/nios2/dts/3c120_devboard.dts 
b/arch/nios2/dts/3c120_devboard.dts
index 2e2956f..2eb339c 100644
--- a/arch/nios2/dts/3c120_devboard.dts
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -72,6 +72,7 @@
<0x4cc0 0x08004cc0 0x0010>,
<0x4ce0 0x08004ce0 0x0010>,
<0x4d00 0x08004d00 0x0010>,
+   <0x4d40 0x08004d40 0x0008>,
<0x4d50 0x08004d50 0x0008>,
<0x8000 0x08008000 0x0020>,
<0x0040 0x0840 0x0020>;
@@ -92,6 +93,13 @@
clock-frequency = < 12500 >;
};
 
+   sysid: sysid@0x4d40 {
+   compatible = "altr,sysid-1.0";
+   reg = <0x4d40 0x0008>;
+   id = <0>;
+   timestamp = <1440939556>;
+   };
+
jtag_uart: serial@0x4d50 {
compatible = "altr,juart-1.0";
reg = <0x4d50 0x0008>;
diff --git a/board/altera/nios2-generic/nios2-generic.c 
b/board/altera/nios2-generic/nios2-generic.c
index 61d32c7..e08b8f7 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -42,7 +42,11 @@ int board_early_init_r(void)
 
 int checkboard(void)
 {
-   printf("BOARD : %s\n", CONFIG_BOARD_NAME);
+#ifdef CONFIG_ALTERA_SYSID
+   extern void display_sysid(void);
+   display_sysid();
+#endif
+   printf("BOARD: %s\n", CONFIG_BOARD_NAME);
return 0;
 }
 
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index 

[U-Boot] [RFC PATCH] x86: Support booting SeaBIOS

2015-09-29 Thread Bin Meng
SeaBIOS is an open source implementation of a 16-bit X86 BIOS.
It can run in an emulator or natively on X86 hardware with the
use of coreboot. With SeaBIOS's help, we can boot some OSes
that require 16-bit BIOS services like Windows/DOS.

As U-Boot, we have to manually create a table where SeaBIOS gets
system information (eg: E820) from. The table unfortunately has
to follow the coreboot table format as SeaBIOS currently supports
booting as a coreboot payload. No U-Boot native support there.

Booting SeaBIOS is done via U-Boot's bootelf command.

This is the initial attempt to support booting SeaBIOS from U-Boot.
If the basic concept is good, I can spend time working on follow-on
patches to enable BIOS tables as well as graphics support. One issue
is that U-Boot x86 does not has a ROM file system like coreboot.
This brings difficulities to pass PCI option ROM to SeaBIOS, if we
don't modify SeaBIOS's source codes. Maybe we should promote CBFS
in U-Boot x86?

This is tested on an Intel Crown Bay board with VGA card, booting
SeaBIOS then chain loading a GRUB on a USB drive, then Linux kernel
finally.

Signed-off-by: Bin Meng 

---

 arch/x86/Kconfig  | 10 ++
 arch/x86/include/asm/tables.h | 29 +
 arch/x86/lib/tables.c | 39 +++
 3 files changed, 78 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5e42d7d..b432ff8 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -401,6 +401,16 @@ config PCIE_ECAM_SIZE
  so a default 0x1000 size covers all of the 256 buses which is the
  maximum number of PCI buses as defined by the PCI specification.
 
+config SEABIOS
+   bool "Support booting SeaBIOS"
+   help
+ SeaBIOS is an open source implementation of a 16-bit X86 BIOS.
+ It can run in an emulator or natively on X86 hardware with the use
+ of coreboot/U-Boot. By turning on this option, U-Boot prepares
+ all the configuration tables that are necessary to boot SeaBIOS.
+
+ Check http://www.seabios.org/SeaBIOS for details.
+
 source "arch/x86/lib/efi/Kconfig"
 
 endmenu
diff --git a/arch/x86/include/asm/tables.h b/arch/x86/include/asm/tables.h
index 0aa6d9b..a083cac 100644
--- a/arch/x86/include/asm/tables.h
+++ b/arch/x86/include/asm/tables.h
@@ -7,6 +7,32 @@
 #ifndef _X86_TABLES_H_
 #define _X86_TABLES_H_
 
+#ifdef CONFIG_SEABIOS
+
+#define CB_TAG_MEMORY  1
+
+struct cb_header {
+   u8 signature[4];
+   u32 header_bytes;
+   u32 header_checksum;
+   u32 table_bytes;
+   u32 table_checksum;
+   u32 table_entries;
+};
+
+struct cb_memory_range {
+   u64 start;
+   u64 size;
+   u32 type;
+};
+
+struct cb_memory {
+   u32 tag;
+   u32 size;
+   struct cb_memory_range map[0];
+};
+#endif
+
 /*
  * All x86 tables happen to like the address range from 0xf to 0x10.
  * We use 0xf as the starting address to store those tables, including
@@ -14,6 +40,9 @@
  */
 #define ROM_TABLE_ADDR 0xf
 
+/* SeaBIOS expects coreboot tables at address range 0x-0x1000 */
+#define CB_TABLE_ADDR  0x800
+
 /**
  * table_compute_checksum() - Compute a table checksum
  *
diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index f15b2e2..5849b2f 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 u8 table_compute_checksum(void *v, int len)
 {
@@ -36,6 +37,41 @@ void table_fill_string(char *dest, const char *src, size_t 
n, char pad)
dest[i] = pad;
 }
 
+#ifdef CONFIG_SEABIOS
+static u32 write_cb_tables(u32 addr)
+{
+   struct cb_header *cbh = (struct cb_header *)addr;
+   struct cb_memory *mem;
+   struct cb_memory_range *map;
+   struct e820entry entry[32];
+   int num, i;
+
+   memset(cbh, 0, sizeof(struct cb_header));
+   strncpy((char *)cbh->signature, "LBIO", 4);
+   cbh->header_bytes = sizeof(struct cb_header);
+
+   /* populate memory map table */
+   mem = (struct cb_memory *)(cbh + 1);
+   mem->tag = CB_TAG_MEMORY;
+   map = mem->map;
+   num = install_e820_map(32, entry);
+   for (i = 0; i < num; i++) {
+   map->start = entry[i].addr;
+   map->size = entry[i].size;
+   map->type = entry[i].type;
+   map++;
+   }
+   mem->size = num * sizeof(struct cb_memory_range) + 8;
+
+   cbh->table_bytes = mem->size;
+   cbh->table_checksum = compute_ip_checksum(mem, cbh->table_bytes);
+   cbh->table_entries = 1;
+   cbh->header_checksum = compute_ip_checksum(cbh, cbh->header_bytes);
+
+   return (u32)map;
+}
+#endif
+
 void write_tables(void)
 {
u32 __maybe_unused rom_table_end = ROM_TABLE_ADDR;
@@ -56,4 +92,7 @@ void write_tables(void)
rom_table_end = write_acpi_tables(rom_table_end);
rom_table_end = ALIGN(rom_table_end, 1024);
 #endif

Re: [U-Boot] [PATCH v2] board/BuR/kwb: use bootvx(...) (with bootline feature) instead go(...)

2015-09-29 Thread Bin Meng
On Tue, Sep 29, 2015 at 2:43 PM, Hannes Schmelzer  wrote:
> Since we don't have for sure a valid IP-setup during
> board_late_init(...) because it maybe allready stored in environment or
> not, we cannot form a proper vxWorks bootline at this place.
>
> So we move to the way, forming the bootline just before
> executing/launching vxWorks. To do this we use the bootvx command
> instead go.
>
> We only have to form the "othbootargs" environment variable, the rest is
> done pretty good by the "bootvx" commannd.
>
> Signed-off-by: Hannes Schmelzer 
> --
> ---
>
> Changes in v2:
> - form only othbootargs instead whole bootline within board-code
> - depends now on Bin Mengs changes belong CMD_ELF
> http://patchwork.ozlabs.org/patch/523289/
> - adapt kwb_defconfig to the new Kconfig defaults
> - use bootvx ... instead go ... to launch vxWorks kernel
>
>  board/BuR/kwb/board.c | 27 +--
>  configs/kwb_defconfig |  3 +++
>  include/configs/kwb.h |  8 +---
>  3 files changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/board/BuR/kwb/board.c b/board/BuR/kwb/board.c
> index 039ec20..ad74ff2 100644
> --- a/board/BuR/kwb/board.c
> +++ b/board/BuR/kwb/board.c
> @@ -47,10 +47,6 @@
>  #defineRSTCTRL_FORCE_PWR_NEN   0x0404
>  #defineRSTCTRL_CAN_STB 0x4040
>
> -#define VXWORKS_BOOTLINE   0x80001100
> -#define DEFAULT_BOOTLINE   "cpsw(0,0):pme/vxWorks"
> -#define VXWORKS_USER   "u=vxWorksFTP pw=vxWorks tn=vxtarget"
> -
>  DECLARE_GLOBAL_DATA_PTR;
>
>  #if defined(CONFIG_SPL_BUILD)
> @@ -281,20 +277,15 @@ int board_late_init(void)
> } else {
> puts("ERROR: i2c_set_bus_speed failed! (scratchregister)\n");
> }
> -   /* setup vxworks bootline */
> -   char *vxworksbootline = (char *)VXWORKS_BOOTLINE;
> -   sprintf(vxworksbootline,
> -   "%s h=%s e=%s:%s g=%s %s o=0x%08x;0x%08x;0x%08x;0x%08x",
> -   DEFAULT_BOOTLINE,
> -   getenv("serverip"),
> -   getenv("ipaddr"), getenv("netmask"),
> -   getenv("gatewayip"),
> -   VXWORKS_USER,
> -   (unsigned int) gd->fb_base-0x20,
> -   (u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
> -   (u32)getenv_ulong("vx_romfsbase", 16, 0),
> -   (u32)getenv_ulong("vx_romfssize", 16, 0));
> -
> +   /* setup othbootargs for bootvx-command (vxWorks bootline) */
> +   char othbootargs[128];
> +   snprintf(othbootargs, sizeof(othbootargs),
> +"u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x",
> +(unsigned int) gd->fb_base-0x20,
> +(u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
> +(u32)getenv_ulong("vx_romfsbase", 16, 0),
> +(u32)getenv_ulong("vx_romfssize", 16, 0));
> +   setenv("othbootargs", othbootargs);
> /*
>  * reset VBAR registers to its reset location, VxWorks 6.9.3.2 does
>  * expect that vectors are there, original u-boot moves them to _start
> diff --git a/configs/kwb_defconfig b/configs/kwb_defconfig
> index f82fcf3..0bbe0a7 100644
> --- a/configs/kwb_defconfig
> +++ b/configs/kwb_defconfig
> @@ -3,6 +3,9 @@ CONFIG_TARGET_KWB=y
>  CONFIG_SPL=y
>  CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1"
>  CONFIG_SYS_PROMPT="U-Boot (BuR V2.0)# "
> +# CONFIG_CMD_BOOTD is not set
> +# CONFIG_CMD_BOOTM is not set
> +# CONFIG_CMD_GO is not set
>  # CONFIG_CMD_IMI is not set
>  # CONFIG_CMD_IMLS is not set
>  # CONFIG_CMD_XIMG is not set
> diff --git a/include/configs/kwb.h b/include/configs/kwb.h
> index 96f2e9d..45253b8 100644
> --- a/include/configs/kwb.h
> +++ b/include/configs/kwb.h
> @@ -57,6 +57,8 @@
>  #ifndef CONFIG_SPL_BUILD
>  #define CONFIG_EXTRA_ENV_SETTINGS \
>  BUR_COMMON_ENV \
> +"bootaddr=0x80001100\0" \
> +"bootdev=cpsw(0,0)\0" \
>  "vx_romfsbase=0x800E\0" \
>  "vx_romfssize=0x2\0" \
>  "vx_memtop=0x8FBEF000\0" \
> @@ -66,7 +68,7 @@ BUR_COMMON_ENV \
>  "logoaddr=0x8200\0" \
>  "defaultARlen=0x8000\0" \
>  "loaddefaultAR=mmc read ${loadaddr} 800 ${defaultARlen}\0" \
> -"defaultAR=run loadromfs; run loaddefaultAR; go ${loadaddr}\0" \
> +"defaultAR=run loadromfs; run loaddefaultAR; bootvx ${loadaddr}\0" \
>  "logo0=fatload mmc 0:1 ${logoaddr} SYSTEM/ADDON/Bootlogo/Bootlogo.bmp.gz && 
> " \
> "bmp display ${logoaddr} 0 0\0" \
>  "logo1=fatload mmc 0:1 ${logoaddr} SYSTEM/BASE/Bootlogo/Bootlogo.bmp.gz && " 
> \
> @@ -74,11 +76,11 @@ BUR_COMMON_ENV \
>  "mmcboot=echo booting AR from eMMC-flash ...; "\
> "run logo0 || run logo1; " \
> "run loadromfs; " \
> -   "fatload mmc 0:1 ${loadaddr} arimg && go ${loadaddr}; " \
> +   "fatload mmc 0:1 ${loadaddr} arimg && bootvx ${loadaddr}; " \
> "run defaultAR;\0" \
>  "netboot=echo booting AR from network ...; " \
> "run loadromfs; " \
> -   

[U-Boot] [PATCH v3] nios2: convert nios2 cpu to driver model

2015-09-29 Thread Thomas Chou
Convert nios2 cpu to driver model. The cpu parameters are
extracted from device tree and saved to global data structure.
We will use them to replace the custom_fpga.h .

Signed-off-by: Thomas Chou 
---
v2
  move cpu param setup to arch_cpu_init_dm, remove probe.
v3
  fix coding style as Marek suggested.
  select CMD_CPU.

 arch/Kconfig |  3 ++
 arch/nios2/cpu/cpu.c | 75 ++--
 arch/nios2/dts/3c120_devboard.dts|  1 +
 arch/nios2/include/asm/global_data.h |  8 
 configs/nios2-generic_defconfig  |  3 +-
 5 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 207c778..9be1538 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -64,6 +64,9 @@ config NIOS2
select HAVE_GENERIC_BOARD
select SYS_GENERIC_BOARD
select SUPPORT_OF_CONTROL
+   select OF_CONTROL
+   select DM
+   select CPU
 
 config OPENRISC
bool "OpenRISC architecture"
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 39ae972..9e98742 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -6,7 +6,9 @@
  */
 
 #include 
-#include 
+#include 
+#include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -51,10 +53,77 @@ void dcache_disable(void)
flush_dcache(CONFIG_SYS_DCACHE_SIZE, CONFIG_SYS_DCACHELINE_SIZE);
 }
 
-int arch_cpu_init(void)
+int arch_cpu_init_dm(void)
 {
-   gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
+   struct udevice *dev;
+
+   uclass_first_device(UCLASS_CPU, );
+   if (!dev)
+   return -ENODEV;
+
+   gd->cpu_clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "clock-frequency", 0);
+   gd->arch.dcache_line_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "dcache-line-size", 0);
+   gd->arch.icache_line_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "icache-line-size", 0);
+   gd->arch.dcache_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "dcache-size", 0);
+   gd->arch.icache_size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "icache-size", 0);
+   gd->arch.reset_addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "altr,reset-addr", 0);
+   gd->arch.exception_addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "altr,exception-addr", 0);
+   gd->arch.has_mmu = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "altr,has-mmu", 0);
+   gd->arch.io_region_base = gd->arch.has_mmu ? 0xe000 : 0x800;
gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
 
return 0;
 }
+
+static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size)
+{
+   const char *cpu_name = "Nios-II";
+
+   if (size < strlen(cpu_name))
+   return -ENOSPC;
+   strcpy(buf, cpu_name);
+
+   return 0;
+}
+
+static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info)
+{
+   info->cpu_freq = gd->cpu_clk;
+   info->features = (1 << CPU_FEAT_L1_CACHE) |
+   (gd->arch.has_mmu ? (1 << CPU_FEAT_MMU) : 0);
+
+   return 0;
+}
+
+static int altera_nios2_get_count(struct udevice *dev)
+{
+   return 1;
+}
+
+static const struct cpu_ops altera_nios2_ops = {
+   .get_desc   = altera_nios2_get_desc,
+   .get_info   = altera_nios2_get_info,
+   .get_count  = altera_nios2_get_count,
+};
+
+static const struct udevice_id altera_nios2_ids[] = {
+   { .compatible = "altr,nios2-1.0" },
+   { .compatible = "altr,nios2-1.1" },
+   { }
+};
+
+U_BOOT_DRIVER(altera_nios2) = {
+   .name   = "altera_nios2",
+   .id = UCLASS_CPU,
+   .of_match   = altera_nios2_ids,
+   .ops= _nios2_ops,
+   .flags  = DM_FLAG_PRE_RELOC,
+};
diff --git a/arch/nios2/dts/3c120_devboard.dts 
b/arch/nios2/dts/3c120_devboard.dts
index 781a652..2e2956f 100644
--- a/arch/nios2/dts/3c120_devboard.dts
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -41,6 +41,7 @@
altr,exception-addr = <0xd020>;
altr,has-initda = <1>;
altr,has-mmu = <1>;
+   u-boot,dm-pre-reloc;
};
};
 
diff --git a/arch/nios2/include/asm/global_data.h 
b/arch/nios2/include/asm/global_data.h
index 580b019..ee5180b 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -9,6 +9,14 @@
 
 /* Architecture-specific global data */
 struct arch_global_data {
+   u32 dcache_line_size;
+   u32 icache_line_size;
+   u32 dcache_size;
+   u32 icache_size;
+   u32 reset_addr;
+   u32 exception_addr;
+   int has_mmu;
+   u32 io_region_base;
 };
 
 #include 
diff --git a/configs/nios2-generic_defconfig b/configs/nios2-generic_defconfig
index ad72272..707ee33 100644
--- a/configs/nios2-generic_defconfig

Re: [U-Boot] [PATCH v2] nios2: convert nios2 cpu to driver model

2015-09-29 Thread Bin Meng
On Tue, Sep 29, 2015 at 10:28 PM, Bin Meng  wrote:
> +Simon
>
> On Tue, Sep 29, 2015 at 3:18 PM, Thomas Chou  wrote:
>> Hi Marek,
>>
>> On 09/29/2015 10:45 AM, Marek Vasut wrote:

 --- a/arch/Kconfig
 +++ b/arch/Kconfig
 @@ -64,6 +64,9 @@ config NIOS2
 select HAVE_GENERIC_BOARD
 select SYS_GENERIC_BOARD
 select SUPPORT_OF_CONTROL
 +   select OF_CONTROL
 +   select DM
 +   select CPU
>>>
>>>
>>> What's this CONFIG_CPU for please ?
>>
>>
>> drivers/cpu/Kconfig
>>
>> It is "Enable CPU drivers using Driver Model". I think it should have been
>> named as CONFIG_DM_CPU to avoid confusion.
>
> I remember Simon intended to name it as CONFIG_DM_CPU as I raised
> similar comments before.

Oops, I must be drunk! I mean CONFIG_CPU ...

>
> [snip]
>
> Regards,
> Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/2] bitops: Add support for order_base_2()

2015-09-29 Thread Fabio Estevam
Add support for the order_base_2() macro (and its dependencies)
from the Linux kernel.

This is useful for the SPI NOR unlock function.

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None.

 arch/arm/include/asm/bitops.h | 56 +++
 1 file changed, 56 insertions(+)

diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index 9b78043..b9b6d21 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -108,6 +108,62 @@ static inline int __ilog2(unsigned int x)
return generic_fls(x) - 1;
 }
 
+static inline int fls64(__u64 x)
+{
+   if (x == 0)
+   return 0;
+   return generic_fls(x) + 1;
+}
+
+static inline unsigned fls_long(unsigned long l)
+{
+   if (sizeof(l) == 4)
+   return generic_fls(l);
+   return fls64(l);
+}
+
+/*
+ * round up to nearest power of two
+ */
+static inline __attribute__((const))
+unsigned long __roundup_pow_of_two(unsigned long n)
+{
+   return 1UL << fls_long(n - 1);
+}
+
+/**
+ * roundup_pow_of_two - round the given value up to nearest power of two
+ * @n - parameter
+ *
+ * round the given value up to the nearest power of two
+ * - the result is undefined when n == 0
+ * - this can be used to initialise global variables from constant data
+ */
+#define roundup_pow_of_two(n)  \
+(  \
+   __builtin_constant_p(n) ? ( \
+   (n == 1) ? 1 :  \
+   (1UL << (__ilog2((n) - 1) + 1)) \
+  ) :  \
+   __roundup_pow_of_two(n) \
+)
+
+/**
+ * order_base_2 - calculate the (rounded up) base 2 order of the argument
+ * @n: parameter
+ *
+ * The first few values calculated by this routine:
+ *  ob2(0) = 0
+ *  ob2(1) = 0
+ *  ob2(2) = 1
+ *  ob2(3) = 2
+ *  ob2(4) = 2
+ *  ob2(5) = 3
+ *  ... and so on.
+ */
+
+#define order_base_2(n) __ilog2(roundup_pow_of_two(n))
+
 /*
  * ffz = Find First Zero in word. Undefined if no zero exists,
  * so code should check against ~0UL first..
-- 
1.9.1

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


[U-Boot] [PATCH v2 2/2] spi: Add SPI NOR protection mechanism

2015-09-29 Thread Fabio Estevam
Many SPI flashes have protection bits (BP2, BP1 and BP0) in the
status register that can protect selected regions of the SPI NOR.

Take these bits into account when performing erase operations,
making sure that the protected areas are skipped.

Introduce the CONFIG_SPI_FLASH_STM_PROTECT option that can be
selectedby systems that want to protect regions of SPI NOR flash
using the same programming model as in the ST Micro SPI NOR flashes,
like for example the M25P32.

Based on the implementation from Brian Norris 
for the Linux kernel:
https://patchwork.ozlabs.org/patch/513041/

Tested on a mx6qsabresd:

=> sf probe 
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
=> sf protect on  0x3f 0x1  
=> sf erase 0x3f 0x1
offset 0x3f is protected and cannot be erased   
SF: 65536 bytes @ 0x3f Erased: ERROR
=> sf protect off  0x3f 0x1 
=> sf erase 0x3f 0x1
SF: 65536 bytes @ 0x3f Erased: OK   

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Add CONFIG_SPI_FLASH_STM_PROTECT in the Kconfig as suggested by 
Stefan Roese

 common/cmd_sf.c   |  30 +++
 drivers/mtd/spi/Kconfig   |  15 
 drivers/mtd/spi/sf_internal.h |   6 --
 drivers/mtd/spi/sf_ops.c  | 188 ++
 include/spi_flash.h   |  25 +-
 5 files changed, 256 insertions(+), 8 deletions(-)

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index ac7f5df..a31243f 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -348,6 +348,28 @@ static int do_spi_flash_erase(int argc, char * const 
argv[])
return ret == 0 ? 0 : 1;
 }
 
+#ifdef CONFIG_SPI_FLASH_STM_PROTECT
+static int do_spi_protect(int argc, char * const argv[])
+{
+   int start, len, ret = 0;
+
+   if (argc != 4)
+   return -1;
+
+   start = simple_strtoull(argv[2], NULL, 16);
+   len = simple_strtoull(argv[3], NULL, 16);
+
+   if (strcmp(argv[1], "on") == 0)
+   ret = stm_lock(flash, start, len);
+   else if (strcmp(argv[1], "off") == 0)
+   ret = stm_unlock(flash, start, len);
+   else
+   return -1;  /* Unknown parameter */
+
+   return ret == 0 ? 0 : 1;
+}
+#endif
+
 #ifdef CONFIG_CMD_SF_TEST
 enum {
STAGE_ERASE,
@@ -540,6 +562,10 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int 
argc,
ret = do_spi_flash_read_write(argc, argv);
else if (strcmp(cmd, "erase") == 0)
ret = do_spi_flash_erase(argc, argv);
+#ifdef CONFIG_SPI_FLASH_STM_PROTECT
+   else if (strcmp(cmd, "protect") == 0)
+   ret = do_spi_protect(argc, argv);
+#endif
 #ifdef CONFIG_CMD_SF_TEST
else if (!strcmp(cmd, "test"))
ret = do_spi_flash_test(argc, argv);
@@ -579,5 +605,9 @@ U_BOOT_CMD(
"sf update addr offset|partition len- erase and write `len' bytes 
from memory\n"
" at `addr' to flash at 
`offset'\n"
" or to start of mtd 
`partition'\n"
+#ifdef CONFIG_SPI_FLASH_STM_PROTECT
+   "sf protect on/off sector len   - protect/unprotect 'len' bytes 
starting\n"
+   " at address 'sector'\n"
+#endif
SF_TEST_HELP
 );
diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
index 3f7433c..2ee1089 100644
--- a/drivers/mtd/spi/Kconfig
+++ b/drivers/mtd/spi/Kconfig
@@ -101,6 +101,21 @@ config SPI_FLASH_USE_4K_SECTORS
  Please note that some tools/drivers/filesystems may not work with
  4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
 
+config SPI_FLASH_STM_PROTECT
+   bool "Use STM flash protection mechanism"
+   depends on SPI_FLASH
+   help
+ Enable the built-in protection mechanism provided by the
+ BP2, BP1 and BP0 bits from the status register present
+ on ST-Micro flashes such as M25P32. Please refer to the
+ M25P32 datasheet to understand how to program these bits
+ in order to protect a selected region of the SPI NOR flash.
+
+ This same bit protection programming model applies to SPI
+ NOR flashes from other manufacturers such as:
+ - Micron M25P32
+ - SST SST25V32B
+
 config SPI_FLASH_DATAFLASH
bool "AT45xxx DataFlash support"
depends on SPI_FLASH && DM_SPI_FLASH
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 9c95d56..e66a62b 100644
--- 

Re: [U-Boot] ## Application terminated, rc = 0x1

2015-09-29 Thread ba_f

Thank you two,
this was the hint i needed.

The Load-Address was wrong.


Anyway, i still don't know how to determine the Load- & Entry-Address, 
and i would be thankful if you could clear some things up for me.


I always work on ARM Cortex A9 processors.
The first time i came in touch with U-Boot i booted a Uimage kernel, and 
i had to do it the following way:

(Please, notice the offset between Load- & Entry-Address)

uboot> fatload mmc 0 0x00c0 bootstrap.uimage
uboot> go 0x0100

But, while both kernels (the Uimage and the current mini kernel) are 
linked for start address 0x0100, i cannot use the same load address 
on the mini-Kernel. Now, i have to load and jump to the same address to 
make it work. Like this:


uboot> fatload mmc 0 0x0100 miniKernel.bin
uboot> go 0x0100

Why this? How comes the offset with the Uimage?


Another issue:

I tried to execute the same Uimage on another platform. The platform has 
the same processor but another U-Boot.

On this platform i fail to execute with my common way:

uboot> fatload mmc 0 0x00c0 bootstrap.uimage
uboot> go 0x0100
## Starting application at 0x0100 ...
undefined instruction
pc : [<01f4>] lr : [<3ff74bc0>]


This looks to me like a wrong Load- or Entry-Address.
But again, it is the same Uimage with start address 0x0100.

What's wrong here?
I'm confused...
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] nios2: convert nios2 cpu to driver model

2015-09-29 Thread Bin Meng
+Simon

On Tue, Sep 29, 2015 at 3:18 PM, Thomas Chou  wrote:
> Hi Marek,
>
> On 09/29/2015 10:45 AM, Marek Vasut wrote:
>>>
>>> --- a/arch/Kconfig
>>> +++ b/arch/Kconfig
>>> @@ -64,6 +64,9 @@ config NIOS2
>>> select HAVE_GENERIC_BOARD
>>> select SYS_GENERIC_BOARD
>>> select SUPPORT_OF_CONTROL
>>> +   select OF_CONTROL
>>> +   select DM
>>> +   select CPU
>>
>>
>> What's this CONFIG_CPU for please ?
>
>
> drivers/cpu/Kconfig
>
> It is "Enable CPU drivers using Driver Model". I think it should have been
> named as CONFIG_DM_CPU to avoid confusion.

I remember Simon intended to name it as CONFIG_DM_CPU as I raised
similar comments before.

[snip]

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


Re: [U-Boot] [PATCH v2] nios2: convert nios2 cpu to driver model

2015-09-29 Thread Simon Glass
Hi,

On 29 September 2015 at 08:29, Bin Meng  wrote:
> On Tue, Sep 29, 2015 at 10:28 PM, Bin Meng  wrote:
>> +Simon
>>
>> On Tue, Sep 29, 2015 at 3:18 PM, Thomas Chou  wrote:
>>> Hi Marek,
>>>
>>> On 09/29/2015 10:45 AM, Marek Vasut wrote:
>
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -64,6 +64,9 @@ config NIOS2
> select HAVE_GENERIC_BOARD
> select SYS_GENERIC_BOARD
> select SUPPORT_OF_CONTROL
> +   select OF_CONTROL
> +   select DM
> +   select CPU


 What's this CONFIG_CPU for please ?
>>>
>>>
>>> drivers/cpu/Kconfig
>>>
>>> It is "Enable CPU drivers using Driver Model". I think it should have been
>>> named as CONFIG_DM_CPU to avoid confusion.
>>
>> I remember Simon intended to name it as CONFIG_DM_CPU as I raised
>> similar comments before.
>
> Oops, I must be drunk! I mean CONFIG_CPU ...

Yes. The CONFIG_DM_xxx options will go away as each subsystem is
converted to driver model.

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


Re: [U-Boot] [ANN] U-Boot v2015.10-rc4 released

2015-09-29 Thread Lukasz Majewski
Hi Tom,

> Hey all,
> 
> I've pushed v2015.10-rc4 out to the repository and tarballs should
> exist soon.
> 
> We're coming up on the release date and I think things are in
> reasonable shape overall.  Please speak up if there's some fixes I'm
> still overlooking, I thought I grabbed them all by now but I may have
> still missed something.
> 

I've found more issues with Exynos4 (Trats) regarding changes done in
the following commit:

"fdt: add new fdt address parsing functions"
SHA1: 02464e386bb5f0a022c121f95ae75cf583759d95

I'm strive to fix this issue ASAP.

-- 
Best regards,

Lukasz Majewski

Samsung R Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] Please pull u-boot-x86.git (take 2)

2015-09-29 Thread Simon Glass
Hi Tom.

This include one more bug fix.

The following changes since commit 1f8836396de8215b7f460616926052b32597bb29:

  Prepare v2015.10-rc4 (2015-09-28 16:57:42 -0400)

are available in the git repository at:

  git://git.denx.de/u-boot-x86.git

for you to fetch changes up to 196193a4d4963a8dde00c7cdd0ec83b60ea61e61:

  x86: fsp: Report correct number of E820 table entries (2015-09-28
21:56:27 -0700)


Bin Meng (1):
  x86: fsp: Report correct number of E820 table entries

Simon Glass (1):
  x86: chromebook_link: Expand early malloc() memory

 arch/x86/lib/fsp/fsp_dram.c   | 3 ++-
 configs/chromebook_link_defconfig | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

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


[U-Boot] [PATCH v2 02/10] vexpress64: Kconfig: tidy up

2015-09-29 Thread Ryan Harkin
The FVP and Juno settings were identical, but duplicated, so I removed
the duplication with this patch.

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 board/armltd/vexpress64/Kconfig | 17 -
 1 file changed, 17 deletions(-)

diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
index f5693ae..8da3bec 100644
--- a/board/armltd/vexpress64/Kconfig
+++ b/board/armltd/vexpress64/Kconfig
@@ -1,5 +1,3 @@
-if TARGET_VEXPRESS64_BASE_FVP
-
 config SYS_BOARD
default "vexpress64"
 
@@ -8,18 +6,3 @@ config SYS_VENDOR
 
 config SYS_CONFIG_NAME
default "vexpress_aemv8a"
-
-endif
-
-if TARGET_VEXPRESS64_JUNO
-
-config SYS_BOARD
-   default "vexpress64"
-
-config SYS_VENDOR
-   default "armltd"
-
-config SYS_CONFIG_NAME
-   default "vexpress_aemv8a"
-
-endif
-- 
2.1.0

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


[U-Boot] [PATCH v2 01/10] vexpress64: fix checkpatch warnings

2015-09-29 Thread Ryan Harkin
This patch fixes a couple of checkpatch warnings on the vexpress64 config.

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 6107c64..53b0f74 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -194,7 +194,8 @@
 #define CONFIG_BOOTARGS"console=ttyAMA0,115200n8 " \
"root=/dev/sda1 rw " \
"rootwait "\
-   "earlyprintk=pl011,0x7ff8 debug 
user_debug=31 "\
+   "earlyprintk=pl011,0x7ff8 debug "\
+   "user_debug=31 "\
"loglevel=9"
 
 /* Copy the kernel and FDT to DRAM memory and boot */
@@ -222,7 +223,8 @@
 
 #define CONFIG_BOOTCOMMAND "smhload ${kernel_name} ${kernel_addr}; " \
"smhload ${fdt_name} ${fdt_addr}; " \
-   "smhload ${initrd_name} ${initrd_addr} 
initrd_end; " \
+   "smhload ${initrd_name} ${initrd_addr} "\
+   "initrd_end; " \
"fdt addr ${fdt_addr}; fdt resize; " \
"fdt chosen ${initrd_addr} ${initrd_end}; " \
"booti $kernel_addr - $fdt_addr"
-- 
2.1.0

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


[U-Boot] [PATCH v2 10/10] vexpress64: juno: use /dev/sda2

2015-09-29 Thread Ryan Harkin
This patch changes the default "root=" parameter to "/dev/sda2".

Many linux based distros use /dev/sda1 for their boot partition; this is
often not a rootfs that can be used by the "root=" parameter.

Linaro images use /dev/sda1 as a boot partition, although this of a
different nature to a distro image.  Linaro uses /dev/sda2 for the rootfs
partition.

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 259f6ac..ef3014d 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -200,7 +200,7 @@
 
 /* Assume we boot with root on the first partition of a USB stick */
 #define CONFIG_BOOTARGS"console=ttyAMA0,115200n8 " \
-   "root=/dev/sda1 rw " \
+   "root=/dev/sda2 rw " \
"rootwait "\
"earlyprintk=pl011,0x7ff8 debug "\
"user_debug=31 "\
-- 
2.1.0

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


Re: [U-Boot] "go" does not work for uImage - was: ## Application terminated, rc = 0x1

2015-09-29 Thread Wolfgang Denk
Dear ba_f,

In message <2e2178cf246f80c4f9098dce357e5...@rbg.informatik.tu-darmstadt.de> 
you wrote:
>
> Another issue:

So, here we go in a new thread.

> I tried to execute the same Uimage on another platform. The platform has 
> the same processor but another U-Boot.
> On this platform i fail to execute with my common way:
> 
> uboot> fatload mmc 0 0x00c0 bootstrap.uimage
> uboot> go 0x0100
> ## Starting application at 0x0100 ...
> undefined instruction
> pc : [<01f4>] lr : [<3ff74bc0>]

Your other platform might use a different memory map...

After running the "fatload" as above, type

iminfo c0

and it will show you which load and entry point addresses shuld be
used.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Testing can show the presense of bugs, but not their absence.
   -- Edsger Dijkstra
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 05/10] vexpress64: juno: add androidboot.hardware=juno

2015-09-29 Thread Ryan Harkin
Linaro's Juno Android builds requires the androidboot.hardware parameter
be set to a know board name.

Non-Android kernels ignore this extra parameter because they don't
contain code to parse it.

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index c1e2e11..f9fa2ce 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -200,6 +200,7 @@
"rootwait "\
"earlyprintk=pl011,0x7ff8 debug "\
"user_debug=31 "\
+   "androidboot.hardware=juno "\
"loglevel=9"
 
 /* Copy the kernel and FDT to DRAM memory and boot */
-- 
2.1.0

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


[U-Boot] [PATCH v2 07/10] common/armflash: load_image returns success or failure

2015-09-29 Thread Ryan Harkin
Change the load_image so that it returns success or failure of the
command (using CMD_RET_SUCCESS or CMD_RET_FAILURE).

This way, hush scripts can optionally load different files depending
upon the system configuration.

A simple example:

if afs load ${kernel_name} ${kernel_addr}; then echo loaded; else echo \
not loaded; fi

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 common/cmd_armflash.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/common/cmd_armflash.c b/common/cmd_armflash.c
index a37f5c4..02b7fee 100644
--- a/common/cmd_armflash.c
+++ b/common/cmd_armflash.c
@@ -175,7 +175,7 @@ static void parse_flash(void)
parse_bank(bank);
 }
 
-static void load_image(const char * const name, const ulong address)
+static int load_image(const char * const name, const ulong address)
 {
struct afs_image *afi = NULL;
int i;
@@ -191,7 +191,7 @@ static void load_image(const char * const name, const ulong 
address)
}
if (!afi) {
printf("image \"%s\" not found in flash\n", name);
-   return;
+   return CMD_RET_FAILURE;
}
 
for (i = 0; i < afi->region_count; i++) {
@@ -215,6 +215,7 @@ static void load_image(const char * const name, const ulong 
address)
   to,
   afi->regions[i].size);
}
+   return CMD_RET_SUCCESS;
 }
 
 static void print_images(void)
@@ -274,12 +275,12 @@ static int do_afs(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
} else if (argc == 3 && !strcmp(argv[1], "exists")) {
ret = exists(argv[2]);
} else if (argc == 3 && !strcmp(argv[1], "load")) {
-   load_image(argv[2], 0x0);
+   ret = load_image(argv[2], 0x0);
} else if (argc == 4 && !strcmp(argv[1], "load")) {
ulong load_addr;
 
load_addr = simple_strtoul(argv[3], NULL, 16);
-   load_image(argv[2], load_addr);
+   ret = load_image(argv[2], load_addr);
} else {
return CMD_RET_USAGE;
}
-- 
2.1.0

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


[U-Boot] [PATCH v2 08/10] vexpress64: juno: add optional initrd

2015-09-29 Thread Ryan Harkin
Some OS images require an initrd on Juno.

If the file ramdisk.img exists in NOR flash, then we load it and pass
the address to the kernel.  Otherwise, we pass the "-" parameter as
before.

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index f9fa2ce..99dd8b6 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -189,6 +189,8 @@
 #define CONFIG_EXTRA_ENV_SETTINGS  \
"kernel_name=Image\0"   \
"kernel_addr=0x8000\0" \
+   "initrd_name=ramdisk.img\0" \
+   "initrd_addr=0x8400\0"  \
"fdt_name=juno\0" \
"fdt_addr=0x8300\0" \
"fdt_high=0x\0" \
@@ -207,7 +209,12 @@
 #define CONFIG_BOOTCOMMAND "afs load ${kernel_name} ${kernel_addr} ; " \
"afs load  ${fdt_name} ${fdt_addr} ; " \
"fdt addr ${fdt_addr}; fdt resize; " \
-   "booti ${kernel_addr} - ${fdt_addr}"
+   "if afs load  ${initrd_name} ${initrd_addr} ; "\
+   "then "\
+   "  setenv initrd_param ${initrd_addr}; "\
+   "  else setenv initrd_param -; "\
+   "fi ; " \
+   "booti ${kernel_addr} ${initrd_param} 
${fdt_addr}"
 
 #define CONFIG_BOOTDELAY   1
 
-- 
2.1.0

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


[U-Boot] [PATCH v2 06/10] common/armflash: add command to check if image exists

2015-09-29 Thread Ryan Harkin
Add a command to the ARM flash support to check if an image exists or
not.

If the image is found, it will return CMD_RET_SUCCESS, else
CMD_RET_FAILURE.  This allows hush scripts to conditionally load images.

A simple example:

if afs exists ${kernel_name}; then echo found; else echo \
not found; fi

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 common/cmd_armflash.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/common/cmd_armflash.c b/common/cmd_armflash.c
index 1db92b0..a37f5c4 100644
--- a/common/cmd_armflash.c
+++ b/common/cmd_armflash.c
@@ -251,10 +251,28 @@ static void print_images(void)
}
 }
 
+static int exists(const char * const name)
+{
+   int i;
+
+   parse_flash();
+   for (i = 0; i < num_afs_images; i++) {
+   struct afs_image *afi = _images[i];
+
+   if (strcmp(afi->name, name) == 0)
+   return CMD_RET_SUCCESS;
+   }
+   return CMD_RET_FAILURE;
+}
+
 static int do_afs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
+   int ret = CMD_RET_SUCCESS;
+
if (argc == 1) {
print_images();
+   } else if (argc == 3 && !strcmp(argv[1], "exists")) {
+   ret = exists(argv[2]);
} else if (argc == 3 && !strcmp(argv[1], "load")) {
load_image(argv[2], 0x0);
} else if (argc == 4 && !strcmp(argv[1], "load")) {
@@ -266,12 +284,14 @@ static int do_afs(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return CMD_RET_USAGE;
}
 
-   return 0;
+   return ret;
 }
 
 U_BOOT_CMD(afs, 4, 0, do_afs, "show AFS partitions",
   "no arguments\n"
   "- list images in flash\n"
+  "exists \n"
+  "- returns 1 if an image exists, else 0\n"
   "load \n"
   "- load an image to the location indicated in the header\n"
   "load  0x\n"
-- 
2.1.0

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


Re: [U-Boot] ## Application terminated, rc = 0x1

2015-09-29 Thread Wolfgang Denk
Dear ba_f,

In message <2e2178cf246f80c4f9098dce357e5...@rbg.informatik.tu-darmstadt.de> 
you wrote:
> 
> Anyway, i still don't know how to determine the Load- & Entry-Address, 
> and i would be thankful if you could clear some things up for me.

Did you read the FAQ? See es[ecially [1]

[1] http://www.denx.de/wiki/view/DULG/MyStandaloneProgramDoesNotWork


> The first time i came in touch with U-Boot i booted a Uimage kernel, and 
> i had to do it the following way:
> (Please, notice the offset between Load- & Entry-Address)
> 
> uboot> fatload mmc 0 0x00c0 bootstrap.uimage
> uboot> go 0x0100

Any uImage should be booted using the "bootm" command, not "go".

> But, while both kernels (the Uimage and the current mini kernel) are 
> linked for start address 0x0100, i cannot use the same load address 
> on the mini-Kernel. Now, i have to load and jump to the same address to 
> make it work. Like this:
> 
> uboot> fatload mmc 0 0x0100 miniKernel.bin
> uboot> go 0x0100
> 
> Why this? How comes the offset with the Uimage?

The uImage file contains a 64 byte header which is interpreted by
commands like "iminfo" or "bootm".


> Another issue:

Plese do NOT do that.  Do not mix topics in a single posting.  Please
open a new thread instead.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Mike's Law: For a lumber company employing two men and a cut-off saw,
the marginal product of labor for any number  of  additional  workers
equals  zero  until the acquisition of another cut-off saw. Let's not
even consider a chainsaw.
- Mike Dennison [You could always  schedule the saw, though - ed.]
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 04/10] vexpress64: fvp dram: add DRAM configuration

2015-09-29 Thread Ryan Harkin
Create an additional FVP configuration to boot images pre-loaded into
DRAM.

Sometimes it's preferential to boot the model by loading the files
directly into DRAM via model parameters, rather than using
SemiHosting.

An example of model parmaters that are used to pre-load the files
into DRAM:
--data cluster0.cpu0=Image@0x8008 \
--data cluster0.cpu0=fvp-base-gicv2-psci.dtb@0x8300 \
--data cluster0.cpu0=uInitrd@0x8400

Signedoff-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 arch/arm/Kconfig   |  4 
 configs/vexpress_aemv8a_dram_defconfig | 19 +++
 include/configs/vexpress_aemv8a.h  | 25 +++--
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c4371c7..c62c3de 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -563,6 +563,10 @@ config TARGET_VEXPRESS64_BASE_FVP
select ARM64
select SEMIHOSTING
 
+config TARGET_VEXPRESS64_BASE_FVP_DRAM
+   bool "Support Versatile Express ARMv8a FVP BASE model booting from DRAM"
+   select ARM64
+
 config TARGET_VEXPRESS64_JUNO
bool "Support Versatile Express Juno Development Platform"
select ARM64
diff --git a/configs/vexpress_aemv8a_dram_defconfig 
b/configs/vexpress_aemv8a_dram_defconfig
new file mode 100644
index 000..e9fc870
--- /dev/null
+++ b/configs/vexpress_aemv8a_dram_defconfig
@@ -0,0 +1,19 @@
+CONFIG_ARM=y
+CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_DEFAULT_DEVICE_TREE="vexpress64"
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EDITENV is not set
+# CONFIG_CMD_ENV_EXISTS is not set
+# CONFIG_CMD_LOADS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+# CONFIG_CMD_ITEST is not set
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_NFS is not set
+# CONFIG_CMD_MISC is not set
+CONFIG_DM=y
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_PROMPT="VExpress64# "
diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index c54baf8..c1e2e11 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -30,7 +30,8 @@
 #define CONFIG_BOOTP_VCI_STRING"U-boot.armv8.vexpress_aemv8a"
 
 /* Link Definitions */
-#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
+#if defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP) || \
+   defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM)
 /* ATF loads u-boot here for BASE_FVP model */
 #define CONFIG_SYS_TEXT_BASE   0x8800
 #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f0)
@@ -103,7 +104,8 @@
 #define GICR_BASE  (0x2f10)
 #else
 
-#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
+#if defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP) || \
+   defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM)
 #define GICD_BASE  (0x2f00)
 #define GICC_BASE  (0x2c00)
 #elif CONFIG_TARGET_VEXPRESS64_JUNO
@@ -233,6 +235,25 @@
 
 #define CONFIG_BOOTDELAY   1
 
+#elif CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM
+#define CONFIG_EXTRA_ENV_SETTINGS  \
+   "kernel_addr=0x8008\0"  \
+   "initrd_addr=0x8400\0"  \
+   "fdt_addr=0x8300\0" \
+   "fdt_high=0x\0" \
+   "initrd_high=0x\0"
+
+#define CONFIG_BOOTARGS"console=ttyAMA0 earlyprintk=pl011,"\
+   "0x1c09 debug user_debug=31 "\
+   "androidboot.hardware=fvpbase "\
+   "root=/dev/vda2 rw "\
+   "rootwait "\
+   "loglevel=9"
+
+#define CONFIG_BOOTCOMMAND "booti $kernel_addr $initrd_addr $fdt_addr"
+
+#define CONFIG_BOOTDELAY   1
+
 #else
 #error "Unknown board variant"
 #endif
-- 
2.1.0

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


[U-Boot] [PATCH v2 00/10] vexpress64 FVP and Juno configuration updates

2015-09-29 Thread Ryan Harkin
This patch series updates the default configuration of the vexpress64 FVP
and Juno platforms to allow it to work on a variety of setups without
modification by the user.

[PATCH v2 01/10] vexpress64: fix checkpatch warnings
[PATCH v2 02/10] vexpress64: Kconfig: tidy up
[PATCH v2 03/10] vexpress64: increase max gunzip size
[PATCH v2 04/10] vexpress64: fvp dram: add DRAM configuration
[PATCH v2 05/10] vexpress64: juno: add androidboot.hardware=juno
[PATCH v2 06/10] common/armflash: add command to check if image exists
[PATCH v2 07/10] common/armflash: load_image returns success or failure
[PATCH v2 08/10] vexpress64: juno: add optional initrd
[PATCH v2 09/10] vexpress64: juno: add alternate kernel and device tree
[PATCH v2 10/10] vexpress64: juno: use /dev/sda2

 arch/arm/Kconfig   |  4 
 board/armltd/vexpress64/Kconfig| 17 -
 board/armltd/vexpress64/MAINTAINERS|  5 +
 common/cmd_armflash.c  | 31 ++-
 configs/vexpress_aemv8a_dram_defconfig | 19 +++
 include/configs/vexpress_aemv8a.h  | 61 
+
 6 files changed, 107 insertions(+), 30 deletions(-)

Changes since v1:
- dropped the Kconfig changes for CONFIG_SYS_BOOTM_LEN
- added CONFIG_SYS_BOOTM_LEN to include/configs/vexpress_aemv8a.h

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


[U-Boot] [PATCH v2 09/10] vexpress64: juno: add alternate kernel and device tree filenames

2015-09-29 Thread Ryan Harkin
The default Juno firmware has renamed the kernel and device tree
filenames to norkern and board.dtb.

Rather than change the default configuration to use the new names,
breaking those with the old firmware, attempt to load the existing
filename first.  If that fails, attempt to load the alternate filename.

I've echo'd that we are loading the alternate file to counter the
output from "afs load" when the first load attempt fails.  For example,
I see this output on my Juno board:

image "Image" not found in flash
Loading norkern instead of Image
loaded region 0 from 0850 to 8000, 00AB6318 bytes
image "juno" not found in flash
Loading board.dtb instead of juno
loaded region 0 from 0A00 to 8300, 3188 bytes

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 99dd8b6..259f6ac 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -187,11 +187,13 @@
  * be copied into DRAM
  */
 #define CONFIG_EXTRA_ENV_SETTINGS  \
-   "kernel_name=Image\0"   \
+   "kernel_name=norkern\0" \
+   "kernel_alt_name=Image\0"   \
"kernel_addr=0x8000\0" \
"initrd_name=ramdisk.img\0" \
"initrd_addr=0x8400\0"  \
-   "fdt_name=juno\0" \
+   "fdt_name=board.dtb\0" \
+   "fdt_alt_name=juno\0" \
"fdt_addr=0x8300\0" \
"fdt_high=0x\0" \
"initrd_high=0x\0" \
@@ -207,7 +209,17 @@
 
 /* Copy the kernel and FDT to DRAM memory and boot */
 #define CONFIG_BOOTCOMMAND "afs load ${kernel_name} ${kernel_addr} ; " \
+   "if test $? -eq 1; then "\
+   "  echo Loading ${kernel_alt_name} instead of "\
+   "${kernel_name}; "\
+   "  afs load ${kernel_alt_name} ${kernel_addr};"\
+   "fi ; "\
"afs load  ${fdt_name} ${fdt_addr} ; " \
+   "if test $? -eq 1; then "\
+   "  echo Loading ${fdt_alt_name} instead of "\
+   "${fdt_name}; "\
+   "  afs load ${fdt_alt_name} ${fdt_addr}; "\
+   "fi ; "\
"fdt addr ${fdt_addr}; fdt resize; " \
"if afs load  ${initrd_name} ${initrd_addr} ; "\
"then "\
-- 
2.1.0

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


Re: [U-Boot] [PATCH 05/10] ti: omap3: config: remove 1 from boolean define

2015-09-29 Thread Igor Grinberg
ping

On 09/24/15 12:56, Igor Grinberg wrote:
> Hi Tom,
> 
> On 08/26/15 17:54, Igor Grinberg wrote:
>> CONFIG_TWL4030_POWER is a boolean define variable. It is either defined
>> or not defined and should not have a value assigned to it.
>> Remove the value.
>>
>> Signed-off-by: Igor Grinberg 
> 
> I think this one can also be applied, no?
> 
>> ---
>>  include/configs/ti_omap3_common.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/configs/ti_omap3_common.h 
>> b/include/configs/ti_omap3_common.h
>> index be231a5..e399a87 100644
>> --- a/include/configs/ti_omap3_common.h
>> +++ b/include/configs/ti_omap3_common.h
>> @@ -66,7 +66,7 @@
>>  #define CONFIG_SYS_MONITOR_LEN  (256 << 10)
>>  
>>  /* TWL4030 */
>> -#define CONFIG_TWL4030_POWER1
>> +#define CONFIG_TWL4030_POWER
>>  
>>  /* SPL */
>>  #define CONFIG_SPL_TEXT_BASE0x40200800
>>
> 

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


[U-Boot] [PATCH v2 03/10] vexpress64: increase max gunzip size

2015-09-29 Thread Ryan Harkin
vexpress64 kernels are usually over 8 MBytes in length, so setting the
max uImage length to 64 Mbytes should give us plenty of scope for
expansion.

I mostly chose this length to match other board configs that use
"(64 << 20)".

Signed-off-by: Ryan Harkin 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 53b0f74..c54baf8 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -41,6 +41,8 @@
 #error "Unknown board variant"
 #endif
 
+#define CONFIG_SYS_BOOTM_LEN (64 << 20)  /* Increase max gunzip size */
+
 /* Flat Device Tree Definitions */
 #define CONFIG_OF_LIBFDT
 
-- 
2.1.0

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


Re: [U-Boot] [PATCH 04/10] Kconfig: add CONFIG_CMD_BOOTZ

2015-09-29 Thread Igor Grinberg
ping x2

On 09/24/15 12:57, Igor Grinberg wrote:
> ping.
> 
> On 08/26/15 17:54, Igor Grinberg wrote:
>> Add CONFIG_CMD_BOOTZ to the Kconfig.
>> Since the CONFIG_CMD_BOOTZ cannot live without the CONFIG_CMD_BOOTM,
>> make it select the CONFIG_CMD_BOOTM.
>>
>> Signed-off-by: Igor Grinberg 
>> Cc: Masahiro Yamada 
>> Cc: Simon Glass 
>> ---
>>  common/Kconfig | 6 ++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/common/Kconfig b/common/Kconfig
>> index ecbf6cb..b7791bd 100644
>> --- a/common/Kconfig
>> +++ b/common/Kconfig
>> @@ -165,6 +165,12 @@ config CMD_BOOTM
>>  help
>>Boot an application image from the memory.
>>  
>> +config CMD_BOOTZ
>> +bool "bootz"
>> +select CMD_BOOTM
>> +help
>> +  Boot a Linux kernel zImage from the memory.
>> +
>>  config CMD_GO
>>  bool "go"
>>  default y
>>
> 

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


Re: [U-Boot] [PATCH 04/10] Kconfig: add CONFIG_CMD_BOOTZ

2015-09-29 Thread Tom Rini
On Tue, Sep 29, 2015 at 07:25:02PM +0300, Igor Grinberg wrote:
> ping x2
> 
> On 09/24/15 12:57, Igor Grinberg wrote:
> > ping.
> > 
> > On 08/26/15 17:54, Igor Grinberg wrote:
> >> Add CONFIG_CMD_BOOTZ to the Kconfig.
> >> Since the CONFIG_CMD_BOOTZ cannot live without the CONFIG_CMD_BOOTM,
> >> make it select the CONFIG_CMD_BOOTM.
> >>
> >> Signed-off-by: Igor Grinberg 
> >> Cc: Masahiro Yamada 
> >> Cc: Simon Glass 
> >> ---
> >>  common/Kconfig | 6 ++
> >>  1 file changed, 6 insertions(+)
> >>
> >> diff --git a/common/Kconfig b/common/Kconfig
> >> index ecbf6cb..b7791bd 100644
> >> --- a/common/Kconfig
> >> +++ b/common/Kconfig
> >> @@ -165,6 +165,12 @@ config CMD_BOOTM
> >>help
> >>  Boot an application image from the memory.
> >>  
> >> +config CMD_BOOTZ
> >> +  bool "bootz"
> >> +  select CMD_BOOTM
> >> +  help
> >> +Boot a Linux kernel zImage from the memory.
> >> +
> >>  config CMD_GO
> >>bool "go"
> >>default y

I figured you were tackling this later with moveconfig.py, no?

-- 
Tom


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


Re: [U-Boot] [PATCH v3 5/5] common: Enable fdt_support in SPL build

2015-09-29 Thread Chin Liang See
Hi Simon,

On Wed, 2015-09-23 at 10:39 +, Simon Glass wrote:
> Hi,
> 
> On 22 September 2015 at 21:10, Chin Liang See  wrote:
> >
> > Hi,
> >
> > > From: ma...@denx.de
> > > Sent: Friday, September 11, 2015 8:45 AM
> > > To: Simon Glass
> > > Cc: Chin Liang See; ZY - u-boot; Dinh Nguyen; Dinh Nguyen; ZY - sr; Vikas 
> > > Manocha; Jagannadh Teki; ZY - pavel
> > > Subject: Re: [PATCH v3 5/5] common: Enable fdt_support in SPL build
> > >
> > > On Friday, September 11, 2015 at 02:14:17 AM, Simon Glass wrote:
> > > > Hi,
> > > >
> > > > On 10 September 2015 at 04:49, Marek Vasut  wrote:
> > > > > On Thursday, September 10, 2015 at 07:02:16 AM, Chin Liang See wrote:
> > > > >> Enable more device tree function support such as
> > > > >> fdt_getprop_u32_default_node in SPL.
> > > > >>
> > > > >> Signed-off-by: Chin Liang See 
> > > > >> Cc: Dinh Nguyen 
> > > > >> Cc: Dinh Nguyen 
> > > > >> Cc: Marek Vasut 
> > > > >> Cc: Stefan Roese 
> > > > >> Cc: Vikas Manocha 
> > > > >> Cc: Jagannadh Teki 
> > > > >> Cc: Pavel Machek 
> > > > >
> > > > > +CC Simon, I'm worried this might blow the size of all SPLs , which is
> > > > > not the thing we'd like to see.
> > > > >
> > > > >> ---
> > > > >>
> > > > >>  common/Makefile |4 ++--
> > > > >>  1 files changed, 2 insertions(+), 2 deletions(-)
> > > > >>
> > > > >> diff --git a/common/Makefile b/common/Makefile
> > > > >> index 556fb07..9e059fe 100644
> > > > >> --- a/common/Makefile
> > > > >> +++ b/common/Makefile
> > > > >> @@ -97,7 +97,7 @@ obj-$(CONFIG_CMD_EXT4) += cmd_ext4.o
> > > > >>
> > > > >>  obj-$(CONFIG_CMD_EXT2) += cmd_ext2.o
> > > > >>  obj-$(CONFIG_CMD_FAT) += cmd_fat.o
> > > > >>  obj-$(CONFIG_CMD_FDC) += cmd_fdc.o
> > > > >>
> > > > >> -obj-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o
> > > > >> +obj-$(CONFIG_OF_LIBFDT) += cmd_fdt.o
> > > > >>
> > > > >>  obj-$(CONFIG_CMD_FITUPD) += cmd_fitupd.o
> > > > >>  obj-$(CONFIG_CMD_FLASH) += cmd_flash.o
> > > > >>  ifdef CONFIG_FPGA
> > > > >>
> > > > >> @@ -265,7 +265,7 @@ obj-y += malloc_simple.o
> > > > >>
> > > > >>  endif
> > > > >>  obj-y += image.o
> > > > >>  obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
> > > > >>
> > > > >> -obj-$(CONFIG_OF_LIBFDT) += image-fdt.o
> > > > >> +obj-$(CONFIG_OF_LIBFDT) += image-fdt.o  fdt_support.o
> > > > >>
> > > > >>  obj-$(CONFIG_FIT) += image-fit.o
> > > > >>  obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o
> > > > >>  obj-$(CONFIG_IO_TRACE) += iotrace.o
> > > > >>
> > > > >> --
> > > > >> 1.7.7.4
> > > >
> > > > It might need a bit of work - here's a buildman run:
> > > >
> > > > 02: common: Enable fdt_support in SPL build
> > > >powerpc:  +   P1022DS_36BIT_NAND T1024RDB_SPIFLASH
> > > > P1010RDB-PA_SPIFLASH P1021RDB-PC_36BIT_NAND T2080QDS_SPIFLASH
> > > > P1025RDB_SDCARD P2020RDB-PC_36BIT_SPIFLASH T1042RDB_PI_SPIFLASH
> > > > P1010RDB-PA_36BIT_NAND P1010RDB-PB_SDCARD P2020RDB-PC_SPIFLASH
> > > > P1020MBG-PC_36BIT_SDCARD P1024RDB_SPIFLASH T1042D4RDB_NAND
> > > > T4240RDB_SDCARD P1010RDB-PB_36BIT_NAND P1022DS_36BIT_SDCARD
> > > > T1024QDS_NAND P1021RDB-PC_SPIFLASH T1024RDB_NAND T1023RDB_SDCARD
> > > > P1010RDB-PB_36BIT_SDCARD P1022DS_NAND P1020RDB-PC_36BIT_NAND
> > > > P1020RDB-PC_SDCARD T1042RDB_PI_NAND P1020RDB-PD_SPIFLASH T2080RDB_NAND
> > > > P1022DS_SDCARD P1020RDB-PC_36BIT_SPIFLASH T1042RDB_PI_SDCARD
> > > > T2081QDS_NAND T4160QDS_SDCARD P1010RDB-PB_SPIFLASH T2080QDS_SDCARD
> > > > P1020MBG-PC_SDCARD P1020RDB-PC_SPIFLASH T4240QDS_SDCARD
> > > > P2020RDB-PC_36BIT_SDCARD T1040RDB_SDCARD P1021RDB-PC_SDCARD
> > > > B4860QDS_NAND T2080RDB_SDCARD P1020RDB-PC_36BIT_SDCARD
> > > > T1040D4RDB_SDCARD T1040D4RDB_SPIFLASH P1020RDB-PC_NAND T2080QDS_NAND
> > > > T1023RDB_NAND P1020RDB-PD_NAND T1040D4RDB_NAND P1010RDB-PA_NAND
> > > > T1040RDB_SPIFLASH P2020RDB-PC_SDCARD T2081QDS_SDCARD
> > > > P1010RDB-PA_36BIT_SDCARD P1024RDB_NAND P1024RDB_SDCARD T4240QDS_NAND
> > > > C29XPCIE_NAND B4420QDS_NAND P1021RDB-PC_36BIT_SPIFLASH
> > > > P1025RDB_SPIFLASH T2081QDS_SPIFLASH T1040RDB_NAND P1010RDB-PA_SDCARD
> > > > P1010RDB-PB_NAND T1024QDS_SDCARD T1024QDS_SPIFLASH P1021RDB-PC_NAND
> > > > T1042D4RDB_SPIFLASH P1020UTM-PC_36BIT_SDCARD T4160QDS_NAND
> > > > T2080RDB_SPIFLASH P1022DS_SPIFLASH T1042D4RDB_SDCARD
> > > > P1021RDB-PC_36BIT_SDCARD P1020RDB-PD_SDCARD P1022DS_36BIT_SPIFLASH
> > > > T1024RDB_SDCARD P1020UTM-PC_SDCARD P2020RDB-PC_36BIT_NAND
> > > > P2020RDB-PC_NAND T1023RDB_SPIFLASH P1010RDB-PB_36BIT_SPIFLASH
> > > > P1025RDB_NAND P1010RDB-PA_36BIT_SPIFLASH
> > > >   blackfin: (for 34/35 boards)  all +16.0  rodata +16.0
> > > >x86: (for 9/9 boards)  bss -14.2  rodata +14.2
> > > >aarch64: (for 13/13 boards)  all +17.2  rodata +17.2
> > > > spl/u-boot-spl:all +151.4  spl/u-boot-spl:rodata +151.4
> > > >  avr32: (for 4/4 boards)  all +16.0  rodata +16.0
> > > >   

Re: [U-Boot] [PATCH] net: bootp fix vci string on SPL-Boot

2015-09-29 Thread Joe Hershberger
Hi Hannes,

On Tue, Sep 29, 2015 at 3:19 AM, Hannes Schmelzer
 wrote:
> Hi,
>
> just checked my upstream branch and noticed that this patch is outstanding.
> How about merge?

Do you think this is a critical bug fix? I was planning to wait for
next release since the patch came after the merge window.

> regards,
> Hannes
>
>
>
> On 25.08.2015 18:01, Joe Hershberger wrote:
>>
>> Hi Hannes,
>>
>> On Tue, Aug 25, 2015 at 5:17 AM, Hannes Schmelzer  wrote:
>>>
>>> If CONFIG_CMD_DHCP is enabled, the vci (vendor-class-identifier) string
>>> isn't inserted into the bootp-packet during SPL stage because the
>>>
>>> CONFIG_BOOTP_VCI_STRING
>>> instead
>>> CONFIG_SPL_NET_VCI_STRING
>>>
>>> We fix this with testing for CONFIG_SPL_BUILD and testing for existing
>>> CONFIG_SPL_NET_VCI_STRING.
>>>
>>> Signed-off-by: Hannes Schmelzer 
>>
>> Acked-by: Joe Hershberger 
>>
>>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] nios2: convert altera timer to driver model

2015-09-29 Thread Chin Liang See
Hi Thomas,


On Tue, 2015-09-29 at 07:39 +, tho...@wytron.com.tw wrote:
> Convert altera timer to driver model.
> 
> Signed-off-by: Thomas Chou 
> ---
> v2
>   fix coding style.
> 
>  arch/nios2/cpu/Makefile |   2 +-
>  arch/nios2/cpu/timer.c  |  65 
>  common/board_f.c|   3 +-
>  configs/nios2-generic_defconfig |   2 +
>  drivers/timer/Kconfig   |   7 +++
>  drivers/timer/Makefile  |   1 +
>  drivers/timer/altera_timer.c| 110 
> 
>  include/configs/nios2-generic.h |   6 ---
>  8 files changed, 122 insertions(+), 74 deletions(-)
>  delete mode 100644 arch/nios2/cpu/timer.c
>  create mode 100644 drivers/timer/altera_timer.c
> 

Thanks for the patch.
The patch looks good except it misses the changes for dts.

Thanks
Chin Liang

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


Re: [U-Boot] Pull-request: u-boot-spi/master

2015-09-29 Thread Jagan Teki
On 21 September 2015 at 23:56, Jagan Teki  wrote:
> Hi Michal,
>
> On 19 September 2015 at 06:38, Michal Simek  wrote:
>> On 09/19/2015 02:55 AM, Michal Simek wrote:
>>> On 09/16/2015 09:20 AM, Jagan Teki wrote:
 Hi Michal,

 On 15 September 2015 at 18:58, Simon Glass  wrote:
> Hi Jagan,
>
> On 15 September 2015 at 02:13, Jagan Teki  wrote:
>> Hi Tom,
>>
>> Zynq patches has SPL build dependency with Simon changes [1].
>>
>> Simon, Any plan to send a PR for your changes.
>>
>> [1] 
>> http://git.denx.de/?p=u-boot/u-boot-dm.git;a=shortlog;h=refs/heads/zynq-working
>
> These are for the zynq maintainer I think. They are not assigned to me
> in patchwork.

 Seems like this patch[1] resolves the SPL build issue, any plan on
 pushing this? of-course I will test this and let you know.


 [1] 
 http://git.denx.de/?p=u-boot/u-boot-dm.git;a=commitdiff;h=7916a8cf902177afd20a09527a9cf307622bb6d2
>>>
>>> Simon: Are you going to push it? Or do you want me to collect all of
>>> these zynq/zynqmp patches?
>>
>> Sorry I have read Simon's reaction after. I will try to collect all
>> these zynq patches and will send pull request.
>
> Please send your PR on top of these changes, and let me know for any inputs.

Seems like Michal is busy with something, Shall I go with build fix
(not sure whether it's working SPI-SPL or not)

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


Re: [U-Boot] [PATCH v2 2/2] spi: Add SPI NOR protection mechanism

2015-09-29 Thread Jagan Teki
On 29 September 2015 at 17:37, Fabio Estevam
 wrote:
> Many SPI flashes have protection bits (BP2, BP1 and BP0) in the
> status register that can protect selected regions of the SPI NOR.
>
> Take these bits into account when performing erase operations,
> making sure that the protected areas are skipped.
>
> Introduce the CONFIG_SPI_FLASH_STM_PROTECT option that can be
> selectedby systems that want to protect regions of SPI NOR flash
> using the same programming model as in the ST Micro SPI NOR flashes,
> like for example the M25P32.
>
> Based on the implementation from Brian Norris 
> for the Linux kernel:
> https://patchwork.ozlabs.org/patch/513041/
>
> Tested on a mx6qsabresd:
>
> => sf probe
> SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
> => sf protect on  0x3f 0x1
> => sf erase 0x3f 0x1
> offset 0x3f is protected and cannot be erased
> SF: 65536 bytes @ 0x3f Erased: ERROR
> => sf protect off  0x3f 0x1
> => sf erase 0x3f 0x1
> SF: 65536 bytes @ 0x3f Erased: OK
>
> Signed-off-by: Fabio Estevam 
> ---
> Changes since v1:
> - Add CONFIG_SPI_FLASH_STM_PROTECT in the Kconfig as suggested by
> Stefan Roese
>
>  common/cmd_sf.c   |  30 +++
>  drivers/mtd/spi/Kconfig   |  15 
>  drivers/mtd/spi/sf_internal.h |   6 --
>  drivers/mtd/spi/sf_ops.c  | 188 
> ++
>  include/spi_flash.h   |  25 +-
>  5 files changed, 256 insertions(+), 8 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index ac7f5df..a31243f 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -348,6 +348,28 @@ static int do_spi_flash_erase(int argc, char * const 
> argv[])
> return ret == 0 ? 0 : 1;
>  }
>
> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT

Drop this vendor specific macro on command code (usually command code
deals generic-ness)

> +static int do_spi_protect(int argc, char * const argv[])
> +{
> +   int start, len, ret = 0;
> +
> +   if (argc != 4)
> +   return -1;
> +
> +   start = simple_strtoull(argv[2], NULL, 16);
> +   len = simple_strtoull(argv[3], NULL, 16);

Use proper endptr - see the sample code on same file.

> +
> +   if (strcmp(argv[1], "on") == 0)
> +   ret = stm_lock(flash, start, len);
> +   else if (strcmp(argv[1], "off") == 0)
> +   ret = stm_unlock(flash, start, len);
> +   else
> +   return -1;  /* Unknown parameter */

Again stm_* vendor calls, use spi_flash_protect(flash, start, end,
prot) then in spi_flash.c call functions flash->lock and flash->unlock
like read/write ops.

> +
> +   return ret == 0 ? 0 : 1;
> +}
> +#endif
> +
>  #ifdef CONFIG_CMD_SF_TEST
>  enum {
> STAGE_ERASE,
> @@ -540,6 +562,10 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int 
> argc,
> ret = do_spi_flash_read_write(argc, argv);
> else if (strcmp(cmd, "erase") == 0)
> ret = do_spi_flash_erase(argc, argv);
> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT
> +   else if (strcmp(cmd, "protect") == 0)
> +   ret = do_spi_protect(argc, argv);
> +#endif
>  #ifdef CONFIG_CMD_SF_TEST
> else if (!strcmp(cmd, "test"))
> ret = do_spi_flash_test(argc, argv);
> @@ -579,5 +605,9 @@ U_BOOT_CMD(
> "sf update addr offset|partition len- erase and write `len' bytes 
> from memory\n"
> " at `addr' to flash at 
> `offset'\n"
> " or to start of mtd 
> `partition'\n"
> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT
> +   "sf protect on/off sector len   - protect/unprotect 'len' 
> bytes starting\n"
> +   " at address 'sector'\n"
> +#endif
> SF_TEST_HELP
>  );
> diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
> index 3f7433c..2ee1089 100644
> --- a/drivers/mtd/spi/Kconfig
> +++ b/drivers/mtd/spi/Kconfig
> @@ -101,6 +101,21 @@ config SPI_FLASH_USE_4K_SECTORS
>   Please note that some tools/drivers/filesystems may not work with
>   4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
>
> +config SPI_FLASH_STM_PROTECT
> +   bool "Use STM flash protection mechanism"
> +   depends on SPI_FLASH
> +   help
> + Enable the built-in protection mechanism provided by the
> + BP2, BP1 and BP0 bits from the status register present
> + on ST-Micro flashes such as M25P32. Please refer to the
> + M25P32 datasheet to understand how to program these bits
> + in order to protect a selected region of the SPI NOR flash.
> +
> + This same bit protection programming model applies to SPI
> + NOR flashes from other manufacturers such as:
> + - Micron M25P32
> + - SST SST25V32B
> +
>  

Re: [U-Boot] [PATCH v3 1/5] spi: cadence_qspi: Ensure spi_calibration is run when sclk change

2015-09-29 Thread Chin Liang See
Hi Marek,

On Thu, 2015-09-24 at 09:16 +0200, ma...@denx.de wrote:
> On Wednesday, September 23, 2015 at 05:21:51 AM, Chin Liang See wrote:
> > Hi,
> 
> Hi!
> 
> > On Wed, 2015-09-23 at 11:13 +0800, Chin Liang See wrote:
> > > From: ma...@denx.de
> > > Sent: Thursday, September 10, 2015 7:52 PM
> > > To: Chin Liang See
> > > Cc: ZY - u-boot; Dinh Nguyen; Dinh Nguyen; ZY - sr; Vikas Manocha;
> > > Jagannadh Teki; ZY - pavel Subject: Re: [PATCH v3 1/5] spi:
> > > cadence_qspi: Ensure spi_calibration is run when sclk change
> > > 
> > > On Thursday, September 10, 2015 at 07:01:12 AM, Chin Liang See wrote:
> > > > Ensuring spi_calibration is run when there is a change of sclk
> > > > frequency. This will ensure the qspi flash access works for high
> > > > sclk frequency
> > > > 
> > > > Signed-off-by: Chin Liang See 
> > > > Cc: Dinh Nguyen 
> > > > Cc: Dinh Nguyen 
> > > > Cc: Marek Vasut 
> > > > Cc: Stefan Roese 
> > > > Cc: Vikas Manocha 
> > > > Cc: Jagannadh Teki 
> > > > Cc: Pavel Machek 
> > > > Acked-by: Marek Vasut 
> > > > Reviewed-by: Jagan Teki 
> > > > ---
> > > > Changes for v2
> > > > - remove frequency set before calibration
> > > > - introducing previous_hz to store requested frequency
> > > > - prevent calibration run when request same frequency
> > > > ---
> > > > 
> > > >  drivers/spi/cadence_qspi.c |   20 
> > > >  drivers/spi/cadence_qspi.h |1 +
> > > >  2 files changed, 13 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
> > > > index 34a0f46..0e7450c 100644
> > > > --- a/drivers/spi/cadence_qspi.c
> > > > +++ b/drivers/spi/cadence_qspi.c
> > > > @@ -37,15 +37,18 @@ static int cadence_spi_write_speed(struct udevice
> > > > *bus, uint hz) }
> > > > 
> > > >  /* Calibration sequence to determine the read data capture delay
> > > >  register
> > > > 
> > > > */ -static int spi_calibration(struct udevice *bus)
> > > > +static int spi_calibration(struct udevice *bus, uint hz)
> > > > 
> > > >  {
> > > > 
> > > > -   struct cadence_spi_platdata *plat = bus->platdata;
> > > > 
> > > > struct cadence_spi_priv *priv = dev_get_priv(bus);
> > > > void *base = priv->regbase;
> > > > u8 opcode_rdid = 0x9F;
> > > > unsigned int idcode = 0, temp = 0;
> > > > int err = 0, i, range_lo = -1, range_hi = -1;
> > > > 
> > > > +   /* if calibrated frequency same as reqeusted, skip it */
> > > > +   if (priv->qspi_calibrated_hz == hz)
> > > > +   return 0;
> > > 
> > > Do you need this check ? I think you're doing the same check in
> > > cadence_spi_set_speed() down below here, so this is redundant.
> > 
> > Oh this is checked against calibrated value. It works together with the
> > check of previous_hz. This is to cater the incident where the calibrated
> > frequency = max frequency when requested frequency exceed the max
> > frequency. Some examples as below
> > 
> > Request 100MHz, Max 50MHz,  run, calibrated 50MHz, previous 100MHz
> > Request 100MHz, Max 50MHz, skip, calibrated 50MHz, previous 100MHz
> > Request  90MHz, Max 50MHz, skip, calibrated 50MHz, previous  90MHz
> > 
> > The check here will skip calibration for third incident.
> > Hope that explains.
> 
> Ah, I see, that makes sense now, thanks!

Cool

> 
> Wouldn't it thus make more sense to place this check into the
> cadence_spi_set_speed() function instead , so that the spi_calibrate()
> function only really does calibration , no matter what ?

Sound right to me :)
Let me update this into v4.

Thanks
Chin Liang


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


Re: [U-Boot] [PATCH] nios2: add clear and set bits macros

2015-09-29 Thread Chin Liang See
Hi Thomas,

On Thu, 2015-09-24 at 14:47 +0800, tho...@wytron.com.tw wrote:
> These macros can be used to clear and set multiple bits
> in a register using a single call.
> 
> Signed-off-by: Thomas Chou 

Thanks for the patch.
Sorry for the late comments as noticed all my mail for last few days was
stuck in mail server.

> ---
>  arch/nios2/include/asm/io.h | 57 
> +
>  1 file changed, 57 insertions(+)
> 
> diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
> index b4bd20f..123e885 100644
> --- a/arch/nios2/include/asm/io.h
> +++ b/arch/nios2/include/asm/io.h
> @@ -116,4 +116,61 @@ static inline void outsl (unsigned long port, const void 
> *src, unsigned long cou
>   while (count--) outl (*p++, port);
>  }
>  
> +/*
> + * Clear and set bits in one shot. These macros can be used to clear and
> + * set multiple bits in a register using a single call. These macros can
> + * also be used to set a multiple-bit bit pattern using a mask, by
> + * specifying the mask in the 'clear' parameter and the new bit pattern
> + * in the 'set' parameter.
> + */
> +
> +#define out_arch(type,endian,a,v)__raw_write##type(cpu_to_##endian(v),a)
> +#define in_arch(type,endian,a)   
> endian##_to_cpu(__raw_read##type(a))
> +
> +#define out_le64(a,v)out_arch(q,le64,a,v)

The 64bit support (q) is not yet available. This will break if someone
using this.


> +#define out_le32(a,v)out_arch(l,le32,a,v)
> +#define out_le16(a,v)out_arch(w,le16,a,v)
> +
> +#define in_le64(a)   in_arch(q,le64,a)

same as above

Thanks
Chin Liang

> +#define in_le32(a)   in_arch(l,le32,a)
> +#define in_le16(a)   in_arch(w,le16,a)
> +
> +#define out_be32(a,v)out_arch(l,be32,a,v)
> +#define out_be16(a,v)out_arch(w,be16,a,v)
> +
> +#define in_be32(a)   in_arch(l,be32,a)
> +#define in_be16(a)   in_arch(w,be16,a)
> +
> +#define out_8(a,v)   __raw_writeb(v,a)
> +#define in_8(a)  __raw_readb(a)
> +
> +#define clrbits(type, addr, clear) \
> + out_##type((addr), in_##type(addr) & ~(clear))
> +
> +#define setbits(type, addr, set) \
> + out_##type((addr), in_##type(addr) | (set))
> +
> +#define clrsetbits(type, addr, clear, set) \
> + out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
> +
> +#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
> +#define setbits_be32(addr, set) setbits(be32, addr, set)
> +#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
> +
> +#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
> +#define setbits_le32(addr, set) setbits(le32, addr, set)
> +#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
> +
> +#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
> +#define setbits_be16(addr, set) setbits(be16, addr, set)
> +#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
> +
> +#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
> +#define setbits_le16(addr, set) setbits(le16, addr, set)
> +#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
> +
> +#define clrbits_8(addr, clear) clrbits(8, addr, clear)
> +#define setbits_8(addr, set) setbits(8, addr, set)
> +#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
> +
>  #endif /* __ASM_NIOS2_IO_H_ */


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


[U-Boot] [PATCH v3] dm: core: Enable optional use of fdt_translate_address()

2015-09-29 Thread Stefan Roese
The current "simple" address translation simple_bus_translate() is not
working on some platforms (e.g. MVEBU). As here more complex "ranges"
properties are used in many nodes (multiple tuples etc). This patch
enables the optional use of the common fdt_translate_address() function
which handles this translation correctly.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
Cc: Marek Vasut 
Cc: Masahiro Yamada 
Cc: Stephen Warren 
Cc: Lukasz Majewski 
---
v3:
- Rebased on current U-Boot version
- Added Stephen and Lukasz to Cc

v2:
- Rework code a bit as suggested by Simon. Also added some comments
  to make the use of the code paths more clear.

 drivers/core/Kconfig  | 30 ++
 drivers/core/device.c | 20 
 2 files changed, 50 insertions(+)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 41f4e69..15681df 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -120,4 +120,34 @@ config SPL_SIMPLE_BUS
  Supports the 'simple-bus' driver, which is used on some systems
  in SPL.
 
+config OF_TRANSLATE
+   bool "Translate addresses using fdt_translate_address"
+   depends on DM && OF_CONTROL
+   default y
+   help
+ If this option is enabled, the reg property will be translated
+ using the fdt_translate_address() function. This is necessary
+ on some platforms (e.g. MVEBU) using complex "ranges"
+ properties in many nodes. As this translation is not handled
+ correctly in the default simple_bus_translate() function.
+
+ If this option is not enabled, simple_bus_translate() will be
+ used for the address translation. This function is faster and
+ smaller in size than fdt_translate_address().
+
+config SPL_OF_TRANSLATE
+   bool "Translate addresses using fdt_translate_address"
+   depends on SPL_DM && SPL_OF_CONTROL
+   default n
+   help
+ If this option is enabled, the reg property will be translated
+ using the fdt_translate_address() function. This is necessary
+ on some platforms (e.g. MVEBU) using complex "ranges"
+ properties in many nodes. As this translation is not handled
+ correctly in the default simple_bus_translate() function.
+
+ If this option is not enabled, simple_bus_translate() will be
+ used for the address translation. This function is faster and
+ smaller in size than fdt_translate_address().
+
 endmenu
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 0bc04d4..92fb854 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -581,6 +582,25 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
fdt_addr_t addr;
 
+   if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
+   const fdt32_t *reg;
+
+   reg = fdt_getprop(gd->fdt_blob, dev->of_offset, "reg", NULL);
+   if (!reg)
+   return FDT_ADDR_T_NONE;
+
+   /*
+* Use the full-fledged translate function for complex
+* bus setups.
+*/
+   return fdt_translate_address((void *)gd->fdt_blob,
+dev->of_offset, reg);
+   }
+
+   /*
+* Use the "simple" translate function for less complex
+* bus setups.
+*/
addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
dev->parent->of_offset,
dev->of_offset, "reg",
-- 
2.5.3

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


Re: [U-Boot] [PATCH 2/2] nios2: convert altera sysid to driver model

2015-09-29 Thread Chin Liang See
Hi Thomas,

On Tue, 2015-09-29 at 15:23 +0800, tho...@wytron.com.tw wrote:
> Convert altera sysid to driver model with misc uclass.
> 
> Signed-off-by: Thomas Chou 

Thanks for the patch.

> ---
>  arch/nios2/cpu/Makefile|  2 +-
>  arch/nios2/cpu/cpu.c   | 15 +
>  arch/nios2/cpu/sysid.c | 46 --
>  arch/nios2/dts/3c120_devboard.dts  |  8 +++
>  board/altera/nios2-generic/nios2-generic.c |  6 +-
>  configs/nios2-generic_defconfig|  2 +
>  drivers/misc/Kconfig   |  7 +++
>  drivers/misc/Makefile  |  1 +
>  drivers/misc/altera_sysid.c| 99 
> ++
>  include/configs/nios2-generic.h|  3 +-
>  10 files changed, 126 insertions(+), 63 deletions(-)
>  delete mode 100644 arch/nios2/cpu/sysid.c
>  create mode 100644 drivers/misc/altera_sysid.c
> 
> diff --git a/arch/nios2/cpu/Makefile b/arch/nios2/cpu/Makefile
> index 3fe7847..185ca3c 100644
> --- a/arch/nios2/cpu/Makefile
> +++ b/arch/nios2/cpu/Makefile
> @@ -7,5 +7,5 @@
>  
>  extra-y  = start.o
>  obj-y= exceptions.o
> -obj-y+= cpu.o interrupts.o sysid.o traps.o
> +obj-y+= cpu.o interrupts.o traps.o
>  obj-y+= fdt.o
> diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
> index 88984e2..7b1717c 100644
> --- a/arch/nios2/cpu/cpu.c
> +++ b/arch/nios2/cpu/cpu.c
> @@ -13,22 +13,11 @@
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> -#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
> -extern void display_sysid (void);
> -#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
> -
> -#ifdef CONFIG_DISPLAY_CPUINFO
>  int print_cpuinfo(void)
>  {
> - printf ("CPU   : Nios-II\n");
> -#if !defined(CONFIG_SYS_NIOS_SYSID_BASE)
> - printf ("SYSID : \n");
> -#else
> - display_sysid ();
> -#endif
> - return (0);
> + printf("CPU:   Nios-II\n");
> + return 0;
>  }
> -#endif /* CONFIG_DISPLAY_CPUINFO */
>  
>  int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
> diff --git a/arch/nios2/cpu/sysid.c b/arch/nios2/cpu/sysid.c
> deleted file mode 100644
> index 50819b2..000
> --- a/arch/nios2/cpu/sysid.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/*
> - * (C) Copyright 2004, Psyent Corporation 
> - * Scott McNutt 
> - *
> - * SPDX-License-Identifier:  GPL-2.0+
> - */
> -
> -#include 
> -
> -#if defined (CONFIG_SYS_NIOS_SYSID_BASE)
> -
> -#include 
> -#include 
> -#include 
> -
> -typedef volatile struct {
> - unsignedid; /* The system build id */
> - unsignedtimestamp;  /* Timestamp */
> -} nios_sysid_t;
> -
> -void display_sysid (void)
> -{
> - nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE;
> - struct tm t;
> - char asc[32];
> - time_t stamp;
> -
> - stamp = readl (>timestamp);
> - localtime_r (, );
> - asctime_r (, asc);
> - printf ("SYSID : %08lx, %s", readl (>id), asc);
> -
> -}
> -
> -int do_sysid (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> -{
> - display_sysid ();
> - return (0);
> -}
> -
> -U_BOOT_CMD(
> - sysid,  1,  1,  do_sysid,
> - "display Nios-II system id",
> - ""
> -);
> -#endif /* CONFIG_SYS_NIOS_SYSID_BASE */
> diff --git a/arch/nios2/dts/3c120_devboard.dts 
> b/arch/nios2/dts/3c120_devboard.dts
> index 2e2956f..2eb339c 100644
> --- a/arch/nios2/dts/3c120_devboard.dts
> +++ b/arch/nios2/dts/3c120_devboard.dts
> @@ -72,6 +72,7 @@
>   <0x4cc0 0x08004cc0 0x0010>,
>   <0x4ce0 0x08004ce0 0x0010>,
>   <0x4d00 0x08004d00 0x0010>,
> + <0x4d40 0x08004d40 0x0008>,
>   <0x4d50 0x08004d50 0x0008>,
>   <0x8000 0x08008000 0x0020>,
>   <0x0040 0x0840 0x0020>;
> @@ -92,6 +93,13 @@
>   clock-frequency = < 12500 >;
>   };
>  
> + sysid: sysid@0x4d40 {
> + compatible = "altr,sysid-1.0";
> + reg = <0x4d40 0x0008>;
> + id = <0>;
> + timestamp = <1440939556>;

I believe we won't need the id and timestamp as these will be read from
sysid register.

Thanks
Chin Liang

p/s: Oh ya, let me know if you need my help to send new revision of
those patches commented by me. I can share the load :)

> + };
> +
>   jtag_uart: serial@0x4d50 {
>   compatible = "altr,juart-1.0";
>   reg = <0x4d50 0x0008>;
> diff --git a/board/altera/nios2-generic/nios2-generic.c 
> b/board/altera/nios2-generic/nios2-generic.c
> index 61d32c7..e08b8f7 

Re: [U-Boot] [PATCH v3] nios2 : convert altera_pio to driver model

2015-09-29 Thread Chin Liang See
Hi Thomas,

On Sat, 2015-09-26 at 17:07 +0800, tho...@wytron.com.tw wrote:
> Convert altera_pio to driver model.
> 
> Signed-off-by: Thomas Chou 
> ---
> v2
>   fix ranges of pio in dts
>   fix coding style as Marek suggested.
> 
> v3
>   change gpio_count device tree binding.
> 
>  arch/nios2/dts/3c120_devboard.dts  |  41 
>  arch/nios2/include/asm/gpio.h  |  80 +---
>  board/altera/nios2-generic/nios2-generic.c |   7 -
>  configs/nios2-generic_defconfig|   2 +
>  drivers/gpio/Kconfig   |   7 +
>  drivers/gpio/altera_pio.c  | 316 
> +++--
>  include/configs/nios2-generic.h|  20 --
>  7 files changed, 127 insertions(+), 346 deletions(-)
> 

Acked-by: Chin Liang See 

Thanks
Chin Liang

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


Re: [U-Boot] [PATCH V2 1/3] fdtdec: fix parsing 'reg' property with zero value in '#size-cells'

2015-09-29 Thread Minkyu Kang
On 29/09/15 13:47, Simon Glass wrote:
> On 28 September 2015 at 06:17, Przemyslaw Marczak  
> wrote:
>> After rework of lib/fdtdec.c by:
>>
>> commit: 02464e3 fdt: add new fdt address parsing functions
>>
>> the function fdtdec_get_addr() doesn't work as previous,
>> because the implementation assumes that properties '#address-cells'
>> and '#size-cells' are equal to 1, which can be not true sometimes.
>>
>> The new API introduced fdtdec_get_addr_size_auto_parent() for the 'reg'
>> property parsing, but the implementation assumes, that #size-cells
>> can't be less than 1.
>>
>> This causes that the following children's 'reg' property can't be reached:
>>
>> parent@0x100 {
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>>  children@0x100 {
>>  reg = < 0x100 >;
>>  };
>> };
>>
>> Change the condition value from '1' to '0', which allows parsing property
>> with at least zero #size-cells, fixes the issue.
>>
>> Now, fdtdec_get_addr_size_auto_parent() works properly.
>>
>> Signed-off-by: Przemyslaw Marczak 
>> Acked-by: Stephen Warren 
>> ---
>> Changes V2:
>> - cleanup commit message
>> - add acked-by
>> ---
>>  lib/fdtdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> I'll pick this series up if no one else is planning to.
> 
> Tested on snow
> Tested-by: Simon Glass 
> 
> Acked-by: Simon Glass 
> 

Acked-by: Minkyu Kang 

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


Re: [U-Boot] [PATCH 1/6] dm: Rename dev_get_parentdata() to dev_get_parent_priv()

2015-09-29 Thread Joe Hershberger
Hi Simon,

On Tue, Sep 29, 2015 at 12:32 AM, Simon Glass  wrote:
> The current name is inconsistent with other driver model data access
> functions. Rename it and fix up all users.
>
> Signed-off-by: Simon Glass 

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


Re: [U-Boot] [PATCH 05/10] ti: omap3: config: remove 1 from boolean define

2015-09-29 Thread Tom Rini
On Tue, Sep 29, 2015 at 07:25:27PM +0300, Igor Grinberg wrote:

> ping
> 
> On 09/24/15 12:56, Igor Grinberg wrote:
> > Hi Tom,
> > 
> > On 08/26/15 17:54, Igor Grinberg wrote:
> >> CONFIG_TWL4030_POWER is a boolean define variable. It is either defined
> >> or not defined and should not have a value assigned to it.
> >> Remove the value.
> >>
> >> Signed-off-by: Igor Grinberg 
> > 
> > I think this one can also be applied, no?
> > 
> >> ---
> >>  include/configs/ti_omap3_common.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/include/configs/ti_omap3_common.h 
> >> b/include/configs/ti_omap3_common.h
> >> index be231a5..e399a87 100644
> >> --- a/include/configs/ti_omap3_common.h
> >> +++ b/include/configs/ti_omap3_common.h
> >> @@ -66,7 +66,7 @@
> >>  #define CONFIG_SYS_MONITOR_LEN(256 << 10)
> >>  
> >>  /* TWL4030 */
> >> -#define CONFIG_TWL4030_POWER  1
> >> +#define CONFIG_TWL4030_POWER
> >>  
> >>  /* SPL */
> >>  #define CONFIG_SPL_TEXT_BASE  0x40200800

Reviewed-by: Tom Rini 

And I figured you just re-post this as part of v2 as it's trivially
correct but also a tiny thing in a bigger series.
-- 
Tom


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