From: Gabor Juhos <juhosg@openwrt.org>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Ralf Baechle <ralf@linux-mips.org>,
linux-mips@linux-mips.org,
David Brownell <dbrownell@users.sourceforge.net>,
"Luis R. Rodriguez" <lrodriguez@atheros.com>,
Cliff Holden <Cliff.Holden@Atheros.com>,
Kathy Giori <Kathy.Giori@Atheros.com>,
spi-devel-general@lists.sourceforge.net,
Imre Kaloz <kaloz@openwrt.org>
Subject: Re: [PATCH v4 09/16] spi: add SPI controller driver for the Atheros AR71XX/AR724X/AR913X SoCs
Date: Tue, 04 Jan 2011 13:56:39 +0100 [thread overview]
Message-ID: <4D231907.8070302@openwrt.org> (raw)
In-Reply-To: <20110103170211.GA2522@angua.secretlab.ca>
2011.01.03. 18:02 keltezéssel, Grant Likely írta:
> On Sun, Jan 02, 2011 at 07:56:22PM +0100, Gabor Juhos wrote:
>> The Atheros AR71XX/AR724X/AR913X SoCs have a built-in SPI controller. This
>> patch implements a driver for that.
>>
>
> Mostly looks okay to me. A few comments below. Do you want this one
> merged via my spi tree, or does it depend on other patches in this
> series? I'm also okay with it going in with the rest of this series.
The driver won't be usable without the preceding patches in the series.
Additionally, further patches depends on this one so it should go via the MIPS tree.
> After addressing comments, feel free to add:
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
Thank you!
>> <...>
>> +struct ath79_spi {
>> + struct spi_bitbang bitbang;
>> + u32 ioc_base;
>> + u32 reg_ctrl;
>> +
>> + void __iomem *base;
>> +
>> + struct platform_device *pdev;
>
> This field doesn't seem to actually be used anywhere.
True, i will remove that.
>
>> +};
>> +
>> +static inline u32 ath79_spi_rr(struct ath79_spi *sp, unsigned reg)
>> +{
>> + return ioread32(sp->base + reg);
>> +}
>> +
>> +static inline void ath79_spi_wr(struct ath79_spi *sp, unsigned reg, u32 val)
>> +{
>> + iowrite32(val, sp->base + reg);
>> +}
>> +
>> +static inline struct ath79_spi *spidev_to_sp(struct spi_device *spi)
>
> should be ath79_spidev_to_sp()
Ok.
>
>> +{
>> + return spi_master_get_devdata(spi->master);
>> +}
>> +
>> +static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
>> +{
>> + struct ath79_spi *sp = spidev_to_sp(spi);
>> + int cs_high = (spi->mode & SPI_CS_HIGH) ? is_active : !is_active;
>> +
>> + if (is_active) {
>> + /* set initial clock polarity */
>> + if (spi->mode & SPI_CPOL)
>> + sp->ioc_base |= AR71XX_SPI_IOC_CLK;
>> + else
>> + sp->ioc_base &= ~AR71XX_SPI_IOC_CLK;
>> +
>> + ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
>> + }
>> +
>> + if (spi->chip_select) {
>> + unsigned long gpio = (unsigned long) spi->controller_data;
>> +
>> + /* SPI is normally active-low */
>> + gpio_set_value(gpio, cs_high);
>> + } else {
>> + if (cs_high)
>> + sp->ioc_base |= AR71XX_SPI_IOC_CS0;
>> + else
>> + sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
>> +
>> + ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
>> + }
>> +
>> +}
>> +
>> +static int ath79_spi_setup_cs(struct spi_device *spi)
>> +{
>> + struct ath79_spi *sp = spidev_to_sp(spi);
>> +
>> + /* enable GPIO mode */
>> + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
>> +
>> + /* save CTRL register */
>> + sp->reg_ctrl = ath79_spi_rr(sp, AR71XX_SPI_REG_CTRL);
>> + sp->ioc_base = ath79_spi_rr(sp, AR71XX_SPI_REG_IOC);
>> +
>> + /* TODO: setup speed? */
>> + ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43);
>> +
>> + if (spi->chip_select) {
>> + unsigned long gpio = (unsigned long) spi->controller_data;
>
> Casting here is bad practice.
It seems that the spi-gpio driver was a bad example. :)
> It would be better to have an explicit ath97_spi_controller_data structure.
I will add the explicit structure. Expect an updated version soon.
Thanks,
Gabor
next prev parent reply other threads:[~2011-01-04 12:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-02 18:56 [PATCH v4 00/16] MIPS: initial support for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 01/16] MIPS: add initial support for the Atheros AR71XX/AR724X/AR931X SoCs Gabor Juhos
2011-01-02 20:43 ` Florian Fainelli
2011-01-03 19:35 ` Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 02/16] MIPS: ath79: add GPIOLIB support Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 03/16] MIPS: ath79: utilize the MIPS multi-machine support Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 04/16] MIPS: ath79: add initial support for the Atheros PB44 reference board Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 05/16] MIPS: ath79: add common GPIO LEDs device Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 06/16] watchdog: add driver for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 07/16] MIPS: ath79: add common watchdog device Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 08/16] MIPS: ath79: add common GPIO buttons device Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 09/16] spi: add SPI controller driver for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2011-01-02 18:56 ` Gabor Juhos
2011-01-03 17:02 ` Grant Likely
2011-01-03 17:02 ` Grant Likely
2011-01-04 12:56 ` Gabor Juhos [this message]
2011-01-02 18:56 ` [PATCH v4 10/16] MIPS: ath79: add common SPI controller device Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 11/16] USB: ehci: add workaround for Synopsys HC bug Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 12/16] USB: ehci: add bus glue for the Atheros AR71XX/AR724X/AR913X SoCs Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 13/16] USB: ohci: add bus glue for the Atheros AR71XX/AR7240 SoCs Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 14/16] MIPS: ath79: add common USB Host Controller device Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 15/16] MIPS: ath79: add initial support for the Atheros AP81 reference board Gabor Juhos
2011-01-02 18:56 ` [PATCH v4 16/16] MIPS: ath79: add common WMAC device for AR913X based boards Gabor Juhos
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=4D231907.8070302@openwrt.org \
--to=juhosg@openwrt.org \
--cc=Cliff.Holden@Atheros.com \
--cc=Kathy.Giori@Atheros.com \
--cc=dbrownell@users.sourceforge.net \
--cc=grant.likely@secretlab.ca \
--cc=kaloz@openwrt.org \
--cc=linux-mips@linux-mips.org \
--cc=lrodriguez@atheros.com \
--cc=ralf@linux-mips.org \
--cc=spi-devel-general@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.