linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
  • * [PATCH 11/17] spi/atmel_spi: add DT support
           [not found] <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com>
           [not found] ` <1352710357-3265-1-git-send-email-wenyou.yang-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
    @ 2012-11-12  8:52 ` Wenyou Yang
      1 sibling, 0 replies; 13+ messages in thread
    From: Wenyou Yang @ 2012-11-12  8:52 UTC (permalink / raw)
      To: linux-arm-kernel
      Cc: nicolas.ferre, JM.Lin, wenyou.yang,
    	Jean-Christophe PLAGNIOL-VILLARD, devicetree-discuss,
    	spi-devel-general, grant.likely, rob.herring, rob, linux-doc,
    	richard.genoud
    
    From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
    
    The atmel_spi use only gpio for chip select.
    
    Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
    Cc: devicetree-discuss@lists.ozlabs.org
    Cc: spi-devel-general@lists.sourceforge.net
    Cc: grant.likely@secretlab.ca
    Cc: rob.herring@calxeda.com
    Cc: rob@landley.net
    Cc: linux-doc@vger.kernel.org
    Cc: richard.genoud@gmail.com
    ---
    Hi, Richard,
    
    This patches is based on the original patch from Jean-Christophe
    	[PATCH] spi/atmel: add DT support
    and merged the patch from Richard Genoud
    	[PATCH] spi-atmel OF: complete documentation
    
    Could you sign your signature in this patch?
    
    Best Regards,
    Wenyou Yang
    
     .../devicetree/bindings/spi/spi_atmel.txt          |   23 ++++++++++++++++++++
     drivers/spi/spi-atmel.c                            |   21 ++++++++++++++----
     2 files changed, 40 insertions(+), 4 deletions(-)
     create mode 100644 Documentation/devicetree/bindings/spi/spi_atmel.txt
    
    diff --git a/Documentation/devicetree/bindings/spi/spi_atmel.txt b/Documentation/devicetree/bindings/spi/spi_atmel.txt
    new file mode 100644
    index 0000000..20cdc91
    --- /dev/null
    +++ b/Documentation/devicetree/bindings/spi/spi_atmel.txt
    @@ -0,0 +1,23 @@
    +Atmel SPI device
    +
    +Required properties:
    +- compatible : should be "atmel,at91rm9200-spi".
    +- reg: Address and length of the register set for the device
    +- interrupts: Should contain macb interrupt
    +- cs-gpio: Should contain the GPIOs used for chipselect.
    +- dma-mask: device coherent dma mask.
    +
    +spi0: spi@f0000000 {
    +	#address-cells = <1>;
    +	#size-cells = <0>;
    +	compatible = "atmel,at91rm9200-spi";
    +	reg = <0xf0000000 0x100>;
    +	interrupts = <13 4>;
    +	cs-gpios = <&pioA 14 0
    +		    &pioA 7 0 /* conflicts with TXD2 */
    +		    &pioA 1 0 /* conflicts with RXD0 */
    +		    &pioB 3 0 /* conflicts with ERXDV */
    +		   >;
    +	dma-mask = <0xffffffff>;
    +	status = "disabled";
    +};
    diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
    index 7a3613d..0cc347c 100644
    --- a/drivers/spi/spi-atmel.c
    +++ b/drivers/spi/spi-atmel.c
    @@ -20,6 +20,7 @@
     #include <linux/interrupt.h>
     #include <linux/spi/spi.h>
     #include <linux/slab.h>
    +#include <linux/of.h>
     
     #include <asm/io.h>
     #include <mach/board.h>
    @@ -1242,7 +1243,7 @@ static int atmel_spi_setup(struct spi_device *spi)
     	u32			scbr, csr;
     	unsigned int		bits = spi->bits_per_word;
     	unsigned long		bus_hz;
    -	unsigned int		npcs_pin;
    +	int			npcs_pin;
     	int			ret;
     
     	as = spi_master_get_devdata(spi->master);
    @@ -1314,7 +1315,9 @@ static int atmel_spi_setup(struct spi_device *spi)
     	csr |= SPI_BF(DLYBCT, 0);
     
     	/* chipselect must have been muxed as GPIO (e.g. in board setup) */
    -	npcs_pin = (unsigned int)spi->controller_data;
    +	if (!gpio_is_valid(spi->cs_gpio))
    +		spi->cs_gpio = (int)spi->controller_data;
    +	npcs_pin = spi->cs_gpio;
     	asd = spi->controller_state;
     	if (!asd) {
     		asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL);
    @@ -1435,7 +1438,7 @@ static void atmel_spi_cleanup(struct spi_device *spi)
     {
     	struct atmel_spi	*as = spi_master_get_devdata(spi->master);
     	struct atmel_spi_device	*asd = spi->controller_state;
    -	unsigned		gpio = (unsigned) spi->controller_data;
    +	unsigned		gpio = spi->cs_gpio;
     
     	if (!asd)
     		return;
    @@ -1485,7 +1488,8 @@ static int __devinit atmel_spi_probe(struct platform_device *pdev)
     	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
     
     	master->bus_num = pdev->id;
    -	master->num_chipselect = 4;
    +	master->dev.of_node = pdev->dev.of_node;
    +	master->num_chipselect = master->dev.of_node ? 0 : 4;
     	master->setup = atmel_spi_setup;
     	master->transfer = atmel_spi_transfer;
     	master->cleanup = atmel_spi_cleanup;
    @@ -1637,11 +1641,20 @@ static int atmel_spi_resume(struct platform_device *pdev)
     #define	atmel_spi_resume	NULL
     #endif
     
    +#if defined(CONFIG_OF)
    +static const struct of_device_id atmel_spi_dt_ids[] = {
    +	{ .compatible = "atmel,at91rm9200-spi" },
    +	{ /* sentinel */ }
    +};
    +
    +MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids);
    +#endif
     
     static struct platform_driver atmel_spi_driver = {
     	.driver		= {
     		.name	= "atmel_spi",
     		.owner	= THIS_MODULE,
    +		.of_match_table	= of_match_ptr(atmel_spi_dt_ids),
     	},
     	.suspend	= atmel_spi_suspend,
     	.resume		= atmel_spi_resume,
    -- 
    1.7.9.5
    
    
    ^ permalink raw reply related	[flat|nested] 13+ messages in thread

  • end of thread, other threads:[~2012-11-15  9:36 UTC | newest]
    
    Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com>
         [not found] ` <1352710357-3265-1-git-send-email-wenyou.yang-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
    2012-11-12  8:52   ` [PATCH 02/17] of_spi: add generic binding support to specify cs gpio Wenyou Yang
    2012-11-12  8:52   ` [PATCH 03/17] spi/atmel_spi: add physical base address Wenyou Yang
    2012-11-12  8:52   ` [PATCH 04/17] spi/atmel_spi: call unmapping on transfers buffers Wenyou Yang
    2012-11-12  8:52   ` [PATCH 05/17] spi/atmel_spi: status information passed through controller data Wenyou Yang
    2012-11-12  8:52   ` [PATCH 06/17] spi/atmel_spi: add flag to controller data for lock operations Wenyou Yang
         [not found]     ` <1352710357-3265-7-git-send-email-wenyou.yang-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
    2012-11-15  9:36       ` Shubhrajyoti Datta
    2012-11-12  8:52   ` [PATCH 07/17] spi/atmel_spi: add dmaengine support Wenyou Yang
    2012-11-12  8:52   ` [PATCH 08/17] spi/atmel_spi: Fix spi-atmel driver to adapt to slave_config changes Wenyou Yang
    2012-11-12  8:52   ` [PATCH 09/17] spi/atmel_spi: correct 16 bits transfers using PIO Wenyou Yang
    2012-11-12  8:52   ` [PATCH 10/17] spi/atmel_spi: correct 16 bits transfer with DMA Wenyou Yang
    2012-11-12  8:52   ` [PATCH 12/17] spi/atmel_spi: add version propety as the spi data Wenyou Yang
    2012-11-12  8:52   ` [PATCH 13/17] spi/atmel_spi: add function to read the spi data from the dts Wenyou Yang
    2012-11-12  8:52 ` [PATCH 11/17] spi/atmel_spi: add DT support Wenyou Yang
    

    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).