Magnus Damm | 0468b2d | 2013-03-28 00:49:34 +0900 | [diff] [blame] | 1 | /* |
| 2 | * r8a7790 processor support |
| 3 | * |
| 4 | * Copyright (C) 2013 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2013 Magnus Damm |
| 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/irq.h> |
| 22 | #include <linux/irqchip.h> |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/of_platform.h> |
Magnus Damm | 55d9fab | 2013-03-28 00:49:44 +0900 | [diff] [blame] | 25 | #include <linux/serial_sci.h> |
Magnus Damm | 8f5ec0a | 2013-03-28 00:49:54 +0900 | [diff] [blame^] | 26 | #include <linux/platform_data/irq-renesas-irqc.h> |
Magnus Damm | 0468b2d | 2013-03-28 00:49:34 +0900 | [diff] [blame] | 27 | #include <mach/common.h> |
| 28 | #include <mach/irqs.h> |
| 29 | #include <mach/r8a7790.h> |
| 30 | #include <asm/mach/arch.h> |
| 31 | |
Magnus Damm | 55d9fab | 2013-03-28 00:49:44 +0900 | [diff] [blame] | 32 | #define SCIF_COMMON(scif_type, baseaddr, irq) \ |
| 33 | .type = scif_type, \ |
| 34 | .mapbase = baseaddr, \ |
| 35 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ |
| 36 | .irqs = SCIx_IRQ_MUXED(irq) |
| 37 | |
| 38 | #define SCIFA_DATA(index, baseaddr, irq) \ |
| 39 | [index] = { \ |
| 40 | SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \ |
| 41 | .scbrr_algo_id = SCBRR_ALGO_4, \ |
| 42 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \ |
| 43 | } |
| 44 | |
| 45 | #define SCIFB_DATA(index, baseaddr, irq) \ |
| 46 | [index] = { \ |
| 47 | SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \ |
| 48 | .scbrr_algo_id = SCBRR_ALGO_4, \ |
| 49 | .scscr = SCSCR_RE | SCSCR_TE, \ |
| 50 | } |
| 51 | |
| 52 | #define SCIF_DATA(index, baseaddr, irq) \ |
| 53 | [index] = { \ |
| 54 | SCIF_COMMON(PORT_SCIF, baseaddr, irq), \ |
| 55 | .scbrr_algo_id = SCBRR_ALGO_2, \ |
| 56 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \ |
| 57 | } |
| 58 | |
| 59 | enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1 }; |
| 60 | |
| 61 | static const struct plat_sci_port scif[] = { |
| 62 | SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ |
| 63 | SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ |
| 64 | SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ |
| 65 | SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ |
| 66 | SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ |
| 67 | SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */ |
| 68 | SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */ |
| 69 | SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */ |
| 70 | }; |
| 71 | |
| 72 | static inline void r8a7790_register_scif(int idx) |
| 73 | { |
| 74 | platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], |
| 75 | sizeof(struct plat_sci_port)); |
| 76 | } |
| 77 | |
Magnus Damm | 8f5ec0a | 2013-03-28 00:49:54 +0900 | [diff] [blame^] | 78 | static struct renesas_irqc_config irqc0_data = { |
| 79 | .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */ |
| 80 | }; |
| 81 | |
| 82 | static struct resource irqc0_resources[] = { |
| 83 | DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */ |
| 84 | DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */ |
| 85 | DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */ |
| 86 | DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */ |
| 87 | DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */ |
| 88 | }; |
| 89 | |
| 90 | #define r8a7790_register_irqc(idx) \ |
| 91 | platform_device_register_resndata(&platform_bus, "renesas_irqc", \ |
| 92 | idx, irqc##idx##_resources, \ |
| 93 | ARRAY_SIZE(irqc##idx##_resources), \ |
| 94 | &irqc##idx##_data, \ |
| 95 | sizeof(struct renesas_irqc_config)) |
| 96 | |
Magnus Damm | 0468b2d | 2013-03-28 00:49:34 +0900 | [diff] [blame] | 97 | void __init r8a7790_add_standard_devices(void) |
| 98 | { |
Magnus Damm | 55d9fab | 2013-03-28 00:49:44 +0900 | [diff] [blame] | 99 | r8a7790_register_scif(SCIFA0); |
| 100 | r8a7790_register_scif(SCIFA1); |
| 101 | r8a7790_register_scif(SCIFB0); |
| 102 | r8a7790_register_scif(SCIFB1); |
| 103 | r8a7790_register_scif(SCIFB2); |
| 104 | r8a7790_register_scif(SCIFA2); |
| 105 | r8a7790_register_scif(SCIF0); |
| 106 | r8a7790_register_scif(SCIF1); |
Magnus Damm | 8f5ec0a | 2013-03-28 00:49:54 +0900 | [diff] [blame^] | 107 | r8a7790_register_irqc(0); |
Magnus Damm | 0468b2d | 2013-03-28 00:49:34 +0900 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | #ifdef CONFIG_USE_OF |
| 111 | void __init r8a7790_add_standard_devices_dt(void) |
| 112 | { |
| 113 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 114 | } |
| 115 | |
| 116 | static const char *r8a7790_boards_compat_dt[] __initdata = { |
| 117 | "renesas,r8a7790", |
| 118 | NULL, |
| 119 | }; |
| 120 | |
| 121 | DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)") |
| 122 | .init_irq = irqchip_init, |
| 123 | .init_machine = r8a7790_add_standard_devices_dt, |
| 124 | .init_time = shmobile_timer_init, |
| 125 | .dt_compat = r8a7790_boards_compat_dt, |
| 126 | MACHINE_END |
| 127 | #endif /* CONFIG_USE_OF */ |