[U-Boot-Users] [PATCH] 83xx: Add Vitesse VSC7385 firmware uploading

Kim Phillips kim.phillips at freescale.com
Thu Feb 7 23:29:10 CET 2008


On Wed,  6 Feb 2008 13:19:25 -0600
Timur Tabi <timur at freescale.com> wrote:

> The Vitesse VSC7385 is a 5-port switch found on the Freescale MPC8349E-mITX
> and other boards.  A small firwmare must be uploaded to its on-board memory
> before it can be enabled.  This patch adds the code which uploads firmware
> (but not the firmware itself) and updates the MPC8349E-mITX, MPC8313E-RDB,
> and MPC837XE-RDB boards to use that code.
> 
> Previously, this feature was provided by a U-Boot application that was
> made available only on Freescale BSPs.  The VSC7385 firmware must still
> be obtained separately, but at least there is no longer a need for a separate
> application.

I'd prefer firmware uploading bits remain apps (perhaps in examples/?)
but I don't know the "U-Boot Philosophy" for this area..

> 
> Changed CONFIG_VSC7385 to CONFIG_VSC7385_ENET.  Also cleaned up the board
> header files to make selecting the VSC7385 easier to control.
> 
> Signed-off-by: Timur Tabi <timur at freescale.com>
> ---
> 
> This patch is for U-Boot 1.3.3
> 
>  board/freescale/mpc8313erdb/mpc8313erdb.c |   21 ++++++
>  board/freescale/mpc8349itx/mpc8349itx.c   |   15 ++++-
>  board/freescale/mpc837xerdb/mpc837xerdb.c |   27 ++++++--
>  drivers/net/Makefile                      |    1 +
>  drivers/net/vsc7385.c                     |  100 +++++++++++++++++++++++++++++
>  include/configs/MPC8313ERDB.h             |   88 +++++++++++++++++--------
>  include/configs/MPC8349ITX.h              |   33 +++++++---
>  include/configs/MPC837XERDB.h             |   83 ++++++++++++++++--------
>  include/vsc7385.h                         |   13 ++++
>  9 files changed, 310 insertions(+), 71 deletions(-)
>  create mode 100644 drivers/net/vsc7385.c
>  create mode 100644 include/vsc7385.h

drivers/net bits go through net maintainer, Ben Warren (separate patch).

> diff --git a/drivers/net/vsc7385.c b/drivers/net/vsc7385.c
> new file mode 100644
> index 0000000..39b077f
> --- /dev/null
> +++ b/drivers/net/vsc7385.c
> @@ -0,0 +1,100 @@
> +/*
> + * Vitesse 7385 Switch Firmware Upload
> + *
> + * Author: Timur Tabi <timur at freescale.com>
> + *
> + * Copyright 2008 Freescale Semiconductor, Inc.  This file is licensed
> + * under the terms of the GNU General Public License version 2.  This
> + * program is licensed "as is" without any warranty of any kind, whether
> + * express or implied.
> + *
> + * This module uploads proprietary firmware for the Vitesse VSC7385 5-port
> + * switch.
> + */
> +
> +#include <config.h>
> +#include <common.h>
> +#include <asm/io.h>
> +#include <asm/errno.h>

This breaks some archs.

> +
> +#ifdef CONFIG_VSC7385_ENET
> +
> +/*
> + * Upload a Vitesse VSC7385 firmware image to the hardware
> + *
> + * This function takes a pointer to a VSC7385 firmware image and a size, and
> + * uploads that firmware to the VSC7385.
> + *
> + * This firmware is typically located at a board-specific flash address,
> + * and the size is typically 8KB.
> + *
> + * The firmware is Vitesse proprietary.
> + *
> + * Further details on the register information can be obtained from Vitesse.
> + */
> +int vsc7385_upload_firmware(void *firmware, unsigned int size)
> +{
> +	u8 *fw = firmware;
> +
> +	u32 *gloreset = (u32 *) (CFG_VSC7385_BASE + 0x1c050);
> +	u32 *icpu_ctrl = (u32 *) (CFG_VSC7385_BASE + 0x1c040);
> +	u32 *icpu_addr = (u32 *) (CFG_VSC7385_BASE + 0x1c044);
> +	u32 *icpu_data = (u32 *) (CFG_VSC7385_BASE + 0x1c048);
> +	u32 *chipid = (u32 *) (CFG_VSC7385_BASE + 0x1c060);
> +	u32 *icpu_rom_map = (u32 *) (CFG_VSC7385_BASE + 0x1c070);
> +
> +	unsigned int i;
> +	int ret = 0;
> +
> +	out_be32(gloreset, 3);
> +	udelay(200);
> +
> +	out_be32(icpu_ctrl, 142);
> +	udelay(20);
> +
> +	out_be32(icpu_rom_map, 1);
> +	udelay(20);
> +
> +        /* Write the firmware to I-RAM */
> +	out_be32(icpu_addr, 0);
> +	udelay(20);
> +
> +	for (i = 0; i < size; i++) {
> +		out_be32(icpu_data, fw[i]);
> +		udelay(20);
> +		if (ctrlc())
> +			return -EINTR;
> +	}
> +
> +	/* Read back and compare */
> +	out_be32(icpu_addr, 0);
> +	udelay(20);
> +
> +	for (i = 0; i < size; i++) {
> +		u8 value;
> +
> +		value = (u8) in_be32(icpu_data);
> +		udelay(20);
> +		if (value != fw[i]) {
> +			debug("VSC7385: Upload mismatch: address 0x%x, "
> +                              "read value 0x%x, image value 0x%x\n",
> +                              i, value, fw[i]);
> +
> +			return -EIO;
> +		}
> +		if (ctrlc())
> +			break;
> +	}
> +
> +	out_be32(icpu_ctrl, 11);
> +	udelay(20);
> +
> +#ifdef DEBUG
> +	printf("VSC7385: Chip ID is %08x\n", in_be32(chipid));
> +	udelay(20);
> +#endif
> +
> +	return 0;
> +}
> +
> +#endif

who is the original author of this code?

Kim




More information about the U-Boot mailing list