Skip to contentSkip to conversation

Add LS1043A platform support

PATCH Superseded Gong Qianyu 2 participants 18 messages Sep 25, 2015

Subsystems (7)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add LS1043A platform support

[Patch V3 01/16] armv7/ls1021a: move ns_access to common file [Patch V3 02/16] common/board_f.c: modify the macro to use [Patch V3 03/16] net/fm: Fix the endian issue to support both [Patch V3 04/16] net/fm/eth: Use mb() to be compatible for both ARM [Patch V3 05/16] net/fm: Add support for 64-bit platforms [Patch V3 06/16] net/fm: Make the return value logic consistent with [Patch V3 07/16] net/fm: bug fix when CONFIG_PHYLIB not defined [Patch V3 08/16] net: Move some header files to include/ [Patch V3 09/16] net/fm: Add QSGMII PCS init
[Patch V3 10/16] net/fm: fix MDIO controller base on FMAN2 [Patch V3 11/16] ARMv8/FSL_LSCH2: Add FSL_LSCH2 SoC [Patch V3 12/16] armv8/ls1043ardb: Add LS1043ARDB board support [Patch V3 13/16] armv8/ls1043ardb: Add nand boot support [Patch V3 14/16] armv8/ls1043a: Add Fman support
[Patch V3 15/16] armv8/ls1043ardb: esdhc: Add esdhc support for [Patch V3 16/16] armv8/ls1043ardb: Add sd boot support

#1 lore raw

PATCH v3 1/16 armv7/ls1021a: move ns_access to common file

From: Mingkai Hu <[email protected]>

Config Security Level Register is different between different SoCs, so put the CSL register definition into the arch specific directory.

---
 arch/arm/include/asm/arch-ls102xa/ns_access.h | 103 ++++++++++++++++++++------
 board/freescale/common/Makefile               |   2 +-
 board/freescale/common/ns_access.c            |   8 +-
 board/freescale/ls1021aqds/ls1021aqds.c       | 101 ++-----------------------
 board/freescale/ls1021atwr/ls1021atwr.c       |  92 +----------------------
 include/configs/ls1021aqds.h                  |   2 +-
 include/configs/ls1021atwr.h                  |   2 +-
 include/fsl_csu.h                             |  34 +++++++++
 8 files changed, 136 insertions(+), 208 deletions(-)
arch/arm/include/asm/arch-ls102xa/ns_access.h +82 -21
index b53f699..a921fb6 100644
@@ -7,22 +7,6 @@
 #ifndef __FSL_NS_ACCESS_H_
 #define __FSL_NS_ACCESS_H_
 
-enum csu_cslx_access {
-	CSU_NS_SUP_R = 0x08,
-	CSU_NS_SUP_W = 0x80,
-	CSU_NS_SUP_RW = 0x88,
-	CSU_NS_USER_R = 0x04,
-	CSU_NS_USER_W = 0x40,
-	CSU_NS_USER_RW = 0x44,
-	CSU_S_SUP_R = 0x02,
-	CSU_S_SUP_W = 0x20,
-	CSU_S_SUP_RW = 0x22,
-	CSU_S_USER_R = 0x01,
-	CSU_S_USER_W = 0x10,
-	CSU_S_USER_RW = 0x11,
-	CSU_ALL_RW = 0xff,
-};
-
 enum csu_cslx_ind {
 	CSU_CSLX_PCIE2_IO = 0,
 	CSU_CSLX_PCIE1_IO,
@@ -108,11 +92,88 @@ enum csu_cslx_ind {
 	CSU_CSLX_MAX,
 };
 
-struct csu_ns_dev {
-	unsigned long ind;
-	uint32_t val;
+static struct csu_ns_dev ns_dev[] = {
+	{ CSU_CSLX_PCIE2_IO, CSU_ALL_RW },
+	{ CSU_CSLX_PCIE1_IO, CSU_ALL_RW },
+	{ CSU_CSLX_MG2TPR_IP, CSU_ALL_RW },
+	{ CSU_CSLX_IFC_MEM, CSU_ALL_RW },
+	{ CSU_CSLX_OCRAM, CSU_ALL_RW },
+	{ CSU_CSLX_GIC, CSU_ALL_RW },
+	{ CSU_CSLX_PCIE1, CSU_ALL_RW },
+	{ CSU_CSLX_OCRAM2, CSU_ALL_RW },
+	{ CSU_CSLX_QSPI_MEM, CSU_ALL_RW },
+	{ CSU_CSLX_PCIE2, CSU_ALL_RW },
+	{ CSU_CSLX_SATA, CSU_ALL_RW },
+	{ CSU_CSLX_USB3, CSU_ALL_RW },
+	{ CSU_CSLX_SERDES, CSU_ALL_RW },
+	{ CSU_CSLX_QDMA, CSU_ALL_RW },
+	{ CSU_CSLX_LPUART2, CSU_ALL_RW },
+	{ CSU_CSLX_LPUART1, CSU_ALL_RW },
+	{ CSU_CSLX_LPUART4, CSU_ALL_RW },
+	{ CSU_CSLX_LPUART3, CSU_ALL_RW },
+	{ CSU_CSLX_LPUART6, CSU_ALL_RW },
+	{ CSU_CSLX_LPUART5, CSU_ALL_RW },
+	{ CSU_CSLX_DSPI2, CSU_ALL_RW },
+	{ CSU_CSLX_DSPI1, CSU_ALL_RW },
+	{ CSU_CSLX_QSPI, CSU_ALL_RW },
+	{ CSU_CSLX_ESDHC, CSU_ALL_RW },
+	{ CSU_CSLX_2D_ACE, CSU_ALL_RW },
+	{ CSU_CSLX_IFC, CSU_ALL_RW },
+	{ CSU_CSLX_I2C1, CSU_ALL_RW },
+	{ CSU_CSLX_USB2, CSU_ALL_RW },
+	{ CSU_CSLX_I2C3, CSU_ALL_RW },
+	{ CSU_CSLX_I2C2, CSU_ALL_RW },
+	{ CSU_CSLX_DUART2, CSU_ALL_RW },
+	{ CSU_CSLX_DUART1, CSU_ALL_RW },
+	{ CSU_CSLX_WDT2, CSU_ALL_RW },
+	{ CSU_CSLX_WDT1, CSU_ALL_RW },
+	{ CSU_CSLX_EDMA, CSU_ALL_RW },
+	{ CSU_CSLX_SYS_CNT, CSU_ALL_RW },
+	{ CSU_CSLX_DMA_MUX2, CSU_ALL_RW },
+	{ CSU_CSLX_DMA_MUX1, CSU_ALL_RW },
+	{ CSU_CSLX_DDR, CSU_ALL_RW },
+	{ CSU_CSLX_QUICC, CSU_ALL_RW },
+	{ CSU_CSLX_DCFG_CCU_RCPM, CSU_ALL_RW },
+	{ CSU_CSLX_SECURE_BOOTROM, CSU_ALL_RW },
+	{ CSU_CSLX_SFP, CSU_ALL_RW },
+	{ CSU_CSLX_TMU, CSU_ALL_RW },
+	{ CSU_CSLX_SECURE_MONITOR, CSU_ALL_RW },
+	{ CSU_CSLX_RESERVED0, CSU_ALL_RW },
+	{ CSU_CSLX_ETSEC1, CSU_ALL_RW },
+	{ CSU_CSLX_SEC5_5, CSU_ALL_RW },
+	{ CSU_CSLX_ETSEC3, CSU_ALL_RW },
+	{ CSU_CSLX_ETSEC2, CSU_ALL_RW },
+	{ CSU_CSLX_GPIO2, CSU_ALL_RW },
+	{ CSU_CSLX_GPIO1, CSU_ALL_RW },
+	{ CSU_CSLX_GPIO4, CSU_ALL_RW },
+	{ CSU_CSLX_GPIO3, CSU_ALL_RW },
+	{ CSU_CSLX_PLATFORM_CONT, CSU_ALL_RW },
+	{ CSU_CSLX_CSU, CSU_ALL_RW },
+	{ CSU_CSLX_ASRC, CSU_ALL_RW },
+	{ CSU_CSLX_SPDIF, CSU_ALL_RW },
+	{ CSU_CSLX_FLEXCAN2, CSU_ALL_RW },
+	{ CSU_CSLX_FLEXCAN1, CSU_ALL_RW },
+	{ CSU_CSLX_FLEXCAN4, CSU_ALL_RW },
+	{ CSU_CSLX_FLEXCAN3, CSU_ALL_RW },
+	{ CSU_CSLX_SAI2, CSU_ALL_RW },
+	{ CSU_CSLX_SAI1, CSU_ALL_RW },
+	{ CSU_CSLX_SAI4, CSU_ALL_RW },
+	{ CSU_CSLX_SAI3, CSU_ALL_RW },
+	{ CSU_CSLX_FTM2, CSU_ALL_RW },
+	{ CSU_CSLX_FTM1, CSU_ALL_RW },
+	{ CSU_CSLX_FTM4, CSU_ALL_RW },
+	{ CSU_CSLX_FTM3, CSU_ALL_RW },
+	{ CSU_CSLX_FTM6, CSU_ALL_RW },
+	{ CSU_CSLX_FTM5, CSU_ALL_RW },
+	{ CSU_CSLX_FTM8, CSU_ALL_RW },
+	{ CSU_CSLX_FTM7, CSU_ALL_RW },
+	{ CSU_CSLX_COP_DCSR, CSU_ALL_RW },
+	{ CSU_CSLX_EPU, CSU_ALL_RW },
+	{ CSU_CSLX_GDI, CSU_ALL_RW },
+	{ CSU_CSLX_DDI, CSU_ALL_RW },
+	{ CSU_CSLX_RESERVED1, CSU_ALL_RW },
+	{ CSU_CSLX_USB3_PHY, CSU_ALL_RW },
+	{ CSU_CSLX_RESERVED2, CSU_ALL_RW },
 };
 
-void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num);
-
 #endif
board/freescale/common/Makefile +1 -1
index 87d0578..51d2814 100644
@@ -71,7 +71,7 @@ obj-$(CONFIG_P4080DS)	+= p_corenet/
 obj-$(CONFIG_P5020DS)	+= p_corenet/
 obj-$(CONFIG_P5040DS)	+= p_corenet/
 
-obj-$(CONFIG_LS102XA_NS_ACCESS)	+= ns_access.o
+obj-$(CONFIG_LAYERSCAPE_NS_ACCESS)	+= ns_access.o
 
 ifdef CONFIG_SECURE_BOOT
 obj-$(CONFIG_CMD_ESBC_VALIDATE) += fsl_validate.o cmd_esbc_validate.o
board/freescale/common/ns_access.c +7 -1
index d7de982..d8d16c5 100644
@@ -6,9 +6,10 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <fsl_csu.h>
 #include <asm/arch/ns_access.h>
 
-void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
+static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
 {
 	u32 *base = (u32 *)CONFIG_SYS_FSL_CSU_ADDR;
 	u32 *reg;
@@ -28,3 +29,8 @@ void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
 		out_be32(reg, val);
 	}
 }
+
+void enable_layerscape_ns_access(void)
+{
+	enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev));
+}
board/freescale/ls1021aqds/ls1021aqds.c +7 -94

137 lines not on this page · raw message

board/freescale/ls1021atwr/ls1021atwr.c +3 -89

116 lines not on this page · raw message

include/configs/ls1021aqds.h +1 -1
index b44f326..0234e32 100644
@@ -561,7 +561,7 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_ARMV7_NONSEC
 #define CONFIG_ARMV7_VIRT
 #define CONFIG_PEN_ADDR_BIG_ENDIAN
-#define CONFIG_LS102XA_NS_ACCESS
+#define CONFIG_LAYERSCAPE_NS_ACCESS
 #define CONFIG_SMP_PEN_ADDR		0x01ee0200
 #define CONFIG_TIMER_CLK_FREQ		12500000
 
include/configs/ls1021atwr.h +1 -1
index 7dcb719..f561cbe 100644
@@ -409,7 +409,7 @@
 #define CONFIG_ARMV7_NONSEC
 #define CONFIG_ARMV7_VIRT
 #define CONFIG_PEN_ADDR_BIG_ENDIAN
-#define CONFIG_LS102XA_NS_ACCESS
+#define CONFIG_LAYERSCAPE_NS_ACCESS
 #define CONFIG_SMP_PEN_ADDR		0x01ee0200
 #define CONFIG_TIMER_CLK_FREQ		12500000
 
include/fsl_csu.h new file +34 -0
new file mode 100644
index 0000000..f4d97fb
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2015 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __FSL_CSU_H__
+#define __FSL_CSU_H__
+
+enum csu_cslx_access {
+	CSU_NS_SUP_R = 0x08,
+	CSU_NS_SUP_W = 0x80,
+	CSU_NS_SUP_RW = 0x88,
+	CSU_NS_USER_R = 0x04,
+	CSU_NS_USER_W = 0x40,
+	CSU_NS_USER_RW = 0x44,
+	CSU_S_SUP_R = 0x02,
+	CSU_S_SUP_W = 0x20,
+	CSU_S_SUP_RW = 0x22,
+	CSU_S_USER_R = 0x01,
+	CSU_S_USER_W = 0x10,
+	CSU_S_USER_RW = 0x11,
+	CSU_ALL_RW = 0xff,
+};
+
+struct csu_ns_dev {
+	unsigned long ind;
+	uint32_t val;
+};
+
+void enable_layerscape_ns_access(void);
+
+#endif
Signature · 1 line
2.1.0.27.g96db324
#2 lore raw

PATCH v3 2/16 common/board_f.c: modify the macro to use get_clocks() more common

In reply to Gong Qianyu

get_clocks() should not be limited by ESDHC.

---
V3:
-Removed defines in PPC configs that have no need to use.

 common/board_f.c                  | 2 +-
 include/configs/colibri_vf.h      | 1 +
 include/configs/ls1021aqds.h      | 1 +
 include/configs/ls1021atwr.h      | 1 +
 include/configs/ls2085aqds.h      | 1 +
 include/configs/ls2085ardb.h      | 1 +
 include/configs/m53evk.h          | 1 +
 include/configs/mx25pdk.h         | 1 +
 include/configs/mx35pdk.h         | 1 +
 include/configs/mx51evk.h         | 1 +
 include/configs/mx53ard.h         | 1 +
 include/configs/mx53evk.h         | 1 +
 include/configs/mx53loco.h        | 1 +
 include/configs/mx53smd.h         | 1 +
 include/configs/mx6_common.h      | 1 +
 include/configs/mx7_common.h      | 1 +
 include/configs/usbarmory.h       | 1 +
 include/configs/vf610twr.h        | 1 +
 include/configs/woodburn_common.h | 1 +
 19 files changed, 19 insertions(+), 1 deletion(-)
common/board_f.c +1 -1
index 613332e..1bb84b3 100644
@@ -806,7 +806,7 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_BOARD_POSTCLK_INIT)
 	board_postclk_init,
 #endif
-#ifdef CONFIG_FSL_ESDHC
+#ifdef CONFIG_FSL_CLK
 	get_clocks,
 #endif
 #ifdef CONFIG_M68K
include/configs/colibri_vf.h +1 -0
index 2583155..5bd742d 100644
@@ -18,6 +18,7 @@
 #define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_USE_ARCH_MEMCPY
 #define CONFIG_USE_ARCH_MEMSET
+#define CONFIG_FSL_CLK
 
 #define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_ARCH_MISC_INIT
include/configs/ls1021aqds.h +1 -0
index 0234e32..c02cefa 100644
@@ -12,6 +12,7 @@
 #define CONFIG_ARMV7_PSCI
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
include/configs/ls1021atwr.h +1 -0
index f561cbe..66f487d 100644
@@ -12,6 +12,7 @@
 #define CONFIG_ARMV7_PSCI
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
include/configs/ls2085aqds.h +1 -0
index f7f3870..4cfcf98 100644
@@ -16,6 +16,7 @@ unsigned long get_board_sys_clk(void);
 unsigned long get_board_ddr_clk(void);
 #endif
 
+#define CONFIG_FSL_CLK
 #define CONFIG_SYS_CLK_FREQ		get_board_sys_clk()
 #define CONFIG_DDR_CLK_FREQ		get_board_ddr_clk()
 #define COUNTER_FREQUENCY_REAL		(CONFIG_SYS_CLK_FREQ/4)
include/configs/ls2085ardb.h +1 -0
index a190bc7..583fed5 100644
@@ -18,6 +18,7 @@
 unsigned long get_board_sys_clk(void);
 #endif
 
+#define CONFIG_FSL_CLK
 #define CONFIG_SYS_CLK_FREQ		get_board_sys_clk()
 #define CONFIG_DDR_CLK_FREQ		133333333
 #define COUNTER_FREQUENCY_REAL		(CONFIG_SYS_CLK_FREQ/4)
include/configs/m53evk.h +1 -0
index 35058e2..4d37785 100644
@@ -18,6 +18,7 @@
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_REVISION_TAG
 #define CONFIG_SYS_NO_FLASH
+#define CONFIG_FSL_CLK
 
 #define CONFIG_FIT
 
include/configs/mx25pdk.h +1 -0
index bd7216e..105ac6d 100644
@@ -15,6 +15,7 @@
 #define CONFIG_SYS_TEXT_BASE		0x81200000
 #define CONFIG_MXC_GPIO
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 #define CONFIG_SYS_TIMER_RATE		32768
 #define CONFIG_SYS_TIMER_COUNTER	\
include/configs/mx35pdk.h +1 -0
index c9983f3..97527b6 100644
@@ -20,6 +20,7 @@
 
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 /* Set TEXT at the beginning of the NOR flash */
 #define CONFIG_SYS_TEXT_BASE	0xA0000000
include/configs/mx51evk.h +1 -0
index 2203c15..e3763c1 100644
@@ -18,6 +18,7 @@
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
 
+#define CONFIG_FSL_CLK
 #define CONFIG_SYS_TEXT_BASE	0x97800000
 
 #include <asm/arch/imx-regs.h>
include/configs/mx53ard.h +1 -0
index 0479195..d57e06d 100644
@@ -24,6 +24,7 @@
 #define CONFIG_REVISION_TAG
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 2 * 1024 * 1024)
include/configs/mx53evk.h +1 -0
index 82c8af8..6cae6d5 100644
@@ -24,6 +24,7 @@
 #define CONFIG_REVISION_TAG
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 #define CONFIG_OF_LIBFDT
 
include/configs/mx53loco.h +1 -0
index ad2629d..540f853 100644
@@ -23,6 +23,7 @@
 #define CONFIG_INITRD_TAG
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(10 * 1024 * 1024)
include/configs/mx53smd.h +1 -0
index bcdb054..0a5f50e 100644
@@ -24,6 +24,7 @@
 #define CONFIG_REVISION_TAG
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 2 * 1024 * 1024)
include/configs/mx6_common.h +1 -0
index ef4cb68..c157e81 100644
@@ -46,6 +46,7 @@
 #define CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_FSL_CLK
 
 /* ATAGs */
 #define CONFIG_CMDLINE_TAG
include/configs/mx7_common.h +1 -0
index ea2be49..85c8df8 100644
@@ -21,6 +21,7 @@
 #define CONFIG_MXC_GPT_HCLK
 #define CONFIG_SYSCOUNTER_TIMER
 #define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
+#define CONFIG_FSL_CLK
 
 /* Enable iomux-lpsr support */
 #define CONFIG_IOMUX_LPSR
include/configs/usbarmory.h +1 -0
index 4a7702c..6ba5086 100644
@@ -14,6 +14,7 @@
 #define CONFIG_MX53
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
+#define CONFIG_FSL_CLK
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_OF_LIBFDT
 #define CONFIG_SYS_GENERIC_BOARD
include/configs/vf610twr.h +1 -0
index c5131af..ba5bc29 100644
@@ -16,6 +16,7 @@
 #define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
+#define CONFIG_FSL_CLK
 
 #define CONFIG_MACH_TYPE		4146
 
include/configs/woodburn_common.h +1 -0
index 5d9f529..53f91c6 100644
@@ -16,6 +16,7 @@
  /* High Level Configuration Options */
 #define CONFIG_MX35
 #define CONFIG_MX35_HCLK_FREQ	24000000
+#define CONFIG_FSL_CLK
 
 #define CONFIG_SYS_DCACHE_OFF
 #define CONFIG_SYS_CACHELINE_SIZE	32
Signature · 1 line
2.1.0.27.g96db324
#3 lore raw

PATCH v3 3/16 net/fm: Fix the endian issue to support both

In reply to Gong Qianyu

From: Hou Zhiqiang <[email protected]>

The Frame Manager(FMan) is a big-endian peripheral, so the registers, internal MURAM and BDs, which are allocated in main memory and used to communication between core and FMan, should be accessed in big-endian. The big-endian platforms can access them directly as the code implemented so far, while for the little-endian platforms it need to swap the byte-order.

---
V3:
- Modify the subject to make the aim clear.

 drivers/net/fm/eth.c | 70 +++++++++++++++++++++++++++-------------------------
 drivers/net/fm/fm.c  | 11 +++++----
 2 files changed, 43 insertions(+), 38 deletions(-)
drivers/net/fm/eth.c +37 -33
index 6702f5a..946b591 100644
@@ -109,7 +109,7 @@ static int tgec_is_fibre(struct eth_device *dev)
 static u16 muram_readw(u16 *addr)
 {
 	u32 base = (u32)addr & ~0x3;
-	u32 val32 = *(u32 *)base;
+	u32 val32 = in_be32((u32 *)base);
 	int byte_pos;
 	u16 ret;
 
@@ -125,7 +125,7 @@ static u16 muram_readw(u16 *addr)
 static void muram_writew(u16 *addr, u16 val)
 {
 	u32 base = (u32)addr & ~0x3;
-	u32 org32 = *(u32 *)base;
+	u32 org32 = in_be32((u32 *)base);
 	u32 val32;
 	int byte_pos;
 
@@ -135,7 +135,7 @@ static void muram_writew(u16 *addr, u16 val)
 	else
 		val32 = (org32 & 0x0000ffff) | ((u32)val << 16);
 
-	*(u32 *)base = val32;
+	out_be32((u32 *)base, val32);
 }
 
 static void bmi_rx_port_disable(struct fm_bmi_rx_port *rx_port)
@@ -213,10 +213,10 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	pram_page_offset = (u32)pram - fm_muram_base(fm_eth->fm_index);
 
 	/* enable global mode- snooping data buffers and BDs */
-	pram->mode = PRAM_MODE_GLOBAL;
+	out_be32(&pram->mode, PRAM_MODE_GLOBAL);
 
 	/* init the Rx queue descriptor pionter */
-	pram->rxqd_ptr = pram_page_offset + 0x20;
+	out_be32(&pram->rxqd_ptr, pram_page_offset + 0x20);
 
 	/* set the max receive buffer length, power of 2 */
 	muram_writew(&pram->mrblr, MAX_RXBUF_LOG2);
@@ -243,10 +243,11 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	/* init Rx BDs ring */
 	rxbd = (struct fm_port_bd *)rx_bd_ring_base;
 	for (i = 0; i < RX_BD_RING_SIZE; i++) {
-		rxbd->status = RxBD_EMPTY;
-		rxbd->len = 0;
-		rxbd->buf_ptr_hi = 0;
-		rxbd->buf_ptr_lo = (u32)rx_buf_pool + i * MAX_RXBUF_LEN;
+		muram_writew(&rxbd->status, RxBD_EMPTY);
+		muram_writew(&rxbd->len, 0);
+		muram_writew(&rxbd->buf_ptr_hi, 0);
+		out_be32(&rxbd->buf_ptr_lo, (u32)rx_buf_pool +
+				i * MAX_RXBUF_LEN);
 		rxbd++;
 	}
 
@@ -254,7 +255,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	rxqd = &pram->rxqd;
 	muram_writew(&rxqd->gen, 0);
 	muram_writew(&rxqd->bd_ring_base_hi, 0);
-	rxqd->bd_ring_base_lo = (u32)rx_bd_ring_base;
+	out_be32(&rxqd->bd_ring_base_lo, (u32)rx_bd_ring_base);
 	muram_writew(&rxqd->bd_ring_size, sizeof(struct fm_port_bd)
 			* RX_BD_RING_SIZE);
 	muram_writew(&rxqd->offset_in, 0);
@@ -285,10 +286,10 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	pram_page_offset = (u32)pram - fm_muram_base(fm_eth->fm_index);
 
 	/* enable global mode- snooping data buffers and BDs */
-	pram->mode = PRAM_MODE_GLOBAL;
+	out_be32(&pram->mode, PRAM_MODE_GLOBAL);
 
 	/* init the Tx queue descriptor pionter */
-	pram->txqd_ptr = pram_page_offset + 0x40;
+	out_be32(&pram->txqd_ptr, pram_page_offset + 0x40);
 
 	/* alloc Tx buffer descriptors from main memory */
 	tx_bd_ring_base = malloc(sizeof(struct fm_port_bd)
@@ -304,16 +305,17 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	/* init Tx BDs ring */
 	txbd = (struct fm_port_bd *)tx_bd_ring_base;
 	for (i = 0; i < TX_BD_RING_SIZE; i++) {
-		txbd->status = TxBD_LAST;
-		txbd->len = 0;
-		txbd->buf_ptr_hi = 0;
-		txbd->buf_ptr_lo = 0;
+		muram_writew(&txbd->status, TxBD_LAST);
+		muram_writew(&txbd->len, 0);
+		muram_writew(&txbd->buf_ptr_hi, 0);
+		out_be32(&txbd->buf_ptr_lo, 0);
+		txbd++;
 	}
 
 	/* set the Tx queue decriptor */
 	txqd = &pram->txqd;
 	muram_writew(&txqd->bd_ring_base_hi, 0);
-	txqd->bd_ring_base_lo = (u32)tx_bd_ring_base;
+	out_be32(&txqd->bd_ring_base_lo, (u32)tx_bd_ring_base);
 	muram_writew(&txqd->bd_ring_size, sizeof(struct fm_port_bd)
 			* TX_BD_RING_SIZE);
 	muram_writew(&txqd->offset_in, 0);
@@ -368,7 +370,7 @@ static void fmc_tx_port_graceful_stop_enable(struct fm_eth *fm_eth)
 
 	pram = fm_eth->tx_pram;
 	/* graceful stop transmission of frames */
-	pram->mode |= PRAM_MODE_GRACEFUL_STOP;
+	setbits_be32(&pram->mode, PRAM_MODE_GRACEFUL_STOP);
 	sync();
 }
 
@@ -378,7 +380,7 @@ static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth)
 
 	pram = fm_eth->tx_pram;
 	/* re-enable transmission of frames */
-	pram->mode &= ~PRAM_MODE_GRACEFUL_STOP;
+	clrbits_be32(&pram->mode, PRAM_MODE_GRACEFUL_STOP);
 	sync();
 }
 
@@ -469,19 +471,20 @@ static int fm_eth_send(struct eth_device *dev, void *buf, int len)
 	txbd = fm_eth->cur_txbd;
 
 	/* find one empty TxBD */
-	for (i = 0; txbd->status & TxBD_READY; i++) {
+	for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) {
 		udelay(100);
 		if (i > 0x1000) {
-			printf("%s: Tx buffer not ready\n", dev->name);
+			printf("%s: Tx buffer not ready, txbd->status = 0x%x\n",
+			       dev->name, muram_readw(&txbd->status));
 			return 0;
 		}
 	}
 	/* setup TxBD */
-	txbd->buf_ptr_hi = 0;
-	txbd->buf_ptr_lo = (u32)buf;
-	txbd->len = len;
+	muram_writew(&txbd->buf_ptr_hi, 0);
+	out_be32(&txbd->buf_ptr_lo, (u32)buf);
+	muram_writew(&txbd->len, len);
 	sync();
-	txbd->status = TxBD_READY | TxBD_LAST;
+	muram_writew(&txbd->status, TxBD_READY | TxBD_LAST);
 	sync();
 
 	/* update TxQD, let RISC to send the packet */
@@ -493,10 +496,11 @@ static int fm_eth_send(struct eth_device *dev, void *buf, int len)
 	sync();
 
 	/* wait for buffer to be transmitted */
-	for (i = 0; txbd->status & TxBD_READY; i++) {
+	for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) {
 		udelay(100);
 		if (i > 0x10000) {
-			printf("%s: Tx error\n", dev->name);
+			printf("%s: Tx error, txbd->status = 0x%x\n",
+					dev->name, muram_readw(&txbd->status));
 			return 0;
 		}
 	}
@@ -525,12 +529,12 @@ static int fm_eth_recv(struct eth_device *dev)
 	fm_eth = (struct fm_eth *)dev->priv;
 	pram = fm_eth->rx_pram;
 	rxbd = fm_eth->cur_rxbd;
-	status = rxbd->status;
+	status = muram_readw(&rxbd->status);
 
 	while (!(status & RxBD_EMPTY)) {
 		if (!(status & RxBD_ERROR)) {
-			data = (u8 *)rxbd->buf_ptr_lo;
-			len = rxbd->len;
+			data = (u8 *)in_be32(&rxbd->buf_ptr_lo);
+			len = muram_readw(&rxbd->len);
 			net_process_received_packet(data, len);
 		} else {
 			printf("%s: Rx error\n", dev->name);
@@ -538,8 +542,8 @@ static int fm_eth_recv(struct eth_device *dev)
 		}
 
 		/* clear the RxBDs */
-		rxbd->status = RxBD_EMPTY;
-		rxbd->len = 0;
+		muram_writew(&rxbd->status, RxBD_EMPTY);
+		muram_writew(&rxbd->len, 0);
 		sync();
 
 		/* advance RxBD */
@@ -548,7 +552,7 @@ static int fm_eth_recv(struct eth_device *dev)
 		if (rxbd >= (rxbd_base + RX_BD_RING_SIZE))
 			rxbd = rxbd_base;
 		/* read next status */
-		status = rxbd->status;
+		status = muram_readw(&rxbd->status);
 
 		/* update RxQD */
 		offset_out = muram_readw(&pram->rxqd.offset_out);
drivers/net/fm/fm.c +6 -5
index 400e9dd..eb0eb3d 100644
@@ -80,11 +80,11 @@ static void fm_upload_ucode(int fm_idx, struct fm_imem *imem,
 	out_be32(&imem->iadd, IRAM_IADD_AIE);
 	/* write microcode to IRAM */
 	for (i = 0; i < size / 4; i++)
-		out_be32(&imem->idata, ucode[i]);
+		out_be32(&imem->idata, (be32_to_cpu(ucode[i])));
 
 	/* verify if the writing is over */
 	out_be32(&imem->iadd, 0);
-	while ((in_be32(&imem->idata) != ucode[0]) && --timeout)
+	while ((in_be32(&imem->idata) != be32_to_cpu(ucode[0])) && --timeout)
 		;
 	if (!timeout)
 		printf("Fman%u: microcode upload timeout\n", fm_idx + 1);
@@ -177,14 +177,15 @@ static int fman_upload_firmware(int fm_idx,
 		const struct qe_microcode *ucode = &firmware->microcode[i];
 
 		/* Upload a microcode if it's present */
-		if (ucode->code_offset) {
+		if (be32_to_cpu(ucode->code_offset)) {
 			u32 ucode_size;
 			u32 *code;
 			printf("Fman%u: Uploading microcode version %u.%u.%u\n",
 			       fm_idx + 1, ucode->major, ucode->minor,
 			       ucode->revision);
-			code = (void *)firmware + ucode->code_offset;
-			ucode_size = sizeof(u32) * ucode->count;
+			code = (void *)firmware +
+			       be32_to_cpu(ucode->code_offset);
+			ucode_size = sizeof(u32) * be32_to_cpu(ucode->count);
 			fm_upload_ucode(fm_idx, fm_imem, code, ucode_size);
 		}
 	}
Signature · 1 line
2.1.0.27.g96db324
#4 lore raw

PATCH v3 4/16 net/fm/eth: Use mb() to be compatible for both ARM and PowerPC

In reply to Gong Qianyu

From: Shaohui Xie <[email protected]>

Use mb() instead of sync() to be compatible for both ARM and PowerPC.

---
V3:
- Separated from patch 'net: Move some header files to include/'

 drivers/net/fm/eth.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/fm/eth.c +7 -7
index 946b591..5b860cc 100644
@@ -371,7 +371,7 @@ static void fmc_tx_port_graceful_stop_enable(struct fm_eth *fm_eth)
 	pram = fm_eth->tx_pram;
 	/* graceful stop transmission of frames */
 	setbits_be32(&pram->mode, PRAM_MODE_GRACEFUL_STOP);
-	sync();
+	mb();
 }
 
 static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth)
@@ -381,7 +381,7 @@ static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth)
 	pram = fm_eth->tx_pram;
 	/* re-enable transmission of frames */
 	clrbits_be32(&pram->mode, PRAM_MODE_GRACEFUL_STOP);
-	sync();
+	mb();
 }
 
 static int fm_eth_open(struct eth_device *dev, bd_t *bd)
@@ -483,9 +483,9 @@ static int fm_eth_send(struct eth_device *dev, void *buf, int len)
 	muram_writew(&txbd->buf_ptr_hi, 0);
 	out_be32(&txbd->buf_ptr_lo, (u32)buf);
 	muram_writew(&txbd->len, len);
-	sync();
+	mb();
 	muram_writew(&txbd->status, TxBD_READY | TxBD_LAST);
-	sync();
+	mb();
 
 	/* update TxQD, let RISC to send the packet */
 	offset_in = muram_readw(&pram->txqd.offset_in);
@@ -493,7 +493,7 @@ static int fm_eth_send(struct eth_device *dev, void *buf, int len)
 	if (offset_in >= muram_readw(&pram->txqd.bd_ring_size))
 		offset_in = 0;
 	muram_writew(&pram->txqd.offset_in, offset_in);
-	sync();
+	mb();
 
 	/* wait for buffer to be transmitted */
 	for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) {
@@ -544,7 +544,7 @@ static int fm_eth_recv(struct eth_device *dev)
 		/* clear the RxBDs */
 		muram_writew(&rxbd->status, RxBD_EMPTY);
 		muram_writew(&rxbd->len, 0);
-		sync();
+		mb();
 
 		/* advance RxBD */
 		rxbd++;
@@ -560,7 +560,7 @@ static int fm_eth_recv(struct eth_device *dev)
 		if (offset_out >= muram_readw(&pram->rxqd.bd_ring_size))
 			offset_out = 0;
 		muram_writew(&pram->rxqd.offset_out, offset_out);
-		sync();
+		mb();
 	}
 	fm_eth->cur_rxbd = (void *)rxbd;
 
Signature · 1 line
2.1.0.27.g96db324
#5 lore raw

PATCH v3 5/16 net/fm: Add support for 64-bit platforms

In reply to Gong Qianyu

From: Hou Zhiqiang <[email protected]>

The FMan IM driver is developed for 32-bit platfroms and isn't friendly to 64-bit platforms, so do the minimal refactor:

1. Refine the MURAM management and access.
2. Correct the initialization and operations for QDs and BDs.

---
V3:
- New patch

 drivers/net/fm/eth.c | 61 ++++++++++++++++++++++++++++++++++++----------------
 drivers/net/fm/fm.c  | 20 ++++++++++-------
 drivers/net/fm/fm.h  | 12 +++++------
 3 files changed, 60 insertions(+), 33 deletions(-)
drivers/net/fm/eth.c +42 -19
index 5b860cc..a5ccccc 100644
@@ -108,12 +108,12 @@ static int tgec_is_fibre(struct eth_device *dev)
 
 static u16 muram_readw(u16 *addr)
 {
-	u32 base = (u32)addr & ~0x3;
-	u32 val32 = in_be32((u32 *)base);
+	ulong base = (ulong)addr & ~0x3UL;
+	u32 val32 = in_be32((void *)base);
 	int byte_pos;
 	u16 ret;
 
-	byte_pos = (u32)addr & 0x3;
+	byte_pos = (ulong)addr & 0x3UL;
 	if (byte_pos)
 		ret = (u16)(val32 & 0x0000ffff);
 	else
@@ -124,18 +124,18 @@ static u16 muram_readw(u16 *addr)
 
 static void muram_writew(u16 *addr, u16 val)
 {
-	u32 base = (u32)addr & ~0x3;
-	u32 org32 = in_be32((u32 *)base);
+	ulong base = (ulong)addr & ~0x3UL;
+	u32 org32 = in_be32((void *)base);
 	u32 val32;
 	int byte_pos;
 
-	byte_pos = (u32)addr & 0x3;
+	byte_pos = (ulong)addr & 0x3UL;
 	if (byte_pos)
 		val32 = (org32 & 0xffff0000) | val;
 	else
 		val32 = (org32 & 0x0000ffff) | ((u32)val << 16);
 
-	out_be32((u32 *)base, val32);
+	out_be32((void *)base, val32);
 }
 
 static void bmi_rx_port_disable(struct fm_bmi_rx_port *rx_port)
@@ -199,6 +199,8 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	u32 pram_page_offset;
 	void *rx_bd_ring_base;
 	void *rx_buf_pool;
+	u32 bd_ring_base_lo, bd_ring_base_hi;
+	u32 buf_lo, buf_hi;
 	struct fm_port_bd *rxbd;
 	struct fm_port_qd *rxqd;
 	struct fm_bmi_rx_port *bmi_rx_port = fm_eth->rx_port;
@@ -207,10 +209,15 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	/* alloc global parameter ram at MURAM */
 	pram = (struct fm_port_global_pram *)fm_muram_alloc(fm_eth->fm_index,
 		FM_PRAM_SIZE, FM_PRAM_ALIGN);
+	if (!pram) {
+		printf("%s: No muram for Rx global parameter\n", __func__);
+		return 0;
+	}
+
 	fm_eth->rx_pram = pram;
 
 	/* parameter page offset to MURAM */
-	pram_page_offset = (u32)pram - fm_muram_base(fm_eth->fm_index);
+	pram_page_offset = (void *)pram - fm_muram_base(fm_eth->fm_index);
 
 	/* enable global mode- snooping data buffers and BDs */
 	out_be32(&pram->mode, PRAM_MODE_GLOBAL);
@@ -234,6 +241,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	if (!rx_buf_pool)
 		return 0;
 	memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE);
+	debug("%s: rx_buf_pool = %p\n", __func__, rx_buf_pool);
 
 	/* save them to fm_eth */
 	fm_eth->rx_bd_ring = rx_bd_ring_base;
@@ -245,17 +253,22 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	for (i = 0; i < RX_BD_RING_SIZE; i++) {
 		muram_writew(&rxbd->status, RxBD_EMPTY);
 		muram_writew(&rxbd->len, 0);
-		muram_writew(&rxbd->buf_ptr_hi, 0);
-		out_be32(&rxbd->buf_ptr_lo, (u32)rx_buf_pool +
-				i * MAX_RXBUF_LEN);
+		buf_hi = upper_32_bits(virt_to_phys(rx_buf_pool +
+					i * MAX_RXBUF_LEN));
+		buf_lo = lower_32_bits(virt_to_phys(rx_buf_pool +
+					i * MAX_RXBUF_LEN));
+		muram_writew(&rxbd->buf_ptr_hi, (u16)buf_hi);
+		out_be32(&rxbd->buf_ptr_lo, buf_lo);
 		rxbd++;
 	}
 
 	/* set the Rx queue descriptor */
 	rxqd = &pram->rxqd;
 	muram_writew(&rxqd->gen, 0);
-	muram_writew(&rxqd->bd_ring_base_hi, 0);
-	out_be32(&rxqd->bd_ring_base_lo, (u32)rx_bd_ring_base);
+	bd_ring_base_hi = upper_32_bits(virt_to_phys(rx_bd_ring_base));
+	bd_ring_base_lo = lower_32_bits(virt_to_phys(rx_bd_ring_base));
+	muram_writew(&rxqd->bd_ring_base_hi, (u16)bd_ring_base_hi);
+	out_be32(&rxqd->bd_ring_base_lo, bd_ring_base_lo);
 	muram_writew(&rxqd->bd_ring_size, sizeof(struct fm_port_bd)
 			* RX_BD_RING_SIZE);
 	muram_writew(&rxqd->offset_in, 0);
@@ -272,6 +285,7 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	struct fm_port_global_pram *pram;
 	u32 pram_page_offset;
 	void *tx_bd_ring_base;
+	u32 bd_ring_base_lo, bd_ring_base_hi;
 	struct fm_port_bd *txbd;
 	struct fm_port_qd *txqd;
 	struct fm_bmi_tx_port *bmi_tx_port = fm_eth->tx_port;
@@ -280,10 +294,14 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	/* alloc global parameter ram at MURAM */
 	pram = (struct fm_port_global_pram *)fm_muram_alloc(fm_eth->fm_index,
 		FM_PRAM_SIZE, FM_PRAM_ALIGN);
+	if (!pram) {
+		printf("%s: No muram for Tx global parameter\n", __func__);
+		return 0;
+	}
 	fm_eth->tx_pram = pram;
 
 	/* parameter page offset to MURAM */
-	pram_page_offset = (u32)pram - fm_muram_base(fm_eth->fm_index);
+	pram_page_offset = (void *)pram - fm_muram_base(fm_eth->fm_index);
 
 	/* enable global mode- snooping data buffers and BDs */
 	out_be32(&pram->mode, PRAM_MODE_GLOBAL);
@@ -314,8 +332,10 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 
 	/* set the Tx queue decriptor */
 	txqd = &pram->txqd;
-	muram_writew(&txqd->bd_ring_base_hi, 0);
-	out_be32(&txqd->bd_ring_base_lo, (u32)tx_bd_ring_base);
+	bd_ring_base_hi = upper_32_bits(virt_to_phys(tx_bd_ring_base));
+	bd_ring_base_lo = lower_32_bits(virt_to_phys(tx_bd_ring_base));
+	muram_writew(&txqd->bd_ring_base_hi, (u16)bd_ring_base_hi);
+	out_be32(&txqd->bd_ring_base_lo, bd_ring_base_lo);
 	muram_writew(&txqd->bd_ring_size, sizeof(struct fm_port_bd)
 			* TX_BD_RING_SIZE);
 	muram_writew(&txqd->offset_in, 0);
@@ -480,8 +500,8 @@ static int fm_eth_send(struct eth_device *dev, void *buf, int len)
 		}
 	}
 	/* setup TxBD */
-	muram_writew(&txbd->buf_ptr_hi, 0);
-	out_be32(&txbd->buf_ptr_lo, (u32)buf);
+	muram_writew(&txbd->buf_ptr_hi, (u16)upper_32_bits(virt_to_phys(buf)));
+	out_be32(&txbd->buf_ptr_lo, lower_32_bits(virt_to_phys(buf)));
 	muram_writew(&txbd->len, len);
 	mb();
 	muram_writew(&txbd->status, TxBD_READY | TxBD_LAST);
@@ -522,6 +542,7 @@ static int fm_eth_recv(struct eth_device *dev)
 	struct fm_port_global_pram *pram;
 	struct fm_port_bd *rxbd, *rxbd_base;
 	u16 status, len;
+	u32 buf_lo, buf_hi;
 	u8 *data;
 	u16 offset_out;
 	int ret = 1;
@@ -533,7 +554,9 @@ static int fm_eth_recv(struct eth_device *dev)
 
 	while (!(status & RxBD_EMPTY)) {
 		if (!(status & RxBD_ERROR)) {
-			data = (u8 *)in_be32(&rxbd->buf_ptr_lo);
+			buf_hi = muram_readw(&rxbd->buf_ptr_hi);
+			buf_lo = in_be32(&rxbd->buf_ptr_lo);
+			data = (u8 *)((ulong)(buf_hi << 16) << 16 | buf_lo);
 			len = muram_readw(&rxbd->len);
 			net_process_received_packet(data, len);
 		} else {
drivers/net/fm/fm.c +12 -8
index eb0eb3d..df5db72 100644
@@ -22,21 +22,22 @@
 
 struct fm_muram muram[CONFIG_SYS_NUM_FMAN];
 
-u32 fm_muram_base(int fm_idx)
+void *fm_muram_base(int fm_idx)
 {
 	return muram[fm_idx].base;
 }
 
-u32 fm_muram_alloc(int fm_idx, u32 size, u32 align)
+void *fm_muram_alloc(int fm_idx, size_t size, ulong align)
 {
-	u32 ret;
-	u32 align_mask, off;
-	u32 save;
+	void *ret;
+	ulong align_mask;
+	size_t off;
+	void *save;
 
 	align_mask = align - 1;
 	save = muram[fm_idx].alloc;
 
-	off = save & align_mask;
+	off = (ulong)save & align_mask;
 	if (off != 0)
 		muram[fm_idx].alloc += (align - off);
 	off = size & align_mask;
@@ -45,6 +46,7 @@ u32 fm_muram_alloc(int fm_idx, u32 size, u32 align)
 	if ((muram[fm_idx].alloc + size) >= muram[fm_idx].top) {
 		muram[fm_idx].alloc = save;
 		printf("%s: run out of ram.\n", __func__);
+		return NULL;
 	}
 
 	ret = muram[fm_idx].alloc;
@@ -56,7 +58,7 @@ u32 fm_muram_alloc(int fm_idx, u32 size, u32 align)
 
 static void fm_init_muram(int fm_idx, void *reg)
 {
-	u32 base = (u32)reg;
+	void *base = reg;
 
 	muram[fm_idx].base = base;
 	muram[fm_idx].size = CONFIG_SYS_FM_MURAM_SIZE;
@@ -256,7 +258,9 @@ static void fm_init_fpm(struct fm_fpm *fpm)
 static int fm_init_bmi(int fm_idx, struct fm_bmi_common *bmi)
 {
 	int blk, i, port_id;
-	u32 val, offset, base;
+	u32 val;
+	size_t offset;
+	void *base;
 
 	/* alloc free buffer pool in MURAM */
 	base = fm_muram_alloc(fm_idx, FM_FREE_POOL_SIZE, FM_FREE_POOL_ALIGN);
drivers/net/fm/fm.h +6 -6
index a9691c6..73c525e 100644
@@ -26,10 +26,10 @@
 #define MIIM_TIMEOUT    0xFFFF
 
 struct fm_muram {
-	u32 base;
-	u32 top;
-	u32 size;
-	u32 alloc;
+	void *base;
+	void *top;
+	size_t size;
+	void *alloc;
 };
 #define FM_MURAM_RES_SIZE	0x01000
 
@@ -95,8 +95,8 @@ struct fm_port_global_pram {
 #endif
 #define FM_FREE_POOL_ALIGN	256
 
-u32 fm_muram_alloc(int fm_idx, u32 size, u32 align);
-u32 fm_muram_base(int fm_idx);
+void *fm_muram_alloc(int fm_idx, size_t size, ulong align);
+void *fm_muram_base(int fm_idx);
 int fm_init_common(int index, struct ccsr_fman *reg);
 int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info);
 phy_interface_t fman_port_enet_if(enum fm_port port);
Signature · 1 line
2.1.0.27.g96db324
#6 lore raw

PATCH v3 6/16 net/fm: Make the return value logic consistent with convention

In reply to Gong Qianyu

From: Hou Zhiqiang <[email protected]>

In convention, the '0' is a normal return value indicating there isn't an error. While some functions of FMan IM driver treat '0' as an error return value.

---
V3:
- New patch

 drivers/net/fm/eth.c | 60 +++++++++++++++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 24 deletions(-)
drivers/net/fm/eth.c +36 -24
index a5ccccc..de32814 100644
@@ -211,7 +211,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 		FM_PRAM_SIZE, FM_PRAM_ALIGN);
 	if (!pram) {
 		printf("%s: No muram for Rx global parameter\n", __func__);
-		return 0;
+		return -ENOMEM;
 	}
 
 	fm_eth->rx_pram = pram;
@@ -232,14 +232,16 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	rx_bd_ring_base = malloc(sizeof(struct fm_port_bd)
 			* RX_BD_RING_SIZE);
 	if (!rx_bd_ring_base)
-		return 0;
+		return -ENOMEM;
+
 	memset(rx_bd_ring_base, 0, sizeof(struct fm_port_bd)
 			* RX_BD_RING_SIZE);
 
 	/* alloc Rx buffer from main memory */
 	rx_buf_pool = malloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE);
 	if (!rx_buf_pool)
-		return 0;
+		return -ENOMEM;
+
 	memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE);
 	debug("%s: rx_buf_pool = %p\n", __func__, rx_buf_pool);
 
@@ -277,7 +279,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 	/* set IM parameter ram pointer to Rx Frame Queue ID */
 	out_be32(&bmi_rx_port->fmbm_rfqid, pram_page_offset);
 
-	return 1;
+	return 0;
 }
 
 static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
@@ -296,7 +298,7 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 		FM_PRAM_SIZE, FM_PRAM_ALIGN);
 	if (!pram) {
 		printf("%s: No muram for Tx global parameter\n", __func__);
-		return 0;
+		return -ENOMEM;
 	}
 	fm_eth->tx_pram = pram;
 
@@ -313,7 +315,8 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	tx_bd_ring_base = malloc(sizeof(struct fm_port_bd)
 			* TX_BD_RING_SIZE);
 	if (!tx_bd_ring_base)
-		return 0;
+		return -ENOMEM;
+
 	memset(tx_bd_ring_base, 0, sizeof(struct fm_port_bd)
 			* TX_BD_RING_SIZE);
 	/* save it to fm_eth */
@@ -344,29 +347,35 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth)
 	/* set IM parameter ram pointer to Tx Confirmation Frame Queue ID */
 	out_be32(&bmi_tx_port->fmbm_tcfqid, pram_page_offset);
 
-	return 1;
+	return 0;
 }
 
 static int fm_eth_init(struct fm_eth *fm_eth)
 {
+	int ret;
 
-	if (!fm_eth_rx_port_parameter_init(fm_eth))
-		return 0;
+	ret = fm_eth_rx_port_parameter_init(fm_eth);
+	if (ret)
+		return ret;
 
-	if (!fm_eth_tx_port_parameter_init(fm_eth))
-		return 0;
+	ret = fm_eth_tx_port_parameter_init(fm_eth);
+	if (ret)
+		return ret;
 
-	return 1;
+	return 0;
 }
 
 static int fm_eth_startup(struct fm_eth *fm_eth)
 {
 	struct fsl_enet_mac *mac;
+	int ret;
+
 	mac = fm_eth->mac;
 
 	/* Rx/TxBDs, Rx/TxQDs, Rx buff and parameter ram init */
-	if (!fm_eth_init(fm_eth))
-		return 0;
+	ret = fm_eth_init(fm_eth);
+	if (ret)
+		return ret;
 	/* setup the MAC controller */
 	mac->init_mac(mac);
 
@@ -381,7 +390,7 @@ static int fm_eth_startup(struct fm_eth *fm_eth)
 	/* init bmi tx port, IM mode and disable */
 	bmi_tx_port_init(fm_eth->tx_port);
 
-	return 1;
+	return 0;
 }
 
 static void fmc_tx_port_graceful_stop_enable(struct fm_eth *fm_eth)
@@ -628,7 +637,7 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg)
 	/* alloc mac controller */
 	mac = malloc(sizeof(struct fsl_enet_mac));
 	if (!mac)
-		return 0;
+		return -ENOMEM;
 	memset(mac, 0, sizeof(struct fsl_enet_mac));
 
 	/* save the mac to fm_eth struct */
@@ -643,7 +652,7 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg)
 		init_tgec(mac, base, phyregs, MAX_RXBUF_LEN);
 #endif
 
-	return 1;
+	return 0;
 }
 
 static int init_phy(struct eth_device *dev)
@@ -696,17 +705,18 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info)
 	struct eth_device *dev;
 	struct fm_eth *fm_eth;
 	int i, num = info->num;
+	int ret;
 
 	/* alloc eth device */
 	dev = (struct eth_device *)malloc(sizeof(struct eth_device));
 	if (!dev)
-		return 0;
+		return -ENOMEM;
 	memset(dev, 0, sizeof(struct eth_device));
 
 	/* alloc the FMan ethernet private struct */
 	fm_eth = (struct fm_eth *)malloc(sizeof(struct fm_eth));
 	if (!fm_eth)
-		return 0;
+		return -ENOMEM;
 	memset(fm_eth, 0, sizeof(struct fm_eth));
 
 	/* save off some things we need from the info struct */
@@ -721,8 +731,9 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info)
 	fm_eth->max_rx_len = MAX_RXBUF_LEN;
 
 	/* init global mac structure */
-	if (!fm_eth_init_mac(fm_eth, reg))
-		return 0;
+	ret = fm_eth_init_mac(fm_eth, reg);
+	if (ret)
+		return ret;
 
 	/* keep same as the manual, we call FMAN1, FMAN2, DTSEC1, DTSEC2, etc */
 	if (fm_eth->type == FM_ETH_1G_E)
@@ -743,8 +754,9 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info)
 	fm_eth->enet_if = info->enet_if;
 
 	/* startup the FM im */
-	if (!fm_eth_startup(fm_eth))
-		return 0;
+	ret = fm_eth_startup(fm_eth);
+	if (ret)
+		return ret;
 
 	init_phy(dev);
 
@@ -753,5 +765,5 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info)
 		dev->enetaddr[i] = 0;
 	eth_register(dev);
 
-	return 1;
+	return 0;
 }
Signature · 1 line
2.1.0.27.g96db324
#7 lore raw

PATCH v3 7/16 net/fm: bug fix when CONFIG_PHYLIB not defined

In reply to Gong Qianyu

From: Shaohui Xie <[email protected]>

phy_shutdown should be wrapped by CONFIG_PHYLIB.

---
 drivers/net/fm/eth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/fm/eth.c +2 -0
index de32814..131902b 100644
@@ -483,8 +483,10 @@ static void fm_eth_halt(struct eth_device *dev)
 	/* disable bmi Rx port */
 	bmi_rx_port_disable(fm_eth->rx_port);
 
+#ifdef CONFIG_PHYLIB
 	if (fm_eth->phydev)
 		phy_shutdown(fm_eth->phydev);
+#endif
 }
 
 static int fm_eth_send(struct eth_device *dev, void *buf, int len)
Signature · 1 line
2.1.0.27.g96db324
#8 lore raw

PATCH v3 8/16 net: Move some header files to include/

In reply to Gong Qianyu

From: Shaohui Xie <[email protected]>

The fsl_dtsec.h & fsl_tgec.h & fsl_fman.h can be shared on both ARM and PPC, move it out of ppc to include/, and change the path in drivers accordingly.

---
 arch/powerpc/include/asm/immap_85xx.h       | 2 +-
 board/freescale/b4860qds/eth_b4860qds.c     | 2 +-
 board/freescale/corenet_ds/eth_hydra.c      | 2 +-
 board/freescale/corenet_ds/eth_p4080.c      | 2 +-
 board/freescale/corenet_ds/eth_superhydra.c | 2 +-
 board/freescale/p1023rdb/p1023rdb.c         | 2 +-
 board/freescale/p2041rdb/eth.c              | 2 +-
 board/freescale/t102xqds/eth_t102xqds.c     | 2 +-
 board/freescale/t102xrdb/eth_t102xrdb.c     | 2 +-
 board/freescale/t1040qds/eth.c              | 2 +-
 board/freescale/t104xrdb/eth.c              | 2 +-
 board/freescale/t208xqds/eth_t208xqds.c     | 2 +-
 board/freescale/t208xrdb/eth_t208xrdb.c     | 2 +-
 board/freescale/t4qds/eth.c                 | 2 +-
 board/freescale/t4rdb/eth.c                 | 2 +-
 drivers/net/fm/dtsec.c                      | 2 +-
 drivers/net/fm/eth.c                        | 4 ++--
 drivers/net/fm/fm.h                         | 2 +-
 drivers/net/fm/tgec.c                       | 2 +-
 drivers/net/fm/tgec_phy.c                   | 2 +-
 20 files changed, 21 insertions(+), 21 deletions(-)
arch/powerpc/include/asm/immap_85xx.h +1 -1
index 0c9d85e..101b8db 100644
@@ -19,7 +19,7 @@
 #include <fsl_sec.h>
 #include <fsl_sfp.h>
 #include <asm/fsl_lbc.h>
