Hi Florian,
On Tue, Jan 31, 2012 at 7:40 PM, Florian Fainelli <[email protected]> wrote:
> This patch adds support for the SPI controller found on the Broadcom BCM63xx
> SoCs.
>
> Signed-off-by: Tanguy Bouzeloc <[email protected]>
> Signed-off-by: Florian Fainelli <[email protected]>
> ---
> Changes since v2:
> - reworked bcm63xx_spi_setup_transfer to choose closest spi transfer
> frequency
> - removed invalid 25Mhz frequency
> - fixed some minor checkpatch issues
>
> Changes since v1:
> - switched to the devm_* API which frees resources automatically
> - switched to dev_pm_ops
> - use module_platform_driver
> - remove MODULE_VERSION()
> - fixed return value when clock is not present using PTR_ERR()
> - fixed probe() error path to disable clock in case of failure
>
> drivers/spi/Kconfig | 6 +
> drivers/spi/Makefile | 1 +
> drivers/spi/spi-bcm63xx.c | 486
> +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 493 insertions(+), 0 deletions(-)
> create mode 100644 drivers/spi/spi-bcm63xx.c
>
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index 3f9a47e..16818ac 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -94,6 +94,12 @@ config SPI_AU1550
> If you say yes to this option, support will be included for the
> PSC SPI controller found on Au1550, Au1200 and Au1300 series.
>
> +config SPI_BCM63XX
> + tristate "Broadcom BCM63xx SPI controller"
> + depends on BCM63XX
> + help
> + Enable support for the SPI controller on the Broadcom BCM63xx SoCs.
> +
> config SPI_BITBANG
> tristate "Utilities for Bitbanging SPI masters"
> help
> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> index 61c3261..be38f73 100644
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -14,6 +14,7 @@ obj-$(CONFIG_SPI_ALTERA) += spi-altera.o
> obj-$(CONFIG_SPI_ATMEL) += spi-atmel.o
> obj-$(CONFIG_SPI_ATH79) += spi-ath79.o
> obj-$(CONFIG_SPI_AU1550) += spi-au1550.o
> +obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o
> obj-$(CONFIG_SPI_BFIN) += spi-bfin5xx.o
> obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o
> obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o
> diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
> new file mode 100644
> index 0000000..eba8505
> --- /dev/null
> +++ b/drivers/spi/spi-bcm63xx.c
> @@ -0,0 +1,486 @@
> +/*
> + * Broadcom BCM63xx SPI controller support
> + *
> + * Copyright (C) 2009-2011 Florian Fainelli <[email protected]>
> + * Copyright (C) 2010 Tanguy Bouzeloc <[email protected]>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the
> + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/delay.h>
> +#include <linux/interrupt.h>
> +#include <linux/spi/spi.h>
> +#include <linux/completion.h>
> +#include <linux/err.h>
> +
> +#include <bcm63xx_dev_spi.h>
> +
> +#define PFX KBUILD_MODNAME
> +#define DRV_VER "0.1.2"
> +
> +struct bcm63xx_spi {
> + spinlock_t lock;
> + int stopping;
> + struct completion done;
> +
> + void __iomem *regs;
> + int irq;
> +
> + /* Platform data */
> + u32 speed_hz;
> + unsigned fifo_size;
> +
> + /* Data buffers */
> + const unsigned char *tx_ptr;
> + unsigned char *rx_ptr;
> +
> + /* data iomem */
> + u8 __iomem *tx_io;
> + const u8 __iomem *rx_io;
> +
> + int remaining_bytes;
> +
> + struct clk *clk;
> + struct platform_device *pdev;
> +};
> +
> +static inline u8 bcm_spi_readb(struct bcm63xx_spi *bs,
> + unsigned int offset)
> +{
> + return bcm_readw(bs->regs + bcm63xx_spireg(offset));
are you sure it should be bcm_readw
> +}
> +
> +static inline u16 bcm_spi_readw(struct bcm63xx_spi *bs,
> + unsigned int offset)
> +{
> + return bcm_readw(bs->regs + bcm63xx_spireg(offset));
> +}
> +
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
spi-devel-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general