All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsl-ifc: set extended addressing for systems whose bootloader doesn't
@ 2016-10-05  3:22 David Singleton
  0 siblings, 0 replies; 3+ messages in thread
From: David Singleton @ 2016-10-05  3:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: xe-kernel, linux-kernel

For 32bit systems whose bootloader doesn't set the extended 36-bit
addressing register for flash devices above the 4GB boundary
we can set up in the driver.

This patch checks the number of address-cells in the dts file
for the fsl-ifc flash controller.  If #address-cells is 2 then
it's a 36-bit address mapping, so set the extended address register
in the ccsr for the upper 0xf address, as specified in the dts file.

The code only sets the extended addressing register if the
dts defines 36-bit addressing for the flash devices AND
the register was not set by the boot loader.

If the bootloader has set the extended addressing register
the code does not update the register.

Cc: xe-kernel@external.cisco.com
Signed-off-by: David Singleton <davsingl@cisco.com>
---
 drivers/memory/fsl_ifc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index 1b182b1..a73b050 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -78,6 +78,31 @@ EXPORT_SYMBOL(fsl_ifc_find);
 static int fsl_ifc_ctrl_init(struct fsl_ifc_ctrl *ctrl)
 {
 	struct fsl_ifc_global __iomem *ifc = ctrl->gregs;
+	np = of_find_compatible_node(NULL, NULL, "fsl,ifc");
+	if (np) {
+		const u32 *prop;
+
+		prop = of_get_property(np, "#address-cells", NULL);
+		if (prop) {
+			u32 cells;
+			/*
+			 * #address-cells 2 means 36-bit addresses are used
+			 * and the if cspr_ext register is zero, the
+			 * bootloader didn't set it, we'll set it manually
+			 */
+			cells = of_n_addr_cells(np);
+			if ((cells == 2) && !(ifc_in32(&ifc->cspr_cs[0].cspr_ext))) {
+				prop = of_get_property(np, "reg", NULL);
+				if (prop) {
+					u32 extaddr;
+
+					extaddr = *prop; /* get the top nibble for 36-bit */
+					pr_info("fsl-ifc extended 36-bit addressing\n");
+					ifc_out32(extaddr, &ifc->cspr_cs[0].cspr_ext);
+				}
+			}
+		}
+	}
 
 	/*
 	 * Clear all the common status and event registers
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] fsl-ifc: set extended addressing for systems whose bootloader doesn't
@ 2016-10-10 20:56 David Singleton
  2016-10-17 21:27 ` Scott Wood
  0 siblings, 1 reply; 3+ messages in thread
From: David Singleton @ 2016-10-10 20:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: xe-kernel, scottwood, linux-kernel

For 32bit systems whose bootloader doesn't set the extended 36-bit
addressing register for flash devices above the 4GB boundary
we can set up in the driver.

This patch checks the number of address-cells in the dts file
for the fsl-ifc flash controller.  If #address-cells is 2 then
it's a 36-bit address mapping, so set the extended address register
in the ccsr for the upper 0xf address, as specified in the dts file.

The code only sets the extended addressing register if the
dts defines 36-bit addressing for the flash devices AND
the register was not set by the boot loader.

If the bootloader has set the extended addressing register
the code does not update the register.

Cc: xe-kernel@external.cisco.com
Cc: scottwood@freescale.com
Signed-off-by: David Singleton <davsingl@cisco.com>
---
 drivers/memory/fsl_ifc.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index 1b182b1..3d7a52e 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -78,6 +78,41 @@ EXPORT_SYMBOL(fsl_ifc_find);
 static int fsl_ifc_ctrl_init(struct fsl_ifc_ctrl *ctrl)
 {
 	struct fsl_ifc_global __iomem *ifc = ctrl->gregs;
+	struct device_node *np;
+
+	/*
+	 * enable extended 36-bit addressing
+	 * 24.3.2 Extended Chip Select Property registers (IFC_CSPRn_EXT)
+	 * The extended chip select property register (CSPRn_EXT) contains
+	 * the extended base address, that is, the most significant
+	 * bits (msb) of the base address.
+	 * Set it here for systems where the bootloader doesn't.
+	 */
+	np = of_find_compatible_node(NULL, NULL, "fsl,ifc");
+	if (np) {
+		const u32 *prop;
+
+		prop = of_get_property(np, "#address-cells", NULL);
+		if (prop) {
+			u32 cells;
+			/*
+			 * #address-cells 2 means 36-bit addresses are used
+			 * and the if cspr_ext register is zero, the
+			 * bootloader didn't set it, we'll set it manually
+			 */
+			cells = of_n_addr_cells(np);
+			if ((cells == 2) && !(ifc_in32(&ifc->cspr_cs[0].cspr_ext))) {
+				prop = of_get_property(np, "reg", NULL);
+				if (prop) {
+					u32 extaddr;
+
+					extaddr = *prop; /* get the top nibble for 36-bit */
+					pr_info("fsl-ifc extended 36-bit addressing\n");
+					ifc_out32(extaddr, &ifc->cspr_cs[0].cspr_ext);
+				}
+			}
+		}
+	}
 
 	/*
 	 * Clear all the common status and event registers
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-17 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05  3:22 [PATCH] fsl-ifc: set extended addressing for systems whose bootloader doesn't David Singleton
2016-10-10 20:56 David Singleton
2016-10-17 21:27 ` Scott Wood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.