Re: [U-Boot] [U-Boot, 3/3] mmc: sd_sdhi: Enable clock using clock framework

2017-08-16 Thread Jaehoon Chung
On 07/22/2017 06:22 AM, Marek Vasut wrote:
> Since we now have clock driver for the RCar Gen3 , add support for
> enabling the clock into the SH SDHI driver to prevent hacks in the
> board files.
> 
> Signed-off-by: Marek Vasut 
> Cc: Nobuhiro Iwamatsu 
> Cc: Jaehoon Chung 
> Reviewed-by: Nobuhiro Iwamatsu 

Applied to u-boot-mmc. Sorry for late!

Best Regards,
Jaehoon Chung


> ---
>  drivers/mmc/sh_sdhi.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c
> index 3c5616e507..eef061abb2 100644
> --- a/drivers/mmc/sh_sdhi.c
> +++ b/drivers/mmc/sh_sdhi.c
> @@ -20,6 +20,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define DRIVER_NAME "sh-sdhi"
>  
> @@ -824,8 +825,10 @@ static int sh_sdhi_dm_probe(struct udevice *dev)
>   struct sh_sdhi_plat *plat = dev_get_platdata(dev);
>   struct sh_sdhi_host *host = dev_get_priv(dev);
>   struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
> + struct clk sh_sdhi_clk;
>   const u32 quirks = dev_get_driver_data(dev);
>   fdt_addr_t base;
> + int ret;
>  
>   base = devfdt_get_addr(dev);
>   if (base == FDT_ADDR_T_NONE)
> @@ -835,6 +838,18 @@ static int sh_sdhi_dm_probe(struct udevice *dev)
>   if (!host->addr)
>   return -ENOMEM;
>  
> + ret = clk_get_by_index(dev, 0, _sdhi_clk);
> + if (ret) {
> + debug("failed to get clock, ret=%d\n", ret);
> + return ret;
> + }
> +
> + ret = clk_enable(_sdhi_clk);
> + if (ret) {
> + debug("failed to enable clock, ret=%d\n", ret);
> + return ret;
> + }
> +
>   host->quirks = quirks;
>  
>   if (host->quirks & SH_SDHI_QUIRK_64BIT_BUF)
> 

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


Re: [U-Boot] [U-Boot,2/3] mmc: sh_sdhi: Fix the ACMD handling

2017-08-16 Thread Jaehoon Chung
On 07/22/2017 06:22 AM, Marek Vasut wrote:
> The command handling in this driver is awful, esp. because the driver
> depends on command numbers to determine whether this is APPCMD or not.
> Also, handling of command RSP response types is totally wrong.
> 
> This patch at least plucks out some of the custom command encoding and
> fixes the APPCMD handling. The RSP handling still needs work, yet that
> might not be needed as it turns out the uniphier-sd.c driver is in much
> better shape and supports the same IP, so we might be able to just drop
> this driver in favor of the uniphier one.
> 
> Signed-off-by: Marek Vasut 
> Cc: Hiroyuki Yokoyama 
> Cc: Nobuhiro Iwamatsu 
> Cc: Jaehoon Chung 
> Reviewed-by: Nobuhiro Iwamatsu 

Applied to u-boot-mmc. Sorry for late!

Best Regards,
Jaehoon Chung


> ---
>  arch/arm/mach-rmobile/include/mach/sh_sdhi.h |   5 --
>  drivers/mmc/sh_sdhi.c| 103 
> ++-
>  2 files changed, 55 insertions(+), 53 deletions(-)
> 
> diff --git a/arch/arm/mach-rmobile/include/mach/sh_sdhi.h 
> b/arch/arm/mach-rmobile/include/mach/sh_sdhi.h
> index 1fb0648b12..00a135faa1 100644
> --- a/arch/arm/mach-rmobile/include/mach/sh_sdhi.h
> +++ b/arch/arm/mach-rmobile/include/mach/sh_sdhi.h
> @@ -49,11 +49,6 @@
>  
>  /* SDHI CMD VALUE */
>  #define CMD_MASK 0x
> -#define SDHI_APP 0x0040
> -#define SDHI_MMC_SEND_OP_COND0x0701
> -#define SDHI_SD_APP_SEND_SCR 0x0073
> -#define SDHI_SD_SWITCH   0x1C06
> -#define SDHI_MMC_SEND_EXT_CSD0x1C08
>  
>  /* SDHI_PORTSEL */
>  #define USE_1PORT(1 << 8) /* 1 port */
> diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c
> index fd710399b6..3c5616e507 100644
> --- a/drivers/mmc/sh_sdhi.c
> +++ b/drivers/mmc/sh_sdhi.c
> @@ -31,6 +31,7 @@ struct sh_sdhi_host {
>   unsigned char wait_int;
>   unsigned char sd_error;
>   unsigned char detect_waiting;
> + unsigned char app_cmd;
>  };
>  
>  static inline void sh_sdhi_writeq(struct sh_sdhi_host *host, int reg, u64 
> val)
> @@ -475,65 +476,64 @@ static void sh_sdhi_get_response(struct sh_sdhi_host 
> *host, struct mmc_cmd *cmd)
>  static unsigned short sh_sdhi_set_cmd(struct sh_sdhi_host *host,
>   struct mmc_data *data, unsigned short opc)
>  {
> - switch (opc) {
> - case SD_CMD_APP_SEND_OP_COND:
> - case SD_CMD_APP_SEND_SCR:
> - opc |= SDHI_APP;
> - break;
> - case SD_CMD_APP_SET_BUS_WIDTH:
> -  /* SD_APP_SET_BUS_WIDTH*/
> + if (host->app_cmd) {
>   if (!data)
> - opc |= SDHI_APP;
> - else /* SD_SWITCH */
> - opc = SDHI_SD_SWITCH;
> - break;
> - case MMC_CMD_SEND_OP_COND:
> - opc = SDHI_MMC_SEND_OP_COND;
> - break;
> + host->app_cmd = 0;
> + return opc | BIT(6);
> + }
> +
> + switch (opc) {
> + case MMC_CMD_SWITCH:
> + return opc | (data ? 0x1c00 : 0x40);
>   case MMC_CMD_SEND_EXT_CSD:
> - if (data)
> - opc = SDHI_MMC_SEND_EXT_CSD;
> - break;
> + return opc | (data ? 0x1c00 : 0);
> + case MMC_CMD_SEND_OP_COND:
> + return opc | 0x0700;
> + case MMC_CMD_APP_CMD:
> + host->app_cmd = 1;
>   default:
> - break;
> + return opc;
>   }
> - return opc;
>  }
>  
>  static unsigned short sh_sdhi_data_trans(struct sh_sdhi_host *host,
>   struct mmc_data *data, unsigned short opc)
>  {
> - unsigned short ret;
> -
> - switch (opc) {
> - case MMC_CMD_READ_MULTIPLE_BLOCK:
> - ret = sh_sdhi_multi_read(host, data);
> - break;
> - case MMC_CMD_WRITE_MULTIPLE_BLOCK:
> - ret = sh_sdhi_multi_write(host, data);
> - break;
> - case MMC_CMD_WRITE_SINGLE_BLOCK:
> - ret = sh_sdhi_single_write(host, data);
> - break;
> - case MMC_CMD_READ_SINGLE_BLOCK:
> - case SDHI_SD_APP_SEND_SCR:
> - case SDHI_SD_SWITCH: /* SD_SWITCH */
> - case SDHI_MMC_SEND_EXT_CSD:
> - ret = sh_sdhi_single_read(host, data);
> - break;
> - default:
> - printf(DRIVER_NAME": SD: NOT SUPPORT CMD = d'%04d\n", opc);
> - ret = -EINVAL;
> - break;
> + if (host->app_cmd) {
> + host->app_cmd = 0;
> + switch (opc) {
> + case SD_CMD_APP_SEND_SCR:
> + case SD_CMD_APP_SD_STATUS:
> + return sh_sdhi_single_read(host, data);
> + default:
> + printf(DRIVER_NAME": SD: NOT SUPPORT APP CMD = 
> d'%04d\n",
> +   

Re: [U-Boot] [U-Boot, 1/3] mmc: sh_sdhi: Add DM and DT probing support

2017-08-16 Thread Jaehoon Chung
On 07/22/2017 06:22 AM, Marek Vasut wrote:
> Add MMC DM and DT probing support into the SH SDHI driver.
> This patch abstracts out the common bits of the send command
> and set ios functions, so they can be used both by DM and non
> DM setups and adds the DM probe support.
> 
> Signed-off-by: Marek Vasut 
> Cc: Hiroyuki Yokoyama 
> Cc: Nobuhiro Iwamatsu 
> Cc: Jaehoon Chung 
> Reviewed-by: Nobuhiro Iwamatsu 

Applied to u-boot-mmc. Sorry for late!

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/sh_sdhi.c | 165 
> --
>  1 file changed, 145 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c
> index d181b63905..fd710399b6 100644
> --- a/drivers/mmc/sh_sdhi.c
> +++ b/drivers/mmc/sh_sdhi.c
> @@ -13,15 +13,18 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
> -#include 
> +#include 
> +#include 
> +#include 
>  #include 
>  #include 
>  
>  #define DRIVER_NAME "sh-sdhi"
>  
>  struct sh_sdhi_host {
> - unsigned long addr;
> + void __iomem *addr;
>   int ch;
>   int bus_shift;
>   unsigned long quirks;
> @@ -50,11 +53,6 @@ static inline u16 sh_sdhi_readw(struct sh_sdhi_host *host, 
> int reg)
>   return readw(host->addr + (reg << host->bus_shift));
>  }
>  
> -static void *mmc_priv(struct mmc *mmc)
> -{
> - return (void *)mmc->priv;
> -}
> -
>  static void sh_sdhi_detect(struct sh_sdhi_host *host)
>  {
>   sh_sdhi_writew(host, SDHI_OPTION,
> @@ -634,23 +632,17 @@ static int sh_sdhi_start_cmd(struct sh_sdhi_host *host,
>   return ret;
>  }
>  
> -static int sh_sdhi_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
> - struct mmc_data *data)
> +static int sh_sdhi_send_cmd_common(struct sh_sdhi_host *host,
> +struct mmc_cmd *cmd, struct mmc_data *data)
>  {
> - struct sh_sdhi_host *host = mmc_priv(mmc);
> - int ret;
> -
>   host->sd_error = 0;
>  
> - ret = sh_sdhi_start_cmd(host, data, cmd);
> -
> - return ret;
> + return sh_sdhi_start_cmd(host, data, cmd);
>  }
>  
> -static int sh_sdhi_set_ios(struct mmc *mmc)
> +static int sh_sdhi_set_ios_common(struct sh_sdhi_host *host, struct mmc *mmc)
>  {
>   int ret;
> - struct sh_sdhi_host *host = mmc_priv(mmc);
>  
>   ret = sh_sdhi_clock_control(host, mmc->clock);
>   if (ret)
> @@ -674,9 +666,8 @@ static int sh_sdhi_set_ios(struct mmc *mmc)
>   return 0;
>  }
>  
> -static int sh_sdhi_initialize(struct mmc *mmc)
> +static int sh_sdhi_initialize_common(struct sh_sdhi_host *host)
>  {
> - struct sh_sdhi_host *host = mmc_priv(mmc);
>   int ret = sh_sdhi_sync_reset(host);
>  
>   sh_sdhi_writew(host, SDHI_PORTSEL, USE_1PORT);
> @@ -692,6 +683,34 @@ static int sh_sdhi_initialize(struct mmc *mmc)
>   return ret;
>  }
>  
> +#ifndef CONFIG_DM_MMC
> +static void *mmc_priv(struct mmc *mmc)
> +{
> + return (void *)mmc->priv;
> +}
> +
> +static int sh_sdhi_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
> + struct mmc_data *data)
> +{
> + struct sh_sdhi_host *host = mmc_priv(mmc);
> +
> + return sh_sdhi_send_cmd_common(host, cmd, data);
> +}
> +
> +static int sh_sdhi_set_ios(struct mmc *mmc)
> +{
> + struct sh_sdhi_host *host = mmc_priv(mmc);
> +
> + return sh_sdhi_set_ios_common(host, mmc);
> +}
> +
> +static int sh_sdhi_initialize(struct mmc *mmc)
> +{
> + struct sh_sdhi_host *host = mmc_priv(mmc);
> +
> + return sh_sdhi_initialize_common(host);
> +}
> +
>  static const struct mmc_ops sh_sdhi_ops = {
>   .send_cmd   = sh_sdhi_send_cmd,
>   .set_ios= sh_sdhi_set_ios,
> @@ -743,7 +762,7 @@ int sh_sdhi_init(unsigned long addr, int ch, unsigned 
> long quirks)
>   }
>  
>   host->ch = ch;
> - host->addr = addr;
> + host->addr = (void __iomem *)addr;
>   host->quirks = quirks;
>  
>   if (host->quirks & SH_SDHI_QUIRK_64BIT_BUF)
> @@ -757,3 +776,109 @@ error:
>   free(host);
>   return ret;
>  }
> +
> +#else
> +
> +struct sh_sdhi_plat {
> + struct mmc_config cfg;
> + struct mmc mmc;
> +};
> +
> +int sh_sdhi_dm_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
> + struct mmc_data *data)
> +{
> + struct sh_sdhi_host *host = dev_get_priv(dev);
> +
> + return sh_sdhi_send_cmd_common(host, cmd, data);
> +}
> +
> +int sh_sdhi_dm_set_ios(struct udevice *dev)
> +{
> + struct sh_sdhi_host *host = dev_get_priv(dev);
> + struct mmc *mmc = mmc_get_mmc_dev(dev);
> +
> + return sh_sdhi_set_ios_common(host, mmc);
> +}
> +
> +static const struct dm_mmc_ops sh_sdhi_dm_ops = {
> + .send_cmd   = sh_sdhi_dm_send_cmd,
> + .set_ios= sh_sdhi_dm_set_ios,
> +};
> +
> +static int sh_sdhi_dm_bind(struct udevice *dev)
> +{
> + struct 

Re: [U-Boot] mmc: uniphier-sd: Fix long response processing

2017-08-16 Thread Jaehoon Chung
On 07/22/2017 06:11 AM, Marek Vasut wrote:
> The long response entry 0..3 LSByte comes from the next response
> register MSByte, not from the next response register LSByte. Fix
> this to make the driver report correct values in response 136 .
> 
> Signed-off-by: Marek Vasut 
> Cc: Masahiro Yamada 
> Cc: Jaehoon Chung 
> Acked-by: Masahiro Yamada 

Applied to u-boot-mmc. Sorry for late!

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/uniphier-sd.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
> index 3c462bd583..e272b14153 100644
> --- a/drivers/mmc/uniphier-sd.c
> +++ b/drivers/mmc/uniphier-sd.c
> @@ -470,13 +470,13 @@ static int uniphier_sd_send_cmd(struct udevice *dev, 
> struct mmc_cmd *cmd,
>   u32 rsp_71_40 = readl(priv->regbase + UNIPHIER_SD_RSP32);
>   u32 rsp_39_8 = readl(priv->regbase + UNIPHIER_SD_RSP10);
>  
> - cmd->response[0] = (rsp_127_104 & 0xff) << 8 |
> - (rsp_103_72 & 0xff);
> - cmd->response[1] = (rsp_103_72  & 0xff) << 8 |
> - (rsp_71_40 & 0xff);
> - cmd->response[2] = (rsp_71_40   & 0xff) << 8 |
> - (rsp_39_8 & 0xff);
> - cmd->response[3] = (rsp_39_8& 0xff) << 8;
> + cmd->response[0] = ((rsp_127_104 & 0x00ff) << 8) |
> +((rsp_103_72  & 0xff00) >> 24);
> + cmd->response[1] = ((rsp_103_72  & 0x00ff) << 8) |
> +((rsp_71_40   & 0xff00) >> 24);
> + cmd->response[2] = ((rsp_71_40   & 0x00ff) << 8) |
> +((rsp_39_8& 0xff00) >> 24);
> + cmd->response[3] = (rsp_39_8 & 0xff)   << 8;
>   } else {
>   /* bit 39-8 */
>   cmd->response[0] = readl(priv->regbase + UNIPHIER_SD_RSP10);
> 

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


Re: [U-Boot] [PATCH] ARM: sun8i: a83t: Add device tree for Sinovoip Bananapi BPI-M3

2017-08-16 Thread icenowy

在 2017-08-17 11:40,Chen-Yu Tsai 写道:

The BPI-M3 is an Allwinner A83T based SBC in the Bananapi/Bpi family.
It is roughly the same form factor as the BPI-M1+, with roughly the
same peripherals and connectors:

  - 2GB LPDDR3 DRAM
  - 8GB eMMC
  - Micro-SD card slot
  - HDMI output
  - Headset (stereo + mic) jack
  - Onboard mic
  - Gigabit Ethernet with RTL8211E transceiver
  - Ampak AP6212 WiFi + BT
  - USB OTG connector
  - USB-to-SATA bridge connected through a USB 2.0 hub
  - Consumer IR receiver
  - MIPI DSI LCD panel connector
  - Camera interface (parallel and MIPI CSI) connector
  - 3 LEDs (Red, Green, Blue), of which 2 are controllable (GB)
  - Raspberry Pi 2 compatible GPIO header

Signed-off-by: Chen-Yu Tsai 
---

Note that the file name follows the convention of most of the other
bananapi boards, that is the vendor "sinovoip" is not included in
the name. This deviates from what is already in U-boot.

This applies on top of my A83t USB patches.

---
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 148 
+++

 2 files changed, 149 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index e0d77ab79f5f..791fecc0774a 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -903,6 +903,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a33-q8-tablet.dtb \
sun8i-a33-sinlinx-sina33.dtb \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
+   sun8i-a83t-bananapi-m3.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h2-plus-orangepi-zero.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
diff --git a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
new file mode 100644
index ..2bafd7e99ef7
--- /dev/null
+++ b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2017 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of 
the

+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+#include "sun8i-a83t.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include 
+
+/ {
+   model = "Banana Pi BPI-M3";
+   compatible = "sinovoip,bpi-m3", "allwinner,sun8i-a83t";


Should we continue to use sinovoip,bpi-mx-xxx or use bananapi,mx-xxx
instead?


+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
+
+ {
+   /* Terminus Tech FE 1.1s 4-port USB 2.0 hub here */
+   status = "okay";
+
+   /* TODO GL830 USB-to-SATA bridge downstream w/ GPIO power controls */
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   vmmc-supply = <_vcc3v3>;
+   bus-width = <4>;
+   cd-gpios = < 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
+   cd-inverted;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_8bit_emmc_pins>;
+   vmmc-supply = <_vcc3v3>;
+   bus-width = <8>;
+ 

[U-Boot] [PATCH] ARM: sun8i: a83t: Add device tree for Sinovoip Bananapi BPI-M3

2017-08-16 Thread Chen-Yu Tsai
The BPI-M3 is an Allwinner A83T based SBC in the Bananapi/Bpi family.
It is roughly the same form factor as the BPI-M1+, with roughly the
same peripherals and connectors:

  - 2GB LPDDR3 DRAM
  - 8GB eMMC
  - Micro-SD card slot
  - HDMI output
  - Headset (stereo + mic) jack
  - Onboard mic
  - Gigabit Ethernet with RTL8211E transceiver
  - Ampak AP6212 WiFi + BT
  - USB OTG connector
  - USB-to-SATA bridge connected through a USB 2.0 hub
  - Consumer IR receiver
  - MIPI DSI LCD panel connector
  - Camera interface (parallel and MIPI CSI) connector
  - 3 LEDs (Red, Green, Blue), of which 2 are controllable (GB)
  - Raspberry Pi 2 compatible GPIO header

Signed-off-by: Chen-Yu Tsai 
---

Note that the file name follows the convention of most of the other
bananapi boards, that is the vendor "sinovoip" is not included in
the name. This deviates from what is already in U-boot.

This applies on top of my A83t USB patches.

---
 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 148 +++
 2 files changed, 149 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index e0d77ab79f5f..791fecc0774a 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -903,6 +903,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a33-q8-tablet.dtb \
sun8i-a33-sinlinx-sina33.dtb \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
+   sun8i-a83t-bananapi-m3.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h2-plus-orangepi-zero.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
diff --git a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts 
b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
new file mode 100644
index ..2bafd7e99ef7
--- /dev/null
+++ b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2017 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+#include "sun8i-a83t.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include 
+
+/ {
+   model = "Banana Pi BPI-M3";
+   compatible = "sinovoip,bpi-m3", "allwinner,sun8i-a83t";
+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
+
+ {
+   /* Terminus Tech FE 1.1s 4-port USB 2.0 hub here */
+   status = "okay";
+
+   /* TODO GL830 USB-to-SATA bridge downstream w/ GPIO power controls */
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   vmmc-supply = <_vcc3v3>;
+   bus-width = <4>;
+   cd-gpios = < 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
+   cd-inverted;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_8bit_emmc_pins>;
+   vmmc-supply = <_vcc3v3>;
+   bus-width = <8>;
+   non-removable;
+   cap-mmc-hw-reset;
+   status = "okay";
+};
+
+_rsb {
+   status = "okay";
+
+   

Re: [U-Boot] [PATCH] ls1046aqds: update the defaule mtdparts

2017-08-16 Thread Xiaowei Bao
Hi york,

Yes, I think so.

Thanks

-Original Message-
From: York Sun 
Sent: Thursday, August 17, 2017 12:15 AM
To: Xiaowei Bao ; Mingkai Hu ; Sumit 
Garg ; u-boot@lists.denx.de
Subject: Re: [U-Boot] [PATCH] ls1046aqds: update the defaule mtdparts

On 08/08/2017 07:27 PM, Xiaowei Bao wrote:
> Hi York,
> 
> The default partition is mainly to facilitate the test staff to view the 
> partition information of the storage medium, And the jira ticket also carry 
> by the test staff, I am not sure if it need to push the opensource.

So you agree we don't need this patch and test team can keep this variable 
internally.

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


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

2017-08-16 Thread Tom Rini
On Wed, Aug 16, 2017 at 08:30:20AM -0700, Tom Warren wrote:

> Tom,
> 
> Please pull u-boot-tegra/master into U-Boot/master. Thanks!
> 
> All Tegra builds are OK, and Stephen's automated test system reports that
> all tests pass.
> 
> The following changes since commit 2d3c4ae350fe8c196698681ab9410733bf9017e0:
> 
>   Prepare v2017.09-rc2 (2017-08-14 20:02:11 -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-tegra.git master
> 
> for you to fetch changes up to 33848eb53e00156bb6bade1955b09d12daeffdc6:
> 
>   apalis_t30/tk1, colibri_t20/t30: fix i2c bus frequencies (2017-08-15
> 14:51:18 -0700)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


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

2017-08-16 Thread Tom Rini
On Wed, Aug 16, 2017 at 06:30:39PM +0530, Jagan Teki wrote:

> Hi Tom,
> 
> Please pull this PR.
> 
> thanks!
> Jagan.
> 
> The following changes since commit eaa90e5df2a4a1cb12fb73571978a9379242d0b5:
> 
>   common/env_embedded.c: rename PPCENV/PPCTEXT macros (2017-08-04 20:38:39 
> -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-spi.git master
> 
> for you to fetch changes up to 294f2050c438d1e4ab39fd040d394927772048f2:
> 
>   sf: Preserve QE bit when clearing BP# bits for Macronix flash (2017-08-16 
> 18:21:50 +0530)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


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

2017-08-16 Thread Tom Rini
On Wed, Aug 16, 2017 at 06:41:09PM +0530, Jagan Teki wrote:

> Hi Tom,
> 
> Please pull this PR.
> 
> thanks!
> Jagan.
> 
> The following changes since commit b24065c4ef21687787a74eef22dfa9232096f965:
> 
>   Merge git://git.denx.de/u-boot-i2c (2017-08-10 07:22:59 -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-sunxi.git master
> 
> for you to fetch changes up to 585bf8ae6f467d85b8e9f17141c8562d96a83c51:
> 
>   sun50i: a64: Add A64-OLinuXino initial support (2017-08-15 11:30:59 +0530)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PULL] Please pull u-boot-imx

2017-08-16 Thread Tom Rini
On Wed, Aug 16, 2017 at 01:18:40PM +0200, Stefano Babic wrote:

> Hi Tom,
> 
> please pull from u-boot-imx, thanks !
> 
> The following changes since commit f19955a01482d118eac0fdaf530ec6e5b08cf414:
> 
>   Merge git://git.denx.de/u-boot-uniphier (2017-07-26 11:29:25 -0400)
> 
> are available in the git repository at:
> 
>   git://www.denx.de/git/u-boot-imx.git master
> 
> for you to fetch changes up to e872f27a020f353dd334fc025999466adf5ae18c:
> 
>   imx: mx7: fix build warning when CONFIG_IMX_RDC not enabled
> (2017-08-16 12:43:09 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


[U-Boot] [PATCHv2 2/2] igep00x0: merge igep0020 and igep0030 defconfigs to igep00x0_defconfig

2017-08-16 Thread Ladislav Michl
From: Pau Pajuelo 

Update igep00x0 code with the following features:
- Add board and revision detection for the boards:
  - IGEP0020-RF
  - IGEP0020-RC
  - IGEP0030-RG
  - IGEP0030-RE
- Merge IGEP0020 and IGEP0030 mux tables
- Add suport to use GPIO_126, GPIO_127 and GPIO_129
- board_name and board_rev environment variables display board and
  revision informations
- Move dtb name selection from code to boot script

Signed-off-by: Pau Pajuelo 
Signed-off-by: Ladislav Michl 
---
 Changes:
 -v2: Move dtb name selection from code to boot script
  Use board_rev to hold board revision

 board/isee/igep00x0/MAINTAINERS|  3 +-
 board/isee/igep00x0/common.c   | 12 ---
 board/isee/igep00x0/igep00x0.c | 90 --
 board/isee/igep00x0/igep00x0.h | 13 ++--
 configs/igep0030_defconfig | 47 ---
 configs/{igep0020_defconfig => igep00x0_defconfig} |  8 --
 include/configs/omap3_igep00x0.h   | 45 ---
 7 files changed, 124 insertions(+), 94 deletions(-)

diff --git a/board/isee/igep00x0/MAINTAINERS b/board/isee/igep00x0/MAINTAINERS
index 720ef2aa69..d75d400eed 100644
--- a/board/isee/igep00x0/MAINTAINERS
+++ b/board/isee/igep00x0/MAINTAINERS
@@ -3,6 +3,5 @@ M:  Enric Balletbo i Serra 
 S: Maintained
 F: board/isee/igep00x0/
 F: include/configs/omap3_igep00x0.h
-F: configs/igep0020_defconfig
-F: configs/igep0030_defconfig
+F: configs/igep00x0_defconfig
 F: configs/igep0032_defconfig
diff --git a/board/isee/igep00x0/common.c b/board/isee/igep00x0/common.c
index b8f1c14f6a..e59516f612 100644
--- a/board/isee/igep00x0/common.c
+++ b/board/isee/igep00x0/common.c
@@ -22,14 +22,6 @@ DECLARE_GLOBAL_DATA_PTR;
 void set_muxconf_regs(void)
 {
MUX_DEFAULT();
-
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-   MUX_IGEP0020();
-#endif
-
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-   MUX_IGEP0030();
-#endif
 }
 
 /*
@@ -60,10 +52,6 @@ int board_init(void)
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 
-#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
-   status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
-#endif
-
return 0;
 }
 
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 74f9bab093..5c7f256711 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -38,6 +37,43 @@ U_BOOT_DEVICE(igep_uart) = {
_serial
 };
 
+/*
+ * Routine: get_board_revision
+ * Description: GPIO_28 and GPIO_129 are used to read board and revision from
+ * IGEP00x0 boards. First of all, it is necessary to reset USB transceiver from
+ * IGEP0030 in order to read GPIO_IGEP00X0_BOARD_DETECTION correctly, because
+ * this functionality is shared by USB HOST.
+ * Once USB reset is applied, U-boot configures these pins as input pullup to
+ * detect board and revision:
+ * IGEP0020-RF = 0b00
+ * IGEP0020-RC = 0b01
+ * IGEP0030-RG = 0b10
+ * IGEP0030-RE = 0b11
+ */
+static int get_board_revision(void)
+{
+   int revision;
+
+   gpio_request(IGEP0030_USB_TRANSCEIVER_RESET,
+   "igep0030_usb_transceiver_reset");
+   gpio_direction_output(IGEP0030_USB_TRANSCEIVER_RESET, 0);
+
+   gpio_request(GPIO_IGEP00X0_BOARD_DETECTION, "igep00x0_board_detection");
+   gpio_direction_input(GPIO_IGEP00X0_BOARD_DETECTION);
+   revision = 2 * gpio_get_value(GPIO_IGEP00X0_BOARD_DETECTION);
+   gpio_free(GPIO_IGEP00X0_BOARD_DETECTION);
+
+   gpio_request(GPIO_IGEP00X0_REVISION_DETECTION,
+   "igep00x0_revision_detection");
+   gpio_direction_input(GPIO_IGEP00X0_REVISION_DETECTION);
+   revision = revision + gpio_get_value(GPIO_IGEP00X0_REVISION_DETECTION);
+   gpio_free(GPIO_IGEP00X0_REVISION_DETECTION);
+
+   gpio_free(IGEP0030_USB_TRANSCEIVER_RESET);
+
+   return revision;
+}
+
 int onenand_board_init(struct mtd_info *mtd)
 {
if (gpmc_cs0_flash == MTD_DEV_TYPE_ONENAND) {
@@ -138,31 +174,69 @@ int ft_board_setup(void *blob, bd_t *bd)
 }
 #endif
 
-void set_fdt(void)
+void set_led(void)
 {
-   switch (gd->bd->bi_arch_number) {
-   case MACH_TYPE_IGEP0020:
-   env_set("fdtfile", "omap3-igep0020.dtb");
+   switch (get_board_revision()) {
+   case 0:
+   case 1:
+   gpio_request(IGEP0020_GPIO_LED, "igep0020_gpio_led");
+   gpio_direction_output(IGEP0020_GPIO_LED, 1);
break;
-   case MACH_TYPE_IGEP0030:
-   env_set("fdtfile", "omap3-igep0030.dtb");
+   case 2:
+   case 3:
+   gpio_request(IGEP0030_GPIO_LED, "igep0030_gpio_led");
+

[U-Boot] [PATCH 1/2] igep00x0: move SPL routines into separate file

2017-08-16 Thread Ladislav Michl
Avoid cluttering board file with CONFIG_SPL_BUILD ifdefs
by moving SPL related functions into separate file.

Signed-off-by: Ladislav Michl 
---
 board/isee/igep00x0/Makefile   |   6 +-
 board/isee/igep00x0/common.c   |  80 ++
 board/isee/igep00x0/igep00x0.c | 128 -
 board/isee/igep00x0/spl.c  |  64 +
 4 files changed, 149 insertions(+), 129 deletions(-)

diff --git a/board/isee/igep00x0/Makefile b/board/isee/igep00x0/Makefile
index 68b151c3c5..74594da771 100644
--- a/board/isee/igep00x0/Makefile
+++ b/board/isee/igep00x0/Makefile
@@ -5,4 +5,8 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-y  := igep00x0.o
+ifdef CONFIG_SPL_BUILD
+obj-y  := spl.o common.o
+else
+obj-y  := igep00x0.o common.o
+endif
diff --git a/board/isee/igep00x0/common.c b/board/isee/igep00x0/common.c
new file mode 100644
index 00..b8f1c14f6a
--- /dev/null
+++ b/board/isee/igep00x0/common.c
@@ -0,0 +1,80 @@
+/*
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "igep00x0.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Routine: set_muxconf_regs
+ * Description: Setting up the configuration Mux registers specific to the
+ * hardware. Many pins need to be moved from protect to primary
+ * mode.
+ */
+void set_muxconf_regs(void)
+{
+   MUX_DEFAULT();
+
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
+   MUX_IGEP0020();
+#endif
+
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
+   MUX_IGEP0030();
+#endif
+}
+
+/*
+ * Routine: board_init
+ * Description: Early hardware init.
+ */
+int board_init(void)
+{
+   int loops = 100;
+
+   /* find out flash memory type, assume NAND first */
+   gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+   gpmc_init();
+
+   /* Issue a RESET and then READID */
+   writeb(NAND_CMD_RESET, _cfg->cs[0].nand_cmd);
+   writeb(NAND_CMD_STATUS, _cfg->cs[0].nand_cmd);
+   while ((readl(_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
+   != NAND_STATUS_READY) {
+   udelay(1);
+   if (--loops == 0) {
+   gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
+   gpmc_init();/* reinitialize for OneNAND */
+   break;
+   }
+   }
+
+   /* boot param addr */
+   gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
+
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+   status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
+#endif
+
+   return 0;
+}
+
+#if defined(CONFIG_MMC)
+int board_mmc_init(bd_t *bis)
+{
+   return omap_mmc_init(0, 0, 0, -1, -1);
+}
+
+void board_mmc_power_init(void)
+{
+   twl4030_power_mmc_init(0);
+}
+#endif
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index a7a75601dd..74f9bab093 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -20,15 +20,12 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include "igep00x0.h"
 
-DECLARE_GLOBAL_DATA_PTR;
-
 static const struct ns16550_platdata igep_serial = {
.base = OMAP34XX_UART3,
.reg_shift = 2,
@@ -41,98 +38,6 @@ U_BOOT_DEVICE(igep_uart) = {
_serial
 };
 
-/*
- * Routine: board_init
- * Description: Early hardware init.
- */
-int board_init(void)
-{
-   int loops = 100;
-
-   /* find out flash memory type, assume NAND first */
-   gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
-   gpmc_init();
-
-   /* Issue a RESET and then READID */
-   writeb(NAND_CMD_RESET, _cfg->cs[0].nand_cmd);
-   writeb(NAND_CMD_STATUS, _cfg->cs[0].nand_cmd);
-   while ((readl(_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
-   != NAND_STATUS_READY) {
-   udelay(1);
-   if (--loops == 0) {
-   gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
-   gpmc_init();/* reinitialize for OneNAND */
-   break;
-   }
-   }
-
-   /* boot param addr */
-   gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
-
-#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
-   status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
-#endif
-
-   return 0;
-}
-
-#ifdef CONFIG_SPL_BUILD
-/*
- * Routine: get_board_mem_timings
- * Description: If we use SPL then there is no x-loader nor config header
- * so we have to setup the DDR timings ourself on both banks.
- */
-void get_board_mem_timings(struct board_sdrc_timings *timings)
-{
-   int mfr, id, err = identify_nand_chip(, );
-
-   timings->mr = MICRON_V_MR_165;
-   if (!err) {
-   switch (mfr) {
-   case NAND_MFR_HYNIX:
-   timings->mcfg = 

[U-Boot] [PATCH 0/2] igep00x0: defconfig merge

2017-08-16 Thread Ladislav Michl
Hi Pau,

code with your patch "igep00x0: merge igep0020 and igep0030 defconfigs to
igep00x0_defconfig" applied no longer fits to sram (and patch even does
not apply anymore), so here's an update:
- move spl related functions to separate file
- update defconfig merge patch to current git
- use board_rev as other boards do
- set fdtfile using script (do not hardcode it)

best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 05/18] net: phy: micrel: Convert to livetree

2017-08-16 Thread Joe Hershberger
On Wed, Aug 16, 2017 at 12:32 PM, Philipp Tomsich
 wrote:
> Update the Micrel KSZ90x1 driver for a live tree.
>
> Signed-off-by: Philipp Tomsich 

Acked-by: Joe Hershberger 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 04/18] net: designware: Convert to livetree

2017-08-16 Thread Joe Hershberger
On Wed, Aug 16, 2017 at 12:32 PM, Philipp Tomsich
 wrote:
> Update the Designware Ethernet MAC driver to support a live device
> tree.
>
> Signed-off-by: Philipp Tomsich 

Acked-by: Joe Hershberger 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 15/19] mmc: dw_mmc: rockchip: add support for rk3066 sdmmc

2017-08-16 Thread Paweł Jarosz
This patch enables support for the Rockchip RK3066 SD/MMC controller, which is 
based on Designware IP. The device supports SD, SDIO, MMC and eMMC.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- dropped OF_PLATDATA

Changes since v2:
- none

 drivers/mmc/rockchip_dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index e7fcf89..a879fcd 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -160,6 +160,7 @@ static int rockchip_dwmmc_bind(struct udevice *dev)
 
 static const struct udevice_id rockchip_dwmmc_ids[] = {
{ .compatible = "rockchip,rk3288-dw-mshc" },
+   { .compatible = "rockchip,rk2928-dw-mshc" },
{ }
 };
 
-- 
2.7.4

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


[U-Boot] [PATCH v3 14/19] mmc: dw_mmc: support transfer mode autodetection

2017-08-16 Thread Paweł Jarosz
dw_mmc supports two transfer modes in u-boot: idma and fifo.
This patch adds autodetection of transfer mode and eliminates setting this in 
host config struct

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 drivers/mmc/dw_mmc.c | 8 
 include/dwmmc.h  | 4 
 2 files changed, 12 insertions(+)

diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index 700f764..2cc4d67 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -428,6 +428,7 @@ static int dwmci_set_ios(struct mmc *mmc)
 static int dwmci_init(struct mmc *mmc)
 {
struct dwmci_host *host = mmc->priv;
+   uint32_t use_dma;
 
if (host->board_init)
host->board_init(host);
@@ -439,6 +440,13 @@ static int dwmci_init(struct mmc *mmc)
return -EIO;
}
 
+   use_dma = SDMMC_GET_TRANS_MODE(dwmci_readl(host, DWMCI_HCON));
+   if (use_dma == DMA_INTERFACE_IDMA) {
+   host->fifo_mode = 0;
+   } else {
+   host->fifo_mode = 1;
+   }
+
/* Enumerate at 400KHz */
dwmci_setup_bus(host, mmc->cfg->f_min);
 
diff --git a/include/dwmmc.h b/include/dwmmc.h
index 4dda009..269536d 100644
--- a/include/dwmmc.h
+++ b/include/dwmmc.h
@@ -115,6 +115,10 @@
 #define RX_WMARK_SHIFT 16
 #define RX_WMARK_MASK  (0xfff << RX_WMARK_SHIFT)
 
+/* HCON Register */
+#define DMA_INTERFACE_IDMA (0x0)
+#define SDMMC_GET_TRANS_MODE(x)(((x)>>16) & 0x3)
+
 #define DWMCI_IDMAC_OWN(1 << 31)
 #define DWMCI_IDMAC_CH (1 << 4)
 #define DWMCI_IDMAC_FS (1 << 3)
-- 
2.7.4

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


[U-Boot] [PATCH v3 10/19] mtd: nand: add the rockchip nand controller driver

2017-08-16 Thread Paweł Jarosz
Add basic Rockchip nand driver.

Driver in current state has 16, 24, 40, 60 per 1024B BCH/ECC ability and 8 bit 
asynchronous flash interface support. Other features will come later.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- fixed correct ecc checking

 drivers/mtd/nand/Kconfig |   6 +
 drivers/mtd/nand/Makefile|   1 +
 drivers/mtd/nand/rockchip_nand.c | 660 +++
 include/fdtdec.h |   1 +
 lib/fdtdec.c |   1 +
 5 files changed, 669 insertions(+)
 create mode 100644 drivers/mtd/nand/rockchip_nand.c

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 71d678f..c308497 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -69,6 +69,12 @@ config NAND_PXA3XX
  This enables the driver for the NAND flash device found on
  PXA3xx processors (NFCv1) and also on Armada 370/XP (NFCv2).
 
+config NAND_ROCKCHIP
+   bool "Support for NAND on Rockchip SoCs"
+   select SYS_NAND_SELF_INIT
+   ---help---
+   Enable support for Rockchip nand.
+
 config NAND_SUNXI
bool "Support for NAND on Allwinner SoCs"
depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index c3d4a99..0659253 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_NAND_OMAP_ELM) += omap_elm.o
 obj-$(CONFIG_NAND_PLAT) += nand_plat.o
 obj-$(CONFIG_NAND_SUNXI) += sunxi_nand.o
 obj-$(CONFIG_NAND_ZYNQ) += zynq_nand.o
+obj-$(CONFIG_NAND_ROCKCHIP) += rockchip_nand.o
 
 else  # minimal SPL drivers
 
diff --git a/drivers/mtd/nand/rockchip_nand.c b/drivers/mtd/nand/rockchip_nand.c
new file mode 100644
index 000..d8f4439
--- /dev/null
+++ b/drivers/mtd/nand/rockchip_nand.c
@@ -0,0 +1,660 @@
+/*
+ * Copyright (c) 2017 Yifeng Zhao 
+ * Copyright (c) 2017 Paweł Jarosz 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define NANDC_V6_BOOTROM_ECC   24
+#defineNANDC_V6_NUM_BANKS  8
+#define NANDC_V6_DEF_TIMEOUT   2
+#define NANDC_V6_READ  0
+#define NANDC_V6_WRITE 1
+
+#defineNANDC_REG_V6_FMCTL  0x00
+#defineNANDC_REG_V6_FMWAIT 0x04
+#defineNANDC_REG_V6_FLCTL  0x08
+#defineNANDC_REG_V6_BCHCTL 0x0c
+#defineNANDC_REG_V6_DMA_CFG0x10
+#defineNANDC_REG_V6_DMA_BUF0   0x14
+#defineNANDC_REG_V6_DMA_BUF1   0x18
+#defineNANDC_REG_V6_DMA_ST 0x1C
+#defineNANDC_REG_V6_BCHST  0x20
+#defineNANDC_REG_V6_RANDMZ 0x150
+#defineNANDC_REG_V6_VER0x160
+#defineNANDC_REG_V6_INTEN  0x16C
+#defineNANDC_REG_V6_INTCLR 0x170
+#defineNANDC_REG_V6_INTST  0x174
+#defineNANDC_REG_V6_SPARE0 0x200
+#defineNANDC_REG_V6_SPARE1 0x230
+#defineNANDC_REG_V6_BANK0  0x800
+#defineNANDC_REG_V6_SRAM0  0x1000
+#defineNANDC_REG_V6_SRAM_SIZE  0x400
+
+#define NANDC_REG_V6_DATA  0x00
+#define NANDC_REG_V6_ADDR  0x04
+#define NANDC_REG_V6_CMD   0x08
+
+/* FMCTL */
+#define NANDC_V6_FM_WP BIT(8)
+#define NANDC_V6_FM_CE_SEL_M   0xFF
+#define NANDC_V6_FM_CE_SEL(x)  (1 << (x))
+#define NANDC_V6_FM_FREADY BIT(9)
+
+/* FLCTL */
+#define NANDC_V6_FL_RSTBIT(0)
+#define NANDC_V6_FL_DIR_S  0x1
+#define NANDC_V6_FL_XFER_START BIT(2)
+#define NANDC_V6_FL_XFER_ENBIT(3)
+#define NANDC_V6_FL_ST_BUF_S   0x4
+#define NANDC_V6_FL_XFER_COUNT BIT(5)
+#define NANDC_V6_FL_ACORRECT   BIT(10)
+#define NANDC_V6_FL_XFER_READY BIT(20)
+
+/* BCHCTL */
+#define NAND_V6_BCH_REGION_S   0x5
+#define NAND_V6_BCH_REGION_M   0x7 
+
+/* BCHST */
+#define NANDC_V6_BCH0_ST_ERR   BIT(2)
+#define NANDC_V6_BCH1_ST_ERR   BIT(15)
+#define NANDC_V6_ECC_ERR_CNT0(x) x & (0x1F << 3)) >> 3) \
+   | ((x & (1 << 27)) >> 22)) & 0x3F)
+#define NANDC_V6_ECC_ERR_CNT1(x) x & (0x1F << 16)) >> 16) \
+   | ((x & (1 << 29)) >> 24)) & 0x3F)
+
+struct rk_nand {
+   uint32_t banks[NANDC_V6_NUM_BANKS];
+   struct nand_hw_control controller;
+   uint32_t ecc_strength;
+   struct mtd_info mtd;
+   bool bootromblocks;
+   void __iomem *regs;
+   int selected_bank;
+};
+
+static struct nand_ecclayout nand_oob_fix = {
+   .eccbytes = 24,
+   .eccpos = {
+  4, 5, 6, 7, 8, 9, 10},
+   .oobfree = {
+   {.offset = 0,
+.length = 4} }
+};
+
+static inline struct rk_nand *to_rknand(struct nand_hw_control *ctrl)
+{
+   return container_of(ctrl, struct rk_nand, controller);
+}
+
+static void rockchip_nand_init(struct 

[U-Boot] [PATCH v3 18/19] dfu: fix spl build

2017-08-16 Thread Paweł Jarosz
In current state dfu depends on cmd/mtdparts.c which isn't build in SPL.
This patch resolves it by cutting out unwanted code in SPL build.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 drivers/dfu/dfu_nand.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
index 6dc9ff7..a196233 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -192,8 +192,9 @@ unsigned int dfu_polltimeout_nand(struct dfu_entity *dfu)
 int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s)
 {
char *st;
+#ifndef CONFIG_SPL_BUILD
int ret, dev, part;
-
+#endif
dfu->data.nand.ubi = 0;
dfu->dev_type = DFU_DEV_NAND;
st = strsep(, " ");
@@ -203,6 +204,7 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char 
*devstr, char *s)
s++;
dfu->data.nand.size = simple_strtoul(s, , 16);
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
+#ifndef CONFIG_SPL_BUILD
char mtd_id[32];
struct mtd_device *mtd_dev;
u8 part_num;
@@ -220,6 +222,7 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char 
*devstr, char *s)
mtdparts_init();
 
ret = find_dev_and_part(mtd_id, _dev, _num, );
+
if (ret != 0) {
printf("Could not locate '%s'\n", mtd_id);
return -1;
@@ -229,6 +232,7 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char 
*devstr, char *s)
dfu->data.nand.size = pi->size;
if (!strcmp(st, "partubi"))
dfu->data.nand.ubi = 1;
+#endif
} else {
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
return -1;
-- 
2.7.4

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


[U-Boot] [PATCH v3 19/19] mtd: nand: spl: allow build nand_bbt, nand_ids and nand_util

2017-08-16 Thread Paweł Jarosz
This patch allows building of nand_bbt, nand_ids, nand_util for nand drivers 
that need it.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 drivers/mtd/nand/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 0659253..9062c2e 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -18,6 +18,9 @@ obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
 obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o
 obj-$(CONFIG_SPL_NAND_INIT) += nand.o
+obj-$(CONFIG_SPL_NAND_BBT) += nand_bbt.o
+obj-$(CONFIG_SPL_NAND_IDS) += nand_ids.o
+obj-$(CONFIG_SPL_NAND_UTIL) += nand_util.o
 ifeq ($(CONFIG_SPL_ENV_SUPPORT),y)
 obj-$(CONFIG_ENV_IS_IN_NAND) += nand_util.o
 endif
-- 
2.7.4

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


[U-Boot] [PATCH v3 16/19] armv7: support rk3066 early back to bootrom in vector.S

2017-08-16 Thread Paweł Jarosz
Rockchip bootrom first reads 1KB data from nand at offset 0x10080C00 and
executes it. Then waits for back to bootrom and loads another 32KB to sram
which also executes. Sdram initialisation code needs to be in one of these two
steps. Then bootloader loads another ~200KB of data at offset 0x6000
and jumps to it.

32KB of data is a little low for tpl + spl part and ~200KB data is to low for
u-boot part(for example to boot from mmc you need to disable usb support.

My solution to size problem is to move sdram initialisation code to tpl stage,
move spl part to third stage(reading 200KB data) and add support for loading
u-boot by spl from ext2/4, fat partitions.

But moving sdram initialisation code to tpl increases size of tpl above 1KB
(first boot stage). Solution to this is to add code which will be below 1KB
offset in tpl binary and do back to bootrom at very beginning of the tpl
execution.

Adding this few lines of code here meets these conditions.

Signed-off-by: Paweł Jarosz 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- moved to vector.S

Changes since v2:
- none

 arch/arm/include/asm/arch-rockchip/boot0.h | 14 ++
 arch/arm/lib/vectors.S | 18 +-
 configs/mk808_defconfig|  1 +
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/arch/arm/include/asm/arch-rockchip/boot0.h 
b/arch/arm/include/asm/arch-rockchip/boot0.h
index 72d264b..4179448 100644
--- a/arch/arm/include/asm/arch-rockchip/boot0.h
+++ b/arch/arm/include/asm/arch-rockchip/boot0.h
@@ -5,6 +5,19 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 
+#if defined(CONFIG_ROCKCHIP_RK3066) && defined(CONFIG_TPL_BUILD)
+   ldr r3, =0x10080900
+   ldr r0, [r3]
+   cmp r0, #1
+   movne   r0, #1
+   strne   r0, [r3]
+   beq out_of_bootrom
+   bx  lr
+out_of_bootrom:
+   mov r0, #0
+   str r0, [r3]
+#endif
+
 /*
  * Execution starts on the instruction following this 4-byte header
  * (containing the magic 'RK33').
@@ -26,6 +39,7 @@
 */
b reset  /* may be overwritten --- should be 'nop' or a 'b reset' */
 #endif
+
b reset
 
 #if defined(CONFIG_ROCKCHIP_RK3399) && defined(CONFIG_SPL_BUILD)
diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S
index 1019091..e3c18da 100644
--- a/arch/arm/lib/vectors.S
+++ b/arch/arm/lib/vectors.S
@@ -47,6 +47,15 @@
 
 _start:
 
+#ifdef CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK
+/*
+ * Various SoCs need something special and SoC-specific up front in
+ * order to boot, allow them to set that in their boot0.h file and then
+ * use it here.
+ */
+#include 
+#endif
+
 #ifdef CONFIG_SYS_DV_NOR_BOOT_CFG
.word   CONFIG_SYS_DV_NOR_BOOT_CFG
 #endif
@@ -60,15 +69,6 @@ _start:
ldr pc, _irq
ldr pc, _fiq
 
-#ifdef CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK
-/*
- * Various SoCs need something special and SoC-specific up front in
- * order to boot, allow them to set that in their boot0.h file and then
- * use it here.
- */
-#include 
-#endif
-
 /*
  *
  *
diff --git a/configs/mk808_defconfig b/configs/mk808_defconfig
index ab67e4f..bf4af82 100644
--- a/configs/mk808_defconfig
+++ b/configs/mk808_defconfig
@@ -13,6 +13,7 @@ CONFIG_USE_PRIVATE_LIBGCC=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_ERRNO_STR=y
 CONFIG_SYS_NS16550=y
+CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
 CONFIG_BOOTDELAY=1
 CONFIG_CONSOLE_MUX=y
 CONFIG_DISPLAY_BOARDINFO=y
-- 
2.7.4

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


[U-Boot] [PATCH v3 17/19] rockchip: sysreset: deduplicate rk3066 and rk3188 sysreset drivers

2017-08-16 Thread Paweł Jarosz
Sysreset drivers for rk3066 and rk3188 contain common elements which can be 
reused.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 .../include/asm/arch-rockchip/sysreset_common.h| 20 +++
 arch/arm/mach-rockchip/Makefile|  3 ++
 arch/arm/mach-rockchip/sysreset-common.c   | 39 ++
 drivers/sysreset/sysreset_rk3066.c | 34 ++-
 drivers/sysreset/sysreset_rk3188.c | 35 ++-
 5 files changed, 84 insertions(+), 47 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/sysreset_common.h
 create mode 100644 arch/arm/mach-rockchip/sysreset-common.c

diff --git a/arch/arm/include/asm/arch-rockchip/sysreset_common.h 
b/arch/arm/include/asm/arch-rockchip/sysreset_common.h
new file mode 100644
index 000..c7e1fc0
--- /dev/null
+++ b/arch/arm/include/asm/arch-rockchip/sysreset_common.h
@@ -0,0 +1,20 @@
+/*
+ * (C) Copyright 2017 Paweł Jarosz 
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+
+#ifndef _ASM_ARCH_SYSRESET_COMMON_H
+#define _ASM_ARCH_SYSRESET_COMMON_H
+
+struct rockchip_sysreset_data {
+   void *grf_soc_con0;
+   uint32_t noc_remap_mask;
+   void *cru_mode_con;
+   void *cru_glb_srst_snd_value;
+   void *cru_glb_srst_fst_value;
+};
+
+int rockchip_sysreset_request(struct rockchip_sysreset_data *data,
+ enum sysreset_t type);
+#endif
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index ae878ef..b58a9c4 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -11,6 +11,9 @@
 obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
 obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
 
+obj-$(CONFIG_ROCKCHIP_RK3066) += sysreset-common.o
+obj-$(CONFIG_ROCKCHIP_RK3188) += sysreset-common.o
+
 obj-tpl-$(CONFIG_ROCKCHIP_RK3066) += rk3066-board-tpl.o
 obj-tpl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
 obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o
diff --git a/arch/arm/mach-rockchip/sysreset-common.c 
b/arch/arm/mach-rockchip/sysreset-common.c
new file mode 100644
index 000..41e76e3
--- /dev/null
+++ b/arch/arm/mach-rockchip/sysreset-common.c
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2017 Paweł Jarosz 
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int rockchip_sysreset_request(struct rockchip_sysreset_data *data,
+ enum sysreset_t type)
+{
+   switch (type) {
+   case SYSRESET_WARM:
+   /*
+* warm-reset keeps the remap value,
+* so make sure it's disabled.
+*/
+   rk_clrsetreg(data->grf_soc_con0,
+   data->noc_remap_mask, 0);
+
+   rk_clrreg(data->cru_mode_con, 0x);
+   writel(0xeca8, data->cru_glb_srst_snd_value);
+   break;
+   case SYSRESET_COLD:
+   rk_clrreg(data->cru_mode_con, 0x);
+   writel(0xfdb9, data->cru_glb_srst_fst_value);
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
diff --git a/drivers/sysreset/sysreset_rk3066.c 
b/drivers/sysreset/sysreset_rk3066.c
index b5dcb9a..f82b3dd 100644
--- a/drivers/sysreset/sysreset_rk3066.c
+++ b/drivers/sysreset/sysreset_rk3066.c
@@ -14,40 +14,28 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 int rk3066_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
struct rk3066_cru *cru = rockchip_get_cru();
-   struct rk3066_grf *grf;
+   struct rk3066_grf *grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+   struct rockchip_sysreset_data data = {
+   .grf_soc_con0 = >soc_con0,
+   .noc_remap_mask = NOC_REMAP_MASK,
+   .cru_mode_con = >cru_mode_con,
+   .cru_glb_srst_snd_value = >cru_glb_srst_snd_value,
+   .cru_glb_srst_fst_value = >cru_glb_srst_fst_value
+   };
 
if (IS_ERR(cru))
return PTR_ERR(cru);
 
-   switch (type) {
-   case SYSRESET_WARM:
-   grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
-   if (IS_ERR(grf))
-   return -EPROTONOSUPPORT;
-   /*
-* warm-reset keeps the remap value,
-* so make sure it's disabled.
-*/
-   rk_clrsetreg(>soc_con0,
-   NOC_REMAP_MASK, 0 << NOC_REMAP_SHIFT);
-
-   rk_clrreg(>cru_mode_con, 0x);
-   writel(0xeca8, >cru_glb_srst_snd_value);
-   break;
-   case SYSRESET_COLD:
-   rk_clrreg(>cru_mode_con, 

[U-Boot] [PATCH v3 11/19] rockchip: mkimage: add support for rockchip nand boot image

2017-08-16 Thread Paweł Jarosz
The Rockchip boot ROM requires a particular file format for booting from NAND:

* It starts with 512-byte, rc4 encoded header and is aligned to nand page size

* Then first 2KB of first stage loader (tpl) aligned to nand page size
* n empty pages

* second 2KB of first stage loader (tpl) aligned to nand page size
* n empty pages

* ...

* first 2KB of second stage loader (spl) aligned to nand page size
* n empty pages

* second 2KB of first stage loader (spl) aligned to nand page size
* n empty pages

* ...

Size of spl and tpl must be aligned to 2KB.

example usage for nand with page size 16384 and one empty page in iteration:

# mkimage -n rk3066 -T rknand -d 
./u-boot/tpl/u-boot-tpl.bin:./u-boot/spl/u-boot-spl.bin -X 16384,1 out

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 common/image.c|   1 +
 include/image.h   |   1 +
 tools/Makefile|   2 +-
 tools/imagetool.h |   1 +
 tools/mkimage.c   |   8 ++-
 tools/rkcommon.c  |  10 ++--
 tools/rkcommon.h  |  10 +++-
 tools/rknand.c| 156 ++
 tools/rksd.c  |   2 +-
 tools/rkspi.c |   2 +-
 10 files changed, 183 insertions(+), 10 deletions(-)
 create mode 100644 tools/rknand.c

diff --git a/common/image.c b/common/image.c
index a058eb8..f5f6cd2 100644
--- a/common/image.c
+++ b/common/image.c
@@ -167,6 +167,7 @@ static const table_entry_t uimage_type[] = {
{   IH_TYPE_FPGA,   "fpga",   "FPGA Image" },
{   IH_TYPE_TEE,"tee","Trusted Execution 
Environment Image",},
{   IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" 
},
+   {   IH_TYPE_RKNAND, "rknand", "Rockchip NAND Boot Image" },
{   -1, "",   "",   },
 };
 
diff --git a/include/image.h b/include/image.h
index 1f4bfda..10ff094 100644
--- a/include/image.h
+++ b/include/image.h
@@ -269,6 +269,7 @@ enum {
IH_TYPE_VYBRIDIMAGE,/* VYBRID .vyb Image */
IH_TYPE_TEE,/* Trusted Execution Environment OS Image */
IH_TYPE_FIRMWARE_IVT,   /* Firmware Image with HABv4 IVT */
+   IH_TYPE_RKNAND, /* Rockchip NAND Boot Image */
 
IH_TYPE_COUNT,  /* Number of image types */
 };
diff --git a/tools/Makefile b/tools/Makefile
index a1790eb..044049c 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -79,7 +79,7 @@ RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
rsa-sign.o rsa-verify.o rsa-checksum.o \
rsa-mod-exp.o)
 
-ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
+ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rknand.o rksd.o rkspi.o
 
 # common objs for dumpimage and mkimage
 dumpimage-mkimage-objs := aisimage.o \
diff --git a/tools/imagetool.h b/tools/imagetool.h
index a8d5054..0b2a707 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -77,6 +77,7 @@ struct image_tool_params {
bool quiet; /* Don't output text in normal operation */
unsigned int external_offset;   /* Add padding to external data */
const char *engine_id;  /* Engine to use for signing */
+   char *extraparams;  /* Extra parameters for img creation (-X) */
 };
 
 /*
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 28ff35e..ffc91d2 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -144,7 +144,7 @@ static void process_args(int argc, char **argv)
int opt;
 
while ((opt = getopt(argc, argv,
-"a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) 
!= -1) {
+
"a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVxX:")) != -1) {
switch (opt) {
case 'a':
params.addr = strtoull(optarg, , 16);
@@ -279,6 +279,9 @@ static void process_args(int argc, char **argv)
case 'x':
params.xflag++;
break;
+   case 'X':
+   params.extraparams = optarg;
+   break;
default:
usage("Invalid option");
}
@@ -416,7 +419,8 @@ int main(int argc, char **argv)
exit (retval);
}
 
-   if ((params.type != IH_TYPE_MULTI) && (params.type != IH_TYPE_SCRIPT)) {
+   if ((params.type != IH_TYPE_MULTI) && (params.type != IH_TYPE_SCRIPT) &&
+   (params.type != IH_TYPE_RKNAND)) {
dfd = open(params.datafile, O_RDONLY | O_BINARY);
if (dfd < 0) {
fprintf(stderr, "%s: Can't open %s: %s\n",
diff --git a/tools/rkcommon.c b/tools/rkcommon.c
index 04e8272..a2f2160 100644
--- a/tools/rkcommon.c
+++ b/tools/rkcommon.c
@@ -73,6 +73,7 @@ struct spl_info {
 
 static struct spl_info spl_infos[] = {
{ 

[U-Boot] [PATCH v3 13/19] ARM: dts: rockchip: prefer u-boot, dm-pre-reloc rather than u-boot, dm-spl

2017-08-16 Thread Paweł Jarosz
rk3xxx.dtsi is used by rk3188 and rk3066. rk3188 uses alocated data in spl but 
rk3066 needs it in tpl.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 arch/arm/dts/rk3xxx.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/dts/rk3xxx.dtsi b/arch/arm/dts/rk3xxx.dtsi
index 6d9e36d..d1c205b 100644
--- a/arch/arm/dts/rk3xxx.dtsi
+++ b/arch/arm/dts/rk3xxx.dtsi
@@ -135,7 +135,7 @@
};
 
noc: syscon@10128000 {
-   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
compatible = "rockchip,rk3188-noc", "syscon";
reg = <0x10128000 0x2000>;
};
@@ -218,13 +218,13 @@
pmu: pmu@20004000 {
compatible = "rockchip,rk3066-pmu", "syscon";
reg = <0x20004000 0x100>;
-   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
};
 
grf: grf@20008000 {
compatible = "syscon";
reg = <0x20008000 0x200>;
-   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
};
 
dmc: dmc@2002 {
@@ -238,7 +238,7 @@
   0x2004 0x294>;
clocks = < PCLK_DDRUPCTL>, < PCLK_PUBL>;
clock-names = "pclk_ddrupctl", "pclk_publ";
-   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
};
 
i2c0: i2c@2002d000 {
-- 
2.7.4

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


[U-Boot] [PATCH v3 12/19] rockchip: board: rk3066: convert board_usb_init to live tree functions

2017-08-16 Thread Paweł Jarosz
Use live tree functions to fill dwc2_plat_otg_data structure in board_usb_init.

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 arch/arm/mach-rockchip/rk3066-board.c | 52 +--
 1 file changed, 7 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-rockchip/rk3066-board.c 
b/arch/arm/mach-rockchip/rk3066-board.c
index 8fa06a2..2b96eb2 100644
--- a/arch/arm/mach-rockchip/rk3066-board.c
+++ b/arch/arm/mach-rockchip/rk3066-board.c
@@ -90,55 +90,17 @@ static struct dwc2_plat_otg_data rk3066_otg_data = {
 
 int board_usb_init(int index, enum usb_init_type init)
 {
-   int node, phy_node;
-   const char *mode;
-   bool matched = false;
-   const void *blob = gd->fdt_blob;
-   u32 grf_phy_offset;
-
-   /* find the usb_otg node */
-   node = fdt_node_offset_by_compatible(blob, -1,
-   "rockchip,rk3066-usb");
-
-   while (node > 0) {
-   mode = fdt_getprop(blob, node, "dr_mode", NULL);
-   if (mode && strcmp(mode, "otg") == 0) {
-   matched = true;
-   break;
-   }
-
-   node = fdt_node_offset_by_compatible(blob, node,
-   "rockchip,rk3066-usb");
-   }
-   if (!matched) {
-   debug("Not found usb_otg device\n");
-   return -ENODEV;
-   }
-   rk3066_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
+   ofnode otg_node;
+   u32 reg;
 
-   node = fdtdec_lookup_phandle(blob, node, "phys");
-   if (node <= 0) {
-   debug("Not found usb phy device\n");
+   otg_node = ofnode_path("/usb@1018");
+   if (!ofnode_valid(otg_node)) {
+   debug("Not found usb otg device\n");
return -ENODEV;
}
 
-   phy_node = fdt_parent_offset(blob, node);
-   if (phy_node <= 0) {
-   debug("Not found usb phy device\n");
-   return -ENODEV;
-   }
-
-   rk3066_otg_data.phy_of_node = phy_node;
-   grf_phy_offset = fdtdec_get_addr(blob, node, "reg");
-
-   node = fdt_node_offset_by_compatible(blob, -1,
-   "rockchip,rk3066-grf");
-   if (node <= 0) {
-   debug("Not found grf device\n");
-   return -ENODEV;
-   }
-   rk3066_otg_data.regs_phy = grf_phy_offset +
-   fdtdec_get_addr(blob, node, "reg");
+   ofnode_read_u32(otg_node, "reg", );
+   rk3066_otg_data.regs_otg = reg;
 
return dwc2_udc_probe(_otg_data);
 }
-- 
2.7.4

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


[U-Boot] [PATCH v3 09/19] mtd: nand: add support for the Sandisk SDTNQGAMA chip

2017-08-16 Thread Paweł Jarosz
Sandisk SDTNQGAMA is a 8GB size, 3.3V 8 bit chip with 16KB page size, 1KB write 
size and 40 bit ecc support

Signed-off-by: Paweł Jarosz 
---
Changes since v1:
- none

Changes since v2:
- none

 drivers/mtd/nand/nand_ids.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c
index d36f900..7bd9f7d 100644
--- a/drivers/mtd/nand/nand_ids.c
+++ b/drivers/mtd/nand/nand_ids.c
@@ -58,6 +58,9 @@ struct nand_flash_dev nand_flash_ids[] = {
{"TC58NVG6D2 64G 3.3V 8-bit",
{ .id = {0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20} },
  SZ_8K, SZ_8K, SZ_2M, 0, 8, 640, NAND_ECC_INFO(40, SZ_1K) },
+   {"SDTNQGAMA 64G 3.3V 8-bit",
+   { .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x57} },
+ SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) },
{"SDTNRGAMA 64G 3.3V 8-bit",
{ .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x50} },
  SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) },
-- 
2.7.4

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


[U-Boot] [PATCH v3 08/19] rockchip: rk3066: add sdram driver

2017-08-16 Thread Paweł Jarosz
Add rockchip rk3066 sdram driver

Signed-off-by: Paweł Jarosz 
Acked-by: Simon Glass 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- use common rockchip_sdram_size
- moved sdram init from sdram_init.c

Changes since v2:
- none

 arch/arm/mach-rockchip/rk3066/Makefile   |   1 +
 arch/arm/mach-rockchip/rk3066/sdram_rk3066.c | 943 +++
 2 files changed, 944 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3066/sdram_rk3066.c

diff --git a/arch/arm/mach-rockchip/rk3066/Makefile 
b/arch/arm/mach-rockchip/rk3066/Makefile
index 61b7fd4..7663b6a 100644
--- a/arch/arm/mach-rockchip/rk3066/Makefile
+++ b/arch/arm/mach-rockchip/rk3066/Makefile
@@ -5,4 +5,5 @@
 #
 
 obj-y += clk_rk3066.o
+obj-y += sdram_rk3066.o
 obj-y += syscon_rk3066.o
diff --git a/arch/arm/mach-rockchip/rk3066/sdram_rk3066.c 
b/arch/arm/mach-rockchip/rk3066/sdram_rk3066.c
new file mode 100644
index 000..e7475b8
--- /dev/null
+++ b/arch/arm/mach-rockchip/rk3066/sdram_rk3066.c
@@ -0,0 +1,943 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ * Copyright 2014 Rockchip Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Adapted from the very similar rk3188 ddr init.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct chan_info {
+   struct rk3288_ddr_pctl *pctl;
+   struct rk3288_ddr_publ *publ;
+   struct rk3188_msch *msch;
+};
+
+struct dram_info {
+   struct chan_info chan[1];
+   struct ram_info info;
+   struct clk ddr_clk;
+   struct rk3066_cru *cru;
+   struct rk3066_grf *grf;
+   struct rk3066_sgrf *sgrf;
+   struct rk3188_pmu *pmu;
+};
+
+struct rk3066_sdram_params {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   struct dtd_rockchip_rk3066_dmc of_plat;
+#endif
+   struct rk3288_sdram_channel ch[2];
+   struct rk3288_sdram_pctl_timing pctl_timing;
+   struct rk3288_sdram_phy_timing phy_timing;
+   struct rk3288_base_params base;
+   int num_channels;
+   struct regmap *map;
+};
+
+const int ddrconf_table[] = {
+   /*
+* [5:4] row(13+n)
+* [1:0] col(9+n), assume bw=2
+* row  col,bw
+*/
+   0,
+   (2 << DDRCONF_ROW_SHIFT) | 1 << DDRCONF_COL_SHIFT,
+   (1 << DDRCONF_ROW_SHIFT) | 1 << DDRCONF_COL_SHIFT,
+   (0 << DDRCONF_ROW_SHIFT) | 1 << DDRCONF_COL_SHIFT,
+   (2 << DDRCONF_ROW_SHIFT) | 2 << DDRCONF_COL_SHIFT,
+   (1 << DDRCONF_ROW_SHIFT) | 2 << DDRCONF_COL_SHIFT,
+   (0 << DDRCONF_ROW_SHIFT) | 2 << DDRCONF_COL_SHIFT,
+   (1 << DDRCONF_ROW_SHIFT) | 0 << DDRCONF_COL_SHIFT,
+   (0 << DDRCONF_ROW_SHIFT) | 0 << DDRCONF_COL_SHIFT,
+   0,
+   0,
+   0,
+   0,
+   0,
+   0,
+   0,
+};
+
+#define TEST_PATTEN0x5aa5f00f
+#define DQS_GATE_TRAINING_ERROR_RANK0  (1 << 4)
+#define DQS_GATE_TRAINING_ERROR_RANK1  (2 << 4)
+
+#ifdef CONFIG_TPL_BUILD
+static void copy_to_reg(u32 *dest, const u32 *src, u32 n)
+{
+   int i;
+
+   for (i = 0; i < n / sizeof(u32); i++) {
+   writel(*src, dest);
+   src++;
+   dest++;
+   }
+}
+
+static void ddr_reset(struct rk3066_cru *cru, u32 ch, u32 ctl, u32 phy)
+{
+   u32 phy_ctl_srstn_shift = 13;
+   u32 ctl_psrstn_shift = 11;
+   u32 ctl_srstn_shift = 10;
+   u32 phy_psrstn_shift = 9;
+   u32 phy_srstn_shift = 8;
+
+   rk_clrsetreg(>cru_softrst_con[5],
+1 << phy_ctl_srstn_shift | 1 << ctl_psrstn_shift |
+1 << ctl_srstn_shift | 1 << phy_psrstn_shift |
+1 << phy_srstn_shift,
+phy << phy_ctl_srstn_shift | ctl << ctl_psrstn_shift |
+ctl << ctl_srstn_shift | phy << phy_psrstn_shift |
+phy << phy_srstn_shift);
+}
+
+static void ddr_phy_ctl_reset(struct rk3066_cru *cru, u32 ch, u32 n)
+{
+   u32 phy_ctl_srstn_shift = 13;
+
+   rk_clrsetreg(>cru_softrst_con[5],
+1 << phy_ctl_srstn_shift, n << phy_ctl_srstn_shift);
+}
+
+static void phy_pctrl_reset(struct rk3066_cru *cru,
+   struct rk3288_ddr_publ *publ,
+   int channel)
+{
+   int i;
+
+   ddr_reset(cru, channel, 1, 1);
+   udelay(1);
+   clrbits_le32(>acdllcr, ACDLLCR_DLLSRST);
+   for (i = 0; i < 4; i++)
+   clrbits_le32(>datx8[i].dxdllcr, DXDLLCR_DLLSRST);
+
+   udelay(10);
+   setbits_le32(>acdllcr, ACDLLCR_DLLSRST);
+   for (i = 0; i < 4; i++)
+   setbits_le32(>datx8[i].dxdllcr, DXDLLCR_DLLSRST);
+
+   udelay(10);
+   ddr_reset(cru, channel, 1, 0);
+   udelay(10);
+   ddr_reset(cru, channel, 0, 0);
+   udelay(10);
+}
+
+static void phy_dll_bypass_set(struct rk3288_ddr_publ 

[U-Boot] [PATCH v3 07/19] rockchip: rk3066: add mk808 board files

2017-08-16 Thread Paweł Jarosz
mk808 is a tv stick with two usb ports, micro sd card slot, hdmi and
nand onboard.

Signed-off-by: Paweł Jarosz 
Acked-by: Simon Glass 
Acked-by: Philipp Tomsich 
Reviewed-by: Philipp Tomsich 
---
Changes since v1:
- added nand support
- dropped spl of-platdata

Changes since v2:
- fixed dfu ram config

 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/rk3066a-mk808.dts  | 189 
 board/rikomagic/mk808_rk3066/Kconfig|  15 +++
 board/rikomagic/mk808_rk3066/MAINTAINERS|   6 +
 board/rikomagic/mk808_rk3066/Makefile   |   7 ++
 board/rikomagic/mk808_rk3066/mk808_rk3066.c |  10 ++
 configs/mk808_defconfig | 114 +
 include/configs/mk808_rk3066.h  |  61 +
 8 files changed, 403 insertions(+)
 create mode 100644 arch/arm/dts/rk3066a-mk808.dts
 create mode 100644 board/rikomagic/mk808_rk3066/Kconfig
 create mode 100644 board/rikomagic/mk808_rk3066/MAINTAINERS
 create mode 100644 board/rikomagic/mk808_rk3066/Makefile
 create mode 100644 board/rikomagic/mk808_rk3066/mk808_rk3066.c
 create mode 100644 configs/mk808_defconfig
 create mode 100644 include/configs/mk808_rk3066.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 2cbdb17..fd4bb4f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -29,6 +29,7 @@ dtb-$(CONFIG_EXYNOS5) += exynos5250-arndale.dtb \
 dtb-$(CONFIG_EXYNOS7420) += exynos7420-espresso7420.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += \
rk3036-sdk.dtb \
+   rk3066a-mk808.dtb \
rk3188-radxarock.dtb \
rk3288-evb.dtb \
rk3288-fennec.dtb \
diff --git a/arch/arm/dts/rk3066a-mk808.dts b/arch/arm/dts/rk3066a-mk808.dts
new file mode 100644
index 000..0a452d7
--- /dev/null
+++ b/arch/arm/dts/rk3066a-mk808.dts
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2017 Paweł Jarosz 
+ *
+ * SPDX-License-Identifier: GPL-2.0+ or X11
+ */
+
+/dts-v1/;
+#include "rk3066a.dtsi"
+
+/ {
+   model = "Rikomagic MK808";
+   compatible = "rikomagic,mk808", "rockchip,rk3066a";
+
+   chosen {
+   stdout-path = "serial2:115200n8";
+   };
+
+   memory@6000 {
+   reg = <0x6000 0x4000>;
+   device_type = "memory";
+   };
+
+   gpio-leds {
+   compatible = "gpio-leds";
+
+   blue {
+   label = "mk808:blue:power";
+   gpios = < 3 GPIO_ACTIVE_HIGH>;
+   default-state = "off";
+   linux,default-trigger = "default-on";
+   };
+   };
+
+   vcc_io: vcc-io {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_io";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
+   vcc_host: usb-host-regulator {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < 6 GPIO_ACTIVE_HIGH>;
+   pinctrl-0 = <_drv>;
+   pinctrl-names = "default";
+   regulator-always-on;
+   regulator-name = "host-pwr";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   startup-delay-us = <10>;
+   vin-supply = <_io>;
+   };
+
+   vcc_otg: usb-otg-regulator {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < 5 GPIO_ACTIVE_HIGH>;
+   pinctrl-0 = <_drv>;
+   pinctrl-names = "default";
+   regulator-always-on;
+   regulator-name = "vcc_otg";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   startup-delay-us = <10>;
+   vin-supply = <_io>;
+   };
+
+   vcc_sd: sdmmc-regulator {
+   compatible = "regulator-fixed";
+   gpio = < 7 GPIO_ACTIVE_LOW>;
+   pinctrl-0 = <_pwr>;
+   pinctrl-names = "default";
+   regulator-name = "vcc_sd";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   startup-delay-us = <10>;
+   vin-supply = <_io>;
+   };
+
+   vcc_wifi: sdio-regulator {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < 24 GPIO_ACTIVE_HIGH>;
+   pinctrl-0 = <_pwr>;
+   pinctrl-names = "default";
+   regulator-name = "vcc_wifi";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   startup-delay-us = <10>;
+   vin-supply = <_io>;
+   

[U-Boot] [PATCH v3 05/19] rockchip: rk3066: add rk3066 platform devicetree file

2017-08-16 Thread Paweł Jarosz
rk3066 peripherials include usb, i2c, pwm, gpio, sdio, sdmmc, emmc, spi,
watchdog and uart

Signed-off-by: Paweł Jarosz 
Reviewed-by: Simon Glass 
Acked-by: Philipp Tomsich 
Reviewed-by: Philipp Tomsich 
---
Changes since v1:
- added nand dts node

Changes since v2:
- none

 arch/arm/dts/rk3066a.dtsi | 707 ++
 1 file changed, 707 insertions(+)
 create mode 100644 arch/arm/dts/rk3066a.dtsi

diff --git a/arch/arm/dts/rk3066a.dtsi b/arch/arm/dts/rk3066a.dtsi
new file mode 100644
index 000..92ee1c2
--- /dev/null
+++ b/arch/arm/dts/rk3066a.dtsi
@@ -0,0 +1,707 @@
+/*
+ * Copyright (c) 2013 MundoReader S.L.
+ * Author: Heiko Stuebner 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include "rk3xxx.dtsi"
+
+/ {
+   compatible = "rockchip,rk3066a";
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   enable-method = "rockchip,rk3066-smp";
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a9";
+   next-level-cache = <>;
+   reg = <0x0>;
+   operating-points = <
+   /* kHzuV */
+   1416000 130
+   120 1175000
+   1008000 1125000
+   816000  1125000
+   60  110
+   504000  110
+   312000  1075000
+   >;
+   clock-latency = <4>;
+   clocks = < ARMCLK>;
+   };
+   cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a9";
+   next-level-cache = <>;
+   reg = <0x1>;
+   };
+   };
+
+   sram: sram@1008 {
+   compatible = "mmio-sram";
+   reg = <0x1008 0x1>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x1008 0x1>;
+
+   smp-sram@0 {
+   compatible = "rockchip,rk3066-smp-sram";
+   reg = <0x0 0x50>;
+   };
+   };
+
+   i2s0: i2s@10118000 {
+   compatible = "rockchip,rk3066-i2s";
+   reg = <0x10118000 0x2000>;
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_bus>;
+   dmas = <_s 4>, <_s 5>;
+   dma-names = "tx", "rx";
+   clock-names = "i2s_hclk", "i2s_clk";
+   clocks = < HCLK_I2S0>, < SCLK_I2S0>;
+   rockchip,playback-channels = <8>;
+   rockchip,capture-channels = <2>;
+   status = "disabled";
+   };
+
+   i2s1: i2s@1011a000 {
+   compatible = "rockchip,rk3066-i2s";
+   reg = <0x1011a000 0x2000>;
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_bus>;
+   dmas = <_s 6>, <_s 7>;
+   dma-names = "tx", "rx";
+   clock-names = "i2s_hclk", "i2s_clk";
+   clocks = < HCLK_I2S1>, < SCLK_I2S1>;
+   rockchip,playback-channels = <2>;
+   rockchip,capture-channels = <2>;
+   status = "disabled";
+   };
+
+   i2s2: i2s@1011c000 {
+   compatible = "rockchip,rk3066-i2s";
+   reg = <0x1011c000 0x2000>;
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_bus>;
+   dmas = <_s 9>, <_s 10>;
+   dma-names = "tx", "rx";
+   clock-names = "i2s_hclk", "i2s_clk";
+   clocks = < HCLK_I2S2>, < SCLK_I2S2>;
+   rockchip,playback-channels = <2>;
+   rockchip,capture-channels = <2>;
+   status = "disabled";
+   };
+
+   nandc: nandc@1050 {
+   compatible = "rockchip,nandc";
+   reg = <0x1050 0x2000>;
+   interrupts = ;
+   clock-names = "hclk";
+   clocks = < HCLK_NANDC0>;
+   status = "disabled";
+   };
+
+   cru: clock-controller@2000 {
+   compatible = "rockchip,rk3066a-cru";
+   reg = <0x2000 0x1000>;
+   rockchip,grf = <>;
+   u-boot,dm-pre-reloc;
+
+   

[U-Boot] [PATCH v3 06/19] rockchip: rk3066: add core support

2017-08-16 Thread Paweł Jarosz
Add core skeleton for rk3066

Signed-off-by: Paweł Jarosz 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- updated to shifted masks
- moved syscon.h below spl.h
- changed error to debug and return error reason
- changed Cortex-A7 to Cortex-A9
- added nand support
- added dfu support
- removed dram_init
- reset timer before enable
- moved configs to board config file
- moved arm clk setup to tpl
- moved ddr setup to tpl
- moved to boot device bootrom

Changes since v2:
- none

 arch/arm/mach-rockchip/Kconfig|  16 +++
 arch/arm/mach-rockchip/Makefile   |   4 +
 arch/arm/mach-rockchip/rk3066-board-spl.c | 139 
 arch/arm/mach-rockchip/rk3066-board-tpl.c |  90 
 arch/arm/mach-rockchip/rk3066-board.c | 150 ++
 arch/arm/mach-rockchip/rk3066/Kconfig |  31 ++
 arch/arm/mach-rockchip/rk3066/Makefile|   8 ++
 arch/arm/mach-rockchip/rk3066/clk_rk3066.c|  33 ++
 arch/arm/mach-rockchip/rk3066/syscon_rk3066.c |  54 ++
 include/configs/rk3066_common.h   |  99 +
 10 files changed, 624 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3066-board-spl.c
 create mode 100644 arch/arm/mach-rockchip/rk3066-board-tpl.c
 create mode 100644 arch/arm/mach-rockchip/rk3066-board.c
 create mode 100644 arch/arm/mach-rockchip/rk3066/Kconfig
 create mode 100644 arch/arm/mach-rockchip/rk3066/Makefile
 create mode 100644 arch/arm/mach-rockchip/rk3066/clk_rk3066.c
 create mode 100644 arch/arm/mach-rockchip/rk3066/syscon_rk3066.c
 create mode 100644 include/configs/rk3066_common.h

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index d9b25d5..810353f 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -11,6 +11,21 @@ config ROCKCHIP_RK3036
  and video codec support. Peripherals include Gigabit Ethernet,
  USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
 
+config ROCKCHIP_RK3066
+   bool "Support Rockchip RK3066"
+   select CPU_V7
+   select SUPPORT_SPL
+   select SUPPORT_TPL
+   select SPL
+   select TPL
+   select BOARD_LATE_INIT
+   select ROCKCHIP_BROM_HELPER
+   help
+ The Rockchip RK3066 is a ARM-based SoC with a dual-core Cortex-A9
+ including NEON and GPU, Mali-400 graphics, several DDR3 options
+ and video codec support. Peripherals include ethernet, USB2 host
+ and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
+
 config ROCKCHIP_RK3188
bool "Support Rockchip RK3188"
select CPU_V7
@@ -164,6 +179,7 @@ config SPL_MMC_SUPPORT
default y if !SPL_ROCKCHIP_BACK_TO_BROM
 
 source "arch/arm/mach-rockchip/rk3036/Kconfig"
+source "arch/arm/mach-rockchip/rk3066/Kconfig"
 source "arch/arm/mach-rockchip/rk3188/Kconfig"
 source "arch/arm/mach-rockchip/rk322x/Kconfig"
 source "arch/arm/mach-rockchip/rk3288/Kconfig"
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index 79e9704..ae878ef 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -11,10 +11,12 @@
 obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
 obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o save_boot_param.o
 
+obj-tpl-$(CONFIG_ROCKCHIP_RK3066) += rk3066-board-tpl.o
 obj-tpl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-tpl.o
 obj-tpl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-tpl.o
 
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
+obj-spl-$(CONFIG_ROCKCHIP_RK3066) += rk3066-board-spl.o
 obj-spl-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board-spl.o
 obj-spl-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board-spl.o
 obj-spl-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board-spl.o
@@ -22,6 +24,7 @@ obj-spl-$(CONFIG_ROCKCHIP_RK3368) += rk3368-board-spl.o 
spl-boot-order.o
 obj-spl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-spl.o spl-boot-order.o
 
 ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
+obj-$(CONFIG_ROCKCHIP_RK3066) += rk3066-board.o
 obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board.o
 obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o
@@ -35,6 +38,7 @@ obj-y += rk_timer.o
 endif
 
 obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
+obj-$(CONFIG_ROCKCHIP_RK3066) += rk3066/
 ifndef CONFIG_TPL_BUILD
 obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188/
 endif
diff --git a/arch/arm/mach-rockchip/rk3066-board-spl.c 
b/arch/arm/mach-rockchip/rk3066-board-spl.c
new file mode 100644
index 000..9acdd83
--- /dev/null
+++ b/arch/arm/mach-rockchip/rk3066-board-spl.c
@@ -0,0 +1,139 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[U-Boot] [PATCH v3 04/19] rockchip: rk3066: add clock driver for rk3066 soc

2017-08-16 Thread Paweł Jarosz
Add clock driver for rk3066 platform.

Signed-off-by: Paweł Jarosz 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- updated to shifted masks
- moved clk init to tpl

Changes since v2:
- none

 arch/arm/include/asm/arch-rockchip/cru_rk3066.h | 189 
 drivers/clk/rockchip/Makefile   |   1 +
 drivers/clk/rockchip/clk_rk3066.c   | 587 
 3 files changed, 777 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3066.h
 create mode 100644 drivers/clk/rockchip/clk_rk3066.c

diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3066.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3066.h
new file mode 100644
index 000..c4a6951
--- /dev/null
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3066.h
@@ -0,0 +1,189 @@
+/*
+ * (C) Copyright 2016 Heiko Stuebner 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#ifndef _ASM_ARCH_CRU_RK3066_H
+#define _ASM_ARCH_CRU_RK3066_H
+
+#define OSC_HZ (24 * 1000 * 1000)
+
+#define APLL_HZ(1416 * 100)
+#define APLL_SAFE_HZ   (600 * 100)
+#define GPLL_HZ(594 * 100)
+#define CPLL_HZ(384 * 100)
+
+/* The SRAM is clocked off aclk_cpu, so we want to max it out for boot speed */
+#define CPU_ACLK_HZ29700
+#define CPU_HCLK_HZ14850
+#define CPU_PCLK_HZ7425
+#define CPU_H2P_HZ 7425
+
+#define PERI_ACLK_HZ   14850
+#define PERI_HCLK_HZ   14850
+#define PERI_PCLK_HZ   7425
+
+/* Private data for the clock driver - used by rockchip_get_cru() */
+struct rk3066_clk_priv {
+   struct rk3066_grf *grf;
+   struct rk3066_cru *cru;
+   ulong rate;
+   bool has_bwadj;
+};
+
+struct rk3066_cru {
+   struct rk3066_pll {
+   u32 con0;
+   u32 con1;
+   u32 con2;
+   u32 con3;
+   } pll[4];
+   u32 cru_mode_con;
+   u32 cru_clksel_con[35];
+   u32 cru_clkgate_con[10];
+   u32 reserved1[2];
+   u32 cru_glb_srst_fst_value;
+   u32 cru_glb_srst_snd_value;
+   u32 reserved2[2];
+   u32 cru_softrst_con[9];
+   u32 cru_misc_con;
+   u32 reserved3[2];
+   u32 cru_glb_cnt_th;
+};
+check_member(rk3066_cru, cru_glb_cnt_th, 0x0140);
+
+/* CRU_CLKSEL0_CON */
+enum {
+   /* a9_core_div: core = core_src / (a9_core_div + 1) */
+   A9_CORE_DIV_SHIFT   = 9,
+   A9_CORE_DIV_MASK= 0x1f << A9_CORE_DIV_SHIFT,
+   CORE_PLL_SHIFT  = 8,
+   CORE_PLL_MASK   = 1 << CORE_PLL_SHIFT,
+   CORE_PLL_SELECT_APLL= 0,
+   CORE_PLL_SELECT_GPLL,
+
+   /* core peri div: core:core_peri = 2:1, 4:1, 8:1 or 16:1 */
+   CORE_PERI_DIV_SHIFT = 6,
+   CORE_PERI_DIV_MASK  = 3 << CORE_PERI_DIV_SHIFT,
+
+   /* aclk_cpu pll selection */
+   CPU_ACLK_PLL_SHIFT  = 5,
+   CPU_ACLK_PLL_MASK   = 1 << CPU_ACLK_PLL_SHIFT,
+   CPU_ACLK_PLL_SELECT_APLL= 0,
+   CPU_ACLK_PLL_SELECT_GPLL,
+
+   /* a9_cpu_div: aclk_cpu = cpu_src / (a9_cpu_div + 1) */
+   A9_CPU_DIV_SHIFT= 0,
+   A9_CPU_DIV_MASK = 0x1f << A9_CPU_DIV_SHIFT,
+};
+
+/* CRU_CLKSEL1_CON */
+enum {
+   /* ahb2apb_pclk_div: hclk_cpu:pclk_cpu = 1:1, 2:1 or 4:1 */
+   AHB2APB_DIV_SHIFT   = 14,
+   AHB2APB_DIV_MASK= 3 << AHB2APB_DIV_SHIFT,
+
+   /* cpu_pclk_div: aclk_cpu:pclk_cpu = 1:1, 2:1, 4:1 or 8:1 */
+   CPU_PCLK_DIV_SHIFT  = 12,
+   CPU_PCLK_DIV_MASK   = 3 << CPU_PCLK_DIV_SHIFT,
+
+   /* cpu_hclk_div: aclk_cpu:hclk_cpu = 1:1, 2:1 or 4:1 */
+   CPU_HCLK_DIV_SHIFT  = 8,
+   CPU_HCLK_DIV_MASK   = 3 << CPU_HCLK_DIV_SHIFT,
+
+   /* core_aclk_div: cire:aclk_core = 1:1, 2:1, 3:1, 4:1 or 8:1 */
+   CORE_ACLK_DIV_SHIFT = 3,
+   CORE_ACLK_DIV_MASK  = 7 << CORE_ACLK_DIV_SHIFT,
+};
+
+/* CRU_CLKSEL10_CON */
+enum {
+   PERI_SEL_PLL_SHIFT  = 15,
+   PERI_SEL_PLL_MASK   = 1 << PERI_SEL_PLL_SHIFT,
+   PERI_SEL_CPLL   = 0,
+   PERI_SEL_GPLL,
+
+   /* peri pclk div: aclk_bus:pclk_bus = 1:1, 2:1, 4:1 or 8:1 */
+   PERI_PCLK_DIV_SHIFT = 12,
+   PERI_PCLK_DIV_MASK  = 3 << PERI_PCLK_DIV_SHIFT,
+
+   /* peripheral bus hclk div:aclk_bus: hclk_bus = 1:1, 2:1 or 4:1 */
+   PERI_HCLK_DIV_SHIFT = 8,
+   PERI_HCLK_DIV_MASK  = 3 << PERI_HCLK_DIV_SHIFT,
+
+   /* peri aclk div: aclk_peri = periph_src / (peri_aclk_div + 1) */
+   PERI_ACLK_DIV_SHIFT = 0,
+   PERI_ACLK_DIV_MASK  = 0x1f << PERI_ACLK_DIV_SHIFT,
+};
+/* CRU_CLKSEL11_CON */
+enum {
+   MMC0_DIV_SHIFT  = 0,
+   MMC0_DIV_MASK   = 0x3f << MMC0_DIV_SHIFT,
+};
+
+/* CRU_CLKSEL12_CON */
+enum {
+   UART_PLL_SHIFT  = 15,
+   UART_PLL_MASK   = 1 << UART_PLL_SHIFT,
+   UART_PLL_SELECT_GENERAL = 0,
+   UART_PLL_SELECT_CODEC,

[U-Boot] [PATCH v3 03/19] rockchip: rk3066: add sysreset driver

2017-08-16 Thread Paweł Jarosz
Add support for system reset for rk3066 socs.

Signed-off-by: Paweł Jarosz 
Reviewed-by: Simon Glass 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- updated to shifted masks

Changes since v2:
- none

 drivers/sysreset/Makefile  |  1 +
 drivers/sysreset/sysreset_rk3066.c | 61 ++
 2 files changed, 62 insertions(+)
 create mode 100644 drivers/sysreset/sysreset_rk3066.c

diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index a5200d3..7d4d0cd 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_ROCKCHIP_RK3036) += sysreset_rk3036.o
 endif
+obj-$(CONFIG_ROCKCHIP_RK3066) += sysreset_rk3066.o
 obj-$(CONFIG_ROCKCHIP_RK3188) += sysreset_rk3188.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += sysreset_rk3288.o
 obj-$(CONFIG_ROCKCHIP_RK3328) += sysreset_rk3328.o
diff --git a/drivers/sysreset/sysreset_rk3066.c 
b/drivers/sysreset/sysreset_rk3066.c
new file mode 100644
index 000..b5dcb9a
--- /dev/null
+++ b/drivers/sysreset/sysreset_rk3066.c
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int rk3066_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+   struct rk3066_cru *cru = rockchip_get_cru();
+   struct rk3066_grf *grf;
+
+   if (IS_ERR(cru))
+   return PTR_ERR(cru);
+
+   switch (type) {
+   case SYSRESET_WARM:
+   grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+   if (IS_ERR(grf))
+   return -EPROTONOSUPPORT;
+   /*
+* warm-reset keeps the remap value,
+* so make sure it's disabled.
+*/
+   rk_clrsetreg(>soc_con0,
+   NOC_REMAP_MASK, 0 << NOC_REMAP_SHIFT);
+
+   rk_clrreg(>cru_mode_con, 0x);
+   writel(0xeca8, >cru_glb_srst_snd_value);
+   break;
+   case SYSRESET_COLD:
+   rk_clrreg(>cru_mode_con, 0x);
+   writel(0xfdb9, >cru_glb_srst_fst_value);
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
+
+static struct sysreset_ops rk3066_sysreset = {
+   .request= rk3066_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_rk3066) = {
+   .name   = "rk3066_sysreset",
+   .id = UCLASS_SYSRESET,
+   .ops= _sysreset,
+};
-- 
2.7.4

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


[U-Boot] [PATCH v3 02/19] rockchip: rk3066: add rk3066 pinctrl driver

2017-08-16 Thread Paweł Jarosz
Add driver supporting pin multiplexing on rk3066 platform.

Signed-off-by: Paweł Jarosz 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- updated to shifted masks
- added nand support

Changes since v2:
- none

 arch/arm/include/asm/arch-rockchip/periph.h |   1 +
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/rockchip/Makefile   |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3066.c   | 340 
 4 files changed, 351 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3066.c

diff --git a/arch/arm/include/asm/arch-rockchip/periph.h 
b/arch/arm/include/asm/arch-rockchip/periph.h
index 9f4bc2e..6c8c77d 100644
--- a/arch/arm/include/asm/arch-rockchip/periph.h
+++ b/arch/arm/include/asm/arch-rockchip/periph.h
@@ -43,6 +43,7 @@ enum periph_id {
PERIPH_ID_HDMI,
PERIPH_ID_GMAC,
PERIPH_ID_SFC,
+   PERIPH_ID_NAND,
 
PERIPH_ID_COUNT,
 
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index bcbe4a1..c9eb49d 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -168,6 +168,15 @@ config PINCTRL_ROCKCHIP_RK3036
  the GPIO definitions and pin control functions for each available
  multiplex function.
 
+config PINCTRL_ROCKCHIP_RK3066
+bool "Rockchip rk3066 pin control driver"
+depends on DM
+help
+  Support pin multiplexing control on Rockchip rk3066 SoCs. The driver 
is
+  controlled by a device tree node which contains both the GPIO
+  definitions and pin control functions for each available multiplex
+  function.
+
 config PINCTRL_ROCKCHIP_RK3188
bool "Rockchip rk3188 pin control driver"
depends on DM
diff --git a/drivers/pinctrl/rockchip/Makefile 
b/drivers/pinctrl/rockchip/Makefile
index 5251771..65923f9 100644
--- a/drivers/pinctrl/rockchip/Makefile
+++ b/drivers/pinctrl/rockchip/Makefile
@@ -6,6 +6,7 @@
 #
 
 obj-$(CONFIG_PINCTRL_ROCKCHIP_RK3036) += pinctrl_rk3036.o
+obj-$(CONFIG_PINCTRL_ROCKCHIP_RK3066) += pinctrl_rk3066.o
 obj-$(CONFIG_PINCTRL_ROCKCHIP_RK3188) += pinctrl_rk3188.o
 obj-$(CONFIG_PINCTRL_ROCKCHIP_RK322X) += pinctrl_rk322x.o
 obj-$(CONFIG_PINCTRL_ROCKCHIP_RK3288) += pinctrl_rk3288.o
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3066.c 
b/drivers/pinctrl/rockchip/pinctrl_rk3066.c
new file mode 100644
index 000..79e0a54
--- /dev/null
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3066.c
@@ -0,0 +1,340 @@
+/*
+ * Pinctrl driver for Rockchip 3066 SoCs
+ * (C) Copyright 2017 Paweł Jarosz 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct rk3066_pinctrl_priv {
+   struct rk3066_grf *grf;
+};
+
+static void pinctrl_rk3066_pwm_config(struct rk3066_grf *grf, int pwm_id)
+{
+   switch (pwm_id) {
+   case PERIPH_ID_PWM0:
+   rk_clrsetreg(>gpio0a_iomux, GPIO0A3_MASK,
+GPIO0A3_PWM0 << GPIO0A3_SHIFT);
+   break;
+   case PERIPH_ID_PWM1:
+   rk_clrsetreg(>gpio0a_iomux, GPIO0A4_MASK,
+GPIO0A4_PWM1 << GPIO0A4_SHIFT);
+   break;
+   case PERIPH_ID_PWM2:
+   rk_clrsetreg(>gpio0d_iomux, GPIO0D6_MASK,
+GPIO0D6_PWM2 << GPIO0D6_SHIFT);
+   break;
+   case PERIPH_ID_PWM3:
+   rk_clrsetreg(>gpio0d_iomux, GPIO0D7_MASK,
+GPIO0D7_PWM3 << GPIO0D7_SHIFT);
+   break;
+   default:
+   debug("pwm id = %d iomux error!\n", pwm_id);
+   break;
+   }
+}
+
+static void pinctrl_rk3066_i2c_config(struct rk3066_grf *grf, int i2c_id)
+{
+   switch (i2c_id) {
+   case PERIPH_ID_I2C0:
+   rk_clrsetreg(>gpio2d_iomux,
+GPIO2D4_MASK | GPIO2D5_MASK,
+GPIO2D4_I2C0_SDA << GPIO2D4_SHIFT |
+GPIO2D5_I2C0_SCL << GPIO2D5_SHIFT);
+   rk_clrsetreg(>soc_con1, 1 << RKI2C0_SEL_SHIFT,
+1 << RKI2C0_SEL_SHIFT);
+   break;
+   case PERIPH_ID_I2C1:
+   rk_clrsetreg(>gpio2d_iomux,
+GPIO2D6_MASK | GPIO2D7_MASK,
+GPIO2D6_I2C1_SDA << GPIO2D6_SHIFT |
+GPIO2D7_I2C1_SCL << GPIO2D7_SHIFT);
+   rk_clrsetreg(>soc_con1, 1 << RKI2C1_SEL_SHIFT,
+1 << RKI2C1_SEL_SHIFT);
+   break;
+   case PERIPH_ID_I2C2:
+   rk_clrsetreg(>gpio3a_iomux,
+GPIO3A1_MASK | GPIO3A0_MASK,
+GPIO3A1_I2C2_SCL << GPIO3A1_SHIFT |
+

[U-Boot] [PATCH v3 01/19] rockchip: rk3066: add grf header file

2017-08-16 Thread Paweł Jarosz
grf is needed by various drivers for rk3066 soc.

Signed-off-by: Paweł Jarosz 
Acked-by: Philipp Tomsich 
---
Changes since v1:
- updated to shifted masks

Changes since v2:
- none

 arch/arm/include/asm/arch-rockchip/grf_rk3066.h | 621 
 1 file changed, 621 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3066.h

diff --git a/arch/arm/include/asm/arch-rockchip/grf_rk3066.h 
b/arch/arm/include/asm/arch-rockchip/grf_rk3066.h
new file mode 100644
index 000..be40884
--- /dev/null
+++ b/arch/arm/include/asm/arch-rockchip/grf_rk3066.h
@@ -0,0 +1,621 @@
+/*
+ * Copyright (c) 2017 Paweł Jarosz 
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+
+#ifndef _ASM_ARCH_GRF_RK3066_H
+#define _ASM_ARCH_GRF_RK3066_H
+
+struct rk3066_grf_gpio_lh {
+   u32 l;
+   u32 h;
+};
+
+struct rk3066_grf {
+   struct rk3066_grf_gpio_lh gpio_dir[7];
+   struct rk3066_grf_gpio_lh gpio_do[7];
+   struct rk3066_grf_gpio_lh gpio_en[7];
+
+   u32 gpio0a_iomux;
+   u32 gpio0b_iomux;
+   u32 gpio0c_iomux;
+   u32 gpio0d_iomux;
+
+   u32 gpio1a_iomux;
+   u32 gpio1b_iomux;
+   u32 gpio1c_iomux;
+   u32 gpio1d_iomux;
+
+   u32 gpio2a_iomux;
+   u32 gpio2b_iomux;
+   u32 gpio2c_iomux;
+   u32 gpio2d_iomux;
+
+   u32 gpio3a_iomux;
+   u32 gpio3b_iomux;
+   u32 gpio3c_iomux;
+   u32 gpio3d_iomux;
+
+   u32 gpio4a_iomux;
+   u32 gpio4b_iomux;
+   u32 gpio4c_iomux;
+   u32 gpio4d_iomux;
+
+   u32 reserved0[5];
+
+   u32 gpio6b_iomux;
+
+   u32 reserved1[2];
+
+   struct rk3066_grf_gpio_lh gpio_pull[7];
+
+   u32 soc_con0;
+   u32 soc_con1;
+   u32 soc_con2;
+
+   u32 soc_status0;
+
+   u32 dmac1_con[3];
+   u32 dmac2_con[4];
+
+   u32 uoc0_con[3];
+   u32 uoc1_con[4];
+   u32 ddrc_con;
+   u32 ddrc_stat;
+
+   u32 reserved2[10];
+
+   u32 os_reg[4];
+};
+check_member(rk3066_grf, os_reg[3], 0x01d4);
+
+/* GRF_GPIO0A_IOMUX */
+enum {
+   GPIO0A6_SHIFT   = 12,
+   GPIO0A6_MASK= 1 << GPIO0A6_SHIFT,
+   GPIO0A6_GPIO= 0,
+   GPIO0A6_HOST_DRV_VBUS,
+
+   GPIO0A5_SHIFT   = 10,
+   GPIO0A5_MASK= 1 << GPIO0A5_SHIFT,
+   GPIO0A5_GPIO= 0,
+   GPIO0A5_OTG_DRV_VBUS,
+
+   GPIO0A4_SHIFT   = 8,
+   GPIO0A4_MASK= 1 << GPIO0A4_SHIFT,
+   GPIO0A4_GPIO= 0,
+   GPIO0A4_PWM1,
+
+   GPIO0A3_SHIFT   = 6,
+   GPIO0A3_MASK= 1 << GPIO0A3_SHIFT,
+   GPIO0A3_GPIO= 0,
+   GPIO0A3_PWM0
+};
+
+/* GRF_GPIO0D_IOMUX */
+enum {
+   GPIO0D7_SHIFT   = 14,
+   GPIO0D7_MASK= 1 << GPIO0D7_SHIFT,
+   GPIO0D7_GPIO= 0,
+   GPIO0D7_PWM3,
+
+   GPIO0D6_SHIFT   = 12,
+   GPIO0D6_MASK= 1 << GPIO0D6_SHIFT,
+   GPIO0D6_GPIO= 0,
+   GPIO0D6_PWM2
+};
+
+/* GRF_GPIO1A_IOMUX */
+enum {
+   GPIO1A7_SHIFT   = 14,
+   GPIO1A7_MASK= 3 << GPIO1A7_SHIFT,
+   GPIO1A7_GPIO= 0,
+   GPIO1A7_UART1_RTS_N,
+   GPIO1A7_SPI0_TXD,
+
+   GPIO1A6_SHIFT   = 12,
+   GPIO1A6_MASK= 3 << GPIO1A6_SHIFT,
+   GPIO1A6_GPIO= 0,
+   GPIO1A6_UART1_CTS_N,
+   GPIO1A6_SPI0_RXD,
+
+   GPIO1A5_SHIFT   = 10,
+   GPIO1A5_MASK= 3 << GPIO1A5_SHIFT,
+   GPIO1A5_GPIO= 0,
+   GPIO1A5_UART1_SOUT,
+   GPIO1A5_SPI0_CLK,
+
+   GPIO1A4_SHIFT   = 8,
+   GPIO1A4_MASK= 3 << GPIO1A4_SHIFT,
+   GPIO1A4_GPIO= 0,
+   GPIO1A4_UART1_SIN,
+   GPIO1A4_SPI0_CSN0,
+
+   GPIO1A3_SHIFT   = 6,
+   GPIO1A3_MASK= 1 << GPIO1A3_SHIFT,
+   GPIO1A3_GPIO= 0,
+   GPIO1A3_UART0_RTS_N,
+
+   GPIO1A2_SHIFT   = 4,
+   GPIO1A2_MASK= 1 << GPIO1A2_SHIFT,
+   GPIO1A2_GPIO= 0,
+   GPIO1A2_UART0_CTS_N,
+
+   GPIO1A1_SHIFT   = 2,
+   GPIO1A1_MASK= 1 << GPIO1A1_SHIFT,
+   GPIO1A1_GPIO= 0,
+   GPIO1A1_UART0_SOUT,
+
+   GPIO1A0_SHIFT   = 0,
+   GPIO1A0_MASK= 1 << GPIO1A0_SHIFT,
+   GPIO1A0_GPIO= 0,
+   GPIO1A0_UART0_SIN
+};
+
+/* GRF_GPIO1B_IOMUX */
+enum {
+   GPIO1B1_SHIFT   = 2,
+   GPIO1B1_MASK= 1 << GPIO1B1_SHIFT,
+   GPIO1B1_GPIO= 0,
+   GPIO1B1_UART2_SOUT,
+
+   GPIO1B0_SHIFT   = 0,
+   GPIO1B0_MASK= 1 << GPIO1B0_SHIFT,
+   GPIO1B0_GPIO= 0,
+   GPIO1B0_UART2_SIN
+};
+
+/* GRF_GPIO2C_IOMUX */
+enum {
+   GPIO2C7_SHIFT   = 14,
+   GPIO2C7_MASK= 3 << GPIO2C7_SHIFT,
+   

[U-Boot] [PATCH v3 00/19] add support for rk3066 platform.

2017-08-16 Thread Paweł Jarosz
This patch serie adds support for Rockchip RK3066 processor.

Paweł Jarosz (19):
  rockchip: rk3066: add grf header file
  rockchip: rk3066: add rk3066 pinctrl driver
  rockchip: rk3066: add sysreset driver
  rockchip: rk3066: add clock driver for rk3066 soc
  rockchip: rk3066: add rk3066 platform devicetree file
  rockchip: rk3066: add core support
  rockchip: rk3066: add mk808 board files
  rockchip: rk3066: add sdram driver
  mtd: nand: add support for the Sandisk SDTNQGAMA chip
  mtd: nand: add the rockchip nand controller driver
  rockchip: mkimage: add support for rockchip nand boot image
  rockchip: board: rk3066: convert board_usb_init to live tree functions
  ARM: dts: rockchip: prefer u-boot,dm-pre-reloc rather than
u-boot,dm-spl
  mmc: dw_mmc: support transfer mode autodetection
  mmc: dw_mmc: rockchip: add support for rk3066 sdmmc
  armv7: support rk3066 early back to bootrom in vector.S
  rockchip: sysreset: deduplicate rk3066 and rk3188 sysreset drivers
  dfu: fix spl build
  mtd: nand: spl: allow build nand_bbt, nand_ids and nand_util

 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/rk3066a-mk808.dts | 189 +
 arch/arm/dts/rk3066a.dtsi  | 707 +++
 arch/arm/dts/rk3xxx.dtsi   |   8 +-
 arch/arm/include/asm/arch-rockchip/boot0.h |  14 +
 arch/arm/include/asm/arch-rockchip/cru_rk3066.h| 189 +
 arch/arm/include/asm/arch-rockchip/grf_rk3066.h| 621 ++
 arch/arm/include/asm/arch-rockchip/periph.h|   1 +
 .../include/asm/arch-rockchip/sysreset_common.h|  20 +
 arch/arm/lib/vectors.S |  18 +-
 arch/arm/mach-rockchip/Kconfig |  16 +
 arch/arm/mach-rockchip/Makefile|   7 +
 arch/arm/mach-rockchip/rk3066-board-spl.c  | 139 +++
 arch/arm/mach-rockchip/rk3066-board-tpl.c  |  90 ++
 arch/arm/mach-rockchip/rk3066-board.c  | 112 +++
 arch/arm/mach-rockchip/rk3066/Kconfig  |  31 +
 arch/arm/mach-rockchip/rk3066/Makefile |   9 +
 arch/arm/mach-rockchip/rk3066/clk_rk3066.c |  33 +
 arch/arm/mach-rockchip/rk3066/sdram_rk3066.c   | 943 +
 arch/arm/mach-rockchip/rk3066/syscon_rk3066.c  |  54 ++
 arch/arm/mach-rockchip/sysreset-common.c   |  39 +
 board/rikomagic/mk808_rk3066/Kconfig   |  15 +
 board/rikomagic/mk808_rk3066/MAINTAINERS   |   6 +
 board/rikomagic/mk808_rk3066/Makefile  |   7 +
 board/rikomagic/mk808_rk3066/mk808_rk3066.c|  10 +
 common/image.c |   1 +
 configs/mk808_defconfig| 115 +++
 drivers/clk/rockchip/Makefile  |   1 +
 drivers/clk/rockchip/clk_rk3066.c  | 587 +
 drivers/dfu/dfu_nand.c |   6 +-
 drivers/mmc/dw_mmc.c   |   8 +
 drivers/mmc/rockchip_dw_mmc.c  |   1 +
 drivers/mtd/nand/Kconfig   |   6 +
 drivers/mtd/nand/Makefile  |   4 +
 drivers/mtd/nand/nand_ids.c|   3 +
 drivers/mtd/nand/rockchip_nand.c   | 660 ++
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/rockchip/Makefile  |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3066.c  | 340 
 drivers/sysreset/Makefile  |   1 +
 drivers/sysreset/sysreset_rk3066.c |  49 ++
 drivers/sysreset/sysreset_rk3188.c |  35 +-
 include/configs/mk808_rk3066.h |  61 ++
 include/configs/rk3066_common.h|  99 +++
 include/dwmmc.h|   4 +
 include/fdtdec.h   |   1 +
 include/image.h|   1 +
 lib/fdtdec.c   |   1 +
 tools/Makefile |   2 +-
 tools/imagetool.h  |   1 +
 tools/mkimage.c|   8 +-
 tools/rkcommon.c   |  10 +-
 tools/rkcommon.h   |  10 +-
 tools/rknand.c | 156 
 tools/rksd.c   |   2 +-
 tools/rkspi.c  |   2 +-
 56 files changed, 5416 insertions(+), 48 deletions(-)
 create mode 100644 arch/arm/dts/rk3066a-mk808.dts
 create mode 100644 arch/arm/dts/rk3066a.dtsi
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3066.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3066.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/sysreset_common.h
 create mode 100644 arch/arm/mach-rockchip/rk3066-board-spl.c
 create mode 100644 

[U-Boot] [PATCH v2 7/8] apalis/colibri_imx6: use independent USB PID for SPL

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Use a completely independent USB Product ID for SPL. This allows
to differentiate a SDP running in SPL and SDP running in a U-Boot
which could not read the config block successfully.

Signed-off-by: Stefan Agner 
Acked-by: Max Krummenacher 
---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c   | 13 +
 board/toradex/colibri_imx6/colibri_imx6.c | 13 +
 2 files changed, 26 insertions(+)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 8e5613cb12..edaca5d346 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1233,6 +1234,18 @@ void reset_cpu(ulong addr)
 {
 }
 
+#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   unsigned short usb_pid;
+
+   usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
+   put_unaligned(usb_pid, >idProduct);
+
+   return 0;
+}
+#endif
+
 #endif
 
 static struct mxc_serial_platdata mxc_serial_plat = {
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index cbf7aa952a..0cc958a0a8 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1118,6 +1119,18 @@ void reset_cpu(ulong addr)
 {
 }
 
+#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   unsigned short usb_pid;
+
+   usb_pid = TORADEX_USB_PRODUCT_NUM_OFFSET + 0xfff;
+   put_unaligned(usb_pid, >idProduct);
+
+   return 0;
+}
+#endif
+
 #endif
 
 static struct mxc_serial_platdata mxc_serial_plat = {
-- 
2.14.1

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


[U-Boot] [PATCH v2 5/8] spl: add serial download protocol (SDP) support

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Add USB serial download protocol support to SPL. If the SoC started
in recovery mode the SPL will immediately switch to SDP and wait for
further downloads/commands from the host side.

Signed-off-by: Stefan Agner 
Reviewed-by: Stefano Babic 
---

Changes in v2:
- Changed function signature of sdp_init/sdp_handle
- Use BOOT_DEVICE_BOARD

 common/spl/Kconfig  |  6 ++
 common/spl/Makefile |  1 +
 common/spl/spl_sdp.c| 37 +
 drivers/usb/gadget/Makefile |  1 +
 4 files changed, 45 insertions(+)
 create mode 100644 common/spl/spl_sdp.c

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 5176857506..b3436b3c28 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -668,6 +668,12 @@ config SPL_DFU_RAM
 
 endchoice
 
+config SPL_USB_SDP_SUPPORT
+   bool "Support SDP (Serial Download Protocol)"
+   help
+ Enable Serial Download Protocol (SDP) device support in SPL. This
+ allows to download images into memory and execute (jump to) them
+ using the same protocol as implemented by the i.MX family's boot ROM.
 endif
 
 config SPL_WATCHDOG_SUPPORT
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 112b3e6022..6255d4f73c 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -30,4 +30,5 @@ obj-$(CONFIG_$(SPL_TPL_)SATA_SUPPORT) += spl_sata.o
 obj-$(CONFIG_$(SPL_TPL_)DFU_SUPPORT) += spl_dfu.o
 obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
 obj-$(CONFIG_$(SPL_TPL_)RAM_SUPPORT) += spl_ram.o
+obj-$(CONFIG_$(SPL_TPL_)USB_SDP_SUPPORT) += spl_sdp.o
 endif
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
new file mode 100644
index 00..350bcdb056
--- /dev/null
+++ b/common/spl/spl_sdp.c
@@ -0,0 +1,37 @@
+/*
+ * (C) Copyright 2016 Toradex
+ * Author: Stefan Agner 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int spl_sdp_load_image(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
+{
+   int ret;
+   const int controller_index = 0;
+
+   g_dnl_clear_detach();
+   g_dnl_register("usb_dnl_sdp");
+
+   ret = sdp_init(controller_index);
+   if (ret) {
+   error("SDP init failed: %d", ret);
+   return -ENODEV;
+   }
+
+   /* This command typically does not return but jumps to an image */
+   sdp_handle(controller_index);
+   error("SDP ended");
+
+   return -EINVAL;
+}
+SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 6a007d1bcb..7258099c1c 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_ETHER) += epautoconf.o config.o usbstring.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += g_dnl.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += f_dfu.o
+obj-$(CONFIG_SPL_USB_SDP_SUPPORT) += f_sdp.o
 endif
 
 # new USB gadget layer dependencies
-- 
2.14.1

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


[U-Boot] [PATCH v2 4/8] cmd: add sdp command

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Add a new command to start USB Serial Download Protocol (SDP)
state machine.

Signed-off-by: Stefan Agner 
Reviewed-by: Łukasz Majewski 
Reviewed-by: Stefano Babic 
---

Changes in v2:
- Changed function signature of sdp_init/sdp_handle

 cmd/Kconfig  |  7 +++
 cmd/Makefile |  1 +
 cmd/usb_gadget_sdp.c | 50 ++
 3 files changed, 58 insertions(+)
 create mode 100644 cmd/usb_gadget_sdp.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 42d955c96a..d6d130edfa 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -895,6 +895,13 @@ config CMD_USB
help
  USB support.
 
+config CMD_USB_SDP
+   bool "sdp"
+   select USB_FUNCTION_SDP
+   help
+ Enables the command "sdp" which is used to have U-Boot emulating the
+ Serial Download Protocol (SDP) via USB.
+
 config CMD_USB_MASS_STORAGE
bool "UMS usb mass storage"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index 13c86f8fcc..4ec0e175cd 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -131,6 +131,7 @@ obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
 obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o
 
 obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o
+obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
 obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
 obj-$(CONFIG_CMD_XIMG) += ximg.o
 obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
new file mode 100644
index 00..b1d8b2858e
--- /dev/null
+++ b/cmd/usb_gadget_sdp.c
@@ -0,0 +1,50 @@
+/*
+ * cmd_sdp.c -- sdp command
+ *
+ * Copyright (C) 2016 Toradex
+ * Author: Stefan Agner 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   int ret = CMD_RET_FAILURE;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   char *usb_controller = argv[1];
+   int controller_index = simple_strtoul(usb_controller, NULL, 0);
+   board_usb_init(controller_index, USB_INIT_DEVICE);
+
+   g_dnl_clear_detach();
+   g_dnl_register("usb_dnl_sdp");
+
+   ret = sdp_init(controller_index);
+   if (ret) {
+   error("SDP init failed: %d", ret);
+   goto exit;
+   }
+
+   /* This command typically does not return but jumps to an image */
+   sdp_handle(controller_index);
+   error("SDP ended");
+
+exit:
+   g_dnl_unregister();
+   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+
+   return ret;
+}
+
+U_BOOT_CMD(sdp, 2, 1, do_sdp,
+   "Serial Downloader Protocol",
+   "\n"
+   "  - serial downloader protocol via \n"
+);
-- 
2.14.1

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


[U-Boot] [PATCH v2 6/8] doc: add Serial Download Protocol documentation

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Document the U-Boot Serial Download Protocol implementation and
some typical use cases.

Signed-off-by: Stefan Agner 
---
This ended up to be almost more a imx_usb documentation. But there
is really not much to document from a U-Boot side since actual usage
heavily depends on host side tooling...

This assumes that the necessary changes will get merged upstream:
https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored


Changes in v2: None

 doc/README.sdp | 100 +
 1 file changed, 100 insertions(+)
 create mode 100644 doc/README.sdp

diff --git a/doc/README.sdp b/doc/README.sdp
new file mode 100644
index 00..9b438c0746
--- /dev/null
+++ b/doc/README.sdp
@@ -0,0 +1,100 @@
+-
+SDP in U-Boot
+-
+
+SDP stands for serial download protocol. It is the protocol used in NXP's
+i.MX SoCs ROM Serial Downloader and provides means to download a program
+image to the chip over USB and UART serial connection.
+
+The implementation in U-Boot uses the USB Downloader Gadget (g_dnl) to
+provide a SDP implementation over USB. This allows to download program
+images to the target in SPL/U-Boot using the same protocol/tooling the
+SoC's recovery mechanism is using.
+
+The SDP protocol over USB is a USB HID class protocol. USB HID class
+protocols allow to access a USB device without OS specific drivers. The
+U-Boot implementation has primarly been tested using the open source
+imx_loader utility (https://github.com/toradex/imx_loader).
+
+The host side utilities are typically capable to interpret the i.MX
+specific image header (see doc/README.imximage). There are extensions
+for imx_loader's imx_usb utility which allow to interpret the U-Boot
+specific legacy image format (see mkimage(1)). Also the U-Boot side
+support beside the i.MX specific header the U-Boot legacy header.
+
+Usage
+-
+
+This implementation can be started in U-Boot using the sdp command
+(CONFIG_CMD_USB_SDP) or in SPL if Serial Downloader boot mode has been
+detected (CONFIG_SPL_USB_SDP_SUPPORT).
+
+A typical use case is downloading full U-Boot after SPL has been
+downloaded through the boot ROM's Serial Downloader. Using boot mode
+detection the SPL will run the SDP implementation automatically in
+this case:
+
+  # imx_usb SPL
+
+Targets Serial Console:
+
+  Trying to boot from USB SDP
+  SDP: initialize...
+  SDP: handle requests...
+
+At this point the SPL reenumerated as a new HID device and emulating
+the boot ROM's SDP protocol. The USB VID/PID will depend on standard
+U-Boot configurations CONFIG_G_DNL_(VENDOR|PRODUCT)_NUM. Make sure
+imx_usb is aware of the USB VID/PID for your device by adding a
+configuration entry in imx_usb.conf:
+
+  0x1b67:0x4fff, mx6_usb_sdp_spl.conf
+
+And the device specific configuration file mx6_usb_sdp_spl.conf:
+
+  mx6_spl_sdp
+  hid,uboot_header,1024,0x91,0x1000,1G,0x0090,0x4
+
+This allows to download the regular U-Boot with legacy image headers
+(u-boot.img) using a second invocation of imx_usb:
+
+  # imx_usb u-boot.img
+
+Furthermore, when U-Boot is running the sdp command can be used to
+download and run scripts:
+
+  # imx_usb script.scr
+
+imx_usb configuration files can be also used to download multiple
+files and of arbitrary types, e.g.
+
+  mx6_usb_sdp_uboot
+  hid,1024,0x1000,1G,0x00907000,0x31000
+  full.itb:load 0x1210
+  boot.scr:load 0x1200,jump 0x1200
+
+There is also a batch mode which allows imx_usb to handle multiple
+consecutive reenumerations by adding multiple VID/PID specifications
+in imx_usb.conf:
+
+  0x15a2:0x0061, mx6_usb_rom.conf, 0x1b67:0x4fff, mx6_usb_sdp_spl.conf
+
+In this mode the file to download (imx_usb job) needs to be specified
+in the configuration files.
+
+mx6_usb_rom.conf:
+
+  mx6_qsb
+  hid,1024,0x91,0x1000,1G,0x0090,0x4
+  SPL:jump header2
+
+mx6_usb_sdp_spl.conf:
+
+  mx6_spl_sdp
+  hid,uboot_header,1024,0x1000,1G,0x00907000,0x31000
+  u-boot.img:jump header2
+
+With that SPL and U-Boot can be downloaded with a single invocation
+of imx_usb without arguments:
+
+  # imx_usb
-- 
2.14.1

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


[U-Boot] [PATCH v2 8/8] apalis/colibri_imx6: enable SDP by default

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Enable Serial Download Protocol (SDP) in SPL and U-Boot. This is
useful to make use of imx_usb to download the complete U-Boot
(u-boot.img) after SPL has been downloaded. The U-Boot command
sdp allows to enumerate as SDP capable device again, e.g. to
download a Linux kernel and/or U-Boot script.

Signed-off-by: Stefan Agner 
Acked-by: Max Krummenacher 
---

Changes in v2: None

 configs/apalis_imx6_defconfig  | 4 
 configs/colibri_imx6_defconfig | 4 
 2 files changed, 8 insertions(+)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 468a1fcac7..8f87f1d34c 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -17,6 +17,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET_SUPPORT=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Apalis iMX6 # "
 CONFIG_CMD_BOOTZ=y
@@ -33,6 +36,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index edbd87fe19..beb74b5ae5 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -17,6 +17,9 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET_SUPPORT=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Colibri iMX6 # "
 CONFIG_CMD_BOOTZ=y
@@ -33,6 +36,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
-- 
2.14.1

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


[U-Boot] [PATCH v2 3/8] usb: gadget: sdp: extend images compatible for jumps

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Support U-Boot images in SPL so that u-boot.img files can be
directly downloaded and executed. Furthermore support U-Boot
scripts download and execution in full U-Boot so that custom
recovery actions can be downloaded from the host in a third
step.

Signed-off-by: Stefan Agner 
Reviewed-by: Łukasz Majewski 
Reviewed-by: Stefano Babic 
---

Changes in v2: None

 drivers/usb/gadget/f_sdp.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 9d82abcd69..0fae66beab 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #define HID_REPORT_ID_MASK 0x00ff
@@ -670,8 +672,22 @@ static void sdp_handle_in_ep(void)
sdp_func->state = SDP_STATE_TX_REGISTER_BUSY;
break;
case SDP_STATE_JUMP:
-   printf("Checking imxheader at 0x%08x\n", f_sdp->jmp_address);
-   status = sdp_jump_imxheader((void *)f_sdp->jmp_address);
+   printf("Jumping to header at 0x%08x\n", sdp_func->jmp_address);
+   status = sdp_jump_imxheader((void *)sdp_func->jmp_address);
+
+   /* If imx header fails, try some U-Boot specific headers */
+   if (status) {
+#ifdef CONFIG_SPL_BUILD
+   /* In SPL, allow jumps to U-Boot images */
+   struct spl_image_info spl_image = {};
+   spl_parse_image_header(_image,
+   (struct image_header *)sdp_func->jmp_address);
+   jump_to_image_no_args(_image);
+#else
+   /* In U-Boot, allow jumps to scripts */
+   source(sdp_func->jmp_address, "script@1");
+#endif
+   }
 
sdp_func->next_state = SDP_STATE_IDLE;
sdp_func->error_status = status;
-- 
2.14.1

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


[U-Boot] [PATCH v2 2/8] usb: gadget: add SDP driver

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Add SDP (Serial Downloader Protocol) implementation for U-Boot. The
protocol is used in NXP SoC's boot ROM and allows to download program
images. Beside that, it can also be used to read/write registers and
download complete Device Configuration Data (DCD) sets. This basic
implementation supports downloading images with the imx header format
reading and writing registers.

Signed-off-by: Stefan Agner 
---

Changes in v2:
- Changed function signature of sdp_init/sdp_handle to allow specifying
  which USB controller should be used.
- Use #defines for security mode
- Improved types used in format strings

 drivers/usb/gadget/Kconfig  |   7 +
 drivers/usb/gadget/Makefile |   1 +
 drivers/usb/gadget/f_sdp.c  | 721 
 include/sdp.h   |  16 +
 4 files changed, 745 insertions(+)
 create mode 100644 drivers/usb/gadget/f_sdp.c
 create mode 100644 include/sdp.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 261ed128ac..225b66bc95 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -103,6 +103,13 @@ config USB_GADGET_DOWNLOAD
 
 if USB_GADGET_DOWNLOAD
 
+config USB_FUNCTION_SDP
+   bool "Enable USB SDP (Serial Download Protocol)"
+   help
+ Enable Serial Download Protocol (SDP) device support in U-Boot. This
+ allows to download images into memory and execute (jump to) them
+ using the same protocol as implemented by the i.MX family's boot ROM.
+
 config G_DNL_MANUFACTURER
string "Vendor name of USB device"
 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 5e316a7cff..6a007d1bcb 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o
 obj-$(CONFIG_USB_FUNCTION_DFU) += f_dfu.o
 obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o
 obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o
+obj-$(CONFIG_USB_FUNCTION_SDP) += f_sdp.o
 endif
 endif
 ifdef CONFIG_USB_ETHER
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
new file mode 100644
index 00..9d82abcd69
--- /dev/null
+++ b/drivers/usb/gadget/f_sdp.c
@@ -0,0 +1,721 @@
+/*
+ * f_sdp.c -- USB HID Serial Download Protocol
+ *
+ * Copyright (C) 2017 Toradex
+ * Author: Stefan Agner 
+ *
+ * This file implements the Serial Download Protocol (SDP) as specified in
+ * the i.MX 6 Reference Manual. The SDP is a USB HID based protocol and
+ * allows to download images directly to memory. The implementation
+ * works with the imx_loader (imx_usb) USB client software on host side.
+ *
+ * Not all commands are implemented, e.g. WRITE_REGISTER, DCD_WRITE and
+ * SKIP_DCD_HEADER are only stubs.
+ *
+ * Parts of the implementation are based on f_dfu and f_thor.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define HID_REPORT_ID_MASK 0x00ff
+
+/*
+ * HID class requests
+ */
+#define HID_REQ_GET_REPORT 0x01
+#define HID_REQ_GET_IDLE   0x02
+#define HID_REQ_GET_PROTOCOL   0x03
+#define HID_REQ_SET_REPORT 0x09
+#define HID_REQ_SET_IDLE   0x0A
+#define HID_REQ_SET_PROTOCOL   0x0B
+
+#define HID_USAGE_PAGE_LEN 76
+
+struct hid_report {
+   u8 usage_page[HID_USAGE_PAGE_LEN];
+} __packed;
+
+#define SDP_READ_REGISTER  0x0101
+#define SDP_WRITE_REGISTER 0x0202
+#define SDP_WRITE_FILE 0x0404
+#define SDP_ERROR_STATUS   0x0505
+#define SDP_DCD_WRITE  0x0a0a
+#define SDP_JUMP_ADDRESS   0x0b0b
+#define SDP_SKIP_DCD_HEADER0x0c0c
+
+#define SDP_SECURITY_CLOSED0x12343412
+#define SDP_SECURITY_OPEN  0x56787856
+
+#define SDP_WRITE_FILE_COMPLETE0x
+#define SDP_WRITE_REGISTER_COMPLETE0x128A8A12
+#define SDP_SKIP_DCD_HEADER_COMPLETE   0x900DD009
+#define SDP_ERROR_IMXHEADER0x000a0533
+
+#define SDP_COMMAND_LEN16
+
+struct sdp_command {
+   u16 cmd;
+   u32 addr;
+   u8 format;
+   u32 cnt;
+   u32 data;
+   u8 rsvd;
+} __packed;
+
+enum sdp_state {
+   SDP_STATE_IDLE,
+   SDP_STATE_RX_DCD_DATA,
+   SDP_STATE_RX_FILE_DATA,
+   SDP_STATE_TX_SEC_CONF,
+   SDP_STATE_TX_SEC_CONF_BUSY,
+   SDP_STATE_TX_REGISTER,
+   SDP_STATE_TX_REGISTER_BUSY,
+   SDP_STATE_TX_STATUS,
+   SDP_STATE_TX_STATUS_BUSY,
+   SDP_STATE_JUMP,
+};
+
+struct f_sdp {
+   struct usb_function usb_function;
+
+   struct usb_descriptor_header**function;
+
+   u8  altsetting;
+   enum sdp_state  state;
+   enum sdp_state  next_state;
+   u32 

[U-Boot] [PATCH v2 1/8] imx: move imximage header to common location

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

Move the imximage.h header file to a common location so we can make
use of it from U-Boot too.

Signed-off-by: Stefan Agner 
Reviewed-by: Łukasz Majewski 
---

Changes in v2: None

 {tools => include}/imximage.h | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename {tools => include}/imximage.h (100%)

diff --git a/tools/imximage.h b/include/imximage.h
similarity index 100%
rename from tools/imximage.h
rename to include/imximage.h
-- 
2.14.1

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


[U-Boot] [PATCH v2 0/8] imx: add USB Serial Download Protocol (SDP) support

2017-08-16 Thread Stefan Agner
From: Stefan Agner 

This series adds NXP's Serial Download Protocol (SDP) support via
USB for SPL/U-Boot. It allows to download U-Boot via USB from a
(recovered) SPL using the same tools used to download SPL itself
(specifically imx_usb, but also sb_loader seems to work).

The idea has been brought up when the first targets started to make
use of SPL for DDR initialization, see:
https://lists.denx.de/pipermail/u-boot/2015-July/220330.html

The initial SDP implementation (patch 2) requires the payload to
have the imx specific headers (hence the move of the imx header
file in patch 1).

Patch 3 extends image header support beyond the SDP specification,
specifically implements also support for U-Boot headers. This
allows to use the same SPL/U-Boot binaries for recovery as used on
the regular boot device (SD/eMMC). For that to work also the host
side imx_usb tools needed an extension, currently available here:

https://github.com/toradex/imx_loader/tree/imx_usb_batch_mode_refactored

(in case this patchset gets accepted in U-Boot, I plan to push
these imx_usb changes upstream as well)

The full patchset allows to download SPL and U-Boot over USB to a
target in recovery mode using the same usb_imx utility. Refer to
the new README.sdp for details how to use usb_imx in combination
with this implementation.

Changes in v2:
- Changed function signature of sdp_init/sdp_handle to allow specifying
  which USB controller should be used.
- Use #defines for security mode
- Improved types used in format strings
- Changed function signature of sdp_init/sdp_handle
- Use BOOT_DEVICE_BOARD

Stefan Agner (8):
  imx: move imximage header to common location
  usb: gadget: add SDP driver
  usb: gadget: sdp: extend images compatible for jumps
  cmd: add sdp command
  spl: add serial download protocol (SDP) support
  doc: add Serial Download Protocol documentation
  apalis/colibri_imx6: use independent USB PID for SPL
  apalis/colibri_imx6: enable SDP by default

 board/toradex/apalis_imx6/apalis_imx6.c   |  13 +
 board/toradex/colibri_imx6/colibri_imx6.c |  13 +
 cmd/Kconfig   |   7 +
 cmd/Makefile  |   1 +
 cmd/usb_gadget_sdp.c  |  50 ++
 common/spl/Kconfig|   6 +
 common/spl/Makefile   |   1 +
 common/spl/spl_sdp.c  |  37 ++
 configs/apalis_imx6_defconfig |   4 +
 configs/colibri_imx6_defconfig|   4 +
 doc/README.sdp| 100 
 drivers/usb/gadget/Kconfig|   7 +
 drivers/usb/gadget/Makefile   |   2 +
 drivers/usb/gadget/f_sdp.c| 737 ++
 {tools => include}/imximage.h |   0
 include/sdp.h |  16 +
 16 files changed, 998 insertions(+)
 create mode 100644 cmd/usb_gadget_sdp.c
 create mode 100644 common/spl/spl_sdp.c
 create mode 100644 doc/README.sdp
 create mode 100644 drivers/usb/gadget/f_sdp.c
 rename {tools => include}/imximage.h (100%)
 create mode 100644 include/sdp.h

-- 
2.14.1

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


[U-Boot] [PATCH 16/18] rockchip: gpio: remove outdate/misleading comment

2017-08-16 Thread Philipp Tomsich
Remove a comment claiming that this driver only supports the RK3288,
as we also use it on the RK3368, RK3399 and (most likely) on other
variants.

Signed-off-by: Philipp Tomsich 
---

 drivers/gpio/rk_gpio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index a4849ad..52c8020 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -103,7 +103,6 @@ static int rockchip_gpio_probe(struct udevice *dev)
char *end;
int ret;
 
-   /* This only supports RK3288 at present */
priv->regs = (struct rockchip_gpio_regs *)dev_read_addr(dev);
ret = uclass_first_device_err(UCLASS_PINCTRL, >pinctrl);
if (ret)
-- 
2.1.4

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


[U-Boot] [PATCH 17/18] rockchip: dts: rk3368-lion: add /chosen/tick-timer

2017-08-16 Thread Philipp Tomsich
To support bootstage recording, we want to mark our DM timer as the
tick-timer; this triggers the support for 'trying harder' to read the
timer in the Rockchip DM timer driver, even if the device model isn't
ready yet.

Signed-off-by: Philipp Tomsich 
---

 arch/arm/dts/rk3368-lion-u-boot.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/dts/rk3368-lion-u-boot.dtsi 
b/arch/arm/dts/rk3368-lion-u-boot.dtsi
index dbf614c..a9b7f81 100644
--- a/arch/arm/dts/rk3368-lion-u-boot.dtsi
+++ b/arch/arm/dts/rk3368-lion-u-boot.dtsi
@@ -13,6 +13,7 @@
chosen {
stdout-path = "serial0:115200n8";
u-boot,spl-boot-order = , 
+   tick-timer = "/timer@ff81";
};
 
 };
@@ -88,6 +89,7 @@
  {
u-boot,dm-pre-reloc;
clock-frequency = <2400>;
+   status = "okay";
 };
 
 
-- 
2.1.4

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


[U-Boot] [PATCH 14/18] rockchip: i2c: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Rockchip I2C driver to support livetree.

Signed-off-by: Philipp Tomsich 
---

 drivers/i2c/rk_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
index 8bc045a..c00b09a 100644
--- a/drivers/i2c/rk_i2c.c
+++ b/drivers/i2c/rk_i2c.c
@@ -369,7 +369,7 @@ static int rockchip_i2c_probe(struct udevice *bus)
 {
struct rk_i2c *priv = dev_get_priv(bus);
 
-   priv->regs = (void *)devfdt_get_addr(bus);
+   priv->regs = (void *)dev_read_addr(bus);
 
return 0;
 }
-- 
2.1.4

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


[U-Boot] [PATCH 18/18] rockchip: lion-rk3368: defconfig: resync w/ OF_LIVE and BOOTSTAGE enabled

2017-08-16 Thread Philipp Tomsich
This adds OF_LIVE and BOOTSTAGE support for the RK3368-uQ7 and
regenerates the defconfig (picking up a few changes/reorderings) from
upstream Kconfig changes.

Signed-off-by: Philipp Tomsich 
---

 configs/lion-rk3368_defconfig | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig
index 407bd44..47205c2 100644
--- a/configs/lion-rk3368_defconfig
+++ b/configs/lion-rk3368_defconfig
@@ -18,6 +18,10 @@ CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_SOURCE="board/theobroma-systems/lion_rk3368/fit_spl_atf.its"
+CONFIG_BOOTSTAGE=y
+CONFIG_SPL_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_REPORT=y
+CONFIG_BOOTSTAGE_FDT=y
 CONFIG_ENV_IS_IN_MMC=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_ARCH_EARLY_INIT_R=y
@@ -36,13 +40,15 @@ CONFIG_TPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FASTBOOT=y
 CONFIG_ANDROID_BOOT_IMAGE=y
 # CONFIG_CMD_IMLS is not set
+CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
-CONFIG_CMD_GPIO=y
+CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_TPL_OF_CONTROL=y
+CONFIG_OF_LIVE=y
 CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent"
 CONFIG_TPL_OF_PLATDATA=y
 CONFIG_NET_RANDOM_ETHADDR=y
@@ -63,7 +69,6 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_PHY_MICREL=y
-CONFIG_PHY_MICREL_KSZ9031=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
-- 
2.1.4

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


[U-Boot] [PATCH 12/18] rockchip: sdhci: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Rockchip SDHCI wrapper to support a live device tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/mmc/rockchip_sdhci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index f31d329..8d62bf9 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -9,7 +9,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -82,7 +81,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice 
*dev)
struct sdhci_host *host = dev_get_priv(dev);
 
host->name = dev->name;
-   host->ioaddr = devfdt_get_addr_ptr(dev);
+   host->ioaddr = (void *)dev_read_addr(dev);
 #endif
 
return 0;
-- 
2.1.4

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


[U-Boot] [PATCH 10/18] rockchip: pinctrl: rk3368: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the pinctrl driver for the RK3368 to support a live device tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/pinctrl/rockchip/pinctrl_rk3368.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3368.c 
b/drivers/pinctrl/rockchip/pinctrl_rk3368.c
index 81ce2e3..b1f5704 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3368.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3368.c
@@ -632,8 +632,7 @@ static int rk3368_pinctrl_get_periph_id(struct udevice *dev,
u32 cell[3];
int ret;
 
-   ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
-  "interrupts", cell, ARRAY_SIZE(cell));
+   ret = dev_read_u32_array(periph, "interrupts", cell, ARRAY_SIZE(cell));
if (ret < 0)
return -EINVAL;
 
-- 
2.1.4

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


[U-Boot] [PATCH 00/18] rockchip: convert the RK3368 to OF_LIVE and validate on the RK3368-uQ7

2017-08-16 Thread Philipp Tomsich

This series converts all dependencies for the RK3368-uQ7 to support a
live tree and and tests w/ BOOTSTAGE enabled (thus introducing a few
additional changes to the Rockchip DM timer driver).

Note that updating the RK3399 support (which will have us look at
video) for a live tree will be next: I plan to keep the RK3399 changes
as a separate series (to be applied on top of this one).


Philipp Tomsich (18):
  bootstage: adjust Makefile to allow including bootstage in SPL, but
not in TPL
  dm: timer: Convert to livetree
  dm: timer: handle being called before dm_root is ready
  net: designware: Convert to livetree
  net: phy: micrel: Convert to livetree
  rockchip: mmc: convert to livetree
  rockchip: timer: implement timer_get_boot_us
  rockchip: timer: Convert to livetree
  rockchip: clk: rk3368: Convert to livetree
  rockchip: pinctrl: rk3368: Convert to livetree
  rockchip: spi: Convert to livetree
  rockchip: sdhci: Convert to livetree
  rockchip: rk8xx: remove unused header includes
  rockchip: i2c: Convert to livetree
  rockchip: gpio: convert to livetree
  rockchip: gpio: remove outdate/misleading comment
  rockchip: dts: rk3368-lion: add /chosen/tick-timer
  rockchip: lion-rk3368: defconfig: resync w/ OF_LIVE and BOOTSTAGE
enabled

 arch/arm/dts/rk3368-lion-u-boot.dtsi  |  2 +
 common/Makefile   |  2 +-
 configs/lion-rk3368_defconfig |  9 +++-
 drivers/clk/rockchip/clk_rk3368.c |  2 +-
 drivers/gpio/rk_gpio.c|  3 +-
 drivers/i2c/rk_i2c.c  |  2 +-
 drivers/mmc/rockchip_dw_mmc.c |  2 +-
 drivers/mmc/rockchip_sdhci.c  |  3 +-
 drivers/net/designware.c  | 11 ++---
 drivers/net/phy/micrel_ksz90x1.c  |  5 +--
 drivers/pinctrl/rockchip/pinctrl_rk3368.c |  3 +-
 drivers/power/pmic/rk8xx.c|  2 -
 drivers/spi/rk_spi.c  |  2 +-
 drivers/timer/rockchip_timer.c| 74 ---
 drivers/timer/timer-uclass.c  | 52 +-
 15 files changed, 120 insertions(+), 54 deletions(-)

-- 
2.1.4

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


[U-Boot] [PATCH 11/18] rockchip: spi: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Rockchip SPI driver to support a live device tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/spi/rk_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index c70d636..b18db74 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -184,7 +184,7 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice 
*bus)
struct rockchip_spi_priv *priv = dev_get_priv(bus);
int ret;
 
-   plat->base = devfdt_get_addr(bus);
+   plat->base = dev_read_addr(bus);
 
ret = clk_get_by_index(bus, 0, >clk);
if (ret < 0) {
-- 
2.1.4

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


[U-Boot] [PATCH 13/18] rockchip: rk8xx: remove unused header includes

2017-08-16 Thread Philipp Tomsich
Remove header file includes that have been left over after the
conversion to livetree-support.

Signed-off-by: Philipp Tomsich 
---

 drivers/power/pmic/rk8xx.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index eb3ec0f..735046d 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -8,8 +8,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 
-- 
2.1.4

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


[U-Boot] [PATCH 06/18] rockchip: mmc: convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Rockchip-specific wrapper for the Designware driver to
support a live device tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/mmc/rockchip_dw_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index e7fcf89..138899a 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -58,7 +58,7 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice 
*dev)
struct dwmci_host *host = >host;
 
host->name = dev->name;
-   host->ioaddr = (void *)devfdt_get_addr(dev);
+   host->ioaddr = (void *)dev_read_addr(dev);
host->buswidth = dev_read_u32_default(dev, "bus-width", 4);
host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
host->priv = dev;
-- 
2.1.4

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


[U-Boot] [PATCH 08/18] rockchip: timer: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Rockchip timer driver to support a live device tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/timer/rockchip_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/timer/rockchip_timer.c b/drivers/timer/rockchip_timer.c
index 74bb002..b375ffd 100644
--- a/drivers/timer/rockchip_timer.c
+++ b/drivers/timer/rockchip_timer.c
@@ -101,7 +101,7 @@ static int rockchip_clk_ofdata_to_platdata(struct udevice 
*dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rockchip_timer_priv *priv = dev_get_priv(dev);
 
-   priv->timer = (struct rk_timer *)devfdt_get_addr(dev);
+   priv->timer = (struct rk_timer *)dev_read_addr(dev);
 #endif
 
return 0;
-- 
2.1.4

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


[U-Boot] [PATCH 07/18] rockchip: timer: implement timer_get_boot_us

2017-08-16 Thread Philipp Tomsich
To make the Rockchip DM timer driver useful for the timing of
bootstages, we need a few enhancements:
 - This implements timer_get_boot_us.
 - This avoids reinitialising the timer, if it has already been
   set up (e.g. by our TPL and SPL stages). Now, we have a single
   timebase ticking from TPL through the full U-Boot.
 - This adds support for reading the timer even before the
   device-model is ready: we find the timer via /chosen/tick-timer,
   then read its address and clock-frequency, and finally read the
   timeval directly).

Signed-off-by: Philipp Tomsich 
---

 drivers/timer/rockchip_timer.c | 72 +++---
 1 file changed, 67 insertions(+), 5 deletions(-)

diff --git a/drivers/timer/rockchip_timer.c b/drivers/timer/rockchip_timer.c
index 831b7da..74bb002 100644
--- a/drivers/timer/rockchip_timer.c
+++ b/drivers/timer/rockchip_timer.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,17 +26,72 @@ struct rockchip_timer_priv {
struct rk_timer *timer;
 };
 
-static int rockchip_timer_get_count(struct udevice *dev, u64 *count)
+static inline int64_t rockchip_timer_get_curr_value(struct rk_timer *timer)
 {
-   struct rockchip_timer_priv *priv = dev_get_priv(dev);
uint64_t timebase_h, timebase_l;
uint64_t cntr;
 
-   timebase_l = readl(>timer->timer_curr_value0);
-   timebase_h = readl(>timer->timer_curr_value1);
+   timebase_l = readl(>timer_curr_value0);
+   timebase_h = readl(>timer_curr_value1);
 
-   /* timers are down-counting */
cntr = timebase_h << 32 | timebase_l;
+   return cntr;
+}
+
+#if CONFIG_IS_ENABLED(BOOTSTAGE)
+ulong timer_get_boot_us(void)
+{
+   uint64_t  ticks = 0;
+   uint32_t  rate;
+   uint64_t  us;
+   int ret;
+
+   ret = dm_timer_init();
+
+   if (!ret) {
+   /* The timer is available */
+   rate = timer_get_rate(gd->timer);
+   timer_get_count(gd->timer, );
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+   } else if (ret == -EAGAIN) {
+   /* We have been called so early that the DM is not ready,... */
+   ofnode node = offset_to_ofnode(-1);
+   struct rk_timer *timer = NULL;
+
+   /*
+* ... so we try to access the raw timer, if it is specified
+* via the tick-timer property in /chosen.
+*/
+   node = ofnode_get_chosen_node("tick-timer");
+   if (!ofnode_valid(node)) {
+   debug("%s: no /chosen/tick-timer\n", __func__);
+   return 0;
+   }
+
+   timer = (struct rk_timer *)ofnode_get_addr(node);
+
+   /* This timer is down-counting */
+   ticks = ~0uLL - rockchip_timer_get_curr_value(timer);
+   if (ofnode_read_u32(node, "clock-frequency", )) {
+   debug("%s: could not read clock-frequency\n", __func__);
+   return 0;
+   }
+#endif
+   } else {
+   return 0;
+   }
+
+   us = (ticks * 1000) / rate;
+   return us;
+}
+#endif
+
+static int rockchip_timer_get_count(struct udevice *dev, u64 *count)
+{
+   struct rockchip_timer_priv *priv = dev_get_priv(dev);
+   uint64_t cntr = rockchip_timer_get_curr_value(priv->timer);
+
+   /* timers are down-counting */
*count = ~0ull - cntr;
return 0;
 }
@@ -58,6 +114,12 @@ static int rockchip_timer_start(struct udevice *dev)
const uint32_t reload_val_l = reload_val & 0x;
const uint32_t reload_val_h = reload_val >> 32;
 
+   /* don't reinit, if the timer is already running and set up */
+   if ((readl(>timer->timer_ctrl_reg) & 1) == 1 &&
+   (readl(>timer->timer_load_count0) == reload_val_l) &&
+   (readl(>timer->timer_load_count1) == reload_val_h))
+   return 0;
+
/* disable timer and reset all control */
writel(0, >timer->timer_ctrl_reg);
/* write reload value */
-- 
2.1.4

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


[U-Boot] [PATCH 05/18] net: phy: micrel: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Micrel KSZ90x1 driver for a live tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/net/phy/micrel_ksz90x1.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
index 20f8a55..0b6cd44 100644
--- a/drivers/net/phy/micrel_ksz90x1.c
+++ b/drivers/net/phy/micrel_ksz90x1.c
@@ -9,11 +9,11 @@
  * (C) Copyright 2017 Adaptrum, Inc.
  * Written by Alexandru Gagniuc  for Adaptrum, Inc.
  */
+
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -120,8 +120,7 @@ static int ksz90x1_of_config_group(struct phy_device 
*phydev,
return -EOPNOTSUPP;
 
for (i = 0; i < ofcfg->grpsz; i++) {
-   val[i] = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
-ofcfg->grp[i].name, -1);
+   val[i] = dev_read_u32_default(dev, ofcfg->grp[i].name, ~0);
offset = ofcfg->grp[i].off;
if (val[i] == -1) {
/* Default register value for KSZ9021 */
-- 
2.1.4

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


[U-Boot] [PATCH 15/18] rockchip: gpio: convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Rockchip GPIO-bank driver to support a live tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/gpio/rk_gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index 6f7366a..a4849ad 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -104,7 +104,7 @@ static int rockchip_gpio_probe(struct udevice *dev)
int ret;
 
/* This only supports RK3288 at present */
-   priv->regs = (struct rockchip_gpio_regs *)devfdt_get_addr(dev);
+   priv->regs = (struct rockchip_gpio_regs *)dev_read_addr(dev);
ret = uclass_first_device_err(UCLASS_PINCTRL, >pinctrl);
if (ret)
return ret;
-- 
2.1.4

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


[U-Boot] [PATCH 09/18] rockchip: clk: rk3368: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the clock driver for the RK3368 to support a live device tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/clk/rockchip/clk_rk3368.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/rockchip/clk_rk3368.c 
b/drivers/clk/rockchip/clk_rk3368.c
index 0160d50..d326fc1 100644
--- a/drivers/clk/rockchip/clk_rk3368.c
+++ b/drivers/clk/rockchip/clk_rk3368.c
@@ -485,7 +485,7 @@ static int rk3368_clk_ofdata_to_platdata(struct udevice 
*dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rk3368_clk_priv *priv = dev_get_priv(dev);
 
-   priv->cru = (struct rk3368_cru *)devfdt_get_addr(dev);
+   priv->cru = (struct rk3368_cru *)dev_read_addr(dev);
 #endif
 
return 0;
-- 
2.1.4

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


[U-Boot] [PATCH 04/18] net: designware: Convert to livetree

2017-08-16 Thread Philipp Tomsich
Update the Designware Ethernet MAC driver to support a live device
tree.

Signed-off-by: Philipp Tomsich 
---

 drivers/net/designware.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 521e4dd..036d231 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -737,16 +737,14 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
 #endif
struct eth_pdata *pdata = _pdata->eth_pdata;
const char *phy_mode;
-   const fdt32_t *cell;
 #ifdef CONFIG_DM_GPIO
int reset_flags = GPIOD_IS_OUT;
 #endif
int ret = 0;
 
-   pdata->iobase = devfdt_get_addr(dev);
+   pdata->iobase = dev_read_addr(dev);
pdata->phy_interface = -1;
-   phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-  NULL);
+   phy_mode = dev_read_string(dev, "phy-mode");
if (phy_mode)
pdata->phy_interface = phy_get_interface_by_name(phy_mode);
if (pdata->phy_interface == -1) {
@@ -754,10 +752,7 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
return -EINVAL;
}
 
-   pdata->max_speed = 0;
-   cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
-   if (cell)
-   pdata->max_speed = fdt32_to_cpu(*cell);
+   pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
 
 #ifdef CONFIG_DM_GPIO
if (dev_read_bool(dev, "snps,reset-active-low"))
-- 
2.1.4

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


[U-Boot] [PATCH 03/18] dm: timer: handle being called before dm_root is ready

2017-08-16 Thread Philipp Tomsich
When used with bootstage recording, dm_timer_init may be called
surprisingly early: i.e. before dm_root is ready. To deal with
this case, we explicitly check for this condition and return
-EAGAIN to the caller (refer to drivers/timer/rockchip_timer.c
for a case where this is needed/used).

Signed-off-by: Philipp Tomsich 
---

 drivers/timer/timer-uclass.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 62d6f0b..45397b2 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -92,6 +92,13 @@ int notrace dm_timer_init(void)
if (gd->timer)
return 0;
 
+   /*
+* Directly access gd->dm_root to suppress error messages, if the
+* virtual root driver does not yet exist.
+*/
+   if (gd->dm_root == NULL)
+   return -EAGAIN;
+
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
/* Check for a chosen timer to be used for tick */
node = ofnode_get_chosen_node("tick-timer");
-- 
2.1.4

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


[U-Boot] [PATCH 01/18] bootstage: adjust Makefile to allow including bootstage in SPL, but not in TPL

2017-08-16 Thread Philipp Tomsich
For timing our bootstages on the RK3368, which has a minimal TPL
(and where we consequently don't want to time the bootstages) and a
full-featured SPL (where we can bootstage recording), we need to
adjust the Makefile.

Use the $(SPL_TPL_) macro in the Makefile for bootstage.o

Signed-off-by: Philipp Tomsich 
---

 common/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/Makefile b/common/Makefile
index 3ee7a6b..230dec7 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -86,7 +86,7 @@ obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
 
 endif # !CONFIG_SPL_BUILD
 
-obj-$(CONFIG_$(SPL_)BOOTSTAGE) += bootstage.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
-- 
2.1.4

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


[U-Boot] [PATCH 02/18] dm: timer: Convert to livetree

2017-08-16 Thread Philipp Tomsich
This updates dm_timer_init to support a live tree and deals with
some fallout (i.e. the need to restructure the code such, that we
don't need multiple discontinuous #if CONFIG_IS_ENABLED blocks).

Signed-off-by: Philipp Tomsich 
---

 drivers/timer/timer-uclass.c | 45 ++--
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index a84755f..62d6f0b 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,9 +55,10 @@ static int timer_pre_probe(struct udevice *dev)
if (IS_ERR_VALUE(ret))
return ret;
uc_priv->clock_rate = ret;
-   } else
-   uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob,
-   dev_of_offset(dev), "clock-frequency", 0);
+   } else {
+   uc_priv->clock_rate =
+   dev_read_u32_default(dev, "clock-frequency", 0);
+   }
 #endif
 
return 0;
@@ -83,9 +85,8 @@ u64 timer_conv_64(u32 count)
 
 int notrace dm_timer_init(void)
 {
-   __maybe_unused const void *blob = gd->fdt_blob;
struct udevice *dev = NULL;
-   int node = -ENOENT;
+   __maybe_unused ofnode node;
int ret;
 
if (gd->timer)
@@ -93,27 +94,27 @@ int notrace dm_timer_init(void)
 
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
/* Check for a chosen timer to be used for tick */
-   node = fdtdec_get_chosen_node(blob, "tick-timer");
+   node = ofnode_get_chosen_node("tick-timer");
+
+   if (ofnode_valid(node) &&
+   uclass_get_device_by_ofnode(UCLASS_TIMER, node, )) {
+   /*
+* If the timer is not marked to be bound before
+* relocation, bind it anyway.
+*/
+   if (!lists_bind_fdt(dm_root(), node, )) {
+   ret = device_probe(dev);
+   if (ret)
+   return ret;
+   }
+   }
 #endif
-   if (node < 0) {
-   /* No chosen timer, trying first available timer */
+
+   if (!dev) {
+   /* Fall back to the first available timer */
ret = uclass_first_device_err(UCLASS_TIMER, );
if (ret)
return ret;
-   } else {
-   if (uclass_get_device_by_of_offset(UCLASS_TIMER, node, )) {
-   /*
-* If the timer is not marked to be bound before
-* relocation, bind it anyway.
-*/
-   if (node > 0 &&
-   !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
-   )) {
-   ret = device_probe(dev);
-   if (ret)
-   return ret;
-   }
-   }
}
 
if (dev) {
-- 
2.1.4

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


[U-Boot] [PATCH] rockchip: rk3399: spl: remove unused header inclusion

2017-08-16 Thread Philipp Tomsich
fdtdec.h is included, but not used in rk3399-board-spl.c: remove the
'#include'-statement.

Signed-off-by: Philipp Tomsich 
---

 arch/arm/mach-rockchip/rk3399-board-spl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/rk3399-board-spl.c 
b/arch/arm/mach-rockchip/rk3399-board-spl.c
index a13b717..d6bf74f 100644
--- a/arch/arm/mach-rockchip/rk3399-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3399-board-spl.c
@@ -7,7 +7,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.1.4

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


Re: [U-Boot] [PATCH] ls1046aqds: update the defaule mtdparts

2017-08-16 Thread York Sun
On 08/08/2017 07:27 PM, Xiaowei Bao wrote:
> Hi York,
> 
> The default partition is mainly to facilitate the test staff to view the 
> partition information of the storage medium, And the jira ticket also carry 
> by the test staff, I am not sure if it need to push the opensource.

So you agree we don't need this patch and test team can keep this 
variable internally.

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


Re: [U-Boot] [PATCH v2 00/19] add support for rk3066 platform.

2017-08-16 Thread Dr. Philipp Tomsich
Either will be fine for me: u-boot-rockchip/master is only one DTS fix ahead
of u-boot/master.

> On 16 Aug 2017, at 17:48, Paweł Jarosz  wrote:
> 
> Hi,
> 
> 
> W dniu 16.08.2017 o 16:28, Dr. Philipp Tomsich pisze:
>> Pawel,
>> 
>> Could you rebase this onto the current master (the SPL/TPL changes for
>> the RK3368 are likely to have affected a few things) and resubmit?
> 
> By master you mean u-boot-rockchip master or u-boot master?
> 
> Cheers,
> Paweł
> 
>> Thanks,
>> Philipp.
>> 
>>> On 11 Aug 2017, at 22:53, Paweł Jarosz  wrote:
>>> 
>>> This patch serie adds support for Rockchip RK3066 processor.
>>> 
>>> Paweł Jarosz (19):
>>>  rockchip: rk3066: add grf header file
>>>  rockchip: rk3066: add rk3066 pinctrl driver
>>>  rockchip: rk3066: add sysreset driver
>>>  rockchip: rk3066: add clock driver for rk3066 soc
>>>  rockchip: rk3066: add rk3066 platform devicetree file
>>>  rockchip: rk3066: add core support
>>>  rockchip: rk3066: add mk808 board files
>>>  rockchip: rk3066: add sdram driver
>>>  mtd: nand: add support for the Sandisk SDTNQGAMA chip
>>>  mtd: nand: add the rockchip nand controller driver
>>>  rockchip: mkimage: add support for rockchip nand boot image
>>>  rockchip: board: rk3066: convert board_usb_init to live tree functions
>>>  ARM: dts: rockchip: prefer u-boot,dm-pre-reloc rather than
>>>u-boot,dm-spl
>>>  mmc: dw_mmc: support transfer mode autodetection
>>>  mmc: dw_mmc: rockchip: add support for rk3066 sdmmc
>>>  armv7: support rk3066 early back to bootrom in vector.S
>>>  rockchip: sysreset: deduplicate rk3066 and rk3188 sysreset drivers
>>>  dfu: fix spl build
>>>  mtd: nand: spl: allow build nand_bbt, nand_ids and nand_util
>>> 
>>> arch/arm/dts/Makefile  |   1 +
>>> arch/arm/dts/rk3066a-mk808.dts | 189 +
>>> arch/arm/dts/rk3066a.dtsi  | 707 +++
>>> arch/arm/dts/rk3xxx.dtsi   |   8 +-
>>> arch/arm/include/asm/arch-rockchip/boot0.h |  14 +
>>> arch/arm/include/asm/arch-rockchip/cru_rk3066.h| 189 +
>>> arch/arm/include/asm/arch-rockchip/grf_rk3066.h| 621 ++
>>> arch/arm/include/asm/arch-rockchip/periph.h|   1 +
>>> .../include/asm/arch-rockchip/sysreset_common.h|  20 +
>>> arch/arm/lib/vectors.S |  18 +-
>>> arch/arm/mach-rockchip/Kconfig |  16 +
>>> arch/arm/mach-rockchip/Makefile|   7 +
>>> arch/arm/mach-rockchip/rk3066-board-spl.c  | 139 +++
>>> arch/arm/mach-rockchip/rk3066-board-tpl.c  |  90 ++
>>> arch/arm/mach-rockchip/rk3066-board.c  | 112 +++
>>> arch/arm/mach-rockchip/rk3066/Kconfig  |  31 +
>>> arch/arm/mach-rockchip/rk3066/Makefile |   9 +
>>> arch/arm/mach-rockchip/rk3066/clk_rk3066.c |  33 +
>>> arch/arm/mach-rockchip/rk3066/sdram_rk3066.c   | 943 
>>> +
>>> arch/arm/mach-rockchip/rk3066/syscon_rk3066.c  |  54 ++
>>> arch/arm/mach-rockchip/sysreset-common.c   |  39 +
>>> board/rikomagic/mk808_rk3066/Kconfig   |  15 +
>>> board/rikomagic/mk808_rk3066/MAINTAINERS   |   6 +
>>> board/rikomagic/mk808_rk3066/Makefile  |   7 +
>>> board/rikomagic/mk808_rk3066/mk808_rk3066.c|  10 +
>>> common/image.c |   1 +
>>> configs/mk808_defconfig| 115 +++
>>> drivers/clk/rockchip/Makefile  |   1 +
>>> drivers/clk/rockchip/clk_rk3066.c  | 587 +
>>> drivers/dfu/dfu_nand.c |   6 +-
>>> drivers/mmc/dw_mmc.c   |   8 +
>>> drivers/mmc/rockchip_dw_mmc.c  |   1 +
>>> drivers/mtd/nand/Kconfig   |   6 +
>>> drivers/mtd/nand/Makefile  |   4 +
>>> drivers/mtd/nand/nand_ids.c|   3 +
>>> drivers/mtd/nand/rockchip_nand.c   | 660 ++
>>> drivers/pinctrl/Kconfig|   9 +
>>> drivers/pinctrl/rockchip/Makefile  |   1 +
>>> drivers/pinctrl/rockchip/pinctrl_rk3066.c  | 340 
>>> drivers/sysreset/Makefile  |   1 +
>>> drivers/sysreset/sysreset_rk3066.c |  49 ++
>>> drivers/sysreset/sysreset_rk3188.c |  35 +-
>>> include/configs/mk808_rk3066.h |  61 ++
>>> include/configs/rk3066_common.h|  99 +++
>>> include/dwmmc.h|   4 +
>>> include/fdtdec.h   |   1 +
>>> include/image.h|   1 +
>>> lib/fdtdec.c   |   1 +
>>> tools/Makefile |   2 +-
>>> tools/imagetool.h  

Re: [U-Boot] [PATCH] serial: ns16550: Enhancements to the RX interrupt buffer support

2017-08-16 Thread Stefan Roese

Hi Bin,

On 16.08.2017 12:09, Bin Meng wrote:

Hi Stefan,

On Wed, Aug 16, 2017 at 5:55 PM, Stefan Roese  wrote:

Hi Bin,


On 16.08.2017 11:45, Bin Meng wrote:


On Tue, Aug 15, 2017 at 5:33 PM, Stefan Roese  wrote:


This patch changes the RX interrupt buffer support in these ways, mostly
suggested by Bin Meng a few weeks ago:

- The RX interrupt buffers size is now configurable via Kconfig
(default still at 256 bytes)
- For NS16550 devices on the PCI bus, the interrupt number will be
read from the PCI config space. Please note that this might not
result in the correct non-zero interrupt number for this PCI
device, as the UART init code is called very early, currently on
x86 before the PCI config registers are initialized via U-Boot
- If the interrupt number is not provided, the code falls back to
the normal polling mode
- The RX interrupt generation is disabled in the UART in the remove
function

While reworking this RX interrupt buffer support, the "default n" is
also removed from Kconfig as its not needed as pointed out by Bin Meng.
Also, a missing comment for the 'irq' variable is added to the
header.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
Cc: Tom Rini 
---
   drivers/serial/Kconfig   |  8 +++-
   drivers/serial/ns16550.c | 41 +++--
   include/ns16550.h|  2 +-
   3 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index a8e997834a..1b19b24f10 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -67,13 +67,19 @@ config DM_SERIAL
   config SERIAL_IRQ_BUFFER
  bool "Enable RX interrupt buffer for serial input"
  depends on DM_SERIAL
-   default n
  help
Enable RX interrupt buffer support for the serial driver.
This enables pasting longer strings, even when the RX FIFO
of the UART is not big enough (e.g. 16 bytes on the normal
NS16550).

+config SERIAL_IRQ_BUFFER_SIZE



I don't see this CONFIG_SERIAL_IRQ_BUFFER_SIZE is referenced anywhere
in the ns16550 codes?



Hugh? I'll take a look later today.



+   int "RX interrupt buffer size"
+   depends on SERIAL_IRQ_BUFFER
+   default 256
+   help
+ The size of the RX interrupt buffer
+
   config SPL_DM_SERIAL
  bool "Enable Driver Model for serial drivers in SPL"
  depends on DM_SERIAL
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 607a1b8c1d..a24ba75031 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -453,11 +453,13 @@ int ns16550_serial_probe(struct udevice *dev)
  /* Allocate the RX buffer */
  plat->buf = malloc(BUF_COUNT);

-   /* Install the interrupt handler */
-   irq_install_handler(plat->irq, ns16550_handle_irq, dev);
+   if (plat->irq) {
+   /* Install the interrupt handler */
+   irq_install_handler(plat->irq,
ns16550_handle_irq, dev);

-   /* Enable RX interrupts */
-   serial_out(UART_IER_RDI, _port->ier);
+   /* Enable RX interrupts */
+   serial_out(UART_IER_RDI, _port->ier);
+   }
  }
   #endif

@@ -469,9 +471,13 @@ int ns16550_serial_probe(struct udevice *dev)
   static int ns16550_serial_remove(struct udevice *dev)
   {
   #if CONFIG_IS_ENABLED(SERIAL_IRQ_BUFFER)
-   if (gd->flags & GD_FLG_RELOC) {
-   struct ns16550_platdata *plat = dev->platdata;
+   struct ns16550_platdata *plat = dev->platdata;
+
+   if ((gd->flags & GD_FLG_RELOC) && (plat->irq)) {
+   struct NS16550 *const com_port = dev_get_priv(dev);

+   /* Disable RX interrupts */
+   serial_out(CONFIG_SYS_NS16550_IER, _port->ier);
  irq_free_handler(plat->irq);
  }
   #endif
@@ -504,6 +510,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice
*dev)
  struct fdt_pci_addr pci_addr;
  u32 bar;
  int ret;
+   u8 irq;

  /* we prefer to use a memory-mapped register */
  ret = fdtdec_get_pci_addr(gd->fdt_blob,
dev_of_offset(dev),
@@ -524,6 +531,10 @@ int ns16550_serial_ofdata_to_platdata(struct udevice
*dev)
  return ret;

  addr = bar;
+
+   /* Try to get the PCI interrupt number */
+   dm_pci_read_config8(dev, PCI_INTERRUPT_LINE, );
+   plat->irq = irq;
  }
   #endif

@@ -562,12 +573,22 @@ int ns16550_serial_ofdata_to_platdata(struct
udevice *dev)
  plat->fcr |= UART_FCR_UME;

   #if CONFIG_IS_ENABLED(SERIAL_IRQ_BUFFER)
-   plat->irq = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),

Re: [U-Boot] [PATCH v2 00/19] add support for rk3066 platform.

2017-08-16 Thread Paweł Jarosz

Hi,


W dniu 16.08.2017 o 16:28, Dr. Philipp Tomsich pisze:

Pawel,

Could you rebase this onto the current master (the SPL/TPL changes for
the RK3368 are likely to have affected a few things) and resubmit?


By master you mean u-boot-rockchip master or u-boot master?

Cheers,
Paweł


Thanks,
Philipp.


On 11 Aug 2017, at 22:53, Paweł Jarosz  wrote:

This patch serie adds support for Rockchip RK3066 processor.

Paweł Jarosz (19):
  rockchip: rk3066: add grf header file
  rockchip: rk3066: add rk3066 pinctrl driver
  rockchip: rk3066: add sysreset driver
  rockchip: rk3066: add clock driver for rk3066 soc
  rockchip: rk3066: add rk3066 platform devicetree file
  rockchip: rk3066: add core support
  rockchip: rk3066: add mk808 board files
  rockchip: rk3066: add sdram driver
  mtd: nand: add support for the Sandisk SDTNQGAMA chip
  mtd: nand: add the rockchip nand controller driver
  rockchip: mkimage: add support for rockchip nand boot image
  rockchip: board: rk3066: convert board_usb_init to live tree functions
  ARM: dts: rockchip: prefer u-boot,dm-pre-reloc rather than
u-boot,dm-spl
  mmc: dw_mmc: support transfer mode autodetection
  mmc: dw_mmc: rockchip: add support for rk3066 sdmmc
  armv7: support rk3066 early back to bootrom in vector.S
  rockchip: sysreset: deduplicate rk3066 and rk3188 sysreset drivers
  dfu: fix spl build
  mtd: nand: spl: allow build nand_bbt, nand_ids and nand_util

arch/arm/dts/Makefile  |   1 +
arch/arm/dts/rk3066a-mk808.dts | 189 +
arch/arm/dts/rk3066a.dtsi  | 707 +++
arch/arm/dts/rk3xxx.dtsi   |   8 +-
arch/arm/include/asm/arch-rockchip/boot0.h |  14 +
arch/arm/include/asm/arch-rockchip/cru_rk3066.h| 189 +
arch/arm/include/asm/arch-rockchip/grf_rk3066.h| 621 ++
arch/arm/include/asm/arch-rockchip/periph.h|   1 +
.../include/asm/arch-rockchip/sysreset_common.h|  20 +
arch/arm/lib/vectors.S |  18 +-
arch/arm/mach-rockchip/Kconfig |  16 +
arch/arm/mach-rockchip/Makefile|   7 +
arch/arm/mach-rockchip/rk3066-board-spl.c  | 139 +++
arch/arm/mach-rockchip/rk3066-board-tpl.c  |  90 ++
arch/arm/mach-rockchip/rk3066-board.c  | 112 +++
arch/arm/mach-rockchip/rk3066/Kconfig  |  31 +
arch/arm/mach-rockchip/rk3066/Makefile |   9 +
arch/arm/mach-rockchip/rk3066/clk_rk3066.c |  33 +
arch/arm/mach-rockchip/rk3066/sdram_rk3066.c   | 943 +
arch/arm/mach-rockchip/rk3066/syscon_rk3066.c  |  54 ++
arch/arm/mach-rockchip/sysreset-common.c   |  39 +
board/rikomagic/mk808_rk3066/Kconfig   |  15 +
board/rikomagic/mk808_rk3066/MAINTAINERS   |   6 +
board/rikomagic/mk808_rk3066/Makefile  |   7 +
board/rikomagic/mk808_rk3066/mk808_rk3066.c|  10 +
common/image.c |   1 +
configs/mk808_defconfig| 115 +++
drivers/clk/rockchip/Makefile  |   1 +
drivers/clk/rockchip/clk_rk3066.c  | 587 +
drivers/dfu/dfu_nand.c |   6 +-
drivers/mmc/dw_mmc.c   |   8 +
drivers/mmc/rockchip_dw_mmc.c  |   1 +
drivers/mtd/nand/Kconfig   |   6 +
drivers/mtd/nand/Makefile  |   4 +
drivers/mtd/nand/nand_ids.c|   3 +
drivers/mtd/nand/rockchip_nand.c   | 660 ++
drivers/pinctrl/Kconfig|   9 +
drivers/pinctrl/rockchip/Makefile  |   1 +
drivers/pinctrl/rockchip/pinctrl_rk3066.c  | 340 
drivers/sysreset/Makefile  |   1 +
drivers/sysreset/sysreset_rk3066.c |  49 ++
drivers/sysreset/sysreset_rk3188.c |  35 +-
include/configs/mk808_rk3066.h |  61 ++
include/configs/rk3066_common.h|  99 +++
include/dwmmc.h|   4 +
include/fdtdec.h   |   1 +
include/image.h|   1 +
lib/fdtdec.c   |   1 +
tools/Makefile |   2 +-
tools/imagetool.h  |   1 +
tools/mkimage.c|   8 +-
tools/rkcommon.c   |  10 +-
tools/rkcommon.h   |  10 +-
tools/rknand.c | 156 
tools/rksd.c   |   2 +-
tools/rkspi.c  |   2 +-
56 files changed, 5416 insertions(+), 48 deletions(-)
create mode 100644 arch/arm/dts/rk3066a-mk808.dts
create mode 100644 

Re: [U-Boot] [PATCH 3/4] x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

2017-08-16 Thread Stefan Roese

Hi Bin,

On 16.08.2017 17:37, Stefan Roese wrote:

To support more input characters (longer stings pasted into the U-Boot
prompt) without dropping, lets selects the recently added UART RX
buffer for these boards.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
---
  board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/board/congatec/conga-qeval20-qa3-e3845/Kconfig 
b/board/congatec/conga-qeval20-qa3-e3845/Kconfig
index e1fae737ac..9e44413c2c 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Kconfig
+++ b/board/congatec/conga-qeval20-qa3-e3845/Kconfig
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select SPI_FLASH_STMICRO
imply SPI_FLASH_SPANSION
imply SPI_FLASH_WINBOND
+   select SERIAL_RX_BUFFER


It might be better to select (or imply) this Kconfig option for x86 in
general, once this support is available in mainline.

What do you think?

Thanks,
Stefan
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/4] Revert "serial: ns16550: Add RX interrupt buffer support"

2017-08-16 Thread Stefan Roese
This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
Cc: Tom Rini 
---
 drivers/serial/Kconfig   |  10 
 drivers/serial/ns16550.c | 123 ++-
 include/ns16550.h|  10 
 3 files changed, 5 insertions(+), 138 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index a8e997834a..1c2c5d66e1 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -64,16 +64,6 @@ config DM_SERIAL
  implements serial_putc() etc. The uclass interface is
  defined in include/serial.h.
 
-config SERIAL_IRQ_BUFFER
-   bool "Enable RX interrupt buffer for serial input"
-   depends on DM_SERIAL
-   default n
-   help
- Enable RX interrupt buffer support for the serial driver.
- This enables pasting longer strings, even when the RX FIFO
- of the UART is not big enough (e.g. 16 bytes on the normal
- NS16550).
-
 config SPL_DM_SERIAL
bool "Enable Driver Model for serial drivers in SPL"
depends on DM_SERIAL
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 607a1b8c1d..c702304e79 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -314,80 +314,6 @@ DEBUG_UART_FUNCS
 #endif
 
 #ifdef CONFIG_DM_SERIAL
-
-#if CONFIG_IS_ENABLED(SERIAL_IRQ_BUFFER)
-
-#define BUF_COUNT  256
-
-static void rx_fifo_to_buf(struct udevice *dev)
-{
-   struct NS16550 *const com_port = dev_get_priv(dev);
-   struct ns16550_platdata *plat = dev->platdata;
-
-   /* Read all available chars into buffer */
-   while ((serial_in(_port->lsr) & UART_LSR_DR)) {
-   plat->buf[plat->wr_ptr++] = serial_in(_port->rbr);
-   plat->wr_ptr %= BUF_COUNT;
-   }
-}
-
-static int rx_pending(struct udevice *dev)
-{
-   struct ns16550_platdata *plat = dev->platdata;
-
-   /*
-* At startup it may happen, that some already received chars are
-* "stuck" in the RX FIFO, even with the interrupt enabled. This
-* RX FIFO flushing makes sure, that these chars are read out and
-* the RX interrupts works as expected.
-*/
-   rx_fifo_to_buf(dev);
-
-   return plat->rd_ptr != plat->wr_ptr ? 1 : 0;
-}
-
-static int rx_get(struct udevice *dev)
-{
-   struct ns16550_platdata *plat = dev->platdata;
-   char val;
-
-   val = plat->buf[plat->rd_ptr++];
-   plat->rd_ptr %= BUF_COUNT;
-
-   return val;
-}
-
-void ns16550_handle_irq(void *data)
-{
-   struct udevice *dev = (struct udevice *)data;
-   struct NS16550 *const com_port = dev_get_priv(dev);
-
-   /* Check if interrupt is pending */
-   if (serial_in(_port->iir) & UART_IIR_NO_INT)
-   return;
-
-   /* Flush all available characters from the RX FIFO into the RX buffer */
-   rx_fifo_to_buf(dev);
-}
-
-#else /* CONFIG_SERIAL_IRQ_BUFFER */
-
-static int rx_pending(struct udevice *dev)
-{
-   struct NS16550 *const com_port = dev_get_priv(dev);
-
-   return serial_in(_port->lsr) & UART_LSR_DR ? 1 : 0;
-}
-
-static int rx_get(struct udevice *dev)
-{
-   struct NS16550 *const com_port = dev_get_priv(dev);
-
-   return serial_in(_port->rbr);
-}
-
-#endif /* CONFIG_SERIAL_IRQ_BUFFER */
-
 static int ns16550_serial_putc(struct udevice *dev, const char ch)
 {
struct NS16550 *const com_port = dev_get_priv(dev);
@@ -413,17 +339,19 @@ static int ns16550_serial_pending(struct udevice *dev, 
bool input)
struct NS16550 *const com_port = dev_get_priv(dev);
 
if (input)
-   return rx_pending(dev);
+   return serial_in(_port->lsr) & UART_LSR_DR ? 1 : 0;
else
return serial_in(_port->lsr) & UART_LSR_THRE ? 0 : 1;
 }
 
 static int ns16550_serial_getc(struct udevice *dev)
 {
-   if (!ns16550_serial_pending(dev, true))
+   struct NS16550 *const com_port = dev_get_priv(dev);
+
+   if (!(serial_in(_port->lsr) & UART_LSR_DR))
return -EAGAIN;
 
-   return rx_get(dev);
+   return serial_in(_port->rbr);
 }
 
 static int ns16550_serial_setbrg(struct udevice *dev, int baudrate)
@@ -446,39 +374,8 @@ int ns16550_serial_probe(struct udevice *dev)
com_port->plat = dev_get_platdata(dev);
NS16550_init(com_port, -1);
 
-#if CONFIG_IS_ENABLED(SERIAL_IRQ_BUFFER)

[U-Boot] [PATCH 2/4] serial: serial-uclass: Add generic serial RX buffer support

2017-08-16 Thread Stefan Roese
Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX buffer support
for all DM based serial drivers. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
Cc: Tom Rini 
---
 drivers/serial/Kconfig | 15 +
 drivers/serial/serial-uclass.c | 48 --
 include/serial.h   | 10 -
 3 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 1c2c5d66e1..aeed538fa4 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -64,6 +64,21 @@ config DM_SERIAL
  implements serial_putc() etc. The uclass interface is
  defined in include/serial.h.
 
+config SERIAL_RX_BUFFER
+   bool "Enable RX buffer for serial input"
+   depends on DM_SERIAL
+   help
+ Enable RX buffer support for the serial driver. This enables
+ pasting longer strings, even when the RX FIFO of the UART is
+ not big enough (e.g. 16 bytes on the normal NS16550).
+
+config SERIAL_RX_BUFFER_SIZE
+   int "RX buffer size"
+   depends on SERIAL_RX_BUFFER
+   default 256
+   help
+ The size of the RX buffer (needs to be power of 2)
+
 config SPL_DM_SERIAL
bool "Enable Driver Model for serial drivers in SPL"
depends on DM_SERIAL
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 998d372da6..2e5116f7ce 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -160,7 +160,7 @@ static void _serial_puts(struct udevice *dev, const char 
*str)
_serial_putc(dev, *str++);
 }
 
-static int _serial_getc(struct udevice *dev)
+static int __serial_getc(struct udevice *dev)
 {
struct dm_serial_ops *ops = serial_get_ops(dev);
int err;
@@ -174,7 +174,7 @@ static int _serial_getc(struct udevice *dev)
return err >= 0 ? err : 0;
 }
 
-static int _serial_tstc(struct udevice *dev)
+static int __serial_tstc(struct udevice *dev)
 {
struct dm_serial_ops *ops = serial_get_ops(dev);
 
@@ -184,6 +184,44 @@ static int _serial_tstc(struct udevice *dev)
return 1;
 }
 
+#if CONFIG_IS_ENABLED(SERIAL_RX_BUFFER)
+static int _serial_tstc(struct udevice *dev)
+{
+   struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
+
+   /* Read all available chars into the RX buffer */
+   while (__serial_tstc(dev)) {
+   upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
+   upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
+   }
+
+   return upriv->rd_ptr != upriv->wr_ptr ? 1 : 0;
+}
+
+static int _serial_getc(struct udevice *dev)
+{
+   struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
+   char val;
+
+   val = upriv->buf[upriv->rd_ptr++];
+   upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
+
+   return val;
+}
+
+#else /* CONFIG_IS_ENABLED(SERIAL_RX_BUFFER) */
+
+static int _serial_getc(struct udevice *dev)
+{
+   return __serial_getc(dev);
+}
+
+static int _serial_tstc(struct udevice *dev)
+{
+   return __serial_tstc(dev);
+}
+#endif /* CONFIG_IS_ENABLED(SERIAL_RX_BUFFER) */
+
 void serial_putc(char ch)
 {
if (gd->cur_serial_dev)
@@ -359,6 +397,12 @@ static int serial_post_probe(struct udevice *dev)
sdev.puts = serial_stub_puts;
sdev.getc = serial_stub_getc;
sdev.tstc = serial_stub_tstc;
+
+#if CONFIG_IS_ENABLED(SERIAL_RX_BUFFER)
+   /* Allocate the RX buffer */
+   upriv->buf = malloc(CONFIG_SERIAL_RX_BUFFER_SIZE);
+#endif
+
stdio_register_dev(, >sdev);
 #endif
return 0;
diff --git a/include/serial.h b/include/serial.h
index f4171964ae..d87f01082a 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -148,10 +148,18 @@ struct dm_serial_ops {
 /**
  * struct serial_dev_priv - information about a device used by the uclass
  *
- * @sdev: stdio device attached to this uart
+ * @sdev:  stdio device attached to this uart
+ *
+ * @buf:   Pointer to the RX buffer
+ * @rd_ptr:Read pointer in the RX buffer
+ * @wr_ptr:Write pointer in the RX buffer
  */
 struct serial_dev_priv {
struct stdio_dev *sdev;
+
+   char *buf;
+   int rd_ptr;
+   int wr_ptr;
 };
 
 /* Access the serial operations for a device */
-- 
2.14.1

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


[U-Boot] [PATCH 3/4] x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

2017-08-16 Thread Stefan Roese
To support more input characters (longer stings pasted into the U-Boot
prompt) without dropping, lets selects the recently added UART RX
buffer for these boards.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
---
 board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/congatec/conga-qeval20-qa3-e3845/Kconfig 
b/board/congatec/conga-qeval20-qa3-e3845/Kconfig
index e1fae737ac..9e44413c2c 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Kconfig
+++ b/board/congatec/conga-qeval20-qa3-e3845/Kconfig
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select SPI_FLASH_STMICRO
imply SPI_FLASH_SPANSION
imply SPI_FLASH_WINBOND
+   select SERIAL_RX_BUFFER
 
 config PCIE_ECAM_BASE
default 0xe000
-- 
2.14.1

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


[U-Boot] [PATCH 4/4] x86: dfi-bt700: Select SERIAL_RX_BUFFER via Kconfig

2017-08-16 Thread Stefan Roese
To support more input characters (longer stings pasted into the U-Boot
prompt) without dropping, lets selects the recently added UART RX
buffer for these boards.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Bin Meng 
---
 board/dfi/dfi-bt700/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/dfi/dfi-bt700/Kconfig b/board/dfi/dfi-bt700/Kconfig
index 4b6c3fc56c..f92f50a448 100644
--- a/board/dfi/dfi-bt700/Kconfig
+++ b/board/dfi/dfi-bt700/Kconfig
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select SPI_FLASH_STMICRO
imply SPI_FLASH_SPANSION
imply SPI_FLASH_WINBOND
+   select SERIAL_RX_BUFFER
 
 config PCIE_ECAM_BASE
default 0xe000
-- 
2.14.1

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


[U-Boot] Pull request, u-boot-tegra/master

2017-08-16 Thread Tom Warren
Tom,

Please pull u-boot-tegra/master into U-Boot/master. Thanks!

All Tegra builds are OK, and Stephen's automated test system reports that
all tests pass.

The following changes since commit 2d3c4ae350fe8c196698681ab9410733bf9017e0:

  Prepare v2017.09-rc2 (2017-08-14 20:02:11 -0400)

are available in the git repository at:

  git://git.denx.de/u-boot-tegra.git master

for you to fetch changes up to 33848eb53e00156bb6bade1955b09d12daeffdc6:

  apalis_t30/tk1, colibri_t20/t30: fix i2c bus frequencies (2017-08-15
14:51:18 -0700)


Marcel Ziswiler (4):
  apalis_t30: fix usb otg power enable
  dm: tegra: move apalis t30/tk1, colibri t20/t30 to livetree
  apalis-tk1: remove duplicate hdmi_ddc device tree node
  apalis_t30/tk1, colibri_t20/t30: fix i2c bus frequencies

 arch/arm/dts/tegra124-apalis.dts| 10 +++---
 arch/arm/dts/tegra20-colibri.dts|  4 ++--
 arch/arm/dts/tegra30-apalis.dts |  6 +++---
 arch/arm/dts/tegra30-colibri.dts|  4 ++--
 board/toradex/apalis_t30/pinmux-config-apalis_t30.h |  4 ++--
 configs/apalis-tk1_defconfig|  4 
 configs/apalis_t30_defconfig|  1 +
 configs/colibri_t20_defconfig   |  1 +
 configs/colibri_t30_defconfig   |  1 +
 9 files changed, 19 insertions(+), 16 deletions(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] rk3288: 32KB SPL size restriction

2017-08-16 Thread Dr. Philipp Tomsich
Jagan,

> On 16 Aug 2017, at 15:12, Jagan Teki  wrote:
> 
> Hi Simon,
> 
> On Mon, Aug 14, 2017 at 11:01 PM, Jagan Teki  wrote:
>> On Mon, Aug 14, 2017 at 10:03 AM, Jagan Teki  
>> wrote:
>>> Hi Simon,
>>> 
>>> On Mon, Aug 14, 2017 at 3:06 AM, Simon Glass  wrote:
 Hi Jagan,
 
 On 10 August 2017 at 03:07, Jagan Teki  wrote:
> Hi Simon/Philipp or any,
> 
> I believe rk3288 has 20KB BootRom and 100KB internal SRAM and current
> u-boot can archive the maximum size of u-boot-spl-dtb.bin which the
> boot ROM will read is 32KB, do we have any possibility to increase the
> SPL size here.
> 
> # ./tools/mkimage -n rk3288 -T rksd -d ./spl/u-boot-spl-dtb.bin out.img
> Warning: SPL image is too large (size 0x9000) and will not boot
> Error: image verification failed
> 
> I tried to increase the spl_size from spl_infos (on tools/rkcommon.c)
> but not able to boot.
 
 I thought all boards were OK at present. Which board is this? Also
 which toolchain are you using? There was a bug that bloating the
 static data a bit.
>>> 
>>> Board similar to firefly-rk3288 and not using
>>> ROCKCHIP_SPL_BACK_TO_BROM. Observed this when I try to add falcon mode
>>> support which eventually increased the SPL size.
>>> 
>>> toolchain: arm-linux-gnueabi-gcc with version 6.3.1 20170109 (Linaro
>>> GCC 6.3-2017.02)
>> 
>> And it is increasing further with gcc-4.7
> 
> Any comments?

I don’t really know too much about the RK3288’s BROM, but I would expect a limit
on the loadable size for the initial stage (this is what the ‘back-to-bootrom’ 
is for).

You can easily check if that is the case (and it 20KB is the limited for this) 
by
padding the unmodified SPL with zeros… if things break once crossing the 20KB
boundary, the BROM’s size-limitation is most likely blame.

> thanks!
> -- 
> Jagan Teki
> Free Software Engineer | www.openedev.com
> U-Boot, Linux | Upstream Maintainer
> Hyderabad, India.

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


Re: [U-Boot] rockchip: rk3399-firefly: update gmac parameter

2017-08-16 Thread Philipp Tomsich
> Update the tx_deday and rx_delay to match the timing for
> rk3399-firefly board to improve the stability of gmac data
> transfer.
> 
> Signed-off-by: Kever Yang 
> Acked-by: Philipp Tomsich 
> Reviewed-by: Philipp Tomsich 
> ---
> 
>  arch/arm/dts/rk3399-firefly.dts | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Applied to u-boot-rockchip, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] vbe: Drop vbe_get_video_info()

2017-08-16 Thread Bin Meng
With DM video, this is not used any more. Drop it.

Signed-off-by: Bin Meng 
---

 drivers/pci/pci_rom.c | 41 -
 include/vbe.h |  2 --
 2 files changed, 43 deletions(-)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 75fb093..46fe5e6 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -202,47 +202,6 @@ static int pci_rom_load(struct pci_rom_header *rom_header,
 
 struct vbe_mode_info mode_info;
 
-int vbe_get_video_info(struct graphic_device *gdev)
-{
-#ifdef CONFIG_FRAMEBUFFER_SET_VESA_MODE
-   struct vesa_mode_info *vesa = _info.vesa;
-
-   gdev->winSizeX = vesa->x_resolution;
-   gdev->winSizeY = vesa->y_resolution;
-
-   gdev->plnSizeX = vesa->x_resolution;
-   gdev->plnSizeY = vesa->y_resolution;
-
-   gdev->gdfBytesPP = vesa->bits_per_pixel / 8;
-
-   switch (vesa->bits_per_pixel) {
-   case 32:
-   case 24:
-   gdev->gdfIndex = GDF_32BIT_X888RGB;
-   break;
-   case 16:
-   gdev->gdfIndex = GDF_16BIT_565RGB;
-   break;
-   default:
-   gdev->gdfIndex = GDF__8BIT_INDEX;
-   break;
-   }
-
-   gdev->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
-   gdev->pciBase = vesa->phys_base_ptr;
-
-   gdev->frameAdrs = vesa->phys_base_ptr;
-   gdev->memSize = vesa->bytes_per_scanline * vesa->y_resolution;
-
-   gdev->vprBase = vesa->phys_base_ptr;
-   gdev->cprBase = vesa->phys_base_ptr;
-
-   return gdev->winSizeX ? 0 : -ENOSYS;
-#else
-   return -ENOSYS;
-#endif
-}
-
 void setup_video(struct screen_info *screen_info)
 {
struct vesa_mode_info *vesa = _info.vesa;
diff --git a/include/vbe.h b/include/vbe.h
index 16bb096..d6980d9 100644
--- a/include/vbe.h
+++ b/include/vbe.h
@@ -104,8 +104,6 @@ struct vbe_ddc_info {
 
 extern struct vbe_mode_info mode_info;
 
-struct graphic_device;
-int vbe_get_video_info(struct graphic_device *gdev);
 struct video_priv;
 struct video_uc_platdata;
 int vbe_setup_video_priv(struct vesa_mode_info *vesa,
-- 
2.9.2

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


Re: [U-Boot] [PATCH v2 00/19] add support for rk3066 platform.

2017-08-16 Thread Dr. Philipp Tomsich
Pawel,

Could you rebase this onto the current master (the SPL/TPL changes for
the RK3368 are likely to have affected a few things) and resubmit?

Thanks,
Philipp.

> On 11 Aug 2017, at 22:53, Paweł Jarosz  wrote:
> 
> This patch serie adds support for Rockchip RK3066 processor.
> 
> Paweł Jarosz (19):
>  rockchip: rk3066: add grf header file
>  rockchip: rk3066: add rk3066 pinctrl driver
>  rockchip: rk3066: add sysreset driver
>  rockchip: rk3066: add clock driver for rk3066 soc
>  rockchip: rk3066: add rk3066 platform devicetree file
>  rockchip: rk3066: add core support
>  rockchip: rk3066: add mk808 board files
>  rockchip: rk3066: add sdram driver
>  mtd: nand: add support for the Sandisk SDTNQGAMA chip
>  mtd: nand: add the rockchip nand controller driver
>  rockchip: mkimage: add support for rockchip nand boot image
>  rockchip: board: rk3066: convert board_usb_init to live tree functions
>  ARM: dts: rockchip: prefer u-boot,dm-pre-reloc rather than
>u-boot,dm-spl
>  mmc: dw_mmc: support transfer mode autodetection
>  mmc: dw_mmc: rockchip: add support for rk3066 sdmmc
>  armv7: support rk3066 early back to bootrom in vector.S
>  rockchip: sysreset: deduplicate rk3066 and rk3188 sysreset drivers
>  dfu: fix spl build
>  mtd: nand: spl: allow build nand_bbt, nand_ids and nand_util
> 
> arch/arm/dts/Makefile  |   1 +
> arch/arm/dts/rk3066a-mk808.dts | 189 +
> arch/arm/dts/rk3066a.dtsi  | 707 +++
> arch/arm/dts/rk3xxx.dtsi   |   8 +-
> arch/arm/include/asm/arch-rockchip/boot0.h |  14 +
> arch/arm/include/asm/arch-rockchip/cru_rk3066.h| 189 +
> arch/arm/include/asm/arch-rockchip/grf_rk3066.h| 621 ++
> arch/arm/include/asm/arch-rockchip/periph.h|   1 +
> .../include/asm/arch-rockchip/sysreset_common.h|  20 +
> arch/arm/lib/vectors.S |  18 +-
> arch/arm/mach-rockchip/Kconfig |  16 +
> arch/arm/mach-rockchip/Makefile|   7 +
> arch/arm/mach-rockchip/rk3066-board-spl.c  | 139 +++
> arch/arm/mach-rockchip/rk3066-board-tpl.c  |  90 ++
> arch/arm/mach-rockchip/rk3066-board.c  | 112 +++
> arch/arm/mach-rockchip/rk3066/Kconfig  |  31 +
> arch/arm/mach-rockchip/rk3066/Makefile |   9 +
> arch/arm/mach-rockchip/rk3066/clk_rk3066.c |  33 +
> arch/arm/mach-rockchip/rk3066/sdram_rk3066.c   | 943 +
> arch/arm/mach-rockchip/rk3066/syscon_rk3066.c  |  54 ++
> arch/arm/mach-rockchip/sysreset-common.c   |  39 +
> board/rikomagic/mk808_rk3066/Kconfig   |  15 +
> board/rikomagic/mk808_rk3066/MAINTAINERS   |   6 +
> board/rikomagic/mk808_rk3066/Makefile  |   7 +
> board/rikomagic/mk808_rk3066/mk808_rk3066.c|  10 +
> common/image.c |   1 +
> configs/mk808_defconfig| 115 +++
> drivers/clk/rockchip/Makefile  |   1 +
> drivers/clk/rockchip/clk_rk3066.c  | 587 +
> drivers/dfu/dfu_nand.c |   6 +-
> drivers/mmc/dw_mmc.c   |   8 +
> drivers/mmc/rockchip_dw_mmc.c  |   1 +
> drivers/mtd/nand/Kconfig   |   6 +
> drivers/mtd/nand/Makefile  |   4 +
> drivers/mtd/nand/nand_ids.c|   3 +
> drivers/mtd/nand/rockchip_nand.c   | 660 ++
> drivers/pinctrl/Kconfig|   9 +
> drivers/pinctrl/rockchip/Makefile  |   1 +
> drivers/pinctrl/rockchip/pinctrl_rk3066.c  | 340 
> drivers/sysreset/Makefile  |   1 +
> drivers/sysreset/sysreset_rk3066.c |  49 ++
> drivers/sysreset/sysreset_rk3188.c |  35 +-
> include/configs/mk808_rk3066.h |  61 ++
> include/configs/rk3066_common.h|  99 +++
> include/dwmmc.h|   4 +
> include/fdtdec.h   |   1 +
> include/image.h|   1 +
> lib/fdtdec.c   |   1 +
> tools/Makefile |   2 +-
> tools/imagetool.h  |   1 +
> tools/mkimage.c|   8 +-
> tools/rkcommon.c   |  10 +-
> tools/rkcommon.h   |  10 +-
> tools/rknand.c | 156 
> tools/rksd.c   |   2 +-
> tools/rkspi.c  |   2 +-
> 56 files changed, 5416 insertions(+), 48 deletions(-)
> create mode 100644 arch/arm/dts/rk3066a-mk808.dts
> create mode 

Re: [U-Boot] [U-Boot,v5,15/30] env: Drop common init() functions

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:02PM -0600, Simon Glass wrote:

> Most of the init() implementations just use the default environment.
> Adjust env_init_new() to do this automatically, and drop the redundant
> code.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 30/30] env: Adjust the load() method to return an error

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:17PM -0600, Simon Glass wrote:

> The load() methods have inconsistent behaviour on error. Some of them load
> an empty default environment. Some load an environment containing an error
> message. Others do nothing.
> 
> As a step in the right direction, have the method return an error code.
> Then the caller could handle this itself in a consistent way.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 28/30] env: Rename some other getenv()-related functions

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:15PM -0600, Simon Glass wrote:

> We are now using an env_ prefix for environment functions. Rename these
> other functions as well, for consistency:
> 
>getenv_vlan()
>getenv_bootm_size()
>getenv_bootm_low()
>getenv_bootm_mapsize()
>env_get_default()
> 
> Suggested-by: Wolfgang Denk 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 23/30] env: Rename common functions related to setenv()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:10PM -0600, Simon Glass wrote:

> We are now using an env_ prefix for environment functions. Rename these
> commonly used functions, for consistency. Also add function comments in
> common.h.
> 
> Suggested-by: Wolfgang Denk 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 29/30] env: Adjust the get_char() method to return an int

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:16PM -0600, Simon Glass wrote:

> In principle this can fail, e.g. if the index is out of range. Adjust the
> driver signature to allow returning an error code.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 24/30] env: Rename eth_setenv_enetaddr() to eth_env_set_enetaddr()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:11PM -0600, Simon Glass wrote:

> Rename this function for consistency with env_set().
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot,v5,19/30] env: Drop env_get_char_spec()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:06PM -0600, Simon Glass wrote:

> We only have a single implementation of this function now and it is called
> env_get_char(). Drop the old function and the weak version.
> 
> Reviewed-by: Tom Rini 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 26/30] env: Rename getenv_hex(), getenv_yesno(), getenv_ulong()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:13PM -0600, Simon Glass wrote:

> We are now using an env_ prefix for environment functions. Rename these
> for consistency. Also add function comments in common.h.
> 
> Suggested-by: Wolfgang Denk 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 21/30] env: Drop saveenv() in favour of env_save()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:08PM -0600, Simon Glass wrote:

> Use the env_save() function directly now that there is only one
> implementation of saveenv().
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Wolfgang Denk 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot,v5,18/30] env: Drop env_init_new()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:05PM -0600, Simon Glass wrote:

> Now that env_init() is only defined once we can drop the env_init_new()
> name and just use env_init().
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 27/30] env: Rename eth_getenv_enetaddr() to eth_env_get_enetaddr()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:14PM -0600, Simon Glass wrote:

> Rename this function for consistency with env_get().
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 25/30] env: Rename getenv/_f() to env_get()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:12PM -0600, Simon Glass wrote:

> We are now using an env_ prefix for environment functions. Rename these
> two functions for consistency. Also add function comments in common.h.
> 
> Quite a few places use getenv() in a condition context, provoking a
> warning from checkpatch. These are fixed up in this patch also.
> 
> Suggested-by: Wolfgang Denk 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot,v5,16/30] env: Drop the env_name_spec global

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:03PM -0600, Simon Glass wrote:

> Add a name to the driver and use that instead of the global variable
> declared by each driver.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 04/30] env: common: Make env_get_addr/get_char_memory() static

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:21:51PM -0600, Simon Glass wrote:

> These functions are not used outside this file. Make them static and order
> them to avoid forward declarations.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 12/30] env: Convert CONFIG_ENV_IS_IN... to a choice

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:21:59PM -0600, Simon Glass wrote:

> At present we support multiple environment drivers but there is not way to
> select between them at run time. Also settings related to the position and
> size of the environment area are global (i.e. apply to all locations).
> 
> Until these limitations are removed we cannot really support more than one
> environment location. Adjust the location to be a choice so that only one
> can be selected. By default the environment is 'nowhere', meaning that the
> environment exists only in memory and cannot be saved.
> 
> Also expand the help for the 'nowhere' option and move it to the top since
> it is the default.
> 
> Signed-off-by: Simon Glass 

After some changes to migrate all of the imply ENV_... to default
ENV_... if ... statements, applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot,v5,17/30] env: Drop unused env_ptr variables

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:04PM -0600, Simon Glass wrote:

> This variable is declared as a global in most environment location
> drivers. But it is not used outside the drivers and most of the
> declarations are unnecessary.
> 
> Also some drivers call free() on env_ptr which seems wrong since it is
> not in the heap.
> 
> Drop the variable where possible, and all calls to free().
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 08/30] env: common: Drop env_get_char_memory()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:21:55PM -0600, Simon Glass wrote:

> This function is the same as env_get_char_spec() apart from dropping the
> brackets. Drop the brackets from env_get_char_spec() and use that instead
> of env_get_char_memory().
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 20/30] env: Drop env_relocate_spec() in favour of env_load()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:07PM -0600, Simon Glass wrote:

> This is a strange name for a function that loads the environment. There is
> now only one implementation of this function, so use the new env_load()
> function directly instead.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 14/30] env: Switch over to use environment location drivers

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:01PM -0600, Simon Glass wrote:

> Move over to use a the master implementation of the location drivers, with
> each method calling out to the appropriate driver.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot, v5, 06/30] env: common: Factor out the common env_valid check

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:21:53PM -0600, Simon Glass wrote:

> The check for gd->env_valid is used in both the 'if' and 'else' part of
> env_get_char(). Move it into that function instead for simplicity. Drop
> that code from the two leaf functions.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [U-Boot,v5,22/30] env: Rename setenv() to env_set()

2017-08-16 Thread Tom Rini
On Thu, Aug 03, 2017 at 12:22:09PM -0600, Simon Glass wrote:

> We are now using an env_ prefix for environment functions. Rename setenv()
> for consistency. Also add function comments in common.h.
> 
> Suggested-by: Wolfgang Denk 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


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


  1   2   >