-#include <asm/fsl_fman.h>
+#include <fsl_fman.h>
 #include <fsl_immap.h>
 
 typedef struct ccsr_local {
board/freescale/b4860qds/eth_b4860qds.c +1 -1
index 501d4b3..df90476 100644
@@ -26,7 +26,7 @@
 #include <fsl_mdio.h>
 #include <malloc.h>
 #include <fdt_support.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 
 #include "../common/ngpixis.h"
 #include "../common/fman.h"
board/freescale/corenet_ds/eth_hydra.c +1 -1
index 396103f..172a55b 100644
@@ -55,7 +55,7 @@
 #include <fsl_mdio.h>
 #include <malloc.h>
 #include <fdt_support.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 
 #include "../common/ngpixis.h"
 #include "../common/fman.h"
board/freescale/corenet_ds/eth_p4080.c +1 -1
index 5cbec7f..c68dc2c 100644
@@ -24,7 +24,7 @@
 
 #include "../common/ngpixis.h"
 #include "../common/fman.h"
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 
 #define EMI_NONE	0xffffffff
 #define EMI_MASK	0xf0000000
board/freescale/corenet_ds/eth_superhydra.c +1 -1
index ad1bffd..62b1635 100644
@@ -55,7 +55,7 @@
 #include <fsl_mdio.h>
 #include <malloc.h>
 #include <fdt_support.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 
 #include "../common/ngpixis.h"
 #include "../common/fman.h"
board/freescale/p1023rdb/p1023rdb.c +1 -1
index 56f561a..074b713 100644
@@ -26,7 +26,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
board/freescale/p2041rdb/eth.c +1 -1
index 532eeac..95fe85b 100644
@@ -19,7 +19,7 @@
 #include <fm_eth.h>
 #include <fsl_mdio.h>
 #include <malloc.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 
 #include "cpld.h"
 #include "../common/fman.h"
board/freescale/t102xqds/eth_t102xqds.c +1 -1
index 441d6a3..99c23f7 100644
@@ -21,7 +21,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
 #include "../common/qixis.h"
 #include "../common/fman.h"
board/freescale/t102xrdb/eth_t102xrdb.c +1 -1
index 856ec6e..02b283d 100644
@@ -21,7 +21,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
 #include "../common/fman.h"
 
board/freescale/t1040qds/eth.c +1 -1
index 8c82934..8bf34fa 100644
@@ -17,7 +17,7 @@
 #include <fm_eth.h>
 #include <fsl_mdio.h>
 #include <malloc.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <vsc9953.h>
 
 #include "../common/fman.h"
board/freescale/t104xrdb/eth.c +1 -1
index 71d0457..52cd112 100644
@@ -11,7 +11,7 @@
 #include <fm_eth.h>
 #include <fsl_mdio.h>
 #include <malloc.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <vsc9953.h>
 
 #include "../common/fman.h"
board/freescale/t208xqds/eth_t208xqds.c +1 -1
index b82e9e7..1c0ce24 100644
@@ -21,7 +21,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
 #include <hwconfig.h>
 #include "../common/qixis.h"
board/freescale/t208xrdb/eth_t208xrdb.c +1 -1
index cbbc625..ea51195 100644
@@ -21,7 +21,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
 
 int board_eth_init(bd_t *bis)
board/freescale/t4qds/eth.c +1 -1
index 9b416b1..2dfdcbb 100644
@@ -21,7 +21,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
 #include <hwconfig.h>
 #include "../common/qixis.h"
board/freescale/t4rdb/eth.c +1 -1
index 879bd1a..e563a61 100644
@@ -23,7 +23,7 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
 #include <hwconfig.h>
 
drivers/net/fm/dtsec.c +1 -1
index 8d3dc0e..b339a84 100644
@@ -7,7 +7,7 @@
 #include <common.h>
 #include <asm/types.h>
 #include <asm/io.h>
-#include <asm/fsl_dtsec.h>
+#include <fsl_dtsec.h>
 #include <fsl_mdio.h>
 #include <phy.h>
 
drivers/net/fm/eth.c +2 -2
index 131902b..a241d27 100644
@@ -13,8 +13,8 @@
 #include <fsl_mdio.h>
 #include <miiphy.h>
 #include <phy.h>
-#include <asm/fsl_dtsec.h>
-#include <asm/fsl_tgec.h>
+#include <fsl_dtsec.h>
+#include <fsl_tgec.h>
 #include <fsl_memac.h>
 
 #include "fm.h"
drivers/net/fm/fm.h +1 -1
index 73c525e..fa9bc9f 100644
@@ -10,7 +10,7 @@
 #include <common.h>
 #include <phy.h>
 #include <fm_eth.h>
-#include <asm/fsl_fman.h>
+#include <fsl_fman.h>
 
 /* Port ID */
 #define OH_PORT_ID_BASE		0x01
drivers/net/fm/tgec.c +1 -1
index 5017123..8d4622f 100644
@@ -12,7 +12,7 @@
 #include <phy.h>
 #include <asm/types.h>
 #include <asm/io.h>
-#include <asm/fsl_tgec.h>
+#include <fsl_tgec.h>
 
 #include "fm.h"
 
drivers/net/fm/tgec_phy.c +1 -1
index 095f00c..24cb17b 100644
@@ -9,7 +9,7 @@
 #include <miiphy.h>
 #include <phy.h>
 #include <asm/io.h>
-#include <asm/fsl_tgec.h>
+#include <fsl_tgec.h>
 #include <fm_eth.h>
 
 /*
Signature · 1 line
2.1.0.27.g96db324
#9 lore raw

PATCH v3 9/16 net/fm: Add QSGMII PCS init

In reply to Gong Qianyu

From: Shaohui Xie <[email protected]>

QSGMII PCS needed to be programmed same as SGMII PCS, and there are four ports in QSGMII PCS, port 0, 1, 2, 3, all the four ports shared port 0's MDIO controller, so when programming port 0, we continue to program other three ports.

---
 drivers/net/fm/eth.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/net/fm/eth.c +17 -5
index a241d27..f3ac7d0 100644
@@ -41,28 +41,39 @@ static void dtsec_configure_serdes(struct fm_eth *priv)
 	bus.priv = priv->mac->phyregs;
 	bool sgmii_2500 = (priv->enet_if ==
 			PHY_INTERFACE_MODE_SGMII_2500) ? true : false;
+	int i = 0;
+
+qsgmii_loop:
+	if ((priv->enet_if == PHY_INTERFACE_MODE_QSGMII) &&
+	    ((priv->phyaddr % 4) != 0))
+		return;
 
 	/* SGMII IF mode + AN enable only for 1G SGMII, not for 2.5G */
 	value = PHY_SGMII_IF_MODE_SGMII;
 	if (!sgmii_2500)
 		value |= PHY_SGMII_IF_MODE_AN;
 
-	memac_mdio_write(&bus, 0, MDIO_DEVAD_NONE, 0x14, value);
+	memac_mdio_write(&bus, i, MDIO_DEVAD_NONE, 0x14, value);
 
 	/* Dev ability according to SGMII specification */
 	value = PHY_SGMII_DEV_ABILITY_SGMII;
-	memac_mdio_write(&bus, 0, MDIO_DEVAD_NONE, 0x4, value);
+	memac_mdio_write(&bus, i, MDIO_DEVAD_NONE, 0x4, value);
 
 	/* Adjust link timer for SGMII  -
 	1.6 ms in units of 8 ns = 2 * 10^5 = 0x30d40 */
-	memac_mdio_write(&bus, 0, MDIO_DEVAD_NONE, 0x13, 0x3);
-	memac_mdio_write(&bus, 0, MDIO_DEVAD_NONE, 0x12, 0xd40);
+	memac_mdio_write(&bus, i, MDIO_DEVAD_NONE, 0x13, 0x3);
+	memac_mdio_write(&bus, i, MDIO_DEVAD_NONE, 0x12, 0xd40);
 
 	/* Restart AN */
 	value = PHY_SGMII_CR_DEF_VAL;
 	if (!sgmii_2500)
 		value |= PHY_SGMII_CR_RESET_AN;
-	memac_mdio_write(&bus, 0, MDIO_DEVAD_NONE, 0, value);
+	memac_mdio_write(&bus, i, MDIO_DEVAD_NONE, 0, value);
+
+	if ((priv->enet_if == PHY_INTERFACE_MODE_QSGMII) && (i < 3)) {
+		i++;
+		goto qsgmii_loop;
+	}
 #else
 	struct dtsec *regs = priv->mac->base;
 	struct tsec_mii_mng *phyregs = priv->mac->phyregs;
@@ -91,6 +102,7 @@ static void dtsec_init_phy(struct eth_device *dev)
 #endif
 
 	if (fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII ||
+	    fm_eth->enet_if == PHY_INTERFACE_MODE_QSGMII ||
 	    fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII_2500)
 		dtsec_configure_serdes(fm_eth);
 }
Signature · 1 line
2.1.0.27.g96db324
#10 lore raw

PATCH v3 10/16 net/fm: fix MDIO controller base on FMAN2

In reply to Gong Qianyu

From: Shaohui Xie <[email protected]>

MDIO controller base on FMAN2 was defined as CONFIG_SYS_FSL_FM2_ADDR plus offset, but CONFIG_SYS_FSL_FM2_ADDR only defined when there are two FMANs, so we should only define MDIO controller base on FMAN2 when there is FMAN2.

---
 include/fm_eth.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/fm_eth.h +17 -0
