Skip to contentSkip to conversation

Xilinx Zynq patches

U-Boot Superseded Michal Simek 3 participants 21 messages Apr 22, 2013 – Apr 23, 2013

Subsystems (7)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

Hi,

I am sending several patches which improve Xilinx Zynq arm port in u-boot.
Patchset contain:
- core changes: patches 1,2
- gem update: patches 1-11
- mmc support: patch 12
- i2c support: patch 13
- pl support: patch 14

I am sending them in one package because driver depends on each other in zynq shared files.

Thanks for your comments,
Michal

-------------- 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/20130422/017120ac/attachment.pgp>

#1 lore raw

PATCH 1/14 arm: zynq: U-Boot udelay < 1000 FIX

From: David Andrey <[email protected]>

Rework the __udelay function of U-Boot Zynq Arch to handle delay < 1000 usec

---
 arch/arm/cpu/armv7/zynq/timer.c | 46 +++++++++++++++++++++++++++++++++--------
 1 file changed, 37 insertions(+), 9 deletions(-)
arch/arm/cpu/armv7/zynq/timer.c +37 -9
index 45b405a..5d8bb24 100644
@@ -114,15 +114,43 @@ ulong get_timer_masked(void)
 
 void __udelay(unsigned long usec)
 {
-	unsigned long long tmp;
-	ulong tmo;
-
-	tmo = usec / (1000000 / CONFIG_SYS_HZ);
-	tmp = get_ticks() + tmo; /* Get current timestamp */
-
-	while (get_ticks() < tmp) { /* Loop till event */
-		 /* NOP */;
-	}
+	u32 countticks;
+	u32 timeend;
+	u32 timediff;
+	u32 timenow;
+
+	if (usec == 0)
+		return;
+
+	countticks = (u32) (((unsigned long long) TIMER_TICK_HZ * usec) /
+								1000000);
+
+	/* decrementing timer */
+	timeend = readl(&timer_base->counter) - countticks;
+
+#if TIMER_LOAD_VAL != 0xFFFFFFFF
+	/* do not manage multiple overflow */
+	if (countticks >= TIMER_LOAD_VAL)
+		countticks = TIMER_LOAD_VAL - 1;
+#endif
+
+	do {
+		timenow = readl(&timer_base->counter);
+
+		if (timenow >= timeend) {
+			/* normal case */
+			timediff = timenow - timeend;
+		} else {
+			if ((TIMER_LOAD_VAL - timeend + timenow) <=
+								countticks) {
+				/* overflow */
+				timediff = TIMER_LOAD_VAL - timeend + timenow;
+			} else {
+				/* missed the exact match */
+				break;
+			}
+		}
+	} while (timediff > 0);
 }
 
 /* Timer without interrupts */

--
1.8.2.1

-------------- 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/20130422/478cfa6b/attachment.pgp>

#2 lore raw

PATCH 2/14 zynq: Move scutimer baseaddr to hardware.h

In reply to Michal Simek

Move baseaddr to hardware.h to be shared between
configurations.

---
 arch/arm/cpu/armv7/zynq/timer.c           | 1 +
 arch/arm/include/asm/arch-zynq/hardware.h | 1 +
 include/configs/zynq.h                    | 3 ---
 3 files changed, 2 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/zynq/timer.c +1 -0
index 5d8bb24..44a5f4c 100644
@@ -44,6 +44,7 @@
 #include <common.h>
 #include <div64.h>
 #include <asm/io.h>
+#include <asm/arch/hardware.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
arch/arm/include/asm/arch-zynq/hardware.h +1 -0
index d0c69da..1b72773 100644
@@ -26,6 +26,7 @@
 #define XPSS_SYS_CTRL_BASEADDR		0xF8000000
 #define XPSS_DEV_CFG_APB_BASEADDR	0xF8007000
 #define XPSS_SCU_BASEADDR		0xF8F00000
+#define CONFIG_SCUTIMER_BASEADDR	0xF8F00600
 
 /* Reflect slcr offsets */
 struct slcr_regs {
include/configs/zynq.h +0 -3
index 2989e72..1147689 100644
@@ -50,9 +50,6 @@
 #define CONFIG_ZYNQ_SERIAL_BAUDRATE0	CONFIG_BAUDRATE
 #define CONFIG_ZYNQ_SERIAL_CLOCK0	50000000
 
-/* SCU timer address is hardcoded */
-#define CONFIG_SCUTIMER_BASEADDR	0xF8F00600
-
 /* Ethernet driver */
 #define CONFIG_NET_MULTI
 #define CONFIG_ZYNQ_GEM

--
1.8.2.1

-------------- 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/20130422/fcfd88b8/attachment.pgp>

#3 lore raw

PATCH 2/14 zynq: Move scutimer baseaddr to hardware.h

Quoted 2 lines · Michal Simek

Move baseaddr to hardware.h to be shared between
configurations.

Is this really configurable? If not, lets also rename it to drop CONFIG.

Signature · 8 lines
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/20130422/ee13622b/attachment.pgp>
#4 lore raw

PATCH 3/14 net: phy: Define Marvell 88e1518 phy

In reply to Michal Simek

From: Michal Simek <[email protected]>

This phy is used on zedboard (xilinx zynq platform).

---
 drivers/net/phy/marvell.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/phy/marvell.c +11 -0
index 4b27198..46801c7 100644
@@ -465,6 +465,16 @@ static struct phy_driver M88E1149S_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
+static struct phy_driver M88E1518_driver = {
+	.name = "Marvell 88E1518",
+	.uid = 0x1410dd1,
+	.mask = 0xffffff0,
+	.features = PHY_GBIT_FEATURES,
+	.config = &m88e1111s_config,
+	.startup = &m88e1011s_startup,
+	.shutdown = &genphy_shutdown,
+};
+
 int phy_marvell_init(void)
 {
 	phy_register(&M88E1149S_driver);
@@ -474,6 +484,7 @@ int phy_marvell_init(void)
 	phy_register(&M88E1118R_driver);
 	phy_register(&M88E1111S_driver);
 	phy_register(&M88E1011S_driver);
+	phy_register(&M88E1518_driver);
 
 	return 0;
 }

--
1.8.2.1

-------------- 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/20130422/4fb7c440/attachment.pgp>

#5 lore raw

PATCH 4/14 net: gem: Remove WRAP bit from TX buffer description

In reply to Michal Simek

From: Michal Simek <[email protected]>

Removing this bit causes that frame is sent only once. (With wrap big one packet has been sent several times which dramatically decrease throughput)

TRM: (Table 16-3: Tx Buffer Descriptor Entry)

---
 drivers/net/zynq_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/zynq_gem.c +1 -2
index 3596065..7188b9e 100644
@@ -310,8 +310,7 @@ static int zynq_gem_send(struct eth_device *dev, void *ptr, int len)
 	memset((void *) &(priv->tx_bd), 0, sizeof(struct emac_bd));
 
 	priv->tx_bd.addr = (u32)ptr;
-	priv->tx_bd.status = len | ZYNQ_GEM_TXBUF_LAST_MASK |
-						ZYNQ_GEM_TXBUF_WRAP_MASK;
+	priv->tx_bd.status = len | ZYNQ_GEM_TXBUF_LAST_MASK;
 
 	/* Start transmit */
 	setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_STARTTX_MASK);

