From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by ozlabs.org (Postfix) with ESMTP id 3A892DDDFF for ; Fri, 31 Oct 2008 19:31:35 +1100 (EST) From: Stefan Roese To: Josh Boyer Subject: Re: [PATCH v3] spi: Add PPC4xx SPI driver Date: Fri, 31 Oct 2008 09:31:19 +0100 References: <1225000124-29366-1-git-send-email-sr@denx.de> <20081029145305.GA3676@yoda.jdub.homelinux.org> In-Reply-To: <20081029145305.GA3676@yoda.jdub.homelinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Message-Id: <200810310931.19565.sr@denx.de> Cc: spi-devel-general@lists.sourceforge.net, weo@reccoware.de, linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 > >+#include > >+#include > >+#include > >+#include > >+#include > >+#include > >+#include > >+#include > >+#include > >+ > >+#include > >+#include > >+#include > >+ > >+#include > >+#include > > Should maybe just be Fixed. > >+#include > >+ > > > > >+/* 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; > >+}; > > > > >+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; > >+} > >+ > > > > >+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