blob: 31cf06d2629bb1ef77a4c29a0301fd0df1498adf [file] [log] [blame]
Simon Horman6dace672013-06-28 13:42:16 +09001/*
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
Laurent Pinchart433aa852014-02-16 22:31:59 +010021#include <linux/dma-mapping.h>
Simon Horman6dace672013-06-28 13:42:16 +090022#include <linux/init.h>
Simon Horman6dace672013-06-28 13:42:16 +090023#include <linux/of_platform.h>
Laurent Pinchart433aa852014-02-16 22:31:59 +010024#include <linux/platform_data/rcar-du.h>
Magnus Damm3fbbcbd2013-11-20 09:02:31 +090025#include <mach/common.h>
Magnus Damm20c61252013-10-17 06:58:19 +090026#include <mach/rcar-gen2.h>
Simon Horman6dace672013-06-28 13:42:16 +090027#include <mach/r8a7790.h>
28#include <asm/mach/arch.h>
Magnus Dammad6ffa02014-06-17 16:47:21 +090029#include "clock.h"
Magnus Dammb6bab122014-06-17 16:47:29 +090030#include "irqs.h"
Simon Horman6dace672013-06-28 13:42:16 +090031
Laurent Pinchart433aa852014-02-16 22:31:59 +010032/* DU */
33static struct rcar_du_encoder_data lager_du_encoders[] = {
34 {
35 .type = RCAR_DU_ENCODER_VGA,
36 .output = RCAR_DU_OUTPUT_DPAD0,
37 }, {
38 .type = RCAR_DU_ENCODER_NONE,
39 .output = RCAR_DU_OUTPUT_LVDS1,
40 .connector.lvds.panel = {
41 .width_mm = 210,
42 .height_mm = 158,
43 .mode = {
44 .clock = 65000,
45 .hdisplay = 1024,
46 .hsync_start = 1048,
47 .hsync_end = 1184,
48 .htotal = 1344,
49 .vdisplay = 768,
50 .vsync_start = 771,
51 .vsync_end = 777,
52 .vtotal = 806,
53 .flags = 0,
54 },
55 },
56 },
57};
58
59static struct rcar_du_platform_data lager_du_pdata = {
60 .encoders = lager_du_encoders,
61 .num_encoders = ARRAY_SIZE(lager_du_encoders),
62};
63
64static const struct resource du_resources[] __initconst = {
65 DEFINE_RES_MEM(0xfeb00000, 0x70000),
66 DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
67 DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
68 DEFINE_RES_IRQ(gic_spi(256)),
69 DEFINE_RES_IRQ(gic_spi(268)),
70 DEFINE_RES_IRQ(gic_spi(269)),
71};
72
73static void __init lager_add_du_device(void)
74{
75 struct platform_device_info info = {
76 .name = "rcar-du-r8a7790",
77 .id = -1,
78 .res = du_resources,
79 .num_res = ARRAY_SIZE(du_resources),
80 .data = &lager_du_pdata,
81 .size_data = sizeof(lager_du_pdata),
82 .dma_mask = DMA_BIT_MASK(32),
83 };
84
85 platform_device_register_full(&info);
86}
87
Magnus Damme6597e02014-03-13 08:36:26 +090088/*
89 * This is a really crude hack to provide clkdev support to platform
90 * devices until they get moved to DT.
91 */
Simon Hormanf71c7722014-03-13 15:29:58 +090092static const struct clk_name clk_names[] __initconst = {
Laurent Pinchart711ee6c2014-04-23 13:15:13 +020093 { "cmt0", "fck", "sh-cmt-48-gen2.0" },
Magnus Damme6597e02014-03-13 08:36:26 +090094 { "du0", "du.0", "rcar-du-r8a7790" },
95 { "du1", "du.1", "rcar-du-r8a7790" },
96 { "du2", "du.2", "rcar-du-r8a7790" },
97 { "lvds0", "lvds.0", "rcar-du-r8a7790" },
98 { "lvds1", "lvds.1", "rcar-du-r8a7790" },
99};
100
Simon Hormanaa5de822014-03-17 11:18:56 +0900101/*
102 * This is a really crude hack to work around core platform clock issues
103 */
104static const struct clk_name clk_enables[] __initconst = {
105 { "ether", NULL, "ee700000.ethernet" },
106 { "msiof1", NULL, "e6e10000.spi" },
Magnus Dammf98b55d2014-03-18 21:52:47 +0900107 { "mmcif1", NULL, "ee220000.mmc" },
Simon Hormanaa5de822014-03-17 11:18:56 +0900108 { "qspi_mod", NULL, "e6b10000.spi" },
Magnus Dammf98b55d2014-03-18 21:52:47 +0900109 { "sdhi0", NULL, "ee100000.sd" },
110 { "sdhi2", NULL, "ee140000.sd" },
Simon Hormanaa5de822014-03-17 11:18:56 +0900111 { "thermal", NULL, "e61f0000.thermal" },
112};
113
Magnus Dammd144f362013-07-08 15:16:46 +0900114static void __init lager_add_standard_devices(void)
Simon Horman6dace672013-06-28 13:42:16 +0900115{
Magnus Damme6597e02014-03-13 08:36:26 +0900116 shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
Simon Hormanaa5de822014-03-17 11:18:56 +0900117 shmobile_clk_workaround(clk_enables, ARRAY_SIZE(clk_enables), true);
Simon Horman6dace672013-06-28 13:42:16 +0900118 r8a7790_add_dt_devices();
Magnus Damm20c61252013-10-17 06:58:19 +0900119 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Laurent Pinchart433aa852014-02-16 22:31:59 +0100120
121 lager_add_du_device();
Simon Horman6dace672013-06-28 13:42:16 +0900122}
123
124static const char *lager_boards_compat_dt[] __initdata = {
Laurent Pinchart1fb68142013-12-11 15:13:58 +0100125 "renesas,lager",
Simon Horman6dace672013-06-28 13:42:16 +0900126 "renesas,lager-reference",
127 NULL,
128};
129
130DT_MACHINE_START(LAGER_DT, "lager")
Magnus Dammad09cb82013-08-29 08:22:07 +0900131 .smp = smp_ops(r8a7790_smp_ops),
Magnus Damm0efd7fa2013-08-08 07:27:01 +0900132 .init_early = r8a7790_init_early,
Magnus Damm50c517d2013-09-12 09:32:49 +0900133 .init_time = rcar_gen2_timer_init,
Simon Horman6dace672013-06-28 13:42:16 +0900134 .init_machine = lager_add_standard_devices,
Magnus Damm3fbbcbd2013-11-20 09:02:31 +0900135 .init_late = shmobile_init_late,
Simon Horman6dace672013-06-28 13:42:16 +0900136 .dt_compat = lager_boards_compat_dt,
137MACHINE_END