[U-Boot] [PATCH v2 1/6] net: emaclite: Fix OF initialization

- Add xilinx_emaclite_of_init to netdev.h - Remove global data pointer from the driver - Add better handling for error state.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
Changes in v2: - Remove bis parameter which was causing compilation error
drivers/net/xilinx_emaclite.c | 17 +++++++++-------- include/netdev.h | 1 + 2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 0a5209d..2a5cc44 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -14,8 +14,6 @@ #include <asm/io.h> #include <fdtdec.h>
-DECLARE_GLOBAL_DATA_PTR; - #undef DEBUG
#define ENET_ADDR_LENGTH 6 @@ -364,24 +362,27 @@ int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, }
#ifdef CONFIG_OF_CONTROL -int xilinx_emaclite_init(bd_t *bis) +int xilinx_emaclite_of_init(const void *blob) { int offset = 0; u32 ret = 0; u32 reg;
do { - offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset, + offset = fdt_node_offset_by_compatible(blob, offset, "xlnx,xps-ethernetlite-1.00.a"); if (offset != -1) { - reg = fdtdec_get_addr(gd->fdt_blob, offset, "reg"); + reg = fdtdec_get_addr(blob, offset, "reg"); if (reg != FDT_ADDR_T_NONE) { - u32 rxpp = fdtdec_get_int(gd->fdt_blob, offset, + u32 rxpp = fdtdec_get_int(blob, offset, "xlnx,rx-ping-pong", 0); - u32 txpp = fdtdec_get_int(gd->fdt_blob, offset, + u32 txpp = fdtdec_get_int(blob, offset, "xlnx,tx-ping-pong", 0); - ret |= xilinx_emaclite_initialize(bis, reg, + ret |= xilinx_emaclite_initialize(NULL, reg, txpp, rxpp); + } else { + debug("EMACLITE: Can't get base address\n"); + return -1; } } } while (offset != -1); diff --git a/include/netdev.h b/include/netdev.h index 3705629..c684014 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -86,6 +86,7 @@ int uli526x_initialize(bd_t *bis); int armada100_fec_register(unsigned long base_addr); int xilinx_axiemac_initialize(bd_t *bis, unsigned long base_addr, unsigned long dma_addr); +int xilinx_emaclite_of_init(const void *blob); int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, int txpp, int rxpp); int xilinx_ll_temac_eth_init(bd_t *bis, unsigned long base_addr, int flags, -- 1.8.2.3

Disable CONFIG_OF_CONTROL for SPL compilation.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
Changes in v2: - Do not init SPL from DTB - not supported now - New patch in this series
include/configs/zynq-common.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 14f0b90..731e69b 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -242,6 +242,7 @@ #ifdef CONFIG_SPL_BUILD #define CONFIG_SYS_DCACHE_OFF #undef CONFIG_FPGA +#undef CONFIG_OF_CONTROL #endif
/* MMC support */ -- 1.8.2.3

On Mon, Feb 24, 2014 at 11:16:29AM +0100, Michal Simek wrote:
Disable CONFIG_OF_CONTROL for SPL compilation.
Signed-off-by: Michal Simek michal.simek@xilinx.com
Applied to u-boot/master, thanks!

Gem can be directly initialized from DTB.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
Changes in v2: None
drivers/net/zynq_gem.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/netdev.h | 1 + 2 files changed, 43 insertions(+)
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 6d4001b..101489c 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -12,6 +12,8 @@ #include <common.h> #include <net.h> #include <config.h> +#include <fdtdec.h> +#include <libfdt.h> #include <malloc.h> #include <asm/io.h> #include <phy.h> @@ -534,3 +536,43 @@ int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio)
return 1; } + +#ifdef CONFIG_OF_CONTROL +int zynq_gem_of_init(const void *blob) +{ + int offset = 0; + u32 ret = 0; + u32 reg, phy_reg; + + debug("ZYNQ GEM: Initialization\n"); + + do { + offset = fdt_node_offset_by_compatible(blob, offset, + "xlnx,ps7-ethernet-1.00.a"); + if (offset != -1) { + reg = fdtdec_get_addr(blob, offset, "reg"); + if (reg != FDT_ADDR_T_NONE) { + offset = fdtdec_lookup_phandle(blob, offset, + "phy-handle"); + if (offset != -1) + phy_reg = fdtdec_get_addr(blob, offset, + "reg"); + else + phy_reg = 0; + + debug("ZYNQ GEM: addr %x, phyaddr %x\n", + reg, phy_reg); + + ret |= zynq_gem_initialize(NULL, reg, + phy_reg, 0); + + } else { + debug("ZYNQ GEM: Can't get base address\n"); + return -1; + } + } + } while (offset != -1); + + return ret; +} +#endif diff --git a/include/netdev.h b/include/netdev.h index c684014..32b5073 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -91,6 +91,7 @@ int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr, int txpp, int rxpp); int xilinx_ll_temac_eth_init(bd_t *bis, unsigned long base_addr, int flags, unsigned long ctrl_addr); +int zynq_gem_of_init(const void *blob); int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio); /* * As long as the Xilinx xps_ll_temac ethernet driver has not its own interface -- 1.8.2.3

On Mon, Feb 24, 2014 at 11:16:30AM +0100, Michal Simek wrote:
Gem can be directly initialized from DTB.
Signed-off-by: Michal Simek michal.simek@xilinx.com
Applied to u-boot/master, thanks!

Enable initialize sdhci from DTB.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
Changes in v2: None
arch/arm/include/asm/arch-zynq/sys_proto.h | 1 + drivers/mmc/zynq_sdhci.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
diff --git a/arch/arm/include/asm/arch-zynq/sys_proto.h b/arch/arm/include/asm/arch-zynq/sys_proto.h index 0a2ba05..a68e1b3 100644 --- a/arch/arm/include/asm/arch-zynq/sys_proto.h +++ b/arch/arm/include/asm/arch-zynq/sys_proto.h @@ -19,5 +19,6 @@ extern void zynq_ddrc_init(void);
/* Driver extern functions */ extern int zynq_sdhci_init(u32 regbase); +extern int zynq_sdhci_of_init(const void *blob);
#endif /* _SYS_PROTO_H_ */ diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 72a272f..fdce2c2 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -7,6 +7,8 @@ */
#include <common.h> +#include <fdtdec.h> +#include <libfdt.h> #include <malloc.h> #include <sdhci.h> #include <asm/arch/sys_proto.h> @@ -32,3 +34,30 @@ int zynq_sdhci_init(u32 regbase) add_sdhci(host, 52000000, 52000000 >> 9); return 0; } + +#ifdef CONFIG_OF_CONTROL +int zynq_sdhci_of_init(const void *blob) +{ + int offset = 0; + u32 ret = 0; + u32 reg; + + debug("ZYNQ SDHCI: Initialization\n"); + + do { + offset = fdt_node_offset_by_compatible(blob, offset, + "arasan,sdhci-8.9a"); + if (offset != -1) { + reg = fdtdec_get_addr(blob, offset, "reg"); + if (reg != FDT_ADDR_T_NONE) { + ret |= zynq_sdhci_init(reg); + } else { + debug("ZYNQ SDHCI: Can't get base address\n"); + return -1; + } + } + } while (offset != -1); + + return ret; +} +#endif -- 1.8.2.3

On Mon, Feb 24, 2014 at 11:16:31AM +0100, Michal Simek wrote:
Enable initialize sdhci from DTB.
Signed-off-by: Michal Simek michal.simek@xilinx.com
Applied to u-boot/master, thanks!

Read ram size directly from DTB.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
Changes in v2: None
board/xilinx/zynq/board.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 82f2345..485a5e4 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -5,6 +5,7 @@ */
#include <common.h> +#include <fdtdec.h> #include <netdev.h> #include <zynqpl.h> #include <asm/arch/hardware.h> @@ -134,8 +135,27 @@ int board_mmc_init(bd_t *bd)
int dram_init(void) { +#ifdef CONFIG_OF_CONTROL + int node; + fdt_addr_t addr; + fdt_size_t size; + const void *blob = gd->fdt_blob; + + node = fdt_node_offset_by_prop_value(blob, -1, "device_type", + "memory", 7); + if (node == -FDT_ERR_NOTFOUND) { + debug("ZYNQ DRAM: Can't get memory node\n"); + return -1; + } + addr = fdtdec_get_addr_size(blob, node, "reg", &size); + if (addr == FDT_ADDR_T_NONE || size == 0) { + debug("ZYNQ DRAM: Can't get base address or size\n"); + return -1; + } + gd->ram_size = size; +#else gd->ram_size = CONFIG_SYS_SDRAM_SIZE; - +#endif zynq_ddrc_init();
return 0; -- 1.8.2.3

On Mon, Feb 24, 2014 at 11:16:32AM +0100, Michal Simek wrote:
Read ram size directly from DTB.
Signed-off-by: Michal Simek michal.simek@xilinx.com
Applied to u-boot/master, thanks!

Add console selection from DTB which is enough to have OF driven solution.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
Changes in v2: None
drivers/serial/serial_zynq.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c index 22c6bf0..53a8af0 100644 --- a/drivers/serial/serial_zynq.c +++ b/drivers/serial/serial_zynq.c @@ -6,6 +6,7 @@ */
#include <common.h> +#include <fdtdec.h> #include <watchdog.h> #include <asm/io.h> #include <linux/compiler.h> @@ -13,6 +14,8 @@ #include <asm/arch/clk.h> #include <asm/arch/hardware.h>
+DECLARE_GLOBAL_DATA_PTR; + #define ZYNQ_UART_SR_TXFULL 0x00000010 /* TX FIFO full */ #define ZYNQ_UART_SR_RXEMPTY 0x00000002 /* RX FIFO empty */
@@ -182,6 +185,30 @@ DECLARE_PSSERIAL_FUNCTIONS(1); struct serial_device uart_zynq_serial1_device = INIT_PSSERIAL_STRUCTURE(1, "ttyPS1");
+#ifdef CONFIG_OF_CONTROL +__weak struct serial_device *default_serial_console(void) +{ + const void *blob = gd->fdt_blob; + int node; + unsigned int base_addr; + + node = fdt_path_offset(blob, "serial0"); + if (node < 0) + return NULL; + + base_addr = fdtdec_get_addr(blob, node, "reg"); + if (base_addr == FDT_ADDR_T_NONE) + return NULL; + + if (base_addr == ZYNQ_SERIAL_BASEADDR0) + return &uart_zynq_serial0_device; + + if (base_addr == ZYNQ_SERIAL_BASEADDR1) + return &uart_zynq_serial1_device; + + return NULL; +} +#else __weak struct serial_device *default_serial_console(void) { #if defined(CONFIG_ZYNQ_SERIAL_UART0) @@ -194,6 +221,7 @@ __weak struct serial_device *default_serial_console(void) #endif return NULL; } +#endif
void zynq_serial_initalize(void) { -- 1.8.2.3

On Mon, Feb 24, 2014 at 11:16:33AM +0100, Michal Simek wrote:
Add console selection from DTB which is enough to have OF driven solution.
Signed-off-by: Michal Simek michal.simek@xilinx.com
Applied to u-boot/master, thanks!

On Mon, Feb 24, 2014 at 11:16:28AM +0100, Michal Simek wrote:
- Add xilinx_emaclite_of_init to netdev.h
- Remove global data pointer from the driver
- Add better handling for error state.
Signed-off-by: Michal Simek michal.simek@xilinx.com
Applied to u-boot/master, thanks!
participants (2)
-
Michal Simek
-
Tom Rini