From: Stefan Roese <sr@denx.de>
To: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Cc: spi-devel-general@lists.sourceforge.net, weo@reccoware.de,
linuxppc-dev@ozlabs.org
Subject: Re: [PATCH v3] spi: Add PPC4xx SPI driver
Date: Fri, 31 Oct 2008 09:31:19 +0100 [thread overview]
Message-ID: <200810310931.19565.sr@denx.de> (raw)
In-Reply-To: <20081029145305.GA3676@yoda.jdub.homelinux.org>
On Wednesday 29 October 2008, Josh Boyer wrote:
> Looks pretty good. Just a few minor comments/questions below.
Thanks. I also added some comments below.
> Also, do you have a patch for a DTS file that gives an example of how to
> instantiate the SPI stuff in the device tree?
OK, I'll add a DTS patch to the next version.
> >diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c
> >new file mode 100644
> >index 0000000..6f94acc
> >--- /dev/null
> >+++ b/drivers/spi/spi_ppc4xx.c
> >+#include <linux/module.h>
> >+#include <linux/init.h>
> >+#include <linux/sched.h>
> >+#include <linux/errno.h>
> >+#include <linux/wait.h>
> >+#include <linux/of_platform.h>
> >+#include <linux/of_spi.h>
> >+#include <linux/of_gpio.h>
> >+#include <linux/interrupt.h>
> >+#include <linux/delay.h>
> >+
> >+#include <linux/gpio.h>
> >+#include <linux/spi/spi.h>
> >+#include <linux/spi/spi_bitbang.h>
> >+
> >+#include <asm/io.h>
> >+#include <asm/dcr-native.h>
>
> Should maybe just be <asm/dcr.h>
Fixed.
> >+#include <asm/dcr-regs.h>
> >+
>
> <snip>
>
> >+/* SPI Controller driver's private data. */
> >+struct ppc4xx_spi {
> >+ /* bitbang has to be first */
> >+ struct spi_bitbang bitbang;
> >+ struct completion done;
> >+
> >+ u64 mapbase;
> >+ u64 mapsize;
> >+ int irqnum;
> >+ /* need this to set the SPI clock */
> >+ unsigned int opb_freq;
> >+
> >+ /* for transfers */
> >+ int len;
> >+ int count;
> >+ /* data buffers */
> >+ const unsigned char *tx;
> >+ unsigned char *rx;
> >+
> >+ int *gpios;
> >+ unsigned int num_gpios;
> >+
> >+ volatile struct spi_ppc4xx_regs __iomem *regs; /* pointer to the
> > registers */
>
> volatile?
Fixed.
> >+ struct spi_master *master;
> >+ struct device *dev;
> >+};
>
> <snip>
>
> >+static int spi_ppc4xx_txrx(struct spi_device *spi, struct spi_transfer
> > *t) +{
> >+ struct ppc4xx_spi *hw;
> >+ u8 data;
> >+
> >+ dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n",
> >+ t->tx_buf, t->rx_buf, t->len);
> >+
> >+ hw = spi_master_get_devdata(spi->master);
> >+
> >+ hw->tx = t->tx_buf;
> >+ hw->rx = t->rx_buf;
> >+ hw->len = t->len;
> >+ hw->count = 0;
> >+
> >+ /* send the first byte */
> >+ data = hw->tx ? hw->tx[0] : 0;
> >+ out_8(&hw->regs->txd, data);
> >+ out_8(&hw->regs->cr, SPI_PPC4XX_CR_STR);
>
> Maybe iowrite8? Same comment elsewhere.
Why? We use the in_/out_xxx() accessor function for all other 4xx driver as
well.
> >+ wait_for_completion(&hw->done);
> >+
> >+ return hw->count;
> >+}
> >+
>
> <snip>
>
> >+static struct of_device_id spi_ppc4xx_of_match[] = {
> >+ { .compatible = "ibm,spi", },
> >+ {},
> >+};
>
> I'm wondering if that is too generic of a match. In theory,
> IBM could have another SPI controller that isn't for 4xx.
> Maybe "ibm,spi-4xx" ?
Right. I was doing it the same way as already done before, e.g. "ibm,iic". For
the gpio driver we already switched to "ibm,ppc4xx-gpio". So how
about "ibm,ppc4xx-spi"?
Thanks.
Best regards,
Stefan
next prev parent reply other threads:[~2008-10-31 8:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-26 5:48 [PATCH v3] spi: Add PPC4xx SPI driver Stefan Roese
2008-10-29 14:53 ` Josh Boyer
2008-10-30 23:24 ` Jason Hanna
2008-11-21 3:17 ` [spi-devel-general] " David Brownell
2008-10-31 8:31 ` Stefan Roese [this message]
2008-10-31 10:34 ` Josh Boyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200810310931.19565.sr@denx.de \
--to=sr@denx.de \
--cc=jwboyer@linux.vnet.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=weo@reccoware.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).