[brcm63xx] prepare for SPI controller driver
[openwrt-10.03/.git] / target / linux / brcm63xx / files / arch / mips / bcm63xx / dev-spi.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org> 
7  */
8
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/platform_device.h>
12 #include <bcm63xx_cpu.h>
13 #include <bcm63xx_dev_spi.h>
14
15 static struct resource spi_resources[] = {
16         {
17                 .start          = -1, /* filled at runtime */
18                 .end            = -1, /* filled at runtime */
19                 .flags          = IORESOURCE_MEM,
20         },
21         {
22                 .start          = -1, /* filled at runtime */
23                 .flags          = IORESOURCE_IRQ,
24         },
25 };
26
27 static struct bcm63xx_spi_pdata spi_pdata = {
28         .bus_num                = 0,
29         .num_chipselect         = 4,
30         .speed_hz               = 50000000,     /* Fclk */
31 };
32
33 static struct platform_device bcm63xx_spi_device = {
34         .name           = "bcm63xx_spi",
35         .id             = 0,
36         .num_resources  = ARRAY_SIZE(spi_resources),
37         .resource       = spi_resources,
38         .dev.pdata      = &spi_pdata;
39 };
40
41 int __init bcm63xx_spi_register(void)
42 {
43         spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
44         spi_resources[0].end = spi_resources[0].start;
45         spi_resources[0].end += RSET_SPI_SIZE - 1;
46         spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
47
48         /* Fill in platform data */
49         if (CPU_IS_BCM6338() || CPU_IS_BCM6348()) {
50                 spi_pdata.msg_fifo_size = SPI_BCM_6338_SPI_MSG_DATA_SIZE;
51                 spi_pdata.rx_fifo_size = SPI_BCM_6338_SPI_RX_DATA_SIZE;
52         }
53
54         if (CPU_IS_BCM6358()) {
55                 spi_pdata.msg_fifo_size = SPI_BCM_6358_SPI_MSG_DATA_SIZE;
56                 spi_pdata.rx_fifo_size =  SPI_BCM_6358_SPI_RX_DATA_SIZE;
57         }
58         
59         return platform_device_register(&bcm63xx_spi_device);
60 }