Merge tag 'hwmon-fixes-for-3.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / arch / arm / mach-shmobile / board-marzen.c
1 /*
2  * marzen board support
3  *
4  * Copyright (C) 2011  Renesas Solutions Corp.
5  * Copyright (C) 2011  Magnus Damm
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/irq.h>
25 #include <linux/platform_device.h>
26 #include <linux/delay.h>
27 #include <linux/io.h>
28 #include <linux/gpio.h>
29 #include <linux/dma-mapping.h>
30 #include <linux/smsc911x.h>
31 #include <mach/hardware.h>
32 #include <mach/r8a7779.h>
33 #include <mach/common.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/time.h>
38 #include <asm/hardware/gic.h>
39 #include <asm/traps.h>
40
41 /* SMSC LAN89218 */
42 static struct resource smsc911x_resources[] = {
43         [0] = {
44                 .start          = 0x18000000, /* ExCS0 */
45                 .end            = 0x180000ff, /* A1->A7 */
46                 .flags          = IORESOURCE_MEM,
47         },
48         [1] = {
49                 .start          = gic_spi(28), /* IRQ 1 */
50                 .flags          = IORESOURCE_IRQ,
51         },
52 };
53
54 static struct smsc911x_platform_config smsc911x_platdata = {
55         .flags          = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
56         .phy_interface  = PHY_INTERFACE_MODE_MII,
57         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
58         .irq_type       = SMSC911X_IRQ_TYPE_PUSH_PULL,
59 };
60
61 static struct platform_device eth_device = {
62         .name           = "smsc911x",
63         .id             = 0,
64         .dev  = {
65                 .platform_data = &smsc911x_platdata,
66         },
67         .resource       = smsc911x_resources,
68         .num_resources  = ARRAY_SIZE(smsc911x_resources),
69 };
70
71 static struct platform_device *marzen_devices[] __initdata = {
72         &eth_device,
73 };
74
75 static struct map_desc marzen_io_desc[] __initdata = {
76         /* 2M entity map for 0xf0000000 (MPCORE) */
77         {
78                 .virtual        = 0xf0000000,
79                 .pfn            = __phys_to_pfn(0xf0000000),
80                 .length         = SZ_2M,
81                 .type           = MT_DEVICE_NONSHARED
82         },
83         /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
84         {
85                 .virtual        = 0xfe000000,
86                 .pfn            = __phys_to_pfn(0xfe000000),
87                 .length         = SZ_16M,
88                 .type           = MT_DEVICE_NONSHARED
89         },
90 };
91
92 static void __init marzen_map_io(void)
93 {
94         iotable_init(marzen_io_desc, ARRAY_SIZE(marzen_io_desc));
95 }
96
97 static void __init marzen_init_early(void)
98 {
99         r8a7779_add_early_devices();
100
101         /* Early serial console setup is not included here due to
102          * memory map collisions. The SCIF serial ports in r8a7779
103          * are difficult to entity map 1:1 due to collision with the
104          * virtual memory range used by the coherent DMA code on ARM.
105          *
106          * Anyone wanting to debug early can remove UPF_IOREMAP from
107          * the sh-sci serial console platform data, adjust mapbase
108          * to a static M:N virt:phys mapping that needs to be added to
109          * the mappings passed with iotable_init() above.
110          *
111          * Then add a call to shmobile_setup_console() from this function.
112          *
113          * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
114          * command line.
115          */
116 }
117
118 static void __init marzen_init(void)
119 {
120         r8a7779_pinmux_init();
121
122         /* SCIF2 (CN18: DEBUG0) */
123         gpio_request(GPIO_FN_TX2_C, NULL);
124         gpio_request(GPIO_FN_RX2_C, NULL);
125
126         /* SCIF4 (CN19: DEBUG1) */
127         gpio_request(GPIO_FN_TX4, NULL);
128         gpio_request(GPIO_FN_RX4, NULL);
129
130         /* LAN89218 */
131         gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
132         gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
133
134         r8a7779_add_standard_devices();
135         platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
136 }
137
138 static void __init marzen_timer_init(void)
139 {
140         r8a7779_clock_init();
141         shmobile_timer.init();
142         return;
143 }
144
145 struct sys_timer marzen_timer = {
146         .init   = marzen_timer_init,
147 };
148
149 MACHINE_START(MARZEN, "marzen")
150         .map_io         = marzen_map_io,
151         .init_early     = marzen_init_early,
152         .nr_irqs        = NR_IRQS_LEGACY,
153         .init_irq       = r8a7779_init_irq,
154         .handle_irq     = gic_handle_irq,
155         .init_machine   = marzen_init,
156         .timer          = &marzen_timer,
157 MACHINE_END