Linux 3.14.25
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-shmobile / board-koelsch-reference.c
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
22 #include <linux/clk.h>
23 #include <linux/clkdev.h>
24 #include <linux/kernel.h>
25 #include <linux/of_platform.h>
26 #include <mach/common.h>
27 #include <mach/rcar-gen2.h>
28 #include <mach/r8a7791.h>
29 #include <asm/mach/arch.h>
30
31 static void __init koelsch_add_standard_devices(void)
32 {
33 #ifdef CONFIG_COMMON_CLK
34         /*
35          * This is a really crude hack to provide clkdev support to the SCIF
36          * and CMT devices until they get moved to DT.
37          */
38         static const char * const scif_names[] = {
39                 "scifa0", "scifa1", "scifb0", "scifb1", "scifb2", "scifa2",
40                 "scif0", "scif1", "scif2", "scif3", "scif4", "scif5", "scifa3",
41                 "scifa4", "scifa5",
42         };
43         struct clk *clk;
44         unsigned int i;
45
46         for (i = 0; i < ARRAY_SIZE(scif_names); ++i) {
47                 clk = clk_get(NULL, scif_names[i]);
48                 if (clk) {
49                         clk_register_clkdev(clk, NULL, "sh-sci.%u", i);
50                         clk_put(clk);
51                 }
52         }
53
54         clk = clk_get(NULL, "cmt0");
55         if (clk) {
56                 clk_register_clkdev(clk, NULL, "sh_cmt.0");
57                 clk_put(clk);
58         }
59 #else
60         r8a7791_clock_init();
61 #endif
62         r8a7791_add_dt_devices();
63         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
64 }
65
66 static const char * const koelsch_boards_compat_dt[] __initconst = {
67         "renesas,koelsch",
68         "renesas,koelsch-reference",
69         NULL,
70 };
71
72 DT_MACHINE_START(KOELSCH_DT, "koelsch")
73         .smp            = smp_ops(r8a7791_smp_ops),
74         .init_early     = r8a7791_init_early,
75         .init_time      = rcar_gen2_timer_init,
76         .init_machine   = koelsch_add_standard_devices,
77         .init_late      = shmobile_init_late,
78         .dt_compat      = koelsch_boards_compat_dt,
79 MACHINE_END