[U-Boot] [RFC][PATCH V0 6/7] drivers: nand: brcmnand: add parameter parameter-page-big-endian

Philippe Reynes philippe.reynes at softathome.com
Fri Nov 16 13:57:03 UTC 2018


The parameter page isn't always in big endian, so we add
an option to choose the endiannes of the parameter page.

Signed-off-by: Philippe Reynes <philippe.reynes at softathome.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 5a53cb9..b156642 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -113,6 +113,7 @@ struct brcmnand_controller {
 	unsigned int		irq;
 	unsigned int		dma_irq;
 	int			nand_version;
+	int			parameter_page_big_endian;
 
 	/* Some SoCs provide custom interrupt status register(s) */
 	struct brcmnand_soc	*soc;
@@ -1446,7 +1447,10 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
 			 * Flash cache is big endian for parameter pages, at
 			 * least on STB SoCs
 			 */
-			flash_cache[i] = be32_to_cpu(brcmnand_read_fc(ctrl, i));
+			if (ctrl->parameter_page_big_endian)
+				flash_cache[i] = be32_to_cpu(brcmnand_read_fc(ctrl, i));
+			else
+				flash_cache[i] = le32_to_cpu(brcmnand_read_fc(ctrl, i));
 
 		brcmnand_soc_data_bus_unprepare(ctrl->soc, true);
 
@@ -2554,6 +2558,9 @@ int brcmnand_probe(struct udevice *dev, struct brcmnand_soc *soc)
 	nand_hw_control_init(&ctrl->controller);
 	INIT_LIST_HEAD(&ctrl->host_list);
 
+	/* Is parameter page in big endian ? */
+	ctrl->parameter_page_big_endian = dev_read_u32_default(dev, "parameter-page-big-endian", 1);
+
 	/* NAND register range */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	ctrl->nand_base = devm_ioremap_resource(dev, res);
-- 
2.7.4



More information about the U-Boot mailing list