Skip to contentSkip to conversation

arm: socfpga: Usability fixes

RFC PATCH Superseded Marek Vasut 6 participants 110 messages Sep 15, 2014 – Sep 19, 2014

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover arm: socfpga: Usability fixes

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Charles Manning (1):
tools: socfpga: Add socfpga preloader signing to mkimage

Marek Vasut (21):
net: dwc: Fix cache alignment issues
net: dwc: Make the cache handling less cryptic
mmc: dw_mmc: Fix cache alignment issue
arm: socfpga: Clean up base address file
arm: socfpga: sysmgr: Clean up system manager
arm: socfpga: clock: Implant order into bit definitions
arm: socfpga: clock: Drop nonsense inlining from clock manager code
arm: socfpga: clock: Add missing stubs into board file
arm: socfpga: clock: Trim down code duplication
arm: socfpga: timer: Pull the timer reload value from config file
arm: socfpga: reset: Add EMAC reset functions
arm: socfpga: board: Align checkboard() output
arm: socfpga: reset: Add function to reset FPGA bridges
arm: socfpga: sysmgr: Add FPGA bits into system manager
arm: cache: Add support for write-allocate D-Cache
arm: socfpga: cache: Define cacheline size
arm: socfpga: cache: Enable D-Cache
arm: socfpga: cache: Enable PL310 L2 cache
arm: socfpga: scu: Add SCU register file
arm: socfpga: nic301: Add NIC-301 GPV register file
arm: socfpga: pl310: Map SDRAM to 0x0

Pavel Machek (13):
net: Remove unused CONFIG_DW_SEARCH_PHY from configs
net: phy: Cleanup drivers/net/phy/micrel.c
mmc: dw_mmc: cleanups
arm: socfpga: Complete the list of base addresses
arm: socfpga: Add watchdog disable for socfpga
arm: socfpga: clock: Add code to read clock configuration
arm: socfpga: mmc: Pick the clock from clock manager
arm: socfpga: misc: Add proper ethernet initialization
arm: socfpga: misc: Add SD controller init
arm: socfpga: misc: Align print_cpuinfo() output
arm: socfpga: board: Correctly set ATAG position
arm: socfpga: fpga: Add SoCFPGA FPGA programming interface
arm: socfpga: nic301: Add NIC-301 configuration code

 arch/arm/cpu/armv7/socfpga/Makefile                |   3 +-
 arch/arm/cpu/armv7/socfpga/clock_manager.c         | 218 ++++++++++++-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c          | 354 +++++++++++++++++++++
 arch/arm/cpu/armv7/socfpga/misc.c                  | 144 ++++++++-
 arch/arm/cpu/armv7/socfpga/reset_manager.c         |  72 +++++
 arch/arm/cpu/armv7/socfpga/system_manager.c        |  57 +++-
 arch/arm/cpu/armv7/socfpga/timer.c                 |   2 +
 arch/arm/include/asm/arch-socfpga/clock_manager.h  | 209 ++++++++----
 arch/arm/include/asm/arch-socfpga/fpga_manager.h   |  77 +++++
 arch/arm/include/asm/arch-socfpga/nic301.h         | 195 ++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h  |   6 +
 arch/arm/include/asm/arch-socfpga/scu.h            |  23 ++
 .../include/asm/arch-socfpga/socfpga_base_addrs.h  |  62 +++-
 arch/arm/include/asm/arch-socfpga/system_manager.h | 111 +++++--
 arch/arm/include/asm/system.h                      |   1 +
 arch/arm/lib/cache-cp15.c                          |   2 +
 board/altera/socfpga/pll_config.h                  |   3 +
 board/altera/socfpga/socfpga_cyclone5.c            |   7 +-
 common/image.c                                     |   1 +
 drivers/fpga/altera.c                              |  21 ++
 drivers/mmc/dw_mmc.c                               |  26 +-
 drivers/mmc/socfpga_dw_mmc.c                       |  15 +-
 drivers/net/designware.c                           |  46 +--
 drivers/net/phy/micrel.c                           |   7 +-
 include/altera.h                                   |   1 +
 include/configs/axs101.h                           |   1 -
 include/configs/socfpga_cyclone5.h                 |   9 +-
 include/dwmmc.h                                    |   2 +-
 include/image.h                                    |   1 +
 tools/Makefile                                     |   1 +
 tools/imagetool.c                                  |   2 +
 tools/imagetool.h                                  |   1 +
 tools/socfpgaimage.c                               | 255 +++++++++++++++
 33 files changed, 1753 insertions(+), 182 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/fpga_manager.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/fpga_manager.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/nic301.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/scu.h
 create mode 100644 tools/socfpgaimage.c
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/35 net: Remove unused CONFIG_DW_SEARCH_PHY from configs

From: Pavel Machek <[email protected]>

Remove this symbol from configs, since it's unused.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 include/configs/axs101.h | 1 -
 1 file changed, 1 deletion(-)
include/configs/axs101.h +0 -1
index c22d6d0..1bf8390 100644
@@ -125,7 +125,6 @@
  */
 #define CONFIG_DESIGNWARE_ETH
 #define CONFIG_DW_AUTONEG
-#define CONFIG_DW_SEARCH_PHY
 #define CONFIG_NET_MULTI
 
 /*
Signature · 1 line
2.1.0
#2 lore raw

PATCH 1/35 net: Remove unused CONFIG_DW_SEARCH_PHY from configs

Quoted 23 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Remove this symbol from configs, since it's unused.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 include/configs/axs101.h | 1 -
 1 file changed, 1 deletion(-)
include/configs/axs101.h +0 -0
index c22d6d0..1bf8390 100644

include/configs/axs101.h line 130

Quoted 7 lines
include/configs/axs101.h +0 -1
@@ -125,7 +125,6 @@
  */
 #define CONFIG_DESIGNWARE_ETH
 #define CONFIG_DW_AUTONEG
-#define CONFIG_DW_SEARCH_PHY
 #define CONFIG_NET_MULTI
 
 /*

Then we can probably remove CONFIG_DW_SEARCH_PHY from configs/socfpga_cyclone5.h too, right?

Dinh

#3 lore raw

PATCH 1/35 net: Remove unused CONFIG_DW_SEARCH_PHY from configs

Quoted 30 lines · Dinh Nguyen
Quoted 29 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Remove this symbol from configs, since it's unused.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>

---

 include/configs/axs101.h | 1 -
 1 file changed, 1 deletion(-)
include/configs/axs101.h +0 -0
index c22d6d0..1bf8390 100644
@@ -125,7 +125,6 @@
 
  */
 
 #define CONFIG_DESIGNWARE_ETH
 #define CONFIG_DW_AUTONEG
 
Quoted 8 lines
Quoted 5 lines
include/configs/axs101.h +0 -1
-#define CONFIG_DW_SEARCH_PHY

#define CONFIG_NET_MULTI

/*

Then we can probably remove CONFIG_DW_SEARCH_PHY from configs/socfpga_cyclone5.h too, right?

Yes, thanks for spotting this !

Best regards,
Marek Vasut

#4 lore raw

PATCH 2/35 net: phy: Cleanup drivers/net/phy/micrel.c

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Old saying says that more than three exclamation marks in a row are sign of mental disease. Cleanup micrel.c.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 drivers/net/phy/micrel.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/phy/micrel.c +3 -4
index 5d7e3be..507b9a3 100644
@@ -25,8 +25,7 @@ static struct phy_driver KSZ804_driver = {
 #ifndef CONFIG_PHY_MICREL_KSZ9021
 /*
  * I can't believe Micrel used the exact same part number
- * for the KSZ9021
- * Shame Micrel, Shame!!!!!
+ * for the KSZ9021. Shame Micrel, Shame!
  */
 static struct phy_driver KS8721_driver = {
 	.name = "Micrel KS8721BL",
@@ -40,7 +39,7 @@ static struct phy_driver KS8721_driver = {
 #endif
 
 
-/**
+/*
  * KSZ9021 - KSZ9031 common
  */
 
@@ -69,8 +68,8 @@ static int ksz90xx_startup(struct phy_device *phydev)
 		phydev->speed = SPEED_10;
 	return 0;
 }
-#ifdef CONFIG_PHY_MICREL_KSZ9021
 
+#ifdef CONFIG_PHY_MICREL_KSZ9021
 /*
  * KSZ9021
  */
Signature · 1 line
2.1.0
#5 lore raw

PATCH 3/35 net: dwc: Fix cache alignment issues

In reply to Marek Vasut

Fix remaining cache alignment issues in the DWC Ethernet driver. Please note that the cache handling in the driver is making the code hideous and thus the next patch cleans that up. In order to make this change reviewable though, the cleanup is split from it.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/designware.c +4 -2
index 7186e3b..aaf146d 100644
@@ -303,7 +303,8 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length)
 
 	/* Flush data to be sent */
 	flush_dcache_range((unsigned long)desc_p->dmamac_addr,
-			   (unsigned long)desc_p->dmamac_addr + length);
+			   (unsigned long)desc_p->dmamac_addr +
+			   roundup(length, ARCH_DMA_MINALIGN));
 
 #if defined(CONFIG_DW_ALTDESCRIPTOR)
 	desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
@@ -372,7 +373,8 @@ static int dw_eth_recv(struct eth_device *dev)
 		/* Flush only status field - others weren't changed */
 		flush_dcache_range((unsigned long)&desc_p->txrx_status,
 				   (unsigned long)&desc_p->txrx_status +
-				   sizeof(desc_p->txrx_status));
+					roundup(sizeof(desc_p->txrx_status),
+						ARCH_DMA_MINALIGN));
 
 		/* Test the wrap-around condition. */
 		if (++desc_num >= CONFIG_RX_DESCR_NUM)
Signature · 1 line
2.1.0
#6 lore raw

PATCH 3/35 net: dwc: Fix cache alignment issues

Quoted 32 lines · Marek Vasut

Fix remaining cache alignment issues in the DWC Ethernet driver. Please note that the cache handling in the driver is making the code hideous and thus the next patch cleans that up. In order to make this change reviewable though, the cleanup is split from it.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/designware.c +2 -1
index 7186e3b..aaf146d 100644
@@ -303,7 +303,8 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length)
 
 	/* Flush data to be sent */
 	flush_dcache_range((unsigned long)desc_p->dmamac_addr,
-			   (unsigned long)desc_p->dmamac_addr + length);
+			   (unsigned long)desc_p->dmamac_addr +
+			   roundup(length, ARCH_DMA_MINALIGN));
 
 #if defined(CONFIG_DW_ALTDESCRIPTOR)
 	desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;

drivers/net/designware.c static int dw_eth_recv(struct eth_device *dev) · line 376

Quoted 5 lines
drivers/net/designware.c +1 -1
@@ -372,7 +373,8 @@ static int dw_eth_recv(struct eth_device *dev)
 		/* Flush only status field - others weren't changed */
 		flush_dcache_range((unsigned long)&desc_p->txrx_status,
 				   (unsigned long)&desc_p->txrx_status +
-				   sizeof(desc_p->txrx_status));
+					roundup(sizeof(desc_p->txrx_status),

Should you keep the number of tabs the same here?

Thanks,
Dinh

Quoted 5 lines
drivers/net/designware.c +1 -0
+						ARCH_DMA_MINALIGN));
 
 		/* Test the wrap-around condition. */
 		if (++desc_num >= CONFIG_RX_DESCR_NUM)
#7 lore raw

PATCH 3/35 net: dwc: Fix cache alignment issues

Quoted 42 lines · Dinh Nguyen
Quoted 41 lines · Marek Vasut

Fix remaining cache alignment issues in the DWC Ethernet driver. Please note that the cache handling in the driver is making the code hideous and thus the next patch cleans that up. In order to make this change reviewable though, the cleanup is split from it.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>

---

 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/designware.c +2 -1
index 7186e3b..aaf146d 100644
@@ -303,7 +303,8 @@ static int dw_eth_send(struct eth_device *dev, void
 *packet, int length)
 
 	/* Flush data to be sent */
 	flush_dcache_range((unsigned long)desc_p->dmamac_addr,
 
-			   (unsigned long)desc_p->dmamac_addr + length);
+			   (unsigned long)desc_p->dmamac_addr +
+			   roundup(length, ARCH_DMA_MINALIGN));
 

#if defined(CONFIG_DW_ALTDESCRIPTOR)

drivers/net/designware.c +0 -0
 	desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
@@ -372,7 +373,8 @@ static int dw_eth_recv(struct eth_device *dev)
 
 		/* Flush only status field - others weren't changed */
 		flush_dcache_range((unsigned long)&desc_p->txrx_status,
 
Quoted 6 lines

drivers/net/designware.c static int dw_eth_recv(struct eth_device *dev) · line 376

Quoted 4 lines
drivers/net/designware.c +1 -1
 				   (unsigned long)&desc_p->txrx_status +
 
-				   sizeof(desc_p->txrx_status));
+					roundup(sizeof(desc_p->txrx_status),

Should you keep the number of tabs the same here?

This code goes in the following patch, so it's rather irrelevant.

Best regards,
Marek Vasut

#8 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

In reply to Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 drivers/net/designware.c | 48 +++++++++++++++++++++++-------------------------
 1 file changed, 23 insertions(+), 25 deletions(-)
drivers/net/designware.c +23 -25
index aaf146d..9ded895 100644
@@ -279,19 +279,21 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length)
 	struct eth_dma_regs *dma_p = priv->dma_regs_p;
 	u32 desc_num = priv->tx_currdescnum;
 	struct dmamacdescr *desc_p = &priv->tx_mac_descrtable[desc_num];
-
+	uint32_t desc_start = (uint32_t)desc_p;
+	uint32_t desc_end = desc_start +
+		roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
+	uint32_t data_start = (uint32_t)desc_p->dmamac_addr;
+	uint32_t data_end = data_start +
+		roundup(length, ARCH_DMA_MINALIGN);
 	/*
 	 * Strictly we only need to invalidate the "txrx_status" field
 	 * for the following check, but on some platforms we cannot
-	 * invalidate only 4 bytes, so roundup to
-	 * ARCH_DMA_MINALIGN. This is safe because the individual
-	 * descriptors in the array are each aligned to
-	 * ARCH_DMA_MINALIGN.
+	 * invalidate only 4 bytes, so we flush the entire descriptor,
+	 * which is 16 bytes in total. This is safe because the
+	 * individual descriptors in the array are each aligned to
+	 * ARCH_DMA_MINALIGN and padded appropriately.
 	 */
-	invalidate_dcache_range(
-		(unsigned long)desc_p,
-		(unsigned long)desc_p +
-		roundup(sizeof(desc_p->txrx_status), ARCH_DMA_MINALIGN));
+	invalidate_dcache_range(desc_start, desc_end);
 
 	/* Check if the descriptor is owned by CPU */
 	if (desc_p->txrx_status & DESC_TXSTS_OWNBYDMA) {
@@ -299,12 +301,10 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length)
 		return -1;
 	}
 
-	memcpy((void *)desc_p->dmamac_addr, packet, length);
+	memcpy(desc_p->dmamac_addr, packet, length);
 
 	/* Flush data to be sent */
-	flush_dcache_range((unsigned long)desc_p->dmamac_addr,
-			   (unsigned long)desc_p->dmamac_addr +
-			   roundup(length, ARCH_DMA_MINALIGN));
+	flush_dcache_range(data_start, data_end);
 
 #if defined(CONFIG_DW_ALTDESCRIPTOR)
 	desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
@@ -322,8 +322,7 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length)
 #endif
 
 	/* Flush modified buffer descriptor */
-	flush_dcache_range((unsigned long)desc_p,
-			   (unsigned long)desc_p + sizeof(struct dmamacdescr));
+	flush_dcache_range(desc_start, desc_end);
 
 	/* Test the wrap-around condition. */
 	if (++desc_num >= CONFIG_TX_DESCR_NUM)
@@ -343,11 +342,14 @@ static int dw_eth_recv(struct eth_device *dev)
 	u32 status, desc_num = priv->rx_currdescnum;
 	struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
 	int length = 0;
+	uint32_t desc_start = (uint32_t)desc_p;
+	uint32_t desc_end = desc_start +
+		roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
+	uint32_t data_start = (uint32_t)desc_p->dmamac_addr;
+	uint32_t data_end;
 
 	/* Invalidate entire buffer descriptor */
-	invalidate_dcache_range((unsigned long)desc_p,
-				(unsigned long)desc_p +
-				sizeof(struct dmamacdescr));
+	invalidate_dcache_range(desc_start, desc_end);
 
 	status = desc_p->txrx_status;
 
@@ -358,9 +360,8 @@ static int dw_eth_recv(struct eth_device *dev)
 			 DESC_RXSTS_FRMLENSHFT;
 
 		/* Invalidate received data */
-		invalidate_dcache_range((unsigned long)desc_p->dmamac_addr,
-					(unsigned long)desc_p->dmamac_addr +
-					roundup(length, ARCH_DMA_MINALIGN));
+		data_end = data_start + roundup(length, ARCH_DMA_MINALIGN);
+		invalidate_dcache_range(data_start, data_end);
 
 		NetReceive(desc_p->dmamac_addr, length);
 
@@ -371,10 +372,7 @@ static int dw_eth_recv(struct eth_device *dev)
 		desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
 
 		/* Flush only status field - others weren't changed */
-		flush_dcache_range((unsigned long)&desc_p->txrx_status,
-				   (unsigned long)&desc_p->txrx_status +
-					roundup(sizeof(desc_p->txrx_status),
-						ARCH_DMA_MINALIGN));
+		flush_dcache_range(desc_start, desc_end);
 
 		/* Test the wrap-around condition. */
 		if (++desc_num >= CONFIG_RX_DESCR_NUM)
Signature · 1 line
2.1.0
#9 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

In reply to Marek Vasut
Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#11 lore raw

PATCH 5/35 mmc: dw_mmc: cleanups

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

The dw_mmc driver was responding to errors with debug(). Change that to prinf()/puts() respectively so that any errors are immediately obvious. Also adjust english in comments.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Pantelis Antoniou <[email protected]>
---
 drivers/mmc/dw_mmc.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/mmc/dw_mmc.c +14 -12
index 0df30bc..f4a6b88 100644
@@ -119,7 +119,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 
 	while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) {
 		if (get_timer(start) > timeout) {
-			printf("Timeout on data busy\n");
+			printf("%s: Timeout on data busy\n", __func__);
 			return TIMEOUT;
 		}
 	}
@@ -177,14 +177,16 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 		}
 	}
 
-	if (i == retry)
+	if (i == retry) {
+		printf("%s: Timeout.\n", __func__);
 		return TIMEOUT;
+	}
 
 	if (mask & DWMCI_INTMSK_RTO) {
-		debug("Response Timeout..\n");
+		printf("%s: Response Timeout.\n", __func__);
 		return TIMEOUT;
 	} else if (mask & DWMCI_INTMSK_RE) {
-		debug("Response Error..\n");
+		printf("%s: Response Error.\n", __func__);
 		return -1;
 	}
 
@@ -204,7 +206,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 		do {
 			mask = dwmci_readl(host, DWMCI_RINTSTS);
 			if (mask & (DWMCI_DATA_ERR | DWMCI_DATA_TOUT)) {
-				debug("DATA ERROR!\n");
+				printf("%s: DATA ERROR!\n", __func__);
 				return -1;
 			}
 		} while (!(mask & DWMCI_INTMSK_DTO));
@@ -232,16 +234,16 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	if ((freq == host->clock) || (freq == 0))
 		return 0;
 	/*
-	 * If host->get_mmc_clk didn't define,
+	 * If host->get_mmc_clk isn't defined,
 	 * then assume that host->bus_hz is source clock value.
-	 * host->bus_hz should be set from user.
+	 * host->bus_hz should be set by user.
 	 */
 	if (host->get_mmc_clk)
 		sclk = host->get_mmc_clk(host);
 	else if (host->bus_hz)
 		sclk = host->bus_hz;
 	else {
-		printf("Didn't get source clock value..\n");
+		printf("%s: Didn't get source clock value.\n", __func__);
 		return -EINVAL;
 	}
 
@@ -260,7 +262,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	do {
 		status = dwmci_readl(host, DWMCI_CMD);
 		if (timeout-- < 0) {
-			printf("TIMEOUT error!!\n");
+			printf("%s: Timeout!\n", __func__);
 			return -ETIMEDOUT;
 		}
 	} while (status & DWMCI_CMD_START);
@@ -275,7 +277,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	do {
 		status = dwmci_readl(host, DWMCI_CMD);
 		if (timeout-- < 0) {
-			printf("TIMEOUT error!!\n");
+			printf("%s: Timeout!\n", __func__);
 			return -ETIMEDOUT;
 		}
 	} while (status & DWMCI_CMD_START);
@@ -290,7 +292,7 @@ static void dwmci_set_ios(struct mmc *mmc)
 	struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
 	u32 ctype, regs;
 
-	debug("Buswidth = %d, clock: %d\n",mmc->bus_width, mmc->clock);
+	debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);
 
 	dwmci_setup_bus(host, mmc->clock);
 	switch (mmc->bus_width) {
@@ -329,7 +331,7 @@ static int dwmci_init(struct mmc *mmc)
 	dwmci_writel(host, DWMCI_PWREN, 1);
 
 	if (!dwmci_wait_reset(host, DWMCI_RESET_ALL)) {
-		debug("%s[%d] Fail-reset!!\n",__func__,__LINE__);
+		printf("%s[%d] Fail-reset!!\n", __func__, __LINE__);
 		return -1;
 	}
 
Signature · 1 line
2.1.0
#12 lore raw

PATCH 5/35 mmc: dw_mmc: cleanups

Quoted 100 lines · Marek Vasut

From: Pavel Machek <[email protected]>

The dw_mmc driver was responding to errors with debug(). Change that to prinf()/puts() respectively so that any errors are immediately obvious. Also adjust english in comments.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Pantelis Antoniou <[email protected]>
---
 drivers/mmc/dw_mmc.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/mmc/dw_mmc.c +12 -10
index 0df30bc..f4a6b88 100644
@@ -119,7 +119,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 
 	while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) {
 		if (get_timer(start) > timeout) {
-			printf("Timeout on data busy\n");
+			printf("%s: Timeout on data busy\n", __func__);
 			return TIMEOUT;
 		}
 	}
@@ -177,14 +177,16 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 		}
 	}
 
-	if (i == retry)
+	if (i == retry) {
+		printf("%s: Timeout.\n", __func__);
 		return TIMEOUT;
+	}
 
 	if (mask & DWMCI_INTMSK_RTO) {
-		debug("Response Timeout..\n");
+		printf("%s: Response Timeout.\n", __func__);
 		return TIMEOUT;
 	} else if (mask & DWMCI_INTMSK_RE) {
-		debug("Response Error..\n");
+		printf("%s: Response Error.\n", __func__);
 		return -1;
 	}
 
@@ -204,7 +206,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 		do {
 			mask = dwmci_readl(host, DWMCI_RINTSTS);
 			if (mask & (DWMCI_DATA_ERR | DWMCI_DATA_TOUT)) {
-				debug("DATA ERROR!\n");
+				printf("%s: DATA ERROR!\n", __func__);
 				return -1;
 			}
 		} while (!(mask & DWMCI_INTMSK_DTO));
@@ -232,16 +234,16 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	if ((freq == host->clock) || (freq == 0))
 		return 0;
 	/*
-	 * If host->get_mmc_clk didn't define,
+	 * If host->get_mmc_clk isn't defined,
 	 * then assume that host->bus_hz is source clock value.
-	 * host->bus_hz should be set from user.
+	 * host->bus_hz should be set by user.
 	 */
 	if (host->get_mmc_clk)
 		sclk = host->get_mmc_clk(host);
 	else if (host->bus_hz)
 		sclk = host->bus_hz;
 	else {
-		printf("Didn't get source clock value..\n");
+		printf("%s: Didn't get source clock value.\n", __func__);
 		return -EINVAL;
 	}
 
@@ -260,7 +262,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	do {
 		status = dwmci_readl(host, DWMCI_CMD);
 		if (timeout-- < 0) {
-			printf("TIMEOUT error!!\n");
+			printf("%s: Timeout!\n", __func__);
 			return -ETIMEDOUT;
 		}
 	} while (status & DWMCI_CMD_START);
@@ -275,7 +277,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	do {
 		status = dwmci_readl(host, DWMCI_CMD);
 		if (timeout-- < 0) {
-			printf("TIMEOUT error!!\n");
+			printf("%s: Timeout!\n", __func__);
 			return -ETIMEDOUT;
 		}
 	} while (status & DWMCI_CMD_START);

drivers/mmc/dw_mmc.c static void dwmci_set_ios(struct mmc *mmc) · line 295

Quoted 5 lines
drivers/mmc/dw_mmc.c +1 -1
@@ -290,7 +292,7 @@ static void dwmci_set_ios(struct mmc *mmc)
 	struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
 	u32 ctype, regs;
 
-	debug("Buswidth = %d, clock: %d\n",mmc->bus_width, mmc->clock);
+	debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);

Did you intend to use printf here also? Or just fix up the spacing around mmc->bus_width?

Dinh

Quoted 13 lines
drivers/mmc/dw_mmc.c +1 -1
 	dwmci_setup_bus(host, mmc->clock);
 	switch (mmc->bus_width) {
@@ -329,7 +331,7 @@ static int dwmci_init(struct mmc *mmc)
 	dwmci_writel(host, DWMCI_PWREN, 1);
 
 	if (!dwmci_wait_reset(host, DWMCI_RESET_ALL)) {
-		debug("%s[%d] Fail-reset!!\n",__func__,__LINE__);
+		printf("%s[%d] Fail-reset!!\n", __func__, __LINE__);
 		return -1;
 	}
 
#13 lore raw

PATCH 5/35 mmc: dw_mmc: cleanups

Quoted 6 lines · Dinh Nguyen
Quoted 5 lines · Marek Vasut

From: Pavel Machek <[email protected]>

The dw_mmc driver was responding to errors with debug(). Change that to prinf()/puts() respectively so that any errors are immediately obvious. Also adjust english in comments.

[...]

Quoted 10 lines

drivers/mmc/dw_mmc.c static void dwmci_set_ios(struct mmc *mmc) · line 296

Quoted 7 lines
drivers/mmc/dw_mmc.c +1 -1
@@ -290,7 +292,7 @@ static void dwmci_set_ios(struct mmc *mmc)
 
 	struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
 	u32 ctype, regs;
 
-	debug("Buswidth = %d, clock: %d\n",mmc->bus_width, mmc->clock);
+	debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);

Did you intend to use printf here also? Or just fix up the spacing around mmc->bus_width?

This cannot be a printf(), since you would get an output upon every call of .set_ios(). This would generate a wall of text. So this is formatting fix.

Best regards,
Marek Vasut

#14 lore raw

PATCH 6/35 mmc: dw_mmc: Fix cache alignment issue

