blob: c034ab54e15224d6eaabddd0111a3a8597d6de3e [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +09002/*
3 * SuperH SCIF device driver.
Nobuhiro Iwamatsu788b73f2013-07-23 13:58:20 +09004 * Copyright (C) 2013 Renesas Electronics Corporation
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +09005 * Copyright (C) 2007,2008,2010, 2014 Nobuhiro Iwamatsu
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +09006 * Copyright (C) 2002 - 2008 Paul Mundt
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +09007 */
8
9#include <common.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060010#include <asm/global_data.h>
Jean-Christophe PLAGNIOL-VILLARDb27a8e32009-01-11 16:35:16 +010011#include <asm/io.h>
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090012#include <asm/processor.h>
Paul Barker476f68a2023-10-16 10:25:35 +010013#include <clk.h>
14#include <dm.h>
Paul Barker327571c2023-10-19 15:30:44 +010015#include <dm/device_compat.h>
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090016#include <dm/platform_data/serial_sh.h>
Paul Barker476f68a2023-10-16 10:25:35 +010017#include <errno.h>
18#include <linux/compiler.h>
Simon Glassdbd79542020-05-10 11:40:11 -060019#include <linux/delay.h>
Paul Barker327571c2023-10-19 15:30:44 +010020#include <reset.h>
Paul Barker476f68a2023-10-16 10:25:35 +010021#include <serial.h>
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090022#include "serial_sh.h"
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090023
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +090024DECLARE_GLOBAL_DATA_PTR;
25
Marek Vasut39df77a2019-05-07 22:31:23 +020026#if defined(CONFIG_CPU_SH7780)
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090027static int scif_rxfill(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090028{
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090029 return sci_in(port, SCRFDR) & 0xff;
30}
31#elif defined(CONFIG_CPU_SH7763)
32static int scif_rxfill(struct uart_port *port)
33{
34 if ((port->mapbase == 0xffe00000) ||
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090035 (port->mapbase == 0xffe08000)) {
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090036 /* SCIF0/1*/
37 return sci_in(port, SCRFDR) & 0xff;
38 } else {
39 /* SCIF2 */
40 return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
41 }
42}
Nobuhiro Iwamatsu1b36beb2008-03-06 14:05:53 +090043#else
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090044static int scif_rxfill(struct uart_port *port)
45{
46 return sci_in(port, SCFDR) & SCIF_RFDC_MASK;
47}
Nobuhiro Iwamatsu1b36beb2008-03-06 14:05:53 +090048#endif
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090049
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090050static void sh_serial_init_generic(struct uart_port *port)
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090051{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090052 sci_out(port, SCSCR , SCSCR_INIT(port));
53 sci_out(port, SCSCR , SCSCR_INIT(port));
54 sci_out(port, SCSMR, 0);
55 sci_out(port, SCSMR, 0);
56 sci_out(port, SCFCR, SCFCR_RFRST|SCFCR_TFRST);
57 sci_in(port, SCFCR);
58 sci_out(port, SCFCR, 0);
Marek Vasut2d2e3ff2019-05-01 18:20:00 +020059#if defined(CONFIG_RZA1)
60 sci_out(port, SCSPTR, 0x0003);
61#endif
Hai Pham19923d82023-02-28 22:29:19 +010062
Paul Barkeraa173962023-10-16 10:25:23 +010063#if IS_ENABLED(CONFIG_RCAR_GEN2) || IS_ENABLED(CONFIG_RCAR_GEN3) || IS_ENABLED(CONFIG_RCAR_GEN4)
Hai Pham19923d82023-02-28 22:29:19 +010064 if (port->type == PORT_HSCIF)
65 sci_out(port, HSSRR, HSSRR_SRE | HSSRR_SRCYC8);
Paul Barkeraa173962023-10-16 10:25:23 +010066#endif
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090067}
68
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090069static void
70sh_serial_setbrg_generic(struct uart_port *port, int clk, int baudrate)
Tetsuyuki Kobayashi5d2b5a22012-11-19 21:37:38 +000071{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090072 if (port->clk_mode == EXT_CLK) {
73 unsigned short dl = DL_VALUE(baudrate, clk);
74 sci_out(port, DL, dl);
Nobuhiro Iwamatsu17861752014-12-10 14:42:05 +090075 /* Need wait: Clock * 1/dl * 1/16 */
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090076 udelay((1000000 * dl * 16 / clk) * 1000 + 1);
77 } else {
78 sci_out(port, SCBRR, SCBRR_VALUE(baudrate, clk));
79 }
Tetsuyuki Kobayashi5d2b5a22012-11-19 21:37:38 +000080}
81
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090082static void handle_error(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090083{
Paul Barkera9b47022023-10-19 15:30:43 +010084 /*
85 * Most errors are cleared by resetting the relevant error bits to zero
86 * in the FSR & LSR registers. For each register, a read followed by a
87 * write is needed according to the relevant datasheets.
88 */
89 unsigned short status = sci_in(port, SCxSR);
90 sci_out(port, SCxSR, status & ~SCxSR_ERRORS(port));
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090091 sci_in(port, SCLSR);
92 sci_out(port, SCLSR, 0x00);
Paul Barkera9b47022023-10-19 15:30:43 +010093
94 /*
95 * To clear framing errors, we also need to read and discard a
96 * character.
97 */
98 if ((port->type != PORT_SCI) && (status & SCIF_FER))
99 sci_in(port, SCxRDR);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900100}
101
102static int serial_raw_putc(struct uart_port *port, const char c)
103{
104 /* Tx fifo is empty */
105 if (!(sci_in(port, SCxSR) & SCxSR_TEND(port)))
106 return -EAGAIN;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900107
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900108 sci_out(port, SCxTDR, c);
109 sci_out(port, SCxSR, sci_in(port, SCxSR) & ~SCxSR_TEND(port));
110
111 return 0;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900112}
113
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900114static int serial_rx_fifo_level(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900115{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900116 return scif_rxfill(port);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900117}
118
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900119static int sh_serial_tstc_generic(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900120{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900121 if (sci_in(port, SCxSR) & SCIF_ERRORS) {
122 handle_error(port);
Tetsuyuki Kobayashi5d2b5a22012-11-19 21:37:38 +0000123 return 0;
124 }
125
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900126 return serial_rx_fifo_level(port) ? 1 : 0;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900127}
128
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900129static int serial_getc_check(struct uart_port *port)
Nobuhiro Iwamatsu6564b1a2008-06-06 16:16:08 +0900130{
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900131 unsigned short status;
132
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900133 status = sci_in(port, SCxSR);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900134
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +0900135 if (status & SCIF_ERRORS)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900136 handle_error(port);
137 if (sci_in(port, SCLSR) & SCxSR_ORER(port))
138 handle_error(port);
Marek Vasutd88686b2020-05-09 22:30:05 +0200139 status &= (SCIF_DR | SCxSR_RDxF(port));
140 if (status)
141 return status;
142 return scif_rxfill(port);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900143}
144
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900145static int sh_serial_getc_generic(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900146{
Nobuhiro Iwamatsu6564b1a2008-06-06 16:16:08 +0900147 unsigned short status;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900148 char ch;
Nobuhiro Iwamatsufcabccc2008-08-22 17:48:51 +0900149
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900150 if (!serial_getc_check(port))
151 return -EAGAIN;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900152
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900153 ch = sci_in(port, SCxRDR);
154 status = sci_in(port, SCxSR);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900155
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900156 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900157
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +0900158 if (status & SCIF_ERRORS)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900159 handle_error(port);
160
161 if (sci_in(port, SCLSR) & SCxSR_ORER(port))
162 handle_error(port);
163
164 return ch;
165}
166
Marek Vasut0dfa9912018-02-16 01:33:27 +0100167#if CONFIG_IS_ENABLED(DM_SERIAL)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900168
169static int sh_serial_pending(struct udevice *dev, bool input)
170{
171 struct uart_port *priv = dev_get_priv(dev);
172
173 return sh_serial_tstc_generic(priv);
174}
175
176static int sh_serial_putc(struct udevice *dev, const char ch)
177{
178 struct uart_port *priv = dev_get_priv(dev);
179
180 return serial_raw_putc(priv, ch);
181}
182
183static int sh_serial_getc(struct udevice *dev)
184{
185 struct uart_port *priv = dev_get_priv(dev);
186
187 return sh_serial_getc_generic(priv);
188}
189
190static int sh_serial_setbrg(struct udevice *dev, int baudrate)
191{
Simon Glassb75b15b2020-12-03 16:55:23 -0700192 struct sh_serial_plat *plat = dev_get_plat(dev);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900193 struct uart_port *priv = dev_get_priv(dev);
194
195 sh_serial_setbrg_generic(priv, plat->clk, baudrate);
196
197 return 0;
198}
199
200static int sh_serial_probe(struct udevice *dev)
201{
Simon Glassb75b15b2020-12-03 16:55:23 -0700202 struct sh_serial_plat *plat = dev_get_plat(dev);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900203 struct uart_port *priv = dev_get_priv(dev);
Paul Barker327571c2023-10-19 15:30:44 +0100204 struct reset_ctl rst;
205 int ret;
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900206
207 priv->membase = (unsigned char *)plat->base;
208 priv->mapbase = plat->base;
209 priv->type = plat->type;
210 priv->clk_mode = plat->clk_mode;
211
Paul Barker327571c2023-10-19 15:30:44 +0100212 /* De-assert the module reset if it is defined. */
213 ret = reset_get_by_index(dev, 0, &rst);
214 if (!ret) {
215 ret = reset_deassert(&rst);
216 if (ret < 0) {
217 dev_err(dev, "failed to de-assert reset line\n");
218 return ret;
219 }
220 }
221
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900222 sh_serial_init_generic(priv);
223
224 return 0;
225}
226
227static const struct dm_serial_ops sh_serial_ops = {
228 .putc = sh_serial_putc,
229 .pending = sh_serial_pending,
230 .getc = sh_serial_getc,
231 .setbrg = sh_serial_setbrg,
232};
233
Marek Vasut0dfa9912018-02-16 01:33:27 +0100234#if CONFIG_IS_ENABLED(OF_CONTROL)
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900235static const struct udevice_id sh_serial_id[] ={
Yoshinori Satoe5669a32016-04-18 16:51:05 +0900236 {.compatible = "renesas,sci", .data = PORT_SCI},
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900237 {.compatible = "renesas,scif", .data = PORT_SCIF},
Paul Barker327571c2023-10-19 15:30:44 +0100238 {.compatible = "renesas,scif-r9a07g044", .data = PORT_SCIFA},
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900239 {.compatible = "renesas,scifa", .data = PORT_SCIFA},
Hai Pham19923d82023-02-28 22:29:19 +0100240 {.compatible = "renesas,hscif", .data = PORT_HSCIF},
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900241 {}
242};
243
Simon Glassaad29ae2020-12-03 16:55:21 -0700244static int sh_serial_of_to_plat(struct udevice *dev)
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900245{
Simon Glassb75b15b2020-12-03 16:55:23 -0700246 struct sh_serial_plat *plat = dev_get_plat(dev);
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200247 struct clk sh_serial_clk;
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900248 fdt_addr_t addr;
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200249 int ret;
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900250
Masahiro Yamadaa89b4de2020-07-17 14:36:48 +0900251 addr = dev_read_addr(dev);
Marek Vasut48db7762018-01-17 22:36:37 +0100252 if (!addr)
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900253 return -EINVAL;
254
255 plat->base = addr;
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200256
257 ret = clk_get_by_name(dev, "fck", &sh_serial_clk);
Marek Vasutfd6a4a72017-09-15 21:11:27 +0200258 if (!ret) {
259 ret = clk_enable(&sh_serial_clk);
260 if (!ret)
261 plat->clk = clk_get_rate(&sh_serial_clk);
262 } else {
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200263 plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
264 "clock", 1);
Marek Vasutfd6a4a72017-09-15 21:11:27 +0200265 }
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200266
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900267 plat->type = dev_get_driver_data(dev);
268 return 0;
269}
270#endif
271
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900272U_BOOT_DRIVER(serial_sh) = {
273 .name = "serial_sh",
274 .id = UCLASS_SERIAL,
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900275 .of_match = of_match_ptr(sh_serial_id),
Simon Glassaad29ae2020-12-03 16:55:21 -0700276 .of_to_plat = of_match_ptr(sh_serial_of_to_plat),
Simon Glassb75b15b2020-12-03 16:55:23 -0700277 .plat_auto = sizeof(struct sh_serial_plat),
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900278 .probe = sh_serial_probe,
279 .ops = &sh_serial_ops,
Bin Mengbdb33d82018-10-24 06:36:36 -0700280#if !CONFIG_IS_ENABLED(OF_CONTROL)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900281 .flags = DM_FLAG_PRE_RELOC,
Bin Mengbdb33d82018-10-24 06:36:36 -0700282#endif
Simon Glass8a2b47f2020-12-03 16:55:17 -0700283 .priv_auto = sizeof(struct uart_port),
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900284};
Marek Vasut98ae2812023-02-28 22:17:22 +0100285#endif
286
287#if !CONFIG_IS_ENABLED(DM_SERIAL) || IS_ENABLED(CONFIG_DEBUG_UART_SCIF)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900288
Marek Vasut98ae2812023-02-28 22:17:22 +0100289#if defined(CFG_SCIF_A)
290 #define SCIF_BASE_PORT PORT_SCIFA
291#elif defined(CFG_SCI)
292 #define SCIF_BASE_PORT PORT_SCI
Hai Pham19923d82023-02-28 22:29:19 +0100293#elif defined(CFG_HSCIF)
294 #define SCIF_BASE_PORT PORT_HSCIF
Marek Vasut98ae2812023-02-28 22:17:22 +0100295#else
296 #define SCIF_BASE_PORT PORT_SCIF
297#endif
298
299static void sh_serial_init_nodm(struct uart_port *port)
300{
301 sh_serial_init_generic(port);
302 serial_setbrg();
303}
304
305static void sh_serial_putc_nondm(struct uart_port *port, const char c)
306{
307 if (c == '\n') {
308 while (1) {
309 if (serial_raw_putc(port, '\r') != -EAGAIN)
310 break;
311 }
312 }
313 while (1) {
314 if (serial_raw_putc(port, c) != -EAGAIN)
315 break;
316 }
317}
318#endif
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900319
Marek Vasut98ae2812023-02-28 22:17:22 +0100320#if !CONFIG_IS_ENABLED(DM_SERIAL)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900321#if defined(CONFIG_CONS_SCIF0)
322# define SCIF_BASE SCIF0_BASE
323#elif defined(CONFIG_CONS_SCIF1)
324# define SCIF_BASE SCIF1_BASE
325#elif defined(CONFIG_CONS_SCIF2)
326# define SCIF_BASE SCIF2_BASE
327#elif defined(CONFIG_CONS_SCIF3)
328# define SCIF_BASE SCIF3_BASE
329#elif defined(CONFIG_CONS_SCIF4)
330# define SCIF_BASE SCIF4_BASE
331#elif defined(CONFIG_CONS_SCIF5)
332# define SCIF_BASE SCIF5_BASE
333#elif defined(CONFIG_CONS_SCIF6)
334# define SCIF_BASE SCIF6_BASE
335#elif defined(CONFIG_CONS_SCIF7)
336# define SCIF_BASE SCIF7_BASE
Marek Vasut1d9756b2018-04-12 15:23:46 +0200337#elif defined(CONFIG_CONS_SCIFA0)
338# define SCIF_BASE SCIFA0_BASE
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900339#else
340# error "Default SCIF doesn't set....."
341#endif
342
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900343static struct uart_port sh_sci = {
344 .membase = (unsigned char *)SCIF_BASE,
345 .mapbase = SCIF_BASE,
346 .type = SCIF_BASE_PORT,
Marek Vasutb811f9b2023-02-28 22:17:21 +0100347#ifdef CFG_SCIF_USE_EXT_CLK
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900348 .clk_mode = EXT_CLK,
349#endif
350};
351
352static void sh_serial_setbrg(void)
353{
354 DECLARE_GLOBAL_DATA_PTR;
355 struct uart_port *port = &sh_sci;
356
357 sh_serial_setbrg_generic(port, CONFIG_SH_SCIF_CLK_FREQ, gd->baudrate);
358}
359
360static int sh_serial_init(void)
361{
Marek Vasut98ae2812023-02-28 22:17:22 +0100362 sh_serial_init_nodm(&sh_sci);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900363
364 return 0;
365}
366
367static void sh_serial_putc(const char c)
368{
Marek Vasut98ae2812023-02-28 22:17:22 +0100369 sh_serial_putc_nondm(&sh_sci, c);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900370}
371
372static int sh_serial_tstc(void)
373{
374 struct uart_port *port = &sh_sci;
375
376 return sh_serial_tstc_generic(port);
377}
378
379static int sh_serial_getc(void)
380{
381 struct uart_port *port = &sh_sci;
382 int ch;
383
384 while (1) {
385 ch = sh_serial_getc_generic(port);
386 if (ch != -EAGAIN)
387 break;
388 }
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900389
Nobuhiro Iwamatsu6564b1a2008-06-06 16:16:08 +0900390 return ch;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900391}
Marek Vasut904d3d72012-09-14 22:40:08 +0200392
Marek Vasut904d3d72012-09-14 22:40:08 +0200393static struct serial_device sh_serial_drv = {
394 .name = "sh_serial",
395 .start = sh_serial_init,
396 .stop = NULL,
397 .setbrg = sh_serial_setbrg,
398 .putc = sh_serial_putc,
Marek Vasutd9c64492012-10-06 14:07:02 +0000399 .puts = default_serial_puts,
Marek Vasut904d3d72012-09-14 22:40:08 +0200400 .getc = sh_serial_getc,
401 .tstc = sh_serial_tstc,
402};
403
404void sh_serial_initialize(void)
405{
406 serial_register(&sh_serial_drv);
407}
408
409__weak struct serial_device *default_serial_console(void)
410{
411 return &sh_serial_drv;
412}
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900413#endif /* CONFIG_DM_SERIAL */
Marek Vasut98ae2812023-02-28 22:17:22 +0100414
415#ifdef CONFIG_DEBUG_UART_SCIF
416#include <debug_uart.h>
417
418static struct uart_port debug_uart_sci = {
419 .membase = (unsigned char *)CONFIG_DEBUG_UART_BASE,
420 .mapbase = CONFIG_DEBUG_UART_BASE,
421 .type = SCIF_BASE_PORT,
422#ifdef CFG_SCIF_USE_EXT_CLK
423 .clk_mode = EXT_CLK,
424#endif
425};
426
427static inline void _debug_uart_init(void)
428{
429 sh_serial_init_nodm(&debug_uart_sci);
430}
431
432static inline void _debug_uart_putc(int c)
433{
434 sh_serial_putc_nondm(&debug_uart_sci, c);
435}
436
437DEBUG_UART_FUNCS
438
439#endif