public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: socfpga: Add SoCFPGA SR1500 board
Date: Fri, 23 Oct 2015 20:40:51 +0200	[thread overview]
Message-ID: <201510232040.51364.marex@denx.de> (raw)
In-Reply-To: <1445585213-6930-3-git-send-email-sr@denx.de>

On Friday, October 23, 2015 at 09:26:53 AM, Stefan Roese wrote:
> The SR1500

Does SR mean Stefan Roese ? :-)

Anyway, shouldn't you place this device under board/vendorname/boardname
instead of plain board/boardname/ ?

And one more thing, would it be possible for you to do a short README on
adding a new board? That'd be real cool. Obviously, it's not something I
demand or that'd block this patch series, it'd be nice though.

> board is a CycloneV based board, similar to the EBV
> SoCrates, equipped with the following devices:
> 
> - SPI NOR
> - eMMC
> - Ethernet
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Pavel Machek <pavel@denx.de>
> Cc: Dinh Nguyen <dinguyen@opensource.altera.com>

[...]

> +int board_early_init_f(void)
> +{
> +	int ret;
> +
> +	/* Reset the Marvell PHY 88E1510 */
> +	ret = gpio_request(63, "PHY reset");
> +	if (ret)
> +		return ret;
> +
> +	gpio_direction_output(63, 0);
> +	mdelay(20);
> +	gpio_set_value(63, 1);

Does the PHY come out of reset immediatelly after you deassert the nRESET
GPIO or not ? You might want to add a small delay here to bullet-proof the
code a bit more.

> +	return 0;
> +}
> +
> +#define CONFIG_SYS_IDT_CLK_ADDR		0x6a
> +
> +static int do_clksave(cmd_tbl_t *cmdtp, int flag, int argc, char *const
> argv[]) +{
> +	u8 buf[1];
> +
> +	buf[0] = 0x01;
> +	i2c_write(CONFIG_SYS_IDT_CLK_ADDR, 0, 0, buf, 1);
> +
> +	return 0;
> +}
> +
> +U_BOOT_CMD(clksave, 1, 0, do_clksave,
> +	   "IDT 5V49EE702 Progsave command", "");

I am not convinced I should let this slide. Wouldn't it be better to just
have an environment script which sends 0x1 to this IDT Versaclock using the
i2c command ?

> +#define NET_DEV_NAME			"ethernet at ff702000"
> +#define MII_MARVELL_PHY_PAGE		22
> +#define PHY_DIAG_START			(1 << 15)
> +#define PHY_DIAG_BUSY			(1 << 11)
> +
> +static char str[16];

Please move this static var into do_phytest() and pass it into pair_state()
as an argument.

> +static char *pair_state(int val)
> +{
> +	switch (val) {
> +	case 0x00:
> +		strcpy(str, "Invalid");
> +		break;
> +	case 0x01:
> +		strcpy(str, "Pair Ok");
> +		break;
> +	case 0x02:
> +		strcpy(str, "Pair Open");
> +		break;
> +	case 0x03:
> +		strcpy(str, "Same Pair Short");
> +		break;
> +	case 0x04:
> +		strcpy(str, "Cross Pair Short");

Do I count correctly that you do strcpy() here on a string which is 16 byte
long + one trailing '\0' (total 17 bytes) and you strcpy() it into 16 byte
long buffer ? Well that's not good, this will overwrite one byte past the
$str buffer with '\0' :-)

> +		break;
> +	case 0x09:
> +		strcpy(str, "Pair Busy");
> +		break;
> +	default:
> +		strcpy(str, "Reserved");
> +		break;
> +	};
> +
> +	return str;
> +}
> +
> +static int do_phytest(cmd_tbl_t *cmdtp, int flag, int argc, char *const
> argv[]) +{
> +	char devname[] = NET_DEV_NAME;

const char * here ?

> +	int addr = 0;

Looks like unsigned value to me, please make it so.

> +	u16 data;
> +	u16 status;
> +	u16 oldpage;
> +	int i;
> +
> +	/* Save current page register */
> +	miiphy_read(devname, addr, MII_MARVELL_PHY_PAGE, &oldpage);
> +
> +	/*
> +	 * Run cable disgnostics
> +	 */
> +	printf("Running cable diagnostic test...");
> +	miiphy_write(devname, addr, MII_MARVELL_PHY_PAGE, 7);
> +	miiphy_write(devname, addr, 21, PHY_DIAG_START);
> +	miiphy_read(devname, addr, 21, &data);
> +	while ((data & PHY_DIAG_BUSY) == PHY_DIAG_BUSY) {
> +		miiphy_read(devname, addr, 21, &data);
> +		mdelay(1);

Unbounded loop, do I need to say more ? ;-)

> +	}
> +	printf("done!\n");

[...]

> +/* Booting Linux */
> +#define CONFIG_BOOTDELAY	3
> +#define CONFIG_BOOTFILE		"uImage"
> +#define CONFIG_BOOTARGS		"console=ttyS0" 
__stringify(CONFIG_BAUDRATE)
> +#ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET

Do you really need socfpga_vt on your quite certainly physical hardware ?

