RE: [Patch V2 1/2] spi: imx: add lpspi bus driver

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

 



From: Mark Brown <mailto:broonie@xxxxxxxxxx> Sent: Thursday, November 17, 2016 1:32 AM
> To: Pandy Gao <pandy.gao@xxxxxxx>
> Cc: robh@xxxxxxxxxx; linux-spi@xxxxxxxxxxxxxxx; Frank Li <frank.li@xxxxxxx>;
> Andy Duan <fugang.duan@xxxxxxx>
> Subject: Re: [Patch V2 1/2] spi: imx: add lpspi bus driver
> 
> On Tue, Nov 15, 2016 at 09:33:50PM +0800, Gao Pan wrote:
> 
> > +static int
> > +fsl_lpspi_prepare_message(struct spi_master *master, struct
> > +spi_message *msg) {
> > +	struct fsl_lpspi_data *fsl_lpspi = spi_master_get_devdata(master);
> > +
> > +	return clk_enable(fsl_lpspi->clk);
> > +}
> 
> Why are we not also unpreparing the clock when the driver is idle?
 
I use clk_enable()  rather than  clk_prepare_enable() here to avoid potential sleeping in runtime cause by clk_prepare().  clk is prepare in fsl_lpspi_probe() and unprepared in fsl_lpspi_remove().

> > +static void fsl_lpspi_copy_to_buf(struct spi_message *m,
> > +					struct fsl_lpspi_data *fsl_lpspi) {
> > +	struct spi_transfer *t;
> > +	u8 *buf = fsl_lpspi->local_buf;
> > +
> > +	list_for_each_entry(t, &m->transfers, transfer_list) {
> > +		if (t->tx_buf)
> > +			memcpy(buf, t->tx_buf, t->len);
> > +		else
> > +			memset(buf, 0, t->len);
> > +		buf += t->len;
> > +	}
> > +}
> 
> Why are we doing this linearization into a single buffer?
 
For a spi  transfer transmitted by lpspi,  the clk for the last bit is incomplete.  The last rising edge never comes unless  we manually de-assert SS.  
In case that a spi message contains multiple transfers, SS should be de-asserted for each transfer.

However, for spi device such as m25p80, SS should keep asserted during a whole message.  So we need do this linearization here.

Thanks!

> > +static int fsl_lpspi_check_message(struct spi_message *m) {
> 
> If there's any checks in here that aren't done by the core then extend the core
> to support them (or drop them).

Due to the limitation of lpspi IP,  all transfers in a message should have same " speed_hz" & " bits_per_word". 
fsl_lpspi_check_message() is used to check the coherence of separate transfers.

This  limitation may not be applicable for other spi.  Do you still think the check should be extend to core?

> > +static int fsl_lpspi_transfer_one_msg(struct spi_master *master,
> > +					struct spi_message *m)
> > +{
> 
> Why are we doing transfer_one_msg() and not transfer_one()?

transfer_one() is used for separate spi transfer, which is not applicable to lpspi. 
Because lpspi need to intergrate all message transfers  into one  transfer. 
 
> 
> > +	m->actual_length = ret ? 0 : trans.len;
> 
> Please write normal if statements, people should be able to read the code.

Thanks, will change it in next version.   

> > +out:
> > +	if (m->status == -EINPROGRESS)
> > +		m->status = ret;
> 
> Why not for other errors?

Should be "m->status = ret" regardless of errors types. Thanks, will change it in next version.

Best  Regards
Gao Pan
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux