Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 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 | |
Laurent Pinchart | 14c5ce1 | 2014-02-16 22:32:01 +0100 | [diff] [blame] | 22 | #include <linux/dma-mapping.h> |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 23 | #include <linux/kernel.h> |
| 24 | #include <linux/of_platform.h> |
Laurent Pinchart | 14c5ce1 | 2014-02-16 22:32:01 +0100 | [diff] [blame] | 25 | #include <linux/platform_data/rcar-du.h> |
Geert Uytterhoeven | 5201b5a | 2014-06-20 18:53:07 +0200 | [diff] [blame] | 26 | |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 27 | #include <asm/mach/arch.h> |
Geert Uytterhoeven | 5201b5a | 2014-06-20 18:53:07 +0200 | [diff] [blame] | 28 | |
Magnus Damm | ad6ffa0 | 2014-06-17 16:47:21 +0900 | [diff] [blame] | 29 | #include "clock.h" |
Magnus Damm | fd44aa5 | 2014-06-17 16:47:37 +0900 | [diff] [blame] | 30 | #include "common.h" |
Magnus Damm | b6bab12 | 2014-06-17 16:47:29 +0900 | [diff] [blame] | 31 | #include "irqs.h" |
Geert Uytterhoeven | 5201b5a | 2014-06-20 18:53:07 +0200 | [diff] [blame] | 32 | #include "r8a7791.h" |
Magnus Damm | 6287298 | 2014-06-17 16:48:01 +0900 | [diff] [blame] | 33 | #include "rcar-gen2.h" |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 34 | |
Laurent Pinchart | 14c5ce1 | 2014-02-16 22:32:01 +0100 | [diff] [blame] | 35 | /* DU */ |
| 36 | static struct rcar_du_encoder_data koelsch_du_encoders[] = { |
| 37 | { |
| 38 | .type = RCAR_DU_ENCODER_NONE, |
| 39 | .output = RCAR_DU_OUTPUT_LVDS0, |
| 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 | |
| 59 | static struct rcar_du_platform_data koelsch_du_pdata = { |
| 60 | .encoders = koelsch_du_encoders, |
| 61 | .num_encoders = ARRAY_SIZE(koelsch_du_encoders), |
| 62 | }; |
| 63 | |
| 64 | static const struct resource du_resources[] __initconst = { |
| 65 | DEFINE_RES_MEM(0xfeb00000, 0x40000), |
| 66 | DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"), |
| 67 | DEFINE_RES_IRQ(gic_spi(256)), |
| 68 | DEFINE_RES_IRQ(gic_spi(268)), |
| 69 | }; |
| 70 | |
| 71 | static void __init koelsch_add_du_device(void) |
| 72 | { |
| 73 | struct platform_device_info info = { |
| 74 | .name = "rcar-du-r8a7791", |
| 75 | .id = -1, |
| 76 | .res = du_resources, |
| 77 | .num_res = ARRAY_SIZE(du_resources), |
| 78 | .data = &koelsch_du_pdata, |
| 79 | .size_data = sizeof(koelsch_du_pdata), |
| 80 | .dma_mask = DMA_BIT_MASK(32), |
| 81 | }; |
| 82 | |
| 83 | platform_device_register_full(&info); |
| 84 | } |
| 85 | |
Magnus Damm | 89aff40 | 2014-03-13 08:36:35 +0900 | [diff] [blame] | 86 | /* |
| 87 | * This is a really crude hack to provide clkdev support to platform |
| 88 | * devices until they get moved to DT. |
| 89 | */ |
Simon Horman | f6f98b3 | 2014-03-13 15:29:57 +0900 | [diff] [blame] | 90 | static const struct clk_name clk_names[] __initconst = { |
Laurent Pinchart | 356af68 | 2014-04-23 13:15:14 +0200 | [diff] [blame] | 91 | { "cmt0", "fck", "sh-cmt-48-gen2.0" }, |
Magnus Damm | 89aff40 | 2014-03-13 08:36:35 +0900 | [diff] [blame] | 92 | { "du0", "du.0", "rcar-du-r8a7791" }, |
| 93 | { "du1", "du.1", "rcar-du-r8a7791" }, |
| 94 | { "lvds0", "lvds.0", "rcar-du-r8a7791" }, |
| 95 | }; |
| 96 | |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 97 | static void __init koelsch_add_standard_devices(void) |
| 98 | { |
Magnus Damm | 89aff40 | 2014-03-13 08:36:35 +0900 | [diff] [blame] | 99 | shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 100 | r8a7791_add_dt_devices(); |
| 101 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
Laurent Pinchart | 14c5ce1 | 2014-02-16 22:32:01 +0100 | [diff] [blame] | 102 | |
| 103 | koelsch_add_du_device(); |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static const char * const koelsch_boards_compat_dt[] __initconst = { |
Laurent Pinchart | 1d2bdbc | 2013-12-11 15:13:59 +0100 | [diff] [blame] | 107 | "renesas,koelsch", |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 108 | "renesas,koelsch-reference", |
| 109 | NULL, |
| 110 | }; |
| 111 | |
| 112 | DT_MACHINE_START(KOELSCH_DT, "koelsch") |
| 113 | .smp = smp_ops(r8a7791_smp_ops), |
Magnus Damm | 7e99497 | 2014-05-12 08:25:27 +0900 | [diff] [blame] | 114 | .init_early = shmobile_init_delay, |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 115 | .init_time = rcar_gen2_timer_init, |
| 116 | .init_machine = koelsch_add_standard_devices, |
Magnus Damm | 6dc00ab | 2013-11-20 12:54:34 +0900 | [diff] [blame] | 117 | .init_late = shmobile_init_late, |
Magnus Damm | 5f65c5b | 2014-06-09 21:38:53 +0900 | [diff] [blame] | 118 | .reserve = rcar_gen2_reserve, |
Magnus Damm | a2baf19 | 2013-10-08 15:30:18 +0900 | [diff] [blame] | 119 | .dt_compat = koelsch_boards_compat_dt, |
| 120 | MACHINE_END |