ARM: shmobile: koelsch-reference: Add DU device
[linux-2.6-block.git] / arch / arm / mach-shmobile / board-koelsch-reference.c
CommitLineData
a2baf191
MD
1/*
2 * Koelsch board support - Reference DT implementation
3 *
4 * Copyright (C) 2013 Renesas Electronics Corporation
5 * Copyright (C) 2013 Renesas Solutions Corp.
6 * Copyright (C) 2013 Magnus Damm
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
f31239ef
LP
22#include <linux/clk.h>
23#include <linux/clkdev.h>
14c5ce17 24#include <linux/dma-mapping.h>
a2baf191
MD
25#include <linux/kernel.h>
26#include <linux/of_platform.h>
14c5ce17 27#include <linux/platform_data/rcar-du.h>
6dc00ab9 28#include <mach/common.h>
14c5ce17 29#include <mach/irqs.h>
a2baf191
MD
30#include <mach/rcar-gen2.h>
31#include <mach/r8a7791.h>
32#include <asm/mach/arch.h>
33
14c5ce17
LP
34/* DU */
35static struct rcar_du_encoder_data koelsch_du_encoders[] = {
36 {
37 .type = RCAR_DU_ENCODER_NONE,
38 .output = RCAR_DU_OUTPUT_LVDS0,
39 .connector.lvds.panel = {
40 .width_mm = 210,
41 .height_mm = 158,
42 .mode = {
43 .clock = 65000,
44 .hdisplay = 1024,
45 .hsync_start = 1048,
46 .hsync_end = 1184,
47 .htotal = 1344,
48 .vdisplay = 768,
49 .vsync_start = 771,
50 .vsync_end = 777,
51 .vtotal = 806,
52 .flags = 0,
53 },
54 },
55 },
56};
57
58static struct rcar_du_platform_data koelsch_du_pdata = {
59 .encoders = koelsch_du_encoders,
60 .num_encoders = ARRAY_SIZE(koelsch_du_encoders),
61};
62
63static const struct resource du_resources[] __initconst = {
64 DEFINE_RES_MEM(0xfeb00000, 0x40000),
65 DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
66 DEFINE_RES_IRQ(gic_spi(256)),
67 DEFINE_RES_IRQ(gic_spi(268)),
68};
69
70static void __init koelsch_add_du_device(void)
71{
72 struct platform_device_info info = {
73 .name = "rcar-du-r8a7791",
74 .id = -1,
75 .res = du_resources,
76 .num_res = ARRAY_SIZE(du_resources),
77 .data = &koelsch_du_pdata,
78 .size_data = sizeof(koelsch_du_pdata),
79 .dma_mask = DMA_BIT_MASK(32),
80 };
81
82 platform_device_register_full(&info);
83}
84
a2baf191
MD
85static void __init koelsch_add_standard_devices(void)
86{
f31239ef
LP
87#ifdef CONFIG_COMMON_CLK
88 /*
189ef3d6
LP
89 * This is a really crude hack to provide clkdev support to the CMT and
90 * DU devices until they get moved to DT.
f31239ef 91 */
189ef3d6
LP
92 static const struct clk_name {
93 const char *clk;
94 const char *con_id;
95 const char *dev_id;
96 } clk_names[] = {
97 { "cmt0", NULL, "sh_cmt.0" },
98 { "scifa0", NULL, "sh-sci.0" },
99 { "scifa1", NULL, "sh-sci.1" },
100 { "scifb0", NULL, "sh-sci.2" },
101 { "scifb1", NULL, "sh-sci.3" },
102 { "scifb2", NULL, "sh-sci.4" },
103 { "scifa2", NULL, "sh-sci.5" },
104 { "scif0", NULL, "sh-sci.6" },
105 { "scif1", NULL, "sh-sci.7" },
106 { "scif2", NULL, "sh-sci.8" },
107 { "scif3", NULL, "sh-sci.9" },
108 { "scif4", NULL, "sh-sci.10" },
109 { "scif5", NULL, "sh-sci.11" },
110 { "scifa3", NULL, "sh-sci.12" },
111 { "scifa4", NULL, "sh-sci.13" },
112 { "scifa5", NULL, "sh-sci.14" },
14c5ce17
LP
113 { "du0", "du.0", "rcar-du-r8a7791" },
114 { "du1", "du.1", "rcar-du-r8a7791" },
115 { "lvds0", "lvds.0", "rcar-du-r8a7791" },
f31239ef
LP
116 };
117 struct clk *clk;
118 unsigned int i;
119
189ef3d6
LP
120 for (i = 0; i < ARRAY_SIZE(clk_names); ++i) {
121 clk = clk_get(NULL, clk_names[i].clk);
ca118752 122 if (!IS_ERR(clk)) {
189ef3d6
LP
123 clk_register_clkdev(clk, clk_names[i].con_id,
124 clk_names[i].dev_id);
f31239ef
LP
125 clk_put(clk);
126 }
127 }
f31239ef 128#else
a2baf191 129 r8a7791_clock_init();
6d75bc64 130#endif
a2baf191
MD
131 r8a7791_add_dt_devices();
132 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
14c5ce17
LP
133
134 koelsch_add_du_device();
a2baf191
MD
135}
136
137static const char * const koelsch_boards_compat_dt[] __initconst = {
1d2bdbc3 138 "renesas,koelsch",
a2baf191
MD
139 "renesas,koelsch-reference",
140 NULL,
141};
142
143DT_MACHINE_START(KOELSCH_DT, "koelsch")
144 .smp = smp_ops(r8a7791_smp_ops),
145 .init_early = r8a7791_init_early,
146 .init_time = rcar_gen2_timer_init,
147 .init_machine = koelsch_add_standard_devices,
6dc00ab9 148 .init_late = shmobile_init_late,
a2baf191
MD
149 .dt_compat = koelsch_boards_compat_dt,
150MACHINE_END