Skip to contentSkip to conversation

mainline u-boot on socfpga

RFC Superseded Pavel Machek 3 participants 6 messages Sep 3, 2014 – Sep 15, 2014

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 mainline u-boot on socfpga

Hi!

I know coding style leaves something to be desired.

But.. it recognizes MMC/ethernet, and can load linux kernel.

Unfortunately, linux kernel then fails to mount / filesystem (or fails to launch init if filesystem is clean); same kernel works with rocketboards u-boot. Ideas what could be a problem are welcome.

Best regards,
Pavel

arch/arm/cpu/armv7/socfpga/Makefile +1 -0
index eb33f2c..c36e0d0 100644
@@ -10,3 +10,4 @@
 obj-y	:= lowlevel_init.o
 obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o scan_manager.o
+obj-y	+= fpga_manager.o
arch/arm/cpu/armv7/socfpga/clock_manager.c +166 -0

175 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/fpga_manager.c new file +335 -0

335 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/lowlevel_init.S +98 -0

107 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/misc.c +226 -10

260 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/reset_manager.c +74 -0

83 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/system_manager.c +47 -1

65 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/clock_manager.h +5 -0
index babac0e..d7c87199 100644
@@ -208,4 +208,9 @@ struct socfpga_clock_manager {
 	CLKMGR_SDRPLLGRP_VCO_DENOM_SET(CONFIG_HPS_SDRPLLGRP_VCO_DENOM) | \
 	CLKMGR_SDRPLLGRP_VCO_NUMER_SET(CONFIG_HPS_SDRPLLGRP_VCO_NUMER))
 
+/* global variable which consume by drivers */
+extern unsigned long cm_l4_sp_clock;
+extern unsigned long cm_sdmmc_clock;
+extern unsigned long cm_qspi_clock;
+
 #endif /* _CLOCK_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/fpga_manager.h new file +92 -0

92 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/reset_manager.h +8 -0
index 3e95476..eb95c5b 100644
@@ -10,6 +10,14 @@
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
+void reset_deassert_all_bridges(void);
+void reset_assert_all_bridges(void);
+
+void emac0_reset_enable(uint state);
+void emac1_reset_enable(uint state);
+
+void watchdog_disable(void);
+
 struct socfpga_reset_manager {
 	u32	status;
 	u32	ctrl;
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h +6 -0
index 2d3152d..39a7874 100644
@@ -7,9 +7,15 @@
 #ifndef _SOCFPGA_BASE_ADDRS_H_
 #define _SOCFPGA_BASE_ADDRS_H_
 
+#define SOCFPGA_EMAC0_ADDRESS 0xff700000
+#define SOCFPGA_EMAC1_ADDRESS 0xff702000
+#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_L4WD0_ADDRESS 0xffd02000
 #define SOCFPGA_CLKMGR_ADDRESS 0xffd04000
arch/arm/include/asm/arch-socfpga/system_manager.h +45 -0

49 lines not on this page · raw message

arch/arm/include/asm/system.h +1 -0
index d51ba66..f0dcbd7 100644
@@ -185,6 +185,7 @@ enum dcache_option {
 	DCACHE_OFF = 0x12,
 	DCACHE_WRITETHROUGH = 0x1a,
 	DCACHE_WRITEBACK = 0x1e,
+	DCACHE_WRITEBACK_WRITEALLOCATE = 0x16,
 };
 
 /* Size of an MMU section */
arch/arm/lib/cache-cp15.c +2 -0
index 3e62d58..3227e5d 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_WRITEBACK_WRITEALLOCATE)
+               set_section_dcache(i, DCACHE_WRITEBACK_WRITEALLOCATE);
 #else
 		set_section_dcache(i, DCACHE_WRITEBACK);
 #endif
board/altera/socfpga/socfpga_cyclone5.c +12 -3
index fb92852..aef3fd7 100644
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *  Copyright (C) 2014 Pavel Machek, pavel at denx.de
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -8,8 +9,6 @@
 #include <asm/arch/reset_manager.h>
 #include <asm/io.h>
 
-#include <netdev.h>
-
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
@@ -34,6 +33,16 @@ int board_early_init_f(void)
  */
 int board_init(void)
 {
-	icache_enable();
+	/* adress of boot parameters for ATAG (if ATAG is used) */
+	gd->bd->bi_boot_params = 0x00000100;
+
+	//	icache_enable();
+	puts("derive_clocks_for_drivers... \n");
+#if 0 /* FIXME */
+	/* calculate the clock frequencies required for drivers */
+	cm_derive_clocks_for_drivers();
+
+	puts("derive_clocks_for_drivers... done\n");
+#endif
 	return 0;
 }
common/cmd_fpga.c +4 -1
index 8c5bf44..884c61a 100644
@@ -43,6 +43,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	void *fpga_data = NULL;
 	char *devstr = getenv("fpga");
 	char *datastr = getenv("fpgadata");
+	char *devsizestr = getenv("fpgadatasize");
 	int rc = FPGA_FAIL;
 	int wrong_parms = 0;
 #if defined(CONFIG_FIT)
@@ -57,7 +58,9 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	if (devstr)
 		dev = (int) simple_strtoul(devstr, NULL, 16);
 	if (datastr)
-		fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
+		fpga_data = (void *) simple_strtoul(datastr, NULL, 16);
+	if (devsizestr)
+		data_size = (size_t) simple_strtoul(devsizestr, NULL, 16);
 
 	switch (argc) {
 #if defined(CONFIG_CMD_FPGA_LOADFS)
common/memsize.c +2 -0
index 589400d..0cae738 100644
@@ -33,6 +33,8 @@ long get_ram_size(long *base, long maxsize)
 	long           size;
 	int            i = 0;
 
+	return maxsize;
+
 	for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
 		addr = base + cnt;	/* pointer arith! */
 		sync ();
drivers/fpga/altera.c +26 -0
index 6e34a8e..36d8826 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,18 @@ 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);
+			if (ret_val) {
+				printf("%s: Failed with error code %d\n",
+				__func__, ret_val);
+				ret_val = 1;
+			}
+			break;
+#endif
 		default:
 			printf ("%s: Unsupported family type, %d\n",
 					__FUNCTION__, desc->family);
@@ -94,6 +112,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 +142,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);
drivers/mmc/socfpga_dw_mmc.c +2 -0
index 1f96382..1c285bc 100644
@@ -16,6 +16,8 @@ static const struct socfpga_clock_manager *clock_manager_base =
 static const struct socfpga_system_manager *system_manager_base =
 		(void *)SOCFPGA_SYSMGR_ADDRESS;
 