--
1.8.2.1

-------------- 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/20130422/eb6de800/attachment.pgp>

#6 lore raw

PATCH 5/14 net: gem: Simplify return path in zynq_gem_recv

In reply to Michal Simek

Remove one return from the code.

---
 drivers/net/zynq_gem.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/zynq_gem.c +1 -3
index 7188b9e..c0da628 100644
@@ -363,11 +363,9 @@ static int zynq_gem_recv(struct eth_device *dev)
 
 		if ((++priv->rxbd_current) >= RX_BUF)
 			priv->rxbd_current = 0;
-
-		return frame_len;
 	}
 
-	return 0;
+	return frame_len;
 }
 
 static void zynq_gem_halt(struct eth_device *dev)

--
1.8.2.1

-------------- 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/20130422/705e2fb3/attachment.pgp>

#7 lore raw

PATCH 6/14 net: gem: Do not initialize BDs again

In reply to Michal Simek

BDs can be correctly setup just once and init function performs only phy autodetection and enabling RX/TX. RX/TX are disabled in halt function.

This patch solves the problem with repeatable tftp transfers.

---
 drivers/net/zynq_gem.c | 86 +++++++++++++++++++++++++++-----------------------
 1 file changed, 47 insertions(+), 39 deletions(-)
drivers/net/zynq_gem.c +47 -39
index c0da628..7758cf8 100644
@@ -134,6 +134,7 @@ struct zynq_gem_priv {
 	u32 rxbd_current;
 	u32 rx_first_buf;
 	int phyaddr;
+	int init;
 	struct phy_device *phydev;
 	struct mii_dev *bus;
 };
@@ -239,50 +240,57 @@ static int zynq_gem_init(struct eth_device *dev, bd_t * bis)
 			SUPPORTED_1000baseT_Half |
 			SUPPORTED_1000baseT_Full;
 
-	/* Disable all interrupts */
-	writel(0xFFFFFFFF, &regs->idr);
-
-	/* Disable the receiver & transmitter */
-	writel(0, &regs->nwctrl);
-	writel(0, &regs->txsr);
-	writel(0, &regs->rxsr);
-	writel(0, &regs->phymntnc);
-
-	/* Clear the Hash registers for the mac address pointed by AddressPtr */
-	writel(0x0, &regs->hashl);
-	/* Write bits [63:32] in TOP */
-	writel(0x0, &regs->hashh);
-
-	/* Clear all counters */
-	for (i = 0; i <= stat_size; i++)
-		readl(&regs->stat[i]);
-
-	/* Setup RxBD space */
-	memset(&(priv->rx_bd), 0, sizeof(priv->rx_bd));
-	/* Create the RxBD ring */
-	memset(&(priv->rxbuffers), 0, sizeof(priv->rxbuffers));
-
-	for (i = 0; i < RX_BUF; i++) {
-		priv->rx_bd[i].status = 0xF0000000;
-		priv->rx_bd[i].addr = (u32)((char *) &(priv->rxbuffers) +
+	if (!priv->init) {
+		/* Disable all interrupts */
+		writel(0xFFFFFFFF, &regs->idr);
+
+		/* Disable the receiver & transmitter */
+		writel(0, &regs->nwctrl);
+		writel(0, &regs->txsr);
+		writel(0, &regs->rxsr);
+		writel(0, &regs->phymntnc);
+
+		/* Clear the Hash registers for the mac address
+		 * pointed by AddressPtr
+		 */
+		writel(0x0, &regs->hashl);
+		/* Write bits [63:32] in TOP */
+		writel(0x0, &regs->hashh);
+
+		/* Clear all counters */
+		for (i = 0; i <= stat_size; i++)
+			readl(&regs->stat[i]);
+
+		/* Setup RxBD space */
+		memset(&(priv->rx_bd), 0, sizeof(priv->rx_bd));
+		/* Create the RxBD ring */
+		memset(&(priv->rxbuffers), 0, sizeof(priv->rxbuffers));
+
+		for (i = 0; i < RX_BUF; i++) {
+			priv->rx_bd[i].status = 0xF0000000;
+			priv->rx_bd[i].addr =
+					(u32)((char *)&(priv->rxbuffers) +
 							(i * PKTSIZE_ALIGN));
-	}
-	/* WRAP bit to last BD */
-	priv->rx_bd[--i].addr |= ZYNQ_GEM_RXBUF_WRAP_MASK;
-	/* Write RxBDs to IP */
-	writel((u32) &(priv->rx_bd), &regs->rxqbase);
+		}
+		/* WRAP bit to last BD */
+		priv->rx_bd[--i].addr |= ZYNQ_GEM_RXBUF_WRAP_MASK;
+		/* Write RxBDs to IP */
+		writel((u32)&(priv->rx_bd), &regs->rxqbase);
 
-	/* MAC Setup */
-	/* Setup Network Configuration register */
-	writel(ZYNQ_GEM_NWCFG_INIT, &regs->nwcfg);
+		/* MAC Setup */
+		/* Setup Network Configuration register */
+		writel(ZYNQ_GEM_NWCFG_INIT, &regs->nwcfg);
 
-	/* Setup for DMA Configuration register */
-	writel(ZYNQ_GEM_DMACR_INIT, &regs->dmacr);
+		/* Setup for DMA Configuration register */
+		writel(ZYNQ_GEM_DMACR_INIT, &regs->dmacr);
 
-	/* Setup for Network Control register, MDIO, Rx and Tx enable */
-	setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_MDEN_MASK |
+		/* Setup for Network Control register, MDIO, Rx and Tx enable */
+		setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_MDEN_MASK |
 			ZYNQ_GEM_NWCTRL_RXEN_MASK | ZYNQ_GEM_NWCTRL_TXEN_MASK);
 
+		priv->init++;
+	}
+
 	/* interface - look at tsec */
 	phydev = phy_connect(priv->bus, priv->phyaddr, dev, 0);
 
@@ -307,7 +315,7 @@ static int zynq_gem_send(struct eth_device *dev, void *ptr, int len)
 	writel((u32)&(priv->tx_bd), &regs->txqbase);
 
 	/* Setup Tx BD */
-	memset((void *) &(priv->tx_bd), 0, sizeof(struct emac_bd));
+	memset((void *)&(priv->tx_bd), 0, sizeof(struct emac_bd));
 
 	priv->tx_bd.addr = (u32)ptr;
 	priv->tx_bd.status = len | ZYNQ_GEM_TXBUF_LAST_MASK;

--
1.8.2.1

-------------- 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/20130422/cc78e896/attachment.pgp>

#8 lore raw

PATCH 7/14 net: gem: Fix gem driver on 1Gbps LAN

In reply to Michal Simek

From: Michal Simek <[email protected]>

The whole driver used 100Mbps because of zc702 rev B. Fix problem with not setup proper clock for gem1. This is generic approach for clk setup.

---
 arch/arm/cpu/armv7/zynq/slcr.c             | 26 +++++++++++++++
 arch/arm/include/asm/arch-zynq/hardware.h  |  7 +++-
 arch/arm/include/asm/arch-zynq/sys_proto.h |  1 +
 drivers/net/zynq_gem.c                     | 53 +++++++++++++++++++++---------
 4 files changed, 71 insertions(+), 16 deletions(-)
arch/arm/cpu/armv7/zynq/slcr.c +26 -0
index 788a8fd..5a8674a 100644
@@ -61,3 +61,29 @@ void zynq_slcr_cpu_reset(void)
 
 	writel(1, &slcr_base->pss_rst_ctrl);
 }
+
+/* Setup clk for network */
+void zynq_slcr_gem_clk_setup(u32 gem_id, u32 rclk, u32 clk)
+{
+	zynq_slcr_unlock();
+
+	if (gem_id > 1) {
+		printf("Non existing GEM id %d\n", gem_id);
+		goto out;
+	}
+
+	if (gem_id) {
+		/* Set divisors for appropriate frequency in GEM_CLK_CTRL */
+		writel(clk, &slcr_base->gem1_clk_ctrl);
+		/* Configure GEM_RCLK_CTRL */
+		writel(rclk, &slcr_base->gem1_rclk_ctrl);
+	} else {
+		/* Set divisors for appropriate frequency in GEM_CLK_CTRL */
+		writel(clk, &slcr_base->gem0_clk_ctrl);
+		/* Configure GEM_RCLK_CTRL */
+		writel(rclk, &slcr_base->gem0_rclk_ctrl);
+	}
+
+out:
+	zynq_slcr_lock();
+}
arch/arm/include/asm/arch-zynq/hardware.h +6 -1
index 1b72773..bee7b09 100644
@@ -33,7 +33,12 @@ struct slcr_regs {
 	u32 scl; /* 0x0 */
 	u32 slcr_lock; /* 0x4 */
 	u32 slcr_unlock; /* 0x8 */
-	u32 reserved1[125];
+	u32 reserved0[75];
+	u32 gem0_rclk_ctrl; /* 0x138 */
+	u32 gem1_rclk_ctrl; /* 0x13c */
+	u32 gem0_clk_ctrl; /* 0x140 */
+	u32 gem1_clk_ctrl; /* 0x144 */
+	u32 reserved1[46];
 	u32 pss_rst_ctrl; /* 0x200 */
 	u32 reserved2[15];
 	u32 fpga_rst_ctrl; /* 0x240 */
arch/arm/include/asm/arch-zynq/sys_proto.h +1 -0
index e788900..57128dc 100644
@@ -26,5 +26,6 @@
 extern void zynq_slcr_lock(void);
 extern void zynq_slcr_unlock(void);
 extern void zynq_slcr_cpu_reset(void);
+extern void zynq_slcr_gem_clk_setup(u32 gem_id, u32 rclk, u32 clk);
 
 #endif /* _SYS_PROTO_H_ */
drivers/net/zynq_gem.c +38 -15

100 lines not on this page · raw message

--
1.8.2.1

-------------- 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/20130422/e4e53a35/attachment.pgp>

#9 lore raw

PATCH 8/14 zynq: Move macros to hardware.h

In reply to Michal Simek

Add all fixed addresses to hardware.h and change petalinux configuration to support this.

---
 arch/arm/include/asm/arch-zynq/hardware.h |  2 ++
 board/xilinx/zynq/board.c                 | 12 +++++++++---
 include/configs/zynq.h                    |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
index bee7b09..e0f6eba 100644
@@ -27,6 +27,8 @@
 #define XPSS_DEV_CFG_APB_BASEADDR	0xF8007000
 #define XPSS_SCU_BASEADDR		0xF8F00000
 #define CONFIG_SCUTIMER_BASEADDR	0xF8F00600
+#define CONFIG_ZYNQ_GEM_BASEADDR0	0xE000B000
+#define CONFIG_ZYNQ_GEM_BASEADDR1	0xE000C000
 
 /* Reflect slcr offsets */
 struct slcr_regs {
board/xilinx/zynq/board.c +9 -3
index 8ed75c3..8da476c 100644
@@ -22,6 +22,8 @@
 
 #include <common.h>
 #include <netdev.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -38,10 +40,14 @@ int board_eth_init(bd_t *bis)
 {
 	u32 ret = 0;
 
-#if defined(CONFIG_ZYNQ_GEM) && defined(CONFIG_ZYNQ_GEM_BASEADDR0)
-	ret = zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR0);
+#if defined(CONFIG_ZYNQ_GEM)
+# if defined(CONFIG_ZYNQ_GEM0)
+	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR0);
+# endif
+# if defined(CONFIG_ZYNQ_GEM1)
+	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR1);
+# endif
 #endif
-
 	return ret;
 }
 #endif
include/configs/zynq.h +1 -1
index 1147689..ebe1b1b 100644
@@ -53,7 +53,7 @@
 /* Ethernet driver */
 #define CONFIG_NET_MULTI
 #define CONFIG_ZYNQ_GEM
-#define CONFIG_ZYNQ_GEM_BASEADDR0	0xE000B000
+#define CONFIG_ZYNQ_GEM0
 
 #if defined(CONFIG_ZYNQ_DCC)
 # define CONFIG_ARM_DCC

--
1.8.2.1

-------------- 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/20130422/b9f60694/attachment.pgp>

#10 lore raw

PATCH 8/14 zynq: Move macros to hardware.h

Quoted 15 lines · Michal Simek

Add all fixed addresses to hardware.h and change petalinux configuration to support this.

---
 arch/arm/include/asm/arch-zynq/hardware.h |  2 ++
 board/xilinx/zynq/board.c                 | 12 +++++++++---
 include/configs/zynq.h                    |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-zynq/hardware.h +0 -0
index bee7b09..e0f6eba 100644

arch/arm/include/asm/arch-zynq/hardware.h line 31

Quoted 5 lines
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
@@ -27,6 +27,8 @@
 #define XPSS_DEV_CFG_APB_BASEADDR	0xF8007000
 #define XPSS_SCU_BASEADDR		0xF8F00000
 #define CONFIG_SCUTIMER_BASEADDR	0xF8F00600
+#define CONFIG_ZYNQ_GEM_BASEADDR0	0xE000B000
+#define CONFIG_ZYNQ_GEM_BASEADDR1	0xE000C000

Are these configurable really or no? If they're in <hardware.h> they shouldn't be CONFIG named.

Signature · 8 lines
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/20130422/de3531cc/attachment.pgp>
#11 lore raw

PATCH 9/14 net: gem: Pass phy address to init

In reply to Michal Simek

From: David Andrey <[email protected]>

Pass the PHY address to the driver init to
allow parallel use of both interfaces

---
 board/xilinx/zynq/board.c | 6 ++++--
 drivers/net/zynq_gem.c    | 8 ++------
 include/configs/zynq.h    | 1 +
 include/netdev.h          | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)
board/xilinx/zynq/board.c +4 -2
index 8da476c..f92d5a8 100644
@@ -42,10 +42,12 @@ int board_eth_init(bd_t *bis)
 
 #if defined(CONFIG_ZYNQ_GEM)
 # if defined(CONFIG_ZYNQ_GEM0)
-	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR0);
+	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR0,
+						CONFIG_ZYNQ_GEM_PHY_ADDR0);
 # endif
 # if defined(CONFIG_ZYNQ_GEM1)
-	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR1);
+	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR1,
+						CONFIG_ZYNQ_GEM_PHY_ADDR1);
 # endif
 #endif
 	return ret;
drivers/net/zynq_gem.c +2 -6
index 2d717e9..316816d 100644
@@ -427,7 +427,7 @@ static int zynq_gem_miiphy_write(const char *devname, uchar addr,
 	return phywrite(dev, addr, reg, val);
 }
 
-int zynq_gem_initialize(bd_t *bis, int base_addr)
+int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr)
 {
 	struct eth_device *dev;
 	struct zynq_gem_priv *priv;
@@ -443,11 +443,7 @@ int zynq_gem_initialize(bd_t *bis, int base_addr)
 	}
 	priv = dev->priv;
 
-#ifdef CONFIG_PHY_ADDR
-	priv->phyaddr = CONFIG_PHY_ADDR;
-#else
-	priv->phyaddr = -1;
-#endif
+	priv->phyaddr = phy_addr;
 
 	sprintf(dev->name, "Gem.%x", base_addr);
 
include/configs/zynq.h +1 -0
index ebe1b1b..3b23354 100644
@@ -54,6 +54,7 @@
 #define CONFIG_NET_MULTI
 #define CONFIG_ZYNQ_GEM
 #define CONFIG_ZYNQ_GEM0
+#define CONFIG_ZYNQ_GEM_PHY_ADDR0	7
 
 #if defined(CONFIG_ZYNQ_DCC)
 # define CONFIG_ARM_DCC
include/netdev.h +1 -1
index fd3e243..81117b1 100644
@@ -104,7 +104,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_initialize(bd_t *bis, int base_addr);
+int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr);
 /*
  * As long as the Xilinx xps_ll_temac ethernet driver has not its own interface
  * exported by a public hader file, we need a global definition at this point.

--
1.8.2.1

-------------- 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/20130422/09c2ff5e/attachment.pgp>

#12 lore raw

PATCH 10/14 net: gem: Preserve clk on emio interface

In reply to Michal Simek

From: David Andrey <[email protected]>

Avoid overwriting GEMx_RCLK_CTRL and GEMx_CLK_CTRL if the Ethernet interface is connect on EMIO

Do not enable emio for this standard board configuration for now.

---
 board/xilinx/zynq/board.c |  4 ++--
 drivers/net/zynq_gem.c    | 12 +++++++++---
 include/netdev.h          |  2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)
board/xilinx/zynq/board.c +2 -2
index f92d5a8..574a6fb 100644
@@ -43,11 +43,11 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_ZYNQ_GEM)
 # if defined(CONFIG_ZYNQ_GEM0)
 	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR0,
-						CONFIG_ZYNQ_GEM_PHY_ADDR0);
+						CONFIG_ZYNQ_GEM_PHY_ADDR0, 0);
 # endif
 # if defined(CONFIG_ZYNQ_GEM1)
 	ret |= zynq_gem_initialize(bis, CONFIG_ZYNQ_GEM_BASEADDR1,
-						CONFIG_ZYNQ_GEM_PHY_ADDR1);
+						CONFIG_ZYNQ_GEM_PHY_ADDR1, 0);
 # endif
 #endif
 	return ret;
drivers/net/zynq_gem.c +9 -3
index 316816d..ee3ff73 100644
@@ -33,6 +33,7 @@
 #include <phy.h>
 #include <miiphy.h>
 #include <watchdog.h>
+#include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
 
 #if !defined(CONFIG_PHYLIB)
@@ -136,6 +137,7 @@ struct zynq_gem_priv {
 	u32 rxbd_current;
 	u32 rx_first_buf;
 	int phyaddr;
+	u32 emio;
 	int init;
 	struct phy_device *phydev;
 	struct mii_dev *bus;
@@ -317,8 +319,11 @@ static int zynq_gem_init(struct eth_device *dev, bd_t * bis)
 		clk = (5 << 20) | (8 << 8) | (0 << 4) | (1 << 0);
 		break;
 	}
-	/* FIXME maybe better to define gem address in hardware.h */
-	zynq_slcr_gem_clk_setup(dev->iobase != 0xE000B000, rclk, clk);
+
+	/* Change the rclk and clk only not using EMIO interface */
+	if (!priv->emio)
+		zynq_slcr_gem_clk_setup(dev->iobase !=
+					CONFIG_ZYNQ_GEM_BASEADDR0, rclk, clk);
 
 	setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_RXEN_MASK |
 					ZYNQ_GEM_NWCTRL_TXEN_MASK);
@@ -427,7 +432,7 @@ static int zynq_gem_miiphy_write(const char *devname, uchar addr,
 	return phywrite(dev, addr, reg, val);
 }
 
-int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr)
+int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio)
 {
 	struct eth_device *dev;
 	struct zynq_gem_priv *priv;
@@ -444,6 +449,7 @@ int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr)
 	priv = dev->priv;
 
 	priv->phyaddr = phy_addr;
+	priv->emio = emio;
 
 	sprintf(dev->name, "Gem.%x", base_addr);
 
include/netdev.h +1 -1
index 81117b1..516b351 100644
@@ -104,7 +104,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_initialize(bd_t *bis, int base_addr, int phy_addr);
+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
  * exported by a public hader file, we need a global definition at this point.

--
1.8.2.1

-------------- 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/20130422/b0186a38/attachment.pgp>

#13 lore raw

PATCH 11/14 net: gem: Add support for phy autodetection

In reply to Michal Simek

Autodetect phy if phyaddress is setup to -1.

---
 drivers/net/zynq_gem.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
