[U-Boot] [PATCH 1/2] powerpc: eSPI and eSPI controller support

Mike Frysinger vapier at gentoo.org
Wed Mar 16 05:05:19 CET 2011


On Tuesday, March 15, 2011 22:53:20 Shaohui Xie wrote:
> --- a/drivers/mtd/spi/spi_flash.c
> +++ b/drivers/mtd/spi/spi_flash.c
> @@ -1,6 +1,8 @@
>  /*
>   * SPI flash interface
> + * Add support for Freescale eSPI controller

this is not the place for changelogs

> @@ -30,6 +32,7 @@ static int spi_flash_read_write(struct spi_slave *spi,
>  	unsigned long flags = SPI_XFER_BEGIN;
>  	int ret;
> 
> +#ifndef CONFIG_FSL_ESPI
>  	if (data_len == 0)
>  		flags |= SPI_XFER_END;
> 
> @@ -43,6 +46,48 @@ static int spi_flash_read_write(struct spi_slave *spi,
>  			debug("SF: Failed to transfer %zu bytes of data: %d\n",
>  					data_len, ret);
>  	}
> +#else
> +	struct espi_transfer transfer[1];
> +	unsigned char *buffer;
> +	size_t buf_len;
> +
> +	if (data_in == NULL)
> +		buf_len = cmd_len;
> +	else
> +		buf_len = 2 * cmd_len;
> +
> +	buffer = (unsigned char *)malloc(data_len + buf_len);
> +	if (!buffer) {
> +		debug("SF: Failed to malloc memory.\n");
> +		return 1;
> +	}
> +
> +	memcpy(buffer, cmd, cmd_len);
> +	if (data_in == NULL)
> +		memcpy(buffer + cmd_len, data_out, data_len);
> +
> +	transfer[0].cmd_len = cmd_len;
> +	transfer[0].data_len = data_len;
> +	transfer[0].tx_buf = buffer;
> +	if (data_in == NULL)
> +		transfer[0].rx_buf = NULL;
> +	else
> +		transfer[0].rx_buf = buffer + cmd_len;
> +
> +	transfer[0].flags = flags | SPI_XFER_END;
> +
> +	spi->transfer = &transfer[0];
> +	ret = spi_xfer(spi, 0, NULL, NULL, 0);
> +	if (ret) {
> +		debug("SF: Failed to send command %02x: %d\n", cmd, ret);
> +		return ret;
> +	}
> +
> +	if (data_in)
> +		memcpy(data_in, transfer[0].rx_buf + cmd_len, data_len);
> +
> +	free(buffer);
> +#endif
> 
>  	return ret;
>  }

yikes, this cant be right
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110316/6655c995/attachment.pgp 


More information about the U-Boot mailing list