[U-Boot] [PATCH v2 52/55] rockchip: sdram: Move all DT decoding to ofdata_to_platdata()

2016-06-12 Thread Simon Glass
It is more correct to avoid touching the device tree in the probe() method.
Update the driver to work this way. Note that only SPL needs to fiddle with
the SDRAM registers, so decoding the platform data fully is not necessary in
U-Boot proper.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/include/asm/arch-rockchip/sdram.h   |  8 ---
 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 91 ++--
 2 files changed, 60 insertions(+), 39 deletions(-)

diff --git a/arch/arm/include/asm/arch-rockchip/sdram.h 
b/arch/arm/include/asm/arch-rockchip/sdram.h
index c9e3001..e08e28f 100644
--- a/arch/arm/include/asm/arch-rockchip/sdram.h
+++ b/arch/arm/include/asm/arch-rockchip/sdram.h
@@ -87,12 +87,4 @@ struct rk3288_base_params {
u32 odt;
 };
 
-struct rk3288_sdram_params {
-   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;
-};
-
 #endif
diff --git a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c 
b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
index 2e21282..4e5186e 100644
--- a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
@@ -43,6 +43,15 @@ struct dram_info {
struct rk3288_pmu *pmu;
 };
 
+struct rk3288_sdram_params {
+   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;
+};
+
 #ifdef CONFIG_SPL_BUILD
 static void copy_to_reg(u32 *dest, const u32 *src, u32 n)
 {
@@ -703,7 +712,7 @@ static int sdram_init(const struct dram_info *dram,
 
return 0;
 }
-#endif
+#endif /* CONFIG_SPL_BUILD */
 
 size_t sdram_size_mb(struct rk3288_pmu *pmu)
 {
@@ -779,18 +788,33 @@ static int veyron_init(struct dram_info *priv)
 static int setup_sdram(struct udevice *dev)
 {
struct dram_info *priv = dev_get_priv(dev);
-   struct rk3288_sdram_params params;
+   struct rk3288_sdram_params *params = dev_get_platdata(dev);
+
+# ifdef CONFIG_ROCKCHIP_FAST_SPL
+   if (priv->is_veyron) {
+   ret = veyron_init(priv);
+   if (ret)
+   return ret;
+   }
+# endif
+
+   return sdram_init(priv, params);
+}
+
+static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev)
+{
+   struct rk3288_sdram_params *params = dev_get_platdata(dev);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
int i, ret;
 
-   params.num_channels = fdtdec_get_int(blob, node,
-"rockchip,num-channels", 1);
-   for (i = 0; i < params.num_channels; i++) {
+   params->num_channels = fdtdec_get_int(blob, node,
+ "rockchip,num-channels", 1);
+   for (i = 0; i < params->num_channels; i++) {
ret = fdtdec_get_byte_array(blob, node,
"rockchip,sdram-channel",
-   (u8 *)[i],
-   sizeof(params.ch[i]));
+   (u8 *)>ch[i],
+   sizeof(params->ch[i]));
if (ret) {
debug("%s: Cannot read rockchip,sdram-channel\n",
  __func__);
@@ -798,41 +822,42 @@ static int setup_sdram(struct udevice *dev)
}
}
ret = fdtdec_get_int_array(blob, node, "rockchip,pctl-timing",
-  (u32 *)_timing,
-  sizeof(params.pctl_timing) / sizeof(u32));
+  (u32 *)>pctl_timing,
+  sizeof(params->pctl_timing) / sizeof(u32));
if (ret) {
debug("%s: Cannot read rockchip,pctl-timing\n", __func__);
return -EINVAL;
}
ret = fdtdec_get_int_array(blob, node, "rockchip,phy-timing",
-  (u32 *)_timing,
-  sizeof(params.phy_timing) / sizeof(u32));
+  (u32 *)>phy_timing,
+  sizeof(params->phy_timing) / sizeof(u32));
if (ret) {
debug("%s: Cannot read rockchip,phy-timing\n", __func__);
return -EINVAL;
}
ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params",
-  (u32 *),
-  sizeof(params.base) / sizeof(u32));
+  (u32 *)>base,
+  sizeof(params->base) / sizeof(u32));
if (ret) {
debug("%s: Cannot read rockchip,sdram-params\n", __func__);
  

[U-Boot] [PATCH v2 44/55] rockchip: mmc: Move all DT decoding to ofdata_to_platdata()

2016-06-12 Thread Simon Glass
It is more correct to avoid touching the device tree in the probe() method.
Update the driver to work this way.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/rockchip_dw_mmc.c | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 750ab9f..26004be 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -27,6 +27,9 @@ struct rockchip_dwmmc_priv {
struct udevice *clk;
int periph;
struct dwmci_host host;
+   int fifo_depth;
+   bool fifo_mode;
+   u32 minmax[2];
 };
 
 static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
@@ -62,6 +65,16 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice 
*dev)
else
host->dev_index = 1;
 
+   priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+   "fifo-depth", 0);
+   if (priv->fifo_depth < 0)
+   return -EINVAL;
+   priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+ "fifo-mode");
+   if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+"clock-freq-min-max", priv->minmax, 2))
+   return -EINVAL;
+
return 0;
 }
 
@@ -74,29 +87,18 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
struct dwmci_host *host = >host;
struct udevice *pwr_dev __maybe_unused;
-   u32 minmax[2];
int ret;
-   int fifo_depth;
 
ret = clk_get_by_index(dev, 0, >clk);
if (ret < 0)
return ret;
priv->periph = ret;
 
-   if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
-"clock-freq-min-max", minmax, 2))
-   return -EINVAL;
-
-   fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-   "fifo-depth", 0);
-   if (fifo_depth < 0)
-   return -EINVAL;
-
host->fifoth_val = MSIZE(0x2) |
-   RX_WMARK(fifo_depth / 2 - 1) | TX_WMARK(fifo_depth / 2);
+   RX_WMARK(priv->fifo_depth / 2 - 1) |
+   TX_WMARK(priv->fifo_depth / 2);
 
-   if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "fifo-mode"))
-   host->fifo_mode = true;
+   host->fifo_mode = priv->fifo_mode;
 
 #ifdef CONFIG_PWRSEQ
/* Enable power if needed */
@@ -110,10 +112,10 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 #endif
 #ifdef CONFIG_BLK
dwmci_setup_cfg(>cfg, dev->name, host->buswidth, host->caps,
-   minmax[1], minmax[0]);
+   priv->minmax[1], priv->minmax[0]);
host->mmc = >mmc;
 #else
-   ret = add_dwmci(host, minmax[1], minmax[0]);
+   ret = add_dwmci(host, priv->minmax[1], priv->minmax[0]);
if (ret)
return ret;
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 38/55] dm: core: Expand platdata for of-platdata devices

2016-06-12 Thread Simon Glass
Devices which use of-platdata have their own platdata. However, in many
cases the driver will have its own auto-alloced platdata, for use with the
device tree. The ofdata_to_platdata() method converts the device tree
settings to platdata.

With of-platdata we would not normally allocate the platdata since it is
provided by the U_BOOT_DEVICE() declaration. However this is inconvenient
since the of-platdata struct is closely tied to the device tree properties.
It is unlikely to exactly match the platdata needed by the driver.

In fact a useful approach is to declare platdata in the driver like this:

struct r3288_mmc_platdata {
struct dtd_rockchip_rk3288_dw_mshc of_platdata;
/* the 'normal' fields go here */
};

In this case we have dt_platadata available, but the normal fields are not
present, since ofdata_to_platdata() is never called. In fact driver model
doesn't allocate any space for the 'normal' fields, since it sees that there
is already platform data attached to the device.

To make this easier, adjust driver model to allocate the full size of the
struct (i.e. platdata_auto_alloc_size from the driver) and copy in the
of-platdata. This means that when the driver's bind() method is called,
the of-platdata will be present, followed by zero bytes for the empty
'normal field' portion.

A new DM_FLAG_OF_PLATDATA flag is available that indicates that the platdata
came from of-platdata. When the allocation/copy happens, the
DM_FLAG_ALLOC_PDATA flag will be set as well. The dtoc tool is updated to
output the platdata_size field, since U-Boot has no other way of knowing
the size of the of-platdata struct.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/device.c | 41 ++---
 include/dm/device.h   |  2 ++
 include/dm/platdata.h |  5 +
 tools/dtoc/dtoc.py|  2 ++
 4 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index d3b731e..f6d867c 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -29,7 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int device_bind_common(struct udevice *parent, const struct driver *drv,
  const char *name, void *platdata,
  ulong driver_data, int of_offset,
- struct udevice **devp)
+ uint of_platdata_size, struct udevice **devp)
 {
struct udevice *dev;
struct uclass *uc;
@@ -83,12 +83,27 @@ static int device_bind_common(struct udevice *parent, const 
struct driver *drv,
}
}
 
-   if (!dev->platdata && drv->platdata_auto_alloc_size) {
-   dev->flags |= DM_FLAG_ALLOC_PDATA;
-   dev->platdata = calloc(1, drv->platdata_auto_alloc_size);
-   if (!dev->platdata) {
-   ret = -ENOMEM;
-   goto fail_alloc1;
+   if (drv->platdata_auto_alloc_size) {
+   bool alloc = !platdata;
+
+   if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
+   if (of_platdata_size)
+   dev->flags |= DM_FLAG_OF_PLATDATA;
+   if (of_platdata_size < drv->platdata_auto_alloc_size)
+   alloc = true;
+   }
+   if (alloc) {
+   dev->flags |= DM_FLAG_ALLOC_PDATA;
+   dev->platdata = calloc(1,
+  drv->platdata_auto_alloc_size);
+   if (!dev->platdata) {
+   ret = -ENOMEM;
+   goto fail_alloc1;
+   }
+   if (CONFIG_IS_ENABLED(OF_PLATDATA) && platdata) {
+   memcpy(dev->platdata, platdata,
+  of_platdata_size);
+   }
}
}
 
@@ -201,14 +216,14 @@ int device_bind_with_driver_data(struct udevice *parent,
 struct udevice **devp)
 {
return device_bind_common(parent, drv, name, NULL, driver_data,
- of_offset, devp);
+ of_offset, 0, devp);
 }
 
 int device_bind(struct udevice *parent, const struct driver *drv,
const char *name, void *platdata, int of_offset,
struct udevice **devp)
 {
-   return device_bind_common(parent, drv, name, platdata, 0, of_offset,
+   return device_bind_common(parent, drv, name, platdata, 0, of_offset, 0,
  devp);
 }
 
@@ -216,6 +231,7 @@ int device_bind_by_name(struct udevice *parent, bool 
pre_reloc_only,
const struct driver_info *info, struct udevice **devp)
 {
struct driver *drv;
+   uint platdata_size = 0;
 
drv = lists_driver_lookup_name(info->name);
if (!drv)

[U-Boot] [PATCH v2 34/55] dm: spl: Bind in all devices in SPL with of-platdata

2016-06-12 Thread Simon Glass
When CONFIG_OF_PLATDATA is enabled, we cannot use the u-boot,dm-pre-reloc
device tree property since the device tree is not available. However,
dt-platdata.c only includes devices which would have been present in the
device tree, and we can assume that all such devices are needed for SPL.
If they were not needed, they would have been omitted to save space.

So in this case, bind all devices regardless of the u-boot,dm-pre-reloc
setting. This avoids needing to add a DM_FLAG_PRE_RELOC to every driver,
thus affecting U-Boot proper also.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/spl/spl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 59f41a1..12aed02 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -210,7 +210,8 @@ int spl_init(void)
}
}
if (IS_ENABLED(CONFIG_SPL_DM)) {
-   ret = dm_init_and_scan(true);
+   /* With CONFIG_OF_PLATDATA, bring in all devices */
+   ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
if (ret) {
debug("dm_init_and_scan() returned error %d\n", ret);
return ret;
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 28/55] dm: Add a library to provide simple device-tree access

2016-06-12 Thread Simon Glass
This Python library provides a way to access the contents of the device
tree. It uses fdtget, so is inefficient for larger device tree files.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/.gitignore  |   1 +
 tools/dtoc/fdt_fallback.py | 207 +
 tools/dtoc/fdt_util.py |  71 
 3 files changed, 279 insertions(+)
 create mode 100644 tools/dtoc/.gitignore
 create mode 100644 tools/dtoc/fdt_fallback.py
 create mode 100644 tools/dtoc/fdt_util.py

diff --git a/tools/dtoc/.gitignore b/tools/dtoc/.gitignore
new file mode 100644
index 000..0d20b64
--- /dev/null
+++ b/tools/dtoc/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/tools/dtoc/fdt_fallback.py b/tools/dtoc/fdt_fallback.py
new file mode 100644
index 000..14decf3
--- /dev/null
+++ b/tools/dtoc/fdt_fallback.py
@@ -0,0 +1,207 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2016 Google, Inc
+# Written by Simon Glass 
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+import command
+import fdt_util
+import sys
+
+# This deals with a device tree, presenting it as a list of Node and Prop
+# objects, representing nodes and properties, respectively.
+#
+# This implementation uses the fdtget tool to access the device tree, so it
+# is not very efficient for larger trees. The tool is called once for each
+# node and property in the tree.
+
+class Prop:
+"""A device tree property
+
+Properties:
+name: Property name (as per the device tree)
+value: Property value as a string of bytes, or a list of strings of
+bytes
+type: Value type
+"""
+def __init__(self, name, byte_list_str):
+self.name = name
+self.value = None
+if not byte_list_str.strip():
+self.type = fdt_util.TYPE_BOOL
+return
+bytes = [chr(int(byte, 16)) for byte in byte_list_str.strip().split(' 
')]
+self.type, self.value = fdt_util.BytesToValue(''.join(bytes))
+
+def GetPhandle(self):
+"""Get a (single) phandle value from a property
+
+Gets the phandle valuie from a property and returns it as an integer
+"""
+return fdt_util.fdt32_to_cpu(self.value[:4])
+
+def Widen(self, newprop):
+"""Figure out which property type is more general
+
+Given a current property and a new property, this function returns the
+one that is less specific as to type. The less specific property will
+be ble to represent the data in the more specific property. This is
+used for things like:
+
+node1 {
+compatible = "fred";
+value = <1>;
+};
+node1 {
+compatible = "fred";
+value = <1 2>;
+};
+
+He we want to use an int array for 'value'. The first property
+suggests that a single int is enough, but the second one shows that
+it is not. Calling this function with these two propertes would
+update the current property to be like the second, since it is less
+specific.
+"""
+if newprop.type < self.type:
+self.type = newprop.type
+
+if type(newprop.value) == list and type(self.value) != list:
+self.value = newprop.value
+
+class Node:
+"""A device tree node
+
+Properties:
+name: Device tree node tname
+path: Full path to node, along with the node name itself
+_fdt: Device tree object
+subnodes: A list of subnodes for this node, each a Node object
+props: A dict of properties for this node, each a Prop object.
+Keyed by property name
+"""
+def __init__(self, fdt, name, path):
+self.name = name
+self.path = path
+self._fdt = fdt
+self.subnodes = []
+self.props = {}
+
+def Scan(self):
+"""Scan a node's properties and subnodes
+
+This fills in the props and subnodes properties, recursively
+searching into subnodes so that the entire tree is built.
+"""
+for name, byte_list_str in self._fdt.GetProps(self.path).iteritems():
+prop = Prop(name, byte_list_str)
+self.props[name] = prop
+
+for name in self._fdt.GetSubNodes(self.path):
+sep = '' if self.path[-1] == '/' else '/'
+path = self.path + sep + name
+node = Node(self._fdt, name, path)
+self.subnodes.append(node)
+
+node.Scan()
+
+
+class Fdt:
+"""Provides simple access to a flat device tree blob.
+
+Properties:
+  fname: Filename of fdt
+  _root: Root of device tree (a Node object)
+"""
+
+def __init__(self, fname):
+self.fname = fname
+
+def Scan(self):
+"""Scan a device tree, building up a tree of Node objects
+
+This fills in the self._root property
+"""
+self._root = 

[U-Boot] [PATCH v2 26/55] dm: Add an option to enable the of-platdata feature

2016-06-12 Thread Simon Glass
Add a Kconfig option to enable this feature.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 dts/Kconfig | 21 +
 1 file changed, 21 insertions(+)

diff --git a/dts/Kconfig b/dts/Kconfig
index c56c129..4b7d8b1 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -85,4 +85,25 @@ config OF_SPL_REMOVE_PROPS
  can be discarded. This option defines the list of properties to
  discard.
 
+config SPL_OF_PLATDATA
+   bool "Generate platform data for use in SPL"
+   depends on SPL_OF_CONTROL
+   help
+ For very constrained SPL environments the overhead of decoding
+ device tree nodes and converting their contents into platform data
+ is too large. This overhead includes libfdt code as well as the
+ device tree contents itself. The latter is fairly compact, but the
+ former can add 3KB or more to a Thumb 2 Image.
+
+ This option enables generation of platform data from the device
+ tree as C code. This code creates devices using U_BOOT_DEVICE()
+ declarations. The benefit is that it allows driver code to access
+ the platform data directly in C structures, avoidin the libfdt
+ overhead.
+
+ This option works by generating C structure declarations for each
+ compatible string, then adding platform data and U_BOOT_DEVICE
+ declarations for each node. See README.platdata for more
+ information.
+
 endmenu
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 20/55] dm: syscon: Add support for of-platdata

2016-06-12 Thread Simon Glass
Provide a new function which can cope with obtaining information from
of-platdata instead of the device tree.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add a comment to the effect that 64-bit machines are not supported

 drivers/core/syscon-uclass.c | 13 +
 include/syscon.h | 11 +++
 2 files changed, 24 insertions(+)

diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index e03f46a..01bd968 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -29,7 +29,20 @@ static int syscon_pre_probe(struct udevice *dev)
 {
struct syscon_uc_info *priv = dev_get_uclass_priv(dev);
 
+   /*
+* With OF_PLATDATA we really have no way of knowing the format of
+* the device-specific platform data. So we assume that it starts with
+* a 'reg' member, and this holds a single address and size. Drivers
+* using OF_PLATDATA will need to ensure that this is true.
+*/
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   struct syscon_base_platdata *plat = dev_get_platdata(dev);
+
+   return regmap_init_mem_platdata(dev, plat->reg, ARRAY_SIZE(plat->reg),
+   >regmap);
+#else
return regmap_init_mem(dev, >regmap);
+#endif
 }
 
 int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp)
diff --git a/include/syscon.h b/include/syscon.h
index 4593b6e..34842aa 100644
--- a/include/syscon.h
+++ b/include/syscon.h
@@ -23,6 +23,17 @@ struct syscon_ops {
 
 #define syscon_get_ops(dev)((struct syscon_ops *)(dev)->driver->ops)
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+/*
+ * We don't support 64-bit machines. If they are so resource-contrained that
+ * they need to use OF_PLATDATA, something is horribly wrong with the
+ * education of our hardware engineers.
+ */
+struct syscon_base_platdata {
+   u32 reg[2];
+};
+#endif
+
 /**
  * syscon_get_regmap() - Get access to a register map
  *
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 50/55] rockchip: Don't use spl_boot_device() with of-platdata

2016-06-12 Thread Simon Glass
This function cannot look at the device tree when of-platdata is used.
Update the code to handle this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-rockchip/rk3288-board-spl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c 
b/arch/arm/mach-rockchip/rk3288-board-spl.c
index 30f874a..6d3b38c 100644
--- a/arch/arm/mach-rockchip/rk3288-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3288-board-spl.c
@@ -29,6 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 u32 spl_boot_device(void)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
const void *blob = gd->fdt_blob;
struct udevice *dev;
const char *bootdev;
@@ -63,6 +64,7 @@ u32 spl_boot_device(void)
}
 
 fallback:
+#endif
return BOOT_DEVICE_MMC1;
 }
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 47/55] rockchip: clk: Update the rk3288 driver to support of-platdata

2016-06-12 Thread Simon Glass
Add support for of-platdata with rk3288. This requires decoding the
of-platdata struct and setting up the devices from that. Also the driver
needs to be renamed to match the string that of-platdata will search for.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/clk/clk_rk3288.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clk_rk3288.c b/drivers/clk/clk_rk3288.c
index 8a62b3d..05912ff 100644
--- a/drivers/clk/clk_rk3288.c
+++ b/drivers/clk/clk_rk3288.c
@@ -7,7 +7,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +24,9 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 struct rk3288_clk_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   struct dtd_rockchip_rk3288_cru dtd;
+#endif
enum rk_clk_id clk_id;
 };
 
@@ -837,11 +842,13 @@ static struct clk_ops rk3288_clk_ops = {
 
 static int rk3288_clk_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rk3288_clk_plat *plat = dev_get_platdata(dev);
struct rk3288_clk_priv *priv = dev_get_priv(dev);
 
if (plat->clk_id == CLK_OSC)
priv->cru = (struct rk3288_cru *)dev_get_addr(dev);
+#endif
 
return 0;
 }
@@ -861,6 +868,9 @@ static int rk3288_clk_probe(struct udevice *dev)
priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
if (IS_ERR(priv->grf))
return PTR_ERR(priv->grf);
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]);
+#endif
 #ifdef CONFIG_SPL_BUILD
rkclk_init(priv->cru, priv->grf);
 #endif
@@ -891,8 +901,8 @@ static int rk3288_clk_bind(struct udevice *dev)
struct rk3288_clk_plat *cplat;
 
debug("%s %s\n", __func__, clk_name[pll]);
-   ret = device_bind_driver(dev, "clk_rk3288", clk_name[pll],
-);
+   ret = device_bind_driver(dev, "rockchip_rk3288_cru",
+clk_name[pll], );
if (ret)
return ret;
cplat = dev_get_platdata(child);
@@ -912,8 +922,8 @@ static const struct udevice_id rk3288_clk_ids[] = {
{ }
 };
 
-U_BOOT_DRIVER(clk_rk3288) = {
-   .name   = "clk_rk3288",
+U_BOOT_DRIVER(rockchip_rk3288_cru) = {
+   .name   = "rockchip_rk3288_cru",
.id = UCLASS_CLK,
.of_match   = rk3288_clk_ids,
.priv_auto_alloc_size = sizeof(struct rk3288_clk_priv),
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 35/55] dm: core: Rename DM_NAME_ALLOCED to DM_FLAG_NAME_ALLOCED

2016-06-12 Thread Simon Glass
This is a flag. Adjust the name to be consistent with the other flags.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/device-remove.c | 2 +-
 drivers/core/device.c| 2 +-
 include/dm/device.h  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index 0e56b23..a7f77b4 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -112,7 +112,7 @@ int device_unbind(struct udevice *dev)
 
devres_release_all(dev);
 
-   if (dev->flags & DM_NAME_ALLOCED)
+   if (dev->flags & DM_FLAG_NAME_ALLOCED)
free((char *)dev->name);
free(dev);
 
diff --git a/drivers/core/device.c b/drivers/core/device.c
index de52f07..d3b731e 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -727,7 +727,7 @@ bool device_is_last_sibling(struct udevice *dev)
 
 void device_set_name_alloced(struct udevice *dev)
 {
-   dev->flags |= DM_NAME_ALLOCED;
+   dev->flags |= DM_FLAG_NAME_ALLOCED;
 }
 
 int device_set_name(struct udevice *dev, const char *name)
diff --git a/include/dm/device.h b/include/dm/device.h
index f03bcd3..0259627 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -42,7 +42,7 @@ struct driver_info;
 #define DM_FLAG_BOUND  (1 << 6)
 
 /* Device name is allocated and should be freed on unbind() */
-#define DM_NAME_ALLOCED(1 << 7)
+#define DM_FLAG_NAME_ALLOCED   (1 << 7)
 
 /**
  * struct udevice - An instance of a driver
@@ -540,7 +540,7 @@ int device_set_name(struct udevice *dev, const char *name);
 /**
  * device_set_name_alloced() - note that a device name is allocated
  *
- * This sets the DM_NAME_ALLOCED flag for the device, so that when it is
+ * This sets the DM_FLAG_NAME_ALLOCED flag for the device, so that when it is
  * unbound the name will be freed. This avoids memory leaks.
  *
  * @dev:   Device to update
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 53/55] rockchip: sdram: Update the driver to support of-platdata

2016-06-12 Thread Simon Glass
Add support for of-platdata with rk3288 SDRAM initr. This requires decoding
the of-platdata struct and setting up the device from that. Also the driver
needs to be renamed to match the string that of-platdata will search for.

The platform data is copied from the of-platdata structure to the one used
by the driver. This allows the same code to be used with device tree and
of-platdata.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 40 +++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c 
b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
index 4e5186e..355c332 100644
--- a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -44,6 +45,9 @@ struct dram_info {
 };
 
 struct rk3288_sdram_params {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   struct dtd_rockchip_rk3288_dmc of_plat;
+#endif
struct rk3288_sdram_channel ch[2];
struct rk3288_sdram_pctl_timing pctl_timing;
struct rk3288_sdram_phy_timing phy_timing;
@@ -803,6 +807,7 @@ static int setup_sdram(struct udevice *dev)
 
 static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rk3288_sdram_params *params = dev_get_platdata(dev);
const void *blob = gd->fdt_blob;
int node = dev->of_offset;
@@ -848,11 +853,39 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice 
*dev)
ret = regmap_init_mem(dev, >map);
if (ret)
return ret;
+#endif
 
return 0;
 }
 #endif /* CONFIG_SPL_BUILD */
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+static int conv_of_platdata(struct udevice *dev)
+{
+   struct rk3288_sdram_params *plat = dev_get_platdata(dev);
+   struct dtd_rockchip_rk3288_dmc *of_plat = >of_plat;
+   int i, ret;
+
+   for (i = 0; i < 2; i++) {
+   memcpy(>ch[i], of_plat->rockchip_sdram_channel,
+  sizeof(plat->ch[i]));
+   }
+   memcpy(>pctl_timing, of_plat->rockchip_pctl_timing,
+  sizeof(plat->pctl_timing));
+   memcpy(>phy_timing, of_plat->rockchip_phy_timing,
+  sizeof(plat->phy_timing));
+   memcpy(>base, of_plat->rockchip_sdram_params, sizeof(plat->base));
+   plat->num_channels = of_plat->rockchip_num_channels;
+   ret = regmap_init_mem_platdata(dev, of_plat->reg,
+  ARRAY_SIZE(of_plat->reg) / 2,
+   >map);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+#endif
+
 static int rk3288_dmc_probe(struct udevice *dev)
 {
 #ifdef CONFIG_SPL_BUILD
@@ -862,6 +895,11 @@ static int rk3288_dmc_probe(struct udevice *dev)
struct regmap *map;
int ret;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   ret = conv_of_platdata(dev);
+   if (ret)
+   return ret;
+#endif
map = syscon_get_regmap_by_driver_data(ROCKCHIP_SYSCON_NOC);
if (IS_ERR(map))
return PTR_ERR(map);
@@ -916,7 +954,7 @@ static const struct udevice_id rk3288_dmc_ids[] = {
 };
 
 U_BOOT_DRIVER(dmc_rk3288) = {
-   .name = "rk3288_dmc",
+   .name = "rockchip_rk3288_dmc",
.id = UCLASS_RAM,
.of_match = rk3288_dmc_ids,
.ops = _dmc_ops,
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 30/55] dm: Makefile: Build of-platdata files when the feature is enabled

2016-06-12 Thread Simon Glass
Update the Makefile to call dtoc to create the C header and source files,
then build these into the image.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 scripts/Makefile.spl | 39 ---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 2b5c995..324b03f 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -45,6 +45,7 @@ LDFLAGS_FINAL += --gc-sections
 # FIX ME
 cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
$(NOSTDINC_FLAGS)
+c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
 
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard 
$(srctree)/board/$(VENDOR)/common/Makefile),y,n)
 
@@ -76,6 +77,9 @@ endif
 
 u-boot-spl-init := $(head-y)
 u-boot-spl-main := $(libs-y)
+ifdef CONFIG_SPL_OF_PLATDATA
+u-boot-spl-platdata := $(obj)/dts/dt-platdata.o
+endif
 
 # Linker Script
 ifdef CONFIG_SPL_LDSCRIPT
@@ -207,6 +211,32 @@ cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) 
$(LDPPFLAGS) -ansi \
 $(obj)/$(SPL_BIN).cfg: include/config.h FORCE
$(call if_changed,cpp_cfg)
 
+pythonpath = PYTHONPATH=tools
+
+quiet_cmd_dtocc = DTOC C  $@
+cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb 
-o $@ platdata
+
+quiet_cmd_dtoch = DTOC H  $@
+cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb 
-o $@ struct
+
+quiet_cmd_plat = PLAT$@
+cmd_plat = $(CC) $(c_flags) -c $< -o $@
+
+$(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c 
include/generated/dt-structs.h
+   $(call if_changed,plat)
+
+PHONY += dts_dir
+dts_dir:
+   $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts)
+
+include/generated/dt-structs.h: $(obj)/$(SPL_BIN).dtb dts_dir dtoc
+   $(call if_changed,dtoch)
+
+$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir dtoc
+   $(call if_changed,dtocc)
+
+dtoc: #$(objtree)/tools/_libfdt.so
+
 ifdef CONFIG_SAMSUNG
 ifdef CONFIG_VAR_SIZE_SPL
 VAR_SIZE_PARAM = --vs
@@ -246,16 +276,19 @@ $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE
 quiet_cmd_u-boot-spl ?= LD  $@
   cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
   $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
-  $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
+  $(patsubst $(obj)/%,%,$(u-boot-spl-main))  \
+  $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
+  --end-group \
   $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
 
-$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds 
FORCE
+$(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \
+   $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE
$(call if_changed,u-boot-spl)
 
 $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
 
 PHONY += $(u-boot-spl-dirs)
-$(u-boot-spl-dirs):
+$(u-boot-spl-dirs): $(u-boot-spl-platdata)
$(Q)$(MAKE) $(build)=$@
 
 quiet_cmd_cpp_lds = LDS $@
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 45/55] rockchip: mmc: Update the driver to support of-platdata

2016-06-12 Thread Simon Glass
Add support for of-platdata with rk3288. This requires decoding the
of-platdata struct and setting up the device from that. Also the driver
needs to be renamed to match the string that of-platdata will search for.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/rockchip_dw_mmc.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 26004be..cc16aed 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -7,8 +7,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -19,6 +21,9 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 struct rockchip_mmc_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   struct dtd_rockchip_rk3288_dw_mshc dtplat;
+#endif
struct mmc_config cfg;
struct mmc mmc;
 };
@@ -49,6 +54,7 @@ static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host 
*host, uint freq)
 
 static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
struct dwmci_host *host = >host;
 
@@ -74,7 +80,7 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice 
*dev)
if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
 "clock-freq-min-max", priv->minmax, 2))
return -EINVAL;
-
+#endif
return 0;
 }
 
@@ -89,9 +95,27 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
struct udevice *pwr_dev __maybe_unused;
int ret;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   struct dtd_rockchip_rk3288_dw_mshc *dtplat = >dtplat;
+
+   host->name = dev->name;
+   host->ioaddr = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
+   host->buswidth = dtplat->bus_width;
+   host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
+   host->priv = dev;
+   host->dev_index = 0;
+   priv->fifo_depth = dtplat->fifo_depth;
+   priv->fifo_mode = 0;
+   memcpy(priv->minmax, dtplat->clock_freq_min_max, sizeof(priv->minmax));
+
+   ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, >clk);
+   if (ret < 0)
+   return ret;
+#else
ret = clk_get_by_index(dev, 0, >clk);
if (ret < 0)
return ret;
+#endif
priv->periph = ret;
 
host->fifoth_val = MSIZE(0x2) |
@@ -147,7 +171,7 @@ static const struct udevice_id rockchip_dwmmc_ids[] = {
 };
 
 U_BOOT_DRIVER(rockchip_dwmmc_drv) = {
-   .name   = "rockchip_dwmmc",
+   .name   = "rockchip_rk3288_dw_mshc",
.id = UCLASS_MMC,
.of_match   = rockchip_dwmmc_ids,
.ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata,
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 39/55] dm: core: Move regmap allocation into a separate function

2016-06-12 Thread Simon Glass
We plan to add a new way of creating a regmap for of-platdata. Move the
allocation code into a separate function so that it can be shared.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/regmap.c | 34 ++
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 7e073cf..dcb1a30 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -15,6 +15,27 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static struct regmap *regmap_alloc_count(int count)
+{
+   struct regmap *map;
+
+   map = malloc(sizeof(struct regmap));
+   if (!map)
+   return NULL;
+   if (count <= 1) {
+   map->range = >base_range;
+   } else {
+   map->range = malloc(count * sizeof(struct regmap_range));
+   if (!map->range) {
+   free(map);
+   return NULL;
+   }
+   }
+   map->range_count = count;
+
+   return map;
+}
+
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size,
 struct regmap **mapp)
@@ -45,22 +66,11 @@ int regmap_init_mem(struct udevice *dev, struct regmap 
**mapp)
if (!cell || !count)
return -EINVAL;
 
-   map = malloc(sizeof(struct regmap));
+   map = regmap_alloc_count(count);
if (!map)
return -ENOMEM;
 
-   if (count <= 1) {
-   map->range = >base_range;
-   } else {
-   map->range = malloc(count * sizeof(struct regmap_range));
-   if (!map->range) {
-   free(map);
-   return -ENOMEM;
-   }
-   }
-
map->base = fdtdec_get_number(cell, addr_len);
-   map->range_count = count;
 
for (range = map->range; count > 0;
 count--, cell += both_len, range++) {
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 32/55] Only build the libfdt python module if 'swig' is available

2016-06-12 Thread Simon Glass
When swig is not available, we can still build correctly. So make this
optional. Add a comment about how to enable this build.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/Makefile | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/Makefile b/tools/Makefile
index a813217..0300e38 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -107,7 +107,10 @@ mkimage-objs   := $(dumpimage-mkimage-objs) mkimage.o
 fit_info-objs   := $(dumpimage-mkimage-objs) fit_info.o
 fit_check_sign-objs   := $(dumpimage-mkimage-objs) fit_check_sign.o
 
-hostprogs-$(CONFIG_SPL_OF_PLATDATA) += _libfdt.so
+# Build a libfdt Python module if swig is available
+# Use 'sudo apt-get install swig libpython-dev' to enable this
+hostprogs-$(CONFIG_SPL_OF_PLATDATA) += \
+   $(if $(shell which swig),_libfdt.so)
 _libfdt.so-sharedobjs += $(LIBFDT_OBJS)
 libfdt:
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 48/55] rockchip: pinctrl: Update the rk3288 driver to support of-platdata

2016-06-12 Thread Simon Glass
Add support for of-platdata with rk3288. This requires disabling access to
the device tree and renaming the driver to match the string that of-platdata
will search for.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/pinctrl/rockchip/pinctrl_rk3288.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3288.c 
b/drivers/pinctrl/rockchip/pinctrl_rk3288.c
index 1fa1daa..8cb3b82 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3288.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3288.c
@@ -476,6 +476,7 @@ static int rk3288_pinctrl_request(struct udevice *dev, int 
func, int flags)
 static int rk3288_pinctrl_get_periph_id(struct udevice *dev,
struct udevice *periph)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
u32 cell[3];
int ret;
 
@@ -506,6 +507,7 @@ static int rk3288_pinctrl_get_periph_id(struct udevice *dev,
case 103:
return PERIPH_ID_HDMI;
}
+#endif
 
return -ENOENT;
 }
@@ -664,8 +666,12 @@ static struct pinctrl_ops rk3288_pinctrl_ops = {
 
 static int rk3288_pinctrl_bind(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+   return 0;
+#else
/* scan child GPIO banks */
return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+#endif
 }
 
 #ifndef CONFIG_SPL_BUILD
@@ -719,7 +725,7 @@ static const struct udevice_id rk3288_pinctrl_ids[] = {
 };
 
 U_BOOT_DRIVER(pinctrl_rk3288) = {
-   .name   = "pinctrl_rk3288",
+   .name   = "rockchip_rk3288_pinctrl",
.id = UCLASS_PINCTRL,
.of_match   = rk3288_pinctrl_ids,
.priv_auto_alloc_size = sizeof(struct rk3288_pinctrl_priv),
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 51/55] rockchip: syscon: Update to work with of-platdata

2016-06-12 Thread Simon Glass
The syscon devices all end up having diffent driver names with of-platdata,
since the driver name comes from the first string in the compatible list.
Add separate device declarations for each one, and add a bind method to set
up driver_data correctly.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-rockchip/rk3288/syscon_rk3288.c | 38 +++
 1 file changed, 38 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c 
b/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c
index c9f7c4e..be4b2b0 100644
--- a/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c
@@ -23,3 +23,41 @@ U_BOOT_DRIVER(syscon_rk3288) = {
.id = UCLASS_SYSCON,
.of_match = rk3288_syscon_ids,
 };
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+static int rk3288_syscon_bind_of_platdata(struct udevice *dev)
+{
+   dev->driver_data = dev->driver->of_match->data;
+   debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data);
+
+   return 0;
+}
+
+U_BOOT_DRIVER(rockchip_rk3288_noc) = {
+   .name = "rockchip_rk3288_noc",
+   .id = UCLASS_SYSCON,
+   .of_match = rk3288_syscon_ids,
+   .bind = rk3288_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3288_grf) = {
+   .name = "rockchip_rk3288_grf",
+   .id = UCLASS_SYSCON,
+   .of_match = rk3288_syscon_ids + 1,
+   .bind = rk3288_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3288_sgrf) = {
+   .name = "rockchip_rk3288_sgrf",
+   .id = UCLASS_SYSCON,
+   .of_match = rk3288_syscon_ids + 2,
+   .bind = rk3288_syscon_bind_of_platdata,
+};
+
+U_BOOT_DRIVER(rockchip_rk3288_pmu) = {
+   .name = "rockchip_rk3288_pmu",
+   .id = UCLASS_SYSCON,
+   .of_match = rk3288_syscon_ids + 3,
+   .bind = rk3288_syscon_bind_of_platdata,
+};
+#endif
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 24/55] dm: serial: Add support for of-platdata

2016-06-12 Thread Simon Glass
When this feature is enabled, we cannot access the device tree to find out
which serial device to use. Just use the first serial driver we find.

Signed-off-by: Simon Glass 
---

Changes in v2: None

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

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 0ce5c44..19f38e1 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -33,7 +33,13 @@ static void serial_find_console_or_panic(void)
struct udevice *dev;
int node;
 
-   if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
+   if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
+   uclass_first_device(UCLASS_SERIAL, );
+   if (dev) {
+   gd->cur_serial_dev = dev;
+   return;
+   }
+   } else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
/* Check for a chosen console */
node = fdtdec_get_chosen_node(blob, "stdout-path");
if (node < 0) {
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 46/55] rockchip: clk: Move all DT decoding to ofdata_to_platdata()

2016-06-12 Thread Simon Glass
It is more correct to avoid touching the device tree in the probe() method.
Update the driver to work this way. Also add an error check on grf since if
that fails then we should not use it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/clk/clk_rk3288.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk_rk3288.c b/drivers/clk/clk_rk3288.c
index d88893c..8a62b3d 100644
--- a/drivers/clk/clk_rk3288.c
+++ b/drivers/clk/clk_rk3288.c
@@ -835,6 +835,17 @@ static struct clk_ops rk3288_clk_ops = {
.get_periph_rate = rk3288_get_periph_rate,
 };
 
+static int rk3288_clk_ofdata_to_platdata(struct udevice *dev)
+{
+   struct rk3288_clk_plat *plat = dev_get_platdata(dev);
+   struct rk3288_clk_priv *priv = dev_get_priv(dev);
+
+   if (plat->clk_id == CLK_OSC)
+   priv->cru = (struct rk3288_cru *)dev_get_addr(dev);
+
+   return 0;
+}
+
 static int rk3288_clk_probe(struct udevice *dev)
 {
struct rk3288_clk_plat *plat = dev_get_platdata(dev);
@@ -847,8 +858,9 @@ static int rk3288_clk_probe(struct udevice *dev)
priv->grf = parent_priv->grf;
return 0;
}
-   priv->cru = (struct rk3288_cru *)dev_get_addr(dev);
priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
+   if (IS_ERR(priv->grf))
+   return PTR_ERR(priv->grf);
 #ifdef CONFIG_SPL_BUILD
rkclk_init(priv->cru, priv->grf);
 #endif
@@ -867,14 +879,11 @@ static const char *const clk_name[CLK_COUNT] = {
 
 static int rk3288_clk_bind(struct udevice *dev)
 {
-   struct rk3288_clk_plat *plat = dev_get_platdata(dev);
int pll, ret;
 
/* We only need to set up the root clock */
-   if (dev->of_offset == -1) {
-   plat->clk_id = CLK_OSC;
+   if (device_get_uclass_id(dev_get_parent(dev)) == UCLASS_CLK)
return 0;
-   }
 
/* Create devices for P main clocks */
for (pll = 1; pll < CLK_COUNT; pll++) {
@@ -911,5 +920,6 @@ U_BOOT_DRIVER(clk_rk3288) = {
.platdata_auto_alloc_size = sizeof(struct rk3288_clk_plat),
.ops= _clk_ops,
.bind   = rk3288_clk_bind,
+   .ofdata_to_platdata = rk3288_clk_ofdata_to_platdata,
.probe  = rk3288_clk_probe,
 };
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 33/55] tiny-printf: Support assert()

2016-06-12 Thread Simon Glass
At present assert() is not supported with tiny-printf, so when DEBUG is
enabled a build error is generated for each assert().

Add an __assert_fail() function to correct this. It prints a message and
then hangs.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 lib/tiny-printf.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 3c65fc9..2aeee2a 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -175,3 +175,12 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
 
return ret;
 }
+
+void __assert_fail(const char *assertion, const char *file, unsigned line,
+  const char *function)
+{
+   /* This will not return */
+   printf("%s:%u: %s: Assertion `%s' failed.", file, line, function,
+  assertion);
+   hang();
+}
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 41/55] dm: serial: ns16550: Update to support of-platdata

2016-06-12 Thread Simon Glass
With of-platdata this driver cannot know the format of the of-platdata
struct, so we cannot use generic code for accessing the of-platdata. Each
SoC that uses this driver will need to set up ns16550's platdata for it.
So don't compile in the generic code.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/serial/ns16550.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index c6cb3eb..88fca15 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -347,7 +347,7 @@ int ns16550_serial_probe(struct udevice *dev)
return 0;
 }
 
-#if CONFIG_IS_ENABLED(OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
 {
struct ns16550_platdata *plat = dev->platdata;
@@ -416,6 +416,7 @@ const struct dm_serial_ops ns16550_serial_ops = {
.setbrg = ns16550_serial_setbrg,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 /*
  * Please consider existing compatible strings before adding a new
@@ -452,4 +453,5 @@ U_BOOT_DRIVER(ns16550_serial) = {
.flags  = DM_FLAG_PRE_RELOC,
 };
 #endif
+#endif /* !OF_PLATDATA */
 #endif /* CONFIG_DM_SERIAL */
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 23/27] zynq: Increase the early malloc() size

2016-06-12 Thread Simon Glass
This is needed to support driver-model conversion of USB and block devices.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/armv8/zynqmp/Kconfig | 4 
 arch/arm/mach-zynq/Kconfig| 3 +++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm/cpu/armv8/zynqmp/Kconfig 
b/arch/arm/cpu/armv8/zynqmp/Kconfig
index 6c71d78..ed3305d 100644
--- a/arch/arm/cpu/armv8/zynqmp/Kconfig
+++ b/arch/arm/cpu/armv8/zynqmp/Kconfig
@@ -20,4 +20,8 @@ config SYS_CONFIG_NAME
 config ZYNQMP_USB
bool "Configure ZynqMP USB"
 
+config SYS_MALLOC_F_LEN
+   default 0x600
+
+
 endif
diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig
index db3c579..a982320 100644
--- a/arch/arm/mach-zynq/Kconfig
+++ b/arch/arm/mach-zynq/Kconfig
@@ -17,4 +17,7 @@ config SYS_CONFIG_NAME
  Based on this option include/configs/.h header
  will be used for board configuration.
 
+config SYS_MALLOC_F_LEN
+   default 0x600
+
 endif
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 17/27] dm: mmc: msm_sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS

2016-06-12 Thread Simon Glass
Add support for using driver model for block devices and MMC operations in
this driver.

Signed-off-by: Simon Glass 
---

 drivers/mmc/msm_sdhci.c | 51 +++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index 1e2a29b..150adf0 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -36,6 +36,11 @@
 /* Non standard (?) SDHCI register */
 #define SDHCI_VENDOR_SPEC_CAPABILITIES0  0x11c
 
+struct msm_sdhc_plat {
+   struct mmc_config cfg;
+   struct mmc mmc;
+};
+
 struct msm_sdhc {
struct sdhci_host host;
void *base;
@@ -74,9 +79,14 @@ static int msm_sdc_clk_init(struct udevice *dev)
 
 static int msm_sdc_probe(struct udevice *dev)
 {
+   struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+#ifdef CONFIG_BLK
+   struct msm_sdhc_plat *plat = dev_get_platdata(dev);
+#endif
struct msm_sdhc *prv = dev_get_priv(dev);
struct sdhci_host *host = >host;
u32 core_version, core_minor, core_major;
+   u32 caps;
int ret;
 
host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_BROKEN_R1B;
@@ -120,7 +130,7 @@ static int msm_sdc_probe(struct udevice *dev)
 * controller versions and must be explicitly enabled.
 */
if (core_major >= 1 && core_minor != 0x11 && core_minor != 0x12) {
-   u32 caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
+   caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
caps |= SDHCI_CAN_VDD_300 | SDHCI_CAN_DO_8BIT;
writel(caps, host->ioaddr + SDHCI_VENDOR_SPEC_CAPABILITIES0);
}
@@ -128,8 +138,26 @@ static int msm_sdc_probe(struct udevice *dev)
/* Set host controller version */
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
 
+#ifdef CONFIG_BLK
+   caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+   ret = sdhci_setup_cfg(>cfg, dev->name, host->bus_width,
+ caps, 0, 0, host->version, host->quirks, 0);
+   host->mmc = >mmc;
+#else
/* automatically detect max and min speed */
-   return add_sdhci(host, 0, 0);
+   ret = add_sdhci(host, 0, 0);
+#endif
+   if (ret)
+   return ret;
+   host->mmc->priv = >host;
+   host->mmc->dev = dev;
+   upriv->mmc = host->mmc;
+
+#ifdef CONFIG_DM_MMC_OPS
+   return sdhci_probe(dev);
+#else
+   return 0;
+#endif
 }
 
 static int msm_sdc_remove(struct udevice *dev)
@@ -164,6 +192,20 @@ static int msm_ofdata_to_platdata(struct udevice *dev)
return 0;
 }
 
+static int msm_sdc_bind(struct udevice *dev)
+{
+#ifdef CONFIG_BLK
+   struct msm_sdhc_plat *plat = dev_get_platdata(dev);
+   int ret;
+
+   ret = sdhci_bind(dev, >mmc, >cfg);
+   if (ret)
+   return ret;
+#endif
+
+   return 0;
+}
+
 static const struct udevice_id msm_mmc_ids[] = {
{ .compatible = "qcom,sdhci-msm-v4" },
{ }
@@ -174,7 +216,12 @@ U_BOOT_DRIVER(msm_sdc_drv) = {
.id = UCLASS_MMC,
.of_match   = msm_mmc_ids,
.ofdata_to_platdata = msm_ofdata_to_platdata,
+#ifdef CONFIG_DM_MMC_OPS
+   .ops= _ops,
+#endif
+   .bind   = msm_sdc_bind,
.probe  = msm_sdc_probe,
.remove = msm_sdc_remove,
.priv_auto_alloc_size = sizeof(struct msm_sdhc),
+   .platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat),
 };
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 25/27] dm: mmc: zynq: Convert zynq to use driver model for MMC

2016-06-12 Thread Simon Glass
Move zynq to the latest driver model support by enabling CONFIG_DM_MMC,
CONFIG_DM_MMC_OPS and CONFIG_BLK.

Signed-off-by: Simon Glass 
---

 arch/arm/Kconfig |  5 +
 drivers/mmc/zynq_sdhci.c | 39 ++-
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2b501eb..42d0dd0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -639,11 +639,13 @@ config ARCH_ZYNQ
select DM_GPIO
select SPL_DM if SPL
select DM_MMC
+   select DM_MMC_OPS
select DM_SPI
select DM_SERIAL
select DM_SPI_FLASH
select SPL_SEPARATE_BSS if SPL
select DM_USB
+   select BLK
 
 config ARCH_ZYNQMP
bool "Support Xilinx ZynqMP Platform"
@@ -653,6 +655,9 @@ config ARCH_ZYNQMP
select DM_SERIAL
select SUPPORT_SPL
select DM_USB
+   select DM_MMC
+   select DM_MMC_OPS
+   select BLK
 
 config TEGRA
bool "NVIDIA Tegra"
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index d405929..bcd154a 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -17,10 +17,18 @@
 # define CONFIG_ZYNQ_SDHCI_MIN_FREQ0
 #endif
 
+struct arasan_sdhci_plat {
+   struct mmc_config cfg;
+   struct mmc mmc;
+};
+
 static int arasan_sdhci_probe(struct udevice *dev)
 {
+   struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
struct sdhci_host *host = dev_get_priv(dev);
+   u32 caps;
+   int ret;
 
host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
   SDHCI_QUIRK_BROKEN_R1B;
@@ -31,13 +39,19 @@ static int arasan_sdhci_probe(struct udevice *dev)
 
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
 
-   add_sdhci(host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
- CONFIG_ZYNQ_SDHCI_MIN_FREQ);
-
-   upriv->mmc = host->mmc;
+   caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+   ret = sdhci_setup_cfg(>cfg, dev->name, host->bus_width,
+ caps, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
+ CONFIG_ZYNQ_SDHCI_MIN_FREQ, host->version,
+ host->quirks, 0);
+   host->mmc = >mmc;
+   if (ret)
+   return ret;
+   host->mmc->priv = host;
host->mmc->dev = dev;
+   upriv->mmc = host->mmc;
 
-   return 0;
+   return sdhci_probe(dev);
 }
 
 static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
@@ -50,6 +64,18 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice 
*dev)
return 0;
 }
 
+static int arasan_sdhci_bind(struct udevice *dev)
+{
+   struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
+   int ret;
+
+   ret = sdhci_bind(dev, >mmc, >cfg);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 static const struct udevice_id arasan_sdhci_ids[] = {
{ .compatible = "arasan,sdhci-8.9a" },
{ }
@@ -60,6 +86,9 @@ U_BOOT_DRIVER(arasan_sdhci_drv) = {
.id = UCLASS_MMC,
.of_match   = arasan_sdhci_ids,
.ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
+   .ops= _ops,
+   .bind   = arasan_sdhci_bind,
.probe  = arasan_sdhci_probe,
.priv_auto_alloc_size = sizeof(struct sdhci_host),
+   .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat),
 };
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 24/27] dm: zynq: usb: Convert to CONFIG_DM_USB

2016-06-12 Thread Simon Glass
Convert zynq USB to driver model. It does not actually work, but the error
is similar.

Before:

Zynq> dm tree
 Class   Probed   Name

 root[ + ]root_driver
 rsa_mod_exp [   ]|-- mod_exp_sw
 simple_bus  [ + ]`-- amba
 gpio[   ]|-- gpio@e000a000
 serial  [ + ]|-- serial@e0001000
 spi [ + ]|-- spi@e000d000
 spi_flash   [   ]|   `-- spi_flash@0:0
 eth [ + ]|-- ethernet@e000b000
 mmc [ + ]|-- sdhci@e010
 simple_bus  [   ]`-- slcr@f800
Zynq> usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1:   usb1 wrong num MIO: 0, Index 1
lowlevel init failed
   scanning usb for storage devices... 0 Storage Device(s) found
Zynq>

After:

Zynq> dm tree
 Class   Probed   Name

 root[ + ]root_driver
 rsa_mod_exp [   ]|-- mod_exp_sw
 simple_bus  [ + ]`-- amba
 gpio[   ]|-- gpio@e000a000
 serial  [ + ]|-- serial@e0001000
 spi [ + ]|-- spi@e000d000
 spi_flash   [   ]|   `-- spi_flash@0:0
 eth [ + ]|-- ethernet@e000b000
 mmc [ + ]|-- sdhci@e010
 blk [ + ]|   `-- sd...@e010.blk
 simple_bus  [   ]|-- slcr@f800
 usb [ + ]`-- usb@e0002000
Zynq> usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... Error: Cannot find high speed parent of usb-1 
device
EHCI timed out on TD - token=0x80008c80
unable to get device descriptor (error=-1)
failed, error -1
Zynq>

Signed-off-by: Simon Glass 
---

 arch/arm/Kconfig |   2 +
 drivers/usb/host/ehci-zynq.c | 102 +--
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1af9c35..2b501eb 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -643,6 +643,7 @@ config ARCH_ZYNQ
select DM_SERIAL
select DM_SPI_FLASH
select SPL_SEPARATE_BSS if SPL
+   select DM_USB
 
 config ARCH_ZYNQMP
bool "Support Xilinx ZynqMP Platform"
@@ -651,6 +652,7 @@ config ARCH_ZYNQMP
select OF_CONTROL
select DM_SERIAL
select SUPPORT_SPL
+   select DM_USB
 
 config TEGRA
bool "NVIDIA Tegra"
diff --git a/drivers/usb/host/ehci-zynq.c b/drivers/usb/host/ehci-zynq.c
index 37a7935..b45c68d 100644
--- a/drivers/usb/host/ehci-zynq.c
+++ b/drivers/usb/host/ehci-zynq.c
@@ -7,55 +7,47 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include "ehci.h"
 
-#define ZYNQ_USB_USBCMD_RST0x002
-#define ZYNQ_USB_USBCMD_STOP   0x000
-#define ZYNQ_USB_NUM_MIO   12
+struct zynq_ehci_priv {
+   struct usb_ehci *ehci;
+};
 
-/*
- * Create the appropriate control structures to manage
- * a new EHCI host controller.
- */
-int ehci_hcd_init(int index,  enum usb_init_type init, struct ehci_hccr **hccr,
- struct ehci_hcor **hcor)
+static int ehci_zynq_ofdata_to_platdata(struct udevice *dev)
 {
-   struct usb_ehci *ehci;
+   struct zynq_ehci_priv *priv = dev_get_priv(dev);
+
+   priv->ehci = (struct usb_ehci *)dev_get_addr_ptr(dev);
+   if (!priv->ehci)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int ehci_zynq_probe(struct udevice *dev)
+{
+   struct usb_platdata *plat = dev_get_platdata(dev);
+   struct zynq_ehci_priv *priv = dev_get_priv(dev);
+   struct ehci_hccr *hccr;
+   struct ehci_hcor *hcor;
struct ulpi_viewport ulpi_vp;
-   int ret, mio_usb;
/* Used for writing the ULPI data address */
struct ulpi_regs *ulpi = (struct ulpi_regs *)0;
+   int ret;
 
-   if (!index) {
-   mio_usb = zynq_slcr_get_mio_pin_status("usb0");
-   if (mio_usb != ZYNQ_USB_NUM_MIO) {
-   printf("usb0 wrong num MIO: %d, Index %d\n", mio_usb,
-  index);
-   return -1;
-   }
-   ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0;
-   } else {
-   mio_usb = zynq_slcr_get_mio_pin_status("usb1");
-   if (mio_usb != ZYNQ_USB_NUM_MIO) {
-   printf("usb1 wrong num MIO: %d, Index %d\n", mio_usb,
-  index);
-   return -1;
-   }
-   ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1;
-   }
-
-   *hccr = (struct ehci_hccr *)((uint32_t)>caplength);
-   *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
-   HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
+   hccr = (struct ehci_hccr *)((uint32_t)>ehci->caplength);
+   hcor = (struct ehci_hcor *)((uint32_t) hccr +
+

[U-Boot] [PATCH 22/27] net: phy: marvell: Add a missing errno.h header

2016-06-12 Thread Simon Glass
This corrects a build error on zynqmp.

Signed-off-by: Simon Glass 
Signed-off-by: Simon Glass 
---

 drivers/net/phy/marvell.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index d2e68d4..8de0574 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -8,6 +8,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 
 #define PHY_AUTONEGOTIATE_TIMEOUT 5000
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 21/27] dm: dfu: mmc: Support CONFIG_BLK in DFU for MMC

2016-06-12 Thread Simon Glass
Update the method of accessing the block device so that it works with
CONFIG_BLK enabled.

Signed-off-by: Simon Glass 
---

 drivers/dfu/dfu_mmc.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 78724e4..926ccbd 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -49,7 +49,7 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity 
*dfu,
}
 
if (dfu->data.mmc.hw_partition >= 0) {
-   part_num_bkp = mmc->block_dev.hwpart;
+   part_num_bkp = mmc_get_blk_desc(mmc)->hwpart;
ret = blk_select_hwpart_devnum(IF_TYPE_MMC,
   dfu->data.mmc.dev_num,
   dfu->data.mmc.hw_partition);
@@ -62,12 +62,11 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity 
*dfu,
  dfu->data.mmc.dev_num, blk_start, blk_count, buf);
switch (op) {
case DFU_OP_READ:
-   n = mmc->block_dev.block_read(>block_dev, blk_start,
- blk_count, buf);
+   n = blk_dread(mmc_get_blk_desc(mmc), blk_start, blk_count, buf);
break;
case DFU_OP_WRITE:
-   n = mmc->block_dev.block_write(>block_dev, blk_start,
-  blk_count, buf);
+   n = blk_dwrite(mmc_get_blk_desc(mmc), blk_start, blk_count,
+  buf);
break;
default:
error("Operation not supported\n");
@@ -356,7 +355,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char 
*devstr, char *s)
 
} else if (!strcmp(entity_type, "part")) {
disk_partition_t partinfo;
-   struct blk_desc *blk_dev = >block_dev;
+   struct blk_desc *blk_dev = mmc_get_blk_desc(mmc);
int mmcdev = second_arg;
int mmcpart = third_arg;
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 18/27] dm: mmc: Move dragonboard410c to use CONFIG_BLK and CONFIG_DM_MMC_OPS

2016-06-12 Thread Simon Glass
Update this board to use driver model for block devices and MMC operations.

Signed-off-by: Simon Glass 
---

 configs/dragonboard410c_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/dragonboard410c_defconfig 
b/configs/dragonboard410c_defconfig
index 37c5ea77..ad2e8b8 100644
--- a/configs/dragonboard410c_defconfig
+++ b/configs/dragonboard410c_defconfig
@@ -18,6 +18,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_BLK=y
 CONFIG_CLK=y
 CONFIG_MSM_GPIO=y
 CONFIG_PM8916_GPIO=y
@@ -25,6 +26,7 @@ CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_SYSRESET=y
 CONFIG_DM_MMC=y
+CONFIG_DM_MMC_OPS=y
 CONFIG_MSM_SDHCI=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_PM8916=y
-- 
2.8.0.rc3.226.g39d4020

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


Re: [U-Boot] [PATCH v2] configs: Fixup afet BOOTDELAY migration

2016-06-12 Thread Heiko Schocher

Hello Hans,

Am 11.06.2016 um 13:36 schrieb Hans de Goede:

Hi,

On 10-06-16 21:43, Tom Rini wrote:

A number of config files were not correctly migrated for BOOTDELAY moving
over to Kconfig.  Update these configs which were not done correctly.

Signed-off-by: Tom Rini 
---
Changes in v2:
- I regenerated this after locally applying (and throwing away as there will
  be an updated series) fixes to moveconfig.py.  This means we now catch the
  boards that were doing -1 as a value and 1 as a value.  I've also dropped
  the parts that removed empty #if/#endif things as we can do that outside
  of this patch.


NACK, see the reply I just send to the similar patch from Masahiro which
was send earlier today, which is currently sitting in the moderation
list due to it having 101 people in the Cc.

Note the fact that this touches files which are maintained by 101 people
alone should be a big red flag that this is a very very bad idea.


How should we move to Kconfig else? Common options touch a lot of
boards ...


Please just revert the patch causing all this pain and lets get back
to the drawing board on this, or on how we move things to Kconfig
in general.


Sorry for all the trouble with this patch. Reverting seems the best
way currently.

@Tom: What do you think?

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 22/55] dm: Add a header that provides access to the of-platdata structs

2016-06-12 Thread Simon Glass
This header can be included from anywhere, but will only pull in the
of-platdata struct definitions when this feature is enabled (and only in
SPL).

Signed-off-by: Simon Glass 
---

Changes in v2: None

 include/dt-structs.h | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 include/dt-structs.h

diff --git a/include/dt-structs.h b/include/dt-structs.h
new file mode 100644
index 000..e13afa6
--- /dev/null
+++ b/include/dt-structs.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __DT_STTUCTS
+#define __DT_STTUCTS
+
+/* These structures may only be used in SPL */
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+struct phandle_2_cell {
+   const void *node;
+   int id;
+};
+#include 
+#endif
+
+#endif
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 54/55] rockchip: Use of-platdata for firefly-rk3288

2016-06-12 Thread Simon Glass
As an experiment, move this board over to use of-platdata. This means that
its SPL configuration will come from C structures generated at build-time
from the device tree, instead of coming from the device tree at run-time.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 configs/firefly-rk3288_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig
index a64f6de..b84f918 100644
--- a/configs/firefly-rk3288_defconfig
+++ b/configs/firefly-rk3288_defconfig
@@ -68,3 +68,6 @@ CONFIG_VIDEO_ROCKCHIP=y
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_ERRNO_STR=y
+CONFIG_SPL_OF_PLATDATA=y
+# CONFIG_SPL_OF_LIBFDT is not set
+CONFIG_ROCKCHIP_SERIAL=y
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 40/55] dm: core: Add an implementation of regmap_init_mem_platdata()

2016-06-12 Thread Simon Glass
Add an implementation of this function which mirrors the functions of the
automatic device-tree implementation. This can be used with of-platdata to
create regmaps.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/regmap.c | 18 --
 include/regmap.h  | 15 ++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index dcb1a30..0299ff0 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -37,10 +37,24 @@ static struct regmap *regmap_alloc_count(int count)
 }
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size,
+int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count,
 struct regmap **mapp)
 {
-   /* TODO(s...@chromium.org): Implement this when needed */
+   struct regmap_range *range;
+   struct regmap *map;
+
+   map = regmap_alloc_count(count);
+   if (!map)
+   return -ENOMEM;
+
+   map->base = *reg;
+   for (range = map->range; count > 0; reg += 2, range++, count--) {
+   range->start = *reg;
+   range->size = reg[1];
+   }
+
+   *mapp = map;
+
return 0;
 }
 #else
diff --git a/include/regmap.h b/include/regmap.h
index 922b39f..1eed94e 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -56,7 +56,20 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);
  */
 int regmap_init_mem(struct udevice *dev, struct regmap **mapp);
 
-int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size,
+/**
+ * regmap_init_mem_platdata() - Set up a new memory register map for 
of-platdata
+ *
+ * This creates a new regmap with a list of regions passed in, rather than
+ * using the device tree. It only supports 32-bit machines.
+ *
+ * Use regmap_uninit() to free it.
+ *
+ * @dev:   Device that uses this map
+ * @reg:   List of address, size pairs
+ * @count: Number of pairs (e.g. 1 if the regmap has a single entry)
+ * @mapp:  Returns allocated map
+ */
+int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count,
 struct regmap **mapp);
 
 /**
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 27/55] dm: Add a README for of-platdata

2016-06-12 Thread Simon Glass
Add documentation on how this works, including the benefits and drawbacks.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 doc/driver-model/of-plat.txt | 268 +++
 1 file changed, 268 insertions(+)
 create mode 100644 doc/driver-model/of-plat.txt

diff --git a/doc/driver-model/of-plat.txt b/doc/driver-model/of-plat.txt
new file mode 100644
index 000..96b9b46
--- /dev/null
+++ b/doc/driver-model/of-plat.txt
@@ -0,0 +1,268 @@
+Driver Model Compiled-in Device Tree / Platform Data
+
+
+
+Introduction
+
+
+Device tree is the standard configuration method in U-Boot. It is used to
+define what devices are in the system and provide configuration information
+to these devices.
+
+The overhead of adding device tree access to U-Boot is fairly modest,
+approximately 3KB on Thumb 2 (plus the size of the DT itself). This means
+that in most cases it is best to use device tree for configuration.
+
+However there are some very constrained environments where U-Boot needs to
+work. These include SPL with severe memory limitations. For example, some
+SoCs require a 16KB SPL image which must include a full MMC stack. In this
+case the overhead of device tree access may be too great.
+
+It is possible to create platform data manually by defining C structures
+for it, and referencing that data in a U_BOOT_DEVICE() declaration. This
+bypasses the use of device tree completely, but is an available option for
+SPL.
+
+As an alternative, a new 'of-platdata' feature is provided. This converts
+device tree contents into C code which can be compiled into the SPL binary.
+This saves the 3KB of code overhead and perhaps a few hundred more bytes due
+to more efficient storage of the data.
+
+
+Caveats
+---
+
+There are many problems with this features. It should only be used when
+stricly necessary. Notable problems include:
+
+   - Device tree does not describe data types but the C code must define a
+type for each property. Thesee are guessed using heuristics which
+are wrong in several fairly common cases. For example an 8-byte value
+is considered to be a 2-item integer array, and is byte-swapped. A
+boolean value that is not present means 'false', but cannot be
+included in the structures since there is generally no mention of it
+in the device tree file.
+
+   - Naming of nodes and properties is automatic. This means that they follow
+the naming in the device tree, which may result in C identifiers that
+look a bit strange
+
+   - It is not possible to find a value given a property name. Code must use
+the associated C member variable directly in the code. This makes
+the code less robust in the face of device-tree changes. It also
+makes it very unlikely that your driver code will be useful for more
+than one SoC. Even if the code is common, each SoC will end up with
+a different C struct and format for the platform data.
+
+   - The platform data is provided to drivers as a C structure. The driver
+must use the same structure to access the data. Since a driver
+normally also supports device tree it must use #ifdef to separate
+out this code, since the structures are only available in SPL.
+
+
+How it works
+
+
+The feature is enabled by CONFIG SPL_OF_PLATDATA. This is only available
+in SPL and should be tested with:
+
+#if CONFIG_IS_ENABLED(SPL_OF_PLATDATA)
+
+A new tool called 'dtoc' converts a device tree file either into a set of
+struct declarations, one for each compatible node, or a set of
+U_BOOT_DEVICE() declarations along with the actual platform data for each
+device. As an example, consider this MMC node:
+
+sdmmc: dwmmc@ff0c {
+compatible = "rockchip,rk3288-dw-mshc";
+clock-freq-min-max = <40 15000>;
+clocks = < HCLK_SDMMC>, < SCLK_SDMMC>,
+ < SCLK_SDMMC_DRV>, < SCLK_SDMMC_SAMPLE>;
+clock-names = "biu", "ciu", "ciu_drv", "ciu_sample";
+fifo-depth = <0x100>;
+interrupts = ;
+reg = <0xff0c 0x4000>;
+bus-width = <4>;
+cap-mmc-highspeed;
+cap-sd-highspeed;
+card-detect-delay = <200>;
+disable-wp;
+num-slots = <1>;
+pinctrl-names = "default";
+pinctrl-0 = <_clk>, <_cmd>, <_cd>, 
<_bus4>;
+vmmc-supply = <_sd>;
+status = "okay";
+u-boot,dm-pre-reloc;
+};
+
+
+Some of these properties are dropped by U-Boot under control of the
+CONFIG_OF_SPL_REMOVE_PROPS option. The rest are processed. This will produce
+the following C struct declaration:
+
+struct dtd_rockchip_rk3288_dw_mshc {
+fdt32_t 

[U-Boot] [PATCH v2 49/55] rockchip: Move the MMC setup check earlier

2016-06-12 Thread Simon Glass
When the boot ROM sets up MMC we don't need to do it again. Remove the
MMC setup code entirely.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-rockchip/rk3288-board-spl.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c 
b/arch/arm/mach-rockchip/rk3288-board-spl.c
index e133cca..30f874a 100644
--- a/arch/arm/mach-rockchip/rk3288-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3288-board-spl.c
@@ -114,7 +114,6 @@ static void configure_l2ctlr(void)
 #ifdef CONFIG_SPL_MMC_SUPPORT
 static int configure_emmc(struct udevice *pinctrl)
 {
-#if !defined(CONFIG_TARGET_ROCK2) && !defined(CONFIG_TARGET_FIREFLY_RK3288)
struct gpio_desc desc;
int ret;
 
@@ -144,7 +143,6 @@ static int configure_emmc(struct udevice *pinctrl)
debug("gpio value ret=%d\n", ret);
return ret;
}
-#endif
 
return 0;
 }
@@ -247,15 +245,18 @@ void spl_board_init(void)
goto err;
}
 #ifdef CONFIG_SPL_MMC_SUPPORT
-   ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
-   if (ret) {
-   debug("%s: Failed to set up SD card\n", __func__);
-   goto err;
-   }
-   ret = configure_emmc(pinctrl);
-   if (ret) {
-   debug("%s: Failed to set up eMMC\n", __func__);
-   goto err;
+   if (!IS_ENABLED(CONFIG_TARGET_ROCK2) &&
+   !IS_ENABLED(CONFIG_TARGET_FIREFLY_RK3288)) {
+   ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
+   if (ret) {
+   debug("%s: Failed to set up SD card\n", __func__);
+   goto err;
+   }
+   ret = configure_emmc(pinctrl);
+   if (ret) {
+   debug("%s: Failed to set up eMMC\n", __func__);
+   goto err;
+   }
}
 #endif
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 43/55] rockchip: Update the sdram-channel property to support of-platdata

2016-06-12 Thread Simon Glass
Add an extra byte so that this data is not byteswapped. Add a comment to
the code to explain the purpose.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/dts/rk3288-firefly.dts| 3 ++-
 arch/arm/include/asm/arch-rockchip/sdram.h | 6 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/rk3288-firefly.dts b/arch/arm/dts/rk3288-firefly.dts
index aed8d3a..3176d50 100644
--- a/arch/arm/dts/rk3288-firefly.dts
+++ b/arch/arm/dts/rk3288-firefly.dts
@@ -30,7 +30,8 @@
0x5 0x0>;
rockchip,phy-timing = <0x48f9aab4 0xea0910 0x1002c200
0xa60 0x40 0x10 0x0>;
-   rockchip,sdram-channel = /bits/ 8 <0x1 0xa 0x3 0x2 0x1 0x0 0xf 0xf>;
+   /* Add a dummy value to cause of-platdata think this is bytes */
+   rockchip,sdram-channel = /bits/ 8 <0x1 0xa 0x3 0x2 0x1 0x0 0xf 0xf 
0xff>;
rockchip,sdram-params = <0x30B25564 0x627 3 66600 3 9 1>;
 };
 
diff --git a/arch/arm/include/asm/arch-rockchip/sdram.h 
b/arch/arm/include/asm/arch-rockchip/sdram.h
index d3de42d..c9e3001 100644
--- a/arch/arm/include/asm/arch-rockchip/sdram.h
+++ b/arch/arm/include/asm/arch-rockchip/sdram.h
@@ -24,6 +24,12 @@ struct rk3288_sdram_channel {
u8 row_3_4;
u8 cs0_row;
u8 cs1_row;
+   /*
+* For of-platdata, which would otherwise convert this into two
+* byte-swapped integers. With a size of 9 bytes, this struct will
+* appear in of-platdata as a byte array.
+*/
+   u8 dummy;
 };
 
 struct rk3288_sdram_pctl_timing {
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 25/55] dm: Don't include fdtdec functions when of-platdata is enabled

2016-06-12 Thread Simon Glass
We cannot access the device tree in this case, so avoid compiling in the
various device-tree helper functions.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 lib/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/Makefile b/lib/Makefile
index f77befe..2fc0272 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,11 +49,10 @@ obj-y += list_sort.o
 endif
 
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
-ifdef CONFIG_SPL_OF_CONTROL
-obj-$(CONFIG_OF_LIBFDT) += libfdt/
-endif
+ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o
+endif
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 31/55] dm: Add a more efficient libfdt library

2016-06-12 Thread Simon Glass
Add a Python version of the libfdt library which contains enough features to
support the dtoc tool. This is only a very bare-bones implementation. It
requires the 'swig' to build.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 lib/libfdt/libfdt.swig|  81 +
 lib/libfdt/setup.py   |  38 ++
 lib/libfdt/test_libfdt.py |  14 
 scripts/Makefile.host |   9 ++-
 tools/Makefile|  11 +++
 tools/dtoc/fdt.py | 174 ++
 6 files changed, 325 insertions(+), 2 deletions(-)
 create mode 100644 lib/libfdt/libfdt.swig
 create mode 100644 lib/libfdt/setup.py
 create mode 100644 lib/libfdt/test_libfdt.py
 create mode 100644 tools/dtoc/fdt.py

diff --git a/lib/libfdt/libfdt.swig b/lib/libfdt/libfdt.swig
new file mode 100644
index 000..95c3e9e
--- /dev/null
+++ b/lib/libfdt/libfdt.swig
@@ -0,0 +1,81 @@
+/* File: libfdt.i */
+%module libfdt
+
+%{
+#define SWIG_FILE_WITH_INIT
+#include "libfdt.h"
+%}
+
+%pythoncode %{
+def Raise(errnum):
+raise ValueError('Error %s' % fdt_strerror(errnum))
+
+def Name(fdt, offset):
+name, len = fdt_get_name(fdt, offset)
+return name
+
+def String(fdt, offset):
+offset = fdt32_to_cpu(offset)
+name = fdt_string(fdt, offset)
+return name
+
+def swap32(x):
+return (((x << 24) & 0xFF00) |
+((x <<  8) & 0x00FF) |
+((x >>  8) & 0xFF00) |
+((x >> 24) & 0x00FF))
+
+def fdt32_to_cpu(x):
+return swap32(x)
+
+def Data(prop):
+set_prop(prop)
+return get_prop_data()
+%}
+
+%include "typemaps.i"
+%include "cstring.i"
+
+%typemap(in) void* = char*;
+
+typedef int fdt32_t;
+
+struct fdt_property {
+fdt32_t tag;
+fdt32_t len;
+fdt32_t nameoff;
+char data[0];
+};
+
+%inline %{
+static struct fdt_property *cur_prop;
+
+void set_prop(struct fdt_property *prop) {
+cur_prop = prop;
+}
+%}
+
+%cstring_output_allocate_size(char **s, int *sz, free(*$1));
+%inline %{
+void get_prop_data(char **s, int *sz) {
+*sz = fdt32_to_cpu(cur_prop->len);
+*s = (char *)malloc(*sz);
+if (!*s)
+*sz = 0;
+else
+memcpy(*s, cur_prop + 1, *sz);
+}
+%}
+
+const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
+int fdt_path_offset(const void *fdt, const char *path);
+int fdt_first_property_offset(const void *fdt, int nodeoffset);
+int fdt_next_property_offset(const void *fdt, int offset);
+const char *fdt_strerror(int errval);
+const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
+  int offset,
+  int *OUTPUT);
+const char *fdt_get_name(const void *fdt, int nodeoffset, int *OUTPUT);
+const char *fdt_string(const void *fdt, int stroffset);
+int fdt_first_subnode(const void *fdt, int offset);
+int fdt_next_subnode(const void *fdt, int offset);
diff --git a/lib/libfdt/setup.py b/lib/libfdt/setup.py
new file mode 100644
index 000..62e7bcc
--- /dev/null
+++ b/lib/libfdt/setup.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+"""
+setup.py file for SWIG libfdt
+"""
+
+from distutils.core import setup, Extension
+import os
+import sys
+
+# Don't cross-compile - always use the host compiler.
+del os.environ['CROSS_COMPILE']
+del os.environ['CC']
+
+progname = sys.argv[0]
+cflags = sys.argv[1]
+files = sys.argv[2:]
+
+if cflags:
+cflags = [flag for flag in cflags.split(' ') if flag]
+else:
+cflags = None
+
+libfdt_module = Extension(
+'_libfdt',
+sources = files,
+extra_compile_args =  cflags
+)
+
+sys.argv = [progname, '--quiet', 'build_ext', '--inplace']
+
+setup (name = 'libfdt',
+   version = '0.1',
+   author  = "SWIG Docs",
+   description = """Simple swig libfdt from docs""",
+   ext_modules = [libfdt_module],
+   py_modules = ["libfdt"],
+   )
diff --git a/lib/libfdt/test_libfdt.py b/lib/libfdt/test_libfdt.py
new file mode 100644
index 000..14d0da4
--- /dev/null
+++ b/lib/libfdt/test_libfdt.py
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+
+import os
+import sys
+
+our_path = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(our_path, '../../b/sandbox_spl/tools'))
+
+import libfdt
+
+with open('b/sandbox_spl/u-boot.dtb') as fd:
+fdt = fd.read()
+
+print libfdt.fdt_path_offset(fdt, "/aliases")
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index bff8b5b..763a699 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -28,12 +28,16 @@ __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
 # C code
 # Executables compiled from a single .c file
 host-csingle   := $(foreach m,$(__hostprogs), \
-   $(if $($(m)-objs)$($(m)-cxxobjs),,$(m)))
+   $(if 
$($(m)-objs)$($(m)-cxxobjs)$($(m)-sharedobjs),,$(m)))
 
 # C executables linked based on 

[U-Boot] [PATCH v2 36/55] dtoc: Ignore the u-boot, dm-pre-reloc property

2016-06-12 Thread Simon Glass
This property is not useful for of-platdata, so omit it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/dtoc.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index 6a2f6ef..9f14e3f 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -39,6 +39,7 @@ PROP_IGNORE_LIST = [
 'linux,phandle',
 "status",
 'phandle',
+'u-boot,dm-pre-reloc',
 ]
 
 # C type declarations for the tyues we support
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 19/55] dm: regmap: Add a dummy implementation for of-platdata

2016-06-12 Thread Simon Glass
Add a placeholder for now so that this code will compile. It currently does
nothing.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/regmap.c | 9 +
 include/regmap.h  | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 519832f..7e073cf 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -15,6 +15,14 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size,
+struct regmap **mapp)
+{
+   /* TODO(s...@chromium.org): Implement this when needed */
+   return 0;
+}
+#else
 int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
 {
const void *blob = gd->fdt_blob;
@@ -64,6 +72,7 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
 
return 0;
 }
+#endif
 
 void *regmap_get_range(struct regmap *map, unsigned int range_num)
 {
diff --git a/include/regmap.h b/include/regmap.h
index eccf770..922b39f 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -56,6 +56,9 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);
  */
 int regmap_init_mem(struct udevice *dev, struct regmap **mapp);
 
+int regmap_init_mem_platdata(struct udevice *dev, fdt32_t *reg, int size,
+struct regmap **mapp);
+
 /**
  * regmap_get_range() - Obtain the base memory address of a regmap range
  *
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 42/55] rockchip: serial: Add an of-platdata driver for rockchip

2016-06-12 Thread Simon Glass
Add a driver that works with of-platdata. It sets up the platform data and
calls the standard ns16550 driver.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/serial/Kconfig   |  9 +
 drivers/serial/Makefile  |  3 +++
 drivers/serial/serial_rockchip.c | 43 
 3 files changed, 55 insertions(+)
 create mode 100644 drivers/serial/serial_rockchip.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 0e38903..9ff7234 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -312,6 +312,15 @@ config SYS_NS16550
  be used. It can be a constant or a function to get clock, eg,
  get_serial_clock().
 
+config ROCKCHIP_SERIAL
+   bool "Rockchip on-chip UART support"
+   depends on DM_SERIAL && SPL_OF_PLATDATA
+   help
+ Select this to enable a debug UART for Rockchip devices when using
+ CONFIG_OF_PLATDATA (i.e. a compiled-in device tree replacemenmt).
+ This uses the ns16550 driver, converting the platdata from of-platdata
+ to the ns16550 format.
+
 config SANDBOX_SERIAL
bool "Sandbox UART support"
depends on SANDBOX
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index e1e28de..2ea9a70 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -28,6 +28,9 @@ obj-$(CONFIG_S5P) += serial_s5p.o
 obj-$(CONFIG_MXC_UART) += serial_mxc.o
 obj-$(CONFIG_PXA_SERIAL) += serial_pxa.o
 obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
+endif
 obj-$(CONFIG_S3C24X0_SERIAL) += serial_s3c24x0.o
 obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
 obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c
new file mode 100644
index 000..6bac95a
--- /dev/null
+++ b/drivers/serial/serial_rockchip.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct rockchip_uart_platdata {
+   struct dtd_rockchip_rk3288_uart dtplat;
+   struct ns16550_platdata plat;
+};
+
+struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat;
+
+static int rockchip_serial_probe(struct udevice *dev)
+{
+   struct rockchip_uart_platdata *plat = dev_get_platdata(dev);
+
+   /* Create some new platform data for the standard driver */
+   plat->plat.base = plat->dtplat.reg[0];
+   plat->plat.reg_shift = plat->dtplat.reg_shift;
+   plat->plat.clock = plat->dtplat.clock_frequency;
+   dev->platdata = >plat;
+
+   return ns16550_serial_probe(dev);
+}
+
+U_BOOT_DRIVER(rockchip_rk3288_uart) = {
+   .name   = "rockchip_rk3288_uart",
+   .id = UCLASS_SERIAL,
+   .priv_auto_alloc_size = sizeof(struct NS16550),
+   .platdata_auto_alloc_size = sizeof(struct rockchip_uart_platdata),
+   .probe  = rockchip_serial_probe,
+   .ops= _serial_ops,
+   .flags  = DM_FLAG_PRE_RELOC,
+};
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 21/55] dm: sandbox: Add a simple driver to test of-platdata

2016-06-12 Thread Simon Glass
Add a driver which uses of-platdata to obtain its platform data. This can
be used to test the feature in sandbox.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/misc/Makefile  |  5 +
 drivers/misc/spltest_sandbox.c | 28 
 2 files changed, 33 insertions(+)
 create mode 100644 drivers/misc/spltest_sandbox.c

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 066639b..3eac024 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -35,6 +35,11 @@ obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o
 obj-$(CONFIG_SMSC_SIO1007) += smsc_sio1007.o
 obj-$(CONFIG_STATUS_LED) += status_led.o
 obj-$(CONFIG_SANDBOX) += swap_case.o
+ifdef CONFIG_SPL_OF_PLATDATA
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SANDBOX) += spltest_sandbox.o
+endif
+endif
 obj-$(CONFIG_SANDBOX) += syscon_sandbox.o
 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
 obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
diff --git a/drivers/misc/spltest_sandbox.c b/drivers/misc/spltest_sandbox.c
new file mode 100644
index 000..ac4d10c
--- /dev/null
+++ b/drivers/misc/spltest_sandbox.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int sandbox_spl_probe(struct udevice *dev)
+{
+   struct dtd_sandbox_spl_test *plat = dev_get_platdata(dev);
+
+   printf("here %s\n", plat->string);
+
+   return 0;
+}
+
+U_BOOT_DRIVER(sandbox_spl_test) = {
+   .name   = "sandbox_spl_test",
+   .id = UCLASS_MISC,
+   .flags  = DM_FLAG_PRE_RELOC,
+   .probe  = sandbox_spl_probe,
+};
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 16/55] dm: spl: Don't set up device tree with of-platdata

2016-06-12 Thread Simon Glass
When this feature is enabled, we should not access the device tree.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 5fbf101..59f41a1 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -202,7 +202,7 @@ int spl_init(void)
gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
gd->malloc_ptr = 0;
 #endif
-   if (CONFIG_IS_ENABLED(OF_CONTROL)) {
+   if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = fdtdec_setup();
if (ret) {
debug("fdtdec_setup() returned error %d\n", ret);
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 17/55] dm: Makefile: Build of-platdata before SPL

2016-06-12 Thread Simon Glass
Since SPL needs the of-platdata structures, build these before starting
to build any SPL components.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 5b03095..edefc0b 100644
--- a/Makefile
+++ b/Makefile
@@ -1316,7 +1316,8 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
 
 spl/u-boot-spl.bin: spl/u-boot-spl
@:
-spl/u-boot-spl: tools prepare $(if $(CONFIG_OF_SEPARATE),dts/dt.dtb)
+spl/u-boot-spl: tools prepare \
+   $(if $(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb)
$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
 
 spl/sunxi-spl.bin: spl/u-boot-spl
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 23/55] dm: clk: Add support for of-platdata

2016-06-12 Thread Simon Glass
Add support for this feature in the core clock code.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/clk/clk-uclass.c | 20 
 drivers/clk/clk_fixed_rate.c |  2 ++
 include/clk.h|  4 
 3 files changed, 26 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index b483c1e..efe2d4e 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -65,6 +66,22 @@ ulong clk_set_periph_rate(struct udevice *dev, int periph, 
ulong rate)
 }
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+# if CONFIG_IS_ENABLED(OF_PLATDATA)
+int clk_get_by_index_platdata(struct udevice *dev, int index,
+ struct phandle_2_cell *cells,
+ struct udevice **clk_devp)
+{
+   int ret;
+
+   if (index != 0)
+   return -ENOSYS;
+   assert(*clk_devp);
+   ret = uclass_get_device(UCLASS_CLK, 0, clk_devp);
+   if (ret)
+   return ret;
+   return cells[0].id;
+}
+# else
 int clk_get_by_index(struct udevice *dev, int index, struct udevice **clk_devp)
 {
int ret;
@@ -104,6 +121,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct 
udevice **clk_devp)
return args.args_count > 0 ? args.args[0] : 0;
 #endif
 }
+# endif /* OF_PLATDATA */
+#else
+
 #endif
 
 UCLASS_DRIVER(clk) = {
diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 8beda9c..8c3fb8f 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -33,9 +33,11 @@ const struct clk_ops clk_fixed_rate_ops = {
 
 static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
to_clk_fixed_rate(dev)->fixed_rate =
fdtdec_get_int(gd->fdt_blob, dev->of_offset,
   "clock-frequency", 0);
+#endif
 
return 0;
 }
diff --git a/include/clk.h b/include/clk.h
index ca20c3d..e4d23be 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -120,6 +120,10 @@ ulong clk_set_periph_rate(struct udevice *dev, int periph, 
ulong rate);
  * argument after the clock node phandle. If there is no arguemnt,
  * returns 0. Return -ve error code on any error
  */
+struct phandle_2_cell;
+int clk_get_by_index_platdata(struct udevice *dev, int index,
+ struct phandle_2_cell *cells,
+ struct udevice **clk_devp);
 int clk_get_by_index(struct udevice *dev, int index, struct udevice 
**clk_devp);
 #else
 static inline int clk_get_by_index(struct udevice *dev, int index,
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 14/55] sandbox: Add a new sandbox_spl board

2016-06-12 Thread Simon Glass
It is useful to be able to build SPL for sandbox. It provides additional
build coverage and allows SPL features to be tested in sandbox. However
it does not need worthwhile to always create an SPL build. It nearly
doubles the build time and the feature is (so far) seldom used.

So for now, create a separate build target for sandbox SPL. This allows
experimentation with this new feature without impacting existing workflows.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/Kconfig|   7 +-
 arch/sandbox/cpu/u-boot-spl.lds |  24 ++
 board/sandbox/MAINTAINERS   |   7 ++
 configs/sandbox_spl_defconfig   | 177 
 include/configs/sandbox_spl.h   |  18 
 5 files changed, 232 insertions(+), 1 deletion(-)
 create mode 100644 arch/sandbox/cpu/u-boot-spl.lds
 create mode 100644 configs/sandbox_spl_defconfig
 create mode 100644 include/configs/sandbox_spl.h

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index a8a90cb..d4c1ee0 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -10,8 +10,13 @@ config SYS_BOARD
 config SYS_CPU
default "sandbox"
 
+config SANDBOX_SPL
+   bool "Enable SPL for sandbox"
+   select SUPPORT_SPL
+
 config SYS_CONFIG_NAME
-   default "sandbox"
+   default "sandbox_spl" if SANDBOX_SPL
+   default "sandbox" if !SANDBOX_SPL
 
 config PCI
bool "PCI support"
diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds
new file mode 100644
index 000..7e92b4a
--- /dev/null
+++ b/arch/sandbox/cpu/u-boot-spl.lds
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011-2012 The Chromium OS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+SECTIONS
+{
+
+   . = ALIGN(4);
+   .u_boot_list : {
+   KEEP(*(SORT(.u_boot_list*)));
+   }
+
+   __u_boot_sandbox_option_start = .;
+   _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
+   __u_boot_sandbox_option_end = .;
+
+   __bss_start = .;
+}
+
+INSERT BEFORE .data;
diff --git a/board/sandbox/MAINTAINERS b/board/sandbox/MAINTAINERS
index f5db773..4dcbf4b 100644
--- a/board/sandbox/MAINTAINERS
+++ b/board/sandbox/MAINTAINERS
@@ -11,3 +11,10 @@ S:   Maintained
 F: board/sandbox/
 F: include/configs/sandbox.h
 F: configs/sandbox_noblk_defconfig
+
+SANDBOX SPL BOARD
+M: Simon Glass 
+S: Maintained
+F: board/sandbox/
+F: include/configs/sandbox_spl.h
+F: configs/sandbox_spl_defconfig
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
new file mode 100644
index 000..ac30d6b
--- /dev/null
+++ b/configs/sandbox_spl_defconfig
@@ -0,0 +1,177 @@
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SPL_DM=y
+CONFIG_BLK=y
+CONFIG_MMC=y
+CONFIG_SANDBOX_SPL=y
+CONFIG_PCI=y
+CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_I8042_KEYB=y
+CONFIG_SPL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_REPORT=y
+CONFIG_BOOTSTAGE_USER_COUNT=0x20
+CONFIG_BOOTSTAGE_FDT=y
+CONFIG_BOOTSTAGE_STASH=y
+CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
+CONFIG_CONSOLE_RECORD=y
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_CPU=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
+CONFIG_LOOPW=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MX_CYCLIC=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_DEMO=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_REMOTEPROC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_TFTPPUT=y
+CONFIG_CMD_TFTPSRV=y
+CONFIG_CMD_RARP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CDP=y
+CONFIG_CMD_SNTP=y
+CONFIG_CMD_DNS=y
+CONFIG_CMD_LINK_LOCAL=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SOUND=y
+CONFIG_CMD_QFW=y
+CONFIG_CMD_BOOTSTAGE=y
+CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_TPM=y
+CONFIG_CMD_TPM_TEST=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_HOSTFILE=y
+CONFIG_NETCONSOLE=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_DEVRES=y
+CONFIG_DEBUG_DEVRES=y
+CONFIG_ADC=y
+CONFIG_ADC_SANDBOX=y
+CONFIG_CLK=y
+CONFIG_CPU=y
+CONFIG_DM_DEMO=y
+CONFIG_DM_DEMO_SIMPLE=y
+CONFIG_DM_DEMO_SHAPE=y
+CONFIG_PM8916_GPIO=y
+CONFIG_SANDBOX_GPIO=y
+CONFIG_DM_I2C_COMPAT=y
+CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_I2C_CROS_EC_LDO=y
+CONFIG_DM_I2C_GPIO=y
+CONFIG_SYS_I2C_SANDBOX=y
+CONFIG_I2C_MUX=y
+CONFIG_SPL_I2C_MUX=y
+CONFIG_I2C_ARB_GPIO_CHALLENGE=y
+CONFIG_CROS_EC_KEYB=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_DM_MAILBOX=y
+CONFIG_SANDBOX_MBOX=y
+CONFIG_MISC=y
+CONFIG_CMD_CROS_EC=y
+CONFIG_CROS_EC=y
+CONFIG_CROS_EC_I2C=y
+CONFIG_CROS_EC_LPC=y

[U-Boot] [PATCH v2 18/55] dm: core: Don't use device tree with of-platdata

2016-06-12 Thread Simon Glass
When CONFIG_SPL_OF_PLATDATA is enabled we should not access the device
tree. Remove all references to this in the core driver-model code.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/device.c | 2 +-
 drivers/core/lists.c  | 2 +-
 drivers/core/root.c   | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index eb75b17..de52f07 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -607,7 +607,7 @@ const char *dev_get_uclass_name(struct udevice *dev)
 
 fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
 {
-#if CONFIG_IS_ENABLED(OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
fdt_addr_t addr;
 
if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 0c27717..6a634e6 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -99,7 +99,7 @@ int device_bind_driver_to_node(struct udevice *parent, const 
char *drv_name,
return 0;
 }
 
-#if CONFIG_IS_ENABLED(OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 /**
  * driver_check_compatible() - Check if a driver is compatible with this node
  *
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 13c2713..0743aeb 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -173,7 +173,7 @@ int dm_scan_platdata(bool pre_reloc_only)
return ret;
 }
 
-#if CONFIG_IS_ENABLED(OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
 bool pre_reloc_only)
 {
@@ -229,7 +229,7 @@ int dm_init_and_scan(bool pre_reloc_only)
return ret;
}
 
-   if (CONFIG_IS_ENABLED(OF_CONTROL)) {
+   if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
if (ret) {
debug("dm_scan_fdt() failed: %d\n", ret);
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 15/55] sandbox: Add a test device that uses of-platdata

2016-06-12 Thread Simon Glass
Add a simple test device that provides a check that the of-platdata
feature is working correctly.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/spl.c|  9 +
 arch/sandbox/dts/sandbox.dts  | 13 +
 include/configs/sandbox_spl.h |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index e17c0ed..b064709 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -49,3 +49,12 @@ int spl_board_load_image(void)
/* Hopefully this will not return */
return os_spl_to_uboot(fname);
 }
+
+void spl_board_init(void)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device(UCLASS_MISC, );
+   printf("ret=%d, dev=%p\n", ret, dev);
+}
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 2ae4014..3455bc0 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -172,6 +172,19 @@
};
};
 
+   spl-test {
+   u-boot,dm-pre-reloc;
+   compatible = "sandbox,spl-test";
+   boolval;
+   intval = <1>;
+   intarray = <2 3 4>;
+   byteval = [05];
+   bytearray = [06 07 08];
+   longbytearray = [09 0a 0b 0c 0d 0e 0f 10 11];
+   string = "message";
+   stringarray = "multi-word", "message";
+   };
+
square {
compatible = "demo-shape";
colour = "blue";
diff --git a/include/configs/sandbox_spl.h b/include/configs/sandbox_spl.h
index 7b5c3f3..ffc3098 100644
--- a/include/configs/sandbox_spl.h
+++ b/include/configs/sandbox_spl.h
@@ -8,6 +8,8 @@
 
 #include 
 
+#define CONFIG_SPL_BOARD_INIT
+
 #define CONFIG_SPL_DRIVERS_MISC_SUPPORT
 #define CONFIG_SPL_ENV_SUPPORT
 #define CONFIG_SPL_FRAMEWORK
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 12/55] sandbox: Don't use IDE and iotrace in SPL

2016-06-12 Thread Simon Glass
These functions are not supported in SPL, so drop them.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 include/configs/sandbox.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 23a0c40..4de89f8 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -16,8 +16,10 @@
 
 #endif
 
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_IO_TRACE
 #define CONFIG_CMD_IOTRACE
+#endif
 
 #ifndef CONFIG_TIMER
 #define CONFIG_SYS_TIMER_RATE  100
@@ -192,6 +194,7 @@
 #define CONFIG_CMD_LZMADEC
 #define CONFIG_CMD_DATE
 
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_CMD_IDE
 #define CONFIG_SYS_IDE_MAXBUS  1
 #define CONFIG_SYS_ATA_IDE0_OFFSET 0
@@ -201,6 +204,7 @@
 #define CONFIG_SYS_ATA_REG_OFFSET  1
 #define CONFIG_SYS_ATA_ALT_OFFSET  2
 #define CONFIG_SYS_ATA_STRIDE  4
+#endif
 
 #define CONFIG_SCSI
 #define CONFIG_SCSI_AHCI_PLAT
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 13/55] sandbox: serial: Don't sync video in SPL

2016-06-12 Thread Simon Glass
SPL does not support an LCD display so there is no need to sync the video
when there is serial output.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/serial/sandbox.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index 58f882b..bcc3465 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -115,7 +115,9 @@ static int sandbox_serial_pending(struct udevice *dev, bool 
input)
return 0;
 
os_usleep(100);
+#ifndef CONFIG_SPL_BUILD
video_sync_all();
+#endif
if (next_index == serial_buf_read)
return 1;   /* buffer full */
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 06/55] sandbox: Support building an SPL image

2016-06-12 Thread Simon Glass
When building an SPL image, override the link flags so that it uses the
system libraries. This is similar to the way the non-SPL image is built.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/config.mk | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 16fd6d5..6d62abb 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -20,4 +20,9 @@ cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds \
-Wl,--start-group $(u-boot-main) -Wl,--end-group \
$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map
 
+cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
+   -Wl,--start-group $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
+   $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) -Wl,--end-group \
+   $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
+
 CONFIG_ARCH_DEVICE_TREE := sandbox
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 08/55] sandbox: Add some missing headers in cpu.c

2016-06-12 Thread Simon Glass
These headers are needed in case they are not transitively included.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/cpu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 7a622c8..4975eb2 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -4,6 +4,8 @@
  */
 #define DEBUG
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 07/55] sandbox: Correct header file order in cpu.c

2016-06-12 Thread Simon Glass
The dm/ file should go at the end. Move it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 196f3e1..7a622c8 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -4,10 +4,10 @@
  */
 #define DEBUG
 #include 
-#include 
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 09/55] sandbox: Don't use PCI in SPL

2016-06-12 Thread Simon Glass
PCI is not supported in SPL for sandbox, so avoid using it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/cpu.c| 2 +-
 arch/sandbox/lib/Makefile | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 4975eb2..2def722 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -57,7 +57,7 @@ int cleanup_before_linux_select(int flags)
 
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
-#ifdef CONFIG_PCI
+#if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD)
unsigned long plen = len;
void *ptr;
 
diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
index 96761e2..7820c55 100644
--- a/arch/sandbox/lib/Makefile
+++ b/arch/sandbox/lib/Makefile
@@ -8,5 +8,7 @@
 #
 
 obj-y  += interrupts.o
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_PCI)  += pci_io.o
+endif
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 02/55] README: Remove CONFIG_SYS_MALLOC_F_LEN comment

2016-06-12 Thread Simon Glass
This option is now widely available, so remove the comment that it is only
available on ARM and sandbox.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 README | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/README b/README
index 1d0b946..c3dcfbd 100644
--- a/README
+++ b/README
@@ -3852,9 +3852,6 @@ Configuration Settings:
The memory will be freed (or in fact just forgotten) when
U-Boot relocates itself.
 
-   Pre-relocation malloc() is only supported on ARM and sandbox
-   at present but is fairly easy to enable for other archs.
-
 - CONFIG_SYS_MALLOC_SIMPLE
Provides a simple and small malloc() and calloc() for those
boards which do not use the full malloc in SPL (which is
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 05/55] sandbox: Allow chaining from SPL to U-Boot proper

2016-06-12 Thread Simon Glass
SPL is expected to load and run U-Boot. This needs to work with sandbox also.
Provide a function to locate the U-Boot image, and another to start it. This
allows SPL to function on sandbox as it does on other archs.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/os.c | 51 +++
 include/os.h  | 25 +
 2 files changed, 76 insertions(+)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 8a4d719..2d63dd8 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -541,6 +541,57 @@ int os_jump_to_image(const void *dest, int size)
return unlink(fname);
 }
 
+int os_find_u_boot(char *fname, int maxlen)
+{
+   struct sandbox_state *state = state_get_current();
+   const char *progname = state->argv[0];
+   int len = strlen(progname);
+   char *p;
+   int fd;
+
+   if (len >= maxlen || len < 4)
+   return -ENOSPC;
+
+   /* Look for 'u-boot' in the same directory as 'u-boot-spl' */
+   strcpy(fname, progname);
+   if (!strcmp(fname + len - 4, "-spl")) {
+   fname[len - 4] = '\0';
+   fd = os_open(fname, O_RDONLY);
+   if (fd >= 0) {
+   close(fd);
+   return 0;
+   }
+   }
+
+   /* Look for 'u-boot' in the parent directory of spl/ */
+   p = strstr(fname, "/spl/");
+   if (p) {
+   strcpy(p, p + 4);
+   fd = os_open(fname, O_RDONLY);
+   if (fd >= 0) {
+   close(fd);
+   return 0;
+   }
+   }
+
+   return -ENOENT;
+}
+
+int os_spl_to_uboot(const char *fname)
+{
+   struct sandbox_state *state = state_get_current();
+   char *argv[state->argc + 1];
+   int ret;
+
+   memcpy(argv, state->argv, sizeof(char *) * (state->argc + 1));
+   argv[0] = (char *)fname;
+   ret = execv(fname, argv);
+   if (ret)
+   return ret;
+
+   return unlink(fname);
+}
+
 void os_localtime(struct rtc_time *rt)
 {
time_t t = time(NULL);
diff --git a/include/os.h b/include/os.h
index 954a48c..1782e50 100644
--- a/include/os.h
+++ b/include/os.h
@@ -287,6 +287,31 @@ int os_read_ram_buf(const char *fname);
 int os_jump_to_image(const void *dest, int size);
 
 /**
+ * os_find_u_boot() - Determine the path to U-Boot proper
+ *
+ * This function is intended to be called from within sandbox SPL. It uses
+ * a few heuristics to find U-Boot proper. Normally it is either in the same
+ * directory, or the directory above (since u-boot-spl is normally in an
+ * spl/ subdirectory when built).
+ *
+ * @fname: Place to put full path to U-Boot
+ * @maxlen:Maximum size of @fname
+ * @return 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found
+ */
+int os_find_u_boot(char *fname, int maxlen);
+
+/**
+ * os_spl_to_uboot() - Run U-Boot proper
+ *
+ * When called from SPL, this runs U-Boot proper. The filename is obtained by
+ * calling os_find_u_boot().
+ *
+ * @fname: Full pathname to U-Boot executable
+ * @return 0 if OK, -ve on error
+ */
+int os_spl_to_uboot(const char *fname);
+
+/**
  * Read the current system time
  *
  * This reads the current Local Time and places it into the provided
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 11/55] sandbox: Add basic SPL implementation

2016-06-12 Thread Simon Glass
Add an sandbox implementation for the generic SPL framework. This supports
locating and running U-Boot proper.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/Makefile  |  1 +
 arch/sandbox/cpu/spl.c | 51 ++
 arch/sandbox/include/asm/spl.h | 23 +++
 3 files changed, 75 insertions(+)
 create mode 100644 arch/sandbox/cpu/spl.c
 create mode 100644 arch/sandbox/include/asm/spl.h

diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
index 1b42fee..db43633 100644
--- a/arch/sandbox/cpu/Makefile
+++ b/arch/sandbox/cpu/Makefile
@@ -8,6 +8,7 @@
 #
 
 obj-y  := cpu.o os.o start.o state.o
+obj-$(CONFIG_SPL_BUILD)+= spl.o
 obj-$(CONFIG_ETH_SANDBOX_RAW)  += eth-raw-os.o
 obj-$(CONFIG_SANDBOX_SDL)  += sdl.o
 
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
new file mode 100644
index 000..e17c0ed
--- /dev/null
+++ b/arch/sandbox/cpu/spl.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void board_init_f(ulong flag)
+{
+   struct sandbox_state *state = state_get_current();
+
+   gd->arch.ram_buf = state->ram_buf;
+   gd->ram_size = state->ram_size;
+}
+
+u32 spl_boot_device(void)
+{
+   return BOOT_DEVICE_BOARD;
+}
+
+void spl_board_announce_boot_device(void)
+{
+   char fname[256];
+   int ret;
+
+   ret = os_find_u_boot(fname, sizeof(fname));
+   if (ret) {
+   printf("(%s not found, error %d)\n", fname, ret);
+   return;
+   }
+   printf("%s\n", fname);
+}
+
+int spl_board_load_image(void)
+{
+   char fname[256];
+   int ret;
+
+   ret = os_find_u_boot(fname, sizeof(fname));
+   if (ret)
+   return ret;
+
+   /* Hopefully this will not return */
+   return os_spl_to_uboot(fname);
+}
diff --git a/arch/sandbox/include/asm/spl.h b/arch/sandbox/include/asm/spl.h
new file mode 100644
index 000..59f2401
--- /dev/null
+++ b/arch/sandbox/include/asm/spl.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __asm_spl_h
+#define __asm_spl_h
+
+#define CONFIG_SPL_BOARD_LOAD_IMAGE
+
+/**
+ * Board-specific load method for boards that have a special way of loading
+ * U-Boot, which does not fit with the existing SPL code.
+ *
+ * @return 0 on success, negative errno value on failure.
+ */
+int spl_board_load_image(void);
+
+enum {
+   BOOT_DEVICE_BOARD,
+};
+
+#endif
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 03/55] spl: Drop include of i2c.h

2016-06-12 Thread Simon Glass
This file does not appear to use I2C, so drop this include.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/spl/spl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 840910a..5fbf101 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 00/55] RFC: dm: rockchip: Add support for compiled-in platform data

2016-06-12 Thread Simon Glass
Note: This v2 series has some minor updates and improvements, mostly as new
patches in the series.

This series provides a way to compile in the contents of a device tree as C
code into U-Boot, implementing an idea that Tom Rini came up with. It is
intended to deal with extremely tight environments where there is not enough
space for the ~3KB device tree code overhead. Examples include SPL where
there is only 16KB of available RAM yet a full MMC stack is required.

To provide a reasonable test environment, SPL support is added to sandbox,
through a new 'sandbox_spl' target. A new tool 'dtoc' converts device tree
data to C code (and structure definitions).

To check its effectiveness for a real application, the v2 series includes
support for enabling of-platdata for a rockchip board (firefly-rk3288). The
results are as follows:

  Code   Data  u-boot-spl.bin size
of-platdata disabled  23159  1624  28864
of-platdata enabled   19093  2616  21761

Overall the saving is 7103 bytes, about 7KB. Approximately 4KB of this comes
from removing the device tree data from SPL although this is offset by
the size of the of-platdata itself (around 1KB). On top of this effective
3KB reduction, another ~3KB reduction comes from dropping libfdt and a
further 1KB from dropping unused setup and driver-model code.

Clearly this approach does have value. Looked at with a favourable light it
provides the best of both worlds: configuration using standard device tree
bindings without the run-time overhead.

Looking under the hood shows a less rosy picture. Effectively we end up
with a new set of C structures which must be handled by the driver. This
series suggests a suitable approach for dealing with this (see of-plat.txt)
which is workable. However there are a number of serious caveats. See that
file for details.

If this feature makes it to mainline it should be used sparingly. Rockchip
is to some extent an unusual case: lots of features, no MMC stack available
to SPL from the internal ROM* and a very limited maximum SPL size. Most SoCs
will not benefit from this.

However, for an SoC with very small SRAM where only a few drivers are needed
in SPL (such as serial and MMC) then of-platdata could provide a useful
benefit, without a significant increase in complexity.

More work is needed before this feature is ready for use, but this series
contains enough to attract initial comments and testing. It is available at
u-boot-dm/dt-working.

* Note that the rockchip internal ROM does include an MMC stack but it only
permits loading of data in its own format, outside control of U-Boot.

Changes in v2:
- Add a comment to the effect that 64-bit machines are not supported
- Add support for rockchip
- Various minor enhancements to the v1 implementation

Simon Glass (55):
  sandbox: Don't print a warning for CONFIG_I2C_COMPAT
  README: Remove CONFIG_SYS_MALLOC_F_LEN comment
  spl: Drop include of i2c.h
  Makefile: Allow the SPL final link rule to be overridden
  sandbox: Allow chaining from SPL to U-Boot proper
  sandbox: Support building an SPL image
  sandbox: Correct header file order in cpu.c
  sandbox: Add some missing headers in cpu.c
  sandbox: Don't use PCI in SPL
  sandbox: Don't include the main loop in SPL
  sandbox: Add basic SPL implementation
  sandbox: Don't use IDE and iotrace in SPL
  sandbox: serial: Don't sync video in SPL
  sandbox: Add a new sandbox_spl board
  sandbox: Add a test device that uses of-platdata
  dm: spl: Don't set up device tree with of-platdata
  dm: Makefile: Build of-platdata before SPL
  dm: core: Don't use device tree with of-platdata
  dm: regmap: Add a dummy implementation for of-platdata
  dm: syscon: Add support for of-platdata
  dm: sandbox: Add a simple driver to test of-platdata
  dm: Add a header that provides access to the of-platdata structs
  dm: clk: Add support for of-platdata
  dm: serial: Add support for of-platdata
  dm: Don't include fdtdec functions when of-platdata is enabled
  dm: Add an option to enable the of-platdata feature
  dm: Add a README for of-platdata
  dm: Add a library to provide simple device-tree access
  dm: Add a tool to generate C code from a device tree
  dm: Makefile: Build of-platdata files when the feature is enabled
  dm: Add a more efficient libfdt library
  Only build the libfdt python module if 'swig' is available
  tiny-printf: Support assert()
  dm: spl: Bind in all devices in SPL with of-platdata
  dm: core: Rename DM_NAME_ALLOCED to DM_FLAG_NAME_ALLOCED
  dtoc: Ignore the u-boot,dm-pre-reloc property
  dm: Don't attach the device tree to SPL with of-platdata
  dm: core: Expand platdata for of-platdata devices
  dm: core: Move regmap allocation into a separate function
  dm: core: Add an implementation of regmap_init_mem_platdata()
  dm: serial: ns16550: Update to support of-platdata
  rockchip: serial: Add an of-platdata driver for rockchip
  rockchip: Update the sdram-channel property to 

[U-Boot] [PATCH v2 10/55] sandbox: Don't include the main loop in SPL

2016-06-12 Thread Simon Glass
SPL does not have a command interface so we should not include the main loop
code.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/start.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 969618e..6e4ec01 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -73,6 +73,7 @@ static int sandbox_cmdline_cb_help(struct sandbox_state 
*state, const char *arg)
 }
 SANDBOX_CMDLINE_OPT_SHORT(help, 'h', 0, "Display help");
 
+#ifndef CONFIG_SPL_BUILD
 int sandbox_main_loop_init(void)
 {
struct sandbox_state *state = state_get_current();
@@ -97,6 +98,7 @@ int sandbox_main_loop_init(void)
 
return 0;
 }
+#endif
 
 static int sandbox_cmdline_cb_boot(struct sandbox_state *state,
  const char *arg)
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 01/55] sandbox: Don't print a warning for CONFIG_I2C_COMPAT

2016-06-12 Thread Simon Glass
Sandbox includes this code to provide build coverage. While we retain this
feature we should have sandbox build it. Sandbox does not in fact use the
I2C compatibility mode. Showing a warning for sandbox is just confusing,
since no conversion is expected.

Drop the warning for sandbox.

Signed-off-by: Simon Glass 
---

Changes in v2: None

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

diff --git a/Makefile b/Makefile
index 0f7d6f3..5b03095 100644
--- a/Makefile
+++ b/Makefile
@@ -801,7 +801,7 @@ quiet_cmd_pad_cat = CAT $@
 cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
 
 all:   $(ALL-y)
-ifeq ($(CONFIG_DM_I2C_COMPAT),y)
+ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
@echo "= WARNING =="
@echo "This board uses CONFIG_DM_I2C_COMPAT. Please remove"
@echo "(possibly in a subsequent patch in your series)"
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH v2 04/55] Makefile: Allow the SPL final link rule to be overridden

2016-06-12 Thread Simon Glass
Overriding the final link rule is possible with U-Boot proper. It us used to
create a sandbox image links with host libraries. To build a sandbox SPL
image we need the same feature for SPL.

To support this, update the SPL link rule so sandbox can override it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 scripts/Makefile.spl | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 0997fd9..2b5c995 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -241,8 +241,10 @@ cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@
 $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE
$(call if_changed,mksunxiboot)
 
-quiet_cmd_u-boot-spl = LD  $@
-  cmd_u-boot-spl = (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
+# Rule to link u-boot-spl
+# May be overridden by arch/$(ARCH)/config.mk
+quiet_cmd_u-boot-spl ?= LD  $@
+  cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
   $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
   $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
   $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 27/27] dm: blk: Enable CONFIG_BLK if DM_MMC is enabled

2016-06-12 Thread Simon Glass
To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is
enabled.

Signed-off-by: Simon Glass 
---

 drivers/block/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 80eea84..fe5aa07 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,6 +1,7 @@
 config BLK
bool "Support block devices"
depends on DM
+   default y if DM_MMC
help
  Enable support for block devices, such as SCSI, MMC and USB
  flash sticks. These provide a block-level interface which permits
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 26/27] dm: mmc: Enable DM_MMC_OPS by default with DM_MMC

2016-06-12 Thread Simon Glass
These two options go together and it is best to do the conversion in one
step. So enable DM_MMC_OPS by default if DM_MMC is enabled.

Signed-off-by: Simon Glass 
---

 drivers/mmc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 79cf18f..b11725e 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -19,6 +19,7 @@ config DM_MMC
 config DM_MMC_OPS
bool "Support MMC controller operations using Driver Model"
depends on DM_MMC
+   default y if DM_MMC
help
  Driver model provides a means of supporting device operations. This
  option moves MMC operations under the control of driver model. The
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 19/27] dm: mmc: msmsdhic: Drop old MMC code

2016-06-12 Thread Simon Glass
Now that we have fully moved to driver model, drop the old code.

Signed-off-by: Simon Glass 
---

 drivers/mmc/Kconfig |  2 +-
 drivers/mmc/msm_sdhci.c | 15 ---
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index b9662f9..79cf18f 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -27,7 +27,7 @@ config DM_MMC_OPS
 
 config MSM_SDHCI
bool "Qualcomm SDHCI controller"
-   depends on DM_MMC
+   depends on DM_MMC && BLK && DM_MMC_OPS
help
  Enables support for SDHCI 2.0 controller present on some Qualcomm
   Snapdragon devices. This device is compatible with eMMC v4.5 and
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index 150adf0..4bc402c 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -80,9 +80,7 @@ static int msm_sdc_clk_init(struct udevice *dev)
 static int msm_sdc_probe(struct udevice *dev)
 {
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
-#ifdef CONFIG_BLK
struct msm_sdhc_plat *plat = dev_get_platdata(dev);
-#endif
struct msm_sdhc *prv = dev_get_priv(dev);
struct sdhci_host *host = >host;
u32 core_version, core_minor, core_major;
@@ -138,26 +136,17 @@ static int msm_sdc_probe(struct udevice *dev)
/* Set host controller version */
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
 
-#ifdef CONFIG_BLK
caps = sdhci_readl(host, SDHCI_CAPABILITIES);
ret = sdhci_setup_cfg(>cfg, dev->name, host->bus_width,
  caps, 0, 0, host->version, host->quirks, 0);
host->mmc = >mmc;
-#else
-   /* automatically detect max and min speed */
-   ret = add_sdhci(host, 0, 0);
-#endif
if (ret)
return ret;
host->mmc->priv = >host;
host->mmc->dev = dev;
upriv->mmc = host->mmc;
 
-#ifdef CONFIG_DM_MMC_OPS
return sdhci_probe(dev);
-#else
-   return 0;
-#endif
 }
 
 static int msm_sdc_remove(struct udevice *dev)
@@ -194,14 +183,12 @@ static int msm_ofdata_to_platdata(struct udevice *dev)
 
 static int msm_sdc_bind(struct udevice *dev)
 {
-#ifdef CONFIG_BLK
struct msm_sdhc_plat *plat = dev_get_platdata(dev);
int ret;
 
ret = sdhci_bind(dev, >mmc, >cfg);
if (ret)
return ret;
-#endif
 
return 0;
 }
@@ -216,9 +203,7 @@ U_BOOT_DRIVER(msm_sdc_drv) = {
.id = UCLASS_MMC,
.of_match   = msm_mmc_ids,
.ofdata_to_platdata = msm_ofdata_to_platdata,
-#ifdef CONFIG_DM_MMC_OPS
.ops= _ops,
-#endif
.bind   = msm_sdc_bind,
.probe  = msm_sdc_probe,
.remove = msm_sdc_remove,
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 13/27] rockchip: Add MAINTAINER files for kylin_rk3036, evb_rk3036

2016-06-12 Thread Simon Glass
These boards should have maintainer entries. Add them.

Signed-off-by: Simon Glass 
---

 board/evb_rk3036/evb_rk3036/MAINTAINERS | 6 ++
 board/kylin/kylin_rk3036/MAINTAINERS| 6 ++
 2 files changed, 12 insertions(+)

diff --git a/board/evb_rk3036/evb_rk3036/MAINTAINERS 
b/board/evb_rk3036/evb_rk3036/MAINTAINERS
index e69de29..152d31c 100644
--- a/board/evb_rk3036/evb_rk3036/MAINTAINERS
+++ b/board/evb_rk3036/evb_rk3036/MAINTAINERS
@@ -0,0 +1,6 @@
+EVB-RK3036
+M:  huang lin 
+S:  Maintained
+F:  board/evb/evb-rk3036
+F:  include/configs/evb-rk3036.h
+F:  configs/evb-rk3036_defconfig
diff --git a/board/kylin/kylin_rk3036/MAINTAINERS 
b/board/kylin/kylin_rk3036/MAINTAINERS
index e69de29..f8ee834 100644
--- a/board/kylin/kylin_rk3036/MAINTAINERS
+++ b/board/kylin/kylin_rk3036/MAINTAINERS
@@ -0,0 +1,6 @@
+KYLIN-RK3036
+M:  huang lin 
+S:  Maintained
+F:  board/kylin/kylin-rk3036
+F:  include/configs/kylin-rk3036.h
+F:  configs/kylin-rk3036_defconfig
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 20/27] dm: spl: mmc: Support CONFIG_BLK in SPL MMC

2016-06-12 Thread Simon Glass
Update the method of accessing the block device so that it works with
CONFIG_BLK enabled.

Signed-off-by: Simon Glass 
---

 common/spl/spl_mmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index ef8583a..4c60bf6 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -184,7 +184,7 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
unsigned long count;
int ret;
 
-   count = mmc->block_dev.block_read(>block_dev,
+   count = blk_dread(mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
(void *) CONFIG_SYS_SPL_ARGS_ADDR);
@@ -225,13 +225,13 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 
 #ifdef CONFIG_SPL_FAT_SUPPORT
if (!spl_start_uboot()) {
-   err = spl_load_image_fat_os(>block_dev,
+   err = spl_load_image_fat_os(mmc_get_blk_desc(mmc),
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err)
return err;
}
 #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-   err = spl_load_image_fat(>block_dev,
+   err = spl_load_image_fat(mmc_get_blk_desc(mmc),
 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
if (!err)
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 15/27] dm: mmc: sdhci: Refactor configuration setup to support DM

2016-06-12 Thread Simon Glass
Move the configuration setting into a separate function which can be used by
the driver-model code.

Signed-off-by: Simon Glass 
---

 drivers/mmc/sdhci.c | 107 +---
 1 file changed, 59 insertions(+), 48 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 5c71ab8..6e786c8 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -478,73 +479,83 @@ static const struct mmc_ops sdhci_ops = {
.init   = sdhci_init,
 };
 
-int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
+int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
+   uint caps, u32 max_clk, u32 min_clk, uint version,
+   uint quirks, uint host_caps)
 {
-   unsigned int caps;
-
-   host->cfg.name = host->name;
-   host->cfg.ops = _ops;
-
-   caps = sdhci_readl(host, SDHCI_CAPABILITIES);
-#ifdef CONFIG_MMC_SDMA
-   if (!(caps & SDHCI_CAN_DO_SDMA)) {
-   printf("%s: Your controller doesn't support SDMA!!\n",
-  __func__);
-   return -1;
-   }
+   cfg->name = name;
+#ifndef CONFIG_DM_MMC_OPS
+   cfg->ops = _ops;
 #endif
-
if (max_clk)
-   host->cfg.f_max = max_clk;
+   cfg->f_max = max_clk;
else {
-   if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300)
-   host->cfg.f_max = (caps & SDHCI_CLOCK_V3_BASE_MASK)
-   >> SDHCI_CLOCK_BASE_SHIFT;
+   if (version >= SDHCI_SPEC_300)
+   cfg->f_max = (caps & SDHCI_CLOCK_V3_BASE_MASK) >>
+   SDHCI_CLOCK_BASE_SHIFT;
else
-   host->cfg.f_max = (caps & SDHCI_CLOCK_BASE_MASK)
-   >> SDHCI_CLOCK_BASE_SHIFT;
-   host->cfg.f_max *= 100;
-   }
-   if (host->cfg.f_max == 0) {
-   printf("%s: Hardware doesn't specify base clock frequency\n",
-  __func__);
-   return -1;
+   cfg->f_max = (caps & SDHCI_CLOCK_BASE_MASK) >>
+   SDHCI_CLOCK_BASE_SHIFT;
+   cfg->f_max *= 100;
}
+   if (cfg->f_max == 0)
+   return -EINVAL;
if (min_clk)
-   host->cfg.f_min = min_clk;
+   cfg->f_min = min_clk;
else {
-   if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300)
-   host->cfg.f_min = host->cfg.f_max /
-   SDHCI_MAX_DIV_SPEC_300;
+   if (version >= SDHCI_SPEC_300)
+   cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_300;
else
-   host->cfg.f_min = host->cfg.f_max /
-   SDHCI_MAX_DIV_SPEC_200;
+   cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_200;
}
-
-   host->cfg.voltages = 0;
+   cfg->voltages = 0;
if (caps & SDHCI_CAN_VDD_330)
-   host->cfg.voltages |= MMC_VDD_32_33 | MMC_VDD_33_34;
+   cfg->voltages |= MMC_VDD_32_33 | MMC_VDD_33_34;
if (caps & SDHCI_CAN_VDD_300)
-   host->cfg.voltages |= MMC_VDD_29_30 | MMC_VDD_30_31;
+   cfg->voltages |= MMC_VDD_29_30 | MMC_VDD_30_31;
if (caps & SDHCI_CAN_VDD_180)
-   host->cfg.voltages |= MMC_VDD_165_195;
+   cfg->voltages |= MMC_VDD_165_195;
 
-   if (host->quirks & SDHCI_QUIRK_BROKEN_VOLTAGE)
-   host->cfg.voltages |= host->voltages;
-
-   host->cfg.host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT;
-   if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
+   cfg->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT;
+   if (version >= SDHCI_SPEC_300) {
if (caps & SDHCI_CAN_DO_8BIT)
-   host->cfg.host_caps |= MMC_MODE_8BIT;
+   cfg->host_caps |= MMC_MODE_8BIT;
}
 
-   if (host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)
-   host->cfg.host_caps &= ~(MMC_MODE_HS | MMC_MODE_HS_52MHz);
+   if (quirks & SDHCI_QUIRK_NO_HISPD_BIT)
+   cfg->host_caps &= ~(MMC_MODE_HS | MMC_MODE_HS_52MHz);
+
+   if (host_caps)
+   cfg->host_caps |= host_caps;
 
-   if (host->host_caps)
-   host->cfg.host_caps |= host->host_caps;
+   cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
-   host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
+   return 0;
+}
+
+int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
+{
+   unsigned int caps;
+
+   caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+#ifdef CONFIG_MMC_SDMA
+   if (!(caps & SDHCI_CAN_DO_SDMA)) {
+   printf("%s: Your controller doesn't support SDMA!!\n",
+   

[U-Boot] [PATCH 14/27] dm: sandbox: Convert to use CONFIG_CMD_MMC_OPS

2016-06-12 Thread Simon Glass
Update the sandbox MMC emulation to use driver model for MMC operations.

Signed-off-by: Simon Glass 
---

 arch/Kconfig  |  1 +
 configs/sandbox_defconfig |  4 ++--
 drivers/mmc/sandbox_mmc.c | 17 ++---
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 566f044..c43787c 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -63,6 +63,7 @@ config SANDBOX
select DM_I2C
select DM_SPI
select DM_GPIO
+   select DM_MMC
 
 config SH
bool "SuperH architecture"
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 71f7130..8777bb8 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_BLK=y
 CONFIG_MMC=y
 CONFIG_PCI=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
@@ -71,6 +70,7 @@ CONFIG_DEVRES=y
 CONFIG_DEBUG_DEVRES=y
 CONFIG_ADC=y
 CONFIG_ADC_SANDBOX=y
+CONFIG_BLK=y
 CONFIG_CLK=y
 CONFIG_CPU=y
 CONFIG_DM_DEMO=y
@@ -101,7 +101,7 @@ CONFIG_CROS_EC_SPI=y
 CONFIG_PWRSEQ=y
 CONFIG_SPL_PWRSEQ=y
 CONFIG_SYSRESET=y
-CONFIG_DM_MMC=y
+CONFIG_DM_MMC_OPS=y
 CONFIG_SANDBOX_MMC=y
 CONFIG_SPI_FLASH_SANDBOX=y
 CONFIG_SPI_FLASH=y
diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
index 7da059c..5f1333b 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -25,7 +25,7 @@ struct sandbox_mmc_plat {
  * This emulate an SD card version 2. Single-block reads result in zero data.
  * Multiple-block reads return a test string.
  */
-static int sandbox_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
struct mmc_data *data)
 {
switch (cmd->cmdidx) {
@@ -85,25 +85,20 @@ static int sandbox_mmc_send_cmd(struct mmc *mmc, struct 
mmc_cmd *cmd,
return 0;
 }
 
-static void sandbox_mmc_set_ios(struct mmc *mmc)
-{
-}
-
-static int sandbox_mmc_init(struct mmc *mmc)
+static int sandbox_mmc_set_ios(struct udevice *dev)
 {
return 0;
 }
 
-static int sandbox_mmc_getcd(struct mmc *mmc)
+static int sandbox_mmc_get_cd(struct udevice *dev)
 {
return 1;
 }
 
-static const struct mmc_ops sandbox_mmc_ops = {
+static const struct dm_mmc_ops sandbox_mmc_ops = {
.send_cmd = sandbox_mmc_send_cmd,
.set_ios = sandbox_mmc_set_ios,
-   .init = sandbox_mmc_init,
-   .getcd = sandbox_mmc_getcd,
+   .get_cd = sandbox_mmc_get_cd,
 };
 
 int sandbox_mmc_probe(struct udevice *dev)
@@ -120,7 +115,6 @@ int sandbox_mmc_bind(struct udevice *dev)
int ret;
 
cfg->name = dev->name;
-   cfg->ops = _mmc_ops;
cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_8BIT;
cfg->voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34;
cfg->f_min = 100;
@@ -150,6 +144,7 @@ U_BOOT_DRIVER(mmc_sandbox) = {
.name   = "mmc_sandbox",
.id = UCLASS_MMC,
.of_match   = sandbox_mmc_ids,
+   .ops= _mmc_ops,
.bind   = sandbox_mmc_bind,
.unbind = sandbox_mmc_unbind,
.probe  = sandbox_mmc_probe,
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 16/27] dm: mmc: sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS

2016-06-12 Thread Simon Glass
Add support for using driver model for block devices and MMC operations in
this driver.

Signed-off-by: Simon Glass 
---

 drivers/mmc/sdhci.c | 40 ++-
 include/sdhci.h | 80 +
 2 files changed, 119 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 6e786c8..7d43f71 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -129,9 +129,17 @@ static int sdhci_transfer_data(struct sdhci_host *host, 
struct mmc_data *data,
 #endif
 #define CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT   100
 
+#ifdef CONFIG_DM_MMC_OPS
+static int sdhci_send_command(struct udevice *dev, struct mmc_cmd *cmd,
+ struct mmc_data *data)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+
+#else
 static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
-  struct mmc_data *data)
+ struct mmc_data *data)
 {
+#endif
struct sdhci_host *host = mmc->priv;
unsigned int stat = 0;
int ret = 0;
@@ -389,8 +397,14 @@ static void sdhci_set_power(struct sdhci_host *host, 
unsigned short power)
sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
 }
 
+#ifdef CONFIG_DM_MMC_OPS
+static int sdhci_set_ios(struct udevice *dev)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+#else
 static void sdhci_set_ios(struct mmc *mmc)
 {
+#endif
u32 ctrl;
struct sdhci_host *host = mmc->priv;
 
@@ -426,6 +440,9 @@ static void sdhci_set_ios(struct mmc *mmc)
ctrl &= ~SDHCI_CTRL_HISPD;
 
sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+#ifdef CONFIG_DM_MMC_OPS
+   return 0;
+#endif
 }
 
 static int sdhci_init(struct mmc *mmc)
@@ -472,12 +489,25 @@ static int sdhci_init(struct mmc *mmc)
return 0;
 }
 
+#ifdef CONFIG_DM_MMC_OPS
+int sdhci_probe(struct udevice *dev)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+
+   return sdhci_init(mmc);
+}
 
+const struct dm_mmc_ops sdhci_ops = {
+   .send_cmd   = sdhci_send_command,
+   .set_ios= sdhci_set_ios,
+};
+#else
 static const struct mmc_ops sdhci_ops = {
.send_cmd   = sdhci_send_command,
.set_ios= sdhci_set_ios,
.init   = sdhci_init,
 };
+#endif
 
 int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
uint caps, u32 max_clk, u32 min_clk, uint version,
@@ -528,11 +558,18 @@ int sdhci_setup_cfg(struct mmc_config *cfg, const char 
*name, int buswidth,
if (host_caps)
cfg->host_caps |= host_caps;
 
+
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
return 0;
 }
 
+#ifdef CONFIG_BLK
+int sdhci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg)
+{
+   return mmc_bind(dev, mmc, cfg);
+}
+#else
 int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
 {
unsigned int caps;
@@ -567,3 +604,4 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 
min_clk)
 
return 0;
 }
+#endif
diff --git a/include/sdhci.h b/include/sdhci.h
index e0f6667..c4d3b55 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -338,5 +338,85 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int 
reg)
 }
 #endif
 
+#ifdef CONFIG_BLK
+/**
+ * sdhci_setup_cfg() - Set up the configuration for DWMMC
+ *
+ * This is used to set up an SDHCI device when you are using CONFIG_BLK.
+ *
+ * This should be called from your MMC driver's probe() method once you have
+ * the information required.
+ *
+ * Generally your driver will have a platform data structure which holds both
+ * the configuration (struct mmc_config) and the MMC device info (struct mmc).
+ * For example:
+ *
+ * struct msm_sdhc_plat {
+ * struct mmc_config cfg;
+ * struct mmc mmc;
+ * };
+ *
+ * ...
+ *
+ * Inside U_BOOT_DRIVER():
+ * .platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat),
+ *
+ * To access platform data:
+ * struct msm_sdhc_plat *plat = dev_get_platdata(dev);
+ *
+ * See msm_sdhci.c for an example.
+ *
+ * @cfg:   Configuration structure to fill in (generally >mmc)
+ * @name:  Device name (normally dev->name)
+ * @buswidth:  Bus width (in bits, such as 4 or 8)
+ * @caps:  Host capabilities (MMC_MODE_...)
+ * @max_clk:   Maximum supported clock speed in HZ (0 for default)
+ * @min_clk:   Minimum supported clock speed in HZ (0 for default)
+ * @version:   Host controller version (generally read from the
+ * SDHCI_HOST_VERSION register)
+ * @quirks:Quick flags (SDHCI_QUIRK_...)
+ * @host_caps: Additional host capabilities (0 if none)
+ */
+int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
+   uint caps, u32 max_clk, u32 min_clk, uint version,
+   uint quirks, uint host_caps);
+
+/**
+ * sdhci_bind() - Set up a new MMC block device
+ *
+ * This is used to set up an SDHCI block device when you 

[U-Boot] [PATCH 09/27] rockchip: Disable CONFIG_SDHCI

2016-06-12 Thread Simon Glass
This option is not actually needed for rockchip boards. Drop it, since it
will not support driver-model MMC operation support.

Signed-off-by: Simon Glass 
---

 include/configs/rk3036_common.h | 1 -
 include/configs/rk3288_common.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h
index 1bdcf9d..ae4b101 100644
--- a/include/configs/rk3036_common.h
+++ b/include/configs/rk3036_common.h
@@ -45,7 +45,6 @@
 /* MMC/SD IP block */
 #define CONFIG_MMC
 #define CONFIG_GENERIC_MMC
-#define CONFIG_SDHCI
 #define CONFIG_DWMMC
 #define CONFIG_BOUNCE_BUFFER
 
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h
index 9d50d83..8adc26f 100644
--- a/include/configs/rk3288_common.h
+++ b/include/configs/rk3288_common.h
@@ -51,7 +51,6 @@
 /* MMC/SD IP block */
 #define CONFIG_MMC
 #define CONFIG_GENERIC_MMC
-#define CONFIG_SDHCI
 #define CONFIG_DWMMC
 #define CONFIG_BOUNCE_BUFFER
 
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 11/27] dm: mmc: dwmmc: Support CONFIG_DM_MMC_OPS

2016-06-12 Thread Simon Glass
Add support to dwmmc for using driver model for MMC operations.

Signed-off-by: Simon Glass 
---

 drivers/mmc/dw_mmc.c | 33 +
 include/dwmmc.h  |  9 +
 2 files changed, 42 insertions(+)

diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index 74a2663..3411f95 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -181,9 +181,16 @@ static int dwmci_set_transfer_mode(struct dwmci_host *host,
return mode;
 }
 
+#ifdef CONFIG_DM_MMC_OPS
+int dwmci_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
+  struct mmc_data *data)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+#else
 static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
struct mmc_data *data)
 {
+#endif
struct dwmci_host *host = mmc->priv;
ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac,
 data ? DIV_ROUND_UP(data->blocks, 8) : 0);
@@ -373,8 +380,14 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 
freq)
return 0;
 }
 
+#ifdef CONFIG_DM_MMC_OPS
+int dwmci_set_ios(struct udevice *dev)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+#else
 static void dwmci_set_ios(struct mmc *mmc)
 {
+#endif
struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
u32 ctype, regs;
 
@@ -405,6 +418,9 @@ static void dwmci_set_ios(struct mmc *mmc)
 
if (host->clksel)
host->clksel(host);
+#ifdef CONFIG_DM_MMC_OPS
+   return 0;
+#endif
 }
 
 static int dwmci_init(struct mmc *mmc)
@@ -448,17 +464,34 @@ static int dwmci_init(struct mmc *mmc)
return 0;
 }
 
+#ifdef CONFIG_DM_MMC_OPS
+int dwmci_probe(struct udevice *dev)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+
+   return dwmci_init(mmc);
+}
+
+const struct dm_mmc_ops dm_dwmci_ops = {
+   .send_cmd   = dwmci_send_cmd,
+   .set_ios= dwmci_set_ios,
+};
+
+#else
 static const struct mmc_ops dwmci_ops = {
.send_cmd   = dwmci_send_cmd,
.set_ios= dwmci_set_ios,
.init   = dwmci_init,
 };
+#endif
 
 void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
 uint caps, u32 max_clk, u32 min_clk)
 {
cfg->name = name;
+#ifndef CONFIG_DM_MMC_OPS
cfg->ops = _ops;
+#endif
cfg->f_min = min_clk;
cfg->f_max = max_clk;
 
diff --git a/include/dwmmc.h b/include/dwmmc.h
index 0199def..6aebe96 100644
--- a/include/dwmmc.h
+++ b/include/dwmmc.h
@@ -293,4 +293,13 @@ int dwmci_bind(struct udevice *dev, struct mmc *mmc, 
struct mmc_config *cfg);
 int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk);
 #endif /* !CONFIG_BLK */
 
+#ifdef CONFIG_DM_MMC_OPS
+/* Export the operations to drivers */
+int dwmci_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
+  struct mmc_data *data);
+int dwmci_set_ios(struct udevice *dev);
+int dwmci_probe(struct udevice *dev);
+extern const struct dm_mmc_ops dm_dwmci_ops;
+#endif
+
 #endif /* __DWMMC_HW_H */
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 12/27] dm: mmc: rockchip: Enable CONFIG_DM_MMC_OPS for all boards

2016-06-12 Thread Simon Glass
Enable this option to move rockchip over to use driver model for MMC
operations.

Signed-off-by: Simon Glass 
---

 arch/arm/Kconfig  | 1 +
 drivers/mmc/rockchip_dw_mmc.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 85b4d31..1af9c35 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -831,6 +831,7 @@ config ARCH_ROCKCHIP
select DM_GPIO
select DM_I2C
select DM_MMC
+   select DM_MMC_OPS
select DM_SERIAL
select DM_SPI
select DM_SPI_FLASH
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index d928b0b..65b9aba 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -113,7 +113,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
host->mmc->dev = dev;
upriv->mmc = host->mmc;
 
-   return 0;
+   return dwmci_probe(dev);
 }
 
 static int rockchip_dwmmc_bind(struct udevice *dev)
@@ -138,6 +138,7 @@ U_BOOT_DRIVER(rockchip_dwmmc_drv) = {
.id = UCLASS_MMC,
.of_match   = rockchip_dwmmc_ids,
.ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata,
+   .ops= _dwmci_ops,
.bind   = rockchip_dwmmc_bind,
.probe  = rockchip_dwmmc_probe,
.priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv),
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 08/27] mmc: Move tracing code into separate functions

2016-06-12 Thread Simon Glass
Move this code into separate functions so that it can be used from the uclass
also. Add static inline versions for when the option is disabled.

Signed-off-by: Simon Glass 
---

 drivers/mmc/mmc.c | 41 ++---
 drivers/mmc/mmc_private.h | 19 +++
 2 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 6593f25..66aaca7 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -47,17 +47,18 @@ __weak int board_mmc_getcd(struct mmc *mmc)
return -1;
 }
 
-int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+#ifdef CONFIG_MMC_TRACE
+void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
 {
-   int ret;
+   printf("CMD_SEND:%d\n", cmd->cmdidx);
+   printf("\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg);
+}
 
-#ifdef CONFIG_MMC_TRACE
+void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret)
+{
int i;
u8 *ptr;
 
-   printf("CMD_SEND:%d\n", cmd->cmdidx);
-   printf("\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg);
-   ret = mmc->cfg->ops->send_cmd(mmc, cmd, data);
if (ret) {
printf("\t\tRET\t\t\t %d\n", ret);
} else {
@@ -103,9 +104,25 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
struct mmc_data *data)
break;
}
}
-#else
-   ret = mmc->cfg->ops->send_cmd(mmc, cmd, data);
+}
+
+void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
+{
+   int status;
+
+   status = (cmd->response[0] & MMC_STATUS_CURR_STATE) >> 9;
+   printf("CURR STATE:%d\n", status);
+}
 #endif
+
+int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+{
+   int ret;
+
+   mmmc_trace_before_send(mmc, cmd);
+   ret = mmc->cfg->ops->send_cmd(mmc, cmd, data);
+   mmmc_trace_after_send(mmc, cmd, ret);
+
return ret;
 }
 
@@ -113,9 +130,6 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 {
struct mmc_cmd cmd;
int err, retries = 5;
-#ifdef CONFIG_MMC_TRACE
-   int status;
-#endif
 
cmd.cmdidx = MMC_CMD_SEND_STATUS;
cmd.resp_type = MMC_RSP_R1;
@@ -145,10 +159,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)
udelay(1000);
}
 
-#ifdef CONFIG_MMC_TRACE
-   status = (cmd.response[0] & MMC_STATUS_CURR_STATE) >> 9;
-   printf("CURR STATE:%d\n", status);
-#endif
+   mmc_trace_state(mmc, );
if (timeout <= 0) {
 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
printf("Timeout waiting card ready\n");
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 3d189ba..49ec022 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -73,6 +73,25 @@ static inline ulong mmc_bwrite(struct blk_desc *block_dev, 
lbaint_t start,
 
 #endif /* CONFIG_SPL_BUILD */
 
+#ifdef CONFIG_MMC_TRACE
+void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
+void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
+void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
+#else
+static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
+{
+}
+
+static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
+int ret)
+{
+}
+
+static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
+{
+}
+#endif
+
 /**
  * mmc_get_next_devnum() - Get the next available MMC device number
  *
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 05/27] dm: mmc: Move non-CONFIG_BLK code into mmc_legacy.c

2016-06-12 Thread Simon Glass
Rather than having #ifdef in mmc.c, move this code into the legacy file.

Signed-off-by: Simon Glass 
---

 drivers/mmc/mmc.c| 95 
 drivers/mmc/mmc_legacy.c | 91 ++
 2 files changed, 91 insertions(+), 95 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 52e7be5..40ab506 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -585,29 +585,6 @@ int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
return ret;
 }
 
-#ifndef CONFIG_BLK
-static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
-{
-   struct mmc *mmc = find_mmc_device(desc->devnum);
-   int ret;
-
-   if (!mmc)
-   return -ENODEV;
-
-   if (mmc->block_dev.hwpart == hwpart)
-   return 0;
-
-   if (mmc->part_config == MMCPART_NOAVAILABLE)
-   return -EMEDIUMTYPE;
-
-   ret = mmc_switch_part(mmc, hwpart);
-   if (ret)
-   return ret;
-
-   return 0;
-}
-#endif
-
 int mmc_hwpart_config(struct mmc *mmc,
  const struct mmc_hwpart_conf *conf,
  enum mmc_hwpart_conf_mode mode)
@@ -1508,68 +1485,6 @@ static int mmc_send_if_cond(struct mmc *mmc)
return 0;
 }
 
-#ifndef CONFIG_BLK
-struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
-{
-   struct blk_desc *bdesc;
-   struct mmc *mmc;
-
-   /* quick validation */
-   if (cfg == NULL || cfg->ops == NULL || cfg->ops->send_cmd == NULL ||
-   cfg->f_min == 0 || cfg->f_max == 0 || cfg->b_max == 0)
-   return NULL;
-
-   mmc = calloc(1, sizeof(*mmc));
-   if (mmc == NULL)
-   return NULL;
-
-   mmc->cfg = cfg;
-   mmc->priv = priv;
-
-   /* the following chunk was mmc_register() */
-
-   /* Setup dsr related values */
-   mmc->dsr_imp = 0;
-   mmc->dsr = 0x;
-   /* Setup the universal parts of the block interface just once */
-   bdesc = mmc_get_blk_desc(mmc);
-   bdesc->if_type = IF_TYPE_MMC;
-   bdesc->removable = 1;
-   bdesc->devnum = mmc_get_next_devnum();
-   bdesc->block_read = mmc_bread;
-   bdesc->block_write = mmc_bwrite;
-   bdesc->block_erase = mmc_berase;
-
-   /* setup initial part type */
-   bdesc->part_type = mmc->cfg->part_type;
-   mmc_list_add(mmc);
-
-   return mmc;
-}
-
-void mmc_destroy(struct mmc *mmc)
-{
-   /* only freeing memory for now */
-   free(mmc);
-}
-
-static int mmc_get_dev(int dev, struct blk_desc **descp)
-{
-   struct mmc *mmc = find_mmc_device(dev);
-   int ret;
-
-   if (!mmc)
-   return -ENODEV;
-   ret = mmc_init(mmc);
-   if (ret)
-   return ret;
-
-   *descp = >block_dev;
-
-   return 0;
-}
-#endif
-
 /* board-specific MMC power initializations. */
 __weak void board_mmc_power_init(void)
 {
@@ -1891,13 +1806,3 @@ int mmc_set_rst_n_function(struct mmc *mmc, u8 enable)
  enable);
 }
 #endif
-
-#ifndef CONFIG_BLK
-U_BOOT_LEGACY_BLK(mmc) = {
-   .if_typename= "mmc",
-   .if_type= IF_TYPE_MMC,
-   .max_devs   = -1,
-   .get_dev= mmc_get_dev,
-   .select_hwpart  = mmc_select_hwpartp,
-};
-#endif
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index 3ec649f..040728b 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -6,7 +6,9 @@
  */
 
 #include 
+#include 
 #include 
+#include "mmc_private.h"
 
 static struct list_head mmc_devices;
 static int cur_dev_num = -1;
@@ -106,3 +108,92 @@ void print_mmc_devices(char separator)
 #else
 void print_mmc_devices(char separator) { }
 #endif
+
+struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
+{
+   struct blk_desc *bdesc;
+   struct mmc *mmc;
+
+   /* quick validation */
+   if (cfg == NULL || cfg->ops == NULL || cfg->ops->send_cmd == NULL ||
+   cfg->f_min == 0 || cfg->f_max == 0 || cfg->b_max == 0)
+   return NULL;
+
+   mmc = calloc(1, sizeof(*mmc));
+   if (mmc == NULL)
+   return NULL;
+
+   mmc->cfg = cfg;
+   mmc->priv = priv;
+
+   /* the following chunk was mmc_register() */
+
+   /* Setup dsr related values */
+   mmc->dsr_imp = 0;
+   mmc->dsr = 0x;
+   /* Setup the universal parts of the block interface just once */
+   bdesc = mmc_get_blk_desc(mmc);
+   bdesc->if_type = IF_TYPE_MMC;
+   bdesc->removable = 1;
+   bdesc->devnum = mmc_get_next_devnum();
+   bdesc->block_read = mmc_bread;
+   bdesc->block_write = mmc_bwrite;
+   bdesc->block_erase = mmc_berase;
+
+   /* setup initial part type */
+   bdesc->part_type = mmc->cfg->part_type;
+   mmc_list_add(mmc);
+
+   return mmc;
+}
+
+void mmc_destroy(struct mmc *mmc)
+{
+   /* only freeing memory for now */
+   

[U-Boot] [PATCH 06/27] mmc: Move MMC boot code into its own file

2016-06-12 Thread Simon Glass
Rather than having an #ifdef in the main mmc.c file, control this feature
from the Makefile by moving the code into its own file.

Signed-off-by: Simon Glass 
---

 drivers/mmc/Makefile  |   3 ++
 drivers/mmc/mmc.c | 126 +---
 drivers/mmc/mmc_boot.c| 131 ++
 drivers/mmc/mmc_private.h |  11 
 4 files changed, 146 insertions(+), 125 deletions(-)
 create mode 100644 drivers/mmc/mmc_boot.c

diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 3da4817..b44a12e 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -25,6 +25,9 @@ obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o
 obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o
 obj-$(CONFIG_GENERIC_MMC) += mmc.o
+ifdef CONFIG_SUPPORT_EMMC_BOOT
+obj-$(CONFIG_GENERIC_MMC) += mmc_boot.o
+endif
 obj-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o
 obj-$(CONFIG_KONA_SDHCI) += kona_sdhci.o
 obj-$(CONFIG_MMC_SPI) += mmc_spi.o
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 40ab506..6593f25 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -463,8 +463,7 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
return err;
 }
 
-
-static int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
+int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 {
struct mmc_cmd cmd;
int timeout = 1000;
@@ -1683,126 +1682,3 @@ int mmc_initialize(bd_t *bis)
mmc_do_preinit();
return 0;
 }
-
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
-/*
- * This function changes the size of boot partition and the size of rpmb
- * partition present on EMMC devices.
- *
- * Input Parameters:
- * struct *mmc: pointer for the mmc device strcuture
- * bootsize: size of boot partition
- * rpmbsize: size of rpmb partition
- *
- * Returns 0 on success.
- */
-
-int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
-   unsigned long rpmbsize)
-{
-   int err;
-   struct mmc_cmd cmd;
-
-   /* Only use this command for raw EMMC moviNAND. Enter backdoor mode */
-   cmd.cmdidx = MMC_CMD_RES_MAN;
-   cmd.resp_type = MMC_RSP_R1b;
-   cmd.cmdarg = MMC_CMD62_ARG1;
-
-   err = mmc_send_cmd(mmc, , NULL);
-   if (err) {
-   debug("mmc_boot_partition_size_change: Error1 = %d\n", err);
-   return err;
-   }
-
-   /* Boot partition changing mode */
-   cmd.cmdidx = MMC_CMD_RES_MAN;
-   cmd.resp_type = MMC_RSP_R1b;
-   cmd.cmdarg = MMC_CMD62_ARG2;
-
-   err = mmc_send_cmd(mmc, , NULL);
-   if (err) {
-   debug("mmc_boot_partition_size_change: Error2 = %d\n", err);
-   return err;
-   }
-   /* boot partition size is multiple of 128KB */
-   bootsize = (bootsize * 1024) / 128;
-
-   /* Arg: boot partition size */
-   cmd.cmdidx = MMC_CMD_RES_MAN;
-   cmd.resp_type = MMC_RSP_R1b;
-   cmd.cmdarg = bootsize;
-
-   err = mmc_send_cmd(mmc, , NULL);
-   if (err) {
-   debug("mmc_boot_partition_size_change: Error3 = %d\n", err);
-   return err;
-   }
-   /* RPMB partition size is multiple of 128KB */
-   rpmbsize = (rpmbsize * 1024) / 128;
-   /* Arg: RPMB partition size */
-   cmd.cmdidx = MMC_CMD_RES_MAN;
-   cmd.resp_type = MMC_RSP_R1b;
-   cmd.cmdarg = rpmbsize;
-
-   err = mmc_send_cmd(mmc, , NULL);
-   if (err) {
-   debug("mmc_boot_partition_size_change: Error4 = %d\n", err);
-   return err;
-   }
-   return 0;
-}
-
-/*
- * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH
- * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH
- * and BOOT_MODE.
- *
- * Returns 0 on success.
- */
-int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
-{
-   int err;
-
-   err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
-EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
-EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
-EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
-
-   if (err)
-   return err;
-   return 0;
-}
-
-/*
- * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
- * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
- * PARTITION_ACCESS.
- *
- * Returns 0 on success.
- */
-int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
-{
-   int err;
-
-   err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
-EXT_CSD_BOOT_ACK(ack) |
-EXT_CSD_BOOT_PART_NUM(part_num) |
-EXT_CSD_PARTITION_ACCESS(access));
-
-   if (err)
-   return err;
-   return 0;
-}
-
-/*
- * Modify EXT_CSD[162] which is RST_n_FUNCTION based on the given value
- * for enable.  Note that this is 

[U-Boot] [PATCH 10/27] dm: mmc: Add a way to use driver model for MMC operations

2016-06-12 Thread Simon Glass
The driver model conversion for MMC has moved in small steps. The first step
was to have an MMC device (CONFIG_DM_MMC). The second was to use a child
block device (CONFIG_BLK). The final one is to use driver model for MMC
operations (CONFIG_DM_MMC_OP). Add support for this.

The immediate priority is to make all boards that use DM_MMC also use those
other two options. This will allow them to be removed.

Signed-off-by: Simon Glass 
---

 drivers/mmc/Kconfig  |  9 +++
 drivers/mmc/mmc-uclass.c | 66 
 drivers/mmc/mmc.c| 21 ---
 include/mmc.h| 66 +++-
 4 files changed, 158 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index c80efc3..b9662f9 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -16,6 +16,15 @@ config DM_MMC
  appear as block devices in U-Boot and can support filesystems such
  as EXT4 and FAT.
 
+config DM_MMC_OPS
+   bool "Support MMC controller operations using Driver Model"
+   depends on DM_MMC
+   help
+ Driver model provides a means of supporting device operations. This
+ option moves MMC operations under the control of driver model. The
+ option will be removed as soon as all DM_MMC drivers use it, as it
+ will the only supported behaviour.
+
 config MSM_SDHCI
bool "Qualcomm SDHCI controller"
depends on DM_MMC
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 530276a..38ced41 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -13,6 +13,72 @@
 #include 
 #include "mmc_private.h"
 
+#ifdef CONFIG_DM_MMC_OPS
+int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
+   struct mmc_data *data)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+   struct dm_mmc_ops *ops = mmc_get_ops(dev);
+   int ret;
+
+   mmmc_trace_before_send(mmc, cmd);
+   if (ops->send_cmd)
+   ret = ops->send_cmd(dev, cmd, data);
+   else
+   ret = -ENOSYS;
+   mmmc_trace_after_send(mmc, cmd, ret);
+
+   return ret;
+}
+
+int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+{
+   return dm_mmc_send_cmd(mmc->dev, cmd, data);
+}
+
+int dm_mmc_set_ios(struct udevice *dev)
+{
+   struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+   if (!ops->set_ios)
+   return -ENOSYS;
+   return ops->set_ios(dev);
+}
+
+int mmc_set_ios(struct mmc *mmc)
+{
+   return dm_mmc_set_ios(mmc->dev);
+}
+
+int dm_mmc_get_wp(struct udevice *dev)
+{
+   struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+   if (!ops->get_wp)
+   return -ENOSYS;
+   return ops->get_wp(dev);
+}
+
+int mmc_getwp(struct mmc *mmc)
+{
+   return dm_mmc_get_wp(mmc->dev);
+}
+
+int dm_mmc_get_cd(struct udevice *dev)
+{
+   struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+   if (!ops->get_cd)
+   return -ENOSYS;
+   return ops->get_cd(dev);
+}
+
+int mmc_getcd(struct mmc *mmc)
+{
+   return dm_mmc_get_cd(mmc->dev);
+}
+#endif
+
 struct mmc *mmc_get_mmc_dev(struct udevice *dev)
 {
struct mmc_uclass_priv *upriv;
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 66aaca7..54324ce 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -21,6 +21,7 @@
 #include 
 #include "mmc_private.h"
 
+#ifndef CONFIG_DM_MMC_OPS
 __weak int board_mmc_getwp(struct mmc *mmc)
 {
return -1;
@@ -46,6 +47,7 @@ __weak int board_mmc_getcd(struct mmc *mmc)
 {
return -1;
 }
+#endif
 
 #ifdef CONFIG_MMC_TRACE
 void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
@@ -115,6 +117,7 @@ void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
 }
 #endif
 
+#ifndef CONFIG_DM_MMC_OPS
 int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 {
int ret;
@@ -125,6 +128,7 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
struct mmc_data *data)
 
return ret;
 }
+#endif
 
 int mmc_send_status(struct mmc *mmc, int timeout)
 {
@@ -789,6 +793,7 @@ int mmc_hwpart_config(struct mmc *mmc,
return 0;
 }
 
+#ifndef CONFIG_DM_MMC_OPS
 int mmc_getcd(struct mmc *mmc)
 {
int cd;
@@ -804,6 +809,7 @@ int mmc_getcd(struct mmc *mmc)
 
return cd;
 }
+#endif
 
 static int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 {
@@ -967,11 +973,13 @@ static const u8 multipliers[] = {
80,
 };
 
+#ifndef CONFIG_DM_MMC_OPS
 static void mmc_set_ios(struct mmc *mmc)
 {
if (mmc->cfg->ops->set_ios)
mmc->cfg->ops->set_ios(mmc);
 }
+#endif
 
 void mmc_set_clock(struct mmc *mmc, uint clock)
 {
@@ -1502,10 +1510,15 @@ __weak void board_mmc_power_init(void)
 
 int mmc_start_init(struct mmc *mmc)
 {
+   bool no_card;
int err;
 
/* we pretend there's no card when init is NULL */
-

[U-Boot] [PATCH 03/27] mmc: Add function declarations for mmc_bread() and mmc_switch_part()

2016-06-12 Thread Simon Glass
These private functions are used both in the driver-model implementation and
in the legacy code. Add them to the header.

Signed-off-by: Simon Glass 
---

 drivers/mmc/mmc.c |  9 -
 drivers/mmc/mmc_private.h | 17 +
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 7586558..c0a97e4 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -215,11 +215,10 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, 
lbaint_t start,
 }
 
 #ifdef CONFIG_BLK
-static ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
-  void *dst)
+ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, void 
*dst)
 #else
-static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start,
-  lbaint_t blkcnt, void *dst)
+ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
+   void *dst)
 #endif
 {
 #ifdef CONFIG_BLK
@@ -566,7 +565,7 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
return 0;
 }
 
-static int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
+int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
 {
int ret;
 
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 9f0d5c2..cfc4aca 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -20,6 +20,14 @@ extern int mmc_set_blocklen(struct mmc *mmc, int len);
 void mmc_adapter_card_type_ident(void);
 #endif
 
+#ifdef CONFIG_BLK
+ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
+   void *dst);
+#else
+ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
+   void *dst);
+#endif
+
 #ifndef CONFIG_SPL_BUILD
 
 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
@@ -89,4 +97,13 @@ void mmc_list_init(void);
  */
 void mmc_list_add(struct mmc *mmc);
 
+/**
+ * mmc_switch_part() - Switch to a new MMC hardware partition
+ *
+ * @mmc:   MMC device
+ * @part_num:  Hardware partition number
+ * @return 0 if OK, -ve on error
+ */
+int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
+
 #endif /* _MMC_PRIVATE_H_ */
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 07/27] dm: mmc: rockchip: Support only CONFIG_BLK

2016-06-12 Thread Simon Glass
Since all Rockchip boards use CONFIG_BLK, we can remove this old code.

Signed-off-by: Simon Glass 
---

 drivers/mmc/rockchip_dw_mmc.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 750ab9f..d928b0b 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -67,9 +67,7 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice 
*dev)
 
 static int rockchip_dwmmc_probe(struct udevice *dev)
 {
-#ifdef CONFIG_BLK
struct rockchip_mmc_plat *plat = dev_get_platdata(dev);
-#endif
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
struct dwmci_host *host = >host;
@@ -108,16 +106,9 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
return ret;
}
 #endif
-#ifdef CONFIG_BLK
dwmci_setup_cfg(>cfg, dev->name, host->buswidth, host->caps,
minmax[1], minmax[0]);
host->mmc = >mmc;
-#else
-   ret = add_dwmci(host, minmax[1], minmax[0]);
-   if (ret)
-   return ret;
-
-#endif
host->mmc->priv = >host;
host->mmc->dev = dev;
upriv->mmc = host->mmc;
@@ -127,14 +118,12 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 
 static int rockchip_dwmmc_bind(struct udevice *dev)
 {
-#ifdef CONFIG_BLK
struct rockchip_mmc_plat *plat = dev_get_platdata(dev);
int ret;
 
ret = dwmci_bind(dev, >mmc, >cfg);
if (ret)
return ret;
-#endif
 
return 0;
 }
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 02/27] rockchip: Use 'select' instead of defaults in Kconfig

2016-06-12 Thread Simon Glass
Rockchip uses driver model for all subsystems. Specify this in the arm
Kconfig rather than as defaults in the Rockchip Kconfig. This means that
boards cannot turn these options off, which seems correct.

Signed-off-by: Simon Glass 
---

 arch/arm/Kconfig   | 10 ++
 arch/arm/mach-rockchip/Kconfig | 27 ---
 2 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e75c4c0..85b4d31 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -823,7 +823,17 @@ config ARCH_ROCKCHIP
select SPL
select OF_CONTROL
select CPU_V7
+   select BLK
select DM
+   select SPL_DM
+   select SYS_MALLOC_F
+   select SPL_SYS_MALLOC_SIMPLE
+   select DM_GPIO
+   select DM_I2C
+   select DM_MMC
+   select DM_SERIAL
+   select DM_SPI
+   select DM_SPI_FLASH
 
 config TARGET_THUNDERX_88XX
bool "Support ThunderX 88xx"
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 2a8afac..c49cc19 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -17,33 +17,6 @@ config ROCKCHIP_RK3036
  and video codec support. Peripherals include Gigabit Ethernet,
  USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
 
-config SYS_MALLOC_F
-   default y
-
-config SPL_SYS_MALLOC_SIMPLE
-   default y
-
-config SPL_DM
-   default y
-
-config DM_SERIAL
-   default y
-
-config DM_SPI
-   default y
-
-config DM_SPI_FLASH
-   default y
-
-config DM_I2C
-   default y
-
-config DM_GPIO
-   default y
-
-config BLK
-   default y
-
 source "arch/arm/mach-rockchip/rk3288/Kconfig"
 source "arch/arm/mach-rockchip/rk3036/Kconfig"
 endif
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 01/27] dm: mmc: dwmmc: Add comments to the dwmmc setup functions

2016-06-12 Thread Simon Glass
These comments were missed when the original code was written. Add them to
help people port their drivers over.

Signed-off-by: Simon Glass 
---

 include/dwmmc.h | 64 +
 1 file changed, 64 insertions(+)

diff --git a/include/dwmmc.h b/include/dwmmc.h
index 335af51..0199def 100644
--- a/include/dwmmc.h
+++ b/include/dwmmc.h
@@ -224,9 +224,73 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int 
reg)
return readb(host->ioaddr + reg);
 }
 
+#ifdef CONFIG_BLK
+/**
+ * dwmci_setup_cfg() - Set up the configuration for DWMMC
+ *
+ * This is used to set up a DWMMC device when you are using CONFIG_BLK.
+ *
+ * This should be called from your MMC driver's probe() method once you have
+ * the information required.
+ *
+ * Generally your driver will have a platform data structure which holds both
+ * the configuration (struct mmc_config) and the MMC device info (struct mmc).
+ * For example:
+ *
+ * struct rockchip_mmc_plat {
+ * struct mmc_config cfg;
+ * struct mmc mmc;
+ * };
+ *
+ * ...
+ *
+ * Inside U_BOOT_DRIVER():
+ * .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat),
+ *
+ * To access platform data:
+ * struct rockchip_mmc_plat *plat = dev_get_platdata(dev);
+ *
+ * See rockchip_dw_mmc.c for an example.
+ *
+ * @cfg:   Configuration structure to fill in (generally >mmc)
+ * @name:  Device name (normally dev->name)
+ * @buswidth:  Bus width (in bits, such as 4 or 8)
+ * @caps:  Host capabilities (MMC_MODE_...)
+ * @max_clk:   Maximum supported clock speed in HZ (e.g. 40)
+ * @min_clk:   Minimum supported clock speed in HZ (e.g. 15000)
+ */
 void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
 uint caps, u32 max_clk, u32 min_clk);
+
+/**
+ * dwmci_bind() - Set up a new MMC block device
+ *
+ * This is used to set up a DWMMC block device when you are using CONFIG_BLK.
+ * It should be called from your driver's bind() method.
+ *
+ * See rockchip_dw_mmc.c for an example.
+ *
+ * @dev:   Device to set up
+ * @mmc:   Pointer to mmc structure (normally >mmc)
+ * @cfg:   Empty configuration structure (generally >cfg). This is
+ * normally all zeroes at this point. The only purpose of passing
+ * this in is to set mmc->cfg to it.
+ * @return 0 if OK, -ve if the block device could not be created
+ */
 int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg);
 
+#else
+/**
+ * add_dwmci() - Add a new DWMMC interface
+ *
+ * This is used when you are not using CONFIG_BLK. Convert your driver over!
+ *
+ * @host:  DWMMC host structure
+ * @max_clk:   Maximum supported clock speed in HZ (e.g. 40)
+ * @min_clk:   Minimum supported clock speed in HZ (e.g. 15000)
+ * @return 0 if OK, -ve on error
+ */
 int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk);
+#endif /* !CONFIG_BLK */
+
 #endif /* __DWMMC_HW_H */
-- 
2.8.0.rc3.226.g39d4020

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


[U-Boot] [PATCH 04/27] dm: mmc: Move CONFIG_BLK code into the mmc uclass

2016-06-12 Thread Simon Glass
Rather than having #ifdef in mmc.c, move this code into the uclass file.

Signed-off-by: Simon Glass 
---

 drivers/mmc/mmc-uclass.c | 80 +
 drivers/mmc/mmc.c| 85 ++--
 2 files changed, 83 insertions(+), 82 deletions(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 1b967d9..530276a 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -8,8 +8,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include "mmc_private.h"
 
 struct mmc *mmc_get_mmc_dev(struct udevice *dev)
 {
@@ -125,6 +127,84 @@ void print_mmc_devices(char separator)
 #else
 void print_mmc_devices(char separator) { }
 #endif
+
+int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config 
*cfg)
+{
+   struct blk_desc *bdesc;
+   struct udevice *bdev;
+   int ret;
+
+   ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, -1, 512,
+0, );
+   if (ret) {
+   debug("Cannot create block device\n");
+   return ret;
+   }
+   bdesc = dev_get_uclass_platdata(bdev);
+   mmc->cfg = cfg;
+   mmc->priv = dev;
+
+   /* the following chunk was from mmc_register() */
+
+   /* Setup dsr related values */
+   mmc->dsr_imp = 0;
+   mmc->dsr = 0x;
+   /* Setup the universal parts of the block interface just once */
+   bdesc->removable = 1;
+
+   /* setup initial part type */
+   bdesc->part_type = cfg->part_type;
+   mmc->dev = dev;
+
+   return 0;
+}
+
+int mmc_unbind(struct udevice *dev)
+{
+   struct udevice *bdev;
+
+   device_find_first_child(dev, );
+   if (bdev) {
+   device_remove(bdev);
+   device_unbind(bdev);
+   }
+
+   return 0;
+}
+
+static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
+{
+   struct udevice *mmc_dev = dev_get_parent(bdev);
+   struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
+   struct blk_desc *desc = dev_get_uclass_platdata(bdev);
+   int ret;
+
+   if (desc->hwpart == hwpart)
+   return 0;
+
+   if (mmc->part_config == MMCPART_NOAVAILABLE)
+   return -EMEDIUMTYPE;
+
+   ret = mmc_switch_part(mmc, hwpart);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static const struct blk_ops mmc_blk_ops = {
+   .read   = mmc_bread,
+#ifndef CONFIG_SPL_BUILD
+   .write  = mmc_bwrite,
+#endif
+   .select_hwpart  = mmc_select_hwpart,
+};
+
+U_BOOT_DRIVER(mmc_blk) = {
+   .name   = "mmc_blk",
+   .id = UCLASS_BLK,
+   .ops= _blk_ops,
+};
 #endif /* CONFIG_BLK */
 
 U_BOOT_DRIVER(mmc) = {
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c0a97e4..52e7be5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -585,27 +585,7 @@ int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
return ret;
 }
 
-#ifdef CONFIG_BLK
-static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
-{
-   struct udevice *mmc_dev = dev_get_parent(bdev);
-   struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
-   struct blk_desc *desc = dev_get_uclass_platdata(bdev);
-   int ret;
-
-   if (desc->hwpart == hwpart)
-   return 0;
-
-   if (mmc->part_config == MMCPART_NOAVAILABLE)
-   return -EMEDIUMTYPE;
-
-   ret = mmc_switch_part(mmc, hwpart);
-   if (ret)
-   return ret;
-
-   return 0;
-}
-#else
+#ifndef CONFIG_BLK
 static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
 {
struct mmc *mmc = find_mmc_device(desc->devnum);
@@ -1528,52 +1508,7 @@ static int mmc_send_if_cond(struct mmc *mmc)
return 0;
 }
 
-#ifdef CONFIG_BLK
-int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config 
*cfg)
-{
-   struct blk_desc *bdesc;
-   struct udevice *bdev;
-   int ret;
-
-   ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, -1, 512,
-0, );
-   if (ret) {
-   debug("Cannot create block device\n");
-   return ret;
-   }
-   bdesc = dev_get_uclass_platdata(bdev);
-   mmc->cfg = cfg;
-   mmc->priv = dev;
-
-   /* the following chunk was from mmc_register() */
-
-   /* Setup dsr related values */
-   mmc->dsr_imp = 0;
-   mmc->dsr = 0x;
-   /* Setup the universal parts of the block interface just once */
-   bdesc->removable = 1;
-
-   /* setup initial part type */
-   bdesc->part_type = cfg->part_type;
-   mmc->dev = dev;
-
-   return 0;
-}
-
-int mmc_unbind(struct udevice *dev)
-{
-   struct udevice *bdev;
-
-   device_find_first_child(dev, );
-   if (bdev) {
-   device_remove(bdev);
-   device_unbind(bdev);
-   }
-
-   return 0;
-}
-
-#else
+#ifndef 

Re: [U-Boot] [PATCH 3/5] tools: fix define2mk.sed to not add quotes around negative integers

2016-06-12 Thread Heiko Schocher

Hello Masahiro,

Am 10.06.2016 um 17:20 schrieb Masahiro Yamada:

The sed script, tools/scripts/define2mk.sed, converts config defines
from C headers into include/autoconf.mk for the use in Makefiles.

I found the tool adds quotes around negative integer values.

For example, at the point of the v2016.07-rc1 tag,
include/configs/microblaze-generic.h defines
   #define CONFIG_BOOTDELAY -1 /* -1 disables auto-boot */

Because it is an integer option, it should be converted to:
   CONFIG_BOOTDELAY=-1

But, the script actually converts it to:
   CONFIG_BOOTDELAY="-1"

This is a fatal problem for the tools/moveconfig.py because it parses
include/autoconf.mk for the config defines from the board headers.
CONFIG_BOOTDELAY="-1" is considered as a string type option and it
is dropped due to the type mismatch from the entry in Kconfig.

Before commit bb597c0eeb7e ("common: bootdelay: move CONFIG_BOOTDELAY
into a Kconfig option"), several boards defined CONFIG_BOOTDELAY as -1
but they are all gone now.

I will fix the mis-converted options right away, but first I need to
fix the script so that tools/moveconfig.py can convert integer config
options with a negative value correctly.

Signed-off-by: Masahiro Yamada 
---

  tools/scripts/define2mk.sed | 2 ++
  1 file changed, 2 insertions(+)


Uff.. many thanks for the fix!

Reviewed-by: Heiko Schocher 

bye,
Heiko


diff --git a/tools/scripts/define2mk.sed b/tools/scripts/define2mk.sed
index c641edf..0f00285 100644
--- a/tools/scripts/define2mk.sed
+++ b/tools/scripts/define2mk.sed
@@ -22,6 +22,8 @@
s/=\(..*\)/="\1"/;
# but remove again from decimal numbers
s/="\([0-9][0-9]*\)"/=\1/;
+   # ... and from negative decimal numbers
+   s/="\(-[1-9][0-9]*\)"/=\1/;
# ... and from hex numbers
s/="\(0[Xx][0-9a-fA-F][0-9a-fA-F]*\)"/=\1/;
# ... and from configs defined from other configs



--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/5] autoboot: follow-up cleanup after CONFIG_BOOTDELAY moves

2016-06-12 Thread Heiko Schocher

Hello Masahiro,

Am 10.06.2016 um 17:20 schrieb Masahiro Yamada:

Tidy up garbage left by commit bb597c0eeb7e ("common: bootdelay: move
CONFIG_BOOTDELAY into a Kconfig option").

Signed-off-by: Masahiro Yamada 
---

  include/configs/bfin_adi_common.h | 5 -
  include/configs/mx6_common.h  | 3 ---
  include/configs/mx7_common.h  | 3 ---
  include/configs/omap3_cairo.h | 2 --
  4 files changed, 13 deletions(-)


Thanks!

Reviewed-by: Heiko Schocher 

bye,
Heiko


diff --git a/include/configs/bfin_adi_common.h 
b/include/configs/bfin_adi_common.h
index 1307607..502ddad 100644
--- a/include/configs/bfin_adi_common.h
+++ b/include/configs/bfin_adi_common.h
@@ -97,11 +97,6 @@
  /*
   * Env Settings
   */
-#ifndef CONFIG_BOOTDELAY
-# if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART)
-# else
-# endif
-#endif
  #ifndef CONFIG_BOOTCOMMAND
  # define CONFIG_BOOTCOMMAND   "run ramboot"
  #endif
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 27f38f4..fb49322 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -59,9 +59,6 @@
  #endif
  #define CONFIG_SYS_LOAD_ADDR  CONFIG_LOADADDR

-#ifndef CONFIG_BOOTDELAY
-#endif
-
  /* allow to overwrite serial and ethaddr */
  #define CONFIG_ENV_OVERWRITE
  #define CONFIG_CONS_INDEX   1
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index 5e5656d..fbc6de6 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -34,9 +34,6 @@
  #define CONFIG_LOADADDR 0x8080
  #define CONFIG_SYS_TEXT_BASE0x8780

-#ifndef CONFIG_BOOTDELAY
-#endif
-
  /* allow to overwrite serial and ethaddr */
  #define CONFIG_ENV_OVERWRITE
  #define CONFIG_CONS_INDEX   1
diff --git a/include/configs/omap3_cairo.h b/include/configs/omap3_cairo.h
index 96c3c4b..82e0d50 100644
--- a/include/configs/omap3_cairo.h
+++ b/include/configs/omap3_cairo.h
@@ -73,8 +73,6 @@
  #define CONFIG_NAND_OMAP_GPMC
  #define CONFIG_SYS_MAX_NAND_DEVICE1   /* Max number of NAND */
/* devices */
-/* override default CONFIG_BOOTDELAY */
-
  #define CONFIG_EXTRA_ENV_SETTINGS \
"machid=\0" \
"fdt_high=0x8700\0" \



--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [Patch v4 2/5] usb: xhci: fsl: code cleanup for device tree fixup for fsl usb controllers

2016-06-12 Thread Sriram Dash
Performs code cleanup for device tree fixup for fsl usb controllers by
making functions to handle these similar errata checking code.

Signed-off-by: Rajesh Bhagat 
Signed-off-by: Sriram Dash 
---
Changes in v4:
  - Removed parenthesis around has_erratum().
  - Made USB controllers macros local to fsl-dt-fixup.c
  - Changed the "usb2-ci" into "chipidea,usb2", which is a generic one. 

Changes in v3:
  - Inverted the condition for has_erratum for better readability
  - If fdt_fixup_usb_erratum fails, return ENOSPC and exit the fixup
  - Added logic for handling the condition with different controllers
with different erratas
- first check if the errata is applicable for the SoC
- then check if it is applicable for the controller
- if both are successful, then fix dt.

Changes in v2:
  - Added patch description
  - Removed the MACRO and use fdt_fixup_erratum function instead

 drivers/usb/common/fsl-dt-fixup.c | 94 +++
 1 file changed, 56 insertions(+), 38 deletions(-)

diff --git a/drivers/usb/common/fsl-dt-fixup.c 
b/drivers/usb/common/fsl-dt-fixup.c
index 6f31932..1523f98 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -19,10 +19,16 @@
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
 #endif
 
+/* USB Controllers */
+#define FSL_USB2_MPH   "fsl-usb2-mph"
+#define FSL_USB2_DR"fsl-usb2-dr"
+#define CHIPIDEA_USB2  "chipidea,usb2"
+#define SNPS_DWC3  "snps,dwc3"
+
 static const char * const compat_usb_fsl[] = {
-   "fsl-usb2-mph",
-   "fsl-usb2-dr",
-   "snps,dwc3",
+   FSL_USB2_MPH,
+   FSL_USB2_DR,
+   SNPS_DWC3,
NULL
 };
 
@@ -80,16 +86,24 @@ static int fdt_fixup_usb_mode_phy_type(void *blob, const 
char *mode,
 }
 
 static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum,
-int start_offset)
+const char *controller_type, int start_offset)
 {
int node_offset, err;
const char *node_type = NULL;
+   const char *node_name = NULL;
 
err = fdt_usb_get_node_type(blob, start_offset,
_offset, _type);
if (err < 0)
return err;
 
+   if (!strcmp(node_type, FSL_USB2_MPH) || !strcmp(node_type, FSL_USB2_DR))
+   node_name = CHIPIDEA_USB2;
+   else
+   node_name = node_type;
+   if (strcmp(node_name, controller_type))
+   return err;
+
err = fdt_setprop(blob, node_offset, prop_erratum, NULL, 0);
if (err < 0) {
printf("ERROR: could not set %s for %s: %s.\n",
@@ -99,6 +113,23 @@ static int fdt_fixup_usb_erratum(void *blob, const char 
*prop_erratum,
return node_offset;
 }
 
+static int fdt_fixup_erratum(int *usb_erratum_off, void *blob,
+const char *controller_type, char *str,
+bool (*has_erratum)(void))
+{
+   char buf[32] = {0};
+
+   snprintf(buf, sizeof(buf), "fsl,usb-erratum-%s", str);
+   if (!has_erratum())
+   return -EINVAL;
+   *usb_erratum_off = fdt_fixup_usb_erratum(blob, buf, controller_type,
+*usb_erratum_off);
+   if (*usb_erratum_off < 0)
+   return -ENOSPC;
+   debug("Adding USB erratum %s\n", str);
+   return 0;
+}
+
 void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 {
static const char * const modes[] = { "host", "peripheral", "otg" };
@@ -111,6 +142,7 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
int usb_phy_off = -1;
char str[5];
int i, j;
+   int ret;
 
for (i = 1; i <= CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
const char *dr_mode_type = NULL;
@@ -164,39 +196,25 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
if (usb_phy_off < 0)
return;
 
-   if (has_erratum_a006261()) {
-   usb_erratum_a006261_off =  fdt_fixup_usb_erratum
-  (blob,
-   "fsl,usb-erratum-a006261",
-   usb_erratum_a006261_off);
-   if (usb_erratum_a006261_off < 0)
-   return;
-   }
-
-   if (has_erratum_a007075()) {
-   usb_erratum_a007075_off =  fdt_fixup_usb_erratum
-  (blob,
-   "fsl,usb-erratum-a007075",
-   usb_erratum_a007075_off);
-   if (usb_erratum_a007075_off < 0)
-   return;
-   }
-
-   if (has_erratum_a007792()) {
-   

[U-Boot] [Patch v4 5/5] usb: xhci: fsl: Add workaround for USB erratum A-008751

2016-06-12 Thread Sriram Dash
This patch is doing the following:
1. Implementing the errata for LS2080.
2. Adding fixup for fdt for LS2080.

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---

Changes in v4:
  - Reworked for changes done in errata checking code.

Changes in v3:
  - Reworked for changes done in errata checking code.
  - made inline bool erratum_a008751 as int erratum_a008751
  - return 0 for success, 1 for failure for erratum_a008751
  - dropped the APPLY_ERRATUM macro.

Changes in v2:
  - Reworked for changes done in errata checking code.

 .../include/asm/arch-fsl-layerscape/immap_lsch3.h  |  1 +
 board/freescale/ls2080aqds/ls2080aqds.c|  2 ++
 board/freescale/ls2080ardb/ls2080ardb.c|  2 ++
 drivers/usb/common/fsl-dt-fixup.c  |  7 +++
 drivers/usb/common/fsl-errata.c| 15 ++
 drivers/usb/host/xhci-fsl.c| 24 ++
 include/fsl_usb.h  |  1 +
 7 files changed, 52 insertions(+)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
index e48bbaf..9b60bd3 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -139,6 +139,7 @@
 /* Supplemental Configuration */
 #define SCFG_BASE  0x01fc
 #define SCFG_USB3PRM1CR0x000
+#define SCFG_USB3PRM1CR_INIT   0x27672b2a
 
 #define TP_ITYP_AV 0x0001  /* Initiator available */
 #define TP_ITYP_TYPE(x)(((x) & 0x6) >> 1)  /* Initiator Type */
diff --git a/board/freescale/ls2080aqds/ls2080aqds.c 
b/board/freescale/ls2080aqds/ls2080aqds.c
index 897793d..479f689 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -298,6 +298,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_memory_banks(blob, base, size, 2);
 
+   fdt_fixup_dr_usb(blob, bd);
+
 #ifdef CONFIG_FSL_MC_ENET
fdt_fixup_board_enet(blob);
err = fsl_mc_ldpaa_exit(bd);
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c 
b/board/freescale/ls2080ardb/ls2080ardb.c
index 52e5e3f..a65cd4a 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -281,6 +281,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_memory_banks(blob, base, size, 2);
 
+   fdt_fixup_dr_usb(blob, bd);
+
 #ifdef CONFIG_FSL_MC_ENET
fdt_fixup_board_enet(blob);
err = fsl_mc_ldpaa_exit(bd);
diff --git a/drivers/usb/common/fsl-dt-fixup.c 
b/drivers/usb/common/fsl-dt-fixup.c
index 930ca1d..9c48852 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -139,6 +139,7 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
int usb_erratum_a007075_off = -1;
int usb_erratum_a007792_off = -1;
int usb_erratum_a005697_off = -1;
+   int usb_erratum_a008751_off = -1;
int usb_mode_off = -1;
int usb_phy_off = -1;
char str[5];
@@ -217,5 +218,11 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
has_erratum_a005697);
if (ret == -ENOSPC)
return;
+   ret = fdt_fixup_erratum(_erratum_a008751_off, blob,
+   SNPS_DWC3, "a008751",
+   has_erratum_a008751);
+   if (ret == -ENOSPC)
+   return;
+
}
 }
diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c
index 95918fc..ebe60a8 100644
--- a/drivers/usb/common/fsl-errata.c
+++ b/drivers/usb/common/fsl-errata.c
@@ -175,4 +175,19 @@ bool has_erratum_a004477(void)
return false;
 }
 
+bool has_erratum_a008751(void)
+{
+   u32 svr = get_svr();
+   u32 soc = SVR_SOC_VER(svr);
+
+   switch (soc) {
+#ifdef CONFIG_ARM64
+   case SVR_LS2080:
+   case SVR_LS2085:
+   return IS_SVR_REV(svr, 1, 0);
+#endif
+   }
+   return false;
+}
+
 #endif
diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c
index 05f09d7..c12a189 100644
--- a/drivers/usb/host/xhci-fsl.c
+++ b/drivers/usb/host/xhci-fsl.c
@@ -15,6 +15,8 @@
 #include 
 #include 
 #include "xhci.h"
+#include 
+#include 
 
 /* Declare global data pointer */
 DECLARE_GLOBAL_DATA_PTR;
@@ -27,6 +29,26 @@ __weak int __board_usb_init(int index, enum usb_init_type 
init)
return 0;
 }
 
+static int erratum_a008751(void)
+{
+#if defined(CONFIG_TARGET_LS2080AQDS) || defined(CONFIG_TARGET_LS2080ARDB)
+   u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
+   writel(SCFG_USB3PRM1CR_INIT, scfg + SCFG_USB3PRM1CR / 4);
+   return 0;
+#endif
+   return 1;
+}
+
+static void fsl_apply_xhci_errata(void)
+{
+   int ret;
+   if (has_erratum_a008751()) {
+ 

[U-Boot] [Patch v4 3/5] fsl: usb: make errata function common for PPC and ARM

2016-06-12 Thread Sriram Dash
This patch does the following things:
1. Makes the errata checking code common for PPC and ARM
2. Moves all these static inline functions into a dedicated C file

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---

Changes in v4:
  - Rework done according to previous patches.

Changes in v3:
  - Rework done according to previous patches.

Changes in v2:
  - Moves all the static inline functions into a dedicated C file

 drivers/usb/common/Makefile   |   4 +-
 drivers/usb/common/fsl-dt-fixup.c |   1 +
 drivers/usb/common/fsl-errata.c   | 178 +++
 include/fsl_usb.h | 191 ++
 4 files changed, 189 insertions(+), 185 deletions(-)
 create mode 100644 drivers/usb/common/fsl-errata.c

diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 2f46d38..aee7e32 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -4,5 +4,5 @@
 #
 
 obj-$(CONFIG_DM_USB) += common.o
-obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o
-obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o
+obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
+obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
diff --git a/drivers/usb/common/fsl-dt-fixup.c 
b/drivers/usb/common/fsl-dt-fixup.c
index 1523f98..930ca1d 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c
new file mode 100644
index 000..95918fc
--- /dev/null
+++ b/drivers/usb/common/fsl-errata.c
@@ -0,0 +1,178 @@
+/*
+ * Freescale USB Controller
+ *
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include
+
+/* USB Erratum Checking code */
+#if defined(CONFIG_PPC) || defined(CONFIG_ARM)
+bool has_dual_phy(void)
+{
+   u32 svr = get_svr();
+   u32 soc = SVR_SOC_VER(svr);
+
+   switch (soc) {
+#ifdef CONFIG_PPC
+   case SVR_T1023:
+   case SVR_T1024:
+   case SVR_T1013:
+   case SVR_T1014:
+   return IS_SVR_REV(svr, 1, 0);
+   case SVR_T1040:
+   case SVR_T1042:
+   case SVR_T1020:
+   case SVR_T1022:
+   case SVR_T2080:
+   case SVR_T2081:
+   return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
+   case SVR_T4240:
+   case SVR_T4160:
+   case SVR_T4080:
+   return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+#endif
+   }
+
+   return false;
+}
+
+bool has_erratum_a006261(void)
+{
+   u32 svr = get_svr();
+   u32 soc = SVR_SOC_VER(svr);
+
+   switch (soc) {
+#ifdef CONFIG_PPC
+   case SVR_P1010:
+   return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+   case SVR_P2041:
+   case SVR_P2040:
+   return IS_SVR_REV(svr, 1, 0) ||
+   IS_SVR_REV(svr, 1, 1) || IS_SVR_REV(svr, 2, 1);
+   case SVR_P3041:
+   return IS_SVR_REV(svr, 1, 0) ||
+   IS_SVR_REV(svr, 1, 1) ||
+   IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
+   case SVR_P5010:
+   case SVR_P5020:
+   case SVR_P5021:
+   return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+   case SVR_T4240:
+   case SVR_T4160:
+   case SVR_T4080:
+   return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+   case SVR_T1040:
+   return IS_SVR_REV(svr, 1, 0);
+   case SVR_T2080:
+   case SVR_T2081:
+   return IS_SVR_REV(svr, 1, 0);
+   case SVR_P5040:
+   return IS_SVR_REV(svr, 1, 0);
+#endif
+   }
+
+   return false;
+}
+
+bool has_erratum_a007075(void)
+{
+   u32 svr = get_svr();
+   u32 soc = SVR_SOC_VER(svr);
+
+   switch (soc) {
+#ifdef CONFIG_PPC
+   case SVR_B4860:
+   case SVR_B4420:
+   return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+   case SVR_P1010:
+   return IS_SVR_REV(svr, 1, 0);
+   case SVR_P4080:
+   return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0);
+#endif
+   }
+   return false;
+}
+
+bool has_erratum_a007798(void)
+{
+#ifdef CONFIG_PPC
+   return SVR_SOC_VER(get_svr()) == SVR_T4240 &&
+   IS_SVR_REV(get_svr(), 2, 0);
+#endif
+   return false;
+}
+
+bool has_erratum_a007792(void)
+{
+   u32 svr = get_svr();
+   u32 soc = SVR_SOC_VER(svr);
+
+   switch (soc) {
+#ifdef CONFIG_PPC
+   case SVR_T4240:
+   case SVR_T4160:
+   case SVR_T4080:
+   return IS_SVR_REV(svr, 2, 0);
+   case SVR_T1024:
+   case SVR_T1023:
+   return IS_SVR_REV(svr, 1, 0);
+   case SVR_T1040:
+   case SVR_T1042:
+   case SVR_T1020:
+   case SVR_T1022:
+   case SVR_T2080:
+   case 

[U-Boot] [Patch v4 4/5] armv8/ls2080: Remove workaround for erratum A008751

2016-06-12 Thread Sriram Dash
This errata a008751 is applied on Soc specific file currently.This will be
moved to a file where all the errata implementation will take place for usb
for fsl. This patch removes the errata workaround from soc specific file
for LS2080.

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---

Changes in v4:
  - No update

Changes in v3:
  - Modified commit message

Changes in v2:
  - No update

 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index dd633f3..d8ec426 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -124,15 +124,6 @@ void erratum_a009635(void)
 }
 #endif /* CONFIG_SYS_FSL_ERRATUM_A009635 */
 
-static void erratum_a008751(void)
-{
-#ifdef CONFIG_SYS_FSL_ERRATUM_A008751
-   u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
-
-   writel(0x27672b2a, scfg + SCFG_USB3PRM1CR / 4);
-#endif
-}
-
 static void erratum_rcw_src(void)
 {
 #if defined(CONFIG_SPL)
@@ -189,7 +180,6 @@ void bypass_smmu(void)
 }
 void fsl_lsch3_early_init_f(void)
 {
-   erratum_a008751();
erratum_rcw_src();
init_early_memctl_regs();   /* tighten IFC timing */
erratum_a009203();
-- 
2.1.0

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


[U-Boot] [Patch v4 1/5] arm64: fsl-layerscape: add get_svr and IS_SVR_REV helper

2016-06-12 Thread Sriram Dash
Adds get_svr and IS_SVR_REV helpers for ARMv8 platforms,
similar to PPC and ARMv7.

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---

 Changes in v4:
  - Parenthesis around all the macro args.

 Changes in v3:
  - Added commit message

 Changes in v2:
  - No update

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c| 7 +++
 arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h | 2 ++
 arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h | 3 +++
 arch/arm/include/asm/arch-fsl-layerscape/soc.h | 2 ++
 4 files changed, 14 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index 9a5a6b5..9c575c1 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -528,6 +528,13 @@ u32 fsl_qoriq_core_to_type(unsigned int core)
return -1;  /* cannot identify the cluster */
 }
 
+uint get_svr(void)
+{
+   struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
+
+   return gur_in32(>svr);
+}
+
 #ifdef CONFIG_DISPLAY_CPUINFO
 int print_cpuinfo(void)
 {
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
index e98e055..8b8a7c1 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
@@ -596,4 +596,6 @@ struct ccsr_cci400 {
 #define SCR0_CLIENTPD_MASK 0x0001
 #define SCR0_USFCFG_MASK   0x0400
 
+uint get_svr(void);
+
 #endif /* __ARCH_FSL_LSCH2_IMMAP_H__*/
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
index 65b3357..e48bbaf 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -319,4 +319,7 @@ struct ccsr_reset {
u32 ip_rev1;/* 0xbf8 */
u32 ip_rev2;/* 0xbfc */
 };
+
+uint get_svr(void);
+
 #endif /* __ARCH_FSL_LSCH3_IMMAP_H_ */
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h 
b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index 02ecc62..2cb6c54 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -53,6 +53,8 @@ struct cpu_type {
 #define SVR_MIN(svr)   (((svr) >> 0) & 0xf)
 #define SVR_SOC_VER(svr)   (((svr) >> 8) & SVR_WO_E)
 #define IS_E_PROCESSOR(svr)(!((svr >> 8) & 0x1))
+#define IS_SVR_REV(svr, maj, min) \
+   ((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))
 
 /* ahci port register default value */
 #define AHCI_PORT_PHY_1_CFG0xa003fffe
-- 
2.1.0

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


[U-Boot] [Patch v4 0/5] Supporting ARM v8 USB errata for FSL

2016-06-12 Thread Sriram Dash
The patch-set does the following :

1. Adds support for ARM for USB Erratum Checking code for implementing the
USB Erratum for fsl.
2. Performs code cleanup to reduce redundancy when adding fsl device
tree fixup.
3. Implements Erratum A008751 for LS2 platform.

Sriram Dash (5):
  arm64: fsl-layerscape: add get_svr and IS_SVR_REV helper
  usb: xhci: fsl: code cleanup for device tree fixup for fsl usb
controllers
  fsl: usb: make errata function common for PPC and ARM
  armv8/ls2080: Remove workaround for erratum A008751
  usb: xhci: fsl: Add workaround for USB erratum A-008751

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c|   7 +
 arch/arm/cpu/armv8/fsl-layerscape/soc.c|  10 --
 .../include/asm/arch-fsl-layerscape/immap_lsch2.h  |   2 +
 .../include/asm/arch-fsl-layerscape/immap_lsch3.h  |   4 +
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |   2 +
 board/freescale/ls2080aqds/ls2080aqds.c|   2 +
 board/freescale/ls2080ardb/ls2080ardb.c|   2 +
 drivers/usb/common/Makefile|   4 +-
 drivers/usb/common/fsl-dt-fixup.c  | 100 +++
 .../fsl_usb.h => drivers/usb/common/fsl-errata.c   | 152 
 drivers/usb/host/xhci-fsl.c|  24 +++
 include/fsl_usb.h  | 192 +
 12 files changed, 153 insertions(+), 348 deletions(-)
 copy include/fsl_usb.h => drivers/usb/common/fsl-errata.c (50%)

-- 
2.1.0

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


[U-Boot] [Patch V2 3/3] armv8: ls1043aqds: print FPGA info early for QSPI boot

2016-06-12 Thread Gong Qianyu
Now I2C is initialized early enough to access FPGA so it supports to
show board info as early as other boot methods.

Signed-off-by: Gong Qianyu 
---
 include/configs/ls1043aqds.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/configs/ls1043aqds.h b/include/configs/ls1043aqds.h
index 520b28c..ee8cb23 100644
--- a/include/configs/ls1043aqds.h
+++ b/include/configs/ls1043aqds.h
@@ -10,11 +10,7 @@
 #include "ls1043a_common.h"
 
 #define CONFIG_DISPLAY_CPUINFO
-#ifdef CONFIG_QSPI_BOOT
-#define CONFIG_DISPLAY_BOARDINFO_LATE
-#else
 #define CONFIG_DISPLAY_BOARDINFO
-#endif
 
 #if defined(CONFIG_NAND_BOOT) || defined(CONFIG_SD_BOOT)
 #define CONFIG_SYS_TEXT_BASE   0x8200
-- 
2.1.0.27.g96db324

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


[U-Boot] [PATCH v5 2/2] common: usb_storage : Implement logic to calculate optimal usb maximum trasfer blocks

2016-06-12 Thread Rajesh Bhagat
From: Rajesh Bhagat 

Implements the logic to calculate the optimal usb maximum trasfer blocks
instead of sending USB_MAX_XFER_BLK blocks which is 65535 and 20 in case
of EHCI and other USB protocols respectively.

It defines USB_MIN_XFER_BLK/USB_MAX_XFER_BLK trasfer blocks that should
be checked for success starting from minimum to maximum, and rest of the
read/write are performed with that optimal value. It tries to increase/
decrease the blocks in follwing scenarios:

1.decrease blocks: when read/write for a particular number of blocks
fails.
2. increase blocks: when read/write for a particular number of blocks
pass and amount left to trasfer is greater than current number of
blocks.

Currently changes are done for EHCI where min = 4096 and max = 65535
is taken. And for other cases code is left unchanged by keeping min
= max = 20.

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---
Changes in v5:
 - None

Changes in v4:
 - Adds udev paramater in dec/inc_cur_xfer_blks function and adds
   sanity check on it.
 - Changes type of pos varible to unsigned int in dec/inc_cur_xfer_blks
 - Removes usage of pos varible from usb_stor_read/write

Changes in v3:
 - Adds cur_xfer_blks in struct usb_device to retain values
 - Adds functions dec/inc_cur_xfer_blks to remove code duplication
 - Moves check from macro to calling functions

Changes in v2:
 - Removes table to store blocks and use formula (1 << (12 + n)) - 1
 - Adds logic to start from minimum, go to maximum in each read/write

 common/usb_storage.c |   67 ++---
 include/usb.h|1 +
 2 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/common/usb_storage.c b/common/usb_storage.c
index f060637..9b09412 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -106,11 +106,16 @@ struct us_data {
  * enough free heap space left, but the SCSI READ(10) and WRITE(10) commands 
are
  * limited to 65535 blocks.
  */
+#define USB_MIN_XFER_BLK   4095
 #define USB_MAX_XFER_BLK   65535
 #else
+#define USB_MIN_XFER_BLK   20
 #define USB_MAX_XFER_BLK   20
 #endif
 
+#define GET_CUR_XFER_BLKS(blks)(LOG2((blks + 1) / (USB_MIN_XFER_BLK + 
1)))
+#define CALC_CUR_XFER_BLKS(pos)((1 << (12 + pos)) - 1)
+
 #ifndef CONFIG_BLK
 static struct us_data usb_stor[USB_MAX_STOR_DEV];
 #endif
@@ -141,6 +146,44 @@ static void usb_show_progress(void)
debug(".");
 }
 
+static int dec_cur_xfer_blks(struct usb_device *udev)
+{
+   /* decrease the cur_xfer_blks */
+   unsigned int pos;
+   unsigned short size;
+
+   if (!udev)
+   return -EINVAL;
+
+   pos = GET_CUR_XFER_BLKS(udev->cur_xfer_blks);
+   size  = pos ? CALC_CUR_XFER_BLKS(pos - 1) : 0;
+
+   if (size < USB_MIN_XFER_BLK)
+   return -EINVAL;
+
+   udev->cur_xfer_blks = size;
+   return 0;
+}
+
+static int inc_cur_xfer_blks(struct usb_device *udev, lbaint_t blks)
+{
+   /* try to increase the cur_xfer_blks */
+   unsigned int pos;
+   unsigned short size;
+
+   if (!udev)
+   return -EINVAL;
+
+   pos = GET_CUR_XFER_BLKS(udev->cur_xfer_blks);
+   size = CALC_CUR_XFER_BLKS(pos + 1);
+
+   if (size > blks || size > USB_MAX_XFER_BLK)
+   return -EINVAL;
+
+   udev->cur_xfer_blks = size;
+   return 0;
+}
+
 
/***
  * show info on storage devices; 'usb start/init' must be invoked earlier
  * as we only retrieve structures populated during devices initialization
@@ -1128,6 +1171,7 @@ static unsigned long usb_stor_read_write(struct blk_desc 
*block_dev,
struct usb_device *udev;
struct us_data *ss;
int retry;
+   bool retry_flag = false;
ccb *srb = _ccb;
 #ifdef CONFIG_BLK
struct blk_desc *block_dev;
@@ -1167,26 +1211,36 @@ static unsigned long usb_stor_read_write(struct 
blk_desc *block_dev,
 */
retry = 2;
srb->pdata = (unsigned char *)buf_addr;
-   if (blks > USB_MAX_XFER_BLK)
-   smallblks = USB_MAX_XFER_BLK;
+   if (blks > udev->cur_xfer_blks)
+   smallblks = udev->cur_xfer_blks;
else
smallblks = (unsigned short) blks;
 retry_it:
-   if (smallblks == USB_MAX_XFER_BLK)
+   debug("usb_%s: retry #%d, cur_xfer_blks %hu, smallblks %hu\n",
+ USB_STOR_OP_TYPE, retry, udev->cur_xfer_blks,
+ smallblks);
+   if (smallblks == udev->cur_xfer_blks)
usb_show_progress();
srb->datalen = block_dev->blksz * smallblks;
srb->pdata = (unsigned char *)buf_addr;
if (usb_stor_operation(srb, ss, start, smallblks, is_write)) {
  

[U-Boot] [PATCH v5 1/2] common: usb_storage: Make common function for usb_stor_read/usb_stor_write

2016-06-12 Thread Rajesh Bhagat
Performs code cleanup by making common function for usb_stor_read/
usb_stor_write. Currently only difference in these fucntions is call
to usb_read_10/usb_write_10 scsi commands.

Signed-off-by: Rajesh Bhagat 
---
Changes in v5:
 - Converts USB_STOR_OPERATION_FUNC macro to a function
 - Corrects the multi line comment accroding to coding style
 - Renames variable to dev to remove code duplication

Changes in v4:
 - Adds code to make common function for read/write

 common/usb_storage.c |  129 +++--
 1 files changed, 40 insertions(+), 89 deletions(-)

diff --git a/common/usb_storage.c b/common/usb_storage.c
index 7e6e52d..f060637 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1104,12 +1104,22 @@ static void usb_bin_fixup(struct usb_device_descriptor 
descriptor,
 }
 #endif /* CONFIG_USB_BIN_FIXUP */
 
+#define USB_STOR_OP_TYPE   (is_write ? "write" : "read")
+static int usb_stor_operation(ccb *srb, struct us_data *ss, unsigned long 
start,
+ unsigned short blocks, bool is_write)
+{
+   return is_write ? usb_write_10(srb, ss, start, blocks) :
+   usb_read_10(srb, ss, start, blocks);
+}
+
 #ifdef CONFIG_BLK
-static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr,
-  lbaint_t blkcnt, void *buffer)
+static unsigned long usb_stor_read_write(struct udevice *dev, lbaint_t blknr,
+lbaint_t blkcnt, const void *buffer,
+bool is_write)
 #else
-static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
-  lbaint_t blkcnt, void *buffer)
+static unsigned long usb_stor_read_write(struct blk_desc *block_dev,
+lbaint_t blknr, lbaint_t blkcnt,
+const void *buffer, bool is_write)
 #endif
 {
lbaint_t start, blks;
@@ -1129,9 +1139,9 @@ static unsigned long usb_stor_read(struct blk_desc 
*block_dev, lbaint_t blknr,
 #ifdef CONFIG_BLK
block_dev = dev_get_uclass_platdata(dev);
udev = dev_get_parent_priv(dev_get_parent(dev));
-   debug("\nusb_read: udev %d\n", block_dev->devnum);
+   debug("\nusb_%s: udev %d\n", USB_STOR_OP_TYPE, block_dev->devnum);
 #else
-   debug("\nusb_read: udev %d\n", block_dev->devnum);
+   debug("\nusb_%s: udev %d\n", USB_STOR_OP_TYPE, block_dev->devnum);
udev = usb_dev_desc[block_dev->devnum].priv;
if (!udev) {
debug("%s: No device\n", __func__);
@@ -1146,11 +1156,15 @@ static unsigned long usb_stor_read(struct blk_desc 
*block_dev, lbaint_t blknr,
start = blknr;
blks = blkcnt;
 
-   debug("\nusb_read: dev %d startblk " LBAF ", blccnt " LBAF " buffer %"
- PRIxPTR "\n", block_dev->devnum, start, blks, buf_addr);
+   debug("\nusb_%s: dev %d startblk " LBAF ", blccnt " LBAF " buffer %"
+ PRIxPTR "\n", USB_STOR_OP_TYPE, block_dev->devnum, start, blks,
+ buf_addr);
 
do {
-   /* XXX need some comment here */
+   /*
+* If read/write fails retry for max retry count else
+* return with number of blocks written successfully.
+*/
retry = 2;
srb->pdata = (unsigned char *)buf_addr;
if (blks > USB_MAX_XFER_BLK)
@@ -1162,8 +1176,8 @@ retry_it:
usb_show_progress();
srb->datalen = block_dev->blksz * smallblks;
srb->pdata = (unsigned char *)buf_addr;
-   if (usb_read_10(srb, ss, start, smallblks)) {
-   debug("Read ERROR\n");
+   if (usb_stor_operation(srb, ss, start, smallblks, is_write)) {
+   debug("%s ERROR\n", USB_STOR_OP_TYPE);
usb_request_sense(srb, ss);
if (retry--)
goto retry_it;
@@ -1176,9 +1190,9 @@ retry_it:
} while (blks != 0);
ss->flags &= ~USB_READY;
 
-   debug("usb_read: end startblk " LBAF
+   debug("usb_%s: end startblk " LBAF
  ", blccnt %x buffer %" PRIxPTR "\n",
- start, smallblks, buf_addr);
+ USB_STOR_OP_TYPE, start, smallblks, buf_addr);
 
usb_disable_asynch(0); /* asynch transfer allowed */
if (blkcnt >= USB_MAX_XFER_BLK)
@@ -1186,90 +1200,27 @@ retry_it:
return blkcnt;
 }
 
+
 #ifdef CONFIG_BLK
-static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr,
-   lbaint_t blkcnt, const void *buffer)
+static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr,
+  lbaint_t blkcnt, void *buffer)
 #else
-static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
-   

[U-Boot] [PATCH v5 0/2] common: usb_storage : Implement logic to calculate optimal

2016-06-12 Thread Rajesh Bhagat
Performs code cleanup by making common function for usb_stor_read/write
and implements the logic to calculate the optimal usb maximum trasfer blocks
instead of sending USB_MAX_XFER_BLK blocks which is 65535 and 20 in case
of EHCI and other USB protocols respectively.

Rajesh Bhagat (2):
  common: usb_storage: Make common function for
usb_stor_read/usb_stor_write
  common: usb_storage : Implement logic to calculate optimal usb
maximum trasfer blocks

 common/usb_storage.c |  196 ++
 include/usb.h|1 +
 2 files changed, 103 insertions(+), 94 deletions(-)

-- 
1.7.7.4

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


Re: [U-Boot] [PATCH] net: Allow setenv to set net global variables

2016-06-12 Thread Chris Packham
Hi Joe,

On 06/11/2016 03:56 AM, Joe Hershberger wrote:
> On Thu, Jun 9, 2016 at 8:40 PM, Matthew Bright
>  wrote:
>> The patch fd3056337e6fcc introduces env callbacks to several of the net
>> related env variables. These callbacks are responsible for updating the
>> corresponding global variables internal to the net source code. However
>> this behavior will be skipped if the source of the callbacks originated
>> from setenv. This is based on the assumption that all current instances
>> of setenv are invoked using the same global variables that the callback
>> will eventually write to; therefore there is no need set them to the
>> same value.
>>
>> As setenv is a public interface this assumption may not always hold. In
>> our usage case we implement a user facing menu system for configuration
>> of networking parameters. This ultimately lead to calling setenv rather
>> than through the traditional interactive command line parser do_env_set.
>> Therefore, in our usage case, setenv can be called for an "interactive"
>> case. Consequently, the early return for non-interactive invocation are
>> now removed and any call to setenv will update the corresponding states
>> internal to the net source code as expected.
>>
>> Signed-off-by: Matthew Bright 
>> Reviewed-by: Hamish Martin 
>> Reviewed-by: Chris Packham 
>> ---
>>   net/net.c | 24 
>>   1 file changed, 24 deletions(-)
>>
>> diff --git a/net/net.c b/net/net.c
>> index 1e1d23d..726b0f0 100644
>> --- a/net/net.c
>> +++ b/net/net.c
>> @@ -209,9 +209,6 @@ int __maybe_unused net_busy_flag;
>>   static int on_bootfile(const char *name, const char *value, enum env_op op,
>>  int flags)
>>   {
>> -   if (flags & H_PROGRAMMATIC)
>> -   return 0;
>> -
>
> Why can't you just change your menu to call the API that is
> interactive instead of setenv?

Which API are you referring to? _do_env_set() is static so the only 
public api would be run_command("setenv ipaddr ...") or have I missed 
something?


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


Re: [U-Boot] [PATCH v2 0/5] Urgent fixes for misconverted CONFIG_BOOTDELAY

2016-06-12 Thread Masahiro Yamada
Hi Tom,

2016-06-13 1:50 GMT+09:00 Tom Rini :
> On Sat, Jun 11, 2016 at 06:44:07PM +0900, Masahiro Yamada wrote:
>
>>
>> Masahiro Yamada (5):
>>   ARM: stm32: remove unused CONFIG_AUTOBOOT
>>   autoboot: follow-up cleanup after CONFIG_BOOTDELAY moves
>>   tools: fix define2mk.sed to not add quotes around negative integers
>>   autoboot: fix a bunch of misconversion of CONFIG_BOOTDELAY
>>   autoboot: add CONFIG_AUTOBOOT to allow to not compile autoboot.c
>
> Please put together a PR with everything except the defconfig changes,
> along with the other moveconfig.py related fixes for me and I'll go
> unbreak everything (along with Hans' patch).  Thanks!


Please let me confirm the ones I should include in my PR.

moveconfig patches and these three?

>>   ARM: stm32: remove unused CONFIG_AUTOBOOT
>>   autoboot: follow-up cleanup after CONFIG_BOOTDELAY moves
>>   tools: fix define2mk.sed to not add quotes around negative integers





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


Re: [U-Boot] [PATCH v2 0/5] Urgent fixes for misconverted CONFIG_BOOTDELAY

2016-06-12 Thread Masahiro Yamada
Hi Tom,


2016-06-13 6:07 GMT+09:00 Masahiro Yamada :
> Hi Tom,
>
> 2016-06-13 1:50 GMT+09:00 Tom Rini :
>> On Sat, Jun 11, 2016 at 06:44:07PM +0900, Masahiro Yamada wrote:
>>
>>>
>>> Masahiro Yamada (5):
>>>   ARM: stm32: remove unused CONFIG_AUTOBOOT
>>>   autoboot: follow-up cleanup after CONFIG_BOOTDELAY moves
>>>   tools: fix define2mk.sed to not add quotes around negative integers
>>>   autoboot: fix a bunch of misconversion of CONFIG_BOOTDELAY
>>>   autoboot: add CONFIG_AUTOBOOT to allow to not compile autoboot.c
>>
>> Please put together a PR with everything except the defconfig changes,
>> along with the other moveconfig.py related fixes for me and I'll go
>> unbreak everything (along with Hans' patch).  Thanks!
>
>
> Please let me confirm the ones I should include in my PR.
>
> moveconfig patches and these three?
>
>>>   ARM: stm32: remove unused CONFIG_AUTOBOOT
>>>   autoboot: follow-up cleanup after CONFIG_BOOTDELAY moves
>>>   tools: fix define2mk.sed to not add quotes around negative integers
>

Done.


BTW, would you consider changing the default of BOOTDELAY
from 0 to 3 ?





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


Re: [U-Boot] [PATCH] arm: dra7xx: Assign omap_vcores based on board type

2016-06-12 Thread Keerthy

Hi Tom,

On Tuesday 07 June 2016 04:05 PM, Keerthy wrote:

Currently omap_vcores which holds pmic data is being assigned based
on the SoC type. PMIC is not a part of SoC. It is logical to
to assign omap_vcores based on board type. Hence over ride the
vcores_init function and assign omap_vcores based on the board type.



If there are no comments on this one. Can you please pull this patch?



Reported-by: Nishanth Menon 
Signed-off-by: Keerthy 
---

Boot tested on both dra7-evm and dra72-evm.

  arch/arm/cpu/armv7/omap5/hw_data.c | 78 
  board/ti/dra7xx/evm.c  | 91 ++
  2 files changed, 91 insertions(+), 78 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap5/hw_data.c 
b/arch/arm/cpu/armv7/omap5/hw_data.c
index a517b13..65f43d6 100644
--- a/arch/arm/cpu/armv7/omap5/hw_data.c
+++ b/arch/arm/cpu/armv7/omap5/hw_data.c
@@ -364,82 +364,6 @@ struct vcores_data omap5430_volts_es2 = {
.mm.abb_tx_done_mask = OMAP_ABB_MM_TXDONE_MASK,
  };

-struct vcores_data dra752_volts = {
-   .mpu.value  = VDD_MPU_DRA7,
-   .mpu.efuse.reg  = STD_FUSE_OPP_VMIN_MPU,
-   .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .mpu.addr   = TPS659038_REG_ADDR_SMPS12,
-   .mpu.pmic   = ,
-   .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
-
-   .eve.value  = VDD_EVE_DRA7,
-   .eve.efuse.reg  = STD_FUSE_OPP_VMIN_DSPEVE,
-   .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .eve.addr   = TPS659038_REG_ADDR_SMPS45,
-   .eve.pmic   = ,
-   .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
-
-   .gpu.value  = VDD_GPU_DRA7,
-   .gpu.efuse.reg  = STD_FUSE_OPP_VMIN_GPU,
-   .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .gpu.addr   = TPS659038_REG_ADDR_SMPS6,
-   .gpu.pmic   = ,
-   .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
-
-   .core.value = VDD_CORE_DRA7,
-   .core.efuse.reg = STD_FUSE_OPP_VMIN_CORE,
-   .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .core.addr  = TPS659038_REG_ADDR_SMPS7,
-   .core.pmic  = ,
-
-   .iva.value  = VDD_IVA_DRA7,
-   .iva.efuse.reg  = STD_FUSE_OPP_VMIN_IVA,
-   .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .iva.addr   = TPS659038_REG_ADDR_SMPS8,
-   .iva.pmic   = ,
-   .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
-};
-
-struct vcores_data dra722_volts = {
-   .mpu.value  = VDD_MPU_DRA7,
-   .mpu.efuse.reg  = STD_FUSE_OPP_VMIN_MPU,
-   .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .mpu.addr   = TPS65917_REG_ADDR_SMPS1,
-   .mpu.pmic   = ,
-   .mpu.abb_tx_done_mask = OMAP_ABB_MPU_TXDONE_MASK,
-
-   .core.value = VDD_CORE_DRA7,
-   .core.efuse.reg = STD_FUSE_OPP_VMIN_CORE,
-   .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .core.addr  = TPS65917_REG_ADDR_SMPS2,
-   .core.pmic  = ,
-
-   /*
-* The DSPEVE, GPU and IVA rails are usually grouped on DRA72x
-* designs and powered by TPS65917 SMPS3, as on the J6Eco EVM.
-*/
-   .gpu.value  = VDD_GPU_DRA7,
-   .gpu.efuse.reg  = STD_FUSE_OPP_VMIN_GPU,
-   .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .gpu.addr   = TPS65917_REG_ADDR_SMPS3,
-   .gpu.pmic   = ,
-   .gpu.abb_tx_done_mask = OMAP_ABB_GPU_TXDONE_MASK,
-
-   .eve.value  = VDD_EVE_DRA7,
-   .eve.efuse.reg  = STD_FUSE_OPP_VMIN_DSPEVE,
-   .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .eve.addr   = TPS65917_REG_ADDR_SMPS3,
-   .eve.pmic   = ,
-   .eve.abb_tx_done_mask = OMAP_ABB_EVE_TXDONE_MASK,
-
-   .iva.value  = VDD_IVA_DRA7,
-   .iva.efuse.reg  = STD_FUSE_OPP_VMIN_IVA,
-   .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-   .iva.addr   = TPS65917_REG_ADDR_SMPS3,
-   .iva.pmic   = ,
-   .iva.abb_tx_done_mask = OMAP_ABB_IVA_TXDONE_MASK,
-};
-
  /*
   * Enable essential clock domains, modules and
   * do some additional special settings needed
@@ -804,7 +728,6 @@ void __weak hw_data_init(void)
case DRA752_ES2_0:
*prcm = _prcm;
*dplls_data = _dplls;
-   *omap_vcores = _volts;
*ctrl = _ctrl;
break;

@@ -812,7 +735,6 @@ void __weak hw_data_init(void)
case DRA722_ES2_0:
*prcm = _prcm;
*dplls_data = _dplls;
-   *omap_vcores = _volts;
*ctrl = _ctrl;
break;

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 8c916a3..c5f7190 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -310,6 +310,82 @@ void emif_get_dmm_regs(const struct dmm_lisa_map_regs 
**dmm_lisa_regs)
}
  }

+struct vcores_data dra752_volts = {
+   .mpu.value  = VDD_MPU_DRA7,
+   .mpu.efuse.reg  = STD_FUSE_OPP_VMIN_MPU,
+   .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
+   .mpu.addr   = 

[U-Boot] [Patch V2 2/3] armv8: ls1043aqds: use configuarable clock

2016-06-12 Thread Gong Qianyu
Get the clocks from FPGA through IFC or I2C. So it needs I2C early init
if booting with IFC disabled.

Signed-off-by: Gong Qianyu 
---
 board/freescale/ls1043aqds/ls1043aqds.c | 4 
 include/configs/ls1043aqds.h| 5 +++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/board/freescale/ls1043aqds/ls1043aqds.c 
b/board/freescale/ls1043aqds/ls1043aqds.c
index 9447c93..b7e9c21 100644
--- a/board/freescale/ls1043aqds/ls1043aqds.c
+++ b/board/freescale/ls1043aqds/ls1043aqds.c
@@ -230,6 +230,10 @@ int board_early_init_f(void)
 #ifdef CONFIG_LPUART
u8 uart;
 #endif
+
+#ifdef CONFIG_SYS_I2C_EARLY_INIT
+   i2c_early_init_f();
+#endif
fsl_lsch2_early_init_f();
 
 #ifdef CONFIG_HAS_FSL_XHCI_USB
diff --git a/include/configs/ls1043aqds.h b/include/configs/ls1043aqds.h
index a19eaee..520b28c 100644
--- a/include/configs/ls1043aqds.h
+++ b/include/configs/ls1043aqds.h
@@ -29,8 +29,8 @@ unsigned long get_board_sys_clk(void);
 unsigned long get_board_ddr_clk(void);
 #endif
 
-#define CONFIG_SYS_CLK_FREQ1
-#define CONFIG_DDR_CLK_FREQ1
+#define CONFIG_SYS_CLK_FREQget_board_sys_clk()
+#define CONFIG_DDR_CLK_FREQget_board_ddr_clk()
 
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
@@ -225,6 +225,7 @@ unsigned long get_board_ddr_clk(void);
 
 #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_SD_BOOT_QSPI)
 #define CONFIG_QIXIS_I2C_ACCESS
+#define CONFIG_SYS_I2C_EARLY_INIT
 #define CONFIG_SYS_NO_FLASH
 #endif
 
-- 
2.1.0.27.g96db324

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


[U-Boot] [Patch V2 1/3] armv8: ls1043aqds: fix to get boot device info from FPGA

2016-06-12 Thread Gong Qianyu
The LBMAP switches on the board will tell which boot device is used.
Only QSPI boot is supported if the boot device is IFCCard.

Signed-off-by: Gong Qianyu 
---
 board/freescale/ls1043aqds/ls1043aqds.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/board/freescale/ls1043aqds/ls1043aqds.c 
b/board/freescale/ls1043aqds/ls1043aqds.c
index 7e47ef0..9447c93 100644
--- a/board/freescale/ls1043aqds/ls1043aqds.c
+++ b/board/freescale/ls1043aqds/ls1043aqds.c
@@ -47,7 +47,7 @@ enum {
 int checkboard(void)
 {
char buf[64];
-#if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT)
+#ifndef CONFIG_SD_BOOT
u8 sw;
 #endif
 
@@ -55,8 +55,6 @@ int checkboard(void)
 
 #ifdef CONFIG_SD_BOOT
puts("SD\n");
-#elif defined(CONFIG_QSPI_BOOT)
-   puts("QSPI\n");
 #else
sw = QIXIS_READ(brdcfg[0]);
sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
@@ -67,8 +65,8 @@ int checkboard(void)
puts("PromJet\n");
else if (sw == 0x9)
puts("NAND\n");
-   else if (sw == 0x15)
-   printf("IFCCard\n");
+   else if (sw == 0xF)
+   printf("QSPI\n");
else
printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
 #endif
-- 
2.1.0.27.g96db324

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


Re: [U-Boot] [PATCH v3 11/11] sunxi: Add PSCI implementation in C

2016-06-12 Thread Chen-Yu Tsai
On Fri, Jun 10, 2016 at 9:40 PM, Hans de Goede  wrote:
> Hi,
>
> On 07-06-16 04:54, Chen-Yu Tsai wrote:
>>
>> To make the PSCI backend more maintainable and easier to port to newer
>> SoCs, rewrite the current PSCI implementation in C.
>>
>> Some inline assembly bits are required to access coprocessor registers.
>> PSCI stack setup is the only part left completely in assembly. In theory
>> this part could be split out of psci_arch_init into a separate common
>> function, and psci_arch_init could be completely in C.
>>
>> Signed-off-by: Chen-Yu Tsai 
>
>
> I tried merging this in my tree to add it to u-boot-sunxi/next, but
> unfortunately it triggers a bug in gcc-6.1, I've filed a bug with
> gcc to get this fixed:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1344717

Interesting. Seems like the compiler should be emitting LDMFD instead
of POP, or a POP followed by a SUBS/MOVS.

>
> Also cp15_read_scr / cp15_write_scr are missing __secure notations.

Do you want me to send a new version for this?

ChenYu

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


  1   2   >