xref: /OK3568_Linux_fs/kernel/arch/mips/bcm63xx/dev-spi.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
3*4882a593Smuzhiyun  * License.  See the file "COPYING" in the main directory of this archive
4*4882a593Smuzhiyun  * for more details.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org>
7*4882a593Smuzhiyun  * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/init.h>
11*4882a593Smuzhiyun #include <linux/kernel.h>
12*4882a593Smuzhiyun #include <linux/export.h>
13*4882a593Smuzhiyun #include <linux/platform_device.h>
14*4882a593Smuzhiyun #include <linux/err.h>
15*4882a593Smuzhiyun #include <linux/clk.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include <bcm63xx_cpu.h>
18*4882a593Smuzhiyun #include <bcm63xx_dev_spi.h>
19*4882a593Smuzhiyun #include <bcm63xx_regs.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun static struct resource spi_resources[] = {
22*4882a593Smuzhiyun 	{
23*4882a593Smuzhiyun 		.start		= -1, /* filled at runtime */
24*4882a593Smuzhiyun 		.end		= -1, /* filled at runtime */
25*4882a593Smuzhiyun 		.flags		= IORESOURCE_MEM,
26*4882a593Smuzhiyun 	},
27*4882a593Smuzhiyun 	{
28*4882a593Smuzhiyun 		.start		= -1, /* filled at runtime */
29*4882a593Smuzhiyun 		.flags		= IORESOURCE_IRQ,
30*4882a593Smuzhiyun 	},
31*4882a593Smuzhiyun };
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun static struct platform_device bcm63xx_spi_device = {
34*4882a593Smuzhiyun 	.id		= -1,
35*4882a593Smuzhiyun 	.num_resources	= ARRAY_SIZE(spi_resources),
36*4882a593Smuzhiyun 	.resource	= spi_resources,
37*4882a593Smuzhiyun };
38*4882a593Smuzhiyun 
bcm63xx_spi_register(void)39*4882a593Smuzhiyun int __init bcm63xx_spi_register(void)
40*4882a593Smuzhiyun {
41*4882a593Smuzhiyun 	if (BCMCPU_IS_6328() || BCMCPU_IS_6345())
42*4882a593Smuzhiyun 		return -ENODEV;
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun 	spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
45*4882a593Smuzhiyun 	spi_resources[0].end = spi_resources[0].start;
46*4882a593Smuzhiyun 	spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
49*4882a593Smuzhiyun 		bcm63xx_spi_device.name = "bcm6348-spi",
50*4882a593Smuzhiyun 		spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1;
51*4882a593Smuzhiyun 	}
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun 	if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() ||
54*4882a593Smuzhiyun 		BCMCPU_IS_6368()) {
55*4882a593Smuzhiyun 		bcm63xx_spi_device.name = "bcm6358-spi",
56*4882a593Smuzhiyun 		spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
57*4882a593Smuzhiyun 	}
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun 	return platform_device_register(&bcm63xx_spi_device);
60*4882a593Smuzhiyun }
61