Merge branch 'async-scsi-resume' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / arch / arm / mach-shmobile / board-lager-reference.c
1 /*
2  * Lager board support - Reference DT implementation
3  *
4  * Copyright (C) 2013  Renesas Solutions Corp.
5  * Copyright (C) 2013  Simon Horman
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/clk.h>
22 #include <linux/clkdev.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/init.h>
25 #include <linux/of_platform.h>
26 #include <linux/platform_data/rcar-du.h>
27 #include <mach/common.h>
28 #include <mach/irqs.h>
29 #include <mach/rcar-gen2.h>
30 #include <mach/r8a7790.h>
31 #include <asm/mach/arch.h>
32
33 /* DU */
34 static struct rcar_du_encoder_data lager_du_encoders[] = {
35         {
36                 .type = RCAR_DU_ENCODER_VGA,
37                 .output = RCAR_DU_OUTPUT_DPAD0,
38         }, {
39                 .type = RCAR_DU_ENCODER_NONE,
40                 .output = RCAR_DU_OUTPUT_LVDS1,
41                 .connector.lvds.panel = {
42                         .width_mm = 210,
43                         .height_mm = 158,
44                         .mode = {
45                                 .clock = 65000,
46                                 .hdisplay = 1024,
47                                 .hsync_start = 1048,
48                                 .hsync_end = 1184,
49                                 .htotal = 1344,
50                                 .vdisplay = 768,
51                                 .vsync_start = 771,
52                                 .vsync_end = 777,
53                                 .vtotal = 806,
54                                 .flags = 0,
55                         },
56                 },
57         },
58 };
59
60 static struct rcar_du_platform_data lager_du_pdata = {
61         .encoders = lager_du_encoders,
62         .num_encoders = ARRAY_SIZE(lager_du_encoders),
63 };
64
65 static const struct resource du_resources[] __initconst = {
66         DEFINE_RES_MEM(0xfeb00000, 0x70000),
67         DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
68         DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
69         DEFINE_RES_IRQ(gic_spi(256)),
70         DEFINE_RES_IRQ(gic_spi(268)),
71         DEFINE_RES_IRQ(gic_spi(269)),
72 };
73
74 static void __init lager_add_du_device(void)
75 {
76         struct platform_device_info info = {
77                 .name = "rcar-du-r8a7790",
78                 .id = -1,
79                 .res = du_resources,
80                 .num_res = ARRAY_SIZE(du_resources),
81                 .data = &lager_du_pdata,
82                 .size_data = sizeof(lager_du_pdata),
83                 .dma_mask = DMA_BIT_MASK(32),
84         };
85
86         platform_device_register_full(&info);
87 }
88
89 static void __init lager_add_standard_devices(void)
90 {
91         /*
92          * This is a really crude hack to provide clkdev support to platform
93          * devices until they get moved to DT.
94          */
95         static const struct clk_name {
96                 const char *clk;
97                 const char *con_id;
98                 const char *dev_id;
99         } clk_names[] = {
100                 { "cmt0", NULL, "sh_cmt.0" },
101                 { "scifa0", NULL, "sh-sci.0" },
102                 { "scifa1", NULL, "sh-sci.1" },
103                 { "scifb0", NULL, "sh-sci.2" },
104                 { "scifb1", NULL, "sh-sci.3" },
105                 { "scifb2", NULL, "sh-sci.4" },
106                 { "scifa2", NULL, "sh-sci.5" },
107                 { "scif0", NULL, "sh-sci.6" },
108                 { "scif1", NULL, "sh-sci.7" },
109                 { "hscif0", NULL, "sh-sci.8" },
110                 { "hscif1", NULL, "sh-sci.9" },
111                 { "du0", "du.0", "rcar-du-r8a7790" },
112                 { "du1", "du.1", "rcar-du-r8a7790" },
113                 { "du2", "du.2", "rcar-du-r8a7790" },
114                 { "lvds0", "lvds.0", "rcar-du-r8a7790" },
115                 { "lvds1", "lvds.1", "rcar-du-r8a7790" },
116         };
117         struct clk *clk;
118         unsigned int i;
119
120         for (i = 0; i < ARRAY_SIZE(clk_names); ++i) {
121                 clk = clk_get(NULL, clk_names[i].clk);
122                 if (!IS_ERR(clk)) {
123                         clk_register_clkdev(clk, clk_names[i].con_id,
124                                             clk_names[i].dev_id);
125                         clk_put(clk);
126                 }
127         }
128
129         r8a7790_add_dt_devices();
130         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
131
132         lager_add_du_device();
133 }
134
135 static const char *lager_boards_compat_dt[] __initdata = {
136         "renesas,lager",
137         "renesas,lager-reference",
138         NULL,
139 };
140
141 DT_MACHINE_START(LAGER_DT, "lager")
142         .smp            = smp_ops(r8a7790_smp_ops),
143         .init_early     = r8a7790_init_early,
144         .init_time      = rcar_gen2_timer_init,
145         .init_machine   = lager_add_standard_devices,
146         .init_late      = shmobile_init_late,
147         .dt_compat      = lager_boards_compat_dt,
148 MACHINE_END