In reply to Marek Vasut

The DMA descriptors used by the DW MMC block must be aligned to cacheline size, otherwise we are unable to properly flush/inval cache over them and we get data corruption.

The reason I chose this approach of expanding the structure is because the driver allocates the descriptors in bulk. This approach does waste space by inserting slop inbetween the descriptors, but it makes access to the descriptors easy as the compiler does know the real size of the structure. It also makes cache operations easy, since the size of the structure is cache aligned and the structure start address is as well.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Pantelis Antoniou <[email protected]>
---
 include/dwmmc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/dwmmc.h +1 -1
index b67f11b..109f7c8 100644
@@ -157,7 +157,7 @@ struct dwmci_idmac {
 	u32 cnt;
 	u32 addr;
 	u32 next_addr;
-};
+} __aligned(ARCH_DMA_MINALIGN);
 
 static inline void dwmci_writel(struct dwmci_host *host, int reg, u32 val)
 {
Signature · 1 line
2.1.0
#15 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#16 lore raw

PATCH 7/35 tools: socfpga: Add socfpga preloader signing to mkimage

In reply to Marek Vasut

From: Charles Manning <[email protected]>

Like many platforms, the Altera socfpga platform requires that the preloader be "signed" in a certain way or the built-in boot ROM will not boot the code.

This change automatically creates an appropriately signed preloader from an SPL image.

The signed image includes a CRC which must, of course, be generated with a CRC generator that the SoCFPGA boot ROM agrees with otherwise the boot ROM will reject the image.

Unfortunately the CRC used in this boot ROM is not the same as the Adler CRC in lib/crc32.c. Indeed the Adler code is not technically a CRC but is more correctly described as a checksum.

Thus, the appropriate CRC generator is added to lib/ as crc32_alt.c.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 common/image.c       |   1 +
 include/image.h      |   1 +
 tools/Makefile       |   1 +
 tools/imagetool.c    |   2 +
 tools/imagetool.h    |   1 +
 tools/socfpgaimage.c | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 261 insertions(+)
 create mode 100644 tools/socfpgaimage.c
common/image.c +1 -0
index 38b56e3..085771c 100644
@@ -138,6 +138,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_PBLIMAGE,   "pblimage",   "Freescale PBL Boot Image",},
 	{	IH_TYPE_RAMDISK,    "ramdisk",	  "RAMDisk Image",	},
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
+	{	IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SOCFPGA preloader",},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
 	{	IH_TYPE_UBLIMAGE,   "ublimage",   "Davinci UBL image",},
 	{	IH_TYPE_MXSIMAGE,   "mxsimage",   "Freescale MXS Boot Image",},
include/image.h +1 -0
index 3401056..4347532 100644
@@ -232,6 +232,7 @@ struct lmb;
 #define IH_TYPE_MXSIMAGE	16	/* Freescale MXSBoot Image	*/
 #define IH_TYPE_GPIMAGE		17	/* TI Keystone GPHeader Image	*/
 #define IH_TYPE_ATMELIMAGE	18	/* ATMEL ROM bootable Image	*/
+#define IH_TYPE_SOCFPGAIMAGE	19	/* Altera SOCFPGA Preloader	*/
 
 /*
  * Compression Types
tools/Makefile +1 -0
index 90e966d..2b05b20 100644
@@ -87,6 +87,7 @@ dumpimage-mkimage-objs := aisimage.o \
 			os_support.o \
 			pblimage.o \
 			pbl_crc32.o \
+			socfpgaimage.o \
 			lib/sha1.o \
 			lib/sha256.o \
 			ublimage.o \
tools/imagetool.c +2 -0
index 32d6278..98717bd 100644
@@ -47,6 +47,8 @@ void register_image_tool(imagetool_register_t image_register)
 	init_ubl_image_type();
 	/* Init Davinci AIS support */
 	init_ais_image_type();
+	/* Init Altera SOCFPGA support */
+	init_socfpga_image_type();
 	/* Init TI Keystone boot image generation/list support */
 	init_gpimage_type();
 }
tools/imagetool.h +1 -0
index c8af0e8..8bce059 100644
@@ -168,6 +168,7 @@ void init_mxs_image_type(void);
 void init_fit_image_type(void);
 void init_ubl_image_type(void);
 void init_omap_image_type(void);
+void init_socfpga_image_type(void);
 void init_gpimage_type(void);
 
 void pbl_load_uboot(int fd, struct image_tool_params *mparams);
tools/socfpgaimage.c new file +255 -0

255 lines not on this page · raw message

Signature · 1 line
2.1.0
#17 lore raw

PATCH 8/35 arm: socfpga: Complete the list of base addresses

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Add base addresses for all subsystems as documented in the Cyclone V HPS documentation.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 .../include/asm/arch-socfpga/socfpga_base_addrs.h  | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h +40 -0
index 2d3152d..cb062ac 100644
@@ -7,16 +7,56 @@
 #ifndef _SOCFPGA_BASE_ADDRS_H_
 #define _SOCFPGA_BASE_ADDRS_H_
 
+#define SOCFPGA_SDMMC_ADDRESS 0xff704000
+#define SOCFPGA_FPGAMGRREGS_ADDRESS 0xff706000
 #define SOCFPGA_L3REGS_ADDRESS 0xff800000
+#define SOCFPGA_FPGAMGRDATA_ADDRESS 0xffb90000
 #define SOCFPGA_UART0_ADDRESS 0xffc02000
 #define SOCFPGA_UART1_ADDRESS 0xffc03000
+#define SOCFPGA_SDR_ADDRESS 0xffc20000
 #define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
+#define SOCFPGA_OSC1TIMER1_ADDRESS 0xffd01000
 #define SOCFPGA_L4WD0_ADDRESS 0xffd02000
+#define SOCFPGA_L4WD1_ADDRESS 0xffd03000
 #define SOCFPGA_CLKMGR_ADDRESS 0xffd04000
 #define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
 #define SOCFPGA_SYSMGR_ADDRESS 0xffd08000
 #define SOCFPGA_SCANMGR_ADDRESS 0xfff02000
 #define SOCFPGA_EMAC0_ADDRESS 0xff700000
 #define SOCFPGA_EMAC1_ADDRESS 0xff702000
+#define SOCFPGA_MPUL2_ADDRESS 0xfffef000
+#define SOCFPGA_MPUSCU_ADDRESS 0xfffec000
+#define SOCFPGA_STM_ADDRESS 0xfc000000
+#define SOCFPGA_DAP_ADDRESS 0xff000000
+#define SOCFPGA_LWFPGASLAVES_ADDRESS 0xff200000
+#define SOCFPGA_LWHPS2FPGAREGS_ADDRESS 0xff400000
+#define SOCFPGA_HPS2FPGAREGS_ADDRESS 0xff500000
+#define SOCFPGA_FPGA2HPSREGS_ADDRESS 0xff600000
+#define SOCFPGA_QSPI_ADDRESS 0xff705000
+#define SOCFPGA_ACPIDMAP_ADDRESS 0xff707000
+#define SOCFPGA_GPIO0_ADDRESS 0xff708000
+#define SOCFPGA_GPIO1_ADDRESS 0xff709000
+#define SOCFPGA_GPIO2_ADDRESS 0xff70a000
+#define SOCFPGA_NANDDATA_ADDRESS 0xff900000
+#define SOCFPGA_QSPIDATA_ADDRESS 0xffa00000
+#define SOCFPGA_USB0_ADDRESS 0xffb00000
+#define SOCFPGA_USB1_ADDRESS 0xffb40000
+#define SOCFPGA_NANDREGS_ADDRESS 0xffb80000
+#define SOCFPGA_CAN0_ADDRESS 0xffc00000
+#define SOCFPGA_CAN1_ADDRESS 0xffc01000
+#define SOCFPGA_I2C0_ADDRESS 0xffc04000
+#define SOCFPGA_I2C1_ADDRESS 0xffc05000
+#define SOCFPGA_I2C2_ADDRESS 0xffc06000
+#define SOCFPGA_I2C3_ADDRESS 0xffc07000
+#define SOCFPGA_SPTIMER0_ADDRESS 0xffc08000
+#define SOCFPGA_SPTIMER1_ADDRESS 0xffc09000
+#define SOCFPGA_DMANONSECURE_ADDRESS 0xffe00000
+#define SOCFPGA_DMASECURE_ADDRESS 0xffe01000
+#define SOCFPGA_SPIS0_ADDRESS 0xffe02000
+#define SOCFPGA_SPIS1_ADDRESS 0xffe03000
+#define SOCFPGA_SPIM0_ADDRESS 0xfff00000
+#define SOCFPGA_SPIM1_ADDRESS 0xfff01000
+#define SOCFPGA_ROM_ADDRESS 0xfffd0000
+#define SOCFPGA_OCRAM_ADDRESS 0xffff0000
 
 #endif /* _SOCFPGA_BASE_ADDRS_H_ */
Signature · 1 line
2.1.0
#18 lore raw

PATCH 9/35 arm: socfpga: Clean up base address file

In reply to Marek Vasut

Sort the list of functional block addresses and fix indentation. No functional change.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 .../include/asm/arch-socfpga/socfpga_base_addrs.h  | 102 ++++++++++-----------
 1 file changed, 51 insertions(+), 51 deletions(-)
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h +51 -51
index cb062ac..6534283 100644
@@ -7,56 +7,56 @@
 #ifndef _SOCFPGA_BASE_ADDRS_H_
 #define _SOCFPGA_BASE_ADDRS_H_
 
-#define SOCFPGA_SDMMC_ADDRESS 0xff704000
-#define SOCFPGA_FPGAMGRREGS_ADDRESS 0xff706000
-#define SOCFPGA_L3REGS_ADDRESS 0xff800000
-#define SOCFPGA_FPGAMGRDATA_ADDRESS 0xffb90000
-#define SOCFPGA_UART0_ADDRESS 0xffc02000
-#define SOCFPGA_UART1_ADDRESS 0xffc03000
-#define SOCFPGA_SDR_ADDRESS 0xffc20000
-#define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
-#define SOCFPGA_OSC1TIMER1_ADDRESS 0xffd01000
-#define SOCFPGA_L4WD0_ADDRESS 0xffd02000
-#define SOCFPGA_L4WD1_ADDRESS 0xffd03000
-#define SOCFPGA_CLKMGR_ADDRESS 0xffd04000
-#define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
-#define SOCFPGA_SYSMGR_ADDRESS 0xffd08000
-#define SOCFPGA_SCANMGR_ADDRESS 0xfff02000
-#define SOCFPGA_EMAC0_ADDRESS 0xff700000
-#define SOCFPGA_EMAC1_ADDRESS 0xff702000
-#define SOCFPGA_MPUL2_ADDRESS 0xfffef000
-#define SOCFPGA_MPUSCU_ADDRESS 0xfffec000
-#define SOCFPGA_STM_ADDRESS 0xfc000000
-#define SOCFPGA_DAP_ADDRESS 0xff000000
-#define SOCFPGA_LWFPGASLAVES_ADDRESS 0xff200000
-#define SOCFPGA_LWHPS2FPGAREGS_ADDRESS 0xff400000
-#define SOCFPGA_HPS2FPGAREGS_ADDRESS 0xff500000
-#define SOCFPGA_FPGA2HPSREGS_ADDRESS 0xff600000
-#define SOCFPGA_QSPI_ADDRESS 0xff705000
-#define SOCFPGA_ACPIDMAP_ADDRESS 0xff707000
-#define SOCFPGA_GPIO0_ADDRESS 0xff708000
-#define SOCFPGA_GPIO1_ADDRESS 0xff709000
-#define SOCFPGA_GPIO2_ADDRESS 0xff70a000
-#define SOCFPGA_NANDDATA_ADDRESS 0xff900000
-#define SOCFPGA_QSPIDATA_ADDRESS 0xffa00000
-#define SOCFPGA_USB0_ADDRESS 0xffb00000
-#define SOCFPGA_USB1_ADDRESS 0xffb40000
-#define SOCFPGA_NANDREGS_ADDRESS 0xffb80000
-#define SOCFPGA_CAN0_ADDRESS 0xffc00000
-#define SOCFPGA_CAN1_ADDRESS 0xffc01000
-#define SOCFPGA_I2C0_ADDRESS 0xffc04000
-#define SOCFPGA_I2C1_ADDRESS 0xffc05000
-#define SOCFPGA_I2C2_ADDRESS 0xffc06000
-#define SOCFPGA_I2C3_ADDRESS 0xffc07000
-#define SOCFPGA_SPTIMER0_ADDRESS 0xffc08000
-#define SOCFPGA_SPTIMER1_ADDRESS 0xffc09000
-#define SOCFPGA_DMANONSECURE_ADDRESS 0xffe00000
-#define SOCFPGA_DMASECURE_ADDRESS 0xffe01000
-#define SOCFPGA_SPIS0_ADDRESS 0xffe02000
-#define SOCFPGA_SPIS1_ADDRESS 0xffe03000
-#define SOCFPGA_SPIM0_ADDRESS 0xfff00000
-#define SOCFPGA_SPIM1_ADDRESS 0xfff01000
-#define SOCFPGA_ROM_ADDRESS 0xfffd0000
-#define SOCFPGA_OCRAM_ADDRESS 0xffff0000
+#define SOCFPGA_STM_ADDRESS		0xfc000000
+#define SOCFPGA_DAP_ADDRESS		0xff000000
+#define SOCFPGA_EMAC0_ADDRESS		0xff700000
+#define SOCFPGA_EMAC1_ADDRESS		0xff702000
+#define SOCFPGA_SDMMC_ADDRESS		0xff704000
+#define SOCFPGA_QSPI_ADDRESS		0xff705000
+#define SOCFPGA_GPIO0_ADDRESS		0xff708000
+#define SOCFPGA_GPIO1_ADDRESS		0xff709000
+#define SOCFPGA_GPIO2_ADDRESS		0xff70a000
+#define SOCFPGA_L3REGS_ADDRESS		0xff800000
+#define SOCFPGA_USB0_ADDRESS		0xffb00000
+#define SOCFPGA_USB1_ADDRESS		0xffb40000
+#define SOCFPGA_CAN0_ADDRESS		0xffc00000
+#define SOCFPGA_CAN1_ADDRESS		0xffc01000
+#define SOCFPGA_UART0_ADDRESS		0xffc02000
+#define SOCFPGA_UART1_ADDRESS		0xffc03000
+#define SOCFPGA_I2C0_ADDRESS		0xffc04000
+#define SOCFPGA_I2C1_ADDRESS		0xffc05000
+#define SOCFPGA_I2C2_ADDRESS		0xffc06000
+#define SOCFPGA_I2C3_ADDRESS		0xffc07000
+#define SOCFPGA_SDR_ADDRESS		0xffc20000
+#define SOCFPGA_L4WD0_ADDRESS		0xffd02000
+#define SOCFPGA_L4WD1_ADDRESS		0xffd03000
+#define SOCFPGA_CLKMGR_ADDRESS		0xffd04000
+#define SOCFPGA_RSTMGR_ADDRESS		0xffd05000
+#define SOCFPGA_SYSMGR_ADDRESS		0xffd08000
+#define SOCFPGA_SPIS0_ADDRESS		0xffe02000
+#define SOCFPGA_SPIS1_ADDRESS		0xffe03000
+#define SOCFPGA_SPIM0_ADDRESS		0xfff00000
+#define SOCFPGA_SPIM1_ADDRESS		0xfff01000
+#define SOCFPGA_SCANMGR_ADDRESS		0xfff02000
+#define SOCFPGA_ROM_ADDRESS		0xfffd0000
+#define SOCFPGA_MPUSCU_ADDRESS		0xfffec000
+#define SOCFPGA_MPUL2_ADDRESS		0xfffef000
+#define SOCFPGA_OCRAM_ADDRESS		0xffff0000
+#define SOCFPGA_LWFPGASLAVES_ADDRESS	0xff200000
+#define SOCFPGA_LWHPS2FPGAREGS_ADDRESS	0xff400000
+#define SOCFPGA_HPS2FPGAREGS_ADDRESS	0xff500000
+#define SOCFPGA_FPGA2HPSREGS_ADDRESS	0xff600000
+#define SOCFPGA_FPGAMGRREGS_ADDRESS	0xff706000
+#define SOCFPGA_ACPIDMAP_ADDRESS	0xff707000
+#define SOCFPGA_NANDDATA_ADDRESS	0xff900000
+#define SOCFPGA_QSPIDATA_ADDRESS	0xffa00000
+#define SOCFPGA_NANDREGS_ADDRESS	0xffb80000
+#define SOCFPGA_FPGAMGRDATA_ADDRESS	0xffb90000
+#define SOCFPGA_SPTIMER0_ADDRESS	0xffc08000
+#define SOCFPGA_SPTIMER1_ADDRESS	0xffc09000
+#define SOCFPGA_OSC1TIMER0_ADDRESS	0xffd00000
+#define SOCFPGA_OSC1TIMER1_ADDRESS	0xffd01000
+#define SOCFPGA_DMANONSECURE_ADDRESS	0xffe00000
+#define SOCFPGA_DMASECURE_ADDRESS	0xffe01000
 
 #endif /* _SOCFPGA_BASE_ADDRS_H_ */
Signature · 1 line
2.1.0
#19 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#20 lore raw

PATCH 9/35 arm: socfpga: Clean up base address file

In reply to Marek Vasut
Quoted 9 lines · Marek Vasut

Sort the list of functional block addresses and fix indentation. No functional change.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#21 lore raw

PATCH 10/35 arm: socfpga: Add watchdog disable for socfpga

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

This adds watchdog disable. It is neccessary for running Linux kernel.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c                 |  4 ++++
 arch/arm/cpu/armv7/socfpga/reset_manager.c        | 13 +++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h |  2 ++
 3 files changed, 19 insertions(+)
arch/arm/cpu/armv7/socfpga/misc.c +4 -0
index ecae393..15cd8c2 100644
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <miiphy.h>
 #include <netdev.h>
+#include <asm/arch/reset_manager.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -38,6 +39,9 @@ int overwrite_console(void)
 
 int misc_init_r(void)
 {
+	/* This is needed, otherwise kernel is rebooted by watchdog. */
+	watchdog_disable();
+
 	return 0;
 }
 
arch/arm/cpu/armv7/socfpga/reset_manager.c +13 -0
index e320c01..07b8c4f 100644
@@ -14,6 +14,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static const struct socfpga_reset_manager *reset_manager_base =
 		(void *)SOCFPGA_RSTMGR_ADDRESS;
 
+#define RSTMGR_PERMODRST_L4WD0_LSB 6
+
+/* Disable the watchdog (toggle reset to watchdog) */
+void watchdog_disable(void)
+{
+	/* assert reset for watchdog */
+	setbits_le32(&reset_manager_base->per_mod_reset,
+		     (1<<RSTMGR_PERMODRST_L4WD0_LSB));
+	/* deassert watchdog from reset (watchdog in not running state) */
+	clrbits_le32(&reset_manager_base->per_mod_reset,
+		     (1<<RSTMGR_PERMODRST_L4WD0_LSB));
+}
+
 /*
  * Write the reset manager register to cause reset
  */
