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