[U-Boot] [PATCH v2 0/4] driver: ti_qspi: Use a SYSCON device to map the ctrl_mod_mmap register

This series allows the ti_qspi driver to use the same dts description as the linux kernel. In Linux since 4.6 the ctrl_mod_mmap is described in the DTS as a syscon. It used to be the 3rd memory range in "reg".
The first two patches of this series are generic ones: * Allow the SPL version of fdtdec_get_addr_size_fixed() to perform address translation * change the regmap initialization to take in account the required address translation by using fdtdec_get_addr_size_fixed().
The third patch adds the mechanism in the ti_qspi driver to get the address of ctrl_mod_mmap from the syscon
The last patch simply enable the SYSCON feature in the default config for the dra7xx and am57xx evms.
changes since v1: * rebased on top of Lokesh's series enabling support for SPL_DM][1][2] * Added a patch to enable address translation in fdtdec_get_addr_size_fixed() * use CONFIG_IS_ENABLED(XXX) instead of CONFIG_XXX and CONFIG_SPL_XXX to simplify the conditional code.
[1] https://www.mail-archive.com/u-boot@lists.denx.de/msg238751.html [2] https://www.mail-archive.com/u-boot@lists.denx.de/msg238964.html
Jean-Jacques Hiblot (4): libfdt: Allow the SPL to perform fdt address translation regmap: use fdt address translation drivers: ti_qspi: use syscon to get the address ctrl_mod_mmap register configs: dra7x/am57x: Enable the SYSCON and REGMAP features
configs/am57xx_evm_defconfig | 6 ++++++ configs/am57xx_hs_evm_defconfig | 6 ++++++ configs/dra7xx_evm_defconfig | 6 ++++++ configs/dra7xx_hs_evm_defconfig | 6 ++++++ drivers/core/regmap.c | 14 ++++++------ drivers/spi/ti_qspi.c | 47 ++++++++++++++++++++++++++++++++++++----- lib/fdtdec.c | 2 +- 7 files changed, 75 insertions(+), 12 deletions(-)

Use OF_TRANSLATE for both u-boot and SPL to tell whether fdt address translation should be used.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
to: sjg@chromium.org
lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 81f47ef..1edfbf2 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -112,7 +112,7 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, return FDT_ADDR_T_NONE; }
-#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT) +#if CONFIG_IS_ENABLED(OF_TRANSLATE) if (translate) addr = fdt_translate_address(blob, node, prop_addr); else

On 2/13/2017 8:47 PM, Jean-Jacques Hiblot wrote:
Use OF_TRANSLATE for both u-boot and SPL to tell whether fdt address translation should be used.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Vignesh has posted a similar patch[1].
[1]http://patchwork.ozlabs.org/patch/727131/
Thanks and regards, Lokesh
to: sjg@chromium.org
lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 81f47ef..1edfbf2 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -112,7 +112,7 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, return FDT_ADDR_T_NONE; }
-#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT) +#if CONFIG_IS_ENABLED(OF_TRANSLATE) if (translate) addr = fdt_translate_address(blob, node, prop_addr); else

On 13/02/2017 16:41, Lokesh Vutla wrote:
On 2/13/2017 8:47 PM, Jean-Jacques Hiblot wrote:
Use OF_TRANSLATE for both u-boot and SPL to tell whether fdt address translation should be used.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Vignesh has posted a similar patch[1].
Sorry, I had missed this one. Please ignore this patch.
[1]http://patchwork.ozlabs.org/patch/727131/
Thanks and regards, Lokesh
to: sjg@chromium.org
lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 81f47ef..1edfbf2 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -112,7 +112,7 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, return FDT_ADDR_T_NONE; }
-#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT) +#if CONFIG_IS_ENABLED(OF_TRANSLATE) if (translate) addr = fdt_translate_address(blob, node, prop_addr); else

