aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2014-01-02 13:35:25 -0500
committerOlof Johansson <olof@lixom.net>2014-01-02 13:35:25 -0500
commitc655479ab89cfad17a773cb55b57199c19f65e9b (patch)
treee2219efc6293053fe89e42ceaf248bcbb9744cab
parent63df151aa1037e4f4e71ec009a3b233ee2cc1dea (diff)
parentd85bcfa916ffdf078f188aeab60f738b290f4309 (diff)
Merge tag 'renesas-soc3-for-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into next/soc
From Simon Horman: Third Round of Renesas ARM Based SoC Updates for v3.14 * Global - Don't set plat_sci_port scbrr_algo_id field - Declare SCIF register base and IRQ as resources - Don't define SCIF platform data in an array - Use macros to declare SCIF devices * r7s72100 SoC (RZ/A1H) - Add i2c clocks * r8a7778 (R-Car M1) - Add sound SCU clock support * tag 'renesas-soc3-for-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas: (43 commits) arm: shmobile: r7s72100: add i2c clocks ARM: shmobile: r8a7791: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a7779: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a7790: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a7740: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a73a4: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a7778: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r7s72100: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: sh73a0: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a7790: Declare SCIF register base and IRQ as resources ARM: shmobile: r8a7791: Declare SCIF register base and IRQ as resources ARM: shmobile: r8a7778: Declare SCIF register base and IRQ as resources ARM: shmobile: sh7372: Don't set plat_sci_port scbrr_algo_id field ARM: shmobile: r8a7779: Declare SCIF register base and IRQ as resources ARM: shmobile: r8a7740: Declare SCIF register base and IRQ as resources ARM: shmobile: r8a73a4: Declare SCIF register base and IRQ as resources ARM: shmobile: r7s72100: Declare SCIF register base and IRQ as resources ARM: shmobile: sh73a0: Declare SCIF register base and IRQ as resources ARM: shmobile: sh7372: Declare SCIF register base and IRQ as resources ARM: shmobile: r8a7790: Don't define SCIF platform data in an array ... Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--arch/arm/mach-shmobile/clock-r7s72100.c8
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7778.c20
-rw-r--r--arch/arm/mach-shmobile/setup-r7s72100.c64
-rw-r--r--arch/arm/mach-shmobile/setup-r8a73a4.c66
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7740.c195
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7778.c46
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c128
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7790.c116
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7791.c129
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c160
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c191
-rw-r--r--drivers/tty/serial/sh-sci.c320
-rw-r--r--drivers/tty/serial/sh-sci.h2
-rw-r--r--include/linux/serial_sci.h34
14 files changed, 512 insertions, 967 deletions
diff --git a/arch/arm/mach-shmobile/clock-r7s72100.c b/arch/arm/mach-shmobile/clock-r7s72100.c
index 4aba20ca127e..850a8a371b43 100644
--- a/arch/arm/mach-shmobile/clock-r7s72100.c
+++ b/arch/arm/mach-shmobile/clock-r7s72100.c
@@ -27,6 +27,7 @@
27#define FRQCR2 0xfcfe0014 27#define FRQCR2 0xfcfe0014
28#define STBCR3 0xfcfe0420 28#define STBCR3 0xfcfe0420
29#define STBCR4 0xfcfe0424 29#define STBCR4 0xfcfe0424
30#define STBCR9 0xfcfe0438
30 31
31#define PLL_RATE 30 32#define PLL_RATE 30
32 33
@@ -144,10 +145,15 @@ struct clk div4_clks[DIV4_NR] = {
144 | CLK_ENABLE_ON_INIT), 145 | CLK_ENABLE_ON_INIT),
145}; 146};
146 147
147enum { MSTP47, MSTP46, MSTP45, MSTP44, MSTP43, MSTP42, MSTP41, MSTP40, 148enum { MSTP97, MSTP96, MSTP95, MSTP94,
149 MSTP47, MSTP46, MSTP45, MSTP44, MSTP43, MSTP42, MSTP41, MSTP40,
148 MSTP33, MSTP_NR }; 150 MSTP33, MSTP_NR };
149 151
150static struct clk mstp_clks[MSTP_NR] = { 152static struct clk mstp_clks[MSTP_NR] = {
153 [MSTP97] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 7, 0), /* RIIC0 */
154 [MSTP96] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 6, 0), /* RIIC1 */
155 [MSTP95] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 5, 0), /* RIIC2 */
156 [MSTP94] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 4, 0), /* RIIC3 */
151 [MSTP47] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 7, 0), /* SCIF0 */ 157 [MSTP47] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 7, 0), /* SCIF0 */
152 [MSTP46] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 6, 0), /* SCIF1 */ 158 [MSTP46] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 6, 0), /* SCIF1 */
153 [MSTP45] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 5, 0), /* SCIF2 */ 159 [MSTP45] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 5, 0), /* SCIF2 */
diff --git a/arch/arm/mach-shmobile/clock-r8a7778.c b/arch/arm/mach-shmobile/clock-r8a7778.c
index 54064346dafb..dfb0fff4d24c 100644
--- a/arch/arm/mach-shmobile/clock-r8a7778.c
+++ b/arch/arm/mach-shmobile/clock-r8a7778.c
@@ -115,6 +115,8 @@ static struct clk *main_clks[] = {
115}; 115};
116 116
117enum { 117enum {
118 MSTP531, MSTP530,
119 MSTP529, MSTP528, MSTP527, MSTP526, MSTP525, MSTP524, MSTP523,
118 MSTP331, 120 MSTP331,
119 MSTP323, MSTP322, MSTP321, 121 MSTP323, MSTP322, MSTP321,
120 MSTP311, MSTP310, 122 MSTP311, MSTP310,
@@ -129,6 +131,15 @@ enum {
129 MSTP_NR }; 131 MSTP_NR };
130 132
131static struct clk mstp_clks[MSTP_NR] = { 133static struct clk mstp_clks[MSTP_NR] = {
134 [MSTP531] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 31, 0), /* SCU0 */
135 [MSTP530] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 30, 0), /* SCU1 */
136 [MSTP529] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 29, 0), /* SCU2 */
137 [MSTP528] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 28, 0), /* SCU3 */
138 [MSTP527] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 27, 0), /* SCU4 */
139 [MSTP526] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 26, 0), /* SCU5 */
140 [MSTP525] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 25, 0), /* SCU6 */
141 [MSTP524] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 24, 0), /* SCU7 */
142 [MSTP523] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 23, 0), /* SCU8 */
132 [MSTP331] = SH_CLK_MSTP32(&s4_clk, MSTPCR3, 31, 0), /* MMC */ 143 [MSTP331] = SH_CLK_MSTP32(&s4_clk, MSTPCR3, 31, 0), /* MMC */
133 [MSTP323] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 23, 0), /* SDHI0 */ 144 [MSTP323] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 23, 0), /* SDHI0 */
134 [MSTP322] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 22, 0), /* SDHI1 */ 145 [MSTP322] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 22, 0), /* SDHI1 */
@@ -219,6 +230,15 @@ static struct clk_lookup lookups[] = {
219 CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP309]), 230 CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP309]),
220 CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP308]), 231 CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP308]),
221 CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP307]), 232 CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP307]),
233 CLKDEV_ICK_ID("scu.0", "rcar_sound", &mstp_clks[MSTP531]),
234 CLKDEV_ICK_ID("scu.1", "rcar_sound", &mstp_clks[MSTP530]),
235 CLKDEV_ICK_ID("scu.2", "rcar_sound", &mstp_clks[MSTP529]),
236 CLKDEV_ICK_ID("scu.3", "rcar_sound", &mstp_clks[MSTP528]),
237 CLKDEV_ICK_ID("scu.4", "rcar_sound", &mstp_clks[MSTP527]),
238 CLKDEV_ICK_ID("scu.5", "rcar_sound", &mstp_clks[MSTP526]),
239 CLKDEV_ICK_ID("scu.6", "rcar_sound", &mstp_clks[MSTP525]),
240 CLKDEV_ICK_ID("scu.7", "rcar_sound", &mstp_clks[MSTP524]),
241 CLKDEV_ICK_ID("scu.8", "rcar_sound", &mstp_clks[MSTP523]),
222}; 242};
223 243
224void __init r8a7778_clock_init(void) 244void __init r8a7778_clock_init(void)
diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c
index 55f0b9c7c482..9c0b3a9d5f7a 100644
--- a/arch/arm/mach-shmobile/setup-r7s72100.c
+++ b/arch/arm/mach-shmobile/setup-r7s72100.c
@@ -28,36 +28,38 @@
28#include <mach/r7s72100.h> 28#include <mach/r7s72100.h>
29#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
30 30
31#define SCIF_DATA(index, baseaddr, irq) \ 31#define R7S72100_SCIF(index, baseaddr, irq) \
32[index] = { \ 32static const struct plat_sci_port scif##index##_platform_data = { \
33 .type = PORT_SCIF, \ 33 .type = PORT_SCIF, \
34 .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, \ 34 .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, \
35 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 35 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
36 .scbrr_algo_id = SCBRR_ALGO_2, \
37 .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \ 36 .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \
38 SCSCR_REIE, \ 37 SCSCR_REIE, \
39 .mapbase = baseaddr, \ 38}; \
40 .irqs = { irq + 1, irq + 2, irq + 3, irq }, \ 39 \
41} 40static struct resource scif##index##_resources[] = { \
42 41 DEFINE_RES_MEM(baseaddr, 0x100), \
43enum { SCIF0, SCIF1, SCIF2, SCIF3, SCIF4, SCIF5, SCIF6, SCIF7 }; 42 DEFINE_RES_IRQ(irq + 1), \
43 DEFINE_RES_IRQ(irq + 2), \
44 DEFINE_RES_IRQ(irq + 3), \
45 DEFINE_RES_IRQ(irq), \
46} \
44 47
45static const struct plat_sci_port scif[] __initconst = { 48R7S72100_SCIF(0, 0xe8007000, gic_iid(221));
46 SCIF_DATA(SCIF0, 0xe8007000, gic_iid(221)), /* SCIF0 */ 49R7S72100_SCIF(1, 0xe8007800, gic_iid(225));
47 SCIF_DATA(SCIF1, 0xe8007800, gic_iid(225)), /* SCIF1 */ 50R7S72100_SCIF(2, 0xe8008000, gic_iid(229));
48 SCIF_DATA(SCIF2, 0xe8008000, gic_iid(229)), /* SCIF2 */ 51R7S72100_SCIF(3, 0xe8008800, gic_iid(233));
49 SCIF_DATA(SCIF3, 0xe8008800, gic_iid(233)), /* SCIF3 */ 52R7S72100_SCIF(4, 0xe8009000, gic_iid(237));
50 SCIF_DATA(SCIF4, 0xe8009000, gic_iid(237)), /* SCIF4 */ 53R7S72100_SCIF(5, 0xe8009800, gic_iid(241));
51 SCIF_DATA(SCIF5, 0xe8009800, gic_iid(241)), /* SCIF5 */ 54R7S72100_SCIF(6, 0xe800a000, gic_iid(245));
52 SCIF_DATA(SCIF6, 0xe800a000, gic_iid(245)), /* SCIF6 */ 55R7S72100_SCIF(7, 0xe800a800, gic_iid(249));
53 SCIF_DATA(SCIF7, 0xe800a800, gic_iid(249)), /* SCIF7 */
54};
55 56
56static inline void r7s72100_register_scif(int idx) 57#define r7s72100_register_scif(index) \
57{ 58 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
58 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 59 scif##index##_resources, \
59 sizeof(struct plat_sci_port)); 60 ARRAY_SIZE(scif##index##_resources), \
60} 61 &scif##index##_platform_data, \
62 sizeof(scif##index##_platform_data))
61 63
62 64
63static struct sh_timer_config mtu2_0_platform_data __initdata = { 65static struct sh_timer_config mtu2_0_platform_data __initdata = {
@@ -81,14 +83,14 @@ static struct resource mtu2_0_resources[] __initdata = {
81 83
82void __init r7s72100_add_dt_devices(void) 84void __init r7s72100_add_dt_devices(void)
83{ 85{
84 r7s72100_register_scif(SCIF0); 86 r7s72100_register_scif(0);
85 r7s72100_register_scif(SCIF1); 87 r7s72100_register_scif(1);
86 r7s72100_register_scif(SCIF2); 88 r7s72100_register_scif(2);
87 r7s72100_register_scif(SCIF3); 89 r7s72100_register_scif(3);
88 r7s72100_register_scif(SCIF4); 90 r7s72100_register_scif(4);
89 r7s72100_register_scif(SCIF5); 91 r7s72100_register_scif(5);
90 r7s72100_register_scif(SCIF6); 92 r7s72100_register_scif(6);
91 r7s72100_register_scif(SCIF7); 93 r7s72100_register_scif(7);
92 r7s72100_register_mtu2(0); 94 r7s72100_register_mtu2(0);
93} 95}
94 96
diff --git a/arch/arm/mach-shmobile/setup-r8a73a4.c b/arch/arm/mach-shmobile/setup-r8a73a4.c
index cc94b64c2ef5..cd36f8078325 100644
--- a/arch/arm/mach-shmobile/setup-r8a73a4.c
+++ b/arch/arm/mach-shmobile/setup-r8a73a4.c
@@ -40,41 +40,39 @@ void __init r8a73a4_pinmux_init(void)
40 ARRAY_SIZE(pfc_resources)); 40 ARRAY_SIZE(pfc_resources));
41} 41}
42 42
43#define SCIF_COMMON(scif_type, baseaddr, irq) \ 43#define R8A73A4_SCIF(scif_type, _scscr, index, baseaddr, irq) \
44static struct plat_sci_port scif##index##_platform_data = { \
44 .type = scif_type, \ 45 .type = scif_type, \
45 .mapbase = baseaddr, \
46 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 46 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
47 .scbrr_algo_id = SCBRR_ALGO_4, \ 47 .scscr = _scscr, \
48 .irqs = SCIx_IRQ_MUXED(irq) 48}; \
49 49 \
50#define SCIFA_DATA(index, baseaddr, irq) \ 50static struct resource scif##index##_resources[] = { \
51[index] = { \ 51 DEFINE_RES_MEM(baseaddr, 0x100), \
52 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \ 52 DEFINE_RES_IRQ(irq), \
53 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
54} 53}
55 54
56#define SCIFB_DATA(index, baseaddr, irq) \ 55#define R8A73A4_SCIFA(index, baseaddr, irq) \
57[index] = { \ 56 R8A73A4_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
58 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \ 57 index, baseaddr, irq)
59 .scscr = SCSCR_RE | SCSCR_TE, \
60}
61 58
62enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFB3 }; 59#define R8A73A4_SCIFB(index, baseaddr, irq) \
60 R8A73A4_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
61 index, baseaddr, irq)
63 62
64static const struct plat_sci_port scif[] = { 63R8A73A4_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
65 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ 64R8A73A4_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
66 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ 65R8A73A4_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
67 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ 66R8A73A4_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
68 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ 67R8A73A4_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
69 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ 68R8A73A4_SCIFB(5, 0xe6cf0000, gic_spi(151)); /* SCIFB3 */
70 SCIFB_DATA(SCIFB3, 0xe6cf0000, gic_spi(151)), /* SCIFB3 */
71};
72 69
73static inline void r8a73a4_register_scif(int idx) 70#define r8a73a4_register_scif(index) \
74{ 71 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
75 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 72 scif##index##_resources, \
76 sizeof(struct plat_sci_port)); 73 ARRAY_SIZE(scif##index##_resources), \
77} 74 &scif##index##_platform_data, \
75 sizeof(scif##index##_platform_data))
78 76
79static const struct renesas_irqc_config irqc0_data = { 77static const struct renesas_irqc_config irqc0_data = {
80 .irq_base = irq_pin(0), /* IRQ0 -> IRQ31 */ 78 .irq_base = irq_pin(0), /* IRQ0 -> IRQ31 */
@@ -192,12 +190,12 @@ static struct resource cmt10_resources[] = {
192 190
193void __init r8a73a4_add_dt_devices(void) 191void __init r8a73a4_add_dt_devices(void)
194{ 192{
195 r8a73a4_register_scif(SCIFA0); 193 r8a73a4_register_scif(0);
196 r8a73a4_register_scif(SCIFA1); 194 r8a73a4_register_scif(1);
197 r8a73a4_register_scif(SCIFB0); 195 r8a73a4_register_scif(2);
198 r8a73a4_register_scif(SCIFB1); 196 r8a73a4_register_scif(3);
199 r8a73a4_register_scif(SCIFB2); 197 r8a73a4_register_scif(4);
200 r8a73a4_register_scif(SCIFB3); 198 r8a73a4_register_scif(5);
201 r8a7790_register_cmt(10); 199 r8a7790_register_cmt(10);
202} 200}
203 201
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index b7d4b2c3bc29..8f3c68101d59 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -203,167 +203,38 @@ static struct platform_device irqpin3_device = {
203 }, 203 },
204}; 204};
205 205
206/* SCIFA0 */ 206/* SCIF */
207static struct plat_sci_port scif0_platform_data = { 207#define R8A7740_SCIF(scif_type, index, baseaddr, irq) \
208 .mapbase = 0xe6c40000, 208static struct plat_sci_port scif##index##_platform_data = { \
209 .flags = UPF_BOOT_AUTOCONF, 209 .type = scif_type, \
210 .scscr = SCSCR_RE | SCSCR_TE, 210 .flags = UPF_BOOT_AUTOCONF, \
211 .scbrr_algo_id = SCBRR_ALGO_4, 211 .scscr = SCSCR_RE | SCSCR_TE, \
212 .type = PORT_SCIFA, 212}; \
213 .irqs = SCIx_IRQ_MUXED(gic_spi(100)), 213 \
214}; 214static struct resource scif##index##_resources[] = { \
215 215 DEFINE_RES_MEM(baseaddr, 0x100), \
216static struct platform_device scif0_device = { 216 DEFINE_RES_IRQ(irq), \
217 .name = "sh-sci", 217}; \
218 .id = 0, 218 \
219 .dev = { 219static struct platform_device scif##index##_device = { \
220 .platform_data = &scif0_platform_data, 220 .name = "sh-sci", \
221 }, 221 .id = index, \
222}; 222 .resource = scif##index##_resources, \
223 223 .num_resources = ARRAY_SIZE(scif##index##_resources), \
224/* SCIFA1 */ 224 .dev = { \
225static struct plat_sci_port scif1_platform_data = { 225 .platform_data = &scif##index##_platform_data, \
226 .mapbase = 0xe6c50000, 226 }, \
227 .flags = UPF_BOOT_AUTOCONF, 227}
228 .scscr = SCSCR_RE | SCSCR_TE,
229 .scbrr_algo_id = SCBRR_ALGO_4,
230 .type = PORT_SCIFA,
231 .irqs = SCIx_IRQ_MUXED(gic_spi(101)),
232};
233
234static struct platform_device scif1_device = {
235 .name = "sh-sci",
236 .id = 1,
237 .dev = {
238 .platform_data = &scif1_platform_data,
239 },
240};
241
242/* SCIFA2 */
243static struct plat_sci_port scif2_platform_data = {
244 .mapbase = 0xe6c60000,
245 .flags = UPF_BOOT_AUTOCONF,
246 .scscr = SCSCR_RE | SCSCR_TE,
247 .scbrr_algo_id = SCBRR_ALGO_4,
248 .type = PORT_SCIFA,
249 .irqs = SCIx_IRQ_MUXED(gic_spi(102)),
250};
251
252static struct platform_device scif2_device = {
253 .name = "sh-sci",
254 .id = 2,
255 .dev = {
256 .platform_data = &scif2_platform_data,
257 },
258};
259
260/* SCIFA3 */
261static struct plat_sci_port scif3_platform_data = {
262 .mapbase = 0xe6c70000,
263 .flags = UPF_BOOT_AUTOCONF,
264 .scscr = SCSCR_RE | SCSCR_TE,
265 .scbrr_algo_id = SCBRR_ALGO_4,
266 .type = PORT_SCIFA,
267 .irqs = SCIx_IRQ_MUXED(gic_spi(103)),
268};
269
270static struct platform_device scif3_device = {
271 .name = "sh-sci",
272 .id = 3,
273 .dev = {
274 .platform_data = &scif3_platform_data,
275 },
276};
277
278/* SCIFA4 */
279static struct plat_sci_port scif4_platform_data = {
280 .mapbase = 0xe6c80000,
281 .flags = UPF_BOOT_AUTOCONF,
282 .scscr = SCSCR_RE | SCSCR_TE,
283 .scbrr_algo_id = SCBRR_ALGO_4,
284 .type = PORT_SCIFA,
285 .irqs = SCIx_IRQ_MUXED(gic_spi(104)),
286};
287
288static struct platform_device scif4_device = {
289 .name = "sh-sci",
290 .id = 4,
291 .dev = {
292 .platform_data = &scif4_platform_data,
293 },
294};
295
296/* SCIFA5 */
297static struct plat_sci_port scif5_platform_data = {
298 .mapbase = 0xe6cb0000,
299 .flags = UPF_BOOT_AUTOCONF,
300 .scscr = SCSCR_RE | SCSCR_TE,
301 .scbrr_algo_id = SCBRR_ALGO_4,
302 .type = PORT_SCIFA,
303 .irqs = SCIx_IRQ_MUXED(gic_spi(105)),
304};
305
306static struct platform_device scif5_device = {
307 .name = "sh-sci",
308 .id = 5,
309 .dev = {
310 .platform_data = &scif5_platform_data,
311 },
312};
313
314/* SCIFA6 */
315static struct plat_sci_port scif6_platform_data = {
316 .mapbase = 0xe6cc0000,
317 .flags = UPF_BOOT_AUTOCONF,
318 .scscr = SCSCR_RE | SCSCR_TE,
319 .scbrr_algo_id = SCBRR_ALGO_4,
320 .type = PORT_SCIFA,
321 .irqs = SCIx_IRQ_MUXED(gic_spi(106)),
322};
323
324static struct platform_device scif6_device = {
325 .name = "sh-sci",
326 .id = 6,
327 .dev = {
328 .platform_data = &scif6_platform_data,
329 },
330};
331
332/* SCIFA7 */
333static struct plat_sci_port scif7_platform_data = {
334 .mapbase = 0xe6cd0000,
335 .flags = UPF_BOOT_AUTOCONF,
336 .scscr = SCSCR_RE | SCSCR_TE,
337 .scbrr_algo_id = SCBRR_ALGO_4,
338 .type = PORT_SCIFA,
339 .irqs = SCIx_IRQ_MUXED(gic_spi(107)),
340};
341
342static struct platform_device scif7_device = {
343 .name = "sh-sci",
344 .id = 7,
345 .dev = {
346 .platform_data = &scif7_platform_data,
347 },
348};
349
350/* SCIFB */
351static struct plat_sci_port scifb_platform_data = {
352 .mapbase = 0xe6c30000,
353 .flags = UPF_BOOT_AUTOCONF,
354 .scscr = SCSCR_RE | SCSCR_TE,
355 .scbrr_algo_id = SCBRR_ALGO_4,
356 .type = PORT_SCIFB,
357 .irqs = SCIx_IRQ_MUXED(gic_spi(108)),
358};
359 228
360static struct platform_device scifb_device = { 229R8A7740_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(100));
361 .name = "sh-sci", 230R8A7740_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(101));
362 .id = 8, 231R8A7740_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(102));
363 .dev = { 232R8A7740_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(103));
364 .platform_data = &scifb_platform_data, 233R8A7740_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(104));
365 }, 234R8A7740_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(105));
366}; 235R8A7740_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(106));
236R8A7740_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(107));
237R8A7740_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(108));
367 238
368/* CMT */ 239/* CMT */
369static struct sh_timer_config cmt10_platform_data = { 240static struct sh_timer_config cmt10_platform_data = {
@@ -528,7 +399,7 @@ static struct platform_device *r8a7740_devices_dt[] __initdata = {
528 &scif5_device, 399 &scif5_device,
529 &scif6_device, 400 &scif6_device,
530 &scif7_device, 401 &scif7_device,
531 &scifb_device, 402 &scif8_device,
532 &cmt10_device, 403 &cmt10_device,
533}; 404};
534 405
@@ -981,7 +852,7 @@ void __init r8a7740_add_standard_devices(void)
981 rmobile_add_device_to_domain("A3SP", &scif5_device); 852 rmobile_add_device_to_domain("A3SP", &scif5_device);
982 rmobile_add_device_to_domain("A3SP", &scif6_device); 853 rmobile_add_device_to_domain("A3SP", &scif6_device);
983 rmobile_add_device_to_domain("A3SP", &scif7_device); 854 rmobile_add_device_to_domain("A3SP", &scif7_device);
984 rmobile_add_device_to_domain("A3SP", &scifb_device); 855 rmobile_add_device_to_domain("A3SP", &scif8_device);
985 rmobile_add_device_to_domain("A3SP", &i2c1_device); 856 rmobile_add_device_to_domain("A3SP", &i2c1_device);
986} 857}
987 858
diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c
index 7ea6308e5da8..6d694526e4ca 100644
--- a/arch/arm/mach-shmobile/setup-r8a7778.c
+++ b/arch/arm/mach-shmobile/setup-r8a7778.c
@@ -44,24 +44,31 @@
44#include <asm/hardware/cache-l2x0.h> 44#include <asm/hardware/cache-l2x0.h>
45 45
46/* SCIF */ 46/* SCIF */
47#define SCIF_INFO(baseaddr, irq) \ 47#define R8A7778_SCIF(index, baseaddr, irq) \
48{ \ 48static struct plat_sci_port scif##index##_platform_data = { \
49 .mapbase = baseaddr, \
50 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 49 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
51 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \ 50 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
52 .scbrr_algo_id = SCBRR_ALGO_2, \
53 .type = PORT_SCIF, \ 51 .type = PORT_SCIF, \
54 .irqs = SCIx_IRQ_MUXED(irq), \ 52}; \
53 \
54static struct resource scif##index##_resources[] = { \
55 DEFINE_RES_MEM(baseaddr, 0x100), \
56 DEFINE_RES_IRQ(irq), \
55} 57}
56 58
57static struct plat_sci_port scif_platform_data[] __initdata = { 59R8A7778_SCIF(0, 0xffe40000, gic_iid(0x66));
58 SCIF_INFO(0xffe40000, gic_iid(0x66)), 60R8A7778_SCIF(1, 0xffe41000, gic_iid(0x67));
59 SCIF_INFO(0xffe41000, gic_iid(0x67)), 61R8A7778_SCIF(2, 0xffe42000, gic_iid(0x68));
60 SCIF_INFO(0xffe42000, gic_iid(0x68)), 62R8A7778_SCIF(3, 0xffe43000, gic_iid(0x69));
61 SCIF_INFO(0xffe43000, gic_iid(0x69)), 63R8A7778_SCIF(4, 0xffe44000, gic_iid(0x6a));
62 SCIF_INFO(0xffe44000, gic_iid(0x6a)), 64R8A7778_SCIF(5, 0xffe45000, gic_iid(0x6b));
63 SCIF_INFO(0xffe45000, gic_iid(0x6b)), 65
64}; 66#define r8a7778_register_scif(index) \
67 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
68 scif##index##_resources, \
69 ARRAY_SIZE(scif##index##_resources), \
70 &scif##index##_platform_data, \
71 sizeof(scif##index##_platform_data))
65 72
66/* TMU */ 73/* TMU */
67static struct resource sh_tmu0_resources[] __initdata = { 74static struct resource sh_tmu0_resources[] __initdata = {
@@ -287,8 +294,6 @@ static void __init r8a7778_register_hspi(int id)
287 294
288void __init r8a7778_add_dt_devices(void) 295void __init r8a7778_add_dt_devices(void)
289{ 296{
290 int i;
291
292#ifdef CONFIG_CACHE_L2X0 297#ifdef CONFIG_CACHE_L2X0
293 void __iomem *base = ioremap_nocache(0xf0100000, 0x1000); 298 void __iomem *base = ioremap_nocache(0xf0100000, 0x1000);
294 if (base) { 299 if (base) {
@@ -300,11 +305,12 @@ void __init r8a7778_add_dt_devices(void)
300 } 305 }
301#endif 306#endif
302 307
303 for (i = 0; i < ARRAY_SIZE(scif_platform_data); i++) 308 r8a7778_register_scif(0);
304 platform_device_register_data(&platform_bus, "sh-sci", i, 309 r8a7778_register_scif(1);
305 &scif_platform_data[i], 310 r8a7778_register_scif(2);
306 sizeof(struct plat_sci_port)); 311 r8a7778_register_scif(3);
307 312 r8a7778_register_scif(4);
313 r8a7778_register_scif(5);
308 r8a7778_register_tmu(0); 314 r8a7778_register_tmu(0);
309 r8a7778_register_tmu(1); 315 r8a7778_register_tmu(1);
310} 316}
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index 13049e9d691c..339292e85838 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -188,107 +188,35 @@ void __init r8a7779_pinmux_init(void)
188 ARRAY_SIZE(r8a7779_pinctrl_devices)); 188 ARRAY_SIZE(r8a7779_pinctrl_devices));
189} 189}
190 190
191static struct plat_sci_port scif0_platform_data = { 191/* SCIF */
192 .mapbase = 0xffe40000, 192#define R8A7779_SCIF(index, baseaddr, irq) \
193 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, 193static struct plat_sci_port scif##index##_platform_data = { \
194 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, 194 .type = PORT_SCIF, \
195 .scbrr_algo_id = SCBRR_ALGO_2, 195 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
196 .type = PORT_SCIF, 196 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
197 .irqs = SCIx_IRQ_MUXED(gic_iid(0x78)), 197}; \
198}; 198 \
199 199static struct resource scif##index##_resources[] = { \
200static struct platform_device scif0_device = { 200 DEFINE_RES_MEM(baseaddr, 0x100), \
201 .name = "sh-sci", 201 DEFINE_RES_IRQ(irq), \
202 .id = 0, 202}; \
203 .dev = { 203 \
204 .platform_data = &scif0_platform_data, 204static struct platform_device scif##index##_device = { \
205 }, 205 .name = "sh-sci", \
206}; 206 .id = index, \
207 207 .resource = scif##index##_resources, \
208static struct plat_sci_port scif1_platform_data = { 208 .num_resources = ARRAY_SIZE(scif##index##_resources), \
209 .mapbase = 0xffe41000, 209 .dev = { \
210 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, 210 .platform_data = &scif##index##_platform_data, \
211 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, 211 }, \
212 .scbrr_algo_id = SCBRR_ALGO_2, 212}
213 .type = PORT_SCIF,
214 .irqs = SCIx_IRQ_MUXED(gic_iid(0x79)),
215};
216
217static struct platform_device scif1_device = {
218 .name = "sh-sci",
219 .id = 1,
220 .dev = {
221 .platform_data = &scif1_platform_data,
222 },
223};
224
225static struct plat_sci_port scif2_platform_data = {
226 .mapbase = 0xffe42000,
227 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
228 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
229 .scbrr_algo_id = SCBRR_ALGO_2,
230 .type = PORT_SCIF,
231 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7a)),
232};
233
234static struct platform_device scif2_device = {
235 .name = "sh-sci",
236 .id = 2,
237 .dev = {
238 .platform_data = &scif2_platform_data,
239 },
240};
241
242static struct plat_sci_port scif3_platform_data = {
243 .mapbase = 0xffe43000,
244 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
245 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
246 .scbrr_algo_id = SCBRR_ALGO_2,
247 .type = PORT_SCIF,
248 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7b)),
249};
250
251static struct platform_device scif3_device = {
252 .name = "sh-sci",
253 .id = 3,
254 .dev = {
255 .platform_data = &scif3_platform_data,
256 },
257};
258
259static struct plat_sci_port scif4_platform_data = {
260 .mapbase = 0xffe44000,
261 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
262 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
263 .scbrr_algo_id = SCBRR_ALGO_2,
264 .type = PORT_SCIF,
265 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7c)),
266};
267
268static struct platform_device scif4_device = {
269 .name = "sh-sci",
270 .id = 4,
271 .dev = {
272 .platform_data = &scif4_platform_data,
273 },
274};
275
276static struct plat_sci_port scif5_platform_data = {
277 .mapbase = 0xffe45000,
278 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
279 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
280 .scbrr_algo_id = SCBRR_ALGO_2,
281 .type = PORT_SCIF,
282 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7d)),
283};
284 213
285static struct platform_device scif5_device = { 214R8A7779_SCIF(0, 0xffe40000, gic_iid(0x78));
286 .name = "sh-sci", 215R8A7779_SCIF(1, 0xffe41000, gic_iid(0x79));
287 .id = 5, 216R8A7779_SCIF(2, 0xffe42000, gic_iid(0x7a));
288 .dev = { 217R8A7779_SCIF(3, 0xffe43000, gic_iid(0x7b));
289 .platform_data = &scif5_platform_data, 218R8A7779_SCIF(4, 0xffe44000, gic_iid(0x7c));
290 }, 219R8A7779_SCIF(5, 0xffe45000, gic_iid(0x7d));
291};
292 220
293/* TMU */ 221/* TMU */
294static struct sh_timer_config tmu00_platform_data = { 222static struct sh_timer_config tmu00_platform_data = {
diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c
index 1a11e26a9431..66476d21544d 100644
--- a/arch/arm/mach-shmobile/setup-r8a7790.c
+++ b/arch/arm/mach-shmobile/setup-r8a7790.c
@@ -100,61 +100,51 @@ void __init r8a7790_pinmux_init(void)
100 r8a7790_register_i2c(3); 100 r8a7790_register_i2c(3);
101} 101}
102 102
103#define SCIF_COMMON(scif_type, baseaddr, irq) \ 103#define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \
104 .type = scif_type, \ 104static struct plat_sci_port scif##index##_platform_data = { \
105 .mapbase = baseaddr, \ 105 .type = scif_type, \
106 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 106 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
107 .irqs = SCIx_IRQ_MUXED(irq) 107 .scscr = _scscr, \
108 108}; \
109#define SCIFA_DATA(index, baseaddr, irq) \ 109 \
110[index] = { \ 110static struct resource scif##index##_resources[] = { \
111 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \ 111 DEFINE_RES_MEM(baseaddr, 0x100), \
112 .scbrr_algo_id = SCBRR_ALGO_4, \ 112 DEFINE_RES_IRQ(irq), \
113 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
114}
115
116#define SCIFB_DATA(index, baseaddr, irq) \
117[index] = { \
118 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
119 .scbrr_algo_id = SCBRR_ALGO_4, \
120 .scscr = SCSCR_RE | SCSCR_TE, \
121}
122
123#define SCIF_DATA(index, baseaddr, irq) \
124[index] = { \
125 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
126 .scbrr_algo_id = SCBRR_ALGO_2, \
127 .scscr = SCSCR_RE | SCSCR_TE, \
128}
129
130#define HSCIF_DATA(index, baseaddr, irq) \
131[index] = { \
132 SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
133 .scbrr_algo_id = SCBRR_ALGO_6, \
134 .scscr = SCSCR_RE | SCSCR_TE, \
135} 113}
136 114
137enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1, 115#define R8A7790_SCIF(index, baseaddr, irq) \
138 HSCIF0, HSCIF1 }; 116 __R8A7790_SCIF(PORT_SCIF, SCSCR_RE | SCSCR_TE, \
139 117 index, baseaddr, irq)
140static const struct plat_sci_port scif[] __initconst = { 118
141 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ 119#define R8A7790_SCIFA(index, baseaddr, irq) \
142 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ 120 __R8A7790_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
143 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ 121 index, baseaddr, irq)
144 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ 122
145 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ 123#define R8A7790_SCIFB(index, baseaddr, irq) \
146 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */ 124 __R8A7790_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
147 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */ 125 index, baseaddr, irq)
148 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */ 126
149 HSCIF_DATA(HSCIF0, 0xe62c0000, gic_spi(154)), /* HSCIF0 */ 127#define R8A7790_HSCIF(index, baseaddr, irq) \
150 HSCIF_DATA(HSCIF1, 0xe62c8000, gic_spi(155)), /* HSCIF1 */ 128 __R8A7790_SCIF(PORT_HSCIF, SCSCR_RE | SCSCR_TE, \
151}; 129 index, baseaddr, irq)
152 130
153static inline void r8a7790_register_scif(int idx) 131R8A7790_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
154{ 132R8A7790_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
155 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 133R8A7790_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
156 sizeof(struct plat_sci_port)); 134R8A7790_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
157} 135R8A7790_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
136R8A7790_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
137R8A7790_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
138R8A7790_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
139R8A7790_HSCIF(8, 0xe62c0000, gic_spi(154)); /* HSCIF0 */
140R8A7790_HSCIF(9, 0xe62c8000, gic_spi(155)); /* HSCIF1 */
141
142#define r8a7790_register_scif(index) \
143 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
144 scif##index##_resources, \
145 ARRAY_SIZE(scif##index##_resources), \
146 &scif##index##_platform_data, \
147 sizeof(scif##index##_platform_data))
158 148
159static const struct renesas_irqc_config irqc0_data __initconst = { 149static const struct renesas_irqc_config irqc0_data __initconst = {
160 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */ 150 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
@@ -207,16 +197,16 @@ static const struct resource cmt00_resources[] __initconst = {
207 197
208void __init r8a7790_add_dt_devices(void) 198void __init r8a7790_add_dt_devices(void)
209{ 199{
210 r8a7790_register_scif(SCIFA0); 200 r8a7790_register_scif(0);
211 r8a7790_register_scif(SCIFA1); 201 r8a7790_register_scif(1);
212 r8a7790_register_scif(SCIFB0); 202 r8a7790_register_scif(2);
213 r8a7790_register_scif(SCIFB1); 203 r8a7790_register_scif(3);
214 r8a7790_register_scif(SCIFB2); 204 r8a7790_register_scif(4);
215 r8a7790_register_scif(SCIFA2); 205 r8a7790_register_scif(5);
216 r8a7790_register_scif(SCIF0); 206 r8a7790_register_scif(6);
217 r8a7790_register_scif(SCIF1); 207 r8a7790_register_scif(7);
218 r8a7790_register_scif(HSCIF0); 208 r8a7790_register_scif(8);
219 r8a7790_register_scif(HSCIF1); 209 r8a7790_register_scif(9);
220 r8a7790_register_cmt(00); 210 r8a7790_register_cmt(00);
221} 211}
222 212
diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c
index cddca99b434f..e28404e43860 100644
--- a/arch/arm/mach-shmobile/setup-r8a7791.c
+++ b/arch/arm/mach-shmobile/setup-r8a7791.c
@@ -84,66 +84,49 @@ void __init r8a7791_pinmux_init(void)
84 r8a7791_register_gpio(7); 84 r8a7791_register_gpio(7);
85} 85}
86 86
87#define SCIF_COMMON(scif_type, baseaddr, irq) \ 87#define __R8A7791_SCIF(scif_type, index, baseaddr, irq) \
88 .type = scif_type, \ 88static struct plat_sci_port scif##index##_platform_data = { \
89 .mapbase = baseaddr, \ 89 .type = scif_type, \
90 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 90 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
91 .irqs = SCIx_IRQ_MUXED(irq) 91 .scscr = SCSCR_RE | SCSCR_TE, \
92 92}; \
93#define SCIFA_DATA(index, baseaddr, irq) \ 93 \
94[index] = { \ 94static struct resource scif##index##_resources[] = { \
95 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \ 95 DEFINE_RES_MEM(baseaddr, 0x100), \
96 .scbrr_algo_id = SCBRR_ALGO_4, \ 96 DEFINE_RES_IRQ(irq), \
97 .scscr = SCSCR_RE | SCSCR_TE, \
98}
99
100#define SCIFB_DATA(index, baseaddr, irq) \
101[index] = { \
102 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
103 .scbrr_algo_id = SCBRR_ALGO_4, \
104 .scscr = SCSCR_RE | SCSCR_TE, \
105}
106
107#define SCIF_DATA(index, baseaddr, irq) \
108[index] = { \
109 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
110 .scbrr_algo_id = SCBRR_ALGO_2, \
111 .scscr = SCSCR_RE | SCSCR_TE, \
112}
113
114#define HSCIF_DATA(index, baseaddr, irq) \
115[index] = { \
116 SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
117 .scbrr_algo_id = SCBRR_ALGO_6, \
118 .scscr = SCSCR_RE | SCSCR_TE, \
119} 97}
120 98
121enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1, 99#define R8A7791_SCIF(index, baseaddr, irq) \
122 SCIF2, SCIF3, SCIF4, SCIF5, SCIFA3, SCIFA4, SCIFA5 }; 100 __R8A7791_SCIF(PORT_SCIF, index, baseaddr, irq)
123 101
124static const struct plat_sci_port scif[] __initconst = { 102#define R8A7791_SCIFA(index, baseaddr, irq) \
125 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ 103 __R8A7791_SCIF(PORT_SCIFA, index, baseaddr, irq)
126 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ 104
127 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ 105#define R8A7791_SCIFB(index, baseaddr, irq) \
128 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ 106 __R8A7791_SCIF(PORT_SCIFB, index, baseaddr, irq)
129 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ 107
130 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */ 108R8A7791_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
131 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */ 109R8A7791_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
132 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */ 110R8A7791_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
133 SCIF_DATA(SCIF2, 0xe6e58000, gic_spi(22)), /* SCIF2 */ 111R8A7791_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
134 SCIF_DATA(SCIF3, 0xe6ea8000, gic_spi(23)), /* SCIF3 */ 112R8A7791_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
135 SCIF_DATA(SCIF4, 0xe6ee0000, gic_spi(24)), /* SCIF4 */ 113R8A7791_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
136 SCIF_DATA(SCIF5, 0xe6ee8000, gic_spi(25)), /* SCIF5 */ 114R8A7791_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
137 SCIFA_DATA(SCIFA3, 0xe6c70000, gic_spi(29)), /* SCIFA3 */ 115R8A7791_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
138 SCIFA_DATA(SCIFA4, 0xe6c78000, gic_spi(30)), /* SCIFA4 */ 116R8A7791_SCIF(8, 0xe6e58000, gic_spi(22)); /* SCIF2 */
139 SCIFA_DATA(SCIFA5, 0xe6c80000, gic_spi(31)), /* SCIFA5 */ 117R8A7791_SCIF(9, 0xe6ea8000, gic_spi(23)); /* SCIF3 */
140}; 118R8A7791_SCIF(10, 0xe6ee0000, gic_spi(24)); /* SCIF4 */
141 119R8A7791_SCIF(11, 0xe6ee8000, gic_spi(25)); /* SCIF5 */
142static inline void r8a7791_register_scif(int idx) 120R8A7791_SCIFA(12, 0xe6c70000, gic_spi(29)); /* SCIFA3 */
143{ 121R8A7791_SCIFA(13, 0xe6c78000, gic_spi(30)); /* SCIFA4 */
144 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 122R8A7791_SCIFA(14, 0xe6c80000, gic_spi(31)); /* SCIFA5 */
145 sizeof(struct plat_sci_port)); 123
146} 124#define r8a7791_register_scif(index) \
125 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
126 scif##index##_resources, \
127 ARRAY_SIZE(scif##index##_resources), \
128 &scif##index##_platform_data, \
129 sizeof(scif##index##_platform_data))
147 130
148static const struct sh_timer_config cmt00_platform_data __initconst = { 131static const struct sh_timer_config cmt00_platform_data __initconst = {
149 .name = "CMT00", 132 .name = "CMT00",
@@ -202,21 +185,21 @@ static const struct resource thermal_resources[] __initconst = {
202 185
203void __init r8a7791_add_dt_devices(void) 186void __init r8a7791_add_dt_devices(void)
204{ 187{
205 r8a7791_register_scif(SCIFA0); 188 r8a7791_register_scif(0);
206 r8a7791_register_scif(SCIFA1); 189 r8a7791_register_scif(1);
207 r8a7791_register_scif(SCIFB0); 190 r8a7791_register_scif(2);
208 r8a7791_register_scif(SCIFB1); 191 r8a7791_register_scif(3);
209 r8a7791_register_scif(SCIFB2); 192 r8a7791_register_scif(4);
210 r8a7791_register_scif(SCIFA2); 193 r8a7791_register_scif(5);
211 r8a7791_register_scif(SCIF0); 194 r8a7791_register_scif(6);
212 r8a7791_register_scif(SCIF1); 195 r8a7791_register_scif(7);
213 r8a7791_register_scif(SCIF2); 196 r8a7791_register_scif(8);
214 r8a7791_register_scif(SCIF3); 197 r8a7791_register_scif(9);
215 r8a7791_register_scif(SCIF4); 198 r8a7791_register_scif(10);
216 r8a7791_register_scif(SCIF5); 199 r8a7791_register_scif(11);
217 r8a7791_register_scif(SCIFA3); 200 r8a7791_register_scif(12);
218 r8a7791_register_scif(SCIFA4); 201 r8a7791_register_scif(13);
219 r8a7791_register_scif(SCIFA5); 202 r8a7791_register_scif(14);
220 r8a7791_register_cmt(00); 203 r8a7791_register_cmt(00);
221} 204}
222 205
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index 311878391e18..27301278c208 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -86,138 +86,36 @@ void __init sh7372_pinmux_init(void)
86 platform_device_register(&sh7372_pfc_device); 86 platform_device_register(&sh7372_pfc_device);
87} 87}
88 88
89/* SCIFA0 */ 89/* SCIF */
90static struct plat_sci_port scif0_platform_data = { 90#define SH7372_SCIF(scif_type, index, baseaddr, irq) \
91 .mapbase = 0xe6c40000, 91static struct plat_sci_port scif##index##_platform_data = { \
92 .flags = UPF_BOOT_AUTOCONF, 92 .type = scif_type, \
93 .scscr = SCSCR_RE | SCSCR_TE, 93 .flags = UPF_BOOT_AUTOCONF, \
94 .scbrr_algo_id = SCBRR_ALGO_4, 94 .scscr = SCSCR_RE | SCSCR_TE, \
95 .type = PORT_SCIFA, 95}; \
96 .irqs = { evt2irq(0x0c00), evt2irq(0x0c00), 96 \
97 evt2irq(0x0c00), evt2irq(0x0c00) }, 97static struct resource scif##index##_resources[] = { \
98}; 98 DEFINE_RES_MEM(baseaddr, 0x100), \
99 99 DEFINE_RES_IRQ(irq), \
100static struct platform_device scif0_device = { 100}; \
101 .name = "sh-sci", 101 \
102 .id = 0, 102static struct platform_device scif##index##_device = { \
103 .dev = { 103 .name = "sh-sci", \
104 .platform_data = &scif0_platform_data, 104 .id = index, \
105 }, 105 .resource = scif##index##_resources, \
106}; 106 .num_resources = ARRAY_SIZE(scif##index##_resources), \
107 107 .dev = { \
108/* SCIFA1 */ 108 .platform_data = &scif##index##_platform_data, \
109static struct plat_sci_port scif1_platform_data = { 109 }, \
110 .mapbase = 0xe6c50000, 110}
111 .flags = UPF_BOOT_AUTOCONF,
112 .scscr = SCSCR_RE | SCSCR_TE,
113 .scbrr_algo_id = SCBRR_ALGO_4,
114 .type = PORT_SCIFA,
115 .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
116 evt2irq(0x0c20), evt2irq(0x0c20) },
117};
118
119static struct platform_device scif1_device = {
120 .name = "sh-sci",
121 .id = 1,
122 .dev = {
123 .platform_data = &scif1_platform_data,
124 },
125};
126
127/* SCIFA2 */
128static struct plat_sci_port scif2_platform_data = {
129 .mapbase = 0xe6c60000,
130 .flags = UPF_BOOT_AUTOCONF,
131 .scscr = SCSCR_RE | SCSCR_TE,
132 .scbrr_algo_id = SCBRR_ALGO_4,
133 .type = PORT_SCIFA,
134 .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
135 evt2irq(0x0c40), evt2irq(0x0c40) },
136};
137
138static struct platform_device scif2_device = {
139 .name = "sh-sci",
140 .id = 2,
141 .dev = {
142 .platform_data = &scif2_platform_data,
143 },
144};
145
146/* SCIFA3 */
147static struct plat_sci_port scif3_platform_data = {
148 .mapbase = 0xe6c70000,
149 .flags = UPF_BOOT_AUTOCONF,
150 .scscr = SCSCR_RE | SCSCR_TE,
151 .scbrr_algo_id = SCBRR_ALGO_4,
152 .type = PORT_SCIFA,
153 .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
154 evt2irq(0x0c60), evt2irq(0x0c60) },
155};
156
157static struct platform_device scif3_device = {
158 .name = "sh-sci",
159 .id = 3,
160 .dev = {
161 .platform_data = &scif3_platform_data,
162 },
163};
164
165/* SCIFA4 */
166static struct plat_sci_port scif4_platform_data = {
167 .mapbase = 0xe6c80000,
168 .flags = UPF_BOOT_AUTOCONF,
169 .scscr = SCSCR_RE | SCSCR_TE,
170 .scbrr_algo_id = SCBRR_ALGO_4,
171 .type = PORT_SCIFA,
172 .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
173 evt2irq(0x0d20), evt2irq(0x0d20) },
174};
175
176static struct platform_device scif4_device = {
177 .name = "sh-sci",
178 .id = 4,
179 .dev = {
180 .platform_data = &scif4_platform_data,
181 },
182};
183
184/* SCIFA5 */
185static struct plat_sci_port scif5_platform_data = {
186 .mapbase = 0xe6cb0000,
187 .flags = UPF_BOOT_AUTOCONF,
188 .scscr = SCSCR_RE | SCSCR_TE,
189 .scbrr_algo_id = SCBRR_ALGO_4,
190 .type = PORT_SCIFA,
191 .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
192 evt2irq(0x0d40), evt2irq(0x0d40) },
193};
194
195static struct platform_device scif5_device = {
196 .name = "sh-sci",
197 .id = 5,
198 .dev = {
199 .platform_data = &scif5_platform_data,
200 },
201};
202
203/* SCIFB */
204static struct plat_sci_port scif6_platform_data = {
205 .mapbase = 0xe6c30000,
206 .flags = UPF_BOOT_AUTOCONF,
207 .scscr = SCSCR_RE | SCSCR_TE,
208 .scbrr_algo_id = SCBRR_ALGO_4,
209 .type = PORT_SCIFB,
210 .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
211 evt2irq(0x0d60), evt2irq(0x0d60) },
212};
213 111
214static struct platform_device scif6_device = { 112SH7372_SCIF(PORT_SCIFA, 0, 0xe6c40000, evt2irq(0x0c00));
215 .name = "sh-sci", 113SH7372_SCIF(PORT_SCIFA, 1, 0xe6c50000, evt2irq(0x0c20));
216 .id = 6, 114SH7372_SCIF(PORT_SCIFA, 2, 0xe6c60000, evt2irq(0x0c40));
217 .dev = { 115SH7372_SCIF(PORT_SCIFA, 3, 0xe6c70000, evt2irq(0x0c60));
218 .platform_data = &scif6_platform_data, 116SH7372_SCIF(PORT_SCIFA, 4, 0xe6c80000, evt2irq(0x0d20));
219 }, 117SH7372_SCIF(PORT_SCIFA, 5, 0xe6cb0000, evt2irq(0x0d40));
220}; 118SH7372_SCIF(PORT_SCIFB, 6, 0xe6c30000, evt2irq(0x0d60));
221 119
222/* CMT */ 120/* CMT */
223static struct sh_timer_config cmt2_platform_data = { 121static struct sh_timer_config cmt2_platform_data = {
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 22de17417fd7..00b348ec48b8 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -71,167 +71,38 @@ void __init sh73a0_pinmux_init(void)
71 ARRAY_SIZE(pfc_resources)); 71 ARRAY_SIZE(pfc_resources));
72} 72}
73 73
74static struct plat_sci_port scif0_platform_data = { 74/* SCIF */
75 .mapbase = 0xe6c40000, 75#define SH73A0_SCIF(scif_type, index, baseaddr, irq) \
76 .flags = UPF_BOOT_AUTOCONF, 76static struct plat_sci_port scif##index##_platform_data = { \
77 .scscr = SCSCR_RE | SCSCR_TE, 77 .type = scif_type, \
78 .scbrr_algo_id = SCBRR_ALGO_4, 78 .flags = UPF_BOOT_AUTOCONF, \
79 .type = PORT_SCIFA, 79 .scscr = SCSCR_RE | SCSCR_TE, \
80 .irqs = { gic_spi(72), gic_spi(72), 80}; \
81 gic_spi(72), gic_spi(72) }, 81 \
82}; 82static struct resource scif##index##_resources[] = { \
83 83 DEFINE_RES_MEM(baseaddr, 0x100), \
84static struct platform_device scif0_device = { 84 DEFINE_RES_IRQ(irq), \
85 .name = "sh-sci", 85}; \
86 .id = 0, 86 \
87 .dev = { 87static struct platform_device scif##index##_device = { \
88 .platform_data = &scif0_platform_data, 88 .name = "sh-sci", \
89 }, 89 .id = index, \
90}; 90 .resource = scif##index##_resources, \
91 91 .num_resources = ARRAY_SIZE(scif##index##_resources), \
92static struct plat_sci_port scif1_platform_data = { 92 .dev = { \
93 .mapbase = 0xe6c50000, 93 .platform_data = &scif##index##_platform_data, \
94 .flags = UPF_BOOT_AUTOCONF, 94 }, \
95 .scscr = SCSCR_RE | SCSCR_TE, 95}
96 .scbrr_algo_id = SCBRR_ALGO_4,
97 .type = PORT_SCIFA,
98 .irqs = { gic_spi(73), gic_spi(73),
99 gic_spi(73), gic_spi(73) },
100};
101
102static struct platform_device scif1_device = {
103 .name = "sh-sci",
104 .id = 1,
105 .dev = {
106 .platform_data = &scif1_platform_data,
107 },
108};
109
110static struct plat_sci_port scif2_platform_data = {
111 .mapbase = 0xe6c60000,
112 .flags = UPF_BOOT_AUTOCONF,
113 .scscr = SCSCR_RE | SCSCR_TE,
114 .scbrr_algo_id = SCBRR_ALGO_4,
115 .type = PORT_SCIFA,
116 .irqs = { gic_spi(74), gic_spi(74),
117 gic_spi(74), gic_spi(74) },
118};
119
120static struct platform_device scif2_device = {
121 .name = "sh-sci",
122 .id = 2,
123 .dev = {
124 .platform_data = &scif2_platform_data,
125 },
126};
127
128static struct plat_sci_port scif3_platform_data = {
129 .mapbase = 0xe6c70000,
130 .flags = UPF_BOOT_AUTOCONF,
131 .scscr = SCSCR_RE | SCSCR_TE,
132 .scbrr_algo_id = SCBRR_ALGO_4,
133 .type = PORT_SCIFA,
134 .irqs = { gic_spi(75), gic_spi(75),
135 gic_spi(75), gic_spi(75) },
136};
137
138static struct platform_device scif3_device = {
139 .name = "sh-sci",
140 .id = 3,
141 .dev = {
142 .platform_data = &scif3_platform_data,
143 },
144};
145
146static struct plat_sci_port scif4_platform_data = {
147 .mapbase = 0xe6c80000,
148 .flags = UPF_BOOT_AUTOCONF,
149 .scscr = SCSCR_RE | SCSCR_TE,
150 .scbrr_algo_id = SCBRR_ALGO_4,
151 .type = PORT_SCIFA,
152 .irqs = { gic_spi(78), gic_spi(78),
153 gic_spi(78), gic_spi(78) },
154};
155
156static struct platform_device scif4_device = {
157 .name = "sh-sci",
158 .id = 4,
159 .dev = {
160 .platform_data = &scif4_platform_data,
161 },
162};
163
164static struct plat_sci_port scif5_platform_data = {
165 .mapbase = 0xe6cb0000,
166 .flags = UPF_BOOT_AUTOCONF,
167 .scscr = SCSCR_RE | SCSCR_TE,
168 .scbrr_algo_id = SCBRR_ALGO_4,
169 .type = PORT_SCIFA,
170 .irqs = { gic_spi(79), gic_spi(79),
171 gic_spi(79), gic_spi(79) },
172};
173
174static struct platform_device scif5_device = {
175 .name = "sh-sci",
176 .id = 5,
177 .dev = {
178 .platform_data = &scif5_platform_data,
179 },
180};
181
182static struct plat_sci_port scif6_platform_data = {
183 .mapbase = 0xe6cc0000,
184 .flags = UPF_BOOT_AUTOCONF,
185 .scscr = SCSCR_RE | SCSCR_TE,
186 .scbrr_algo_id = SCBRR_ALGO_4,
187 .type = PORT_SCIFA,
188 .irqs = { gic_spi(156), gic_spi(156),
189 gic_spi(156), gic_spi(156) },
190};
191
192static struct platform_device scif6_device = {
193 .name = "sh-sci",
194 .id = 6,
195 .dev = {
196 .platform_data = &scif6_platform_data,
197 },
198};
199
200static struct plat_sci_port scif7_platform_data = {
201 .mapbase = 0xe6cd0000,
202 .flags = UPF_BOOT_AUTOCONF,
203 .scscr = SCSCR_RE | SCSCR_TE,
204 .scbrr_algo_id = SCBRR_ALGO_4,
205 .type = PORT_SCIFA,
206 .irqs = { gic_spi(143), gic_spi(143),
207 gic_spi(143), gic_spi(143) },
208};
209
210static struct platform_device scif7_device = {
211 .name = "sh-sci",
212 .id = 7,
213 .dev = {
214 .platform_data = &scif7_platform_data,
215 },
216};
217
218static struct plat_sci_port scif8_platform_data = {
219 .mapbase = 0xe6c30000,
220 .flags = UPF_BOOT_AUTOCONF,
221 .scscr = SCSCR_RE | SCSCR_TE,
222 .scbrr_algo_id = SCBRR_ALGO_4,
223 .type = PORT_SCIFB,
224 .irqs = { gic_spi(80), gic_spi(80),
225 gic_spi(80), gic_spi(80) },
226};
227 96
228static struct platform_device scif8_device = { 97SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
229 .name = "sh-sci", 98SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
230 .id = 8, 99SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
231 .dev = { 100SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
232 .platform_data = &scif8_platform_data, 101SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
233 }, 102SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
234}; 103SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
104SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
105SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
235 106
236static struct sh_timer_config cmt10_platform_data = { 107static struct sh_timer_config cmt10_platform_data = {
237 .name = "CMT10", 108 .name = "CMT10",
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7d8103cd3e2e..e4bf0e435af6 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -23,35 +23,34 @@
23 23
24#undef DEBUG 24#undef DEBUG
25 25
26#include <linux/module.h> 26#include <linux/clk.h>
27#include <linux/console.h>
28#include <linux/ctype.h>
29#include <linux/cpufreq.h>
30#include <linux/delay.h>
31#include <linux/dmaengine.h>
32#include <linux/dma-mapping.h>
33#include <linux/err.h>
27#include <linux/errno.h> 34#include <linux/errno.h>
28#include <linux/sh_dma.h> 35#include <linux/init.h>
29#include <linux/timer.h>
30#include <linux/interrupt.h> 36#include <linux/interrupt.h>
31#include <linux/tty.h>
32#include <linux/tty_flip.h>
33#include <linux/serial.h>
34#include <linux/major.h>
35#include <linux/string.h>
36#include <linux/sysrq.h>
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/major.h>
39#include <linux/module.h>
38#include <linux/mm.h> 40#include <linux/mm.h>
39#include <linux/init.h>
40#include <linux/delay.h>
41#include <linux/console.h>
42#include <linux/platform_device.h>
43#include <linux/serial_sci.h>
44#include <linux/notifier.h> 41#include <linux/notifier.h>
42#include <linux/platform_device.h>
45#include <linux/pm_runtime.h> 43#include <linux/pm_runtime.h>
46#include <linux/cpufreq.h>
47#include <linux/clk.h>
48#include <linux/ctype.h>
49#include <linux/err.h>
50#include <linux/dmaengine.h>
51#include <linux/dma-mapping.h>
52#include <linux/scatterlist.h> 44#include <linux/scatterlist.h>
45#include <linux/serial.h>
46#include <linux/serial_sci.h>
47#include <linux/sh_dma.h>
53#include <linux/slab.h> 48#include <linux/slab.h>
54#include <linux/gpio.h> 49#include <linux/string.h>
50#include <linux/sysrq.h>
51#include <linux/timer.h>
52#include <linux/tty.h>
53#include <linux/tty_flip.h>
55 54
56#ifdef CONFIG_SUPERH 55#ifdef CONFIG_SUPERH
57#include <asm/sh_bios.h> 56#include <asm/sh_bios.h>
@@ -64,6 +63,10 @@ struct sci_port {
64 63
65 /* Platform configuration */ 64 /* Platform configuration */
66 struct plat_sci_port *cfg; 65 struct plat_sci_port *cfg;
66 int overrun_bit;
67 unsigned int error_mask;
68 unsigned int sampling_rate;
69
67 70
68 /* Break timer */ 71 /* Break timer */
69 struct timer_list break_timer; 72 struct timer_list break_timer;
@@ -74,8 +77,8 @@ struct sci_port {
74 /* Function clock */ 77 /* Function clock */
75 struct clk *fclk; 78 struct clk *fclk;
76 79
80 int irqs[SCIx_NR_IRQS];
77 char *irqstr[SCIx_NR_IRQS]; 81 char *irqstr[SCIx_NR_IRQS];
78 char *gpiostr[SCIx_NR_FNS];
79 82
80 struct dma_chan *chan_tx; 83 struct dma_chan *chan_tx;
81 struct dma_chan *chan_rx; 84 struct dma_chan *chan_rx;
@@ -421,9 +424,9 @@ static void sci_port_enable(struct sci_port *sci_port)
421 424
422 pm_runtime_get_sync(sci_port->port.dev); 425 pm_runtime_get_sync(sci_port->port.dev);
423 426
424 clk_enable(sci_port->iclk); 427 clk_prepare_enable(sci_port->iclk);
425 sci_port->port.uartclk = clk_get_rate(sci_port->iclk); 428 sci_port->port.uartclk = clk_get_rate(sci_port->iclk);
426 clk_enable(sci_port->fclk); 429 clk_prepare_enable(sci_port->fclk);
427} 430}
428 431
429static void sci_port_disable(struct sci_port *sci_port) 432static void sci_port_disable(struct sci_port *sci_port)
@@ -431,8 +434,16 @@ static void sci_port_disable(struct sci_port *sci_port)
431 if (!sci_port->port.dev) 434 if (!sci_port->port.dev)
432 return; 435 return;
433 436
434 clk_disable(sci_port->fclk); 437 /* Cancel the break timer to ensure that the timer handler will not try
435 clk_disable(sci_port->iclk); 438 * to access the hardware with clocks and power disabled. Reset the
439 * break flag to make the break debouncing state machine ready for the
440 * next break.
441 */
442 del_timer_sync(&sci_port->break_timer);
443 sci_port->break_flag = 0;
444
445 clk_disable_unprepare(sci_port->fclk);
446 clk_disable_unprepare(sci_port->iclk);
436 447
437 pm_runtime_put_sync(sci_port->port.dev); 448 pm_runtime_put_sync(sci_port->port.dev);
438} 449}
@@ -557,7 +568,7 @@ static inline int sci_rxd_in(struct uart_port *port)
557 return 1; 568 return 1;
558 569
559 /* Cast for ARM damage */ 570 /* Cast for ARM damage */
560 return !!__raw_readb((void __iomem *)s->cfg->port_reg); 571 return !!__raw_readb((void __iomem *)(uintptr_t)s->cfg->port_reg);
561} 572}
562 573
563/* ********************************************************************** * 574/* ********************************************************************** *
@@ -733,8 +744,6 @@ static void sci_break_timer(unsigned long data)
733{ 744{
734 struct sci_port *port = (struct sci_port *)data; 745 struct sci_port *port = (struct sci_port *)data;
735 746
736 sci_port_enable(port);
737
738 if (sci_rxd_in(&port->port) == 0) { 747 if (sci_rxd_in(&port->port) == 0) {
739 port->break_flag = 1; 748 port->break_flag = 1;
740 sci_schedule_break_timer(port); 749 sci_schedule_break_timer(port);
@@ -744,8 +753,6 @@ static void sci_break_timer(unsigned long data)
744 sci_schedule_break_timer(port); 753 sci_schedule_break_timer(port);
745 } else 754 } else
746 port->break_flag = 0; 755 port->break_flag = 0;
747
748 sci_port_disable(port);
749} 756}
750 757
751static int sci_handle_errors(struct uart_port *port) 758static int sci_handle_errors(struct uart_port *port)
@@ -755,19 +762,15 @@ static int sci_handle_errors(struct uart_port *port)
755 struct tty_port *tport = &port->state->port; 762 struct tty_port *tport = &port->state->port;
756 struct sci_port *s = to_sci_port(port); 763 struct sci_port *s = to_sci_port(port);
757 764
758 /* 765 /* Handle overruns */
759 * Handle overruns, if supported. 766 if (status & (1 << s->overrun_bit)) {
760 */ 767 port->icount.overrun++;
761 if (s->cfg->overrun_bit != SCIx_NOT_SUPPORTED) {
762 if (status & (1 << s->cfg->overrun_bit)) {
763 port->icount.overrun++;
764 768
765 /* overrun error */ 769 /* overrun error */
766 if (tty_insert_flip_char(tport, 0, TTY_OVERRUN)) 770 if (tty_insert_flip_char(tport, 0, TTY_OVERRUN))
767 copied++; 771 copied++;
768 772
769 dev_notice(port->dev, "overrun error"); 773 dev_notice(port->dev, "overrun error");
770 }
771 } 774 }
772 775
773 if (status & SCxSR_FER(port)) { 776 if (status & SCxSR_FER(port)) {
@@ -829,7 +832,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port)
829 if (!reg->size) 832 if (!reg->size)
830 return 0; 833 return 0;
831 834
832 if ((serial_port_in(port, SCLSR) & (1 << s->cfg->overrun_bit))) { 835 if ((serial_port_in(port, SCLSR) & (1 << s->overrun_bit))) {
833 serial_port_out(port, SCLSR, 0); 836 serial_port_out(port, SCLSR, 0);
834 837
835 port->icount.overrun++; 838 port->icount.overrun++;
@@ -1075,19 +1078,19 @@ static int sci_request_irq(struct sci_port *port)
1075 1078
1076 for (i = j = 0; i < SCIx_NR_IRQS; i++, j++) { 1079 for (i = j = 0; i < SCIx_NR_IRQS; i++, j++) {
1077 struct sci_irq_desc *desc; 1080 struct sci_irq_desc *desc;
1078 unsigned int irq; 1081 int irq;
1079 1082
1080 if (SCIx_IRQ_IS_MUXED(port)) { 1083 if (SCIx_IRQ_IS_MUXED(port)) {
1081 i = SCIx_MUX_IRQ; 1084 i = SCIx_MUX_IRQ;
1082 irq = up->irq; 1085 irq = up->irq;
1083 } else { 1086 } else {
1084 irq = port->cfg->irqs[i]; 1087 irq = port->irqs[i];
1085 1088
1086 /* 1089 /*
1087 * Certain port types won't support all of the 1090 * Certain port types won't support all of the
1088 * available interrupt sources. 1091 * available interrupt sources.
1089 */ 1092 */
1090 if (unlikely(!irq)) 1093 if (unlikely(irq < 0))
1091 continue; 1094 continue;
1092 } 1095 }
1093 1096
@@ -1112,7 +1115,7 @@ static int sci_request_irq(struct sci_port *port)
1112 1115
1113out_noirq: 1116out_noirq:
1114 while (--i >= 0) 1117 while (--i >= 0)
1115 free_irq(port->cfg->irqs[i], port); 1118 free_irq(port->irqs[i], port);
1116 1119
1117out_nomem: 1120out_nomem:
1118 while (--j >= 0) 1121 while (--j >= 0)
@@ -1130,16 +1133,16 @@ static void sci_free_irq(struct sci_port *port)
1130 * IRQ first. 1133 * IRQ first.
1131 */ 1134 */
1132 for (i = 0; i < SCIx_NR_IRQS; i++) { 1135 for (i = 0; i < SCIx_NR_IRQS; i++) {
1133 unsigned int irq = port->cfg->irqs[i]; 1136 int irq = port->irqs[i];
1134 1137
1135 /* 1138 /*
1136 * Certain port types won't support all of the available 1139 * Certain port types won't support all of the available
1137 * interrupt sources. 1140 * interrupt sources.
1138 */ 1141 */
1139 if (unlikely(!irq)) 1142 if (unlikely(irq < 0))
1140 continue; 1143 continue;
1141 1144
1142 free_irq(port->cfg->irqs[i], port); 1145 free_irq(port->irqs[i], port);
1143 kfree(port->irqstr[i]); 1146 kfree(port->irqstr[i]);
1144 1147
1145 if (SCIx_IRQ_IS_MUXED(port)) { 1148 if (SCIx_IRQ_IS_MUXED(port)) {
@@ -1149,67 +1152,6 @@ static void sci_free_irq(struct sci_port *port)
1149 } 1152 }
1150} 1153}
1151 1154
1152static const char *sci_gpio_names[SCIx_NR_FNS] = {
1153 "sck", "rxd", "txd", "cts", "rts",
1154};
1155
1156static const char *sci_gpio_str(unsigned int index)
1157{
1158 return sci_gpio_names[index];
1159}
1160
1161static void sci_init_gpios(struct sci_port *port)
1162{
1163 struct uart_port *up = &port->port;
1164 int i;
1165
1166 if (!port->cfg)
1167 return;
1168
1169 for (i = 0; i < SCIx_NR_FNS; i++) {
1170 const char *desc;
1171 int ret;
1172
1173 if (!port->cfg->gpios[i])
1174 continue;
1175
1176 desc = sci_gpio_str(i);
1177
1178 port->gpiostr[i] = kasprintf(GFP_KERNEL, "%s:%s",
1179 dev_name(up->dev), desc);
1180
1181 /*
1182 * If we've failed the allocation, we can still continue
1183 * on with a NULL string.
1184 */
1185 if (!port->gpiostr[i])
1186 dev_notice(up->dev, "%s string allocation failure\n",
1187 desc);
1188
1189 ret = gpio_request(port->cfg->gpios[i], port->gpiostr[i]);
1190 if (unlikely(ret != 0)) {
1191 dev_notice(up->dev, "failed %s gpio request\n", desc);
1192
1193 /*
1194 * If we can't get the GPIO for whatever reason,
1195 * no point in keeping the verbose string around.
1196 */
1197 kfree(port->gpiostr[i]);
1198 }
1199 }
1200}
1201
1202static void sci_free_gpios(struct sci_port *port)
1203{
1204 int i;
1205
1206 for (i = 0; i < SCIx_NR_FNS; i++)
1207 if (port->cfg->gpios[i]) {
1208 gpio_free(port->cfg->gpios[i]);
1209 kfree(port->gpiostr[i]);
1210 }
1211}
1212
1213static unsigned int sci_tx_empty(struct uart_port *port) 1155static unsigned int sci_tx_empty(struct uart_port *port)
1214{ 1156{
1215 unsigned short status = serial_port_in(port, SCxSR); 1157 unsigned short status = serial_port_in(port, SCxSR);
@@ -1309,7 +1251,7 @@ static int sci_dma_rx_push(struct sci_port *s, size_t count)
1309 } 1251 }
1310 1252
1311 if (room < count) 1253 if (room < count)
1312 dev_warn(port->dev, "Rx overrun: dropping %u bytes\n", 1254 dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
1313 count - room); 1255 count - room);
1314 if (!room) 1256 if (!room)
1315 return room; 1257 return room;
@@ -1442,7 +1384,7 @@ static void work_fn_rx(struct work_struct *work)
1442 int count; 1384 int count;
1443 1385
1444 chan->device->device_control(chan, DMA_TERMINATE_ALL, 0); 1386 chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
1445 dev_dbg(port->dev, "Read %u bytes with cookie %d\n", 1387 dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
1446 sh_desc->partial, sh_desc->cookie); 1388 sh_desc->partial, sh_desc->cookie);
1447 1389
1448 spin_lock_irqsave(&port->lock, flags); 1390 spin_lock_irqsave(&port->lock, flags);
@@ -1655,7 +1597,7 @@ static void rx_timer_fn(unsigned long arg)
1655 1597
1656 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1598 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1657 scr &= ~0x4000; 1599 scr &= ~0x4000;
1658 enable_irq(s->cfg->irqs[1]); 1600 enable_irq(s->irqs[SCIx_RXI_IRQ]);
1659 } 1601 }
1660 serial_port_out(port, SCSCR, scr | SCSCR_RIE); 1602 serial_port_out(port, SCSCR, scr | SCSCR_RIE);
1661 dev_dbg(port->dev, "DMA Rx timed out\n"); 1603 dev_dbg(port->dev, "DMA Rx timed out\n");
@@ -1691,16 +1633,17 @@ static void sci_request_dma(struct uart_port *port)
1691 s->chan_tx = chan; 1633 s->chan_tx = chan;
1692 sg_init_table(&s->sg_tx, 1); 1634 sg_init_table(&s->sg_tx, 1);
1693 /* UART circular tx buffer is an aligned page. */ 1635 /* UART circular tx buffer is an aligned page. */
1694 BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK); 1636 BUG_ON((uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
1695 sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf), 1637 sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf),
1696 UART_XMIT_SIZE, (int)port->state->xmit.buf & ~PAGE_MASK); 1638 UART_XMIT_SIZE,
1639 (uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
1697 nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE); 1640 nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE);
1698 if (!nent) 1641 if (!nent)
1699 sci_tx_dma_release(s, false); 1642 sci_tx_dma_release(s, false);
1700 else 1643 else
1701 dev_dbg(port->dev, "%s: mapped %d@%p to %x\n", __func__, 1644 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__,
1702 sg_dma_len(&s->sg_tx), 1645 sg_dma_len(&s->sg_tx), port->state->xmit.buf,
1703 port->state->xmit.buf, sg_dma_address(&s->sg_tx)); 1646 &sg_dma_address(&s->sg_tx));
1704 1647
1705 s->sg_len_tx = nent; 1648 s->sg_len_tx = nent;
1706 1649
@@ -1740,7 +1683,7 @@ static void sci_request_dma(struct uart_port *port)
1740 1683
1741 sg_init_table(sg, 1); 1684 sg_init_table(sg, 1);
1742 sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx, 1685 sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
1743 (int)buf[i] & ~PAGE_MASK); 1686 (uintptr_t)buf[i] & ~PAGE_MASK);
1744 sg_dma_address(sg) = dma[i]; 1687 sg_dma_address(sg) = dma[i];
1745 } 1688 }
1746 1689
@@ -1808,20 +1751,21 @@ static void sci_shutdown(struct uart_port *port)
1808 sci_free_irq(s); 1751 sci_free_irq(s);
1809} 1752}
1810 1753
1811static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, 1754static unsigned int sci_scbrr_calc(struct sci_port *s, unsigned int bps,
1812 unsigned long freq) 1755 unsigned long freq)
1813{ 1756{
1814 switch (algo_id) { 1757 if (s->sampling_rate)
1758 return DIV_ROUND_CLOSEST(freq, s->sampling_rate * bps) - 1;
1759
1760 switch (s->cfg->scbrr_algo_id) {
1815 case SCBRR_ALGO_1: 1761 case SCBRR_ALGO_1:
1816 return ((freq + 16 * bps) / (16 * bps) - 1); 1762 return freq / (16 * bps);
1817 case SCBRR_ALGO_2: 1763 case SCBRR_ALGO_2:
1818 return ((freq + 16 * bps) / (32 * bps) - 1); 1764 return DIV_ROUND_CLOSEST(freq, 32 * bps) - 1;
1819 case SCBRR_ALGO_3: 1765 case SCBRR_ALGO_3:
1820 return (((freq * 2) + 16 * bps) / (16 * bps) - 1); 1766 return freq / (8 * bps);
1821 case SCBRR_ALGO_4: 1767 case SCBRR_ALGO_4:
1822 return (((freq * 2) + 16 * bps) / (32 * bps) - 1); 1768 return DIV_ROUND_CLOSEST(freq, 16 * bps) - 1;
1823 case SCBRR_ALGO_5:
1824 return (((freq * 1000 / 32) / bps) - 1);
1825 } 1769 }
1826 1770
1827 /* Warn, but use a safe default */ 1771 /* Warn, but use a safe default */
@@ -1903,12 +1847,11 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1903 1847
1904 baud = uart_get_baud_rate(port, termios, old, 0, max_baud); 1848 baud = uart_get_baud_rate(port, termios, old, 0, max_baud);
1905 if (likely(baud && port->uartclk)) { 1849 if (likely(baud && port->uartclk)) {
1906 if (s->cfg->scbrr_algo_id == SCBRR_ALGO_6) { 1850 if (s->cfg->type == PORT_HSCIF) {
1907 sci_baud_calc_hscif(baud, port->uartclk, &t, &srr, 1851 sci_baud_calc_hscif(baud, port->uartclk, &t, &srr,
1908 &cks); 1852 &cks);
1909 } else { 1853 } else {
1910 t = sci_scbrr_calc(s->cfg->scbrr_algo_id, baud, 1854 t = sci_scbrr_calc(s, baud, port->uartclk);
1911 port->uartclk);
1912 for (cks = 0; t >= 256 && cks <= 3; cks++) 1855 for (cks = 0; t >= 256 && cks <= 3; cks++)
1913 t >>= 2; 1856 t >>= 2;
1914 } 1857 }
@@ -2115,10 +2058,6 @@ static void sci_config_port(struct uart_port *port, int flags)
2115 2058
2116static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) 2059static int sci_verify_port(struct uart_port *port, struct serial_struct *ser)
2117{ 2060{
2118 struct sci_port *s = to_sci_port(port);
2119
2120 if (ser->irq != s->cfg->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs)
2121 return -EINVAL;
2122 if (ser->baud_base < 2400) 2061 if (ser->baud_base < 2400)
2123 /* No paper tape reader for Mitch.. */ 2062 /* No paper tape reader for Mitch.. */
2124 return -EINVAL; 2063 return -EINVAL;
@@ -2151,11 +2090,13 @@ static struct uart_ops sci_uart_ops = {
2151}; 2090};
2152 2091
2153static int sci_init_single(struct platform_device *dev, 2092static int sci_init_single(struct platform_device *dev,
2154 struct sci_port *sci_port, 2093 struct sci_port *sci_port, unsigned int index,
2155 unsigned int index, 2094 struct plat_sci_port *p, bool early)
2156 struct plat_sci_port *p)
2157{ 2095{
2158 struct uart_port *port = &sci_port->port; 2096 struct uart_port *port = &sci_port->port;
2097 const struct resource *res;
2098 unsigned int sampling_rate;
2099 unsigned int i;
2159 int ret; 2100 int ret;
2160 2101
2161 sci_port->cfg = p; 2102 sci_port->cfg = p;
@@ -2164,31 +2105,90 @@ static int sci_init_single(struct platform_device *dev,
2164 port->iotype = UPIO_MEM; 2105 port->iotype = UPIO_MEM;
2165 port->line = index; 2106 port->line = index;
2166 2107
2108 if (dev->num_resources) {
2109 /* Device has resources, use them. */
2110 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
2111 if (res == NULL)
2112 return -ENOMEM;
2113
2114 port->mapbase = res->start;
2115
2116 for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i)
2117 sci_port->irqs[i] = platform_get_irq(dev, i);
2118
2119 /* The SCI generates several interrupts. They can be muxed
2120 * together or connected to different interrupt lines. In the
2121 * muxed case only one interrupt resource is specified. In the
2122 * non-muxed case three or four interrupt resources are
2123 * specified, as the BRI interrupt is optional.
2124 */
2125 if (sci_port->irqs[0] < 0)
2126 return -ENXIO;
2127
2128 if (sci_port->irqs[1] < 0) {
2129 sci_port->irqs[1] = sci_port->irqs[0];
2130 sci_port->irqs[2] = sci_port->irqs[0];
2131 sci_port->irqs[3] = sci_port->irqs[0];
2132 }
2133 } else {
2134 /* No resources, use old-style platform data. */
2135 port->mapbase = p->mapbase;
2136 for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i)
2137 sci_port->irqs[i] = p->irqs[i] ? p->irqs[i] : -ENXIO;
2138 }
2139
2140 if (p->regtype == SCIx_PROBE_REGTYPE) {
2141 ret = sci_probe_regmap(p);
2142 if (unlikely(ret))
2143 return ret;
2144 }
2145
2167 switch (p->type) { 2146 switch (p->type) {
2168 case PORT_SCIFB: 2147 case PORT_SCIFB:
2169 port->fifosize = 256; 2148 port->fifosize = 256;
2149 sci_port->overrun_bit = 9;
2150 sampling_rate = 16;
2170 break; 2151 break;
2171 case PORT_HSCIF: 2152 case PORT_HSCIF:
2172 port->fifosize = 128; 2153 port->fifosize = 128;
2154 sampling_rate = 0;
2155 sci_port->overrun_bit = 0;
2173 break; 2156 break;
2174 case PORT_SCIFA: 2157 case PORT_SCIFA:
2175 port->fifosize = 64; 2158 port->fifosize = 64;
2159 sci_port->overrun_bit = 9;
2160 sampling_rate = 16;
2176 break; 2161 break;
2177 case PORT_SCIF: 2162 case PORT_SCIF:
2178 port->fifosize = 16; 2163 port->fifosize = 16;
2164 if (p->regtype == SCIx_SH7705_SCIF_REGTYPE) {
2165 sci_port->overrun_bit = 9;
2166 sampling_rate = 16;
2167 } else {
2168 sci_port->overrun_bit = 0;
2169 sampling_rate = 32;
2170 }
2179 break; 2171 break;
2180 default: 2172 default:
2181 port->fifosize = 1; 2173 port->fifosize = 1;
2174 sci_port->overrun_bit = 5;
2175 sampling_rate = 32;
2182 break; 2176 break;
2183 } 2177 }
2184 2178
2185 if (p->regtype == SCIx_PROBE_REGTYPE) { 2179 /* Set the sampling rate if the baud rate calculation algorithm isn't
2186 ret = sci_probe_regmap(p); 2180 * specified.
2187 if (unlikely(ret)) 2181 */
2188 return ret; 2182 if (p->scbrr_algo_id == SCBRR_ALGO_NONE) {
2183 /* SCIFA on sh7723 and sh7724 need a custom sampling rate that
2184 * doesn't match the SoC datasheet, this should be investigated.
2185 * Let platform data override the sampling rate for now.
2186 */
2187 sci_port->sampling_rate = p->sampling_rate ? p->sampling_rate
2188 : sampling_rate;
2189 } 2189 }
2190 2190
2191 if (dev) { 2191 if (!early) {
2192 sci_port->iclk = clk_get(&dev->dev, "sci_ick"); 2192 sci_port->iclk = clk_get(&dev->dev, "sci_ick");
2193 if (IS_ERR(sci_port->iclk)) { 2193 if (IS_ERR(sci_port->iclk)) {
2194 sci_port->iclk = clk_get(&dev->dev, "peripheral_clk"); 2194 sci_port->iclk = clk_get(&dev->dev, "peripheral_clk");
@@ -2208,8 +2208,6 @@ static int sci_init_single(struct platform_device *dev,
2208 2208
2209 port->dev = &dev->dev; 2209 port->dev = &dev->dev;
2210 2210
2211 sci_init_gpios(sci_port);
2212
2213 pm_runtime_enable(&dev->dev); 2211 pm_runtime_enable(&dev->dev);
2214 } 2212 }
2215 2213
@@ -2220,32 +2218,22 @@ static int sci_init_single(struct platform_device *dev,
2220 /* 2218 /*
2221 * Establish some sensible defaults for the error detection. 2219 * Establish some sensible defaults for the error detection.
2222 */ 2220 */
2223 if (!p->error_mask) 2221 sci_port->error_mask = (p->type == PORT_SCI) ?
2224 p->error_mask = (p->type == PORT_SCI) ?
2225 SCI_DEFAULT_ERROR_MASK : SCIF_DEFAULT_ERROR_MASK; 2222 SCI_DEFAULT_ERROR_MASK : SCIF_DEFAULT_ERROR_MASK;
2226 2223
2227 /* 2224 /*
2228 * Establish sensible defaults for the overrun detection, unless 2225 * Establish sensible defaults for the overrun detection, unless
2229 * the part has explicitly disabled support for it. 2226 * the part has explicitly disabled support for it.
2230 */ 2227 */
2231 if (p->overrun_bit != SCIx_NOT_SUPPORTED) {
2232 if (p->type == PORT_SCI)
2233 p->overrun_bit = 5;
2234 else if (p->scbrr_algo_id == SCBRR_ALGO_4)
2235 p->overrun_bit = 9;
2236 else
2237 p->overrun_bit = 0;
2238 2228
2239 /* 2229 /*
2240 * Make the error mask inclusive of overrun detection, if 2230 * Make the error mask inclusive of overrun detection, if
2241 * supported. 2231 * supported.
2242 */ 2232 */
2243 p->error_mask |= (1 << p->overrun_bit); 2233 sci_port->error_mask |= 1 << sci_port->overrun_bit;
2244 }
2245 2234
2246 port->mapbase = p->mapbase;
2247 port->type = p->type; 2235 port->type = p->type;
2248 port->flags = p->flags; 2236 port->flags = UPF_FIXED_PORT | p->flags;
2249 port->regshift = p->regshift; 2237 port->regshift = p->regshift;
2250 2238
2251 /* 2239 /*
@@ -2255,7 +2243,7 @@ static int sci_init_single(struct platform_device *dev,
2255 * 2243 *
2256 * For the muxed case there's nothing more to do. 2244 * For the muxed case there's nothing more to do.
2257 */ 2245 */
2258 port->irq = p->irqs[SCIx_RXI_IRQ]; 2246 port->irq = sci_port->irqs[SCIx_RXI_IRQ];
2259 port->irqflags = 0; 2247 port->irqflags = 0;
2260 2248
2261 port->serial_in = sci_serial_in; 2249 port->serial_in = sci_serial_in;
@@ -2270,8 +2258,6 @@ static int sci_init_single(struct platform_device *dev,
2270 2258
2271static void sci_cleanup_single(struct sci_port *port) 2259static void sci_cleanup_single(struct sci_port *port)
2272{ 2260{
2273 sci_free_gpios(port);
2274
2275 clk_put(port->iclk); 2261 clk_put(port->iclk);
2276 clk_put(port->fclk); 2262 clk_put(port->fclk);
2277 2263
@@ -2387,7 +2373,7 @@ static int sci_probe_earlyprintk(struct platform_device *pdev)
2387 2373
2388 early_serial_console.index = pdev->id; 2374 early_serial_console.index = pdev->id;
2389 2375
2390 sci_init_single(NULL, &sci_ports[pdev->id], pdev->id, cfg); 2376 sci_init_single(pdev, &sci_ports[pdev->id], pdev->id, cfg, true);
2391 2377
2392 serial_console_setup(&early_serial_console, early_serial_buf); 2378 serial_console_setup(&early_serial_console, early_serial_buf);
2393 2379
@@ -2454,7 +2440,7 @@ static int sci_probe_single(struct platform_device *dev,
2454 return -EINVAL; 2440 return -EINVAL;
2455 } 2441 }
2456 2442
2457 ret = sci_init_single(dev, sciport, index, p); 2443 ret = sci_init_single(dev, sciport, index, p, false);
2458 if (ret) 2444 if (ret)
2459 return ret; 2445 return ret;
2460 2446
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index 5aca7364634c..d5db81a0a430 100644
--- a/drivers/tty/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
@@ -9,7 +9,7 @@
9#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) 9#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
10#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) 10#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
11 11
12#define SCxSR_ERRORS(port) (to_sci_port(port)->cfg->error_mask) 12#define SCxSR_ERRORS(port) (to_sci_port(port)->error_mask)
13 13
14#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 14#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h
index 50fe651da965..af414e1895a5 100644
--- a/include/linux/serial_sci.h
+++ b/include/linux/serial_sci.h
@@ -11,11 +11,11 @@
11#define SCIx_NOT_SUPPORTED (-1) 11#define SCIx_NOT_SUPPORTED (-1)
12 12
13enum { 13enum {
14 SCBRR_ALGO_1, /* ((clk + 16 * bps) / (16 * bps) - 1) */ 14 SCBRR_ALGO_NONE, /* Compute sampling rate in the driver */
15 SCBRR_ALGO_2, /* ((clk + 16 * bps) / (32 * bps) - 1) */ 15 SCBRR_ALGO_1, /* clk / (16 * bps) */
16 SCBRR_ALGO_3, /* (((clk * 2) + 16 * bps) / (16 * bps) - 1) */ 16 SCBRR_ALGO_2, /* DIV_ROUND_CLOSEST(clk, 32 * bps) - 1 */
17 SCBRR_ALGO_4, /* (((clk * 2) + 16 * bps) / (32 * bps) - 1) */ 17 SCBRR_ALGO_3, /* clk / (8 * bps) */
18 SCBRR_ALGO_5, /* (((clk * 1000 / 32) / bps) - 1) */ 18 SCBRR_ALGO_4, /* DIV_ROUND_CLOSEST(clk, 16 * bps) - 1 */
19 SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */ 19 SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */
20}; 20};
21 21
@@ -70,17 +70,6 @@ enum {
70 SCIx_MUX_IRQ = SCIx_NR_IRQS, /* special case */ 70 SCIx_MUX_IRQ = SCIx_NR_IRQS, /* special case */
71}; 71};
72 72
73/* Offsets into the sci_port->gpios array */
74enum {
75 SCIx_SCK,
76 SCIx_RXD,
77 SCIx_TXD,
78 SCIx_CTS,
79 SCIx_RTS,
80
81 SCIx_NR_FNS,
82};
83
84enum { 73enum {
85 SCIx_PROBE_REGTYPE, 74 SCIx_PROBE_REGTYPE,
86 75
@@ -108,10 +97,10 @@ enum {
108} 97}
109 98
110#define SCIx_IRQ_IS_MUXED(port) \ 99#define SCIx_IRQ_IS_MUXED(port) \
111 ((port)->cfg->irqs[SCIx_ERI_IRQ] == \ 100 ((port)->irqs[SCIx_ERI_IRQ] == \
112 (port)->cfg->irqs[SCIx_RXI_IRQ]) || \ 101 (port)->irqs[SCIx_RXI_IRQ]) || \
113 ((port)->cfg->irqs[SCIx_ERI_IRQ] && \ 102 ((port)->irqs[SCIx_ERI_IRQ] && \
114 !(port)->cfg->irqs[SCIx_RXI_IRQ]) 103 ((port)->irqs[SCIx_RXI_IRQ] < 0))
115/* 104/*
116 * SCI register subset common for all port types. 105 * SCI register subset common for all port types.
117 * Not all registers will exist on all parts. 106 * Not all registers will exist on all parts.
@@ -142,20 +131,17 @@ struct plat_sci_port_ops {
142struct plat_sci_port { 131struct plat_sci_port {
143 unsigned long mapbase; /* resource base */ 132 unsigned long mapbase; /* resource base */
144 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */ 133 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */
145 unsigned int gpios[SCIx_NR_FNS]; /* SCK, RXD, TXD, CTS, RTS */
146 unsigned int type; /* SCI / SCIF / IRDA / HSCIF */ 134 unsigned int type; /* SCI / SCIF / IRDA / HSCIF */
147 upf_t flags; /* UPF_* flags */ 135 upf_t flags; /* UPF_* flags */
148 unsigned long capabilities; /* Port features/capabilities */ 136 unsigned long capabilities; /* Port features/capabilities */
149 137
138 unsigned int sampling_rate;
150 unsigned int scbrr_algo_id; /* SCBRR calculation algo */ 139 unsigned int scbrr_algo_id; /* SCBRR calculation algo */
151 unsigned int scscr; /* SCSCR initialization */ 140 unsigned int scscr; /* SCSCR initialization */
152 141
153 /* 142 /*
154 * Platform overrides if necessary, defaults otherwise. 143 * Platform overrides if necessary, defaults otherwise.
155 */ 144 */
156 int overrun_bit;
157 unsigned int error_mask;
158
159 int port_reg; 145 int port_reg;
160 unsigned char regshift; 146 unsigned char regshift;
161 unsigned char regtype; 147 unsigned char regtype;