> +#define CONFIG_BOOTCOMMAND	"run ramboot"
> +#else
> +#define CONFIG_BOOTCOMMAND	"run mmcload; run mmcboot"
> +#endif
> +#define CONFIG_LOADADDR		0x8000
> +#define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
> +#define CONFIG_SYS_CONSOLE_INFO_QUIET	/* don't print console @ startup 
*/
> +
> +/* Ethernet on SoC (EMAC) */
> +#if defined(CONFIG_CMD_NET)
> +#define CONFIG_EMAC_BASE		SOCFPGA_EMAC1_ADDRESS

This EMAC address is certainly not needed now, it should come from OF.

> +#define CONFIG_PHY_INTERFACE_MODE	PHY_INTERFACE_MODE_RGMII
> +/* The PHY is autodetected, so no MII PHY address is needed here */
> +#define CONFIG_PHY_MARVELL
> +#define PHY_ANEG_TIMEOUT	8000
> +#endif
> +
> +/* Extra Environment */
> +#define CONFIG_HOSTNAME		sr1500
> +
> +#define CONFIG_EXTRA_ENV_SETTINGS \
> +	"verify=n\0" \
> +	"loadaddr= " __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
> +	"ramboot=setenv bootargs " CONFIG_BOOTARGS ";" \
> +		"bootm ${loadaddr} - ${fdt_addr}\0" \
> +	"bootimage=zImage\0" \
> +	"fdt_addr=100\0" \
> +	"fdtimage=socfpga.dtb\0" \
> +		"fsloadcmd=ext2load\0" \
> +	"bootm ${loadaddr} - ${fdt_addr}\0" \
> +	"mmcroot=/dev/mmcblk0p2\0" \
> +	"mmcboot=setenv bootargs " CONFIG_BOOTARGS \
> +		" root=${mmcroot} rw rootwait;" \
> +		"bootz ${loadaddr} - ${fdt_addr}\0" \
> +	"mmcload=mmc rescan;" \
> +		"load mmc 0:1 ${loadaddr} ${bootimage};" \
> +		"load mmc 0:1 ${fdt_addr} ${fdtimage}\0" \
> +	"qspiroot=/dev/mtdblock0\0" \
> +	"qspirootfstype=jffs2\0" \
> +	"qspiboot=setenv bootargs " CONFIG_BOOTARGS \
> +		" root=${qspiroot} rw rootfstype=${qspirootfstype};"\
> +		"bootm ${loadaddr} - ${fdt_addr}\0"
> +
> +/* Environment */
> +#define CONFIG_ENV_IS_IN_SPI_FLASH
> +
> +/* Enable SPI NOR flash reset, needed for SPI booting */
> +#define CONFIG_SPI_N25Q256A_RESET
> +
> +/* Environment setting for SPI flash */
> +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
> +#define CONFIG_ENV_SECT_SIZE	(64 * 1024)
> +#define CONFIG_ENV_SIZE		(16 * 1024)
> +#define CONFIG_ENV_OFFSET	(0x00040000)

Parenthesis not needed.

> +#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET +
> CONFIG_ENV_SECT_SIZE) +#define CONFIG_ENV_SPI_BUS	0
> +#define CONFIG_ENV_SPI_CS	0
> +#define CONFIG_ENV_SPI_MODE	SPI_MODE_3
> +#define CONFIG_ENV_SPI_MAX_HZ	CONFIG_SF_DEFAULT_SPEED
> +
> +/* U-Boot payload is stored at offset 0x60000 */
> +#define CONFIG_SYS_SPI_U_BOOT_OFFS	0x60000
> +
> +/*
> + * Bootcounter
> + */
> +#define CONFIG_BOOTCOUNT_LIMIT
> +/* last 2 lwords in OCRAM */
> +#define CONFIG_SYS_BOOTCOUNT_ADDR	0xfffffff8
> +#define CONFIG_SYS_BOOTCOUNT_BE

It might be better to use some scratch registers for this, no ?
Especially since you can get SRAM corruption if you fiddle with
SRAM ECC configuration.

> +/* The rest of the configuration is shared */
> +#include <configs/socfpga_common.h>
> +
> +#endif	/* __CONFIG_SOCFPGA_SR1500_H__ */

  reply	other threads:[~2015-10-23 18:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23  7:26 [U-Boot] [PATCH] arm: socfpga: Allow board specific config values for env Stefan Roese
2015-10-23  7:26 ` [U-Boot] [PATCH] arm: socfpga: Add CONFIG_BUILD_TARGET to socfpga_common.h Stefan Roese
2015-10-23 18:26   ` Marek Vasut
2015-10-23  7:26 ` [U-Boot] [PATCH] arm: socfpga: Add SoCFPGA SR1500 board Stefan Roese
2015-10-23 18:40   ` Marek Vasut [this message]
2015-10-26  8:17     ` Stefan Roese
2015-10-26 20:32       ` Marek Vasut
2015-10-26  8:36   ` [U-Boot] [PATCH v2] " Stefan Roese
2015-10-27 15:29     ` Dinh Nguyen
2015-10-28 17:45     ` Marek Vasut
2015-11-02 12:26     ` [U-Boot] [PATCH v3] " Stefan Roese
2015-11-02 18:44       ` Marek Vasut
2015-11-18 10:06     ` [U-Boot] [PATCH v4] " Stefan Roese
2015-11-19 15:38       ` Pavel Machek
2015-10-23 18:25 ` [U-Boot] [PATCH] arm: socfpga: Allow board specific config values for env Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201510232040.51364.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox