xref: /OK3568_Linux_fs/kernel/arch/mips/bcm63xx/dev-hsspi.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) 2012 Jonas Gorski <jonas.gorski@gmail.com>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/init.h>
10*4882a593Smuzhiyun #include <linux/kernel.h>
11*4882a593Smuzhiyun #include <linux/platform_device.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <bcm63xx_cpu.h>
14*4882a593Smuzhiyun #include <bcm63xx_dev_hsspi.h>
15*4882a593Smuzhiyun #include <bcm63xx_regs.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun static struct resource spi_resources[] = {
18*4882a593Smuzhiyun 	{
19*4882a593Smuzhiyun 		.start		= -1, /* filled at runtime */
20*4882a593Smuzhiyun 		.end		= -1, /* filled at runtime */
21*4882a593Smuzhiyun 		.flags		= IORESOURCE_MEM,
22*4882a593Smuzhiyun 	},
23*4882a593Smuzhiyun 	{
24*4882a593Smuzhiyun 		.start		= -1, /* filled at runtime */
25*4882a593Smuzhiyun 		.flags		= IORESOURCE_IRQ,
26*4882a593Smuzhiyun 	},
27*4882a593Smuzhiyun };
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun static struct platform_device bcm63xx_hsspi_device = {
30*4882a593Smuzhiyun 	.name		= "bcm63xx-hsspi",
31*4882a593Smuzhiyun 	.id		= 0,
32*4882a593Smuzhiyun 	.num_resources	= ARRAY_SIZE(spi_resources),
33*4882a593Smuzhiyun 	.resource	= spi_resources,
34*4882a593Smuzhiyun };
35*4882a593Smuzhiyun 
bcm63xx_hsspi_register(void)36*4882a593Smuzhiyun int __init bcm63xx_hsspi_register(void)
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun 	if (!BCMCPU_IS_6328() && !BCMCPU_IS_6362())
39*4882a593Smuzhiyun 		return -ENODEV;
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun 	spi_resources[0].start = bcm63xx_regset_address(RSET_HSSPI);
42*4882a593Smuzhiyun 	spi_resources[0].end = spi_resources[0].start;
43*4882a593Smuzhiyun 	spi_resources[0].end += RSET_HSSPI_SIZE - 1;
44*4882a593Smuzhiyun 	spi_resources[1].start = bcm63xx_get_irq_number(IRQ_HSSPI);
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun 	return platform_device_register(&bcm63xx_hsspi_device);
47*4882a593Smuzhiyun }
48