+#define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK (1 << 8)
+
 static void socfpga_dwmci_clksel(struct dwmci_host *host)
 {
 	unsigned int drvsel;
drivers/net/phy/micrel.c +34 -6
index 5d7e3be..06a31b0 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
  */
@@ -113,17 +112,46 @@ static int ksz9021_phy_extwrite(struct phy_device *phydev, int addr,
 	return ksz9021_phy_extended_write(phydev, regnum, val);
 }
 
+/* FIXME: disable_giga is probably what we want to do */
+
 /* Micrel ksz9021 */
 static int ksz9021_config(struct phy_device *phydev)
 {
 	unsigned ctrl1000 = 0;
 	const unsigned master = CTRL1000_PREFER_MASTER |
-			CTRL1000_CONFIG_MASTER | CTRL1000_MANUAL_CONFIG;
+		CTRL1000_CONFIG_MASTER | CTRL1000_MANUAL_CONFIG;
 	unsigned features = phydev->drv->features;
 
+	printf("ksz9021: configuring\n");
+
+	printf("Configuring PHY skew timing for %s\n",
+	       phydev->drv->name);
+
+	/* min rx data delay */
+	if (ksz9021_phy_extended_write(phydev,
+				       MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW,
+				       getenv_ulong(CONFIG_KSZ9021_DATA_SKEW_ENV, 16,
+						    CONFIG_KSZ9021_DATA_SKEW_VAL)) < 0)
+		return -1;
+	/* min tx data delay */
+	if (ksz9021_phy_extended_write(phydev,
+				       MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW,
+				       getenv_ulong(CONFIG_KSZ9021_DATA_SKEW_ENV, 16,
+						    CONFIG_KSZ9021_DATA_SKEW_VAL)) < 0)
+		return -1;
+	/* max rx/tx clock delay, min rx/tx control */
+	if (ksz9021_phy_extended_write(phydev,
+				       MII_KSZ9021_EXT_RGMII_CLOCK_SKEW,
+				       getenv_ulong(CONFIG_KSZ9021_CLK_SKEW_ENV, 16,
+						    CONFIG_KSZ9021_CLK_SKEW_VAL)) < 0)
+		return -1;
+
+	printf("ksz9021: skew ok\n");
+
+
 	if (getenv("disable_giga"))
 		features &= ~(SUPPORTED_1000baseT_Half |
-				SUPPORTED_1000baseT_Full);
+			      SUPPORTED_1000baseT_Full);
 	/* force master mode for 1000BaseT due to chip errata */
 	if (features & SUPPORTED_1000baseT_Half)
 		ctrl1000 |= ADVERTISE_1000HALF | master;
examples/standalone/Makefile +2 -1
index 2dacba2..163672f 100644
@@ -5,7 +5,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-extra-y        := hello_world
+extra-y        := 
+#extra-y        := hello_world
 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
 extra-$(CONFIG_SMC911X)            += smc911x_eeprom
 extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
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 */
include/configs/axs101.h +0 -1
index c22d6d0..1bf83907 100644
@@ -125,7 +125,6 @@
  */
 #define CONFIG_DESIGNWARE_ETH
 #define CONFIG_DW_AUTONEG
-#define CONFIG_DW_SEARCH_PHY
 #define CONFIG_NET_MULTI
 
 /*
include/configs/socfpga_cyclone5.h +70 -13

169 lines not on this page · raw message

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

RFC v2 1/1 mainline u-boot on socfpga

Hi!

I know coding style leaves something to be desired.

But.. it recognizes MMC/ethernet, and can load linux kernel.

Unfortunately, 1MB of memory at 0 is not available for some reason; but linux works ok if you avoid that area.

"fpga load 0" now seems to work.

For some reason, I had to rewrite fpgamgr_axi_write(). There's some bug in assembly version, causing code to get confused after it is executed.

If some ARM expert could take a look, that would be great; bug is likely also present in rocketboards version of u-boot.

Best regards,
Pavel

arch/arm/cpu/armv7/socfpga/Makefile +1 -0
index eb33f2c..c36e0d0 100644
@@ -10,3 +10,4 @@
 obj-y	:= lowlevel_init.o
 obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o scan_manager.o
+obj-y	+= fpga_manager.o
arch/arm/cpu/armv7/socfpga/clock_manager.c +220 -0

229 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/fpga_manager.c new file +378 -0

378 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/lowlevel_init.S +110 -0

119 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/misc.c +226 -10

260 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/reset_manager.c +75 -0

84 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/system_manager.c +47 -1

65 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/clock_manager.h +5 -0
index babac0e..d7c87199 100644
@@ -208,4 +208,9 @@ struct socfpga_clock_manager {
 	CLKMGR_SDRPLLGRP_VCO_DENOM_SET(CONFIG_HPS_SDRPLLGRP_VCO_DENOM) | \
 	CLKMGR_SDRPLLGRP_VCO_NUMER_SET(CONFIG_HPS_SDRPLLGRP_VCO_NUMER))
 
+/* global variable which consume by drivers */
+extern unsigned long cm_l4_sp_clock;
+extern unsigned long cm_sdmmc_clock;
+extern unsigned long cm_qspi_clock;
+
 #endif /* _CLOCK_MANAGER_H_ */
arch/arm/include/asm/arch-socfpga/fpga_manager.h new file +92 -0

92 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/reset_manager.h +8 -0
index 3e95476..eb95c5b 100644
@@ -10,6 +10,14 @@
 void reset_cpu(ulong addr);
 void reset_deassert_peripherals_handoff(void);
 
+void reset_deassert_all_bridges(void);
+void reset_assert_all_bridges(void);
+
+void emac0_reset_enable(uint state);
+void emac1_reset_enable(uint state);
+
+void watchdog_disable(void);
+
 struct socfpga_reset_manager {
 	u32	status;
 	u32	ctrl;
arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h +6 -0
index 2d3152d..39a7874 100644
@@ -7,9 +7,15 @@
 #ifndef _SOCFPGA_BASE_ADDRS_H_
 #define _SOCFPGA_BASE_ADDRS_H_
 
+#define SOCFPGA_EMAC0_ADDRESS 0xff700000
+#define SOCFPGA_EMAC1_ADDRESS 0xff702000
+#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_L4WD0_ADDRESS 0xffd02000
 #define SOCFPGA_CLKMGR_ADDRESS 0xffd04000
arch/arm/include/asm/arch-socfpga/system_manager.h +45 -0

49 lines not on this page · raw message

arch/arm/include/asm/system.h +1 -0
index d51ba66..f0dcbd7 100644
@@ -185,6 +185,7 @@ enum dcache_option {
 	DCACHE_OFF = 0x12,
 	DCACHE_WRITETHROUGH = 0x1a,
 	DCACHE_WRITEBACK = 0x1e,
+	DCACHE_WRITEBACK_WRITEALLOCATE = 0x16,
 };
 
 /* Size of an MMU section */
arch/arm/lib/cache-cp15.c +2 -0
index 3e62d58..3227e5d 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_WRITEBACK_WRITEALLOCATE)
+               set_section_dcache(i, DCACHE_WRITEBACK_WRITEALLOCATE);
 #else
 		set_section_dcache(i, DCACHE_WRITEBACK);
 #endif
board/altera/socfpga/socfpga_cyclone5.c +13 -3
index fb92852..6b74997d 100644
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *  Copyright (C) 2014 Pavel Machek, pavel at denx.de
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -8,8 +9,6 @@
 #include <asm/arch/reset_manager.h>
 #include <asm/io.h>
 
-#include <netdev.h>
-
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
@@ -34,6 +33,17 @@ int board_early_init_f(void)
  */
 int board_init(void)
 {
-	icache_enable();
+	//	icache_enable();
+	puts("derive_clocks_for_drivers... \n");
+#if 1
+	/* calculate the clock frequencies required for drivers */
+	cm_derive_clocks_for_drivers();
+
+	puts("derive_clocks_for_drivers... done\n");
+#endif
+
+	/* adress of boot parameters for ATAG (if ATAG is used) */
+	gd->bd->bi_boot_params = 0x00000100;
+
 	return 0;
 }
common/cmd_fpga.c +4 -1
index 8c5bf44..884c61a 100644
@@ -43,6 +43,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	void *fpga_data = NULL;
 	char *devstr = getenv("fpga");
 	char *datastr = getenv("fpgadata");
+	char *devsizestr = getenv("fpgadatasize");
 	int rc = FPGA_FAIL;
 	int wrong_parms = 0;
 #if defined(CONFIG_FIT)
@@ -57,7 +58,9 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	if (devstr)
 		dev = (int) simple_strtoul(devstr, NULL, 16);
 	if (datastr)
-		fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
+		fpga_data = (void *) simple_strtoul(datastr, NULL, 16);
+	if (devsizestr)
+		data_size = (size_t) simple_strtoul(devsizestr, NULL, 16);
 
 	switch (argc) {
 #if defined(CONFIG_CMD_FPGA_LOADFS)
common/memsize.c +2 -0
index 589400d..0cae738 100644
@@ -33,6 +33,8 @@ long get_ram_size(long *base, long maxsize)
 	long           size;
 	int            i = 0;
 
+	return maxsize;
+
 	for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
 		addr = base + cnt;	/* pointer arith! */
 		sync ();
drivers/fpga/altera.c +26 -0
index 6e34a8e..36d8826 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,18 @@ 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);
+			if (ret_val) {
+				printf("%s: Failed with error code %d\n",
+				__func__, ret_val);
+				ret_val = 1;
+			}
+			break;
+#endif
 		default:
 			printf ("%s: Unsupported family type, %d\n",
 					__FUNCTION__, desc->family);
@@ -94,6 +112,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 +142,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);
drivers/mmc/dw_mmc.c +13 -11
index 0df30bc..4c16e7f 100644
@@ -177,14 +177,16 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 		}
 	}
 