drivers/net/zynq_gem.c +51 -0
index ee3ff73..c4d0de4 100644
@@ -95,6 +95,17 @@
 					ZYNQ_GEM_DMACR_TXSIZE | \
 					ZYNQ_GEM_DMACR_RXBUF)
 
+/* Use MII register 1 (MII status register) to detect PHY */
+#define PHY_DETECT_REG  1
+
+/* Mask used to verify certain PHY features (or register contents)
+ * in the register above:
+ *  0x1000: 10Mbps full duplex support
+ *  0x0800: 10Mbps half duplex support
+ *  0x0008: Auto-negotiation support
+ */
+#define PHY_DETECT_MASK 0x1808
+
 /* Device registers */
 struct zynq_gem_regs {
 	u32 nwctrl; /* Network Control reg */
@@ -201,6 +212,44 @@ static u32 phywrite(struct eth_device *dev, u32 phy_addr, u32 regnum, u16 data)
 				ZYNQ_GEM_PHYMNTNC_OP_W_MASK, &data);
 }
 
+static void phy_detection(struct eth_device *dev)
+{
+	int i;
+	u16 phyreg;
+	struct zynq_gem_priv *priv = dev->priv;
+
+	if (priv->phyaddr != -1) {
+		phyread(dev, priv->phyaddr, PHY_DETECT_REG, &phyreg);
+		if ((phyreg != 0xFFFF) &&
+		    ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
+			/* Found a valid PHY address */
+			debug("Default phy address %d is valid\n",
+			      priv->phyaddr);
+			return;
+		} else {
+			debug("PHY address is not setup correctly %d\n",
+			      priv->phyaddr);
+			priv->phyaddr = -1;
+		}
+	}
+
+	debug("detecting phy address\n");
+	if (priv->phyaddr == -1) {
+		/* detect the PHY address */
+		for (i = 31; i >= 0; i--) {
+			phyread(dev, i, PHY_DETECT_REG, &phyreg);
+			if ((phyreg != 0xFFFF) &&
+			    ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
+				/* Found a valid PHY address */
+				priv->phyaddr = i;
+				debug("Found valid phy address, %d\n", i);
+				return;
+			}
+		}
+	}
+	printf("PHY is not detected\n");
+}
+
 static int zynq_gem_setup_mac(struct eth_device *dev)
 {
 	u32 i, macaddrlow, macaddrhigh;
@@ -290,6 +339,8 @@ static int zynq_gem_init(struct eth_device *dev, bd_t * bis)
 		priv->init++;
 	}
 
+	phy_detection(dev);
+
 	/* interface - look at tsec */
 	phydev = phy_connect(priv->bus, priv->phyaddr, dev, 0);
 

--
1.8.2.1

-------------- 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/20130422/b5057d31/attachment.pgp>

#14 lore raw

PATCH 12/14 mmc: Add support for Xilinx Zynq sdhci controller

In reply to Michal Simek

Add support for SD, MMC and eMMC card on Xilinx Zynq.

---
 arch/arm/include/asm/arch-zynq/hardware.h  |  2 ++
 arch/arm/include/asm/arch-zynq/sys_proto.h |  3 +++
 board/xilinx/zynq/board.c                  | 17 +++++++++++++
 drivers/mmc/Makefile                       |  1 +
 drivers/mmc/zynq_sdhci.c                   | 40 ++++++++++++++++++++++++++++++
 include/configs/zynq.h                     | 16 ++++++++++++
 6 files changed, 79 insertions(+)
 create mode 100644 drivers/mmc/zynq_sdhci.c
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
index e0f6eba..3fa94d7 100644
@@ -29,6 +29,8 @@
 #define CONFIG_SCUTIMER_BASEADDR	0xF8F00600
 #define CONFIG_ZYNQ_GEM_BASEADDR0	0xE000B000
 #define CONFIG_ZYNQ_GEM_BASEADDR1	0xE000C000
+#define CONFIG_ZYNQ_SDHCI_BASEADDR0	0xE0100000
+#define CONFIG_ZYNQ_SDHCI_BASEADDR1	0xE0101000
 
 /* Reflect slcr offsets */
 struct slcr_regs {
arch/arm/include/asm/arch-zynq/sys_proto.h +3 -0
index 57128dc..af9e7f8 100644
@@ -28,4 +28,7 @@ extern void zynq_slcr_unlock(void);
 extern void zynq_slcr_cpu_reset(void);
 extern void zynq_slcr_gem_clk_setup(u32 gem_id, u32 rclk, u32 clk);
 
+/* Driver extern functions */
+extern int zynq_sdhci_init(u32 regbase);
+
 #endif /* _SYS_PROTO_H_ */
board/xilinx/zynq/board.c +17 -0
index 574a6fb..e42febd 100644
@@ -54,6 +54,23 @@ int board_eth_init(bd_t *bis)
 }
 #endif
 
+#ifdef CONFIG_CMD_MMC
+int board_mmc_init(bd_t *bd)
+{
+	int ret = 0;
+
+#if defined(CONFIG_ZYNQ_SDHCI)
+# if defined(CONFIG_ZYNQ_SDHCI0)
+	ret = zynq_sdhci_init(CONFIG_ZYNQ_SDHCI_BASEADDR0);
+# endif
+# if defined(CONFIG_ZYNQ_SDHCI1)
+	ret |= zynq_sdhci_init(CONFIG_ZYNQ_SDHCI_BASEADDR1);
+# endif
+#endif
+	return ret;
+}
+#endif
+
 int dram_init(void)
 {
 	gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
drivers/mmc/Makefile +1 -0
index 1d6faa2..7cd4281 100644
@@ -49,6 +49,7 @@ COBJS-$(CONFIG_SH_MMCIF) += sh_mmcif.o
 COBJS-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
 COBJS-$(CONFIG_DWMMC) += dw_mmc.o
 COBJS-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
+COBJS-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mmc/zynq_sdhci.c new file +40 -0
new file mode 100644
index 0000000..9e37af4
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2013 Inc.
+ *
+ * Xilinx Zynq SD Host Controller Interface
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <sdhci.h>
+#include <asm/arch/sys_proto.h>
+
+int zynq_sdhci_init(u32 regbase)
+{
+	struct sdhci_host *host = NULL;
+
+	host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
+	if (!host) {
+		printf("zynq_sdhci_init: sdhci_host malloc fail\n");
+		return 1;
+	}
+
+	host->name = "zynq_sdhci";
+	host->ioaddr = (void *)regbase;
+	host->quirks = SDHCI_QUIRK_NO_CD | SDHCI_QUIRK_WAIT_SEND_CMD;
+	host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
+
+	host->host_caps = MMC_MODE_HC;
+
+	add_sdhci(host, 52000000, 52000000 >> 9);
+	return 0;
+}
include/configs/zynq.h +16 -0
index 3b23354..2ed88a7 100644
@@ -56,6 +56,22 @@
 #define CONFIG_ZYNQ_GEM0
 #define CONFIG_ZYNQ_GEM_PHY_ADDR0	7
 
+#define CONFIG_ZYNQ_SDHCI
+#define CONFIG_ZYNQ_SDHCI0
+
+/* MMC */
+#if defined(CONFIG_ZYNQ_SDHCI0) || defined(CONFIG_ZYNQ_SDHCI1)
+# define CONFIG_MMC
+# define CONFIG_GENERIC_MMC
+# define CONFIG_SDHCI
+# define CONFIG_ZYNQ_SDHCI
+# define CONFIG_CMD_MMC
+# define CONFIG_CMD_FAT
+# define CONFIG_SUPPORT_VFAT
+# define CONFIG_CMD_EXT2
+# define CONFIG_DOS_PARTITION
+#endif
+
 #if defined(CONFIG_ZYNQ_DCC)
 # define CONFIG_ARM_DCC
 # define CONFIG_CPU_V6 /* Required by CONFIG_ARM_DCC */

--
1.8.2.1

-------------- 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/20130422/0b1a0878/attachment.pgp>

#15 lore raw

PATCH 13/14 i2c: zynq: Add support for Xilinx Zynq

In reply to Michal Simek

Support Xilinx Zynq i2c controller.

---
 arch/arm/include/asm/arch-zynq/hardware.h |   2 +
 drivers/i2c/Makefile                      |   1 +
 drivers/i2c/zynq_i2c.c                    | 304 ++++++++++++++++++++++++++++++
 include/configs/zynq.h                    |  11 ++
 4 files changed, 318 insertions(+)
 create mode 100644 drivers/i2c/zynq_i2c.c
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
index 3fa94d7..901a74c 100644
@@ -31,6 +31,8 @@
 #define CONFIG_ZYNQ_GEM_BASEADDR1	0xE000C000
 #define CONFIG_ZYNQ_SDHCI_BASEADDR0	0xE0100000
 #define CONFIG_ZYNQ_SDHCI_BASEADDR1	0xE0101000
+#define CONFIG_ZYNQ_I2C_BASEADDR0	0xE0004000
+#define CONFIG_ZYNQ_I2C_BASEADDR1	0xE0005000
 
 /* Reflect slcr offsets */
 struct slcr_regs {
drivers/i2c/Makefile +1 -0
index 5dbdbe3..72e85a3 100644
@@ -46,6 +46,7 @@ COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
 COBJS-$(CONFIG_U8500_I2C) += u8500_i2c.o
 COBJS-$(CONFIG_SH_I2C) += sh_i2c.o
 COBJS-$(CONFIG_SH_SH7734_I2C) += sh_sh7734_i2c.o
+COBJS-$(CONFIG_ZYNQ_I2C) += zynq_i2c.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/i2c/zynq_i2c.c new file +304 -0

304 lines not on this page · raw message

include/configs/zynq.h +11 -0
index 2ed88a7..6877a68 100644
@@ -72,6 +72,17 @@
 # define CONFIG_DOS_PARTITION
 #endif
 
+#define CONFIG_ZYNQ_I2C0
+
+/* I2C */
+#if defined(CONFIG_ZYNQ_I2C0) || defined(CONFIG_ZYNQ_I2C1)
+# define CONFIG_CMD_I2C
+# define CONFIG_ZYNQ_I2C
+# define CONFIG_HARD_I2C		1
+# define CONFIG_SYS_I2C_SPEED		100000
+# define CONFIG_SYS_I2C_SLAVE		1
+#endif
+
 #if defined(CONFIG_ZYNQ_DCC)
 # define CONFIG_ARM_DCC
 # define CONFIG_CPU_V6 /* Required by CONFIG_ARM_DCC */

--
1.8.2.1

-------------- 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/20130422/68d8f2d6/attachment.pgp>

#16 lore raw

PATCH 13/14 i2c: zynq: Add support for Xilinx Zynq

Quoted 4 lines · Michal Simek

Support Xilinx Zynq i2c controller.

Adding Heiko (http://patchwork.ozlabs.org/patch/238560/) ...

Quoted 4 lines
---
 arch/arm/include/asm/arch-zynq/hardware.h |   2 +
 drivers/i2c/Makefile                      |   1 +
 drivers/i2c/zynq_i2c.c                    | 304 ++++++++++++++++++++++++++++++

There's 3 new checkpatch warnings here, please fix. Also:

arch/arm/include/asm/arch-zynq/hardware.h line 35

Quoted 8 lines
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
@@ -31,6 +31,8 @@
 #define CONFIG_ZYNQ_GEM_BASEADDR1	0xE000C000
 #define CONFIG_ZYNQ_SDHCI_BASEADDR0	0xE0100000
 #define CONFIG_ZYNQ_SDHCI_BASEADDR1	0xE0101000
+#define CONFIG_ZYNQ_I2C_BASEADDR0	0xE0004000
+#define CONFIG_ZYNQ_I2C_BASEADDR1	0xE0005000

Same comment as before about CONFIG in <hardware.h>

arch/arm/include/asm/arch-zynq/hardware.h line 37

Quoted 2 lines
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
+/* Control register fields */
+#define	ZYNQ_I2C_CONTROL_RW		0x00000001

'#define<space>', fix globally please.

arch/arm/include/asm/arch-zynq/hardware.h

Quoted 2 lines
arch/arm/include/asm/arch-zynq/hardware.h +2 -0
+	/* Temporarily disable restart (by clearing hold)... */
+	/* It doesn't seem to work. */

/*
* Multi line comments go like this
*/

[snip]

Quoted 1 line

+# define CONFIG_HARD_I2C 1

No need for training 1 here.

Signature · 8 lines
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/20130422/7d0f9194/attachment.pgp>
#17 lore raw

PATCH 14/14 fpga: Add support for loading bitstream for Xilinx Zynq

In reply to Michal Simek

Devcfg device requires to load bitstream in binary format.

---
 arch/arm/cpu/armv7/zynq/slcr.c             |  36 +++++
 arch/arm/include/asm/arch-zynq/hardware.h  |  10 +-
 arch/arm/include/asm/arch-zynq/sys_proto.h |   3 +
 board/xilinx/zynq/board.c                  |  37 +++++
 drivers/fpga/Makefile                      |   1 +
 drivers/fpga/xilinx.c                      |  37 +++++
 drivers/fpga/zynqpl.c                      | 231 +++++++++++++++++++++++++++++
 include/configs/zynq.h                     |   6 +
 include/xilinx.h                           |   4 +
 include/zynqpl.h                           |  61 ++++++++
 10 files changed, 424 insertions(+), 2 deletions(-)
 create mode 100644 drivers/fpga/zynqpl.c
 create mode 100644 include/zynqpl.h
arch/arm/cpu/armv7/zynq/slcr.c +36 -0
index 5a8674a..a391af4 100644
@@ -28,6 +28,9 @@
 #define SLCR_LOCK_MAGIC		0x767B
 #define SLCR_UNLOCK_MAGIC	0xDF0D
 
+#define SLCR_IDCODE_MASK	0x1F000
+#define SLCR_IDCODE_SHIFT	12
+
 static int slcr_lock = 1; /* 1 means locked, 0 means unlocked */
 
 void zynq_slcr_lock(void)
@@ -87,3 +90,36 @@ void zynq_slcr_gem_clk_setup(u32 gem_id, u32 rclk, u32 clk)
 out:
 	zynq_slcr_lock();
 }
+
+void zynq_slcr_devcfg_disable(void)
+{
+	zynq_slcr_unlock();
+
+	/* Disable AXI interface */
+	writel(0xFFFFFFFF, &slcr_base->fpga_rst_ctrl);
+
+	/* Set Level Shifters DT618760 */
+	writel(0xA, &slcr_base->lvl_shftr_en);
+
+	zynq_slcr_lock();
+}
+
+void zynq_slcr_devcfg_enable(void)
+{
+	zynq_slcr_unlock();
+
+	/* Set Level Shifters DT618760 */
+	writel(0xF, &slcr_base->lvl_shftr_en);
+
+	/* Disable AXI interface */
+	writel(0x0, &slcr_base->fpga_rst_ctrl);
+
+	zynq_slcr_lock();
+}
+
+u32 zynq_slcr_get_idcode(void)
+{
+	return (readl(&slcr_base->pss_idcode) & SLCR_IDCODE_MASK) >>
+							SLCR_IDCODE_SHIFT;
+}
+
arch/arm/include/asm/arch-zynq/hardware.h +8 -2
index 901a74c..93e6894 100644
@@ -53,11 +53,17 @@ struct slcr_regs {
 	u32 boot_mode; /* 0x25c */
 	u32 reserved4[116];
 	u32 trust_zone; /* 0x430 */ /* FIXME */
-	u32 reserved5[115];
+	u32 reserved5_1[63];
+	u32 pss_idcode; /* 0x530 */
+	u32 reserved5_2[51];
 	u32 ddr_urgent; /* 0x600 */
 	u32 reserved6[6];
 	u32 ddr_urgent_sel; /* 0x61c */
-	u32 reserved7[188];
+	u32 reserved7[56];
+	u32 mio_pin[54]; /* 0x700 - 0x7D4 */
+	u32 reserved8[74];
+	u32 lvl_shftr_en; /* 0x900 */
+	u32 reserved9[3];
 	u32 ocm_cfg; /* 0x910 */
 };
 
arch/arm/include/asm/arch-zynq/sys_proto.h +3 -0
index af9e7f8..2317121 100644
@@ -27,6 +27,9 @@ extern void zynq_slcr_lock(void);
 extern void zynq_slcr_unlock(void);
 extern void zynq_slcr_cpu_reset(void);
 extern void zynq_slcr_gem_clk_setup(u32 gem_id, u32 rclk, u32 clk);
+extern void zynq_slcr_devcfg_disable(void);
+extern void zynq_slcr_devcfg_enable(void);
+extern u32 zynq_slcr_get_idcode(void);
 
 /* Driver extern functions */
 extern int zynq_sdhci_init(u32 regbase);
board/xilinx/zynq/board.c +37 -0
index e42febd..4bc757a 100644
@@ -22,15 +22,52 @@
 
 #include <common.h>
 #include <netdev.h>
+#include <zynqpl.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_FPGA
+Xilinx_desc fpga;
+
+/* It can be done differently */
+Xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
+Xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
+Xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
+Xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
+#endif
+
 int board_init(void)
 {
+#ifdef CONFIG_FPGA
+	u32 idcode;
+
+	idcode = zynq_slcr_get_idcode();
+
+	switch (idcode) {
+	case XILINX_ZYNQ_7010:
+		fpga = fpga010;
+		break;
+	case XILINX_ZYNQ_7020:
+		fpga = fpga020;
+		break;
+	case XILINX_ZYNQ_7030:
+		fpga = fpga030;
+		break;
+	case XILINX_ZYNQ_7045:
+		fpga = fpga045;
+		break;
+	}
+#endif
+
 	icache_enable();
 
+#ifdef CONFIG_FPGA
+	fpga_init();
+	fpga_add(fpga_xilinx, &fpga);
+#endif
+
 	return 0;
 }
 
drivers/fpga/Makefile +1 -0
index b48f623..0b51dcd 100644
@@ -30,6 +30,7 @@ COBJS-y += fpga.o
 COBJS-$(CONFIG_FPGA_SPARTAN2) += spartan2.o
 COBJS-$(CONFIG_FPGA_SPARTAN3) += spartan3.o
 COBJS-$(CONFIG_FPGA_VIRTEX2) += virtex2.o
+COBJS-$(CONFIG_FPGA_ZYNQPL) += zynqpl.o
 COBJS-$(CONFIG_FPGA_XILINX) += xilinx.o
 COBJS-$(CONFIG_FPGA_LATTICE) += ivm_core.o lattice.o
 ifdef CONFIG_FPGA_ALTERA
drivers/fpga/xilinx.c +37 -0
index 32787b2..9b8b692 100644
@@ -1,4 +1,6 @@
 /*
+ * (C) Copyright 2012-2013, Xilinx, Michal Simek
+ *
  * (C) Copyright 2002
  * Rich Ireland, Enterasys Networks, rireland at enterasys.com.
  * Keith Outwater, keith_outwater at mvis.com
@@ -31,6 +33,7 @@
 #include <virtex2.h>
 #include <spartan2.h>
 #include <spartan3.h>
+#include <zynqpl.h>
 
 #if 0
 #define FPGA_DEBUG
@@ -86,6 +89,16 @@ int xilinx_load(Xilinx_desc *desc, const void *buf, size_t bsize)
 					__FUNCTION__);
 #endif
 			break;
+		case Xilinx_Zynq:
+#if defined(CONFIG_FPGA_ZYNQPL)
+			PRINTF("%s: Launching the Zynq PL Loader...\n",
+					__func__);
+			ret_val = zynq_load(desc, buf, bsize);
+#else
+			printf("%s: No support for Zynq devices.\n",
+					__func__);
+#endif
+			break;
 
 		default:
 			printf ("%s: Unsupported family type, %d\n",
@@ -133,6 +146,16 @@ int xilinx_dump(Xilinx_desc *desc, const void *buf, size_t bsize)
 					__FUNCTION__);
 #endif
 			break;
+		case Xilinx_Zynq:
+#if defined(CONFIG_FPGA_ZYNQPL)
+			PRINTF("%s: Launching the Zynq PL Reader...\n",
+					__func__);
+			ret_val = zynq_dump(desc, buf, bsize);
+#else
+			printf("%s: No support for Zynq devices.\n",
+					__func__);
+#endif
+			break;
 
 		default:
 			printf ("%s: Unsupported family type, %d\n",
@@ -158,6 +181,9 @@ int xilinx_info (Xilinx_desc * desc)
 		case Xilinx_Virtex2:
 			printf ("Virtex-II\n");
 			break;
+		case Xilinx_Zynq:
+			printf("Zynq PL\n");
+			break;
 			/* Add new family types here */
 		default:
 			printf ("Unknown family type, %d\n", desc->family);
@@ -183,6 +209,9 @@ int xilinx_info (Xilinx_desc * desc)
 		case master_selectmap:
 			printf ("Master SelectMap Mode\n");
 			break;
+		case devcfg:
+			printf("Device configuration interface (Zynq)\n");
+			break;
 			/* Add new interface types here */
 		default:
 			printf ("Unsupported interface type, %d\n", desc->iface);
@@ -222,6 +251,14 @@ int xilinx_info (Xilinx_desc * desc)
 						__FUNCTION__);
 #endif
 				break;
+			case Xilinx_Zynq:
+#if defined(CONFIG_FPGA_ZYNQPL)
+				zynq_info(desc);
+#else
+				/* just in case */
+				printf("%s: No support for Zynq devices.\n",
+						__func__);
+#endif
 				/* Add new family types here */
 			default:
 				/* we don't need a message here - we give one up above */
drivers/fpga/zynqpl.c new file +231 -0

231 lines not on this page · raw message

include/configs/zynq.h +6 -0
index 6877a68..5a05c3a 100644
@@ -88,6 +88,12 @@
 # define CONFIG_CPU_V6 /* Required by CONFIG_ARM_DCC */
 #endif
 
+/* Enable the PL to be downloaded */
+#define CONFIG_FPGA
+#define CONFIG_FPGA_XILINX
+#define CONFIG_FPGA_ZYNQPL
+#define CONFIG_CMD_FPGA
+
 #define CONFIG_BOOTP_SERVERIP
 #define CONFIG_BOOTP_BOOTPATH
 #define CONFIG_BOOTP_GATEWAY
include/xilinx.h +4 -0
index 5f25b7a..4cf53cb 100644
@@ -33,10 +33,12 @@
 #define CONFIG_SYS_VIRTEX_E			CONFIG_SYS_FPGA_DEV( 0x2 )
 #define CONFIG_SYS_VIRTEX2			CONFIG_SYS_FPGA_DEV( 0x4 )
 #define CONFIG_SYS_SPARTAN3			CONFIG_SYS_FPGA_DEV( 0x8 )
+#define CONFIG_SYS_ZYNQ				CONFIG_SYS_FPGA_DEV(0x10)
 #define CONFIG_SYS_XILINX_SPARTAN2	(CONFIG_SYS_FPGA_XILINX | CONFIG_SYS_SPARTAN2)
 #define CONFIG_SYS_XILINX_VIRTEX_E	(CONFIG_SYS_FPGA_XILINX | CONFIG_SYS_VIRTEX_E)
 #define CONFIG_SYS_XILINX_VIRTEX2	(CONFIG_SYS_FPGA_XILINX | CONFIG_SYS_VIRTEX2)
 #define CONFIG_SYS_XILINX_SPARTAN3	(CONFIG_SYS_FPGA_XILINX | CONFIG_SYS_SPARTAN3)
+#define CONFIG_SYS_XILINX_ZYNQ	(CONFIG_SYS_FPGA_XILINX | CONFIG_SYS_ZYNQ)
 /* XXX - Add new models here */
 
 
@@ -59,6 +61,7 @@ typedef enum {			/* typedef Xilinx_iface */
 	jtag_mode,		/* jtag/tap serial (not used ) */
 	master_selectmap,	/* master SelectMap (virtex2)           */
 	slave_selectmap,	/* slave SelectMap (virtex2)            */
+	devcfg,			/* devcfg interface (zynq) */
 	max_xilinx_iface_type	/* insert all new types before this */
 } Xilinx_iface;			/* end, typedef Xilinx_iface */
 
@@ -68,6 +71,7 @@ typedef enum {			/* typedef Xilinx_Family */
 	Xilinx_VirtexE,		/* Virtex-E Family */
 	Xilinx_Virtex2,		/* Virtex2 Family */
 	Xilinx_Spartan3,	/* Spartan-III Family */
+	Xilinx_Zynq,		/* Zynq Family */
 	max_xilinx_type		/* insert all new types before this */
 } Xilinx_Family;		/* end, typedef Xilinx_Family */
 
include/zynqpl.h new file +61 -0

61 lines not on this page · raw message

--
1.8.2.1

-------------- 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/20130422/989df4ea/attachment.pgp>

#18 lore raw

PATCH 14/14 fpga: Add support for loading bitstream for Xilinx Zynq

Quoted 1 line · Michal Simek

Devcfg device requires to load bitstream in binary format.

[snip]

Quoted 2 lines

+/* Device Image Sizes
+ *********************************************************************/

This is not the correct format for a comment.

Signature · 8 lines
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/20130422/951d544e/attachment.pgp>
#19 lore raw
In reply to Michal Simek
Quoted 11 lines · Michal Simek

Hi,

I am sending several patches which improve Xilinx Zynq arm port in u-boot.
Patchset contain:
- core changes: patches 1,2
- gem update: patches 1-11
- mmc support: patch 12
- i2c support: patch 13
- pl support: patch 14

Quoted 4 lines

I am sending them in one package because driver depends on each other in zynq shared files.

Thanks for your comments,

I've read over the series and in general things look good. The only other high level comment would be that it seems checkpatch has been updated since you last made sure the series was checkpatch clean so please re-check and correct the minor problems that show up. Thanks!

Signature · 8 lines
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/20130422/1934581c/attachment.pgp>
#20 lore raw

Hi Tom,

Quoted 16 lines · Tom Rini
Quoted 14 lines · Michal Simek

Hi,

I am sending several patches which improve Xilinx Zynq arm port in u-boot.
Patchset contain:
- core changes: patches 1,2
- gem update: patches 1-11
- mmc support: patch 12
- i2c support: patch 13
- pl support: patch 14

I am sending them in one package because driver depends on each other in zynq shared files.

Quoted 6 lines
Quoted 1 line

Thanks for your comments,

I've read over the series and in general things look good. The only other high level comment would be that it seems checkpatch has been updated since you last made sure the series was checkpatch clean so please re-check and correct the minor problems that show up. Thanks!

Thanks for your comments. I have fixed all these issues and start to use patman for the next v2 series.

Thanks,
Michal

Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/71481d67/attachment.pgp>