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>
13 #include <bcm63xx_cpu.h>
14 #include <bcm63xx_dev_spi.h>
15 #include <bcm63xx_regs.h>
17 static struct resource spi_resources[] = {
19 .start = -1, /* filled at runtime */
20 .end = -1, /* filled at runtime */
21 .flags = IORESOURCE_MEM,
24 .start = -1, /* filled at runtime */
25 .flags = IORESOURCE_IRQ,
29 static struct bcm63xx_spi_pdata spi_pdata = {
32 .speed_hz = 50000000, /* Fclk */
35 static struct platform_device bcm63xx_spi_device = {
36 .name = "bcm63xx_spi",
38 .num_resources = ARRAY_SIZE(spi_resources),
39 .resource = spi_resources,
41 .platform_data = &spi_pdata,
45 int __init bcm63xx_spi_register(void)
47 spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
48 spi_resources[0].end = spi_resources[0].start;
49 spi_resources[0].end += RSET_SPI_SIZE - 1;
50 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
52 /* Fill in platform data */
53 if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
54 spi_pdata.msg_fifo_size = SPI_BCM_6338_SPI_MSG_DATA_SIZE;
55 spi_pdata.rx_fifo_size = SPI_BCM_6338_SPI_RX_DATA_SIZE;
58 if (BCMCPU_IS_6358()) {
59 spi_pdata.msg_fifo_size = SPI_BCM_6358_SPI_MSG_DATA_SIZE;
60 spi_pdata.rx_fifo_size = SPI_BCM_6358_SPI_RX_DATA_SIZE;
63 return platform_device_register(&bcm63xx_spi_device);