Re: [PATCHv2] drivers: spi: Add qspi flash controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Alright, so I spent some time looking at the SPI framework and :

On Tue, Jul 02, 2013 at 02:26:39PM +0530, Sourav Poddar wrote:
> +static int dra7xxx_qspi_start_transfer_one(struct spi_master *master,
> +		struct spi_message *m)
> +{
> +	struct dra7xxx_qspi *qspi = spi_master_get_devdata(master);
> +	struct spi_device *spi = m->spi;
> +	struct spi_transfer *t;
> +	int status = 0;
> +	int flags = 0;
> +
> +	/* setup command reg */
> +	qspi->cmd = 0;
> +	qspi->cmd |= QSPI_WLEN(8);

this m->spi->bits_per_word;

> +	qspi->cmd |= QSPI_EN_CS(0);

this should be m->spi->chip_select;

> +	qspi->cmd |= 0xfff;

this will be a little tricky to count... because, I believe it should be
something like:

	int count = 0;

	list_for_each_entry(t, &m->transfers, transfer_list)
		count += t->len;

	frame_length = DIV_ROUND_UP(count, m->spi->bits_per_word);

	/* up to 4096 words */
	frame_length = clamp(frame_length, 4096);

	qspi->cmd |= QSPI_FRAME_LENGTH(DIV_ROUND_UP(count,
			frame_length));

Now, it would've been better if SPI framework would already give us
some sort of total_length field in struct spi_message which would be the
sum of all spi_transfers.

> +	/* setup device control reg */
> +	qspi->dc = 0;
> +
> +	if (spi->mode & SPI_CPHA)
> +		qspi->dc |= QSPI_CKPHA(0);
> +	if (spi->mode & SPI_CPOL)
> +		qspi->dc |= QSPI_CKPOL(0);
> +	if (spi->mode & SPI_CS_HIGH)
> +		qspi->dc |= QSPI_CSPOL(0);

all of these zeroes being passed to these macros should be
m->spi->chip_select

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux