Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org>
0007  * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
0008  */
0009 
0010 #include <linux/init.h>
0011 #include <linux/kernel.h>
0012 #include <linux/export.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/err.h>
0015 #include <linux/clk.h>
0016 
0017 #include <bcm63xx_cpu.h>
0018 #include <bcm63xx_dev_spi.h>
0019 #include <bcm63xx_regs.h>
0020 
0021 static struct resource spi_resources[] = {
0022     {
0023         .start      = -1, /* filled at runtime */
0024         .end        = -1, /* filled at runtime */
0025         .flags      = IORESOURCE_MEM,
0026     },
0027     {
0028         .start      = -1, /* filled at runtime */
0029         .flags      = IORESOURCE_IRQ,
0030     },
0031 };
0032 
0033 static struct platform_device bcm63xx_spi_device = {
0034     .id     = -1,
0035     .num_resources  = ARRAY_SIZE(spi_resources),
0036     .resource   = spi_resources,
0037 };
0038 
0039 int __init bcm63xx_spi_register(void)
0040 {
0041     if (BCMCPU_IS_6328() || BCMCPU_IS_6345())
0042         return -ENODEV;
0043 
0044     spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
0045     spi_resources[0].end = spi_resources[0].start;
0046     spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
0047 
0048     if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
0049         bcm63xx_spi_device.name = "bcm6348-spi",
0050         spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1;
0051     }
0052 
0053     if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() ||
0054         BCMCPU_IS_6368()) {
0055         bcm63xx_spi_device.name = "bcm6358-spi",
0056         spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
0057     }
0058 
0059     return platform_device_register(&bcm63xx_spi_device);
0060 }