arch/arm/include/asm/arch-socfpga/reset_manager.h +2 -0
index 3e95476..e004343 100644
@@ -10,6 +10,8 @@
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
+void watchdog_disable(void);
+
 struct socfpga_reset_manager {
 	u32	status;
 	u32	ctrl;
Signature · 1 line
2.1.0
#22 lore raw

PATCH 10/35 arm: socfpga: Add watchdog disable for socfpga

Quoted 45 lines · Marek Vasut

From: Pavel Machek <[email protected]>

This adds watchdog disable. It is neccessary for running Linux kernel.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c                 |  4 ++++
 arch/arm/cpu/armv7/socfpga/reset_manager.c        | 13 +++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h |  2 ++
 3 files changed, 19 insertions(+)
arch/arm/cpu/armv7/socfpga/misc.c +4 -0
index ecae393..15cd8c2 100644
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <miiphy.h>
 #include <netdev.h>
+#include <asm/arch/reset_manager.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -38,6 +39,9 @@ int overwrite_console(void)
 
 int misc_init_r(void)
 {
+	/* This is needed, otherwise kernel is rebooted by watchdog. */
+	watchdog_disable();
+
 	return 0;
 }
 
arch/arm/cpu/armv7/socfpga/reset_manager.c +0 -0
index e320c01..07b8c4f 100644

arch/arm/cpu/armv7/socfpga/reset_manager.c DECLARE_GLOBAL_DATA_PTR; · line 17

Quoted 4 lines
arch/arm/cpu/armv7/socfpga/reset_manager.c +1 -0
@@ -14,6 +14,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static const struct socfpga_reset_manager *reset_manager_base =
 		(void *)SOCFPGA_RSTMGR_ADDRESS;
 
+#define RSTMGR_PERMODRST_L4WD0_LSB 6

Should this define go into -> arch-socfpga/reset_manager.h ?

Dinh

Quoted 29 lines
arch/arm/cpu/armv7/socfpga/reset_manager.c +12 -0
+
+/* Disable the watchdog (toggle reset to watchdog) */
+void watchdog_disable(void)
+{
+	/* assert reset for watchdog */
+	setbits_le32(&reset_manager_base->per_mod_reset,
+		     (1<<RSTMGR_PERMODRST_L4WD0_LSB));
+	/* deassert watchdog from reset (watchdog in not running state) */
+	clrbits_le32(&reset_manager_base->per_mod_reset,
+		     (1<<RSTMGR_PERMODRST_L4WD0_LSB));
+}
+
 /*
  * Write the reset manager register to cause reset
  */
arch/arm/include/asm/arch-socfpga/reset_manager.h +2 -0
index 3e95476..e004343 100644
@@ -10,6 +10,8 @@
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
+void watchdog_disable(void);
+
 struct socfpga_reset_manager {
 	u32	status;
 	u32	ctrl;
#23 lore raw

PATCH 10/35 arm: socfpga: Add watchdog disable for socfpga

Quoted 54 lines · Dinh Nguyen
Quoted 53 lines · Marek Vasut

From: Pavel Machek <[email protected]>

This adds watchdog disable. It is neccessary for running Linux kernel.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>

---

 arch/arm/cpu/armv7/socfpga/misc.c                 |  4 ++++
 arch/arm/cpu/armv7/socfpga/reset_manager.c        | 13 +++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h |  2 ++
 3 files changed, 19 insertions(+)
(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/misc.c index ecae393..15cd8c2 100644

arch/arm/cpu/armv7/socfpga/misc.c +1 -0
@@ -8,6 +8,7 @@
 
 #include <asm/io.h>
 #include <miiphy.h>
 #include <netdev.h>
 
+#include <asm/arch/reset_manager.h>
 

DECLARE_GLOBAL_DATA_PTR;

arch/arm/cpu/armv7/socfpga/misc.c +3 -0
@@ -38,6 +39,9 @@ int overwrite_console(void)
 
 int misc_init_r(void)
 {
 
+	/* This is needed, otherwise kernel is rebooted by watchdog. */
+	watchdog_disable();
+
 
 	return 0;

}

(quoted diff) +0 -0

b/arch/arm/cpu/armv7/socfpga/reset_manager.c index e320c01..07b8c4f 100644

arch/arm/cpu/armv7/socfpga/reset_manager.c +0 -0
@@ -14,6 +14,19 @@ DECLARE_GLOBAL_DATA_PTR;
 
Quoted 7 lines

arch/arm/cpu/armv7/socfpga/reset_manager.c DECLARE_GLOBAL_DATA_PTR; · line 17

Quoted 5 lines
arch/arm/cpu/armv7/socfpga/reset_manager.c +1 -0
 static const struct socfpga_reset_manager *reset_manager_base =
 
 		(void *)SOCFPGA_RSTMGR_ADDRESS;
 
+#define RSTMGR_PERMODRST_L4WD0_LSB 6

Should this define go into -> arch-socfpga/reset_manager.h ?

Yeah, done. And fixed this for the EMAC reset patch as well. Thanks!

#24 lore raw

PATCH 11/35 arm: socfpga: sysmgr: Clean up system manager

In reply to Marek Vasut

Clean up the system manager register definition and add the missing register definitions in place.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/system_manager.c        |  18 ++--
 arch/arm/include/asm/arch-socfpga/system_manager.h | 102 +++++++++++++++------
 2 files changed, 86 insertions(+), 34 deletions(-)
arch/arm/cpu/armv7/socfpga/system_manager.c +10 -8
index d96521b..07c72e4 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2013 Altera Corporation <www.altera.com>
+ * Copyright (C) 2013 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -7,21 +7,23 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/system_manager.h>
+#include <asm/arch/fpga_manager.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static struct socfpga_system_manager *sysmgr_regs =
+	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
 /*
  * Configure all the pin muxes
  */
 void sysmgr_pinmux_init(void)
 {
-	unsigned long offset = CONFIG_SYSMGR_PINMUXGRP_OFFSET;
-
-	const unsigned long *pval = sys_mgr_init_table;
-	unsigned long i;
+	uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
+	int i;
 
-	for (i = 0; i < ARRAY_SIZE(sys_mgr_init_table);
-		i++, offset += sizeof(unsigned long)) {
-		writel(*pval++, (SOCFPGA_SYSMGR_ADDRESS + offset));
+	for (i = 0; i < ARRAY_SIZE(sys_mgr_init_table); i++) {
+		writel(sys_mgr_init_table[i], regs);
+		regs += sizeof(regs);
 	}
 }
arch/arm/include/asm/arch-socfpga/system_manager.h +76 -26

153 lines not on this page · raw message

Signature · 1 line
2.1.0
#25 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#26 lore raw

PATCH 12/35 arm: socfpga: clock: Implant order into bit definitions

In reply to Marek Vasut

The bit definitions for clock manager are complete chaos. Implement some basic logical order into them.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/include/asm/arch-socfpga/clock_manager.h | 166 +++++++++++++---------
 1 file changed, 99 insertions(+), 67 deletions(-)
arch/arm/include/asm/arch-socfpga/clock_manager.h +99 -67
index babac0e..dea171e 100644
@@ -103,96 +103,128 @@ struct socfpga_clock_manager {
 	u32	_pad_0xe0_0x200[72];
 };
 
-#define CLKMGR_MAINPLLGRP_EN_S2FUSER0CLK_MASK 0x00000200
+#define CLKMGR_CTRL_SAFEMODE_MASK 0x00000001
+#define CLKMGR_CTRL_SAFEMODE_SET(x) (((x) << 0) & 0x00000001)
+
+#define CLKMGR_BYPASS_MAINPLL_SET(x) (((x) << 0) & 0x00000001)
+#define CLKMGR_BYPASS_PERPLLSRC_SET(x) (((x) << 4) & 0x00000010)
+#define CLKMGR_BYPASS_PERPLL_SET(x) (((x) << 3) & 0x00000008)
+#define CLKMGR_BYPASS_SDRPLLSRC_SET(x) (((x) << 2) & 0x00000004)
+#define CLKMGR_BYPASS_SDRPLL_SET(x) (((x) << 1) & 0x00000002)
+
+#define CLKMGR_INTER_MAINPLLLOCKED_MASK 0x00000040
+#define CLKMGR_INTER_PERPLLLOCKED_MASK 0x00000080
+#define CLKMGR_INTER_SDRPLLLOCKED_MASK 0x00000100
+
+/* Main PLL */
+#define CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(x) (((x) << 0) & 0x00000001)
+#define CLKMGR_MAINPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000)
+#define CLKMGR_MAINPLLGRP_VCO_EN_SET(x) (((x) << 1) & 0x00000002)
+#define CLKMGR_MAINPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8)
+#define CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK 0x01000000
+#define CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(x) (((x) << 2) & 0x00000004)
+#define CLKMGR_MAINPLLGRP_VCO_REGEXTSEL_MASK 0x80000000
+#define CLKMGR_MAINPLLGRP_VCO_RESET_VALUE 0x8001000d
+
+#define CLKMGR_MAINPLLGRP_MPUCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_MAINPLLGRP_MAINCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_MAINPLLGRP_DBGATCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_MAINPLLGRP_MAINQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_MAINPLLGRP_MAINNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_MAINPLLGRP_CFGS2FUSER0CLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_MAINPLLGRP_EN_DBGATCLK_MASK 0x00000010
+#define CLKMGR_MAINPLLGRP_EN_DBGCLK_MASK 0x00000020
 #define CLKMGR_MAINPLLGRP_EN_DBGTIMERCLK_MASK 0x00000080
 #define CLKMGR_MAINPLLGRP_EN_DBGTRACECLK_MASK 0x00000040
-#define CLKMGR_MAINPLLGRP_EN_DBGCLK_MASK 0x00000020
-#define CLKMGR_MAINPLLGRP_EN_DBGATCLK_MASK 0x00000010
 #define CLKMGR_MAINPLLGRP_EN_L4MPCLK_MASK 0x00000004
-#define CLKMGR_MAINPLLGRP_VCO_RESET_VALUE 0x8001000d
-#define CLKMGR_PERPLLGRP_VCO_RESET_VALUE 0x8001000d
-#define CLKMGR_SDRPLLGRP_VCO_RESET_VALUE 0x8001000d
+#define CLKMGR_MAINPLLGRP_EN_S2FUSER0CLK_MASK 0x00000200
+
+#define CLKMGR_MAINPLLGRP_MAINDIV_L3MPCLK_SET(x) (((x) << 0) & 0x00000003)
+#define CLKMGR_MAINPLLGRP_MAINDIV_L3SPCLK_SET(x) (((x) << 2) & 0x0000000c)
 #define CLKMGR_MAINPLLGRP_MAINDIV_L4MPCLK_SET(x) (((x) << 4) & 0x00000070)
 #define CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_SET(x)  (((x) << 7) & 0x00000380)
+
+#define CLKMGR_MAINPLLGRP_DBGDIV_DBGATCLK_SET(x) (((x) << 0) & 0x00000003)
+#define CLKMGR_MAINPLLGRP_DBGDIV_DBGCLK_SET(x) (((x) << 2) & 0x0000000c)
+
+#define CLKMGR_MAINPLLGRP_TRACEDIV_TRACECLK_SET(x) (((x) << 0) & 0x00000007)
+
 #define CLKMGR_MAINPLLGRP_L4SRC_L4MP_SET(x) (((x) << 0) & 0x00000001)
 #define CLKMGR_MAINPLLGRP_L4SRC_L4SP_SET(x) (((x) << 1) & 0x00000002)
-#define CLKMGR_PERPLLGRP_SRC_QSPI_SET(x) (((x) << 4) & 0x00000030)
-#define CLKMGR_PERPLLGRP_SRC_NAND_SET(x) (((x) << 2) & 0x0000000c)
-#define CLKMGR_PERPLLGRP_SRC_SDMMC_SET(x) (((x) << 0) & 0x00000003)
-#define CLKMGR_MAINPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000)
-#define CLKMGR_MAINPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8)
-#define CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(x) (((x) << 2) & 0x00000004)
-#define CLKMGR_MAINPLLGRP_VCO_EN_SET(x) (((x) << 1) & 0x00000002)
-#define CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(x) (((x) << 0) & 0x00000001)
-#define CLKMGR_PERPLLGRP_VCO_PSRC_SET(x) (((x) << 22) & 0x00c00000)
+#define CLKMGR_MAINPLLGRP_L4SRC_RESET_VALUE 0x00000000
+
+/* Per PLL */
 #define CLKMGR_PERPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000)
 #define CLKMGR_PERPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8)
-#define CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(x) (((x) << 25) & 0x7e000000)
-#define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000)
-#define CLKMGR_SDRPLLGRP_VCO_SSRC_SET(x) (((x) << 22) & 0x00c00000)
-#define CLKMGR_SDRPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000)
-#define CLKMGR_SDRPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8)
-#define CLKMGR_MAINPLLGRP_MPUCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_MAINPLLGRP_MAINCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_MAINPLLGRP_DBGATCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_MAINPLLGRP_CFGS2FUSER0CLK_CNT_SET(x) \
-	(((x) << 0) & 0x000001ff)
+#define CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK 0x01000000
+#define CLKMGR_PERPLLGRP_VCO_PSRC_SET(x) (((x) << 22) & 0x00c00000)
+#define CLKMGR_PERPLLGRP_VCO_REGEXTSEL_MASK 0x80000000
+#define CLKMGR_PERPLLGRP_VCO_RESET_VALUE 0x8001000d
+
 #define CLKMGR_PERPLLGRP_EMAC0CLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
 #define CLKMGR_PERPLLGRP_EMAC1CLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_MAINPLLGRP_MAINQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_MAINPLLGRP_MAINNANDSDMMCCLK_CNT_SET(x) \
-	(((x) << 0) & 0x000001ff)
+
+#define CLKMGR_PERPLLGRP_PERQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
+#define CLKMGR_PERPLLGRP_PERNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
 #define CLKMGR_PERPLLGRP_PERBASECLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+
 #define CLKMGR_PERPLLGRP_S2FUSER1CLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_PERPLLGRP_PERNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
-#define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
-#define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
-#define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
-#define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
-#define CLKMGR_MAINPLLGRP_DBGDIV_DBGCLK_SET(x) (((x) << 2) & 0x0000000c)
-#define CLKMGR_MAINPLLGRP_DBGDIV_DBGATCLK_SET(x) (((x) << 0) & 0x00000003)
-#define CLKMGR_MAINPLLGRP_TRACEDIV_TRACECLK_SET(x) (((x) << 0) & 0x00000007)
-#define CLKMGR_MAINPLLGRP_MAINDIV_L3MPCLK_SET(x) (((x) << 0) & 0x00000003)
-#define CLKMGR_MAINPLLGRP_MAINDIV_L3SPCLK_SET(x) (((x) << 2) & 0x0000000c)
-#define CLKMGR_BYPASS_PERPLL_SET(x) (((x) << 3) & 0x00000008)
-#define CLKMGR_BYPASS_SDRPLL_SET(x) (((x) << 1) & 0x00000002)
-#define CLKMGR_BYPASS_MAINPLL_SET(x) (((x) << 0) & 0x00000001)
-#define CLKMGR_PERPLLGRP_DIV_USBCLK_SET(x) (((x) << 0) & 0x00000007)
-#define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038)
+
+#define CLKMGR_PERPLLGRP_EN_NANDCLK_MASK 0x00000400
+#define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK 0x00000100
+
 #define CLKMGR_PERPLLGRP_DIV_CAN0CLK_SET(x) (((x) << 6) & 0x000001c0)
 #define CLKMGR_PERPLLGRP_DIV_CAN1CLK_SET(x) (((x) << 9) & 0x00000e00)
-#define CLKMGR_INTER_SDRPLLLOCKED_MASK 0x00000100
-#define CLKMGR_INTER_PERPLLLOCKED_MASK 0x00000080
-#define CLKMGR_INTER_MAINPLLLOCKED_MASK 0x00000040
-#define CLKMGR_CTRL_SAFEMODE_MASK 0x00000001
-#define CLKMGR_CTRL_SAFEMODE_SET(x) (((x) << 0) & 0x00000001)
-#define CLKMGR_SDRPLLGRP_VCO_OUTRESET_MASK 0x7e000000
-#define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000)
-#define CLKMGR_PERPLLGRP_PERQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
 #define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038)
+#define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038)
+#define CLKMGR_PERPLLGRP_DIV_USBCLK_SET(x) (((x) << 0) & 0x00000007)
+
 #define CLKMGR_PERPLLGRP_GPIODIV_GPIODBCLK_SET(x) (((x) << 0) & 0x00ffffff)
-#define CLKMGR_BYPASS_PERPLLSRC_SET(x) (((x) << 4) & 0x00000010)
-#define CLKMGR_BYPASS_SDRPLLSRC_SET(x) (((x) << 2) & 0x00000004)
+
+#define CLKMGR_PERPLLGRP_SRC_NAND_SET(x) (((x) << 2) & 0x0000000c)
+#define CLKMGR_PERPLLGRP_SRC_QSPI_SET(x) (((x) << 4) & 0x00000030)
 #define CLKMGR_PERPLLGRP_SRC_RESET_VALUE 0x00000015
-#define CLKMGR_MAINPLLGRP_L4SRC_RESET_VALUE 0x00000000
-#define CLKMGR_MAINPLLGRP_VCO_REGEXTSEL_MASK 0x80000000
-#define CLKMGR_PERPLLGRP_VCO_REGEXTSEL_MASK 0x80000000
+#define CLKMGR_PERPLLGRP_SRC_SDMMC_SET(x) (((x) << 0) & 0x00000003)
+
+/* SDR PLL */
+#define CLKMGR_SDRPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000)
+#define CLKMGR_SDRPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8)
+#define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000)
+#define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000)
+#define CLKMGR_SDRPLLGRP_VCO_OUTRESET_MASK 0x7e000000
+#define CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(x) (((x) << 25) & 0x7e000000)
 #define CLKMGR_SDRPLLGRP_VCO_REGEXTSEL_MASK 0x80000000
-#define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_MASK 0x001ffe00
-#define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_MASK 0x001ffe00
-#define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_MASK 0x001ffe00
-#define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_MASK 0x001ffe00
-#define CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK 0x01000000
-#define CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK 0x01000000
-#define CLKMGR_PERPLLGRP_EN_NANDCLK_MASK 0x00000400
+#define CLKMGR_SDRPLLGRP_VCO_RESET_VALUE 0x8001000d
+#define CLKMGR_SDRPLLGRP_VCO_SSRC_SET(x) (((x) << 22) & 0x00c00000)
+
 #define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_MASK 0x000001ff
+#define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+#define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_MASK 0x001ffe00
+#define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
+
 #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_MASK 0x000001ff
+#define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+#define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_MASK 0x001ffe00
+#define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
+
 #define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_MASK 0x000001ff
+#define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+#define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_MASK 0x001ffe00
+#define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
+
 #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_MASK 0x000001ff
+#define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_SET(x) (((x) << 0) & 0x000001ff)
+#define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_MASK 0x001ffe00
+#define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_SET(x) (((x) << 9) & 0x00000e00)
 
 #define MAIN_VCO_BASE \
 	(CLKMGR_MAINPLLGRP_VCO_DENOM_SET(CONFIG_HPS_MAINPLLGRP_VCO_DENOM) | \
Signature · 1 line
2.1.0
#27 lore raw

PATCH 12/35 arm: socfpga: clock: Implant order into bit definitions

Dear Marek Vasut,

Quoted 2 lines · In message <[email protected]> you wrote:

The bit definitions for clock manager are complete chaos. Implement some basic logical order into them.

...

arch/arm/include/asm/arch-socfpga/clock_manager.h struct socfpga_clock_manager { · line 113

Quoted 5 lines
arch/arm/include/asm/arch-socfpga/clock_manager.h +5 -0
+#define CLKMGR_BYPASS_MAINPLL_SET(x)		(((x) << 0) & 0x00000001)
+#define CLKMGR_BYPASS_PERPLLSRC_SET(x)	(((x) << 4) & 0x00000010)
+#define CLKMGR_BYPASS_PERPLL_SET(x)		(((x) << 3) & 0x00000008)
+#define CLKMGR_BYPASS_SDRPLLSRC_SET(x)	(((x) << 2) & 0x00000004)
+#define CLKMGR_BYPASS_SDRPLL_SET(x)		(((x) << 1) & 0x00000002)

What is the purpose of all these funny shift operation shere? Is it just to obfuscate the meaning of the code, or is the code eventually wrong?

As is above could be rewritten much simpler without the shifts:

#define CLKMGR_BYPASS_MAINPLL_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_PERPLLSRC_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_PERPLL_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_SDRPLLSRC_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_SDRPLL_SET(x) ((x) & 1)

Note also that the macros are misnamed - "<something>_SET" means an action, i. e. the macro is supposed to set some bits in the argument, but here you actually perform a test if something "is set".

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When it is incorrect, it is, at least *authoritatively* incorrect.
                                    - Hitchiker's Guide To The Galaxy
#28 lore raw

PATCH 12/35 arm: socfpga: clock: Implant order into bit definitions

Hi!

Quoted 24 lines

Dear Marek Vasut,

Quoted 2 lines · In message <[email protected]> you wrote:

The bit definitions for clock manager are complete chaos. Implement some basic logical order into them.

...

arch/arm/include/asm/arch-socfpga/clock_manager.h struct socfpga_clock_manager { · line 113

Quoted 5 lines
arch/arm/include/asm/arch-socfpga/clock_manager.h +5 -0
+#define CLKMGR_BYPASS_MAINPLL_SET(x)		(((x) << 0) & 0x00000001)
+#define CLKMGR_BYPASS_PERPLLSRC_SET(x)	(((x) << 4) & 0x00000010)
+#define CLKMGR_BYPASS_PERPLL_SET(x)		(((x) << 3) & 0x00000008)
+#define CLKMGR_BYPASS_SDRPLLSRC_SET(x)	(((x) << 2) & 0x00000004)
+#define CLKMGR_BYPASS_SDRPLL_SET(x)		(((x) << 1) & 0x00000002)

What is the purpose of all these funny shift operation shere? Is it just to obfuscate the meaning of the code, or is the code eventually wrong?

As is above could be rewritten much simpler without the shifts:

#define CLKMGR_BYPASS_MAINPLL_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_PERPLLSRC_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_PERPLL_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_SDRPLLSRC_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_SDRPLL_SET(x) ((x) & 1)

Quoted 3 lines

Note also that the macros are misnamed - "<something>_SET" means an action, i. e. the macro is supposed to set some bits in the argument, but here you actually perform a test if something "is set".

Not the way macros are used; they really use them to set bits:

        /* Put all plls in bypass */
        cm_write_bypass(
                CLKMGR_BYPASS_PERPLLSRC_SET(
                CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) |
                CLKMGR_BYPASS_SDRPLLSRC_SET(
                CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) |
		CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE)
        |
                CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) |
                CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE));

So replacing with ((x) & 1) would not work.

But yes, there are more cleanups that could be done there.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#29 lore raw

PATCH 12/35 arm: socfpga: clock: Implant order into bit definitions

Quoted 47 lines · Pavel Machek

Hi!

Quoted 27 lines

Dear Marek Vasut,

Quoted 2 lines · In message <[email protected]> you wrote:

The bit definitions for clock manager are complete chaos. Implement some basic logical order into them.

...

arch/arm/include/asm/arch-socfpga/clock_manager.h struct socfpga_clock_manager { · line 113

Quoted 5 lines
arch/arm/include/asm/arch-socfpga/clock_manager.h +5 -0
+#define CLKMGR_BYPASS_MAINPLL_SET(x)		(((x) << 0) & 0x00000001)
+#define CLKMGR_BYPASS_PERPLLSRC_SET(x)	(((x) << 4) & 0x00000010)
+#define CLKMGR_BYPASS_PERPLL_SET(x)		(((x) << 3) & 0x00000008)
+#define CLKMGR_BYPASS_SDRPLLSRC_SET(x)	(((x) << 2) & 0x00000004)
+#define CLKMGR_BYPASS_SDRPLL_SET(x)		(((x) << 1) & 0x00000002)

What is the purpose of all these funny shift operation shere? Is it just to obfuscate the meaning of the code, or is the code eventually wrong?

As is above could be rewritten much simpler without the shifts:

#define CLKMGR_BYPASS_MAINPLL_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_PERPLLSRC_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_PERPLL_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_SDRPLLSRC_SET(x) ((x) & 1)
#define CLKMGR_BYPASS_SDRPLL_SET(x) ((x) & 1)

Quoted 3 lines

Note also that the macros are misnamed - "<something>_SET" means an action, i. e. the macro is supposed to set some bits in the argument, but here you actually perform a test if something "is set".

Not the way macros are used; they really use them to set bits:

        /* Put all plls in bypass */
        cm_write_bypass(
                CLKMGR_BYPASS_PERPLLSRC_SET(
                CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) |
                CLKMGR_BYPASS_SDRPLLSRC_SET(
                CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) |
		CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE)

                CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) |
                CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE));
Quoted 3 lines

So replacing with ((x) & 1) would not work.

But yes, there are more cleanups that could be done there.

You surely wanted to say "must be done where" ;-) I've yet to decide if I'll do it before this patchset or after ; I am more inclined doing it as a subsequent patch to allow Altera guys review the changes and match them with their existing code. And only then do the cleanup , probably automatically using some script.

What do you think, Wolfgang, Pavel, Dinh, others ... ?

Best regards,
Marek Vasut

#30 lore raw

PATCH 12/35 arm: socfpga: clock: Implant order into bit definitions

Dear Marek,

Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 10 lines
        cm_write_bypass(
                CLKMGR_BYPASS_PERPLLSRC_SET(
                CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) |
                CLKMGR_BYPASS_SDRPLLSRC_SET(
                CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) |
		CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE)

                CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) |
                CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE));

...

Quoted 8 lines
Quoted 1 line

But yes, there are more cleanups that could be done there.

You surely wanted to say "must be done where" ;-) I've yet to decide if I'll do it before this patchset or after ; I am more inclined doing it as a subsequent patch to allow Altera guys review the changes and match them with their existing code. And only then do the cleanup , probably automatically using some script.

What do you think, Wolfgang, Pavel, Dinh, others ... ?

Well, frankly speaking, the code above (and many similar use cases) are an unreadable and unmaintainable mess. I understand that parts of this are computer-generated definitions, but in my opinion there are several serious disadvantages:

- The macro names are so long that the code becomes unreadable; the CodingStyle recommens in "Chapter 4: Naming":

C is a Spartan language, and so should your naming be. Unlike Modula-2 and Pascal programmers, C programmers do not use cute names like ThisVariableIsATemporaryCounter. A C programmer would call that variable "tmp", which is much easier to write, and not the least more difficult to understand.
...
LOCAL variable names should be short, and to the point.

- There is virtually no visual difference between macro names that take arguments (like CLKMGR_BYPASS_PERPLLSRC_SET()) and macro names that are used as arguments (like CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) which makes parsing the code even more difficult.

We should especially keep in mind that things like CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1 are deined in a single C source file only ("arch/arm/cpu/armv7/socfpga/clock_manager.c"), i. e. they have strictly local scope, so the long names make even less sense.

- The code not only difficult to read, but even more difficult to debug. Assume you are single stepping through this code, and you reach this statement:

Quoted 9 lines
Quoted 9 lines
        cm_write_bypass(
                CLKMGR_BYPASS_PERPLLSRC_SET(
                CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) |
                CLKMGR_BYPASS_SDRPLLSRC_SET(
                CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) |
		CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE)

                CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) |
                CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE));

In the debugger, you see

  	cm_write_bypass(0x0000000D);

How long does it take you to figure out if this is what we expect or not?

The macros are probably intended to offer unlimited flexibility, but they come at a cost. Do we really need this flexibility? How many of the macros are actually used und how many different ways.

Under normal conditions I would simple NAK such a patch and demand that the code is cleaned up before it gets accepted for mainline. Unfortunately, we already have this mess in mainline - somehow "arch/arm/cpu/armv7/socfpga/clock_manager.c" slipped through the reviews without anybody noticing this stuff.

So accepting this patch now does not make things dramatically worse, but I understand it would help to prepare the ground for other, urgently needed cleanup.

So as far as I am concerned I do not intend to block this with a plain NAK, but I would be really happy if this whole clock manager code would be put on the list of things that need rework, and we don't forget this about more recent tasks coming.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Everybody is talking about the  weather  but  nobody  does  anything
about it."                                               - Mark Twain
#31 lore raw

PATCH 12/35 arm: socfpga: clock: Implant order into bit definitions

Quoted 25 lines · Wolfgang Denk

Dear Marek,

Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 11 lines
        cm_write_bypass(
        
                CLKMGR_BYPASS_PERPLLSRC_SET(
                CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) |
                CLKMGR_BYPASS_SDRPLLSRC_SET(
                CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) |
		
		CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE)
		
                CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) |
                CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE));

...

Quoted 8 lines
Quoted 1 line

But yes, there are more cleanups that could be done there.

You surely wanted to say "must be done where" ;-) I've yet to decide if I'll do it before this patchset or after ; I am more inclined doing it as a subsequent patch to allow Altera guys review the changes and match them with their existing code. And only then do the cleanup , probably automatically using some script.

Quoted 6 lines
Quoted 1 line

What do you think, Wolfgang, Pavel, Dinh, others ... ?

Well, frankly speaking, the code above (and many similar use cases) are an unreadable and unmaintainable mess. I understand that parts of this are computer-generated definitions, but in my opinion there are several serious disadvantages:

Full ACK on this, the header files are full of dark chaos so far.

[...]

Quoted 4 lines

So as far as I am concerned I do not intend to block this with a plain NAK, but I would be really happy if this whole clock manager code would be put on the list of things that need rework, and we don't forget this about more recent tasks coming.

Will be in V2.

Best regards,
Marek Vasut

#32 lore raw

PATCH 13/35 arm: socfpga: clock: Drop nonsense inlining from clock manager code

In reply to Marek Vasut

The inlining is done by GCC whe needed, there is no need to do it explicitly. Furthermore, the inline keyword does not force-inline the code, but is only a hint for the compiler. Scrub this hint.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/clock_manager.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm/cpu/armv7/socfpga/clock_manager.c +6 -6
index 158501a..d032bbd 100644
@@ -30,7 +30,7 @@ static const struct socfpga_clock_manager *clock_manager_base =
 	CLKMGR_MAINPLLGRP_VCO_EN_SET(1)| \
 	CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(0))
 
-static inline void cm_wait_for_lock(uint32_t mask)
+static void cm_wait_for_lock(uint32_t mask)
 {
 	register uint32_t inter_val;
 	do {
@@ -39,7 +39,7 @@ static inline void cm_wait_for_lock(uint32_t mask)
 }
 
 /* function to poll in the fsm busy bit */
-static inline void cm_wait_for_fsm(void)
+static void cm_wait_for_fsm(void)
 {
 	while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY)
 		;
@@ -49,22 +49,22 @@ static inline void cm_wait_for_fsm(void)
  * function to write the bypass register which requires a poll of the
  * busy bit
  */
-static inline void cm_write_bypass(uint32_t val)
+static void cm_write_bypass(uint32_t val)
 {
 	writel(val, &clock_manager_base->bypass);
 	cm_wait_for_fsm();
 }
 
 /* function to write the ctrl register which requires a poll of the busy bit */
-static inline void cm_write_ctrl(uint32_t val)
+static void cm_write_ctrl(uint32_t val)
 {
 	writel(val, &clock_manager_base->ctrl);
 	cm_wait_for_fsm();
 }
 
 /* function to write a clock register that has phase information */
-static inline void cm_write_with_phase(uint32_t value,
-	uint32_t reg_address, uint32_t mask)
+static void cm_write_with_phase(uint32_t value,
+				uint32_t reg_address, uint32_t mask)
 {
 	/* poll until phase is zero */
 	while (readl(reg_address) & mask)
Signature · 1 line
2.1.0
#33 lore raw

PATCH 13/35 arm: socfpga: clock: Drop nonsense inlining from clock manager code

Quoted 1 line · Marek Vasut

The inlining is done by GCC whe needed, there is no need to do it

s/whe/when.

thanks...

Quoted 64 lines

explicitly. Furthermore, the inline keyword does not force-inline the code, but is only a hint for the compiler. Scrub this hint.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/clock_manager.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm/cpu/armv7/socfpga/clock_manager.c +6 -6
index 158501a..d032bbd 100644
@@ -30,7 +30,7 @@ static const struct socfpga_clock_manager *clock_manager_base =
 	CLKMGR_MAINPLLGRP_VCO_EN_SET(1)| \
 	CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(0))
 
-static inline void cm_wait_for_lock(uint32_t mask)
+static void cm_wait_for_lock(uint32_t mask)
 {
 	register uint32_t inter_val;
 	do {
@@ -39,7 +39,7 @@ static inline void cm_wait_for_lock(uint32_t mask)
 }
 
 /* function to poll in the fsm busy bit */
-static inline void cm_wait_for_fsm(void)
+static void cm_wait_for_fsm(void)
 {
 	while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY)
 		;
@@ -49,22 +49,22 @@ static inline void cm_wait_for_fsm(void)
  * function to write the bypass register which requires a poll of the
  * busy bit
  */
-static inline void cm_write_bypass(uint32_t val)
+static void cm_write_bypass(uint32_t val)
 {
 	writel(val, &clock_manager_base->bypass);
 	cm_wait_for_fsm();
 }
 
 /* function to write the ctrl register which requires a poll of the busy bit */
-static inline void cm_write_ctrl(uint32_t val)
+static void cm_write_ctrl(uint32_t val)
 {
 	writel(val, &clock_manager_base->ctrl);
 	cm_wait_for_fsm();
 }
 
 /* function to write a clock register that has phase information */
-static inline void cm_write_with_phase(uint32_t value,
-	uint32_t reg_address, uint32_t mask)
+static void cm_write_with_phase(uint32_t value,
+				uint32_t reg_address, uint32_t mask)
 {
 	/* poll until phase is zero */
 	while (readl(reg_address) & mask)
#34 lore raw

PATCH 13/35 arm: socfpga: clock: Drop nonsense inlining from clock manager code

Quoted 8 lines · Dinh Nguyen
Quoted 1 line · Marek Vasut

The inlining is done by GCC whe needed, there is no need to do it

s/whe/when.

thanks...

Fixed, thanks!

Best regards,
Marek Vasut

#35 lore raw

PATCH 14/35 arm: socfpga: clock: Add missing stubs into board file

In reply to Marek Vasut

Add some stub defines, which are used by the clock code, but are missing from the auto-generated header file for the SoCFPGA family.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 board/altera/socfpga/pll_config.h | 3 +++
 1 file changed, 3 insertions(+)
board/altera/socfpga/pll_config.h +3 -0
index 9bd0442..f0f59a9 100644
@@ -94,6 +94,9 @@
 
 /* Info for driver */
 #define CONFIG_HPS_CLK_OSC1_HZ			(25000000)
+#define CONFIG_HPS_CLK_OSC2_HZ			0
+#define CONFIG_HPS_CLK_F2S_SDR_REF_HZ		0
+#define CONFIG_HPS_CLK_F2S_PER_REF_HZ		0
 #define CONFIG_HPS_CLK_MAINVCO_HZ		(1600000000)
 #define CONFIG_HPS_CLK_PERVCO_HZ		(1000000000)
 #ifdef CONFIG_SOCFPGA_ARRIA5
Signature · 1 line
2.1.0
#36 lore raw

PATCH 14/35 arm: socfpga: clock: Add missing stubs into board file

Quoted 20 lines · Marek Vasut

Add some stub defines, which are used by the clock code, but are missing from the auto-generated header file for the SoCFPGA family.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 board/altera/socfpga/pll_config.h | 3 +++
 1 file changed, 3 insertions(+)
board/altera/socfpga/pll_config.h +0 -0
index 9bd0442..f0f59a9 100644

board/altera/socfpga/pll_config.h line 102

Quoted 9 lines
board/altera/socfpga/pll_config.h +3 -0
@@ -94,6 +94,9 @@
 
 /* Info for driver */
 #define CONFIG_HPS_CLK_OSC1_HZ			(25000000)
+#define CONFIG_HPS_CLK_OSC2_HZ			0
+#define CONFIG_HPS_CLK_F2S_SDR_REF_HZ		0
+#define CONFIG_HPS_CLK_F2S_PER_REF_HZ		0
 #define CONFIG_HPS_CLK_MAINVCO_HZ		(1600000000)
 #define CONFIG_HPS_CLK_PERVCO_HZ		(1000000000)
 #ifdef CONFIG_SOCFPGA_ARRIA5

thanks...

#37 lore raw

PATCH 14/35 arm: socfpga: clock: Add missing stubs into board file

In reply to Marek Vasut
Quoted 9 lines · Marek Vasut

Add some stub defines, which are used by the clock code, but are missing from the auto-generated header file for the SoCFPGA family.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#38 lore raw

PATCH 15/35 arm: socfpga: clock: Add code to read clock configuration

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Add the entire bulk of code to read out clock configuration from the SoCFPGA CPU registers. This is important for MMC, QSPI and UART drivers as otherwise they cannot determine the frequency of their upstream clock.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/clock_manager.c        | 226 +++++++++++++++++++++-
 arch/arm/include/asm/arch-socfpga/clock_manager.h |  43 +++-
 include/configs/socfpga_cyclone5.h                |   1 +
 3 files changed, 267 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/socfpga/clock_manager.c +225 -1
index d032bbd..07cf74c 100644
@@ -8,8 +8,10 @@
 #include <asm/io.h>
 #include <asm/arch/clock_manager.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static const struct socfpga_clock_manager *clock_manager_base =
-		(void *)SOCFPGA_CLKMGR_ADDRESS;
+	(struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
 
 #define CLKMGR_BYPASS_ENABLE	1
 #define CLKMGR_BYPASS_DISABLE	0
@@ -358,3 +360,225 @@ void cm_basic_init(const cm_config_t *cfg)
 	writel(~0, &clock_manager_base->per_pll.en);
 	writel(~0, &clock_manager_base->sdr_pll.en);
 }
+
+unsigned long cm_get_mpu_clk_hz(void)
+{
+	uint32_t reg, clock;
+
+	/* get the main VCO clock */
+	reg = readl(&clock_manager_base->main_pll.vco);
+	clock = CONFIG_HPS_CLK_OSC1_HZ /
+		(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
+	clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+	/* get the MPU clock */
+	reg = readl(&clock_manager_base->altera.mpuclk);
+	clock /= (reg + 1);
+	reg = readl(&clock_manager_base->main_pll.mpuclk);
+	clock /= (reg + 1);
+	return clock;
+}
+
+unsigned long cm_get_sdram_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify SDRAM PLL clock source */
+	reg = readl(&clock_manager_base->sdr_pll.vco);
+	reg = CLKMGR_SDRPLLGRP_VCO_SSRC_GET(reg);
+	if (reg == CLKMGR_VCO_SSRC_EOSC1)
+		clock = CONFIG_HPS_CLK_OSC1_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+		clock = CONFIG_HPS_CLK_OSC2_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_F2S)
+		clock = CONFIG_HPS_CLK_F2S_SDR_REF_HZ;
+
+	/* get the SDRAM VCO clock */
+	reg = readl(&clock_manager_base->sdr_pll.vco);
+	clock /= (CLKMGR_SDRPLLGRP_VCO_DENOM_GET(reg) + 1);
+	clock *= (CLKMGR_SDRPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+	/* get the SDRAM (DDR_DQS) clock */
+	reg = readl(&clock_manager_base->sdr_pll.ddrdqsclk);
+	reg = CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_GET(reg);
+	clock /= (reg + 1);
+
+	return clock;
+}
+
+unsigned int cm_get_l4_sp_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify the source of L4 SP clock */
+	reg = readl(&clock_manager_base->main_pll.l4src);
+	reg = CLKMGR_MAINPLLGRP_L4SRC_L4SP_GET(reg);
+
+	if (reg == CLKMGR_L4_SP_CLK_SRC_MAINPLL) {
+		/* get the main VCO clock */
+		reg = readl(&clock_manager_base->main_pll.vco);
+		clock = CONFIG_HPS_CLK_OSC1_HZ /
+			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the clock prior L4 SP divider (main clk) */
+		reg = readl(&clock_manager_base->altera.mainclk);
+		clock /= (reg + 1);
+		reg = readl(&clock_manager_base->main_pll.mainclk);
+		clock /= (reg + 1);
+	} else if (reg == CLKMGR_L4_SP_CLK_SRC_PERPLL) {
+		/* identify PER PLL clock source */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
+		if (reg == CLKMGR_VCO_SSRC_EOSC1)
+			clock = CONFIG_HPS_CLK_OSC1_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+			clock = CONFIG_HPS_CLK_OSC2_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_F2S)
+			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+
+		/* get the PER VCO clock */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the clock prior L4 SP divider (periph_base_clk) */
+		reg = readl(&clock_manager_base->per_pll.perbaseclk);
+		clock /= (reg + 1);
+	}
+
+	/* get the L4 SP clock which supplied to UART */
+	reg = readl(&clock_manager_base->main_pll.maindiv);
+	reg = CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_GET(reg);
+	clock = clock / (reg + 1);
+
+	return clock;
+}
+
+unsigned int cm_get_mmc_controller_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify the source of MMC clock */
+	reg = readl(&clock_manager_base->per_pll.src);
+	reg = CLKMGR_PERPLLGRP_SRC_SDMMC_GET(reg);
+
+	if (reg == CLKMGR_SDMMC_CLK_SRC_F2S) {
+		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+	} else if (reg == CLKMGR_SDMMC_CLK_SRC_MAIN) {
+		/* get the main VCO clock */
+		reg = readl(&clock_manager_base->main_pll.vco);
+		clock = CONFIG_HPS_CLK_OSC1_HZ /
+			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the SDMMC clock */
+		reg = readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
+		clock /= (reg + 1);
+	} else if (reg == CLKMGR_SDMMC_CLK_SRC_PER) {
+		/* identify PER PLL clock source */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
+		if (reg == CLKMGR_VCO_SSRC_EOSC1)
+			clock = CONFIG_HPS_CLK_OSC1_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+			clock = CONFIG_HPS_CLK_OSC2_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_F2S)
+			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+
+		/* get the PER VCO clock */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the SDMMC clock */
+		reg = readl(&clock_manager_base->per_pll.pernandsdmmcclk);
+		clock /= (reg + 1);
+	}
+
+	/* further divide by 4 as we have fixed divider at wrapper */
+	clock /= 4;
+	return clock;
+}
+
+unsigned int cm_get_qspi_controller_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify the source of QSPI clock */
+	reg = readl(&clock_manager_base->per_pll.src);
+	reg = CLKMGR_PERPLLGRP_SRC_QSPI_GET(reg);
+
+	if (reg == CLKMGR_QSPI_CLK_SRC_F2S) {
+		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+	} else if (reg == CLKMGR_QSPI_CLK_SRC_MAIN) {
+		/* get the main VCO clock */
+		reg = readl(&clock_manager_base->main_pll.vco);
+		clock = CONFIG_HPS_CLK_OSC1_HZ /
+			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the qspi clock */
+		reg = readl(&clock_manager_base->main_pll.mainqspiclk);
+		clock /= (reg + 1);
+	} else if (reg == CLKMGR_QSPI_CLK_SRC_PER) {
+		/* identify PER PLL clock source */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
+		if (reg == CLKMGR_VCO_SSRC_EOSC1)
+			clock = CONFIG_HPS_CLK_OSC1_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+			clock = CONFIG_HPS_CLK_OSC2_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_F2S)
+			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+
+		/* get the PER VCO clock */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the qspi clock */
+		reg = readl(&clock_manager_base->per_pll.perqspiclk);
+		clock /= (reg + 1);
+	}
+
+	return clock;
+}
+
+static void cm_print_clock_quick_summary(void)
+{
+	printf("MPU       %10ld kHz\n", cm_get_mpu_clk_hz() / 1000);
+	printf("DDR       %10ld kHz\n", cm_get_sdram_clk_hz() / 1000);
+	printf("EOSC1       %8d kHz\n", CONFIG_HPS_CLK_OSC1_HZ / 1000);
+	printf("EOSC2       %8d kHz\n", CONFIG_HPS_CLK_OSC2_HZ / 1000);
+	printf("F2S_SDR_REF %8d kHz\n", CONFIG_HPS_CLK_F2S_SDR_REF_HZ / 1000);
+	printf("F2S_PER_REF %8d kHz\n", CONFIG_HPS_CLK_F2S_PER_REF_HZ / 1000);
+	printf("MMC         %8d kHz\n", cm_get_mmc_controller_clk_hz() / 1000);
+	printf("QSPI        %8d kHz\n", cm_get_qspi_controller_clk_hz() / 1000);
+	printf("UART        %8d kHz\n", cm_get_l4_sp_clk_hz() / 1000);
+}
+
+int set_cpu_clk_info(void)
+{
+	/* Calculate the clock frequencies required for drivers */
+	cm_get_l4_sp_clk_hz();
+	cm_get_mmc_controller_clk_hz();
+
+	gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000;
+	gd->bd->bi_dsp_freq = 0;
+	gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000;
+
+	return 0;
+}
+
+int do_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	cm_print_clock_quick_summary();
+	return 0;
+}
+
+U_BOOT_CMD(
+	clocks,	CONFIG_SYS_MAXARGS, 1, do_showclocks,
+	"display clocks",
+	""
+);
arch/arm/include/asm/arch-socfpga/clock_manager.h +41 -2

111 lines not on this page · raw message

include/configs/socfpga_cyclone5.h +1 -0
index 5d145cd..3b6cfb4 100644
@@ -24,6 +24,7 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_SINGLE_BOOTLOADER
 #define CONFIG_SOCFPGA
+#define CONFIG_CLOCKS
 
 /* base address for .text section */
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
Signature · 1 line
2.1.0
#39 lore raw

PATCH 15/35 arm: socfpga: clock: Add code to read clock configuration

Quoted 121 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Add the entire bulk of code to read out clock configuration from the SoCFPGA CPU registers. This is important for MMC, QSPI and UART drivers as otherwise they cannot determine the frequency of their upstream clock.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/clock_manager.c        | 226 +++++++++++++++++++++-
 arch/arm/include/asm/arch-socfpga/clock_manager.h |  43 +++-
 include/configs/socfpga_cyclone5.h                |   1 +
 3 files changed, 267 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/socfpga/clock_manager.c +84 -1
index d032bbd..07cf74c 100644
@@ -8,8 +8,10 @@
 #include <asm/io.h>
 #include <asm/arch/clock_manager.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static const struct socfpga_clock_manager *clock_manager_base =
-		(void *)SOCFPGA_CLKMGR_ADDRESS;
+	(struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
 
 #define CLKMGR_BYPASS_ENABLE	1
 #define CLKMGR_BYPASS_DISABLE	0
@@ -358,3 +360,225 @@ void cm_basic_init(const cm_config_t *cfg)
 	writel(~0, &clock_manager_base->per_pll.en);
 	writel(~0, &clock_manager_base->sdr_pll.en);
 }
+
+unsigned long cm_get_mpu_clk_hz(void)
+{
+	uint32_t reg, clock;
+
+	/* get the main VCO clock */
+	reg = readl(&clock_manager_base->main_pll.vco);
+	clock = CONFIG_HPS_CLK_OSC1_HZ /
+		(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
+	clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+	/* get the MPU clock */
+	reg = readl(&clock_manager_base->altera.mpuclk);
+	clock /= (reg + 1);
+	reg = readl(&clock_manager_base->main_pll.mpuclk);
+	clock /= (reg + 1);
+	return clock;
+}
+
+unsigned long cm_get_sdram_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify SDRAM PLL clock source */
+	reg = readl(&clock_manager_base->sdr_pll.vco);
+	reg = CLKMGR_SDRPLLGRP_VCO_SSRC_GET(reg);
+	if (reg == CLKMGR_VCO_SSRC_EOSC1)
+		clock = CONFIG_HPS_CLK_OSC1_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+		clock = CONFIG_HPS_CLK_OSC2_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_F2S)
+		clock = CONFIG_HPS_CLK_F2S_SDR_REF_HZ;
+
+	/* get the SDRAM VCO clock */
+	reg = readl(&clock_manager_base->sdr_pll.vco);
+	clock /= (CLKMGR_SDRPLLGRP_VCO_DENOM_GET(reg) + 1);
+	clock *= (CLKMGR_SDRPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+	/* get the SDRAM (DDR_DQS) clock */
+	reg = readl(&clock_manager_base->sdr_pll.ddrdqsclk);
+	reg = CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_GET(reg);
+	clock /= (reg + 1);
+
+	return clock;
+}
+
+unsigned int cm_get_l4_sp_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify the source of L4 SP clock */
+	reg = readl(&clock_manager_base->main_pll.l4src);
+	reg = CLKMGR_MAINPLLGRP_L4SRC_L4SP_GET(reg);
+
+	if (reg == CLKMGR_L4_SP_CLK_SRC_MAINPLL) {
+		/* get the main VCO clock */
+		reg = readl(&clock_manager_base->main_pll.vco);
+		clock = CONFIG_HPS_CLK_OSC1_HZ /
+			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+		/* get the clock prior L4 SP divider (main clk) */
+		reg = readl(&clock_manager_base->altera.mainclk);
+		clock /= (reg + 1);
+		reg = readl(&clock_manager_base->main_pll.mainclk);
+		clock /= (reg + 1);
+	} else if (reg == CLKMGR_L4_SP_CLK_SRC_PERPLL) {
+		/* identify PER PLL clock source */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
+		if (reg == CLKMGR_VCO_SSRC_EOSC1)
+			clock = CONFIG_HPS_CLK_OSC1_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+			clock = CONFIG_HPS_CLK_OSC2_HZ;
+		else if (reg == CLKMGR_VCO_SSRC_F2S)
+			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+
+		/* get the PER VCO clock */
+		reg = readl(&clock_manager_base->per_pll.vco);
+		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
+		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);

arch/arm/cpu/armv7/socfpga/clock_manager.c void cm_basic_init(const cm_config_t *cfg) · line 453

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/clock_manager.c +10 -0
+
+		/* get the clock prior L4 SP divider (periph_base_clk) */
+		reg = readl(&clock_manager_base->per_pll.perbaseclk);
+		clock /= (reg + 1);
+	}
+
+	/* get the L4 SP clock which supplied to UART */
+	reg = readl(&clock_manager_base->main_pll.maindiv);
+	reg = CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_GET(reg);
+	clock = clock / (reg + 1);

This is not a +1. The l4 mp clock divider is structured like this:

0x0 = divide by 1
0x1 = divide by 2
0x2 = divide by 4
0x3 = divide by 8
0x4 = divide by 16

So it should be:
clock = clock / (1 << reg);

Dinh

#40 lore raw

PATCH 15/35 arm: socfpga: clock: Add code to read clock configuration

Quoted 1 line · Dinh Nguyen

On 09/15/2014 06:06 AM, Marek Vasut wrote:

[...]

Quoted 7 lines

arch/arm/cpu/armv7/socfpga/clock_manager.c void cm_basic_init(const cm_config_t *cfg) · line 453

Quoted 4 lines
arch/arm/cpu/armv7/socfpga/clock_manager.c +4 -0
+	/* get the L4 SP clock which supplied to UART */
+	reg = readl(&clock_manager_base->main_pll.maindiv);
+	reg = CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_GET(reg);
+	clock = clock / (reg + 1);

This is not a +1. The l4 mp clock divider is structured like this:

Quoted 8 lines

0x0 = divide by 1
0x1 = divide by 2
0x2 = divide by 4
0x3 = divide by 8
0x4 = divide by 16

So it should be:
clock = clock / (1 << reg);

Fixed, thanks! I also synched the clock code with your codebase for all but the SDRAM auto refresh part.

Best regards,
Marek Vasut

#41 lore raw

PATCH 16/35 arm: socfpga: clock: Trim down code duplication

In reply to Marek Vasut

Pull out functions to read frequency of Main clock VCO and PLL clock VCO as the code is duplicated multiple times.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/clock_manager.c | 96 ++++++++++++------------------
 1 file changed, 38 insertions(+), 58 deletions(-)
arch/arm/cpu/armv7/socfpga/clock_manager.c +38 -58
index 07cf74c..1ab62e7 100644
@@ -361,7 +361,7 @@ void cm_basic_init(const cm_config_t *cfg)
 	writel(~0, &clock_manager_base->sdr_pll.en);
 }
 
-unsigned long cm_get_mpu_clk_hz(void)
+static unsigned int cm_get_main_vco_clk_hz(void)
 {
 	uint32_t reg, clock;
 
@@ -371,6 +371,37 @@ unsigned long cm_get_mpu_clk_hz(void)
 		(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
 	clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
 
+	return clock;
+}
+
+static unsigned int cm_get_per_vco_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify PER PLL clock source */
+	reg = readl(&clock_manager_base->per_pll.vco);
+	reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
+	if (reg == CLKMGR_VCO_SSRC_EOSC1)
+		clock = CONFIG_HPS_CLK_OSC1_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+		clock = CONFIG_HPS_CLK_OSC2_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_F2S)
+		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+
+	/* get the PER VCO clock */
+	reg = readl(&clock_manager_base->per_pll.vco);
+	clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
+	clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+	return clock;
+}
+
+unsigned long cm_get_mpu_clk_hz(void)
+{
+	uint32_t reg, clock;
+
+	clock = cm_get_main_vco_clk_hz();
+
 	/* get the MPU clock */
 	reg = readl(&clock_manager_base->altera.mpuclk);
 	clock /= (reg + 1);
@@ -415,11 +446,7 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 	reg = CLKMGR_MAINPLLGRP_L4SRC_L4SP_GET(reg);
 
 	if (reg == CLKMGR_L4_SP_CLK_SRC_MAINPLL) {
-		/* get the main VCO clock */
-		reg = readl(&clock_manager_base->main_pll.vco);
-		clock = CONFIG_HPS_CLK_OSC1_HZ /
-			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_main_vco_clk_hz();
 
 		/* get the clock prior L4 SP divider (main clk) */
 		reg = readl(&clock_manager_base->altera.mainclk);
@@ -427,20 +454,7 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 		reg = readl(&clock_manager_base->main_pll.mainclk);
 		clock /= (reg + 1);
 	} else if (reg == CLKMGR_L4_SP_CLK_SRC_PERPLL) {
-		/* identify PER PLL clock source */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
-		if (reg == CLKMGR_VCO_SSRC_EOSC1)
-			clock = CONFIG_HPS_CLK_OSC1_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-			clock = CONFIG_HPS_CLK_OSC2_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_F2S)
-			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
-
-		/* get the PER VCO clock */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_per_vco_clk_hz();
 
 		/* get the clock prior L4 SP divider (periph_base_clk) */
 		reg = readl(&clock_manager_base->per_pll.perbaseclk);
@@ -466,30 +480,13 @@ unsigned int cm_get_mmc_controller_clk_hz(void)
 	if (reg == CLKMGR_SDMMC_CLK_SRC_F2S) {
 		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
 	} else if (reg == CLKMGR_SDMMC_CLK_SRC_MAIN) {
-		/* get the main VCO clock */
-		reg = readl(&clock_manager_base->main_pll.vco);
-		clock = CONFIG_HPS_CLK_OSC1_HZ /
-			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_main_vco_clk_hz();
 
 		/* get the SDMMC clock */
 		reg = readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
 		clock /= (reg + 1);
 	} else if (reg == CLKMGR_SDMMC_CLK_SRC_PER) {
-		/* identify PER PLL clock source */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
-		if (reg == CLKMGR_VCO_SSRC_EOSC1)
-			clock = CONFIG_HPS_CLK_OSC1_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-			clock = CONFIG_HPS_CLK_OSC2_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_F2S)
-			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
-
-		/* get the PER VCO clock */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_per_vco_clk_hz();
 
 		/* get the SDMMC clock */
 		reg = readl(&clock_manager_base->per_pll.pernandsdmmcclk);
@@ -512,30 +509,13 @@ unsigned int cm_get_qspi_controller_clk_hz(void)
 	if (reg == CLKMGR_QSPI_CLK_SRC_F2S) {
 		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
 	} else if (reg == CLKMGR_QSPI_CLK_SRC_MAIN) {
-		/* get the main VCO clock */
-		reg = readl(&clock_manager_base->main_pll.vco);
-		clock = CONFIG_HPS_CLK_OSC1_HZ /
-			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_main_vco_clk_hz();
 
 		/* get the qspi clock */
 		reg = readl(&clock_manager_base->main_pll.mainqspiclk);
 		clock /= (reg + 1);
 	} else if (reg == CLKMGR_QSPI_CLK_SRC_PER) {
-		/* identify PER PLL clock source */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
-		if (reg == CLKMGR_VCO_SSRC_EOSC1)
-			clock = CONFIG_HPS_CLK_OSC1_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-			clock = CONFIG_HPS_CLK_OSC2_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_F2S)
-			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
-
-		/* get the PER VCO clock */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_per_vco_clk_hz();
 
 		/* get the qspi clock */
 		reg = readl(&clock_manager_base->per_pll.perqspiclk);
Signature · 1 line
2.1.0
#42 lore raw

PATCH 16/35 arm: socfpga: clock: Trim down code duplication

Quoted 157 lines · Marek Vasut

Pull out functions to read frequency of Main clock VCO and PLL clock VCO as the code is duplicated multiple times.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/clock_manager.c | 96 ++++++++++++------------------
 1 file changed, 38 insertions(+), 58 deletions(-)
arch/arm/cpu/armv7/socfpga/clock_manager.c +37 -52
index 07cf74c..1ab62e7 100644
@@ -361,7 +361,7 @@ void cm_basic_init(const cm_config_t *cfg)
 	writel(~0, &clock_manager_base->sdr_pll.en);
 }
 
-unsigned long cm_get_mpu_clk_hz(void)
+static unsigned int cm_get_main_vco_clk_hz(void)
 {
 	uint32_t reg, clock;
 
@@ -371,6 +371,37 @@ unsigned long cm_get_mpu_clk_hz(void)
 		(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
 	clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
 
+	return clock;
+}
+
+static unsigned int cm_get_per_vco_clk_hz(void)
+{
+	uint32_t reg, clock = 0;
+
+	/* identify PER PLL clock source */
+	reg = readl(&clock_manager_base->per_pll.vco);
+	reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
+	if (reg == CLKMGR_VCO_SSRC_EOSC1)
+		clock = CONFIG_HPS_CLK_OSC1_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_EOSC2)
+		clock = CONFIG_HPS_CLK_OSC2_HZ;
+	else if (reg == CLKMGR_VCO_SSRC_F2S)
+		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
+
+	/* get the PER VCO clock */
+	reg = readl(&clock_manager_base->per_pll.vco);
+	clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
+	clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+
+	return clock;
+}
+
+unsigned long cm_get_mpu_clk_hz(void)
+{
+	uint32_t reg, clock;
+
+	clock = cm_get_main_vco_clk_hz();
+
 	/* get the MPU clock */
 	reg = readl(&clock_manager_base->altera.mpuclk);
 	clock /= (reg + 1);
@@ -415,11 +446,7 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 	reg = CLKMGR_MAINPLLGRP_L4SRC_L4SP_GET(reg);
 
 	if (reg == CLKMGR_L4_SP_CLK_SRC_MAINPLL) {
-		/* get the main VCO clock */
-		reg = readl(&clock_manager_base->main_pll.vco);
-		clock = CONFIG_HPS_CLK_OSC1_HZ /
-			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_main_vco_clk_hz();
 
 		/* get the clock prior L4 SP divider (main clk) */
 		reg = readl(&clock_manager_base->altera.mainclk);
@@ -427,20 +454,7 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 		reg = readl(&clock_manager_base->main_pll.mainclk);
 		clock /= (reg + 1);
 	} else if (reg == CLKMGR_L4_SP_CLK_SRC_PERPLL) {
-		/* identify PER PLL clock source */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
-		if (reg == CLKMGR_VCO_SSRC_EOSC1)
-			clock = CONFIG_HPS_CLK_OSC1_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-			clock = CONFIG_HPS_CLK_OSC2_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_F2S)
-			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
-
-		/* get the PER VCO clock */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_per_vco_clk_hz();
 
 		/* get the clock prior L4 SP divider (periph_base_clk) */
 		reg = readl(&clock_manager_base->per_pll.perbaseclk);
@@ -466,30 +480,13 @@ unsigned int cm_get_mmc_controller_clk_hz(void)
 	if (reg == CLKMGR_SDMMC_CLK_SRC_F2S) {
 		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
 	} else if (reg == CLKMGR_SDMMC_CLK_SRC_MAIN) {
-		/* get the main VCO clock */
-		reg = readl(&clock_manager_base->main_pll.vco);
-		clock = CONFIG_HPS_CLK_OSC1_HZ /
-			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_main_vco_clk_hz();
 
 		/* get the SDMMC clock */
 		reg = readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
 		clock /= (reg + 1);
 	} else if (reg == CLKMGR_SDMMC_CLK_SRC_PER) {
-		/* identify PER PLL clock source */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
-		if (reg == CLKMGR_VCO_SSRC_EOSC1)
-			clock = CONFIG_HPS_CLK_OSC1_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-			clock = CONFIG_HPS_CLK_OSC2_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_F2S)
-			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
-
-		/* get the PER VCO clock */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_per_vco_clk_hz();
 
 		/* get the SDMMC clock */
 		reg = readl(&clock_manager_base->per_pll.pernandsdmmcclk);
@@ -512,30 +509,13 @@ unsigned int cm_get_qspi_controller_clk_hz(void)
 	if (reg == CLKMGR_QSPI_CLK_SRC_F2S) {
 		clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
 	} else if (reg == CLKMGR_QSPI_CLK_SRC_MAIN) {
-		/* get the main VCO clock */
-		reg = readl(&clock_manager_base->main_pll.vco);
-		clock = CONFIG_HPS_CLK_OSC1_HZ /
-			(CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_main_vco_clk_hz();
 
 		/* get the qspi clock */
 		reg = readl(&clock_manager_base->main_pll.mainqspiclk);
 		clock /= (reg + 1);
 	} else if (reg == CLKMGR_QSPI_CLK_SRC_PER) {
-		/* identify PER PLL clock source */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg);
-		if (reg == CLKMGR_VCO_SSRC_EOSC1)
-			clock = CONFIG_HPS_CLK_OSC1_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-			clock = CONFIG_HPS_CLK_OSC2_HZ;
-		else if (reg == CLKMGR_VCO_SSRC_F2S)

arch/arm/cpu/armv7/socfpga/clock_manager.c unsigned int cm_get_qspi_controller_clk_hz(void) · line 521

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/clock_manager.c +1 -6
-			clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ;
-
-		/* get the PER VCO clock */
-		reg = readl(&clock_manager_base->per_pll.vco);
-		clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1);
-		clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1);
+		clock = cm_get_per_vco_clk_hz();
 
 		/* get the qspi clock */
 		reg = readl(&clock_manager_base->per_pll.perqspiclk);

Thanks...

#43 lore raw

PATCH 16/35 arm: socfpga: clock: Trim down code duplication

In reply to Marek Vasut
Quoted 9 lines · Marek Vasut

Pull out functions to read frequency of Main clock VCO and PLL clock VCO as the code is duplicated multiple times.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#44 lore raw

PATCH 17/35 arm: socfpga: mmc: Pick the clock from clock manager

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Make the SoCFPGA MMC stub pick clock via the clock manager frequency accessors instead of hard-coding the frequency.

Also fix calloc() misuse.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 drivers/mmc/socfpga_dw_mmc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/mmc/socfpga_dw_mmc.c +11 -4
index 1f96382..eb69aed 100644
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <dwmmc.h>
+#include <errno.h>
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clock_manager.h>
 #include <asm/arch/system_manager.h>
@@ -44,12 +45,18 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host)
 int socfpga_dwmmc_init(u32 regbase, int bus_width, int index)
 {
 	struct dwmci_host *host;
+	unsigned long clk = cm_get_mmc_controller_clk_hz();
+
+	if (clk == 0) {
+		printf("%s: MMC clock is zero!", __func__);
+		return -EINVAL;
+	}
 
 	/* calloc for zero init */
-	host = calloc(sizeof(struct dwmci_host), 1);
+	host = calloc(1, sizeof(struct dwmci_host));
 	if (!host) {
-		printf("dwmci_host calloc fail!\n");
-		return -1;
+		printf("%s: calloc() failed!\n", __func__);
+		return -ENOMEM;
 	}
 
 	host->name = "SOCFPGA DWMMC";
@@ -58,7 +65,7 @@ int socfpga_dwmmc_init(u32 regbase, int bus_width, int index)
 	host->clksel = socfpga_dwmci_clksel;
 	host->dev_index = index;
 	/* fixed clock divide by 4 which due to the SDMMC wrapper */
-	host->bus_hz = CONFIG_SOCFPGA_DWMMC_BUS_HZ;
+	host->bus_hz = clk;
 	host->fifoth_val = MSIZE(0x2) |
 		RX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2 - 1) |
 		TX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2);
Signature · 1 line
2.1.0
#45 lore raw

PATCH 17/35 arm: socfpga: mmc: Pick the clock from clock manager

Quoted 55 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Make the SoCFPGA MMC stub pick clock via the clock manager frequency accessors instead of hard-coding the frequency.

Also fix calloc() misuse.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 drivers/mmc/socfpga_dw_mmc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/mmc/socfpga_dw_mmc.c +10 -3
index 1f96382..eb69aed 100644
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <dwmmc.h>
+#include <errno.h>
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clock_manager.h>
 #include <asm/arch/system_manager.h>
@@ -44,12 +45,18 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host)
 int socfpga_dwmmc_init(u32 regbase, int bus_width, int index)
 {
 	struct dwmci_host *host;
+	unsigned long clk = cm_get_mmc_controller_clk_hz();
+
+	if (clk == 0) {
+		printf("%s: MMC clock is zero!", __func__);
+		return -EINVAL;
+	}
 
 	/* calloc for zero init */
-	host = calloc(sizeof(struct dwmci_host), 1);
+	host = calloc(1, sizeof(struct dwmci_host));
 	if (!host) {
-		printf("dwmci_host calloc fail!\n");
-		return -1;
+		printf("%s: calloc() failed!\n", __func__);
+		return -ENOMEM;
 	}
 
 	host->name = "SOCFPGA DWMMC";

drivers/mmc/socfpga_dw_mmc.c int socfpga_dwmmc_init(u32 regbase, int bus_width, int index) · line 71

Quoted 8 lines
drivers/mmc/socfpga_dw_mmc.c +1 -1
@@ -58,7 +65,7 @@ int socfpga_dwmmc_init(u32 regbase, int bus_width, int index)
 	host->clksel = socfpga_dwmci_clksel;
 	host->dev_index = index;
 	/* fixed clock divide by 4 which due to the SDMMC wrapper */
-	host->bus_hz = CONFIG_SOCFPGA_DWMMC_BUS_HZ;
+	host->bus_hz = clk;
 	host->fifoth_val = MSIZE(0x2) |
 		RX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2 - 1) |
 		TX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2);

Thanks..

#46 lore raw

PATCH 18/35 arm: socfpga: timer: Pull the timer reload value from config file

In reply to Marek Vasut

The timer reload value is a property of the timer hardware and there is no reason for this to be configurable. Place this into the timer driver just like on the other hardware.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/timer.c | 2 ++
 include/configs/socfpga_cyclone5.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/socfpga/timer.c +2 -0
index 58fc789..253cde3 100644
@@ -8,6 +8,8 @@
 #include <asm/io.h>
 #include <asm/arch/timer.h>
 
+#define TIMER_LOAD_VAL		0xFFFFFFFF
+
 static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE;
 
 /*
include/configs/socfpga_cyclone5.h +0 -2
index 3b6cfb4..f50081b 100644
@@ -195,8 +195,6 @@
 /* This timer use eosc1 where the clock frequency is fixed
  * throughout any condition */
 #define CONFIG_SYS_TIMERBASE		SOCFPGA_OSC1TIMER0_ADDRESS
-/* reload value when timer count to zero */
-#define TIMER_LOAD_VAL			0xFFFFFFFF
 /* Timer info */
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_TIMER_RATE		2400000
Signature · 1 line
2.1.0
#47 lore raw

PATCH 18/35 arm: socfpga: timer: Pull the timer reload value from config file

Quoted 10 lines · Marek Vasut

The timer reload value is a property of the timer hardware and there is no reason for this to be configurable. Place this into the timer driver just like on the other hardware.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#48 lore raw

PATCH 18/35 arm: socfpga: timer: Pull the timer reload value from config file

In reply to Marek Vasut
Quoted 35 lines · Marek Vasut

The timer reload value is a property of the timer hardware and there is no reason for this to be configurable. Place this into the timer driver just like on the other hardware.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/timer.c | 2 ++
 include/configs/socfpga_cyclone5.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/socfpga/timer.c +2 -0
index 58fc789..253cde3 100644
@@ -8,6 +8,8 @@
 #include <asm/io.h>
 #include <asm/arch/timer.h>
 
+#define TIMER_LOAD_VAL		0xFFFFFFFF
+
 static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE;
 
 /*
include/configs/socfpga_cyclone5.h +0 -0
index 3b6cfb4..f50081b 100644

include/configs/socfpga_cyclone5.h line 200

Quoted 8 lines
include/configs/socfpga_cyclone5.h +0 -2
@@ -195,8 +195,6 @@
 /* This timer use eosc1 where the clock frequency is fixed
  * throughout any condition */
 #define CONFIG_SYS_TIMERBASE		SOCFPGA_OSC1TIMER0_ADDRESS
-/* reload value when timer count to zero */
-#define TIMER_LOAD_VAL			0xFFFFFFFF
 /* Timer info */
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_TIMER_RATE		2400000

Thanks...

#49 lore raw

PATCH 19/35 arm: socfpga: reset: Add EMAC reset functions

In reply to Marek Vasut

Add functions to reset the EMAC ethernet blocks. We cannot handle two EMAC ethernet blocks yet, therefore the ifdefs. Once there is hardware using both EMAC blocks, this ifdef will have to go.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/reset_manager.c        | 21 +++++++++++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h |  2 ++
 2 files changed, 23 insertions(+)
arch/arm/cpu/armv7/socfpga/reset_manager.c +21 -0
index 07b8c4f..77579b7 100644
@@ -14,6 +14,8 @@ DECLARE_GLOBAL_DATA_PTR;
 static const struct socfpga_reset_manager *reset_manager_base =
 		(void *)SOCFPGA_RSTMGR_ADDRESS;
 
+#define RSTMGR_PERMODRST_EMAC0_LSB 0
+#define RSTMGR_PERMODRST_EMAC1_LSB 1
 #define RSTMGR_PERMODRST_L4WD0_LSB 6
 
 /* Disable the watchdog (toggle reset to watchdog) */
@@ -50,3 +52,22 @@ void reset_deassert_peripherals_handoff(void)
 {
 	writel(0, &reset_manager_base->per_mod_reset);
 }
+
+/* Change the reset state for EMAC 0 and EMAC 1 */
+void socfpga_emac_reset(int enable)
+{
+	const void *reset = &reset_manager_base->per_mod_reset;
+
+	if (enable) {
+		setbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC0_LSB);
+		setbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC1_LSB);
+	} else {
+#if (CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS)
+		clrbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC0_LSB);
+#elif (CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS)
+		clrbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC1_LSB);
+#else
+#error "Incorrect CONFIG_EMAC_BASE value!"
+#endif
+	}
+}
arch/arm/include/asm/arch-socfpga/reset_manager.h +2 -0
index e004343..9d22576 100644
@@ -10,6 +10,8 @@
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
+void socfpga_emac_reset(int enable);
+
 void watchdog_disable(void);
 
 struct socfpga_reset_manager {
Signature · 1 line
2.1.0
#50 lore raw

PATCH 19/35 arm: socfpga: reset: Add EMAC reset functions

Quoted 10 lines · Marek Vasut

Add functions to reset the EMAC ethernet blocks. We cannot handle two EMAC ethernet blocks yet, therefore the ifdefs. Once there is hardware using both EMAC blocks, this ifdef will have to go.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#51 lore raw

PATCH 20/35 arm: socfpga: misc: Add proper ethernet initialization

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Add function to initialize the EMAC blocks upon board startup. The preprocessor guards against building on SoCFPGA-VT and against SPL build are not needed as those are handled implicitly via both SPL framework and the socfpga_cyclone5.h config file, which will not define CONFIG_DESIGNWARE_ETH if building for SoCFPGA-VT.

We cannot handle two EMAC ethernet blocks yet, therefore the ifdefs. Once there is hardware using both EMAC blocks, this ifdef will have to go.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c                  | 58 ++++++++++++++++------
 arch/arm/include/asm/arch-socfpga/system_manager.h |  9 ++++
 2 files changed, 52 insertions(+), 15 deletions(-)
arch/arm/cpu/armv7/socfpga/misc.c +43 -15
index 15cd8c2..ee7283b 100644
@@ -9,15 +9,58 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static struct socfpga_system_manager *sysmgr_regs =
+	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 	return 0;
 }
 
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_DESIGNWARE_ETH
+int cpu_eth_init(bd_t *bis)
+{
+#if CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS
+	const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB;
+#elif CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS
+	const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB;
+#else
+#error "Incorrect CONFIG_EMAC_BASE value!"
+#endif
+
+	/* Initialize EMAC. This needs to be done at least once per boot. */
+
+	/*
+	 * Putting the EMAC controller to reset when configuring the PHY
+	 * interface select at System Manager
+	 */
+	socfpga_emac_reset(1);
+
+	/* Clearing emac0 PHY interface select to 0 */
+	clrbits_le32(&sysmgr_regs->emacgrp_ctrl,
+		     SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift);
+
+	/* configure to PHY interface select choosed */
+	setbits_le32(&sysmgr_regs->emacgrp_ctrl,
+		     SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII << physhift);
+
+	/* Release the EMAC controller from reset */
+	socfpga_emac_reset(0);
+
+	/* initialize and register the emac */
+	return designware_initialize(CONFIG_EMAC_BASE,
+				     CONFIG_PHY_INTERFACE_MODE);
+}
+#endif
+
 #if defined(CONFIG_DISPLAY_CPUINFO)
 /*
  * Print CPU information
@@ -44,18 +87,3 @@ int misc_init_r(void)
 
 	return 0;
 }
-
-
-/*
- * DesignWare Ethernet initialization
- */
-int cpu_eth_init(bd_t *bis)
-{
-#if !defined(CONFIG_SOCFPGA_VIRTUAL_TARGET) && !defined(CONFIG_SPL_BUILD)
-       /* initialize and register the emac */
-	return designware_initialize(CONFIG_EMAC_BASE,
-				     CONFIG_PHY_INTERFACE_MODE);
-#else
-	return 0;
-#endif
-}
arch/arm/include/asm/arch-socfpga/system_manager.h +9 -0
index 90d2720..071ec4f 100644
@@ -134,4 +134,13 @@ struct socfpga_system_manager {
 #define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel)	\
 	((((drvsel) << 0) & 0x7) | (((smplsel) << 3) & 0x38))
 
+/* EMAC Group Bit definitions */
+#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII	0x0
+#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII		0x1
+#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII		0x2
+
+#define SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB			0
+#define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
+#define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3
+
 #endif /* _SYSTEM_MANAGER_H_ */
Signature · 1 line
2.1.0
#52 lore raw

PATCH 21/35 arm: socfpga: misc: Add SD controller init

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Add CPU function to register and initialize the dw_mmc SD controller. This allows us to use the HPS SDMMC block.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/cpu/armv7/socfpga/misc.c +13 -0
index ee7283b..440d2a3 100644
@@ -10,6 +10,7 @@
 #include <netdev.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/arch/system_manager.h>
+#include <asm/arch/dwmmc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -61,6 +62,18 @@ int cpu_eth_init(bd_t *bis)
 }
 #endif
 
+#ifdef CONFIG_DWMMC
+/*
+ * Initializes MMC controllers.
+ * to override, implement board_mmc_init()
+ */
+int cpu_mmc_init(bd_t *bis)
+{
+	return socfpga_dwmmc_init(SOCFPGA_SDMMC_ADDRESS,
+				  CONFIG_HPS_SDMMC_BUSWIDTH, 0);
+}
+#endif
+
 #if defined(CONFIG_DISPLAY_CPUINFO)
 /*
  * Print CPU information
Signature · 1 line
2.1.0
#53 lore raw

PATCH 22/35 arm: socfpga: misc: Align print_cpuinfo() output

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Cosmetic change to the print_cpuinfo() function output. Align the output with the rest of initial output produced by U-Boot.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv7/socfpga/misc.c +1 -1
index 440d2a3..51be55c 100644
@@ -80,7 +80,7 @@ int cpu_mmc_init(bd_t *bis)
  */
 int print_cpuinfo(void)
 {
-	puts("CPU   : Altera SOCFPGA Platform\n");
+	puts("CPU:   Altera SoCFPGA Platform\n");
 	return 0;
 }
 #endif
Signature · 1 line
2.1.0
#54 lore raw

PATCH 23/35 arm: socfpga: board: Correctly set ATAG position

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

The bi_boot_params must point to offset 0x100 in DRAM. Make it so.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 board/altera/socfpga/socfpga_cyclone5.c | 4 ++++
 1 file changed, 4 insertions(+)
board/altera/socfpga/socfpga_cyclone5.c +4 -0
index fb92852..bc8a87c 100644
@@ -35,5 +35,9 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	icache_enable();
+
+	/* Address of boot parameters for ATAG (if ATAG is used) */
+	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+
 	return 0;
 }
Signature · 1 line
2.1.0
#55 lore raw

PATCH 24/35 arm: socfpga: board: Align checkboard() output

In reply to Marek Vasut

Cosmetic change to the checkboard() function output. Align the output with the rest of initial output produced by U-Boot.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 board/altera/socfpga/socfpga_cyclone5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/altera/socfpga/socfpga_cyclone5.c +1 -1
index bc8a87c..4149842 100644
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 int checkboard(void)
 {
-	puts("BOARD : Altera SOCFPGA Cyclone5 Board\n");
+	puts("BOARD: Altera SoCFPGA Cyclone5 Board\n");
 	return 0;
 }
 
Signature · 1 line
2.1.0
#56 lore raw

PATCH 24/35 arm: socfpga: board: Align checkboard() output

Quoted 9 lines · Marek Vasut

Cosmetic change to the checkboard() function output. Align the output with the rest of initial output produced by U-Boot.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#57 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/Makefile              |   3 +-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c        | 354 +++++++++++++++++++++++
 arch/arm/cpu/armv7/socfpga/misc.c                |  37 +++
 arch/arm/include/asm/arch-socfpga/fpga_manager.h |  77 +++++
 drivers/fpga/altera.c                            |  21 ++
 include/altera.h                                 |   1 +
 6 files changed, 492 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/fpga_manager.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/fpga_manager.h
arch/arm/cpu/armv7/socfpga/Makefile +2 -1
index eb33f2c..8b6e108 100644
@@ -8,5 +8,6 @@
 #
 
 obj-y	:= lowlevel_init.o
-obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o
+obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o \
+	   fpga_manager.o
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o scan_manager.o
arch/arm/cpu/armv7/socfpga/fpga_manager.c new file +354 -0

354 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/misc.c +37 -0
index 51be55c..8e25f09 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <altera.h>
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/reset_manager.h>
@@ -93,8 +94,44 @@ int overwrite_console(void)
 }
 #endif
 
+#ifdef CONFIG_FPGA
+/*
+ * FPGA programming support for SoC FPGA Cyclone V
+ */
+static Altera_desc altera_fpga[] = {
+	{
+		/* Family */
+		Altera_SoCFPGA,
+		/* Interface type */
+		fast_passive_parallel,
+		/* No limitation as additional data will be ignored */
+		-1,
+		/* No device function table */
+		NULL,
+		/* Base interface address specified in driver */
+		NULL,
+		/* No cookie implementation */
+		0
+	},
+};
+
+/* add device descriptor to FPGA device table */
+static void socfpga_fpga_add(void)
+{
+	int i;
+	fpga_init();
+	for (i = 0; i < ARRAY_SIZE(altera_fpga); i++)
+		fpga_add(fpga_altera, &altera_fpga[i]);
+}
+#else
+static inline void socfpga_fpga_add(void) {}
+#endif
+
 int misc_init_r(void)
 {
+	/* Add device descriptor to FPGA device table */
+	socfpga_fpga_add();
+
 	/* This is needed, otherwise kernel is rebooted by watchdog. */
 	watchdog_disable();
 
arch/arm/include/asm/arch-socfpga/fpga_manager.h new file +77 -0

77 lines not on this page · raw message

drivers/fpga/altera.c +21 -0
index 6e34a8e..d20b7be 100644
@@ -1,4 +1,7 @@
 /*
+ * (C) Copyright 2013
+ * Altera Corporation <www.altera.com>
+ *
  * (C) Copyright 2003
  * Steven Scholz, imc Measurement & Control, steven.scholz at imc-berlin.de
  *
@@ -14,6 +17,9 @@
 #include <common.h>
 #include <ACEX1K.h>
 #include <stratixII.h>
+#if defined(CONFIG_FPGA_SOCFPGA)
+#include <asm/arch/fpga_manager.h>
+#endif
 
 /* Define FPGA_DEBUG to get debug printf's */
 /* #define FPGA_DEBUG */
@@ -59,6 +65,13 @@ int altera_load(Altera_desc *desc, const void *buf, size_t bsize)
 			ret_val = StratixII_load (desc, buf, bsize);
 			break;
 #endif
+#if defined(CONFIG_FPGA_SOCFPGA)
+		case Altera_SoCFPGA:
+			PRINTF("%s: Launching the SoC FPGA Loader...\n",
+			       __func__);
+			ret_val = fpgamgr_program_fpga(buf, bsize);
+			break;
+#endif
 		default:
 			printf ("%s: Unsupported family type, %d\n",
 					__FUNCTION__, desc->family);
@@ -94,6 +107,11 @@ int altera_dump(Altera_desc *desc, const void *buf, size_t bsize)
 			ret_val = StratixII_dump (desc, buf, bsize);
 			break;
 #endif
+		case Altera_SoCFPGA:
+			printf("%s: Unsupported due to security reason, %d\n",
+			       __func__, desc->family);
+			ret_val = FPGA_SUCCESS;
+			break;
 		default:
 			printf ("%s: Unsupported family type, %d\n",
 					__FUNCTION__, desc->family);
@@ -119,6 +137,9 @@ int altera_info( Altera_desc *desc )
 		case Altera_StratixII:
 			printf ("Stratix II\n");
 			break;
+		case Altera_SoCFPGA:
+			printf("SoC FPGA\n");
+			break;
 			/* Add new family types here */
 		default:
 			printf ("Unknown family type, %d\n", desc->family);
include/altera.h +1 -0
index ae5f7ee..c7f78fc 100644
@@ -27,6 +27,7 @@ typedef enum {			/* typedef Altera_Family */
 	Altera_ACEX1K,		/* ACEX1K Family */
 	Altera_CYC2,		/* CYCLONII Family */
 	Altera_StratixII,	/* StratixII Family */
+	Altera_SoCFPGA,		/* SoCFPGA Family */
 /* Add new models here */
 	max_altera_type		/* insert all new types before this */
 } Altera_Family;		/* end, typedef Altera_Family */
Signature · 1 line
2.1.0
#58 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

Dear Marek Vasut,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

...

arch/arm/cpu/armv7/socfpga/fpga_manager.c line 39

Quoted 7 lines
arch/arm/cpu/armv7/socfpga/fpga_manager.c new file +7 -0
+/* Get the FPGA mode */
+static int fpgamgr_get_mode(void)
+{
+	unsigned long val;
+	val = readl(&fpgamgr_regs->stat);
+	return val & FPGAMGRREGS_STAT_MODE_MASK;
+}

Please always separate declarations and code by a blank line (please fix globally).

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I can't understand why  people  are  frightened  of  new  ideas.  I'm
frightened of the old ones.                               - John Cage
#59 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

Quoted 12 lines · Wolfgang Denk

Dear Marek Vasut,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

...

Quoted 10 lines

arch/arm/cpu/armv7/socfpga/fpga_manager.c line 39

Quoted 7 lines
arch/arm/cpu/armv7/socfpga/fpga_manager.c new file +7 -0
+/* Get the FPGA mode */
+static int fpgamgr_get_mode(void)
+{
+	unsigned long val;
+	val = readl(&fpgamgr_regs->stat);
+	return val & FPGAMGRREGS_STAT_MODE_MASK;
+}

Please always separate declarations and code by a blank line (please fix globally).

Done, thank you!

Best regards,
Marek Vasut

#60 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

In reply to Marek Vasut
Quoted 15 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Quoted 3 lines
---
 arch/arm/cpu/armv7/socfpga/Makefile              |   3 +-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c        | 354 +++++++++++++++++++++++

We have drivers/fpga and you should move this driver there to be visible for others. Maybe also nios can use this driver with some changes.

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: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/6c2be8ce/attachment.pgp>
#61 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

Quoted 18 lines · Michal Simek
Quoted 17 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>

---

Quoted 6 lines
Quoted 3 lines
 arch/arm/cpu/armv7/socfpga/Makefile              |   3 +-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c        | 354

+++++++++++++++++++++++

We have drivers/fpga and you should move this driver there to be visible for others. Maybe also nios can use this driver with some changes.

Good point about the move, but how could NIOS possibly use this ?

Best regards,
Marek Vasut

#62 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

Quoted 19 lines · Marek Vasut
Quoted 18 lines · Michal Simek
Quoted 17 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>

---

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
 arch/arm/cpu/armv7/socfpga/Makefile              |   3 +-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c        | 354

+++++++++++++++++++++++

We have drivers/fpga and you should move this driver there to be visible for others. Maybe also nios can use this driver with some changes.

Good point about the move, but how could NIOS possibly use this ?

I don't know the architecture but I expect that this fpga_manager can also work with partial bitstream.
It means the flow is.
1. load full bitstream with NIOS
2. NIOS become security manager and own this driver
3. NIOS is able to load partial bitstreams via this device.

Not sure if this realistic flow on socfpga but this is possible to do on our fpga.
That's why IMHO this driver should be in drivers/fpga.

Also look at my xilinx fpga changes I have done recently and you should change that altera code to look the same and remove that ugly ifdef mess.

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: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/2744d308/attachment.pgp>
#63 lore raw

PATCH 25/35 arm: socfpga: fpga: Add SoCFPGA FPGA programming interface

Quoted 36 lines · Michal Simek
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Michal Simek
Quoted 17 lines · Marek Vasut

From: Pavel Machek <[email protected]>

Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>

---

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
 arch/arm/cpu/armv7/socfpga/Makefile              |   3 +-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c        | 354

+++++++++++++++++++++++

We have drivers/fpga and you should move this driver there to be visible for others. Maybe also nios can use this driver with some changes.

Good point about the move, but how could NIOS possibly use this ?

I don't know the architecture but I expect that this fpga_manager can also work with partial bitstream.
It means the flow is.
1. load full bitstream with NIOS
2. NIOS become security manager and own this driver
3. NIOS is able to load partial bitstreams via this device.

Quoted 7 lines

Not sure if this realistic flow on socfpga but this is possible to do on our fpga.
That's why IMHO this driver should be in drivers/fpga.

Also look at my xilinx fpga changes I have done recently and you should change that altera code to look the same and remove that ugly ifdef mess.

I did clean that up to a certain degree. It was truly hideous. Who's picking up the patches for drivers/fpga/ nowadays ?

Best regards,
Marek Vasut

#64 lore raw

PATCH 26/35 arm: socfpga: reset: Add function to reset FPGA bridges

In reply to Marek Vasut

Add function to enable and disable FPGA bridges. This code is used by the FPGA manager to disable the bridges before programming the FPGA and will later be also used by the initialization code for the chip to put the chip into well defined state during startup.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/reset_manager.c        | 38 +++++++++++++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h |  2 ++
 2 files changed, 40 insertions(+)
arch/arm/cpu/armv7/socfpga/reset_manager.c +38 -0
index 77579b7..85579c0 100644
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/reset_manager.h>
+#include <asm/arch/fpga_manager.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -53,6 +54,43 @@ void reset_deassert_peripherals_handoff(void)
 	writel(0, &reset_manager_base->per_mod_reset);
 }
 
+#if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
+void socfpga_bridges_reset(int enable)
+{
+	/* For SoCFPGA-VT, this is NOP. */
+}
+#else
+
+#define L3REGS_REMAP_LWHPS2FPGA_MASK	0x10
+#define L3REGS_REMAP_HPS2FPGA_MASK	0x08
+#define L3REGS_REMAP_OCRAM_MASK		0x01
+
+void socfpga_bridges_reset(int enable)
+{
+	const uint32_t l3mask = L3REGS_REMAP_LWHPS2FPGA_MASK |
+				L3REGS_REMAP_HPS2FPGA_MASK |
+				L3REGS_REMAP_OCRAM_MASK;
+
+	if (enable) {
+		/* brdmodrst */
+		writel(0xffffffff, &reset_manager_base->brg_mod_reset);
+	} else {
+		/* Check signal from FPGA. */
+		if (fpgamgr_poll_fpga_ready()) {
+			/* FPGA not ready. Wait for watchdog timeout. */
+			printf("%s: fpga not ready, hanging.\n", __func__);
+			hang();
+		}
+
+		/* brdmodrst */
+		writel(0, &reset_manager_base->brg_mod_reset);
+
+		/* Remap the bridges into memory map */
+		writel(l3mask, SOCFPGA_L3REGS_ADDRESS);
+	}
+}
+#endif
+
 /* Change the reset state for EMAC 0 and EMAC 1 */
 void socfpga_emac_reset(int enable)
 {
arch/arm/include/asm/arch-socfpga/reset_manager.h +2 -0
index 9d22576..4cbce96 100644
@@ -10,6 +10,8 @@
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
+void socfpga_bridges_reset(int enable);
+
 void socfpga_emac_reset(int enable);
 
 void watchdog_disable(void);
Signature · 1 line
2.1.0
#65 lore raw

PATCH 26/35 arm: socfpga: reset: Add function to reset FPGA bridges

Quoted 11 lines · Marek Vasut

Add function to enable and disable FPGA bridges. This code is used by the FPGA manager to disable the bridges before programming the FPGA and will later be also used by the initialization code for the chip to put the chip into well defined state during startup.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#66 lore raw

PATCH 27/35 arm: socfpga: sysmgr: Add FPGA bits into system manager

In reply to Marek Vasut

Add missing system manager bits from Altera U-Boot to make the code comparable. These are the bits which depend on the FPGA manager.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/system_manager.c | 39 +++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
arch/arm/cpu/armv7/socfpga/system_manager.c +39 -0
index 07c72e4..11f7bad 100644
@@ -15,6 +15,43 @@ static struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
 
 /*
+ * Populate the value for SYSMGR.FPGAINTF.MODULE based on pinmux setting.
+ * The value is not wrote to SYSMGR.FPGAINTF.MODULE but
+ * CONFIG_SYSMGR_ISWGRP_HANDOFF.
+ */
+static void populate_sysmgr_fpgaintf_module(void)
+{
+	uint32_t handoff_val = 0;
+
+	/* ISWGRP_HANDOFF_FPGAINTF */
+	writel(0, &sysmgr_regs->iswgrp_handoff[2]);
+
+	/* Enable the signal for those HPS peripherals that use FPGA. */
+	if (readl(&sysmgr_regs->nandusefpga) == SYSMGR_FPGAINTF_USEFPGA)
+		handoff_val |= SYSMGR_FPGAINTF_NAND;
+	if (readl(&sysmgr_regs->rgmii1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+		handoff_val |= SYSMGR_FPGAINTF_EMAC1;
+	if (readl(&sysmgr_regs->sdmmcusefpga) == SYSMGR_FPGAINTF_USEFPGA)
+		handoff_val |= SYSMGR_FPGAINTF_SDMMC;
+	if (readl(&sysmgr_regs->rgmii0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+		handoff_val |= SYSMGR_FPGAINTF_EMAC0;
+	if (readl(&sysmgr_regs->spim0usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+		handoff_val |= SYSMGR_FPGAINTF_SPIM0;
+	if (readl(&sysmgr_regs->spim1usefpga) == SYSMGR_FPGAINTF_USEFPGA)
+		handoff_val |= SYSMGR_FPGAINTF_SPIM1;
+
+	/* populate (not writing) the value for SYSMGR.FPGAINTF.MODULE
+	based on pinmux setting */
+	setbits_le32(&sysmgr_regs->iswgrp_handoff[2], handoff_val);
+
+	handoff_val = readl(&sysmgr_regs->iswgrp_handoff[2]);
+	if (fpgamgr_test_fpga_ready()) {
+		/* Enable the required signals only */
+		writel(handoff_val, &sysmgr_regs->fpgaintfgrp_module);
+	}
+}
+
+/*
  * Configure all the pin muxes
  */
 void sysmgr_pinmux_init(void)
@@ -26,4 +63,6 @@ void sysmgr_pinmux_init(void)
 		writel(sys_mgr_init_table[i], regs);
 		regs += sizeof(regs);
 	}
+
+	populate_sysmgr_fpgaintf_module();
 }
Signature · 1 line
2.1.0
#67 lore raw

PATCH 28/35 arm: cache: Add support for write-allocate D-Cache

In reply to Marek Vasut

Add configuration for the write-allocate mode of L1 D-Cache on ARM. This is needed for D-Cache operation on Cortex-A9 on the SoCFPGA .

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/include/asm/system.h | 1 +
 arch/arm/lib/cache-cp15.c     | 2 ++
 2 files changed, 3 insertions(+)
arch/arm/include/asm/system.h +1 -0
index d51ba66..ca2d44f 100644
@@ -185,6 +185,7 @@ enum dcache_option {
 	DCACHE_OFF = 0x12,
 	DCACHE_WRITETHROUGH = 0x1a,
 	DCACHE_WRITEBACK = 0x1e,
+	DCACHE_WRITEALLOC = 0x16,
 };
 
 /* Size of an MMU section */
arch/arm/lib/cache-cp15.c +2 -0
index 3e62d58..2155fe8 100644
@@ -73,6 +73,8 @@ __weak void dram_bank_mmu_setup(int bank)
 	     i++) {
 #if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
 		set_section_dcache(i, DCACHE_WRITETHROUGH);
+#elif defined(CONFIG_SYS_ARM_CACHE_WRITEALLOC)
+		set_section_dcache(i, DCACHE_WRITEALLOC);
 #else
 		set_section_dcache(i, DCACHE_WRITEBACK);
 #endif
Signature · 1 line
2.1.0
#68 lore raw

PATCH 28/35 arm: cache: Add support for write-allocate D-Cache

Quoted 9 lines · Marek Vasut

Add configuration for the write-allocate mode of L1 D-Cache on ARM. This is needed for D-Cache operation on Cortex-A9 on the SoCFPGA .

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#69 lore raw

PATCH 29/35 arm: socfpga: cache: Define cacheline size

In reply to Marek Vasut

The Cortex-A9 has 32-byte long L1 cachelines. Define this value.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 include/configs/socfpga_cyclone5.h | 2 ++
 1 file changed, 2 insertions(+)
include/configs/socfpga_cyclone5.h +2 -0
index f50081b..f0eac4d 100644
@@ -26,6 +26,8 @@
 #define CONFIG_SOCFPGA
 #define CONFIG_CLOCKS
 
+#define CONFIG_SYS_CACHELINE_SIZE	32
+
 /* base address for .text section */
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_TEXT_BASE		0x08000040
Signature · 1 line
2.1.0
#70 lore raw

PATCH 29/35 arm: socfpga: cache: Define cacheline size

Quoted 8 lines · Marek Vasut

The Cortex-A9 has 32-byte long L1 cachelines. Define this value.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#71 lore raw

PATCH 30/35 arm: socfpga: cache: Enable D-Cache

In reply to Marek Vasut

The code is now fixed to the point where we can safely enable the L1 data cache. Enable the D-Cache and set it as write-alloc.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 board/altera/socfpga/socfpga_cyclone5.c | 1 +
 include/configs/socfpga_cyclone5.h      | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
board/altera/socfpga/socfpga_cyclone5.c +1 -0
index 4149842..6b98277 100644
@@ -35,6 +35,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	icache_enable();
+	dcache_enable();
 
 	/* Address of boot parameters for ATAG (if ATAG is used) */
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
include/configs/socfpga_cyclone5.h +1 -1
index f0eac4d..20da1ac 100644
@@ -18,7 +18,6 @@
 #undef CONFIG_SOCFPGA_VIRTUAL_TARGET
 
 #define CONFIG_ARMV7
-#define CONFIG_SYS_DCACHE_OFF
 #undef CONFIG_USE_IRQ
 
 #define CONFIG_MISC_INIT_R
@@ -26,6 +25,7 @@
 #define CONFIG_SOCFPGA
 #define CONFIG_CLOCKS
 
+#define CONFIG_SYS_ARM_CACHE_WRITEALLOC
 #define CONFIG_SYS_CACHELINE_SIZE	32
 
 /* base address for .text section */
Signature · 1 line
2.1.0
#72 lore raw

PATCH 30/35 arm: socfpga: cache: Enable D-Cache

Quoted 9 lines · Marek Vasut

The code is now fixed to the point where we can safely enable the L1 data cache. Enable the D-Cache and set it as write-alloc.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#73 lore raw

PATCH 31/35 arm: socfpga: cache: Enable PL310 L2 cache

In reply to Marek Vasut

Enable the PL310 L2 cache controller support for the SoCFPGA. With the cache related issues resolved, this is safe to be done.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 include/configs/socfpga_cyclone5.h | 2 ++
 1 file changed, 2 insertions(+)
include/configs/socfpga_cyclone5.h +2 -0
index 20da1ac..32175b7 100644
@@ -27,6 +27,8 @@
 
 #define CONFIG_SYS_ARM_CACHE_WRITEALLOC
 #define CONFIG_SYS_CACHELINE_SIZE	32
+#define CONFIG_SYS_L2_PL310
+#define CONFIG_SYS_PL310_BASE		SOCFPGA_MPUL2_ADDRESS
 
 /* base address for .text section */
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
Signature · 1 line
2.1.0
#74 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#75 lore raw

PATCH 32/35 arm: socfpga: scu: Add SCU register file

In reply to Marek Vasut

Add the Snoop Control Unit register definition file.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/include/asm/arch-socfpga/scu.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-socfpga/scu.h
arch/arm/include/asm/arch-socfpga/scu.h new file +23 -0
new file mode 100644
index 0000000..7a5b074
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2014 Marek Vasut <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __SOCFPGA_SCU_H__
+#define __SOCFPGA_SCU_H__
+
+struct scu_registers {
+	u32	ctrl;			/* 0x00 */
+	u32	cfg;
+	u32	cpsr;
+	u32	iassr;
+	u32	_pad_0x10_0x3c[12];	/* 0x10 */
+	u32	fsar;			/* 0x40 */
+	u32	fear;
+	u32	_pad_0x48_0x50[2];
+	u32	acr;			/* 0x54 */
+	u32	sacr;
+};
+
+#endif	/* __SOCFPGA_SCU_H__ */
Signature · 1 line
2.1.0
#76 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#77 lore raw

PATCH 33/35 arm: socfpga: nic301: Add NIC-301 GPV register file

In reply to Marek Vasut

Add register definition for the NIC-301 used on SoCFPGA.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/include/asm/arch-socfpga/nic301.h | 195 +++++++++++++++++++++++++++++
 1 file changed, 195 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-socfpga/nic301.h
arch/arm/include/asm/arch-socfpga/nic301.h new file +195 -0
new file mode 100644
index 0000000..3c8ab31
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2014 Marek Vasut <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef	_NIC301_REGISTERS_H_
+#define	_NIC301_REGISTERS_H_
+
+struct nic301_registers {
+	u32	remap;				/* 0x0 */
+	/* Security Register Group */
+	u32	_pad_0x4_0x8[1];
+	u32	l4main;
+	u32	l4sp;
+	u32	l4mp;				/* 0x10 */
+	u32	l4osc1;
+	u32	l4spim;
+	u32	stm;
+	u32	lwhps2fpgaregs;			/* 0x20 */
+	u32	_pad_0x24_0x28[1];
+	u32	usb1;
+	u32	nanddata;
+	u32	_pad_0x30_0x80[20];
+	u32	usb0;				/* 0x80 */
+	u32	nandregs;
+	u32	qspidata;
+	u32	fpgamgrdata;
+	u32	hps2fpgaregs;			/* 0x90 */
+	u32	acp;
+	u32	rom;
+	u32	ocram;
+	u32	sdrdata;			/* 0xA0 */
+	u32	_pad_0xa4_0x1fd0[1995];
+	/* ID Register Group */
+	u32	periph_id_4;			/* 0x1FD0 */
+	u32	_pad_0x1fd4_0x1fe0[3];
+	u32	periph_id_0;			/* 0x1FE0 */
+	u32	periph_id_1;
+	u32	periph_id_2;
+	u32	periph_id_3;
+	u32	comp_id_0;			/* 0x1FF0 */
+	u32	comp_id_1;
+	u32	comp_id_2;
+	u32	comp_id_3;
+	u32	_pad_0x2000_0x2008[2];
+	/* L4 MAIN */
+	u32	l4main_fn_mod_bm_iss;
+	u32	_pad_0x200c_0x3008[1023];
+	/* L4 SP */
+	u32	l4sp_fn_mod_bm_iss;
+	u32	_pad_0x300c_0x4008[1023];
+	/* L4 MP */
+	u32	l4mp_fn_mod_bm_iss;
+	u32	_pad_0x400c_0x5008[1023];
+	/* L4 OSC1 */
+	u32	l4osc_fn_mod_bm_iss;
+	u32	_pad_0x500c_0x6008[1023];
+	/* L4 SPIM */
+	u32	l4spim_fn_mod_bm_iss;
+	u32	_pad_0x600c_0x7008[1023];
+	/* STM */
+	u32	stm_fn_mod_bm_iss;
+	u32	_pad_0x700c_0x7108[63];
+	u32	stm_fn_mod;
+	u32	_pad_0x710c_0x8008[959];
+	/* LWHPS2FPGA */
+	u32	lwhps2fpga_fn_mod_bm_iss;
+	u32	_pad_0x800c_0x8108[63];
+	u32	lwhps2fpga_fn_mod;
+	u32	_pad_0x810c_0xa008[1983];
+	/* USB1 */
+	u32	usb1_fn_mod_bm_iss;
+	u32	_pad_0xa00c_0xa044[14];
+	u32	usb1_ahb_cntl;
+	u32	_pad_0xa048_0xb008[1008];
+	/* NANDDATA */
+	u32	nanddata_fn_mod_bm_iss;
+	u32	_pad_0xb00c_0xb108[63];
+	u32	nanddata_fn_mod;
+	u32	_pad_0xb10c_0x20008[21439];
+	/* USB0 */
+	u32	usb0_fn_mod_bm_iss;
+	u32	_pad_0x2000c_0x20044[14];
+	u32	usb0_ahb_cntl;
+	u32	_pad_0x20048_0x21008[1008];
+	/* NANDREGS */
+	u32	nandregs_fn_mod_bm_iss;
+	u32	_pad_0x2100c_0x21108[63];
+	u32	nandregs_fn_mod;
+	u32	_pad_0x2110c_0x22008[959];
+	/* QSPIDATA */
+	u32	qspidata_fn_mod_bm_iss;
+	u32	_pad_0x2200c_0x22044[14];
+	u32	qspidata_ahb_cntl;
+	u32	_pad_0x22048_0x23008[1008];
+	/* FPGAMGRDATA */
+	u32	fpgamgrdata_fn_mod_bm_iss;
+	u32	_pad_0x2300c_0x23040[13];
+	u32	fpgamgrdata_wr_tidemark;	/* 0x23040 */
+	u32	_pad_0x23044_0x23108[49];
+	u32	fn_mod;
+	u32	_pad_0x2310c_0x24008[959];
+	/* HPS2FPGA */
+	u32	hps2fpga_fn_mod_bm_iss;
+	u32	_pad_0x2400c_0x24040[13];
+	u32	hps2fpga_wr_tidemark;		/* 0x24040 */
+	u32	_pad_0x24044_0x24108[49];
+	u32	hps2fpga_fn_mod;
+	u32	_pad_0x2410c_0x25008[959];
+	/* ACP */
+	u32	acp_fn_mod_bm_iss;
+	u32	_pad_0x2500c_0x25108[63];
+	u32	acp_fn_mod;
+	u32	_pad_0x2510c_0x26008[959];
+	/* Boot ROM */
+	u32	bootrom_fn_mod_bm_iss;
+	u32	_pad_0x2600c_0x26108[63];
+	u32	bootrom_fn_mod;
+	u32	_pad_0x2610c_0x27008[959];
+	/* On-chip RAM */
+	u32	ocram_fn_mod_bm_iss;
+	u32	_pad_0x2700c_0x27040[13];
+	u32	ocram_wr_tidemark;		/* 0x27040 */
+	u32	_pad_0x27044_0x27108[49];
+	u32	ocram_fn_mod;
+	u32	_pad_0x2710c_0x42024[27590];
+	/* DAP */
+	u32	dap_fn_mod2;
+	u32	dap_fn_mod_ahb;
+	u32	_pad_0x4202c_0x42100[53];
+	u32	dap_read_qos;			/* 0x42100 */
+	u32	dap_write_qos;
+	u32	dap_fn_mod;
+	u32	_pad_0x4210c_0x43100[1021];
+	/* MPU */
+	u32	mpu_read_qos;			/* 0x43100 */
+	u32	mpu_write_qos;
+	u32	mpu_fn_mod;
+	u32	_pad_0x4310c_0x44028[967];
+	/* SDMMC */
+	u32	sdmmc_fn_mod_ahb;
+	u32	_pad_0x4402c_0x44100[53];
+	u32	sdmmc_read_qos;			/* 0x44100 */
+	u32	sdmmc_write_qos;
+	u32	sdmmc_fn_mod;
+	u32	_pad_0x4410c_0x45100[1021];
+	/* DMA */
+	u32	dma_read_qos;			/* 0x45100 */
+	u32	dma_write_qos;
+	u32	dma_fn_mod;
+	u32	_pad_0x4510c_0x46040[973];
+	/* FPGA2HPS */
+	u32	fpga2hps_wr_tidemark;		/* 0x46040 */
+	u32	_pad_0x46044_0x46100[47];
+	u32	fpga2hps_read_qos;		/* 0x46100 */
+	u32	fpga2hps_write_qos;
+	u32	fpga2hps_fn_mod;
+	u32	_pad_0x4610c_0x47100[1021];
+	/* ETR */
+	u32	etr_read_qos;			/* 0x47100 */
+	u32	etr_write_qos;
+	u32	etr_fn_mod;
+	u32	_pad_0x4710c_0x48100[1021];
+	/* EMAC0 */
+	u32	emac0_read_qos;			/* 0x48100 */
+	u32	emac0_write_qos;
+	u32	emac0_fn_mod;
+	u32	_pad_0x4810c_0x49100[1021];
+	/* EMAC1 */
+	u32	emac1_read_qos;			/* 0x49100 */
+	u32	emac1_write_qos;
+	u32	emac1_fn_mod;
+	u32	_pad_0x4910c_0x4a028[967];
+	/* USB0 */
+	u32	usb0_fn_mod_ahb;
+	u32	_pad_0x4a02c_0x4a100[53];
+	u32	usb0_read_qos;			/* 0x4A100 */
+	u32	usb0_write_qos;
+	u32	usb0_fn_mod;
+	u32	_pad_0x4a10c_0x4b100[1021];
+	/* NAND */
+	u32	nand_read_qos;			/* 0x4B100 */
+	u32	nand_write_qos;
+	u32	nand_fn_mod;
+	u32	_pad_0x4b10c_0x4c028[967];
+	/* USB1 */
+	u32	usb1_fn_mod_ahb;
+	u32	_pad_0x4c02c_0x4c100[53];
+	u32	usb1_read_qos;			/* 0x4C100 */
+	u32	usb1_write_qos;
+	u32	usb1_fn_mod;
+};
+
+#endif	/* _NIC301_REGISTERS_H_ */
Signature · 1 line
2.1.0
#78 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#79 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 5 lines · Pavel Machek
Quoted 4 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Quoted 8 lines
Quoted 6 lines
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>

Um, how many copies of this email did you send ? ;-)

Best regards,
Marek Vasut

#80 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 13 lines · Marek Vasut
Quoted 12 lines · Pavel Machek
Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Quoted 3 lines
Quoted 1 line

Um, how many copies of this email did you send ? ;-)

I got 8...do those count towards Pavel's creditability in the community? ;)

Dinh

#81 lore raw

PATCH 4/35 net: dwc: Make the cache handling less cryptic

Quoted 14 lines · Dinh Nguyen
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Pavel Machek
Quoted 10 lines · Marek Vasut

Add a few new variables to make the cache handling less cryptic. Add a variable for DMA and DATA descriptor start and end, so the correctness of the code is easier to inspect.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Um, how many copies of this email did you send ? ;-)

I got 8...do those count towards Pavel's creditability in the community? ;)

Well, he managed to master the art of sending email all right. Now's the time to master the art of self-restraint ;-)

Best regards,
Marek Vasut

#82 lore raw

PATCH 34/35 arm: socfpga: pl310: Map SDRAM to 0x0

In reply to Marek Vasut

Configure the PL310 address filter to make sure DRAM is mapped to 0x0. This code also configures the "remap" register of NIC-301 and sets the required 'mpuzero' bit.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/cpu/armv7/socfpga/misc.c +14 -0
index 8e25f09..4ff8bd8 100644
@@ -12,11 +12,17 @@
 #include <asm/arch/reset_manager.h>
 #include <asm/arch/system_manager.h>
 #include <asm/arch/dwmmc.h>
+#include <asm/arch/nic301.h>
+#include <asm/pl310.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static struct pl310_regs *const pl310 =
+	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
 static struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+static struct nic301_registers *nic301_regs =
+	(struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
 
 int dram_init(void)
 {
@@ -129,6 +135,14 @@ static inline void socfpga_fpga_add(void) {}
 
 int misc_init_r(void)
 {
+	/* Configure the L2 controller to make SDRAM start at 0 */
+#ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
+	writel(0x2, &nic301_regs->remap);
+#else
+	writel(0x1, &nic301_regs->remap);	/* remap.mpuzero */
+	writel(0x1, &pl310->pl310_addr_filter_start);
+#endif
+
 	/* Add device descriptor to FPGA device table */
 	socfpga_fpga_add();
 
Signature · 1 line
2.1.0
#83 lore raw

PATCH 35/35 arm: socfpga: nic301: Add NIC-301 configuration code

In reply to Marek Vasut

From: Pavel Machek <[email protected]>

Add code which configures the AMBA NIC-301 and the SCU on the SoCFPGA . The code sets the access permissions for the CPU to the AMBA slaves such that the CPU can access them in both secure and non-secure mode.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
---
 arch/arm/cpu/armv7/socfpga/misc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
arch/arm/cpu/armv7/socfpga/misc.c +26 -0
index 4ff8bd8..417db7c 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/system_manager.h>
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/nic301.h>
+#include <asm/arch/scu.h>
 #include <asm/pl310.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -23,6 +24,8 @@ static struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
 static struct nic301_registers *nic301_regs =
 	(struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
+static struct scu_registers *scu_regs =
+	(struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
 
 int dram_init(void)
 {
@@ -133,8 +136,31 @@ static void socfpga_fpga_add(void)
 static inline void socfpga_fpga_add(void) {}
 #endif
 
+/*
+ * Convert all NIC-301 AMBA slaves from secure to non-secure
+ */
+static void socfpga_nic301_slave_ns(void)
+{
+	writel(0x1, &nic301_regs->lwhps2fpgaregs);
+	writel(0x1, &nic301_regs->hps2fpgaregs);
+	writel(0x1, &nic301_regs->acp);
+	writel(0x1, &nic301_regs->rom);
+	writel(0x1, &nic301_regs->ocram);
+	writel(0x1, &nic301_regs->sdrdata);
+}
+
 int misc_init_r(void)
 {
+	socfpga_bridges_reset(1);
+	socfpga_nic301_slave_ns();
+
+	/*
+	 * Private components security:
+	 * U-Boot : configure private timer, global timer and cpu component
+	 * access as non secure for kernel stage (as required by Linux)
+	 */
+	setbits_le32(&scu_regs->sacr, 0xfff);
+
 	/* Configure the L2 controller to make SDRAM start at 0 */
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 	writel(0x2, &nic301_regs->remap);
Signature · 1 line
2.1.0
#84 lore raw

cover arm: socfpga: Usability fixes

In reply to Marek Vasut

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

So

Thanks and best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#85 lore raw

cover arm: socfpga: Usability fixes

Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines

So

Thanks and best regards,
Pavel

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:

This was tested a Cyclone5 devkit.

Dinh

#86 lore raw

cover arm: socfpga: Usability fixes

Quoted 46 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines

So

Thanks and best regards,

Pavel

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

Quoted 6 lines

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes. (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have 128MiB)

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

btw you don't happen to have a spare CV and AV kits you could send me, so I can do the testing rounds on them too, do you ?

Best regards,
Marek Vasut

#87 lore raw

cover arm: socfpga: Usability fixes

Quoted 47 lines · Marek Vasut
Quoted 46 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines

So

Thanks and best regards,

Pavel

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

Quoted 8 lines
Quoted 6 lines

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In

The devkit has 1GB.

Quoted 9 lines

any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes. (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have 128MiB)

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

Yes, tracked it down to get_ram_size(). I forced gd->ram_size to 1GB and it works fine for me now. I'll try to spend some cycles to debug the problem.

Quoted 3 lines

btw you don't happen to have a spare CV and AV kits you could send me, so I can do the testing rounds on them too, do you ?

I'll look around.

Dinh

#88 lore raw

cover arm: socfpga: Usability fixes

Quoted 21 lines · dinguyen
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

So

Thanks and best regards,

Pavel

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled

DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Watchdog enabled

DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In

The devkit has 1GB.

Ah, thanks for this info!

Quoted 9 lines
Quoted 9 lines

any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes.

   (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have
   128MiB)
Quoted 6 lines
Quoted 2 lines

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

Yes, tracked it down to get_ram_size(). I forced gd->ram_size to 1GB and it works fine for me now. I'll try to spend some cycles to debug the problem.

Hmmmmm, how much DRAM can the SoCFPGA chip drive in total ?

Well, consider a theoretical SoCFPGA board with 128MiB of DRAM attached to it, what happens if I try to write at address of the 129th MiB (which is past the DRAM) ? Will this generate an DABT for the ARM core or will some kind of DRAM "mirroring" or "wraparound" happen such that I would write to the content of 1st MiB of the DRAM ?

If I would get DABT, then there is a rather easy fix for that, see arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c and mxs_mem_get_size() function. The function places an assembly return instruction into the DABT handler entry position (offset 0x14 in ARM vector table IIRC) and then runs the get_dram_size() . The assembly instruction only returns from the DABT handler right past the code where the DABT happened. For the get_ram_size(), the read from the unpopulated DRAM space contains zeroes and the function doesn't even realize the DABT happened. But it considers the DRAM invalid and thus this works correctly. That's how it detects the amount of DRAM.

You might want to consider something similar if that's how it behaves on SoCFPGA.

Quoted 4 lines
Quoted 2 lines

btw you don't happen to have a spare CV and AV kits you could send me, so I can do the testing rounds on them too, do you ?

I'll look around.

Thanks!

#89 lore raw

cover arm: socfpga: Usability fixes

Quoted 76 lines · Marek Vasut
Quoted 21 lines · dinguyen
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

So

Thanks and best regards,

Pavel

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled

DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Watchdog enabled

DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In

The devkit has 1GB.

Ah, thanks for this info!

Quoted 9 lines
Quoted 9 lines

any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes.

   (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have
   128MiB)
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

Yes, tracked it down to get_ram_size(). I forced gd->ram_size to 1GB and it works fine for me now. I'll try to spend some cycles to debug the problem.

Hmmmmm, how much DRAM can the SoCFPGA chip drive in total ?

All of our devkits have at least 1 GiB and I have heard there is a variant with 2GiB in the wild. Spec says up to 4 GiB.

Quoted 6 lines

Well, consider a theoretical SoCFPGA board with 128MiB of DRAM attached to it, what happens if I try to write at address of the 129th MiB (which is past the DRAM) ? Will this generate an DABT for the ARM core or will some kind of DRAM "mirroring" or "wraparound" happen such that I would write to the content of 1st MiB of the DRAM ?

We've encountered this issue downstream on a system with 1 GiB.

Quoted 11 lines

If I would get DABT, then there is a rather easy fix for that, see arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c and mxs_mem_get_size() function. The function places an assembly return instruction into the DABT handler entry position (offset 0x14 in ARM vector table IIRC) and then runs the get_dram_size() . The assembly instruction only returns from the DABT handler right past the code where the DABT happened. For the get_ram_size(), the read from the unpopulated DRAM space contains zeroes and the function doesn't even realize the DABT happened. But it considers the DRAM invalid and thus this works correctly. That's how it detects the amount of DRAM.

Quoted 2 lines

You might want to consider something similar if that's how it behaves on SoCFPGA.

This could be the issue. I think Chin Liang would know about this more than me at this point. So I hope he can solve this quickly.

Seems odd that the get_ram_size is working on your DENX board and not the devkit.

Dinh

#90 lore raw

cover arm: socfpga: Usability fixes

On Wednesday, September 17, 2014 at 12:29:54 AM, Dinh Nguyen wrote:

[...]

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Yes, tracked it down to get_ram_size(). I forced gd->ram_size to 1GB and it works fine for me now. I'll try to spend some cycles to debug the problem.

Hmmmmm, how much DRAM can the SoCFPGA chip drive in total ?

All of our devkits have at least 1 GiB and I have heard there is a variant with 2GiB in the wild. Spec says up to 4 GiB.

OK, I see. You cannot realistically map all those 4GiB into the 32-bit address space of an CortexA9, but on the other hand, all those bugs related to an CA9 with 4GiB of DRAM should be fixed due to my work on Novena ;-)

Quoted 7 lines
Quoted 5 lines

Well, consider a theoretical SoCFPGA board with 128MiB of DRAM attached to it, what happens if I try to write at address of the 129th MiB (which is past the DRAM) ? Will this generate an DABT for the ARM core or will some kind of DRAM "mirroring" or "wraparound" happen such that I would write to the content of 1st MiB of the DRAM ?

We've encountered this issue downstream on a system with 1 GiB.

OK, so a wraparound happens ?

Quoted 11 lines
Quoted 11 lines

If I would get DABT, then there is a rather easy fix for that, see arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c and mxs_mem_get_size() function. The function places an assembly return instruction into the DABT handler entry position (offset 0x14 in ARM vector table IIRC) and then runs the get_dram_size() . The assembly instruction only returns from the DABT handler right past the code where the DABT happened. For the get_ram_size(), the read from the unpopulated DRAM space contains zeroes and the function doesn't even realize the DABT happened. But it considers the DRAM invalid and thus this works correctly. That's how it detects the amount of DRAM.

Quoted 5 lines
Quoted 2 lines

You might want to consider something similar if that's how it behaves on SoCFPGA.

This could be the issue. I think Chin Liang would know about this more than me at this point. So I hope he can solve this quickly.

Sure, patch is welcome!

Quoted 2 lines

Seems odd that the get_ram_size is working on your DENX board and not the devkit.

I _think_ I might have hacked this part up and it's still in the cleanup pipeline.

Best regards,
Marek Vasut

#91 lore raw

cover arm: socfpga: Usability fixes

Quoted 8 lines · marex at denx.de

On Wednesday, September 17, 2014 at 12:29:54 AM, Dinh Nguyen wrote:

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Yes, tracked it down to get_ram_size(). I forced gd->ram_size to 1GB and it works fine for me now. I'll try to spend some cycles to debug the problem.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Hmmmmm, how much DRAM can the SoCFPGA chip drive in total ?

All of our devkits have at least 1 GiB and I have heard there is a variant with 2GiB in the wild. Spec says up to 4 GiB.

OK, I see. You cannot realistically map all those 4GiB into the 32-bit address space of an CortexA9, but on the other hand, all those bugs related to an CA9 with 4GiB of DRAM should be fixed due to my work on Novena ;-)

Yup, 4GB would not be possible. Within SocFPGA, by using HPS-FPGA bridges, we can workaround by swapping memory chunk so ARM processor can access entire 4GB. Interested to find out how you did it for Novena :)

Quoted 11 lines
Quoted 8 lines
Quoted 6 lines

Well, consider a theoretical SoCFPGA board with 128MiB of DRAM attached to it, what happens if I try to write at address of the 129th MiB (which is past the DRAM) ? Will this generate an DABT for the ARM core or will some kind of DRAM "mirroring" or "wraparound" happen such that I would write to the content of 1st MiB of the DRAM ?

We've encountered this issue downstream on a system with 1 GiB.

OK, so a wraparound happens ?

It should be a wrap around. It is not working previously as incorrect configuration for one of SDRAM parameters. The fix is under internal review now. :)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

If I would get DABT, then there is a rather easy fix for that, see arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c and mxs_mem_get_size() function. The function places an assembly return instruction into the DABT handler entry position (offset 0x14 in ARM vector table IIRC) and then runs the get_dram_size() . The assembly instruction only returns from the DABT handler right past the code where the DABT happened. For the get_ram_size(), the read from the unpopulated DRAM space contains zeroes and the function doesn't even realize the DABT happened. But it considers the DRAM invalid and thus this works correctly. That's how it detects the amount of DRAM.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

You might want to consider something similar if that's how it behaves on SoCFPGA.

This could be the issue. I think Chin Liang would know about this more than me at this point. So I hope he can solve this quickly.

Sure, patch is welcome!

Hmmm... actually I can get it works well for my Altera dev kit. The get_dram_size would take in the argument PHYS_SDRAM_1_SIZE. From here, the function will ensure the memory specified can read and writable. If its failing here, probably the SDRAM access might have issue. FYI, PHYS_SDRAM_1_SIZE is 0x40000000 for 1GB.

Quoted 6 lines
Quoted 2 lines

Seems odd that the get_ram_size is working on your DENX board and not the devkit.

I _think_ I might have hacked this part up and it's still in the cleanup pipeline.

It works for me without hacks. I can read and write to the SDRAM memory well (include 1MB region).

U-Boot 2014.10-rc2-00123-g461be2f-dirty (Sep 17 2014 - 04:28:52)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board
DRAM:  1 GiB
WARNING: Caches not enabled

Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set.

Warning: Your board does not use generic board. Please read doc/README.generic-board and take action. Boards not upgraded by the late 2014 may break or be removed. Hit any key to stop autoboot: 0
Wrong Image Format for bootm command
ERROR: can't get kernel image!
SOCFPGA_CYCLONE5 # md 0

00000000: 00000000 aaaaaaaa aaaaaaaa aaaaaaaa    ................
00000010: aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa    ................
00000020: 55555555 55555555 55555555 55555555    UUUUUUUUUUUUUUUU
00000030: 55555555 55555555 55555555 55555555    UUUUUUUUUUUUUUUU
00000040: 7f7b958a a30289de 6bfe35cb 2d3f494f    ..{......5.kOI?-
00000050: d5777778 6f010bb3 ec671fe4 27131f7b    xww....o..g.{..'
00000060: 2f6ff6e4 bb97cecd 7fff9dda 6ffa1fcd    ..o/...........o
00000070: b7375b84 7159d3ae f07ac971 e99bbff6    .[7...Yqq.z.....
00000080: d325d7fd d3b663b8 f377cfea f3675f72    ..%..c....w.r_g.
00000090: 3d1d4cd9 11a59b18 b795fffd 33ba95b8    .L.=...........3
000000a0: 575bbfef 73eb794f 33536eee 104389cf    ..[WOy.s.nS3..C.
000000b0: 7763a778 35ff5fd8 f33e57c1 f777fbce    x.cw._.5.W>...w.
000000c0: f35b6f9b 5bf70fdb bb730de3 7d7b5f88    .o[....[..s.._{}
000000d0: 5547a7f9 f33f07eb a395364c b35377e8    ..GU..?.L6...wS.
000000e0: 77bf6597 27737ea2 af3577f5 5b34f7d9    .e.w.~s'.w5...4[
000000f0: 33eadbba fed7df87 3efbfaa8 83b9ef9c    ...3.......>....
SOCFPGA_CYCLONE5 # mw 0 12345678 100
SOCFPGA_CYCLONE5 # md 0
00000000: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000010: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000020: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000030: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000040: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000050: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000060: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000070: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000080: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
00000090: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
000000a0: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
000000b0: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
000000c0: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
000000d0: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
000000e0: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
000000f0: 12345678 12345678 12345678 12345678    xV4.xV4.xV4.xV4.
SOCFPGA_CYCLONE5 # md 100000
00100000: eafffffd fbff4b3f fffffffe fdff33be    ....?K.......3..
00100010: ffb2aacf f7779ac4 f73bbf7f f7fbfbfc    ......w...;.....
00100020: ffe3bb6d ef9f3fff fdb63bbd f6f76f5d    m....?...;..]o..
00100030: efafbdf1 bbefbdbd efbffcfd fffffffd    ................
00100040: fffbb58f e7baabfc ebfa37cd ed3ff96e    .........7..n.?.
00100050: ff7ff7f4 ef1b3ff3 eff71fb6 ffbb0d73    .....?......s...
00100060: efeff6e7 ffb7afeb f7bfbdfb efffffff    ................
00100070: f7fff7ff f7df73ee f1fafff5 ebbbb1e7    .....s..........
00100080: f3e3dff5 f7eff3ff fb77fd64 fbffdff2    ........d.w.....
00100090: ffbc5cfd f5fbbff8 effffffd f7f8a1fc    .\..............
001000a0: 5b7b3fff f7bb734f fbffffee f3fb8bcf    .?{[Os..........
001000b0: f3b3b75f ffffffda f3bf5fc5 fbffffdb    _........_......
001000c0: f3df6fde dbffffdd fbf1ede7 bd7b7fdc    .o............{.
001000d0: f7d7b77f f39f2fef f7933bdc f35337af    ...../...;...7S.
001000e0: f7f71ddf e7f77e38 ef7777fd ffb4f2fc    ....8~...ww.....
001000f0: f3eafb5e fffffee7 fffbdaec f3f0e5f7    ^...............
SOCFPGA_CYCLONE5 # mw 100000 23456789 100
SOCFPGA_CYCLONE5 # md 100000
00100000: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100010: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100020: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100030: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100040: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100050: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100060: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100070: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100080: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
00100090: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
001000a0: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
001000b0: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
001000c0: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
001000d0: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
001000e0: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#
001000f0: 23456789 23456789 23456789 23456789    .gE#.gE#.gE#.gE#

SOCFPGA_CYCLONE5 #

Thanks
Chin Liang

Quoted 2 lines

Best regards,
Marek Vasut

#92 lore raw

cover arm: socfpga: Usability fixes

Quoted 14 lines · Chin Liang See
Quoted 13 lines · marex at denx.de

On Wednesday, September 17, 2014 at 12:29:54 AM, Dinh Nguyen wrote:

[...]

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Yes, tracked it down to get_ram_size(). I forced gd->ram_size to 1GB and it works fine for me now. I'll try to spend some cycles to debug the problem.

Hmmmmm, how much DRAM can the SoCFPGA chip drive in total ?

All of our devkits have at least 1 GiB and I have heard there is a variant with 2GiB in the wild. Spec says up to 4 GiB.

Quoted 8 lines
Quoted 4 lines

OK, I see. You cannot realistically map all those 4GiB into the 32-bit address space of an CortexA9, but on the other hand, all those bugs related to an CA9 with 4GiB of DRAM should be fixed due to my work on Novena ;-)

Yup, 4GB would not be possible. Within SocFPGA, by using HPS-FPGA bridges, we can workaround by swapping memory chunk so ARM processor can access entire 4GB. Interested to find out how you did it for Novena :)

Awwwwww, you know this kind of stuff is really so cool about these SoC+FPGA combo designs :)

As for the Novena, MX6 can only address 3.8 GiB, there is a bit of the DRAM which is not available .

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Well, consider a theoretical SoCFPGA board with 128MiB of DRAM attached to it, what happens if I try to write at address of the 129th MiB (which is past the DRAM) ? Will this generate an DABT for the ARM core or will some kind of DRAM "mirroring" or "wraparound" happen such that I would write to the content of 1st MiB of the DRAM ?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

We've encountered this issue downstream on a system with 1 GiB.

OK, so a wraparound happens ?

It should be a wrap around. It is not working previously as incorrect configuration for one of SDRAM parameters. The fix is under internal review now. :)

All right :)

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 11 lines

If I would get DABT, then there is a rather easy fix for that, see arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c and mxs_mem_get_size() function. The function places an assembly return instruction into the DABT handler entry position (offset 0x14 in ARM vector table IIRC) and then runs the get_dram_size() . The assembly instruction only returns from the DABT handler right past the code where the DABT happened. For the get_ram_size(), the read from the unpopulated DRAM space contains zeroes and the function doesn't even realize the DABT happened. But it considers the DRAM invalid and thus this works correctly. That's how it detects the amount of DRAM.

Quoted 2 lines

You might want to consider something similar if that's how it behaves on SoCFPGA.

This could be the issue. I think Chin Liang would know about this more than me at this point. So I hope he can solve this quickly.

Quoted 7 lines
Quoted 1 line

Sure, patch is welcome!

Hmmm... actually I can get it works well for my Altera dev kit. The get_dram_size would take in the argument PHYS_SDRAM_1_SIZE. From here, the function will ensure the memory specified can read and writable. If its failing here, probably the SDRAM access might have issue. FYI, PHYS_SDRAM_1_SIZE is 0x40000000 for 1GB.

Aw, fixed locally, thanks!

[...]

Pavel had some strange issue here, but these patches should address that. This one 'arm: socfpga: pl310: Map SDRAM to 0x0' is extremely important .

#93 lore raw

cover arm: socfpga: Usability fixes

In reply to Chin Liang See

Dear Chin Liang See,

Quoted 6 lines · In message <[email protected]> you wrote:

Hmmm... actually I can get it works well for my Altera dev kit. The get_dram_size would take in the argument PHYS_SDRAM_1_SIZE. From here, the function will ensure the memory specified can read and writable. If its failing here, probably the SDRAM access might have issue. FYI, PHYS_SDRAM_1_SIZE is 0x40000000 for 1GB.

Normally, get_dram_size() would be called with a size argument that is _larger_ (twice as big) as the biggest possible memory configuration on the respective device. Otherwise it can only detect smaller memory sizes, but would fail to detect if a bigger memory device is installed by accident.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Have you lived in this village all your life?"        "No, not yet."
#94 lore raw

cover arm: socfpga: Usability fixes

Dear Wolfgang,

Quoted 10 lines · ZY - wd

Dear Chin Liang See,

Quoted 6 lines · In message <[email protected]> you wrote:

Hmmm... actually I can get it works well for my Altera dev kit. The get_dram_size would take in the argument PHYS_SDRAM_1_SIZE. From here, the function will ensure the memory specified can read and writable. If its failing here, probably the SDRAM access might have issue. FYI, PHYS_SDRAM_1_SIZE is 0x40000000 for 1GB.

Quoted 6 lines

Normally, get_dram_size() would be called with a size argument that is _larger_ (twice as big) as the biggest possible memory configuration on the respective device. Otherwise it can only detect smaller memory sizes, but would fail to detect if a bigger memory device is installed by accident.

Yup, you are right. But currently, the memory space after the SDRAM is a bridge to FPGA. We will get data abort when trying to read that area (for a blank FPGA).

I believe Marek's suggestion to work around the DABT and memory detection would work around SOCFPGA memory detection. Its something we would work closely with Marek to enable this auto detection.

Thanks
Chin Liang

Quoted 4 lines

Best regards,

Wolfgang Denk

#95 lore raw

cover arm: socfpga: Usability fixes

Quoted 18 lines · Chin Liang See

Dear Wolfgang,

Quoted 9 lines · ZY - wd

Dear Chin Liang See,

Quoted 5 lines · In message <[email protected]> you wrote:

Hmmm... actually I can get it works well for my Altera dev kit. The get_dram_size would take in the argument PHYS_SDRAM_1_SIZE. From here, the function will ensure the memory specified can read and writable. If its failing here, probably the SDRAM access might have issue. FYI, PHYS_SDRAM_1_SIZE is 0x40000000 for 1GB.

Quoted 5 lines

Normally, get_dram_size() would be called with a size argument that is _larger_ (twice as big) as the biggest possible memory configuration on the respective device. Otherwise it can only detect smaller memory sizes, but would fail to detect if a bigger memory device is installed by accident.

Quoted 3 lines

Yup, you are right. But currently, the memory space after the SDRAM is a bridge to FPGA. We will get data abort when trying to read that area (for a blank FPGA).

This is good, no ? If you reliably get DABT if the H2F bridge is disabled, you can place the trampoline into the DABT vector and detect DRAM size. I'll have to test this.

Quoted 3 lines

I believe Marek's suggestion to work around the DABT and memory detection would work around SOCFPGA memory detection. Its something we would work closely with Marek to enable this auto detection.

OK ;-)

Best regards,
Marek Vasut

#96 lore raw

cover arm: socfpga: Usability fixes

Quoted 7 lines · Marek Vasut
Quoted 6 lines · Chin Liang See

Dear Wolfgang,

Quoted 3 lines · ZY - wd

Dear Chin Liang See,

In message <[email protected]> you

Quoted 12 lines · wrote:
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines

Hmmm... actually I can get it works well for my Altera dev kit. The get_dram_size would take in the argument PHYS_SDRAM_1_SIZE. From here, the function will ensure the memory specified can read and writable. If its failing here, probably the SDRAM access might have issue. FYI, PHYS_SDRAM_1_SIZE is 0x40000000 for 1GB.

Normally, get_dram_size() would be called with a size argument that is _larger_ (twice as big) as the biggest possible memory configuration on the respective device. Otherwise it can only detect smaller memory sizes, but would fail to detect if a bigger memory device is installed by accident.

Quoted 7 lines
Quoted 3 lines

Yup, you are right. But currently, the memory space after the SDRAM is a bridge to FPGA. We will get data abort when trying to read that area (for a blank FPGA).

This is good, no ? If you reliably get DABT if the H2F bridge is disabled, you can place the trampoline into the DABT vector and detect DRAM size. I'll have to test this.

Aw snap, on my hardware, when I access past SDRAM, I am getting a wrap around. What's worse is that I can reliably read and write from that location. This renders get_ram_size() unusable. All right, guys, ideas ?

Best regards,
Marek Vasut

#97 lore raw

cover arm: socfpga: Usability fixes

In reply to Marek Vasut

Dear Marek,

Quoted 3 lines · In message <[email protected]> you wrote:

... For the get_ram_size(), the read
from the unpopulated DRAM space contains zeroes ...

<nitpick>

Reading from non-existent memory is not guaranteed to return zeroes, nor any other specific value; in general, the value you read back is undefined.

</nitpick>

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is practically impossible to teach good programming style to  stu-
dents that have had prior exposure to BASIC: as potential programmers
they are mentally mutilated beyond hope of regeneration.   - Dijkstra
#98 lore raw

cover arm: socfpga: Usability fixes

In reply to Marek Vasut
Quoted 62 lines · Marek Vasut
Quoted 46 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines

So

Thanks and best regards,

Pavel

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

Quoted 6 lines

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes. (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have 128MiB)

Quoted 5 lines

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

btw you don't happen to have a spare CV and AV kits you could send me, so I can do the testing rounds on them too, do you ?

What board are doing your testing on? The Arrow Sockit?

I also see this error print:

U-Boot 2014.10-rc2-00139-g70e9e3e-dirty (Sep 16 2014 - 16:26:56)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM: 1 GiB
WARNING: Caches not enabled
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set. 

^^^^^

Do you see this on your side? I can track it down...

Thanks,
Dinh

#99 lore raw

cover arm: socfpga: Usability fixes

Quoted 21 lines · dinguyen
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

So

Thanks and best regards,

Pavel

Quoted 40 lines
Quoted 40 lines
Quoted 22 lines

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled

DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

Quoted 8 lines

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled

DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes.

   (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have
   128MiB)
Quoted 7 lines
Quoted 5 lines

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

btw you don't happen to have a spare CV and AV kits you could send me, so I can do the testing rounds on them too, do you ?

What board are doing your testing on? The Arrow Sockit?

DENX MCVEVK and I also have the SoCKIT here. Pavel has something funny at home, which I prefer to not know ;-)

Quoted 9 lines

I also see this error print:

U-Boot 2014.10-rc2-00139-g70e9e3e-dirty (Sep 16 2014 - 16:26:56)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM: 1 GiB
WARNING: Caches not enabled

This needs resolving. The I/D caches are enabled too late so we get this splat. I'll cook a patch for that.

Quoted 10 lines

Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set.

^^^^^

Do you see this on your side? I can track it down...

Use
=> setenv ethaddr 00:ma:ca:dd:re:ss
=> saveenv

It's possibly because the code to read out the MAC from some storage where it usually is is likely defunct. So just set the MAC manually and your ethernet will work.

#100 lore raw

cover arm: socfpga: Usability fixes

Quoted 103 lines · Marek Vasut
Quoted 21 lines · dinguyen
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Dinh Nguyen
Quoted 18 lines · Pavel Machek

Hi!

Quoted 11 lines · Marek Vasut

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Just... I earlier today I tested Marek's git tree based on this series, and it works well for me on board similar to sockit.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

So

Thanks and best regards,

Pavel

Quoted 40 lines
Quoted 40 lines
Quoted 22 lines

I applied all the patches to v2014.10-rc2, and I see that the watchdog has been enabled and it's getting reset:

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled

DRAM:
U-Boot SPL 2013.01.01-00019-g9cce15f (Jul 18 2013 - 13:05:43) SDRAM : Initializing MMR registers
SDRAM : Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0
reading u-boot.img
reading u-boot.img

Quoted 8 lines

U-Boot 2014.10-rc2-00139-g70e9e3e (Sep 16 2014 - 11:21:38)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled

DRAM:

This doesn't seem like a WDT problem. How much DRAM is there on that kit ? In any case, try this:

1) Edit arch/arm/cpu/armv7/socfpga/misc.c
2) Locate call to get_ram_size()
3) Replace this function call with the size of your DRAM in bytes.

   (that is, make it "gd->ram_size = 128 * 1024 * 1024;" if you have
   128MiB)
Quoted 7 lines
Quoted 5 lines

I suspect get_ram_size() on socfpga is still broken in mainline and causes this crash you observe.

btw you don't happen to have a spare CV and AV kits you could send me, so I can do the testing rounds on them too, do you ?

What board are doing your testing on? The Arrow Sockit?

DENX MCVEVK and I also have the SoCKIT here. Pavel has something funny at home, which I prefer to not know ;-)

Quoted 9 lines

I also see this error print:

U-Boot 2014.10-rc2-00139-g70e9e3e-dirty (Sep 16 2014 - 16:26:56)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM: 1 GiB
WARNING: Caches not enabled

This needs resolving. The I/D caches are enabled too late so we get this splat. I'll cook a patch for that.

Quoted 9 lines

Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set.

^^^^^

Quoted 5 lines
Quoted 1 line

Do you see this on your side? I can track it down...

Use
=> setenv ethaddr 00:ma:ca:dd:re:ss
=> saveenv

ah yes...I added a CONFIG_ETHADDR since "saveenv" is not enabled yet.

Sorry for the noise, I was expecting
"Warning: failed to set MAC address"

Dinh

#101 lore raw

cover arm: socfpga: Usability fixes

On Wednesday, September 17, 2014 at 12:20:34 AM, Dinh Nguyen wrote:
[...]

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set.

^^^^^

Do you see this on your side? I can track it down...

Quoted 8 lines
Quoted 3 lines

Use
=> setenv ethaddr 00:ma:ca:dd:re:ss
=> saveenv

ah yes...I added a CONFIG_ETHADDR since "saveenv" is not enabled yet.

Sorry for the noise, I was expecting
"Warning: failed to set MAC address"

Ah yes, feel free to post a patch ;-)

Best regards,
Marek Vasut

#102 lore raw

cover arm: socfpga: Usability fixes

In reply to dinguyen

Hi!

Quoted 1 line

What board are doing your testing on? The Arrow Sockit?

I have board similar to SocKit, yes.

Quoted 11 lines

I also see this error print:

U-Boot 2014.10-rc2-00139-g70e9e3e-dirty (Sep 16 2014 - 16:26:56)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board

Watchdog enabled
DRAM: 1 GiB
WARNING: Caches not enabled
Using default environment

Quoted 8 lines
In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set. 

^^^^^

Do you see this on your side? I can track it down...

i2c code that reads address from ROM was not part of the merge, so you need to either set address manually or port it from rocketboards version.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#103 lore raw

cover arm: socfpga: Usability fixes

In reply to Marek Vasut
Quoted 93 lines · marex at denx.de

This entire RFC series is the first stab at making SoCFPGA usable with mainline U-Boot again. There are still some bits missing, but in general, this allows me to use mainline U-Boot on my SoCFPGA systems. The big missing part is the SPL generation, which still needs a lot of additional work.

This set contains patches for a few subsystems, bu the most part is the SoCFPGA chip support.

Most of the patches should be in good shape already, so I wonder if the RFC tag is really necessary.

Charles Manning (1):
tools: socfpga: Add socfpga preloader signing to mkimage

Marek Vasut (21):
net: dwc: Fix cache alignment issues
net: dwc: Make the cache handling less cryptic
mmc: dw_mmc: Fix cache alignment issue
arm: socfpga: Clean up base address file
arm: socfpga: sysmgr: Clean up system manager
arm: socfpga: clock: Implant order into bit definitions
arm: socfpga: clock: Drop nonsense inlining from clock manager code
arm: socfpga: clock: Add missing stubs into board file
arm: socfpga: clock: Trim down code duplication
arm: socfpga: timer: Pull the timer reload value from config file
arm: socfpga: reset: Add EMAC reset functions
arm: socfpga: board: Align checkboard() output
arm: socfpga: reset: Add function to reset FPGA bridges
arm: socfpga: sysmgr: Add FPGA bits into system manager
arm: cache: Add support for write-allocate D-Cache
arm: socfpga: cache: Define cacheline size
arm: socfpga: cache: Enable D-Cache
arm: socfpga: cache: Enable PL310 L2 cache
arm: socfpga: scu: Add SCU register file
arm: socfpga: nic301: Add NIC-301 GPV register file
arm: socfpga: pl310: Map SDRAM to 0x0

Pavel Machek (13):
net: Remove unused CONFIG_DW_SEARCH_PHY from configs
net: phy: Cleanup drivers/net/phy/micrel.c
mmc: dw_mmc: cleanups
arm: socfpga: Complete the list of base addresses
arm: socfpga: Add watchdog disable for socfpga
arm: socfpga: clock: Add code to read clock configuration
arm: socfpga: mmc: Pick the clock from clock manager
arm: socfpga: misc: Add proper ethernet initialization
arm: socfpga: misc: Add SD controller init
arm: socfpga: misc: Align print_cpuinfo() output
arm: socfpga: board: Correctly set ATAG position
arm: socfpga: fpga: Add SoCFPGA FPGA programming interface
arm: socfpga: nic301: Add NIC-301 configuration code

 arch/arm/cpu/armv7/socfpga/Makefile                |   3 +-
 arch/arm/cpu/armv7/socfpga/clock_manager.c         | 218 ++++++++++++-
 arch/arm/cpu/armv7/socfpga/fpga_manager.c          | 354 +++++++++++++++++++++
 arch/arm/cpu/armv7/socfpga/misc.c                  | 144 ++++++++-
 arch/arm/cpu/armv7/socfpga/reset_manager.c         |  72 +++++
 arch/arm/cpu/armv7/socfpga/system_manager.c        |  57 +++-
 arch/arm/cpu/armv7/socfpga/timer.c                 |   2 +
 arch/arm/include/asm/arch-socfpga/clock_manager.h  | 209 ++++++++----
 arch/arm/include/asm/arch-socfpga/fpga_manager.h   |  77 +++++
 arch/arm/include/asm/arch-socfpga/nic301.h         | 195 ++++++++++++
 arch/arm/include/asm/arch-socfpga/reset_manager.h  |   6 +
 arch/arm/include/asm/arch-socfpga/scu.h            |  23 ++
 .../include/asm/arch-socfpga/socfpga_base_addrs.h  |  62 +++-
 arch/arm/include/asm/arch-socfpga/system_manager.h | 111 +++++--
 arch/arm/include/asm/system.h                      |   1 +
 arch/arm/lib/cache-cp15.c                          |   2 +
 board/altera/socfpga/pll_config.h                  |   3 +
 board/altera/socfpga/socfpga_cyclone5.c            |   7 +-
 common/image.c                                     |   1 +
 drivers/fpga/altera.c                              |  21 ++
 drivers/mmc/dw_mmc.c                               |  26 +-
 drivers/mmc/socfpga_dw_mmc.c                       |  15 +-
 drivers/net/designware.c                           |  46 +--
 drivers/net/phy/micrel.c                           |   7 +-
 include/altera.h                                   |   1 +
 include/configs/axs101.h                           |   1 -
 include/configs/socfpga_cyclone5.h                 |   9 +-
 include/dwmmc.h                                    |   2 +-
 include/image.h                                    |   1 +
 tools/Makefile                                     |   1 +
 tools/imagetool.c                                  |   2 +
 tools/imagetool.h                                  |   1 +
 tools/socfpgaimage.c                               | 255 +++++++++++++++
 33 files changed, 1753 insertions(+), 182 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/fpga_manager.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/fpga_manager.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/nic301.h
 create mode 100644 arch/arm/include/asm/arch-socfpga/scu.h
 create mode 100644 tools/socfpgaimage.c
Quoted 8 lines
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Joe Hershberger <[email protected]>

A quick test from my side and result as below:

1. SDRAM access is working where I can read and write to few spots. :)

SOCFPGA_CYCLONE5 # md 0
00000000: 00000000 aaaaaaaa aaaaaaaa aaaaaaaa ................
SOCFPGA_CYCLONE5 # mw 0 12345678 100 SOCFPGA_CYCLONE5 # md 0
00000000: 12345678 12345678 12345678 12345678 xV4.xV4.xV4.xV4.
SOCFPGA_CYCLONE5 # md 100000
00100000: eafffffd fbff4b3f fffffffe fdff33be ....?K.......3..
SOCFPGA_CYCLONE5 # mw 100000 23456789 100 SOCFPGA_CYCLONE5 # md 100000
00100000: 23456789 23456789 23456789 23456789 .gE#.gE#.gE#.gE#
SOCFPGA_CYCLONE5 #

2. Ethernet seems not working for me.
But I will look into this to find out any missing pieces.

SOCFPGA_CYCLONE5 # setenv ethaddr 02:11:22:33:44:55 SOCFPGA_CYCLONE5 # dhcp
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Retry time exceeded; starting again

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

Thanks
Chin Liang

#104 lore raw

cover arm: socfpga: Usability fixes

On Wednesday, September 17, 2014 at 01:29:15 PM, Chin Liang See wrote:
[...]

Quoted 4 lines

A quick test from my side and result as below:

1. SDRAM access is working where I can read and write to few spots. :)

Quoted 11 lines

SOCFPGA_CYCLONE5 # md 0
00000000: 00000000 aaaaaaaa aaaaaaaa aaaaaaaa ................
SOCFPGA_CYCLONE5 # mw 0 12345678 100 SOCFPGA_CYCLONE5 # md 0
00000000: 12345678 12345678 12345678 12345678 xV4.xV4.xV4.xV4.
SOCFPGA_CYCLONE5 # md 100000
00100000: eafffffd fbff4b3f fffffffe fdff33be ....?K.......3..
SOCFPGA_CYCLONE5 # mw 100000 23456789 100 SOCFPGA_CYCLONE5 # md 100000
00100000: 23456789 23456789 23456789 23456789 .gE#.gE#.gE#.gE#
SOCFPGA_CYCLONE5 #

What does that mean?

Quoted 24 lines

2. Ethernet seems not working for me.
But I will look into this to find out any missing pieces.

SOCFPGA_CYCLONE5 # setenv ethaddr 02:11:22:33:44:55 SOCFPGA_CYCLONE5 # dhcp
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Quoted 1 line

Retry time exceeded; starting again

This is on the SoCDK, right ?

Quoted 3 lines

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

This should be in the tree in fact. Is CONFIG_CMD_MMC defined ?

#105 lore raw

cover arm: socfpga: Usability fixes

Quoted 18 lines · marex at denx.de

On Wednesday, September 17, 2014 at 01:29:15 PM, Chin Liang See wrote:
[...]

Quoted 4 lines

A quick test from my side and result as below:

1. SDRAM access is working where I can read and write to few spots. :)

Quoted 11 lines

SOCFPGA_CYCLONE5 # md 0
00000000: 00000000 aaaaaaaa aaaaaaaa aaaaaaaa ................
SOCFPGA_CYCLONE5 # mw 0 12345678 100 SOCFPGA_CYCLONE5 # md 0
00000000: 12345678 12345678 12345678 12345678 xV4.xV4.xV4.xV4.
SOCFPGA_CYCLONE5 # md 100000
00100000: eafffffd fbff4b3f fffffffe fdff33be ....?K.......3..
SOCFPGA_CYCLONE5 # mw 100000 23456789 100 SOCFPGA_CYCLONE5 # md 100000
00100000: 23456789 23456789 23456789 23456789 .gE#.gE#.gE#.gE#
SOCFPGA_CYCLONE5 #

Quoted 1 line

What does that mean?

I recall Pavel was having issue when he is accessing 1MB of memory at 0. I believe this is gone as this new patch works well for me.

Quoted 25 lines
Quoted 25 lines

2. Ethernet seems not working for me.
But I will look into this to find out any missing pieces.

SOCFPGA_CYCLONE5 # setenv ethaddr 02:11:22:33:44:55 SOCFPGA_CYCLONE5 # dhcp
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Quoted 3 lines
Quoted 1 line

Retry time exceeded; starting again

This is on the SoCDK, right ?

Yup, Altera SoCDK.

Quoted 6 lines
Quoted 4 lines

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

This should be in the tree in fact. Is CONFIG_CMD_MMC defined ?

I didn't see any MMC configuration at include/configs/socfpga_cyclone5 at mainline nor the new patch series. Wonder I might miss out any ACKed patch?

Thanks
Chin Liang

#106 lore raw

cover arm: socfpga: Usability fixes

Quoted 20 lines · Chin Liang See
Quoted 19 lines · marex at denx.de

On Wednesday, September 17, 2014 at 01:29:15 PM, Chin Liang See wrote:
[...]

Quoted 15 lines

A quick test from my side and result as below:

1. SDRAM access is working where I can read and write to few spots. :)

SOCFPGA_CYCLONE5 # md 0
00000000: 00000000 aaaaaaaa aaaaaaaa aaaaaaaa ................
SOCFPGA_CYCLONE5 # mw 0 12345678 100 SOCFPGA_CYCLONE5 # md 0
00000000: 12345678 12345678 12345678 12345678 xV4.xV4.xV4.xV4.
SOCFPGA_CYCLONE5 # md 100000
00100000: eafffffd fbff4b3f fffffffe fdff33be ....?K.......3..
SOCFPGA_CYCLONE5 # mw 100000 23456789 100 SOCFPGA_CYCLONE5 # md 100000
00100000: 23456789 23456789 23456789 23456789 .gE#.gE#.gE#.gE#
SOCFPGA_CYCLONE5 #

Quoted 4 lines
Quoted 1 line

What does that mean?

I recall Pavel was having issue when he is accessing 1MB of memory at 0. I believe this is gone as this new patch works well for me.

Yes, the NIC301 patches solve this. Pavel confirmed this yesterday.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

2. Ethernet seems not working for me.
But I will look into this to find out any missing pieces.

SOCFPGA_CYCLONE5 # setenv ethaddr 02:11:22:33:44:55 SOCFPGA_CYCLONE5 # dhcp
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Retry time exceeded; starting again

This is on the SoCDK, right ?

Yup, Altera SoCDK.

OK

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

This should be in the tree in fact. Is CONFIG_CMD_MMC defined ?

I didn't see any MMC configuration at include/configs/socfpga_cyclone5 at mainline nor the new patch series. Wonder I might miss out any ACKed patch?

Oh I see. I have this enabled in the repository here, but I didn't submit that change since it needs more work. The code is there , added in the patch

arm: socfpga: misc: Add SD controller init

The change for the SoCFPGA config file is missing though.

Best regards,
Marek Vasut

#107 lore raw

cover arm: socfpga: Usability fixes

Hi Marek,

Quoted 13 lines · marex at denx.de
Quoted 11 lines · Chin Liang See
Quoted 6 lines · marex at denx.de
Quoted 3 lines · Chin Liang See

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

This should be in the tree in fact. Is CONFIG_CMD_MMC defined ?

I didn't see any MMC configuration at include/configs/socfpga_cyclone5 at mainline nor the new patch series. Wonder I might miss out any ACKed patch?

Quoted 6 lines

Oh I see. I have this enabled in the repository here, but I didn't submit that change since it needs more work. The code is there , added in the patch

arm: socfpga: misc: Add SD controller init

The change for the SoCFPGA config file is missing though.

Yup, I just submit the patch to add that "socfpga: Enable DWMMC for SOCFPGA". With this added, the SDMMC is working well at U-Boot. This including all the 35 patches from you. Something to cheer during the weekend :)

Here is the printout:

SOCFPGA_CYCLONE5 # fatls mmc 0:1

   194168   u-boot.img
    16289   socfpga.dtb
  3202824   zimage

3 file(s), 0 dir(s)

SOCFPGA_CYCLONE5 # mmc read 8000 0 1

MMC read: dev # 0, block # 0, count 1 ... 1 blocks read: OK SOCFPGA_CYCLONE5 # md 8000

00008000: 00000000 00000000 00000000 00000000    ................
00008010: 00000000 00000000 00000000 00000000    ................
00008020: 00000000 00000000 00000000 00000000    ................
00008030: 00000000 00000000 00000000 00000000    ................
00008040: 00000000 00000000 00000000 00000000    ................
00008050: 00000000 00000000 00000000 00000000    ................
00008060: 00000000 00000000 00000000 00000000    ................
00008070: 00000000 00000000 00000000 00000000    ................
00008080: 00000000 00000000 00000000 00000000    ................
00008090: 00000000 00000000 00000000 00000000    ................
000080a0: 00000000 00000000 00000000 00000000    ................
000080b0: 00000000 00000000 00000000 00000000    ................
000080c0: 00000000 00000000 00000000 00000000    ................
000080d0: 00000000 00000000 00000000 00000000    ................
000080e0: 00000000 00000000 00000000 00000000    ................
000080f0: 00000000 00000000 00000000 00000000    ................
SOCFPGA_CYCLONE5 #
00008100: 00000000 00000000 00000000 00000000    ................
00008110: 00000000 00000000 00000000 00000000    ................
00008120: 00000000 00000000 00000000 00000000    ................
00008130: 00000000 00000000 00000000 00000000    ................
00008140: 00000000 00000000 00000000 00000000    ................
00008150: 00000000 00000000 00000000 00000000    ................
00008160: 00000000 00000000 00000000 00000000    ................
00008170: 00000000 00000000 00000000 00000000    ................
00008180: 00000000 00000000 00000000 00000000    ................
00008190: 00000000 00000000 00000000 00000000    ................
000081a0: 00000000 00000000 00000000 00000000    ................
000081b0: 00000000 00000000 479bf7be 01000000    ...........G....
000081c0: 3c0b0001 003e093e 937e0000 00000000    ...<>.>...~.....
000081d0: 3c830a01 93bc133e 93bc0000 00000000    ...<>...........
000081e0: 3ca21401 27781d3e 93bc0001 00000000    ...<>.x'........
000081f0: 00000000 00000000 00000000 aa550000    ..............U.

SOCFPGA_CYCLONE5 #

Thanks
Chin Liang

Quoted 3 lines

Best regards,
Marek Vasut

#108 lore raw

cover arm: socfpga: Usability fixes

Hi guys,

Quoted 19 lines · Chin Liang See

Hi Marek,

Quoted 16 lines · marex at denx.de
Quoted 11 lines · Chin Liang See
Quoted 6 lines · marex at denx.de
Quoted 3 lines · Chin Liang See

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

This should be in the tree in fact. Is CONFIG_CMD_MMC defined ?

I didn't see any MMC configuration at include/configs/socfpga_cyclone5 at mainline nor the new patch series. Wonder I might miss out any ACKed patch?

Oh I see. I have this enabled in the repository here, but I didn't submit that change since it needs more work. The code is there , added in the patch

Quoted 9 lines
Quoted 3 lines

arm: socfpga: misc: Add SD controller init

The change for the SoCFPGA config file is missing though.

Yup, I just submit the patch to add that "socfpga: Enable DWMMC for SOCFPGA". With this added, the SDMMC is working well at U-Boot. This including all the 35 patches from you. Something to cheer during the weekend :)

I just submitted a patch "socfpga: Enable SDMMC boot for SOCFPGA U-Boot". This will enable the SDMMC boot as default boot for Altera dev kit. With that, I am able to success boot till Linux 3.10 LTSi successfully :)

Thanks
Chin Liang

U-Boot 2014.10-rc2-00126-g77676b6 (Sep 19 2014 - 05:28:06)

CPU:   Altera SoCFPGA Platform
BOARD: Altera SoCFPGA Cyclone5 Board
DRAM:  1 GiB
WARNING: Caches not enabled
MMC:   SOCFPGA DWMMC: 0

Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.ff702000
Error: dwmac.ff702000 address not set.

Warning: Your board does not use generic board. Please read doc/README.generic-board and take action. Boards not upgraded by the late 2014 may break or be removed. Hit any key to stop autoboot: 0
reading zImage
3525736 bytes read in 196 ms (17.2 MiB/s)
reading socfpga.dtb
19247 bytes read in 8 ms (2.3 MiB/s)
Kernel image @ 0x007fc0 [ 0x000000 - 0x35cc68 ]
## Flattened Device Tree blob at 00000100
Booting using the fdt blob at 0x000100
Loading Device Tree to 0fff7000, end 0fffeb2e ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 3.10.31-ltsi (jdasilva at sj-interactive3) (gcc version 4.8.3 20140401 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2014.04 - Linaro GCC 4.8-2014.04) ) #1 SMP Wed Sep 17 00:24:24 PDT 2014
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Altera SOCFPGA, model: Altera SOCFPGA Cyclone V
Memory policy: ECC disabled, Data cache writealloc
PERCPU: Embedded 8 pages/cpu @80f70000 s11200 r8192 d13376 u32768 Built 1 zonelists in Zone order, mobility grouping on. Total pages:
260096
Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1024MB = 1024MB total
Memory: 1031884k/1031884k available, 16692k reserved, 0K highmem Virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc0800000 - 0xff000000   (1000 MB)
    lowmem  : 0x80000000 - 0xc0000000   (1024 MB)
    modules : 0x7f000000 - 0x80000000   (  16 MB)
      .text : 0x80008000 - 0x8068cab0   (6675 kB)
      .init : 0x8068d000 - 0x806e3bc0   ( 347 kB)
      .data : 0x806e4000 - 0x807204d0   ( 242 kB)
       .bss : 0x807204d0 - 0x80761cb4   ( 262 kB)

SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 Hierarchical RCU implementation.
NR_IRQS:16 nr_irqs:16 16
sched_clock: 32 bits at 100MHz, resolution 10ns, wraps every 42949ms
Console: colour dummy device 80x30
Calibrating delay loop... 1836.64 BogoMIPS (lpj=9183232)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
ftrace: allocating 17914 entries in 53 pages
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x804d39c8 - 0x804d3a20
CPU1: Booted secondary processor
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
Brought up 2 CPUs
SMP: Total of 2 processors activated (3679.84 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
NET: Registered protocol family 16
fpga bridge driver
DMA: preallocated 256 KiB pool for atomic coherent allocations L310 cache controller enabled
l2x0: 8 ways, CACHE_ID 0x410030c9, AUX_CTRL 0x32460000, Cache size:
524288 B
syscon fffef000.l2-cache: regmap [mem 0xfffef000-0xfffeffff] registered syscon ffd05000.rstmgr: regmap [mem 0xffd05000-0xffd05fff] registered syscon ffc25000.sdrctl: regmap [mem 0xffc25000-0xffc25fff] registered syscon ff800000.l3regs: regmap [mem 0xff800000-0xff800fff] registered syscon ffd08000.sysmgr: regmap [mem 0xffd08000-0xffd0bfff] registered
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes. altera_hps2fpga_bridge fpgabridge.2: fpga bridge [hps2fpga] registered as device hps2fpga
altera_hps2fpga_bridge fpgabridge.2: init-val not specified altera_hps2fpga_bridge fpgabridge.3: fpga bridge [lshps2fpga] registered as device lwhps2fpga
altera_hps2fpga_bridge fpgabridge.3: init-val not specified altera_hps2fpga_bridge fpgabridge.4: fpga bridge [fpga2hps] registered as device fpga2hps
altera_hps2fpga_bridge fpgabridge.4: init-val not specified
bio: create slab <bio-0> at 0
FPGA Mangager framework driver
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
lcd-comm 0-0028: LCD driver initialized
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
PTP clock support registered
Switching to clocksource timer0
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 4, 65536 bytes) TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP: reno registered
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
arm-pmu arm-pmu: PMU:CTI successfully enabled for 2 cores
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
NTFS driver 2.1.30 [Flags: R/W].
jffs2: version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
msgmni has been set to 2015
io scheduler noop registered (default)
usbcore: registered new interface driver udlfb
Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled ffc02000.serial0: ttyS0 at MMIO 0xffc02000 (irq = 194) is a 16550A console [ttyS0] enabled
altera_fpga_manager ff706000.fpgamgr: fpga manager [Altera FPGA Manager] registered as minor 0
brd: module loaded
at24 0-0051: 4096 byte 24c32 EEPROM, writable, 32 bytes/write cadence-qspi ff705000.spi: DMA NOT enabled
cadence-qspi ff705000.spi: master is unqueued, this is deprecated m25p80 spi2.0: found n25q512a, expected n25q00
m25p80 spi2.0: n25q512a (65536 Kbytes)
2 ofpart partitions found on MTD device spi2.0
Creating 2 MTD partitions on "spi2.0":
0x000000000000-0x000000800000 : "Flash 0 Raw Data" 0x000000800000-0x000008000000 : "Flash 0 jffs2 Filesystem"
mtd: partition "Flash 0 jffs2 Filesystem" extends beyond the end of device "spi2.0" -- size truncated to 0x3800000
cadence-qspi ff705000.spi: Cadence QSPI controller driver dw_spi_mmio fff00000.spi: master is unqueued, this is deprecated CAN device driver interface
c_can_platform ffc00000.d_can: invalid resource c_can_platform ffc00000.d_can: control memory is not used for raminit c_can_platform ffc00000.d_can: c_can_platform device registered (regs=c08e4000, irq=163)
stmmac - user ID: 0x10, Synopsys ID: 0x37
Ring mode enabled
DMA HW capability register supported
Enhanced/Alternate descriptors
Enabled extended descriptors
RX Checksum Offload Engine supported (type 2)
TX Checksum insertion supported
Enable RX Mitigation via HW Watchdog Timer
libphy: stmmac: probed
eth0: PHY ID 00221611 at 4 IRQ POLL (stmmac-1:04) active dwc2 ffb40000.usb: unable to find phy
dwc2 ffb40000.usb: EPs:15
dwc2 ffb40000.usb: dedicated fifos
dwc2 ffb40000.usb: 2560 invalid for host_rx_fifo_size. Check HW configuration.
dwc2 ffb40000.usb: DWC OTG Controller
dwc2 ffb40000.usb: new USB bus registered, assigned bus number 1 dwc2 ffb40000.usb: irq 160, io mem 0x00000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 usb usb1: Product: DWC OTG Controller
usb usb1: Manufacturer: Linux 3.10.31-ltsi dwc2_hsotg
usb usb1: SerialNumber: ffb40000.usb
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
rtc-ds1307 0-0068: SET TIME!
rtc-ds1307 0-0068: rtc core: registered ds1339 as rtc0
i2c /dev entries driver
Synopsys Designware Multimedia Card Interface Driver dwmmc_socfpga ff704000.dwmmc0: couldn't determine pwr-en, assuming pwr-en = 0
dwmmc_socfpga ff704000.dwmmc0: Using internal DMA controller. dwmmc_socfpga ff704000.dwmmc0: Version ID is 240a dwmmc_socfpga ff704000.dwmmc0: DW MMC controller at irq 171, 32 bit host data width, 1024 deep fifo
mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 400000Hz, actual 396825HZ div = 63)
dwmmc_socfpga ff704000.dwmmc0: 1 slots initialized
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
oprofile: using arm/armv7-ca9
TCP: cubic registered
NET: Registered protocol family 10
sit: IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
NET: Registered protocol family 15
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
8021q: 802.1Q VLAN Support v1.8
Key type dns_resolver registered
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 ThumbEE CPU extension supported.
Registering SWP/SWPB emulation handler
Waiting for root device /dev/mmcblk0p2...
mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 50000000Hz, actual 50000000HZ div = 0)
mmc0: new high speed SDHC card at address 0007
mmcblk0: mmc0:0007 SD4GB 3.70 GiB
mmcblk0: p1 p2 p3
EXT2-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel memory: 344K (8068d000 - 806e3000) Initializing random number generator... done.
Starting network...

Welcome to Altera SOCFPGA5XS1
Altera_SOCFPGA5XS1 login: root

# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 1836.64
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3
tls lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor : 1
model name : ARMv7 Processor rev 0 (v7l)
BogoMIPS : 1843.20
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3
tls lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part : 0xc09
CPU revision : 0

Hardware : Altera SOCFPGA
Revision : 0000
Serial : 0000000000000000
#

#109 lore raw

cover arm: socfpga: Usability fixes

Quoted 32 lines · Chin Liang See

Hi guys,

Quoted 20 lines · Chin Liang See

Hi Marek,

Quoted 17 lines · marex at denx.de
Quoted 11 lines · Chin Liang See
Quoted 6 lines · marex at denx.de
Quoted 3 lines · Chin Liang See

3. MMC is not enabled in SocFPGA.
I recall there is a patch from Pavel.
I believe its pending for v2 due to some comments.

This should be in the tree in fact. Is CONFIG_CMD_MMC defined ?

I didn't see any MMC configuration at include/configs/socfpga_cyclone5 at mainline nor the new patch series. Wonder I might miss out any ACKed patch?

Oh I see. I have this enabled in the repository here, but I didn't submit that change since it needs more work. The code is there , added in the patch

Quoted 8 lines
Quoted 3 lines

arm: socfpga: misc: Add SD controller init

The change for the SoCFPGA config file is missing though.

Yup, I just submit the patch to add that "socfpga: Enable DWMMC for SOCFPGA". With this added, the SDMMC is working well at U-Boot. This including all the 35 patches from you. Something to cheer during the weekend :)

Quoted 4 lines

I just submitted a patch "socfpga: Enable SDMMC boot for SOCFPGA U-Boot". This will enable the SDMMC boot as default boot for Altera dev kit. With that, I am able to success boot till Linux 3.10 LTSi successfully :)

We still have a few bugs in the DWMMC driver when using eMMC card, but that's a problem with a particular eMMC card I think. I'll have to look into it.

I will pick your patch and re-post the entire bulk today or tomorrow with the suggested changes.

Best regards,
Marek Vasut