[U-Boot] [PATCH 0/3] 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 patch of this series is a generic one. It changes the regmap initialization to take in account the required address translation.
The second 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.
Jean-Jacques Hiblot (3): 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 | 2 ++ configs/am57xx_hs_evm_defconfig | 2 ++ configs/dra7xx_evm_defconfig | 2 ++ configs/dra7xx_hs_evm_defconfig | 2 ++ drivers/core/regmap.c | 14 ++++++------ drivers/spi/ti_qspi.c | 47 ++++++++++++++++++++++++++++++++++++----- 6 files changed, 58 insertions(+), 11 deletions(-)

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 c68bcba..07a6614 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->parent->of_offset; 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;

+Stephen
On 7 February 2017 at 08:45, 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(-)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index c68bcba..07a6614 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->parent->of_offset; 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;
-- 1.9.1

On 02/10/2017 09:22 AM, Simon Glass wrote:
+Stephen
On 7 February 2017 at 08:45, 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(-)
Reviewed-by: Simon Glass sjg@chromium.org
Reviewed-by: Stephen Warren swarren@nvidia.com

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 CONFIG_SYSCON is no set, 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 6f9f983..d964b50 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 defined(CONFIG_SYSCON) && !defined(CONFIG_SPL_BUILD) + 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 = bus->of_offset; - 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 7 February 2017 at 08:45, 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 CONFIG_SYSCON is no set, 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(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Tuesday 07 February 2017 09:15 PM, Jean-Jacques Hiblot 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 CONFIG_SYSCON is no set, 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 6f9f983..d964b50 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 defined(CONFIG_SYSCON) && !defined(CONFIG_SPL_BUILD)
Please change this to #if CONFIG_IS_ENABLED(SYSCON)

This is required by the ti_qspi driver to get from the DTS the address of the ctrl_mod_mmap register.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com --- configs/am57xx_evm_defconfig | 2 ++ configs/am57xx_hs_evm_defconfig | 2 ++ configs/dra7xx_evm_defconfig | 2 ++ configs/dra7xx_hs_evm_defconfig | 2 ++ 4 files changed, 8 insertions(+)
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index a582055..15bb474 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -50,6 +50,8 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="am57xx-beagle-x15 am57xx-beagle-x15-revb1 am572x-idk am571x-idk" CONFIG_DM=y +CONFIG_REGMAP=y +CONFIG_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 4dcfce4..fc37b58 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -52,6 +52,8 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_DM=y +CONFIG_REGMAP=y +CONFIG_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 64fe038..624cfe4 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -50,6 +50,8 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm" CONFIG_DM=y +CONFIG_REGMAP=y +CONFIG_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 b890a06..028b212 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -55,6 +55,8 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm" CONFIG_DM=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y

On 7 February 2017 at 08:45, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
This is required by the ti_qspi driver to get from the DTS the address of the ctrl_mod_mmap register.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
configs/am57xx_evm_defconfig | 2 ++ configs/am57xx_hs_evm_defconfig | 2 ++ configs/dra7xx_evm_defconfig | 2 ++ configs/dra7xx_hs_evm_defconfig | 2 ++ 4 files changed, 8 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

Hi,
On 10 February 2017 at 09:22, Simon Glass sjg@chromium.org wrote:
On 7 February 2017 at 08:45, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
This is required by the ti_qspi driver to get from the DTS the address of the ctrl_mod_mmap register.
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
configs/am57xx_evm_defconfig | 2 ++ configs/am57xx_hs_evm_defconfig | 2 ++ configs/dra7xx_evm_defconfig | 2 ++ configs/dra7xx_hs_evm_defconfig | 2 ++ 4 files changed, 8 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
This doesn't apply, and given that patch 1 has been dropped in favour of something else, would you mind checking this and resending what you need to on top of dm/testing?
Regards, Simon

On Tuesday 07 February 2017 09:15 PM, Jean-Jacques Hiblot wrote:
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 patch of this series is a generic one. It changes the regmap initialization to take in account the required address translation.
The second 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.
Jean-Jacques Hiblot (3): 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
Could you rebase this series on top of Lokesh's series enabling support for SPL_DM][1][2]. The changes that you need to do to this patch series is minimum and restricted to defconfig files:
diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index a52acc51d365..591c64dc7453 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -60,7 +60,9 @@ 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 @@ -103,3 +105,5 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0451 CONFIG_G_DNL_PRODUCT_NUM=0xd022 +CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_SPL_OF_TRANSLATE=y
[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
-- Regards Vignesh
participants (4)
-
Jean-Jacques Hiblot
-
Simon Glass
-
Stephen Warren
-
Vignesh R