In the DTS, the addresses are defined relative to the parent bus. We need to translate them to get the address as seen by the CPU core.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com ---
to: sjg@chromium.org
drivers/core/regmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 833cd78..3bec3df 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -70,6 +70,7 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp) int addr_len, size_len, both_len; int parent; int len; + int index;
parent = dev_of_offset(dev->parent); addr_len = fdt_address_cells(blob, parent); @@ -86,13 +87,14 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp) if (!map) return -ENOMEM;
- map->base = fdtdec_get_number(cell, addr_len); - - for (range = map->range; count > 0; - count--, cell += both_len, range++) { - range->start = fdtdec_get_number(cell, addr_len); - range->size = fdtdec_get_number(cell + addr_len, size_len); + for (range = map->range, index = 0; count > 0; + count--, cell += both_len, range++, index++) { + fdt_size_t sz; + range->start = fdtdec_get_addr_size_fixed(blob, dev->of_offset, + "reg", index, addr_len, size_len, &sz, true); + range->size = sz; } + map->base = map->range[0].start;
*mapp = map;

Hi,
On 13 February 2017 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
In the DTS, the addresses are defined relative to the parent bus. We need to translate them to get the address as seen by the CPU core.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
to: sjg@chromium.org
drivers/core/regmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
This says v2 but I don't see a change log. Can you please resend this?
Regards, Simon

On 14/02/2017 06:23, Simon Glass wrote:
Hi,
On 13 February 2017 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
In the DTS, the addresses are defined relative to the parent bus. We need to translate them to get the address as seen by the CPU core.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
to: sjg@chromium.org
drivers/core/regmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
This says v2 but I don't see a change log. Can you please resend this?
Hi Simon,
Sorry, I didn't think about sending the whole series to you. The series is marked v2 but this particular patch that you and stephen warren have already reviewed hasn't changed a bit.
Jean-Jacques
Regards, Simon

On 14 February 2017 at 03:20, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
On 14/02/2017 06:23, Simon Glass wrote:
Hi,
On 13 February 2017 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
In the DTS, the addresses are defined relative to the parent bus. We need to translate them to get the address as seen by the CPU core.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
to: sjg@chromium.org
drivers/core/regmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
This says v2 but I don't see a change log. Can you please resend this?
Hi Simon,
Sorry, I didn't think about sending the whole series to you. The series is marked v2 but this particular patch that you and stephen warren have already reviewed hasn't changed a bit.
Jean-Jacques
OK thanks. It's good to have 'v2: no changes' in the patch for this sort of situation. E.g. patman will do this for you.
Regards, Simon

On 16 February 2017 at 13:43, Simon Glass sjg@chromium.org wrote:
On 14 February 2017 at 03:20, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
On 14/02/2017 06:23, Simon Glass wrote:
Hi,
On 13 February 2017 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
In the DTS, the addresses are defined relative to the parent bus. We need to translate them to get the address as seen by the CPU core.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
to: sjg@chromium.org
drivers/core/regmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
This says v2 but I don't see a change log. Can you please resend this?
Hi Simon,
Sorry, I didn't think about sending the whole series to you. The series is marked v2 but this particular patch that you and stephen warren have already reviewed hasn't changed a bit.
Jean-Jacques
OK thanks. It's good to have 'v2: no changes' in the patch for this sort of situation. E.g. patman will do this for you.
Regards, Simon
Applied to u-boot-dm, thanks!
You mention above some review tags but I don't see them in this patch. I think you may have forgotten to add then to you v2, along with the change log?
- Simon

On 17/03/2017 17:20, Simon Glass wrote:
On 16 February 2017 at 13:43, Simon Glass sjg@chromium.org wrote:
On 14 February 2017 at 03:20, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
On 14/02/2017 06:23, Simon Glass wrote:
Hi,
On 13 February 2017 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
In the DTS, the addresses are defined relative to the parent bus. We need to translate them to get the address as seen by the CPU core.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
to: sjg@chromium.org
drivers/core/regmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
This says v2 but I don't see a change log. Can you please resend this?
Hi Simon,
Sorry, I didn't think about sending the whole series to you. The series is marked v2 but this particular patch that you and stephen warren have already reviewed hasn't changed a bit.
Jean-Jacques
OK thanks. It's good to have 'v2: no changes' in the patch for this sort of situation. E.g. patman will do this for you.
Regards, Simon
Applied to u-boot-dm, thanks!
You mention above some review tags but I don't see them in this patch. I think you may have forgotten to add then to you v2, along with the change log?
Yes I forgot to add the reviewed-by tags. Thanks for pulling it in
- Simon

We used to get the address of the optionnal ctrl_mod_mmap register as the third memory range of the "reg" property. the linux driver moved to use a syscon instead. In order to keep the DTS as close as possible to that of linux, we move to using a syscon as well.
If SYSCON is not supported, the driver reverts to the old way of getting the address from the 3rd memory range
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com --- drivers/spi/ti_qspi.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c index 79955d7..3c4c9dd 100644 --- a/drivers/spi/ti_qspi.c +++ b/drivers/spi/ti_qspi.c @@ -17,6 +17,8 @@ #include <asm/omap_common.h> #include <asm/ti-common/ti-edma3.h> #include <linux/kernel.h> +#include <regmap.h> +#include <syscon.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -549,21 +551,56 @@ static int ti_qspi_probe(struct udevice *bus) return 0; }
+static void *map_syscon_chipselects(struct udevice *bus) +{ +#if CONFIG_IS_ENABLED(SYSCON) + struct udevice *syscon; + struct regmap *regmap; + const fdt32_t *cell; + int len, err; + + err = uclass_get_device_by_phandle(UCLASS_SYSCON, bus, + "syscon-chipselects", &syscon); + if (err) { + debug("%s: unable to find syscon device (%d)\n", __func__, + err); + return NULL; + } + + regmap = syscon_get_regmap(syscon); + if (IS_ERR(regmap)) { + debug("%s: unable to find regmap (%ld)\n", __func__, + PTR_ERR(regmap)); + return NULL; + } + + cell = fdt_getprop(gd->fdt_blob, bus->of_offset, "syscon-chipselects", + &len); + if (len < 2*sizeof(fdt32_t)) { + debug("%s: offset not available\n", __func__); + return NULL; + } + + return fdtdec_get_number(cell + 1, 1) + regmap_get_range(regmap, 0); +#else + fdt_addr_t addr; + addr = dev_get_addr_index(bus, 2); + return (addr == FDT_ADDR_T_NONE) ? NULL : + map_physmem(addr, 0, MAP_NOCACHE); +#endif +} + static int ti_qspi_ofdata_to_platdata(struct udevice *bus) { struct ti_qspi_priv *priv = dev_get_priv(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - fdt_addr_t addr; - void *mmap;
+ priv->ctrl_mod_mmap = map_syscon_chipselects(bus); priv->base = map_physmem(dev_get_addr(bus), sizeof(struct ti_qspi_regs), MAP_NOCACHE); priv->memory_map = map_physmem(dev_get_addr_index(bus, 1), 0, MAP_NOCACHE); - addr = dev_get_addr_index(bus, 2); - mmap = map_physmem(dev_get_addr_index(bus, 2), 0, MAP_NOCACHE); - priv->ctrl_mod_mmap = (addr == FDT_ADDR_T_NONE) ? NULL : mmap;
priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1); if (priv->max_hz < 0) {

On 13 February 2017 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
We used to get the address of the optionnal ctrl_mod_mmap register as the third memory range of the "reg" property. the linux driver moved to use a syscon instead. In order to keep the DTS as close as possible to that of linux, we move to using a syscon as well.
If SYSCON is not supported, the driver reverts to the old way of getting the address from the 3rd memory range
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
drivers/spi/ti_qspi.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-)
Applied to u-boot-dm, thanks!

This is required by the ti_qspi driver to get from the DTS the address of the ctrl_mod_mmap register in SPL and in u-boot.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com --- configs/am57xx_evm_defconfig | 6 ++++++ configs/am57xx_hs_evm_defconfig | 6 ++++++ configs/dra7xx_evm_defconfig | 6 ++++++ configs/dra7xx_hs_evm_defconfig | 6 ++++++ 4 files changed, 24 insertions(+)
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index d9648d8..ca20e18 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -56,9 +56,15 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_ISO_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_OF_LIST="am57xx-beagle-x15 am57xx-beagle-x15-revb1 am572x-idk am571x-idk" CONFIG_DM=y CONFIG_SPL_DM=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index a0abf34..a907008 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -59,8 +59,14 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_ISO_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_DM=y CONFIG_SPL_DM=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index 42f87b3..968b8cf 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -56,9 +56,15 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_ISO_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm" CONFIG_DM=y CONFIG_SPL_DM=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig index 12f2c3a..0775183 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -60,9 +60,15 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_ISO_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_SPL_OF_TRANSLATE=y +CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm" CONFIG_DM=y CONFIG_SPL_DM=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y

On Monday 13 February 2017 08:47 PM, Jean-Jacques Hiblot wrote:
This is required by the ti_qspi driver to get from the DTS the address of the ctrl_mod_mmap register in SPL and in u-boot.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Tested-by: Lokesh Vutla lokeshvutla@ti.com
Thanks and regards, Lokesh
participants (3)
-
Jean-Jacques Hiblot
-
Lokesh Vutla
-
Simon Glass