index 3e1b9f4..d43f801 100644
@@ -45,8 +45,10 @@ enum fm_eth_type {
 #ifdef CONFIG_SYS_FMAN_V3
 #define CONFIG_SYS_FM1_DTSEC_MDIO_ADDR	(CONFIG_SYS_FSL_FM1_ADDR + 0xfc000)
 #define CONFIG_SYS_FM1_TGEC_MDIO_ADDR	(CONFIG_SYS_FSL_FM1_ADDR + 0xfd000)
+#if (CONFIG_SYS_NUM_FMAN == 2)
 #define CONFIG_SYS_FM2_DTSEC_MDIO_ADDR	(CONFIG_SYS_FSL_FM2_ADDR + 0xfc000)
 #define CONFIG_SYS_FM2_TGEC_MDIO_ADDR	(CONFIG_SYS_FSL_FM2_ADDR + 0xfd000)
+#endif
 #else
 #define CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR	(CONFIG_SYS_FSL_FM1_ADDR + 0xe1120)
 #define CONFIG_SYS_FM1_TGEC_MDIO_ADDR	(CONFIG_SYS_FSL_FM1_ADDR + 0xf1000)
@@ -89,6 +91,7 @@ enum fm_eth_type {
 				 offsetof(struct ccsr_fman, memac[n-1]),\
 }
 #else
+#if (CONFIG_SYS_NUM_FMAN == 2)
 #define FM_TGEC_INFO_INITIALIZER(idx, n) \
 {									\
 	FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM2_TGEC_MDIO_ADDR)	\
@@ -101,6 +104,20 @@ enum fm_eth_type {
 	.compat_offset	= CONFIG_SYS_FSL_FM##idx##_OFFSET +		\
 				offsetof(struct ccsr_fman, memac[n-1+8]),\
 }
+#else
+#define FM_TGEC_INFO_INITIALIZER(idx, n) \
+{									\
+	FM_ETH_INFO_INITIALIZER(idx, CONFIG_SYS_FM1_TGEC_MDIO_ADDR)	\
+	.index		= idx,						\
+	.num		= n - 1,					\
+	.type		= FM_ETH_10G_E,					\
+	.port		= FM##idx##_10GEC##n,				\
+	.rx_port_id	= RX_PORT_10G_BASE + n - 1,			\
+	.tx_port_id	= TX_PORT_10G_BASE + n - 1,			\
+	.compat_offset	= CONFIG_SYS_FSL_FM##idx##_OFFSET +		\
+				offsetof(struct ccsr_fman, memac[n-1+8]),\
+}
+#endif
 #endif
 
 #if (CONFIG_SYS_NUM_FM1_10GEC >= 3)
Signature · 1 line
2.1.0.27.g96db324
#11 lore raw

PATCH v3 11/16 ARMv8/FSL_LSCH2: Add FSL_LSCH2 SoC

In reply to Gong Qianyu

From: Mingkai Hu <[email protected]>

Freescale LayerScape with Chassis Generation 2 is a set of SoCs with ARMv8 cores and 2rd generation of Chassis.

---
V3:
- Update MMU table initialization to match the latest code.
- Remove some dead code
- Rename #include<asm/arch-fsl-lsch2/xxx> to #include<asm/arch/xxx>

 arch/arm/cpu/armv8/Makefile                       |   1 +
 arch/arm/cpu/armv8/fsl-lsch2/Makefile             |  12 +
 arch/arm/cpu/armv8/fsl-lsch2/README               |  10 +
 arch/arm/cpu/armv8/fsl-lsch2/cpu.c                | 527 ++++++++++++++++++++++
 arch/arm/cpu/armv8/fsl-lsch2/fdt.c                |  13 +
 arch/arm/cpu/armv8/fsl-lsch2/fsl_lsch2_serdes.c   | 116 +++++
 arch/arm/cpu/armv8/fsl-lsch2/lowlevel.S           | 122 +++++
 arch/arm/cpu/armv8/fsl-lsch2/ls1043a_serdes.c     |  86 ++++
 arch/arm/cpu/armv8/fsl-lsch2/soc.c                |  36 ++
 arch/arm/cpu/armv8/fsl-lsch2/speed.c              | 137 ++++++
 arch/arm/cpu/armv8/fsl-lsch2/speed.h              |   7 +
 arch/arm/include/asm/arch-fsl-lsch2/clock.h       |  24 +
 arch/arm/include/asm/arch-fsl-lsch2/config.h      | 151 +++++++
 arch/arm/include/asm/arch-fsl-lsch2/fsl_serdes.h  | 105 +++++
 arch/arm/include/asm/arch-fsl-lsch2/immap_lsch2.h | 490 ++++++++++++++++++++
 arch/arm/include/asm/arch-fsl-lsch2/imx-regs.h    |  52 +++
 arch/arm/include/asm/arch-fsl-lsch2/mmu.h         |  10 +
 arch/arm/include/asm/arch-fsl-lsch2/ns_access.h   | 158 +++++++
 arch/arm/include/asm/arch-fsl-lsch2/soc.h         |   7 +
 arch/arm/include/asm/arch-fsl-lsch2/spl.h         |  20 +
 arch/arm/include/asm/armv8/mmu.h                  |   1 +
 include/common.h                                  |   3 +
 22 files changed, 2088 insertions(+)
arch/arm/cpu/armv8/Makefile +1 -0
index adb11b3..eee8344 100644
@@ -15,6 +15,7 @@ obj-y	+= cache.o
 obj-y	+= tlb.o
 obj-y	+= transition.o
 
+obj-$(CONFIG_FSL_LSCH2) += fsl-lsch2/
 obj-$(CONFIG_FSL_LSCH3) += fsl-lsch3/
 obj-$(CONFIG_ARCH_ZYNQMP) += zynqmp/
 obj-$(CONFIG_TARGET_HIKEY) += hisilicon/
arch/arm/cpu/armv8/fsl-lsch2/Makefile new file +12 -0
new file mode 100644
index 0000000..9d2ac43
@@ -0,0 +1,12 @@
+#
+# Copyright 2015, Freescale Semiconductor
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += cpu.o
+obj-y += lowlevel.o
+obj-y += soc.o
+obj-y += speed.o
+obj-$(CONFIG_SYS_HAS_SERDES) += fsl_lsch2_serdes.o ls1043a_serdes.o
+obj-$(CONFIG_OF_LIBFDT) += fdt.o
arch/arm/cpu/armv8/fsl-lsch2/README new file +10 -0
new file mode 100644
index 0000000..a6ef830
@@ -0,0 +1,10 @@
+#
+# Copyright 2015 Freescale Semiconductor
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+Freescale LayerScape with Chassis Generation 2
+
+This architecture supports Freescale ARMv8 SoCs with Chassis generation 2,
+for example LS1043A.
arch/arm/cpu/armv8/fsl-lsch2/cpu.c new file +527 -0

527 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch2/fdt.c new file +13 -0
new file mode 100644
index 0000000..015ad76
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <libfdt.h>
+#include <fdt_support.h>
+
+void ft_cpu_setup(void *blob, bd_t *bd)
+{
+}
arch/arm/cpu/armv8/fsl-lsch2/fsl_lsch2_serdes.c new file +116 -0

116 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch2/lowlevel.S new file +122 -0

122 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch2/ls1043a_serdes.c new file +86 -0

86 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch2/soc.c new file +36 -0
new file mode 100644
index 0000000..7839bf7
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <fsl_ifc.h>
+#include <asm/arch/soc.h>
+#include <asm/io.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void fsl_lsch2_early_init_f(void)
+{
+	struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
+
+#ifdef CONFIG_FSL_IFC
+	init_early_memctl_regs();	/* tighten IFC timing */
+#endif
+
+	/*
+	 * Enable snoop requests and DVM message requests for
+	 * Slave insterface S4 (A53 core cluster)
+	 */
+	out_le32(&cci->slave[4].snoop_ctrl,
+		 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
+}
+
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+	return 0;
+}
+#endif
arch/arm/cpu/armv8/fsl-lsch2/speed.c new file +137 -0

137 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch2/speed.h new file +7 -0
new file mode 100644
index 0000000..c5497b5
@@ -0,0 +1,7 @@
+/*
+ * Copyright 2015, Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+void get_sys_info(struct sys_info *sys_info);
arch/arm/include/asm/arch-fsl-lsch2/clock.h new file +24 -0
new file mode 100644
index 0000000..705c9bf
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __ASM_ARCH_FSL_LSCH2_CLOCK_H_
+#define __ASM_ARCH_FSL_LSCH2_CLOCK_H_
+
+#include <common.h>
+
+enum mxc_clock {
+	MXC_ARM_CLK = 0,
+	MXC_BUS_CLK,
+	MXC_UART_CLK,
+	MXC_ESDHC_CLK,
+	MXC_I2C_CLK,
+	MXC_DSPI_CLK,
+};
+
+unsigned int mxc_get_clock(enum mxc_clock clk);
+
+#endif /* __ASM_ARCH_FSL_LSCH2_CLOCK_H_ */
arch/arm/include/asm/arch-fsl-lsch2/config.h new file +151 -0

151 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch2/fsl_serdes.h new file +105 -0

105 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch2/immap_lsch2.h new file +490 -0

490 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch2/imx-regs.h new file +52 -0

52 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch2/mmu.h new file +10 -0
new file mode 100644
index 0000000..d1d3481
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2015, Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARMV8_FSL_LSCH2_MMU_H_
+#define _ASM_ARMV8_FSL_LSCH2_MMU_H_
+#include <asm/arch-armv8/mmu.h>
+#endif /* _ASM_ARMV8_FSL_LSCH2_MMU_H_ */
arch/arm/include/asm/arch-fsl-lsch2/ns_access.h new file +158 -0

158 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch2/soc.h new file +7 -0
new file mode 100644
index 0000000..73f7de5
@@ -0,0 +1,7 @@
+/*
+ * Copyright 2015 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+void fsl_lsch2_early_init_f(void);
arch/arm/include/asm/arch-fsl-lsch2/spl.h new file +20 -0
new file mode 100644
index 0000000..356a338
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_ARCH_SPL_H__
+#define __ASM_ARCH_SPL_H__
+
+#define BOOT_DEVICE_NONE	0
+#define BOOT_DEVICE_XIP         1
+#define BOOT_DEVICE_XIPWAIT     2
+#define BOOT_DEVICE_NAND	3
+#define BOOT_DEVICE_ONENAND	4
+#define BOOT_DEVICE_MMC1	5
+#define BOOT_DEVICE_MMC2	6
+#define BOOT_DEVICE_MMC2_2	7
+#define BOOT_DEVICE_SPI		10
+
+#endif	/* __ASM_ARCH_SPL_H__ */
arch/arm/include/asm/armv8/mmu.h +1 -0
index 0c928d4..50e3a83 100644
@@ -65,6 +65,7 @@
 /*
  * Section
  */
+#define PMD_SECT_NS		(1 << 5)
 #define PMD_SECT_NON_SHARE	(0 << 8)
 #define PMD_SECT_OUTER_SHARE	(2 << 8)
 #define PMD_SECT_INNER_SHARE	(3 << 8)
include/common.h +3 -0
index 68b24d0..ed02104 100644
@@ -76,6 +76,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_SOC_DA8XX
 #include <asm/arch/hardware.h>
 #endif
+#ifdef CONFIG_FSL_LSCH2
+#include <asm/arch/immap_lsch2.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
Signature · 1 line
2.1.0.27.g96db324
#12 lore raw

PATCH v3 11/16 ARMv8/FSL_LSCH2: Add FSL_LSCH2 SoC

Quoted 15 lines · Gong Qianyu

From: Mingkai Hu <[email protected]>

Freescale LayerScape with Chassis Generation 2 is a set of SoCs with ARMv8 cores and 2rd generation of Chassis.

---
V3:
- Update MMU table initialization to match the latest code.
- Remove some dead code
- Rename #include<asm/arch-fsl-lsch2/xxx> to #include<asm/arch/xxx>

Quoted 4 lines
 arch/arm/cpu/armv8/Makefile                       |   1 +
 arch/arm/cpu/armv8/fsl-lsch2/Makefile             |  12 +
 arch/arm/cpu/armv8/fsl-lsch2/README               |  10 +
 arch/arm/cpu/armv8/fsl-lsch2/cpu.c                | 527 ++++++++++++++++++++++

NACK. Do NOT duplicate massive code. Please consolidate fsl-lsch3 and fsl-lsc2 and move common code out.

York

#13 lore raw

PATCH v3 12/16 armv8/ls1043ardb: Add LS1043ARDB board support

In reply to Gong Qianyu

From: Mingkai Hu <[email protected]>

LS1043ARDB Specification:
-------------------------
Memory subsystem:
* 2GByte DDR4 SDRAM (32bit bus)
* 128 Mbyte NOR flash single-chip memory
* 512 Mbyte NAND flash
* 16 Mbyte high-speed SPI flash
* SD connector to interface with the SD memory card

Ethernet:
* XFI 10G port
* QSGMII with 4x 1G ports
* Two RGMII ports

PCIe:
* PCIe2 (Lanes C) to mini-PCIe slot
* PCIe3 (Lanes D) to PCIe slot

USB 3.0: two super speed USB 3.0 type A ports

UART: supports two UARTs up to 115200 bps for console

---
V3:
- Fix message typos.
- Add ddr model number in comments.
- Fix boot options in README.
- Remove some dead code.

 arch/arm/Kconfig                        |   7 ++
 board/freescale/ls1043ardb/Kconfig      |  16 +++
 board/freescale/ls1043ardb/MAINTAINERS  |   7 ++
 board/freescale/ls1043ardb/Makefile     |   9 ++
 board/freescale/ls1043ardb/README       |  85 ++++++++++++++
 board/freescale/ls1043ardb/cpld.c       | 115 +++++++++++++++++++
 board/freescale/ls1043ardb/cpld.h       |  43 +++++++
 board/freescale/ls1043ardb/ddr.c        | 191 ++++++++++++++++++++++++++++++++
 board/freescale/ls1043ardb/ddr.h        |  45 ++++++++
 board/freescale/ls1043ardb/ls1043ardb.c | 134 ++++++++++++++++++++++
 configs/ls1043ardb_defconfig            |   3 +
 drivers/i2c/mxc_i2c.c                   |   2 +-
 include/configs/ls1043a_common.h        | 134 ++++++++++++++++++++++
 include/configs/ls1043ardb.h            | 191 ++++++++++++++++++++++++++++++++
 14 files changed, 981 insertions(+), 1 deletion(-)
arch/arm/Kconfig +7 -0
index c4371c7..5faf8c8 100644
@@ -616,6 +616,12 @@ config TARGET_LS1021ATWR
 	select CPU_V7
 	select SUPPORT_SPL
 
+config TARGET_LS1043ARDB
+	bool "Support ls1043ardb"
+	select ARM64
+	help
+	  Support for Freescale LS1043ARDB platform.
+
 config TARGET_H2200
 	bool "Support h2200"
 	select CPU_PXA
@@ -730,6 +736,7 @@ source "board/freescale/ls2085aqds/Kconfig"
 source "board/freescale/ls2085ardb/Kconfig"
 source "board/freescale/ls1021aqds/Kconfig"
 source "board/freescale/ls1021atwr/Kconfig"
+source "board/freescale/ls1043ardb/Kconfig"
 source "board/freescale/mx23evk/Kconfig"
 source "board/freescale/mx25pdk/Kconfig"
 source "board/freescale/mx28evk/Kconfig"
board/freescale/ls1043ardb/Kconfig new file +16 -0
new file mode 100644
index 0000000..eb6a12a
@@ -0,0 +1,16 @@
+
+if TARGET_LS1043ARDB
+
+config SYS_BOARD
+	default "ls1043ardb"
+
+config SYS_VENDOR
+	default "freescale"
+
+config SYS_SOC
+	default "fsl-lsch2"
+
+config SYS_CONFIG_NAME
+	default "ls1043ardb"
+
+endif
board/freescale/ls1043ardb/MAINTAINERS new file +7 -0
new file mode 100644
index 0000000..b8f6be2
@@ -0,0 +1,7 @@
+LS1043A BOARD
+M:	Mingkai Hu <[email protected]>
+S:	Maintained
+F:	board/freescale/ls1043ardb/
+F:	board/freescale/ls1043ardb/ls1043ardb.c
+F:	include/configs/ls1043ardb.h
+F:	configs/ls1043ardb_defconfig
board/freescale/ls1043ardb/Makefile new file +9 -0
new file mode 100644
index 0000000..dd17e2e
@@ -0,0 +1,9 @@
+#
+# Copyright 2015 Freescale Semiconductor
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += cpld.o
+obj-y += ddr.o
+obj-y += ls1043ardb.o
board/freescale/ls1043ardb/README new file +85 -0

85 lines not on this page · raw message

board/freescale/ls1043ardb/cpld.c new file +115 -0

115 lines not on this page · raw message

board/freescale/ls1043ardb/cpld.h new file +43 -0

43 lines not on this page · raw message

board/freescale/ls1043ardb/ddr.c new file +191 -0

191 lines not on this page · raw message

board/freescale/ls1043ardb/ddr.h new file +45 -0

45 lines not on this page · raw message

board/freescale/ls1043ardb/ls1043ardb.c new file +134 -0

134 lines not on this page · raw message

configs/ls1043ardb_defconfig new file +3 -0
new file mode 100644
index 0000000..62a96aa
@@ -0,0 +1,3 @@
+CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4"
+CONFIG_ARM=y
+CONFIG_TARGET_LS1043ARDB=y
drivers/i2c/mxc_i2c.c +1 -1
index f1056e2..2c84847 100644
@@ -524,7 +524,7 @@ static int bus_i2c_write(struct mxc_i2c_bus *i2c_bus, u8 chip, u32 addr,
 
 static struct mxc_i2c_bus mxc_i2c_buses[] = {
 #if defined(CONFIG_LS102XA) || defined(CONFIG_FSL_LSCH3) || \
-		defined(CONFIG_VF610)
+		defined(CONFIG_VF610) || defined(CONFIG_FSL_LSCH2)
 	{ 0, I2C1_BASE_ADDR, I2C_QUIRK_FLAG },
 	{ 1, I2C2_BASE_ADDR, I2C_QUIRK_FLAG },
 	{ 2, I2C3_BASE_ADDR, I2C_QUIRK_FLAG },
include/configs/ls1043a_common.h new file +134 -0

134 lines not on this page · raw message

include/configs/ls1043ardb.h new file +191 -0

191 lines not on this page · raw message

Signature · 1 line
2.1.0.27.g96db324
#14 lore raw

PATCH v3 13/16 armv8/ls1043ardb: Add nand boot support

In reply to Gong Qianyu
---
 arch/arm/Kconfig                                   |  1 +
 arch/arm/cpu/armv8/fsl-lsch2/Makefile              |  1 +
 arch/arm/cpu/armv8/fsl-lsch2/spl.c                 | 79 ++++++++++++++++++++++
 board/freescale/ls1043ardb/README                  |  1 +
 board/freescale/ls1043ardb/cpld.c                  | 18 +++++
 board/freescale/ls1043ardb/cpld.h                  |  1 +
 board/freescale/ls1043ardb/ls1043ardb_pbi.cfg      | 14 ++++
 board/freescale/ls1043ardb/ls1043ardb_rcw_nand.cfg |  7 ++
 configs/ls1043ardb_nand_defconfig                  |  4 ++
 include/configs/ls1043a_common.h                   | 27 ++++++++
 include/configs/ls1043ardb.h                       | 46 +++++++++++++
 11 files changed, 199 insertions(+)
arch/arm/Kconfig +1 -0
index 5faf8c8..f487d13 100644
@@ -619,6 +619,7 @@ config TARGET_LS1021ATWR
 config TARGET_LS1043ARDB
 	bool "Support ls1043ardb"
 	select ARM64
+	select SUPPORT_SPL
 	help
 	  Support for Freescale LS1043ARDB platform.
 
arch/arm/cpu/armv8/fsl-lsch2/Makefile +1 -0
index 9d2ac43..12d0b5a 100644
@@ -10,3 +10,4 @@ obj-y += soc.o
 obj-y += speed.o
 obj-$(CONFIG_SYS_HAS_SERDES) += fsl_lsch2_serdes.o ls1043a_serdes.o
 obj-$(CONFIG_OF_LIBFDT) += fdt.o
+obj-$(CONFIG_SPL) += spl.o
arch/arm/cpu/armv8/fsl-lsch2/spl.c new file +79 -0

79 lines not on this page · raw message

board/freescale/ls1043ardb/README +1 -0
index d5925a9..4f15557 100644
@@ -83,3 +83,4 @@ Start Address	End Address	Description		Size
 Booting Options
 ---------------
 a) NOR boot
+b) NAND boot
board/freescale/ls1043ardb/cpld.c +18 -0
index 3f1101e..5acb97d 100644
@@ -45,6 +45,21 @@ void cpld_set_defbank(void)
 	CPLD_WRITE(global_rst, 1);
 }
 
+void cpld_set_nand(void)
+{
+	u16 reg = CPLD_CFG_RCW_SRC_NAND;
+	u8 reg5 = (u8)(reg >> 1);
+	u8 reg6 = (u8)(reg & 1);
+	cpld_rev_bit(&reg5);
+
+	CPLD_WRITE(soft_mux_on, 1);
+
+	CPLD_WRITE(cfg_rcw_src1, reg5);
+	CPLD_WRITE(cfg_rcw_src2, reg6);
+
+	CPLD_WRITE(system_rst, 1);
+}
+
 #ifdef DEBUG
 static void cpld_dump_regs(void)
 {
@@ -91,6 +106,8 @@ int do_cpld(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (strcmp(argv[1], "reset") == 0) {
 		if (strcmp(argv[2], "altbank") == 0)
 			cpld_set_altbank();
+		else if (strcmp(argv[2], "nand") == 0)
+			cpld_set_nand();
 		else
 			cpld_set_defbank();
 #ifdef DEBUG
@@ -109,6 +126,7 @@ U_BOOT_CMD(
 	"Reset the board or alternate bank",
 	"reset: reset to default bank\n"
 	"cpld reset altbank: reset to alternate bank\n"
+	"cpld reset nand: reset to boot from NAND flash\n"
 #ifdef DEBUG
 	"cpld dump - display the CPLD registers\n"
 #endif
board/freescale/ls1043ardb/cpld.h +1 -0
index ea4efd8..5f43a8a 100644
@@ -40,4 +40,5 @@ void cpld_rev_bit(unsigned char *value);
 #define CPLD_SW_MUX_BANK_SEL	0x40
 #define CPLD_BANK_SEL_MASK	0x07
 #define CPLD_BANK_SEL_ALTBANK	0x04
+#define CPLD_CFG_RCW_SRC_NAND	0x106
 #endif
board/freescale/ls1043ardb/ls1043ardb_pbi.cfg new file +14 -0
new file mode 100644
index 0000000..f072274
@@ -0,0 +1,14 @@
+#Configure Scratch register
+09570600 00000000
+09570604 10000000
+#Alt base register
+09570158 00001000
+#Disable CCI barrier tranaction
+09570178 0000e010
+09180000 00000008
+#USB PHY frequency sel
+09570418 0000009e
+0957041c 0000009e
+09570420 0000009e
+#flush PBI data
+096100c0 000fffff
board/freescale/ls1043ardb/ls1043ardb_rcw_nand.cfg new file +7 -0
new file mode 100644
index 0000000..935ffc0
@@ -0,0 +1,7 @@
+#PBL preamble and RCW header
+aa55aa55 01ee0100
+# serdes protocol
+0810000f 0c000000 00000000 00000000
+14550002 80004012 e0106000 61002000
+00000000 00000000 00000000 00038800
+00000000 00001100 00000096 00000001
configs/ls1043ardb_nand_defconfig new file +4 -0
new file mode 100644
index 0000000..fffaca0
@@ -0,0 +1,4 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,NAND_BOOT,SYS_FSL_DDR4"
+CONFIG_ARM=y
+CONFIG_TARGET_LS1043ARDB=y
include/configs/ls1043a_common.h +27 -0
index 103fc1b..9491752 100644
@@ -57,6 +57,33 @@
 #define CONFIG_BAUDRATE			115200
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }
 
+/* NAND SPL */
+#ifdef CONFIG_NAND_BOOT
+#define CONFIG_SPL_PBL_PAD
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_LDSCRIPT		"arch/arm/cpu/armv8/u-boot-spl.lds"
+#define CONFIG_SPL_TARGET		"u-boot-with-spl.bin"
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_ENV_SUPPORT
+#define CONFIG_SPL_WATCHDOG_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
+#define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SPL_DRIVERS_MISC_SUPPORT
+#define CONFIG_SPL_TEXT_BASE		0x10000000
+#define CONFIG_SPL_MAX_SIZE		0x1a000
+#define CONFIG_SPL_STACK		0x1001d000
+#define CONFIG_SYS_NAND_U_BOOT_DST	CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_NAND_U_BOOT_START	CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_SPL_MALLOC_START	0x80200000
+#define CONFIG_SPL_BSS_START_ADDR	0x80100000
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000
+#define CONFIG_SYS_MONITOR_LEN		0xa0000
+#endif
+
 /* IFC */
 #define CONFIG_FSL_IFC
 /*
include/configs/ls1043ardb.h +46 -0

86 lines not on this page · raw message

Signature · 1 line
2.1.0.27.g96db324
#15 lore raw

PATCH v3 14/16 armv8/ls1043a: Add Fman support

In reply to Gong Qianyu

From: Shaohui Xie <[email protected]>

---
 arch/arm/cpu/armv8/fsl-lsch2/cpu.c      |  19 +++++
 arch/arm/cpu/armv8/fsl-lsch2/fdt.c      |   7 ++
 arch/arm/cpu/armv8/fsl-lsch2/speed.c    |  23 ++++++
 board/freescale/common/fman.c           |   6 +-
 board/freescale/ls1043ardb/Makefile     |   1 +
 board/freescale/ls1043ardb/eth.c        |  77 +++++++++++++++++++++
 board/freescale/ls1043ardb/ls1043ardb.c |   4 ++
 doc/README.fsl-dpaa                     |   4 +-
 drivers/net/fm/Makefile                 |   1 +
 drivers/net/fm/init.c                   |  10 ++-
 drivers/net/fm/ls1043.c                 | 119 ++++++++++++++++++++++++++++++++
 include/configs/ls1043a_common.h        |  12 ++++
 include/configs/ls1043ardb.h            |  25 +++++++
 13 files changed, 303 insertions(+), 5 deletions(-)
arch/arm/cpu/armv8/fsl-lsch2/cpu.c +19 -0
index ef11c1c..ef63770 100644
@@ -12,6 +12,7 @@
 #include <asm/io.h>
 #include <asm/arch/immap_lsch2.h>
 #include <asm/arch/fsl_serdes.h>
+#include <fm_eth.h>
 #include "speed.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -471,6 +472,9 @@ int print_cpuinfo(void)
 	printf("\n       Bus:      %-4s MHz  ",
 	       strmhz(buf, sysinfo.freq_systembus));
 	printf("DDR:      %-4s MT/s", strmhz(buf, sysinfo.freq_ddrbus));
+#ifdef CONFIG_SYS_DPAA_FMAN
+	printf("  FMAN:     %-4s MHz", strmhz(buf, sysinfo.freq_fman[0]));
+#endif
 	puts("\n");
 
 	/*
@@ -491,11 +495,26 @@ int print_cpuinfo(void)
 }
 #endif
 
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
+{
+#ifdef CONFIG_FMAN_ENET
+	fm_standard_init(bis);
+#endif
+	return 0;
+}
+
 int arch_early_init_r(void)
 {
 #ifdef CONFIG_SYS_HAS_SERDES
 	fsl_serdes_init();
 #endif
+#ifdef CONFIG_FMAN_ENET
+	fman_enet_init();
+#endif
 	return 0;
 }
 
arch/arm/cpu/armv8/fsl-lsch2/fdt.c +7 -0
index 015ad76..a646faa 100644
@@ -7,6 +7,13 @@
 #include <common.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+#include <phy.h>
+
+int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
+{
+	return fdt_setprop_string(blob, offset, "phy-connection-type",
+					 phy_string_for_interface(phyc));
+}
 
 void ft_cpu_setup(void *blob, bd_t *bd)
 {
arch/arm/cpu/armv8/fsl-lsch2/speed.c +23 -0
index 68cb5c2..3bc6401 100644
@@ -25,6 +25,9 @@ void get_sys_info(struct sys_info *sys_info)
 	struct fsl_ifc ifc_regs = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL};
 	u32 ccr;
 #endif
+#ifdef CONFIG_SYS_DPAA_FMAN
+	u32 rcw_tmp;
+#endif
 	struct ccsr_clk *clk = (void *)(CONFIG_SYS_FSL_CLK_ADDR);
 	unsigned int cpu;
 	const u8 core_cplx_pll[8] = {
@@ -79,6 +82,26 @@ void get_sys_info(struct sys_info *sys_info)
 
 #define HWA_CGA_M1_CLK_SEL	0xe0000000
 #define HWA_CGA_M1_CLK_SHIFT	29
+#ifdef CONFIG_SYS_DPAA_FMAN
+	rcw_tmp = in_be32(&gur->rcwsr[7]);
+	switch ((rcw_tmp & HWA_CGA_M1_CLK_SEL) >> HWA_CGA_M1_CLK_SHIFT) {
+	case 2:
+		sys_info->freq_fman[0] = freq_c_pll[0] / 2;
+		break;
+	case 3:
+		sys_info->freq_fman[0] = freq_c_pll[0] / 3;
+		break;
+	case 6:
+		sys_info->freq_fman[0] = freq_c_pll[1] / 2;
+		break;
+	case 7:
+		sys_info->freq_fman[0] = freq_c_pll[1] / 3;
+		break;
+	default:
+		printf("Error: Unknown FMan1 clock select!\n");
+		break;
+	}
+#endif
 
 #define HWA_CGA_M2_CLK_SEL	0x00000007
 #define HWA_CGA_M2_CLK_SHIFT	0
board/freescale/common/fman.c +5 -1
index 9dc5402..e491064 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011-2015 Freescale Semiconductor, Inc.
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -10,7 +10,11 @@
 #include <fdt_support.h>
 
 #include <fm_eth.h>
+#ifdef CONFIG_FSL_LSCH2
+#include <asm/arch/fsl_serdes.h>
+#else
 #include <asm/fsl_serdes.h>
+#endif
 
 /*
  * Given the following ...
board/freescale/ls1043ardb/Makefile +1 -0
index dd17e2e..5fe1cc9 100644
@@ -7,3 +7,4 @@
 obj-y += cpld.o
 obj-y += ddr.o
 obj-y += ls1043ardb.o
+obj-$(CONFIG_SYS_DPAA_FMAN) += eth.o
board/freescale/ls1043ardb/eth.c new file +77 -0

77 lines not on this page · raw message

board/freescale/ls1043ardb/ls1043ardb.c +4 -0
index 47c00e8..5a2f3bd 100644
@@ -14,6 +14,7 @@
 #include <hwconfig.h>
 #include <ahci.h>
 #include <scsi.h>
+#include <fm_eth.h>
 #include <fsl_csu.h>
 #include <fsl_esdhc.h>
 #include <fsl_ifc.h>
@@ -111,6 +112,9 @@ int misc_init_r(void)
 
 int ft_board_setup(void *blob, bd_t *bd)
 {
+#ifdef CONFIG_SYS_DPAA_FMAN
+	fdt_fixup_fman_ethernet(blob);
+#endif
 	return 0;
 }
 
doc/README.fsl-dpaa +2 -2
index 0d8d4f6..3ef5eeb 100644
@@ -2,9 +2,9 @@ This file documents Freescale DPAA-specific options.
 
 FMan (Frame Manager)
   - CONFIG_FSL_FM_10GEC_REGULAR_NOTATION
-	on SoCs earlier(e.g. T4240, T2080), the notation between 10GEC and MAC as below:
+	on SoCs T4240, T2080, LS1043A, etc, the notation between 10GEC and MAC as below:
 		10GEC1->MAC9, 10GEC2->MAC10, 10GEC3->MAC1, 10GEC4->MAC2
-	on SoCs later(e.g. T1024, etc), the notation between 10GEC and MAC as below:
+	on SoCs T1024, etc, the notation between 10GEC and MAC as below:
 		10GEC1->MAC1, 10GEC2->MAC2
 	so we introduce CONFIG_FSL_FM_10GEC_REGULAR_NOTATION to identify the new SoCs on
 	which 10GEC enumeration is consistent with MAC enumeration.
drivers/net/fm/Makefile +1 -0
index d052fcb..a3c9f99 100644
@@ -37,3 +37,4 @@ obj-$(CONFIG_PPC_T4160) += t4240.o
 obj-$(CONFIG_PPC_T4080) += t4240.o
 obj-$(CONFIG_PPC_B4420) += b4860.o
 obj-$(CONFIG_PPC_B4860) += b4860.o
+obj-$(CONFIG_LS1043A)	+= ls1043.o
drivers/net/fm/init.c +8 -2
index b3ff4c5..00a036c 100644
@@ -1,13 +1,17 @@
 /*
- * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011-2015 Freescale Semiconductor, Inc.
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <errno.h>
 #include <common.h>
 #include <asm/io.h>
-#include <asm/fsl_serdes.h>
 #include <fsl_mdio.h>
+#ifdef CONFIG_FSL_LSCH2
+#include <asm/arch/fsl_serdes.h>
+#else
+#include <asm/fsl_serdes.h>
+#endif
 
 #include "fm.h"
 
@@ -153,7 +157,9 @@ void fm_disable_port(enum fm_port port)
 		return;
 
 	fm_info[i].enabled = 0;
+#ifndef CONFIG_SYS_FMAN_V3
 	fman_disable_port(port);
+#endif
 }
 
 void fm_enable_port(enum fm_port port)
drivers/net/fm/ls1043.c new file +119 -0

119 lines not on this page · raw message

include/configs/ls1043a_common.h +12 -0
index 9491752..3cb013d 100644
@@ -115,6 +115,18 @@
 #define CONFIG_CMD_ENV
 #define CONFIG_CMD_PING
 
+/* FMan ucode */
+#define CONFIG_SYS_DPAA_FMAN
+#ifdef CONFIG_SYS_DPAA_FMAN
+#define CONFIG_SYS_FM_MURAM_SIZE	0x60000
+
+#define CONFIG_SYS_QE_FMAN_FW_IN_NOR
+/* FMan fireware Pre-load address */
+#define CONFIG_SYS_FMAN_FW_ADDR		0x60300000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH	0x10000
+#define CONFIG_SYS_FDT_PAD		(0x3000 + CONFIG_SYS_QE_FMAN_FW_LENGTH)
+#endif
+
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_LOAD_ADDR	(CONFIG_SYS_DDR_SDRAM_BASE + 0x10000000)
 #define CONFIG_ARCH_EARLY_INIT_R
include/configs/ls1043ardb.h +25 -0
index 8ac752e..5c65153 100644
@@ -234,4 +234,29 @@
 #define CONFIG_ENV_SIZE			0x20000
 #endif
 
+/* FMan */
+#ifdef CONFIG_SYS_DPAA_FMAN
+#define CONFIG_FMAN_ENET
+#define CONFIG_MII
+#define CONFIG_PHYLIB
+#define CONFIG_PHYLIB_10G
+#define CONFIG_PHY_GIGE		/* Include GbE speed/duplex detection */
+
+#define CONFIG_PHY_VITESSE
+#define CONFIG_PHY_REALTEK
+#define CONFIG_PHY_AQUANTIA
+
+#define RGMII_PHY1_ADDR			0x1
+#define RGMII_PHY2_ADDR			0x2
+
+#define QSGMII_PORT1_PHY_ADDR		0x4
+#define QSGMII_PORT2_PHY_ADDR		0x5
+#define QSGMII_PORT3_PHY_ADDR		0x6
+#define QSGMII_PORT4_PHY_ADDR		0x7
+
+#define FM1_10GEC1_PHY_ADDR		0x1
+
+#define CONFIG_ETHPRIME			"FM1 at DTSEC3"
+#endif
+
 #endif /* __LS1043ARDB_H__ */
Signature · 1 line
2.1.0.27.g96db324
#16 lore raw

PATCH v3 15/16 armv8/ls1043ardb: esdhc: Add esdhc support for ls1043ardb

In reply to Gong Qianyu

From: Yangbo Lu <[email protected]>

This patch adds esdhc support for ls1043ardb.

---
 arch/arm/cpu/armv8/fsl-lsch2/cpu.c      | 10 ++++++++++
 arch/arm/cpu/armv8/fsl-lsch2/fdt.c      |  6 ++++++
 arch/arm/cpu/armv8/fsl-lsch2/speed.c    | 18 +++++++++++++++++-
 board/freescale/ls1043ardb/ls1043ardb.c |  1 +
 drivers/mmc/fsl_esdhc.c                 | 13 +++++++------
 include/configs/ls1043a_common.h        | 11 +++++++++++
 include/fsl_esdhc.h                     |  2 +-
 7 files changed, 53 insertions(+), 8 deletions(-)
arch/arm/cpu/armv8/fsl-lsch2/cpu.c +10 -0
index ef63770..63b74d0 100644
@@ -13,6 +13,9 @@
 #include <asm/arch/immap_lsch2.h>
 #include <asm/arch/fsl_serdes.h>
 #include <fm_eth.h>
+#ifdef CONFIG_FSL_ESDHC
+#include <fsl_esdhc.h>
+#endif
 #include "speed.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -495,6 +498,13 @@ int print_cpuinfo(void)
 }
 #endif
 
+#ifdef CONFIG_FSL_ESDHC
+int cpu_mmc_init(bd_t *bis)
+{
+	return fsl_esdhc_mmc_init(bis);
+}
+#endif
+
 /*
  * Initializes on-chip ethernet controllers.
  * to override, implement board_eth_init()
arch/arm/cpu/armv8/fsl-lsch2/fdt.c +6 -0
index a646faa..f1ae1f1 100644
@@ -8,6 +8,9 @@
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <phy.h>
+#ifdef CONFIG_FSL_ESDHC
+#include <fsl_esdhc.h>
+#endif
 
 int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
 {
@@ -17,4 +20,7 @@ int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
 
 void ft_cpu_setup(void *blob, bd_t *bd)
 {
+#if defined(CONFIG_FSL_ESDHC)
+	fdt_fixup_esdhc(blob, bd);
+#endif
 }
arch/arm/cpu/armv8/fsl-lsch2/speed.c +17 -1
index 3bc6401..4c59baa 100644
@@ -25,7 +25,7 @@ void get_sys_info(struct sys_info *sys_info)
 	struct fsl_ifc ifc_regs = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL};
 	u32 ccr;
 #endif
-#ifdef CONFIG_SYS_DPAA_FMAN
+#if defined(CONFIG_FSL_ESDHC) || defined(CONFIG_SYS_DPAA_FMAN)
 	u32 rcw_tmp;
 #endif
 	struct ccsr_clk *clk = (void *)(CONFIG_SYS_FSL_CLK_ADDR);
@@ -105,6 +105,11 @@ void get_sys_info(struct sys_info *sys_info)
 
 #define HWA_CGA_M2_CLK_SEL	0x00000007
 #define HWA_CGA_M2_CLK_SHIFT	0
+#if defined(CONFIG_FSL_ESDHC)
+	rcw_tmp = in_be32(&gur->rcwsr[15]);
+	rcw_tmp = (rcw_tmp & HWA_CGA_M2_CLK_SEL) >> HWA_CGA_M2_CLK_SHIFT;
+	sys_info->freq_sdhc = freq_c_pll[1] / rcw_tmp;
+#endif
 
 #if defined(CONFIG_FSL_IFC)
 	ccr = in_le32(&ifc_regs.gregs->ifc_ccr);
@@ -123,6 +128,10 @@ int get_clocks(void)
 	gd->bus_clk = sys_info.freq_systembus;
 	gd->mem_clk = sys_info.freq_ddrbus;
 
+#if defined(CONFIG_FSL_ESDHC)
+	gd->arch.sdhc_clk = sys_info.freq_sdhc;
+#endif
+
 	if (gd->cpu_clk != 0)
 		return 0;
 	else
@@ -139,6 +148,11 @@ ulong get_ddr_freq(ulong dummy)
 	return gd->mem_clk;
 }
 
+int get_sdhc_freq(ulong dummy)
+{
+	return gd->arch.sdhc_clk;
+}
+
 int get_serial_clock(void)
 {
 	return gd->bus_clk;
@@ -149,6 +163,8 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
 	switch (clk) {
 	case MXC_I2C_CLK:
 		return get_bus_freq(0);
+	case MXC_ESDHC_CLK:
+		return get_sdhc_freq(0);
 	case MXC_DSPI_CLK:
 		return get_bus_freq(0);
 	case MXC_UART_CLK:
board/freescale/ls1043ardb/ls1043ardb.c +1 -0
index 5a2f3bd..de6682a 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/soc.h>
 #include <hwconfig.h>
 #include <ahci.h>
+#include <mmc.h>
 #include <scsi.h>
 #include <fm_eth.h>
 #include <fsl_csu.h>
drivers/mmc/fsl_esdhc.c +7 -6
index 0b37002..0a22874 100644
@@ -106,7 +106,8 @@ static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
 		xfertyp |= XFERTYP_RSPTYP_48;
 
 #if defined(CONFIG_MX53) || defined(CONFIG_PPC_T4240) || \
-	defined(CONFIG_LS102XA) || defined(CONFIG_LS2085A)
+	defined(CONFIG_LS102XA) || defined(CONFIG_LS2085A) || \
+	defined(CONFIG_LS1043A)
 	if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
 		xfertyp |= XFERTYP_CMDTYP_ABORT;
 #endif
@@ -184,7 +185,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 	int timeout;
 	struct fsl_esdhc_cfg *cfg = mmc->priv;
 	struct fsl_esdhc *regs = (struct fsl_esdhc *)cfg->esdhc_base;
-#ifdef CONFIG_LS2085A
+#if defined(CONFIG_LS2085A) || defined(CONFIG_LS1043A)
 	dma_addr_t addr;
 #endif
 	uint wml_value;
@@ -197,7 +198,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 
 		esdhc_clrsetbits32(&regs->wml, WML_RD_WML_MASK, wml_value);
 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
-#ifdef CONFIG_LS2085A
+#if defined(CONFIG_LS2085A) || defined(CONFIG_LS1043A)
 		addr = virt_to_phys((void *)(data->dest));
 		if (upper_32_bits(addr))
 			printf("Error found for upper 32 bits\n");
@@ -223,7 +224,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 		esdhc_clrsetbits32(&regs->wml, WML_WR_WML_MASK,
 					wml_value << 16);
 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
-#ifdef CONFIG_LS2085A
+#if defined(CONFIG_LS2085A) || defined(CONFIG_LS1043A)
 		addr = virt_to_phys((void *)(data->src));
 		if (upper_32_bits(addr))
 			printf("Error found for upper 32 bits\n");
@@ -277,7 +278,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 static void check_and_invalidate_dcache_range
 	(struct mmc_cmd *cmd,
 	 struct mmc_data *data) {
-#ifdef CONFIG_LS2085A
+#if defined(CONFIG_LS2085A) || defined(CONFIG_LS1043A)
 	unsigned start = 0;
 #else
 	unsigned start = (unsigned)data->dest ;
@@ -285,7 +286,7 @@ static void check_and_invalidate_dcache_range
 	unsigned size = roundup(ARCH_DMA_MINALIGN,
 				data->blocks*data->blocksize);
 	unsigned end = start+size ;
-#ifdef CONFIG_LS2085A
+#if defined(CONFIG_LS2085A) || defined(CONFIG_LS1043A)
 	dma_addr_t addr;
 
 	addr = virt_to_phys((void *)(data->dest));
include/configs/ls1043a_common.h +11 -0
index 3cb013d..d3ba4a3 100644
@@ -115,6 +115,17 @@
 #define CONFIG_CMD_ENV
 #define CONFIG_CMD_PING
 
+/*  MMC  */
+#define CONFIG_MMC
+#ifdef CONFIG_MMC
+#define CONFIG_CMD_MMC
+#define CONFIG_FSL_ESDHC
+#define CONFIG_SYS_FSL_MMC_HAS_CAPBLT_VS33
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
 /* FMan ucode */
 #define CONFIG_SYS_DPAA_FMAN
 #ifdef CONFIG_SYS_DPAA_FMAN
include/fsl_esdhc.h +1 -1
index 0d00b7d..b6572e7 100644
@@ -166,7 +166,7 @@
 #define ESDHC_VENDORSPEC_VSELECT 0x00000002 /* Use 1.8V */
 
 struct fsl_esdhc_cfg {
-#ifdef CONFIG_LS2085A
+#if defined(CONFIG_LS2085A) || defined(CONFIG_LS1043A)
 	u64	esdhc_base;
 #else
 	u32	esdhc_base;
Signature · 1 line
2.1.0.27.g96db324
#17 lore raw

PATCH v3 16/16 armv8/ls1043ardb: Add sd boot support

In reply to Gong Qianyu
---
 board/freescale/ls1043ardb/README                |  1 +
 board/freescale/ls1043ardb/cpld.c                | 17 ++++++++++++++
 board/freescale/ls1043ardb/cpld.h                |  1 +
 board/freescale/ls1043ardb/ls1043ardb.c          |  6 +++++
 board/freescale/ls1043ardb/ls1043ardb_rcw_sd.cfg |  7 ++++++
 configs/ls1043ardb_sdcard_defconfig              |  4 ++++
 include/configs/ls1043a_common.h                 | 30 ++++++++++++++++++++++++
 include/configs/ls1043ardb.h                     | 13 ++++++++--
 8 files changed, 77 insertions(+), 2 deletions(-)
board/freescale/ls1043ardb/README +1 -0
index 4f15557..0556e73 100644
@@ -84,3 +84,4 @@ Booting Options
 ---------------
 a) NOR boot
 b) NAND boot
+c) SD boot
board/freescale/ls1043ardb/cpld.c +17 -0
index 5acb97d..faa0de8 100644
@@ -60,6 +60,20 @@ void cpld_set_nand(void)
 	CPLD_WRITE(system_rst, 1);
 }
 
+void cpld_set_sd(void)
+{
+	u16 reg = CPLD_CFG_RCW_SRC_SD;
+	u8 reg5 = (u8)(reg >> 1);
+	u8 reg6 = (u8)(reg & 1);
+	cpld_rev_bit(&reg5);
+
+	CPLD_WRITE(soft_mux_on, 1);
+
+	CPLD_WRITE(cfg_rcw_src1, reg5);
+	CPLD_WRITE(cfg_rcw_src2, reg6);
+
+	CPLD_WRITE(system_rst, 1);
+}
 #ifdef DEBUG
 static void cpld_dump_regs(void)
 {
@@ -108,6 +122,8 @@ int do_cpld(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			cpld_set_altbank();
 		else if (strcmp(argv[2], "nand") == 0)
 			cpld_set_nand();
+		else if (strcmp(argv[2], "sd") == 0)
+			cpld_set_sd();
 		else
 			cpld_set_defbank();
 #ifdef DEBUG
@@ -127,6 +143,7 @@ U_BOOT_CMD(
 	"reset: reset to default bank\n"
 	"cpld reset altbank: reset to alternate bank\n"
 	"cpld reset nand: reset to boot from NAND flash\n"
+	"cpld reset sd: reset to boot from SD card\n"
 #ifdef DEBUG
 	"cpld dump - display the CPLD registers\n"
 #endif
board/freescale/ls1043ardb/cpld.h +1 -0
index 5f43a8a..bd59c0e 100644
@@ -41,4 +41,5 @@ void cpld_rev_bit(unsigned char *value);
 #define CPLD_BANK_SEL_MASK	0x07
 #define CPLD_BANK_SEL_ALTBANK	0x04
 #define CPLD_CFG_RCW_SRC_NAND	0x106
+#define CPLD_CFG_RCW_SRC_SD	0x040
 #endif
board/freescale/ls1043ardb/ls1043ardb.c +6 -0
index de6682a..37846ff 100644
@@ -26,12 +26,17 @@ DECLARE_GLOBAL_DATA_PTR;
 int checkboard(void)
 {
 	static const char *freq[3] = {"100.00MHZ", "156.25MHZ"};
+#ifndef CONFIG_SD_BOOT
 	u8 cfg_rcw_src1, cfg_rcw_src2;
 	u32 cfg_rcw_src;
+#endif
 	u32 sd1refclk_sel;
 
 	printf("Board: LS1043ARDB, boot from ");
 
+#ifdef CONFIG_SD_BOOT
+	puts("SD\n");
+#else
 	cfg_rcw_src1 = CPLD_READ(cfg_rcw_src1);
 	cfg_rcw_src2 = CPLD_READ(cfg_rcw_src2);
 	cpld_rev_bit(&cfg_rcw_src1);
@@ -44,6 +49,7 @@ int checkboard(void)
 		puts("NAND\n");
 	else
 		printf("Invalid setting of SW4\n");
+#endif
 
 	printf("CPLD:  V%x.%x\nPCBA:  V%x.0\n", CPLD_READ(cpld_ver),
 	       CPLD_READ(cpld_ver_sub), CPLD_READ(pcba_ver));
board/freescale/ls1043ardb/ls1043ardb_rcw_sd.cfg new file +7 -0
new file mode 100644
index 0000000..28cd958
@@ -0,0 +1,7 @@
+#PBL preamble and RCW header
+aa55aa55 01ee0100
+# RCW
+0810000f 0c000000 00000000 00000000
+14550002 80004012 60040000 61002000
+00000000 00000000 00000000 00038800
+00000000 00001100 00000096 00000001
configs/ls1043ardb_sdcard_defconfig new file +4 -0
new file mode 100644
index 0000000..5fe0470
@@ -0,0 +1,4 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,SD_BOOT,SYS_FSL_DDR4"
+CONFIG_ARM=y
+CONFIG_TARGET_LS1043ARDB=y
include/configs/ls1043a_common.h +30 -0
index d3ba4a3..565acf5 100644
@@ -57,6 +57,36 @@
 #define CONFIG_BAUDRATE			115200
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }
 
+/* SD boot SPL */
+#ifdef CONFIG_SD_BOOT
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_LDSCRIPT		"arch/arm/cpu/armv8/u-boot-spl.lds"
+#define CONFIG_SPL_TARGET		"u-boot-with-spl.bin"
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_ENV_SUPPORT
+#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
+#define CONFIG_SPL_WATCHDOG_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_DRIVERS_MISC_SUPPORT
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR		0xf0
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS		0x500
+
+#define CONFIG_SPL_TEXT_BASE		0x10000000
+#define CONFIG_SPL_MAX_SIZE		0x1d000
+#define CONFIG_SPL_STACK		0x1001e000
+#define CONFIG_SPL_PAD_TO		0x1d000
+
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_TEXT_BASE + \
+					CONFIG_SYS_MONITOR_LEN)
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000
+#define CONFIG_SPL_BSS_START_ADDR	0x80100000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000
+#define CONFIG_SYS_MONITOR_LEN		0xa0000
+#endif
+
 /* NAND SPL */
 #ifdef CONFIG_NAND_BOOT
 #define CONFIG_SPL_PBL_PAD
include/configs/ls1043ardb.h +11 -2
index 5c65153..dcdedab 100644
@@ -12,7 +12,7 @@
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
 
-#if defined(CONFIG_NAND_BOOT)
+#if defined(CONFIG_NAND_BOOT) || defined(CONFIG_SD_BOOT)
 #define CONFIG_SYS_TEXT_BASE		0x82000000
 #else
 #define CONFIG_SYS_TEXT_BASE		0x60100000
@@ -45,6 +45,10 @@
 #define CONFIG_SYS_FSL_PBL_RCW board/freescale/ls1043ardb/ls1043ardb_rcw_nand.cfg
 #endif
 
+#ifdef CONFIG_SD_BOOT
+#define CONFIG_SYS_FSL_PBL_RCW board/freescale/ls1043ardb/ls1043ardb_rcw_sd.cfg
+#endif
+
 /*
  * NOR Flash Definitions
  */
@@ -223,7 +227,12 @@
  */
 #define CONFIG_ENV_OVERWRITE
 
-#if defined(CONFIG_NAND_BOOT)
+#if defined(CONFIG_SD_BOOT)
+#define CONFIG_ENV_OFFSET		(1024 * 1024)
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV		0
+#define CONFIG_ENV_SIZE			0x2000
+#elif defined(CONFIG_NAND_BOOT)
 #define CONFIG_ENV_IS_IN_NAND
 #define CONFIG_ENV_SIZE			0x2000
 #define CONFIG_ENV_OFFSET		(10 * CONFIG_SYS_NAND_BLOCK_SIZE)
Signature · 1 line
2.1.0.27.g96db324