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
6 * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org>
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>
15 static struct resource spi_resources
[] = {
17 .start
= -1, /* filled at runtime */
18 .end
= -1, /* filled at runtime */
19 .flags
= IORESOURCE_MEM
,
22 .start
= -1, /* filled at runtime */
23 .flags
= IORESOURCE_IRQ
,
27 static struct bcm63xx_spi_pdata spi_pdata
= {
30 .speed_hz
= 50000000, /* Fclk */
33 static struct platform_device bcm63xx_spi_device
= {
34 .name
= "bcm63xx_spi",
36 .num_resources
= ARRAY_SIZE(spi_resources
),
37 .resource
= spi_resources
,
38 .dev
.pdata
= &spi_pdata
;
41 int __init
bcm63xx_spi_register(void)
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
);
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
;
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
;
59 return platform_device_register(&bcm63xx_spi_device
);