All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization
@ 2014-02-13 10:30 Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 2/5] net: gem: Add OF initialization support Michal Simek
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michal Simek @ 2014-02-13 10:30 UTC (permalink / raw)
  To: u-boot

- 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>
---

 drivers/net/xilinx_emaclite.c | 15 ++++++++-------
 include/netdev.h              |  1 +
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 0a5209d..a607098 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,
 								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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140213/d0fe4b84/attachment.pgp>

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

* [U-Boot] [PATCH 2/5] net: gem: Add OF initialization support
  2014-02-13 10:30 [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Michal Simek
@ 2014-02-13 10:30 ` Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 3/5] mmc: zynq: " Michal Simek
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2014-02-13 10:30 UTC (permalink / raw)
  To: u-boot

Gem can be directly initialized from DTB.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 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 381bca4..9affebd 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>
@@ -532,3 +534,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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140213/04550256/attachment.pgp>

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

* [U-Boot] [PATCH 3/5] mmc: zynq: Add OF initialization support
  2014-02-13 10:30 [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 2/5] net: gem: Add OF initialization support Michal Simek
@ 2014-02-13 10:30 ` Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 4/5] zynq: Add OF ram " Michal Simek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2014-02-13 10:30 UTC (permalink / raw)
  To: u-boot

Enable initialize sdhci from DTB.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 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 8f925af..86e7db5 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 610bef5..d39cbf0 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>
@@ -31,3 +33,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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140213/0ac20170/attachment.pgp>

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

* [U-Boot] [PATCH 4/5] zynq: Add OF ram initialization support
  2014-02-13 10:30 [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 2/5] net: gem: Add OF initialization support Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 3/5] mmc: zynq: " Michal Simek
@ 2014-02-13 10:30 ` Michal Simek
  2014-02-13 10:30 ` [U-Boot] [PATCH 5/5] serial: zynq: Add OF " Michal Simek
  2014-02-21 16:32 ` [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Tom Rini
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2014-02-13 10:30 UTC (permalink / raw)
  To: u-boot

Read ram size directly from DTB.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 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 5a47149..b678a23 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>
@@ -144,8 +145,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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140213/c0a543c8/attachment.pgp>

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

* [U-Boot] [PATCH 5/5] serial: zynq: Add OF initialization support
  2014-02-13 10:30 [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Michal Simek
                   ` (2 preceding siblings ...)
  2014-02-13 10:30 ` [U-Boot] [PATCH 4/5] zynq: Add OF ram " Michal Simek
@ 2014-02-13 10:30 ` Michal Simek
  2014-02-21 16:32 ` [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Tom Rini
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2014-02-13 10:30 UTC (permalink / raw)
  To: u-boot

Add console selection from DTB which is enough to have
OF driven solution.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 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 ff28f3c..c57137f 100644
--- a/drivers/serial/serial_zynq.c
+++ b/drivers/serial/serial_zynq.c
@@ -6,11 +6,14 @@
  */

 #include <common.h>
+#include <fdtdec.h>
 #include <watchdog.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
 #include <serial.h>

+DECLARE_GLOBAL_DATA_PTR;
+
 #define ZYNQ_UART_SR_TXFULL	0x00000010 /* TX FIFO full */
 #define ZYNQ_UART_SR_RXEMPTY	0x00000002 /* RX FIFO empty */

@@ -184,6 +187,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 (uart_zynq_ports[0])
@@ -193,6 +220,7 @@ __weak struct serial_device *default_serial_console(void)

 	return NULL;
 }
+#endif

 void zynq_serial_initalize(void)
 {
--
1.8.2.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140213/5906a99d/attachment.pgp>

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

* [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization
  2014-02-13 10:30 [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Michal Simek
                   ` (3 preceding siblings ...)
  2014-02-13 10:30 ` [U-Boot] [PATCH 5/5] serial: zynq: Add OF " Michal Simek
@ 2014-02-21 16:32 ` Tom Rini
  4 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2014-02-21 16:32 UTC (permalink / raw)
  To: u-boot

On Thu, Feb 13, 2014 at 11:30:04AM +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>

/home/trini/work/u-boot/u-boot/drivers/net/xilinx_emaclite.c: In
function 'xilinx_emaclite_of_init':
/home/trini/work/u-boot/u-boot/drivers/net/xilinx_emaclite.c:381:39:
error: 'bis' undeclared (first use in this function)
/home/trini/work/u-boot/u-boot/drivers/net/xilinx_emaclite.c:381:39:
note: each undeclared identifier is reported only once for each function
it appears in
make[2]: *** [drivers/net/xilinx_emaclite.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers/net] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [sub-make] Error 2

--------------------- SUMMARY ----------------------------
Boards compiled: 1
Boards with errors: 1 ( microblaze-generic )

Please fix in v2, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140221/31c60a0a/attachment.pgp>

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

end of thread, other threads:[~2014-02-21 16:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-13 10:30 [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Michal Simek
2014-02-13 10:30 ` [U-Boot] [PATCH 2/5] net: gem: Add OF initialization support Michal Simek
2014-02-13 10:30 ` [U-Boot] [PATCH 3/5] mmc: zynq: " Michal Simek
2014-02-13 10:30 ` [U-Boot] [PATCH 4/5] zynq: Add OF ram " Michal Simek
2014-02-13 10:30 ` [U-Boot] [PATCH 5/5] serial: zynq: Add OF " Michal Simek
2014-02-21 16:32 ` [U-Boot] [PATCH 1/5] net: emaclite: Fix OF initialization Tom Rini

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