On 02/19/2013 06:38 AM, Laxman Dewangan wrote:+ bits_per_word = t->bits_per_word ? t->bits_per_word :I thought I'd seen patches so this conditional wasn't needed any more;
+ spi->bits_per_word;
isn't t->bit_per_word always set correctly by the SPI core now?
Certainly the existing spi-tegra20-slink.c doesn't seem to have any
conditional here.
A similar comment applies in tegra_spi_read_rx_fifo_to_client_rxbuf()
and tegra_spi_copy_spi_rxbuf_to_client_rxbuf().
+ total_fifo_words = (max_len + 3)/4;Need spaces around /. The same comment applies in some other places;
please search for them. Was checkpatch run? I'm not sure if catches this.
spi-tegra20-slink.c doesn't have that rounding; is just says:
total_fifo_words = max_len / 4;
Is that a bug in the old driver?
+ if (tspi->cur_direction & DATA_DIR_TX) {In spi-tegra20-slink.c, there's a wmb() right between those last two
+ tegra_spi_copy_client_txbuf_to_spi_txbuf(tspi, t);
+ ret = tegra_spi_start_tx_dma(tspi, len);
lines. Is it needed here?
+static int tegra_spi_start_transfer_one(struct spi_device *spi,...
+ struct spi_transfer *t, bool is_first_of_msg,
+ bool is_single_xfer)
+ /* possibly use the hw based chip select */Why "possibly"; the code seems to always use HW chip select.
+ command1 |= SPI_CS_SW_HW;
+ if (spi->mode & SPI_CS_HIGH)
+ command1 |= SPI_CS_SS_VAL;
+ else
+ command1 &= ~SPI_CS_SS_VAL;
+ ret = pm_runtime_get_sync(tspi->dev);In the older Tegra SPI drivers, the PM runtime logic was was of
+ if (ret < 0) {
+ dev_err(tspi->dev, "runtime PM get failed: %d\n", ret);
+ msg->status = ret;
+ spi_finalize_current_message(master);
+ return ret;
+ }
master->{un,}prepare_transfer. I'm curious why it's implemented
differently here.
+ prop = of_get_property(np, "spi-max-frequency", NULL);The following might be better:
+ if (prop)
+ tspi->spi_max_frequency = be32_to_cpup(prop);
if (of_property_read_u32(np, "spi-max-frequency",
&tspi->spi_max_frequency))
tspi->spi_max_frequency = 25000000; /* 25MHz */
(and you can remove the check of !tspi->spi_max_frequency from probe()
then too)
The tegra20 driver use the devm_ioremap_resource() which is new API get added recently. I will change this driver to use this one.
+static int tegra_spi_probe(struct platform_device *pdev)...+ if (!pdev->dev.of_node) {I don't think there's much point checking that; see the Tegra20 SPI
+ dev_err(&pdev->dev, "Driver support DT registration only\n");
+ return -ENODEV;
+ }
cleanup patches I posted a couple days ago.
+ tspi->base = devm_request_and_ioremap(&pdev->dev, r);The existing Tegra20 driver checks if (IS_ERR(tspi->base)) here. Which
+ if (!tspi->base) {
is wrong?
+ tspi->clk = devm_clk_get(&pdev->dev, "spi");Does this HW block use multiple clocks? If not, I think s/"spi"/NULL/
there, just like the Tegra20 driver.
As an overall comment, this driver is textually perhaps 80-90% the same
as spi-tegra20-slink.c. Instead of creating a completely new driver, how
nasty would a unified driver look; one which contained some runtime
conditionals for the register layout and programming differences? It
might be worth looking at, although perhaps it would turn out to be a
crazy mess, so a separate driver really is appropriate.