-	if (i == retry)
+	if (i == retry) {
+		printf("dwmci_send_cmd: timeout..\n");
 		return TIMEOUT;
+	}
 
 	if (mask & DWMCI_INTMSK_RTO) {
-		debug("Response Timeout..\n");
+		printf("dwmci_send_cmd: Response Timeout..\n");
 		return TIMEOUT;
 	} else if (mask & DWMCI_INTMSK_RE) {
-		debug("Response Error..\n");
+		printf("dwmci_send_cmd: Response Error..\n");
 		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("dwmci_send_cmd: DATA ERROR!\n");
 				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("dwmci_setup_bus: Didn't get source clock value..\n");
 		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("dwmci_setup_bus: timeout!\n");
 			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("dwmci_setup_bus: timeout!\n");
 			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;
 	}
 
drivers/mmc/socfpga_dw_mmc.c +4 -1
index 1f96382..d8da7f5 100644
@@ -16,6 +16,8 @@ static const struct socfpga_clock_manager *clock_manager_base =
 static const struct socfpga_system_manager *system_manager_base =
 		(void *)SOCFPGA_SYSMGR_ADDRESS;
 
+#define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK (1 << 8)
+
 static void socfpga_dwmci_clksel(struct dwmci_host *host)
 {
 	unsigned int drvsel;
@@ -58,7 +60,8 @@ 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 = cm_sdmmc_clock;
+	printf("bus_hz: %ld\n", host->bus_hz);
 	host->fifoth_val = MSIZE(0x2) |
 		RX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2 - 1) |
 		TX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2);
drivers/net/phy/micrel.c +34 -6
index 5d7e3be..06a31b0 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
  */
@@ -113,17 +112,46 @@ static int ksz9021_phy_extwrite(struct phy_device *phydev, int addr,
 	return ksz9021_phy_extended_write(phydev, regnum, val);
 }
 
+/* FIXME: disable_giga is probably what we want to do */
+
 /* Micrel ksz9021 */
 static int ksz9021_config(struct phy_device *phydev)
 {
 	unsigned ctrl1000 = 0;
 	const unsigned master = CTRL1000_PREFER_MASTER |
-			CTRL1000_CONFIG_MASTER | CTRL1000_MANUAL_CONFIG;
+		CTRL1000_CONFIG_MASTER | CTRL1000_MANUAL_CONFIG;
 	unsigned features = phydev->drv->features;
 
+	printf("ksz9021: configuring\n");
+
+	printf("Configuring PHY skew timing for %s\n",
+	       phydev->drv->name);
+
+	/* min rx data delay */
+	if (ksz9021_phy_extended_write(phydev,
+				       MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW,
+				       getenv_ulong(CONFIG_KSZ9021_DATA_SKEW_ENV, 16,
+						    CONFIG_KSZ9021_DATA_SKEW_VAL)) < 0)
+		return -1;
+	/* min tx data delay */
+	if (ksz9021_phy_extended_write(phydev,
+				       MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW,
+				       getenv_ulong(CONFIG_KSZ9021_DATA_SKEW_ENV, 16,
+						    CONFIG_KSZ9021_DATA_SKEW_VAL)) < 0)
+		return -1;
+	/* max rx/tx clock delay, min rx/tx control */
+	if (ksz9021_phy_extended_write(phydev,
+				       MII_KSZ9021_EXT_RGMII_CLOCK_SKEW,
+				       getenv_ulong(CONFIG_KSZ9021_CLK_SKEW_ENV, 16,
+						    CONFIG_KSZ9021_CLK_SKEW_VAL)) < 0)
+		return -1;
+
+	printf("ksz9021: skew ok\n");
+
+
 	if (getenv("disable_giga"))
 		features &= ~(SUPPORTED_1000baseT_Half |
-				SUPPORTED_1000baseT_Full);
+			      SUPPORTED_1000baseT_Full);
 	/* force master mode for 1000BaseT due to chip errata */
 	if (features & SUPPORTED_1000baseT_Half)
 		ctrl1000 |= ADVERTISE_1000HALF | master;
examples/standalone/Makefile +2 -1
index 2dacba2..163672f 100644
@@ -5,7 +5,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-extra-y        := hello_world
+extra-y        := 
+#extra-y        := hello_world
 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
 extra-$(CONFIG_SMC911X)            += smc911x_eeprom
 extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
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 */
include/configs/axs101.h +0 -1
index c22d6d0..1bf83907 100644
@@ -125,7 +125,6 @@
  */
 #define CONFIG_DESIGNWARE_ETH
 #define CONFIG_DW_AUTONEG
-#define CONFIG_DW_SEARCH_PHY
 #define CONFIG_NET_MULTI
 
 /*
include/configs/socfpga_cyclone5.h +69 -13

168 lines not on this page · raw message

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

Hi Pavel,

Quoted 3 lines · Pavel Machek

Hi!

I know coding style leaves something to be desired.

It is more than this. Also SPDX license headers, etc.

Quoted 5 lines

But.. it recognizes MMC/ethernet, and can load linux kernel.

Unfortunately, 1MB of memory at 0 is not available for some reason; but linux works ok if you avoid that area.

Quoted 9 lines

"fpga load 0" now seems to work.

For some reason, I had to rewrite fpgamgr_axi_write(). There's some bug in assembly version, causing code to get confused after it is executed.

If some ARM expert could take a look, that would be great; bug is likely also present in rocketboards version of u-boot.

I have quickly looked at this patch and there are a lot of things in one patch and it is not possible to even quickly review. Please create patches with proper description and then we can review.

For drivers/fpga/altera.c please look at xilinx wrappers and change altera code based on that. Hopefully you can add all fpga code to drivers/fpga.

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/20140908/5be79fcb/attachment.pgp>
#3 lore raw
In reply to Pavel Machek

Hi Pavel,

Quoted 9 lines · ZY - pavel

Hi!

I know coding style leaves something to be desired.

But.. it recognizes MMC/ethernet, and can load linux kernel.

Unfortunately, 1MB of memory at 0 is not available for some reason; but linux works ok if you avoid that area.

The lowest 1MB region is configurable based on the ARM interconnect NIC-301 / L3REGS setting. I saw in this patch, there is a code which setup the PL310 / L2 controller address filter start address. This code will convert the lowest 1MB region as SDRAM. If the next 1MB memory is working, the lowest 1MB should work too.

At same time, I noticed that the L2 controller address filter start address configuration is done at cpu_eth_init. I am wonder the failure you spotted is happening before this function is called?

Chin Liang

#4 lore raw
In reply to Pavel Machek

Hi Pavel,

Quoted 6 lines · ZY - pavel

Hi!

I know coding style leaves something to be desired.

But.. it recognizes MMC/ethernet, and can load linux kernel.

Quoted 9 lines

Unfortunately, 1MB of memory at 0 is not available for some reason; but linux works ok if you avoid that area.

"fpga load 0" now seems to work.

For some reason, I had to rewrite fpgamgr_axi_write(). There's some bug in assembly version, causing code to get confused after it is executed.

This assembly version works well for me as I got daily test run to test this functionality. We got around 77% improvement using this assembly compared to C code previously. Having that said, probably you can share with me the details of your bug.

Chin Liang

Quoted 5 lines

If some ARM expert could take a look, that would be great; bug is likely also present in rocketboards version of u-boot.

Best regards,
Pavel

#5 lore raw

Hi!

Quoted 14 lines
Quoted 4 lines

I know coding style leaves something to be desired.

But.. it recognizes MMC/ethernet, and can load linux kernel.

Quoted 9 lines

Unfortunately, 1MB of memory at 0 is not available for some reason; but linux works ok if you avoid that area.

"fpga load 0" now seems to work.

For some reason, I had to rewrite fpgamgr_axi_write(). There's some bug in assembly version, causing code to get confused after it is executed.

Quoted 4 lines

This assembly version works well for me as I got daily test run to test this functionality. We got around 77% improvement using this assembly compared to C code previously. Having that said, probably you can share with me the details of your bug.

It seems that if CONFIG_THUMB is enabled (as is in some versions, IIRC), it crashes and burns.

Compared with MMC speed, it seems to be fast enough, but ok, 77% speedup is nice. We have fixed version in tree, Marek will post it soon.

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