brcm63xx: add preliminary support for 3.13
[openwrt.git] / target / linux / brcm63xx / patches-3.13 / 005-MIPS-BCM63XX-add-HSSPI-platform-device-and-register-.patch
1 From ad04c99347cf9e583457f7258e97f0be22fad2ec Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sat, 12 Nov 2011 12:18:26 +0100
4 Subject: [PATCH 4/5] MIPS: BCM63XX: add HSSPI platform device and register it
5
6 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
7 ---
8  arch/mips/bcm63xx/Makefile                         |  4 +-
9  arch/mips/bcm63xx/boards/board_bcm963xx.c          |  3 ++
10  arch/mips/bcm63xx/dev-hsspi.c                      | 47 ++++++++++++++++++++++
11  .../include/asm/mach-bcm63xx/bcm63xx_dev_hsspi.h   |  8 ++++
12  4 files changed, 60 insertions(+), 2 deletions(-)
13  create mode 100644 arch/mips/bcm63xx/dev-hsspi.c
14  create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_hsspi.h
15
16 --- a/arch/mips/bcm63xx/Makefile
17 +++ b/arch/mips/bcm63xx/Makefile
18 @@ -1,7 +1,7 @@
19  obj-y          += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \
20                    setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
21 -                  dev-pcmcia.o dev-rng.o dev-spi.o dev-uart.o dev-wdt.o \
22 -                  dev-usb-usbd.o
23 +                  dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
24 +                  dev-wdt.o dev-usb-usbd.o
25  obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
26  
27  obj-y          += boards/
28 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
29 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
30 @@ -23,6 +23,7 @@
31  #include <bcm63xx_dev_enet.h>
32  #include <bcm63xx_dev_dsp.h>
33  #include <bcm63xx_dev_flash.h>
34 +#include <bcm63xx_dev_hsspi.h>
35  #include <bcm63xx_dev_pcmcia.h>
36  #include <bcm63xx_dev_spi.h>
37  #include <bcm63xx_dev_usb_usbd.h>
38 @@ -915,6 +916,8 @@ int __init board_register_devices(void)
39  
40         bcm63xx_spi_register();
41  
42 +       bcm63xx_hsspi_register();
43 +
44         bcm63xx_flash_register();
45  
46         bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
47 --- /dev/null
48 +++ b/arch/mips/bcm63xx/dev-hsspi.c
49 @@ -0,0 +1,47 @@
50 +/*
51 + * This file is subject to the terms and conditions of the GNU General Public
52 + * License.  See the file "COPYING" in the main directory of this archive
53 + * for more details.
54 + *
55 + * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
56 + */
57 +
58 +#include <linux/init.h>
59 +#include <linux/kernel.h>
60 +#include <linux/platform_device.h>
61 +
62 +#include <bcm63xx_cpu.h>
63 +#include <bcm63xx_dev_hsspi.h>
64 +#include <bcm63xx_regs.h>
65 +
66 +static struct resource spi_resources[] = {
67 +       {
68 +               .start          = -1, /* filled at runtime */
69 +               .end            = -1, /* filled at runtime */
70 +               .flags          = IORESOURCE_MEM,
71 +       },
72 +       {
73 +               .start          = -1, /* filled at runtime */
74 +               .flags          = IORESOURCE_IRQ,
75 +       },
76 +};
77 +
78 +static struct platform_device bcm63xx_hsspi_device = {
79 +       .name           = "bcm63xx-hsspi",
80 +       .id             = 0,
81 +       .num_resources  = ARRAY_SIZE(spi_resources),
82 +       .resource       = spi_resources,
83 +};
84 +
85 +int __init bcm63xx_hsspi_register(void)
86 +{
87 +       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6362())
88 +               return -ENODEV;
89 +
90 +       spi_resources[0].start = bcm63xx_regset_address(RSET_HSSPI);
91 +       spi_resources[0].end = spi_resources[0].start;
92 +       spi_resources[0].end += RSET_HSSPI_SIZE - 1;
93 +       spi_resources[1].start = bcm63xx_get_irq_number(IRQ_HSSPI);
94 +
95 +       return platform_device_register(&bcm63xx_hsspi_device);
96 +}
97 --- /dev/null
98 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_hsspi.h
99 @@ -0,0 +1,8 @@
100 +#ifndef BCM63XX_DEV_HSSPI_H
101 +#define BCM63XX_DEV_HSSPI_H
102 +
103 +#include <linux/types.h>
104 +
105 +int bcm63xx_hsspi_register(void);
106 +
107 +#endif /* BCM63XX_DEV_HSSPI_H */