blob: e4cc4ee426039c7d3ad6cf7be31ddee9f84c771c [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
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Jean-Christophe PLAGNIOL-VILLARDb27a8e32009-01-11 16:35:16 +010010#include <asm/io.h>
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090011#include <asm/processor.h>
Paul Barker476f68a2023-10-16 10:25:35 +010012#include <clk.h>
13#include <dm.h>
Paul Barker327571c2023-10-19 15:30:44 +010014#include <dm/device_compat.h>
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090015#include <dm/platform_data/serial_sh.h>
Paul Barker476f68a2023-10-16 10:25:35 +010016#include <errno.h>
17#include <linux/compiler.h>
Simon Glassdbd79542020-05-10 11:40:11 -060018#include <linux/delay.h>
Paul Barker327571c2023-10-19 15:30:44 +010019#include <reset.h>
Paul Barker476f68a2023-10-16 10:25:35 +010020#include <serial.h>
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090021#include "serial_sh.h"
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090022
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +090023DECLARE_GLOBAL_DATA_PTR;
24
Marek Vasut39df77a2019-05-07 22:31:23 +020025#if defined(CONFIG_CPU_SH7780)
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090026static int scif_rxfill(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090027{
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090028 return sci_in(port, SCRFDR) & 0xff;
29}
30#elif defined(CONFIG_CPU_SH7763)
31static int scif_rxfill(struct uart_port *port)
32{
33 if ((port->mapbase == 0xffe00000) ||
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090034 (port->mapbase == 0xffe08000)) {
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090035 /* SCIF0/1*/
36 return sci_in(port, SCRFDR) & 0xff;
37 } else {
38 /* SCIF2 */
39 return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
40 }
41}
Nobuhiro Iwamatsu1b36beb2008-03-06 14:05:53 +090042#else
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090043static int scif_rxfill(struct uart_port *port)
44{
45 return sci_in(port, SCFDR) & SCIF_RFDC_MASK;
46}
Nobuhiro Iwamatsu1b36beb2008-03-06 14:05:53 +090047#endif
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090048
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090049static void sh_serial_init_generic(struct uart_port *port)
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +090050{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090051 sci_out(port, SCSCR , SCSCR_INIT(port));
52 sci_out(port, SCSCR , SCSCR_INIT(port));
53 sci_out(port, SCSMR, 0);
54 sci_out(port, SCSMR, 0);
55 sci_out(port, SCFCR, SCFCR_RFRST|SCFCR_TFRST);
56 sci_in(port, SCFCR);
57 sci_out(port, SCFCR, 0);
Marek Vasut2d2e3ff2019-05-01 18:20:00 +020058#if defined(CONFIG_RZA1)
59 sci_out(port, SCSPTR, 0x0003);
60#endif
Hai Pham19923d82023-02-28 22:29:19 +010061
Paul Barkeraa173962023-10-16 10:25:23 +010062#if IS_ENABLED(CONFIG_RCAR_GEN2) || IS_ENABLED(CONFIG_RCAR_GEN3) || IS_ENABLED(CONFIG_RCAR_GEN4)
Hai Pham19923d82023-02-28 22:29:19 +010063 if (port->type == PORT_HSCIF)
64 sci_out(port, HSSRR, HSSRR_SRE | HSSRR_SRCYC8);
Paul Barkeraa173962023-10-16 10:25:23 +010065#endif
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090066}
67
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090068static void
69sh_serial_setbrg_generic(struct uart_port *port, int clk, int baudrate)
Tetsuyuki Kobayashi5d2b5a22012-11-19 21:37:38 +000070{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090071 if (port->clk_mode == EXT_CLK) {
72 unsigned short dl = DL_VALUE(baudrate, clk);
73 sci_out(port, DL, dl);
Nobuhiro Iwamatsu17861752014-12-10 14:42:05 +090074 /* Need wait: Clock * 1/dl * 1/16 */
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090075 udelay((1000000 * dl * 16 / clk) * 1000 + 1);
76 } else {
77 sci_out(port, SCBRR, SCBRR_VALUE(baudrate, clk));
78 }
Tetsuyuki Kobayashi5d2b5a22012-11-19 21:37:38 +000079}
80
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090081static void handle_error(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090082{
Paul Barkera9b47022023-10-19 15:30:43 +010083 /*
84 * Most errors are cleared by resetting the relevant error bits to zero
85 * in the FSR & LSR registers. For each register, a read followed by a
86 * write is needed according to the relevant datasheets.
87 */
88 unsigned short status = sci_in(port, SCxSR);
89 sci_out(port, SCxSR, status & ~SCxSR_ERRORS(port));
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090090 sci_in(port, SCLSR);
91 sci_out(port, SCLSR, 0x00);
Paul Barkera9b47022023-10-19 15:30:43 +010092
93 /*
94 * To clear framing errors, we also need to read and discard a
95 * character.
96 */
97 if ((port->type != PORT_SCI) && (status & SCIF_FER))
98 sci_in(port, SCxRDR);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +090099}
100
101static int serial_raw_putc(struct uart_port *port, const char c)
102{
103 /* Tx fifo is empty */
104 if (!(sci_in(port, SCxSR) & SCxSR_TEND(port)))
105 return -EAGAIN;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900106
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900107 sci_out(port, SCxTDR, c);
108 sci_out(port, SCxSR, sci_in(port, SCxSR) & ~SCxSR_TEND(port));
109
110 return 0;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900111}
112
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900113static int serial_rx_fifo_level(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900114{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900115 return scif_rxfill(port);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900116}
117
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900118static int sh_serial_tstc_generic(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900119{
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900120 if (sci_in(port, SCxSR) & SCIF_ERRORS) {
121 handle_error(port);
Tetsuyuki Kobayashi5d2b5a22012-11-19 21:37:38 +0000122 return 0;
123 }
124
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900125 return serial_rx_fifo_level(port) ? 1 : 0;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900126}
127
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900128static int serial_getc_check(struct uart_port *port)
Nobuhiro Iwamatsu6564b1a2008-06-06 16:16:08 +0900129{
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900130 unsigned short status;
131
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900132 status = sci_in(port, SCxSR);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900133
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +0900134 if (status & SCIF_ERRORS)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900135 handle_error(port);
136 if (sci_in(port, SCLSR) & SCxSR_ORER(port))
137 handle_error(port);
Marek Vasutd88686b2020-05-09 22:30:05 +0200138 status &= (SCIF_DR | SCxSR_RDxF(port));
139 if (status)
140 return status;
141 return scif_rxfill(port);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900142}
143
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900144static int sh_serial_getc_generic(struct uart_port *port)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900145{
Nobuhiro Iwamatsu6564b1a2008-06-06 16:16:08 +0900146 unsigned short status;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900147 char ch;
Nobuhiro Iwamatsufcabccc2008-08-22 17:48:51 +0900148
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900149 if (!serial_getc_check(port))
150 return -EAGAIN;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900151
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900152 ch = sci_in(port, SCxRDR);
153 status = sci_in(port, SCxSR);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900154
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900155 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900156
Nobuhiro Iwamatsua5579ca2010-10-26 03:55:15 +0900157 if (status & SCIF_ERRORS)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900158 handle_error(port);
159
160 if (sci_in(port, SCLSR) & SCxSR_ORER(port))
161 handle_error(port);
162
163 return ch;
164}
165
Marek Vasut0dfa9912018-02-16 01:33:27 +0100166#if CONFIG_IS_ENABLED(DM_SERIAL)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900167
168static int sh_serial_pending(struct udevice *dev, bool input)
169{
170 struct uart_port *priv = dev_get_priv(dev);
171
172 return sh_serial_tstc_generic(priv);
173}
174
175static int sh_serial_putc(struct udevice *dev, const char ch)
176{
177 struct uart_port *priv = dev_get_priv(dev);
178
179 return serial_raw_putc(priv, ch);
180}
181
182static int sh_serial_getc(struct udevice *dev)
183{
184 struct uart_port *priv = dev_get_priv(dev);
185
186 return sh_serial_getc_generic(priv);
187}
188
189static int sh_serial_setbrg(struct udevice *dev, int baudrate)
190{
Simon Glassb75b15b2020-12-03 16:55:23 -0700191 struct sh_serial_plat *plat = dev_get_plat(dev);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900192 struct uart_port *priv = dev_get_priv(dev);
193
194 sh_serial_setbrg_generic(priv, plat->clk, baudrate);
195
196 return 0;
197}
198
199static int sh_serial_probe(struct udevice *dev)
200{
Simon Glassb75b15b2020-12-03 16:55:23 -0700201 struct sh_serial_plat *plat = dev_get_plat(dev);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900202 struct uart_port *priv = dev_get_priv(dev);
Paul Barker327571c2023-10-19 15:30:44 +0100203 struct reset_ctl rst;
204 int ret;
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900205
206 priv->membase = (unsigned char *)plat->base;
207 priv->mapbase = plat->base;
208 priv->type = plat->type;
209 priv->clk_mode = plat->clk_mode;
210
Paul Barker327571c2023-10-19 15:30:44 +0100211 /* De-assert the module reset if it is defined. */
212 ret = reset_get_by_index(dev, 0, &rst);
213 if (!ret) {
214 ret = reset_deassert(&rst);
215 if (ret < 0) {
216 dev_err(dev, "failed to de-assert reset line\n");
217 return ret;
218 }
219 }
220
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900221 sh_serial_init_generic(priv);
222
223 return 0;
224}
225
226static const struct dm_serial_ops sh_serial_ops = {
227 .putc = sh_serial_putc,
228 .pending = sh_serial_pending,
229 .getc = sh_serial_getc,
230 .setbrg = sh_serial_setbrg,
231};
232
Marek Vasut0dfa9912018-02-16 01:33:27 +0100233#if CONFIG_IS_ENABLED(OF_CONTROL)
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900234static const struct udevice_id sh_serial_id[] ={
Yoshinori Satoe5669a32016-04-18 16:51:05 +0900235 {.compatible = "renesas,sci", .data = PORT_SCI},
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900236 {.compatible = "renesas,scif", .data = PORT_SCIF},
Paul Barker327571c2023-10-19 15:30:44 +0100237 {.compatible = "renesas,scif-r9a07g044", .data = PORT_SCIFA},
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900238 {.compatible = "renesas,scifa", .data = PORT_SCIFA},
Hai Pham19923d82023-02-28 22:29:19 +0100239 {.compatible = "renesas,hscif", .data = PORT_HSCIF},
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900240 {}
241};
242
Simon Glassaad29ae2020-12-03 16:55:21 -0700243static int sh_serial_of_to_plat(struct udevice *dev)
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900244{
Simon Glassb75b15b2020-12-03 16:55:23 -0700245 struct sh_serial_plat *plat = dev_get_plat(dev);
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200246 struct clk sh_serial_clk;
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900247 fdt_addr_t addr;
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200248 int ret;
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900249
Masahiro Yamadaa89b4de2020-07-17 14:36:48 +0900250 addr = dev_read_addr(dev);
Marek Vasut48db7762018-01-17 22:36:37 +0100251 if (!addr)
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900252 return -EINVAL;
253
254 plat->base = addr;
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200255
256 ret = clk_get_by_name(dev, "fck", &sh_serial_clk);
Marek Vasutfd6a4a72017-09-15 21:11:27 +0200257 if (!ret) {
258 ret = clk_enable(&sh_serial_clk);
259 if (!ret)
260 plat->clk = clk_get_rate(&sh_serial_clk);
261 } else {
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200262 plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
263 "clock", 1);
Marek Vasutfd6a4a72017-09-15 21:11:27 +0200264 }
Marek Vasut8fe2ffc2017-07-21 23:19:18 +0200265
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900266 plat->type = dev_get_driver_data(dev);
267 return 0;
268}
269#endif
270
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900271U_BOOT_DRIVER(serial_sh) = {
272 .name = "serial_sh",
273 .id = UCLASS_SERIAL,
Yoshinori Satoa6eed2b2016-04-18 16:51:04 +0900274 .of_match = of_match_ptr(sh_serial_id),
Simon Glassaad29ae2020-12-03 16:55:21 -0700275 .of_to_plat = of_match_ptr(sh_serial_of_to_plat),
Simon Glassb75b15b2020-12-03 16:55:23 -0700276 .plat_auto = sizeof(struct sh_serial_plat),
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900277 .probe = sh_serial_probe,
278 .ops = &sh_serial_ops,
Bin Mengbdb33d82018-10-24 06:36:36 -0700279#if !CONFIG_IS_ENABLED(OF_CONTROL)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900280 .flags = DM_FLAG_PRE_RELOC,
Bin Mengbdb33d82018-10-24 06:36:36 -0700281#endif
Simon Glass8a2b47f2020-12-03 16:55:17 -0700282 .priv_auto = sizeof(struct uart_port),
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900283};
Marek Vasut98ae2812023-02-28 22:17:22 +0100284#endif
285
286#if !CONFIG_IS_ENABLED(DM_SERIAL) || IS_ENABLED(CONFIG_DEBUG_UART_SCIF)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900287
Marek Vasut98ae2812023-02-28 22:17:22 +0100288#if defined(CFG_SCIF_A)
289 #define SCIF_BASE_PORT PORT_SCIFA
290#elif defined(CFG_SCI)
291 #define SCIF_BASE_PORT PORT_SCI
Hai Pham19923d82023-02-28 22:29:19 +0100292#elif defined(CFG_HSCIF)
293 #define SCIF_BASE_PORT PORT_HSCIF
Marek Vasut98ae2812023-02-28 22:17:22 +0100294#else
295 #define SCIF_BASE_PORT PORT_SCIF
296#endif
297
298static void sh_serial_init_nodm(struct uart_port *port)
299{
300 sh_serial_init_generic(port);
301 serial_setbrg();
302}
303
304static void sh_serial_putc_nondm(struct uart_port *port, const char c)
305{
306 if (c == '\n') {
307 while (1) {
308 if (serial_raw_putc(port, '\r') != -EAGAIN)
309 break;
310 }
311 }
312 while (1) {
313 if (serial_raw_putc(port, c) != -EAGAIN)
314 break;
315 }
316}
317#endif
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900318
Marek Vasut98ae2812023-02-28 22:17:22 +0100319#if !CONFIG_IS_ENABLED(DM_SERIAL)
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900320#if defined(CONFIG_CONS_SCIF0)
321# define SCIF_BASE SCIF0_BASE
322#elif defined(CONFIG_CONS_SCIF1)
323# define SCIF_BASE SCIF1_BASE
324#elif defined(CONFIG_CONS_SCIF2)
325# define SCIF_BASE SCIF2_BASE
326#elif defined(CONFIG_CONS_SCIF3)
327# define SCIF_BASE SCIF3_BASE
328#elif defined(CONFIG_CONS_SCIF4)
329# define SCIF_BASE SCIF4_BASE
330#elif defined(CONFIG_CONS_SCIF5)
331# define SCIF_BASE SCIF5_BASE
332#elif defined(CONFIG_CONS_SCIF6)
333# define SCIF_BASE SCIF6_BASE
334#elif defined(CONFIG_CONS_SCIF7)
335# define SCIF_BASE SCIF7_BASE
Marek Vasut1d9756b2018-04-12 15:23:46 +0200336#elif defined(CONFIG_CONS_SCIFA0)
337# define SCIF_BASE SCIFA0_BASE
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900338#else
339# error "Default SCIF doesn't set....."
340#endif
341
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900342static struct uart_port sh_sci = {
343 .membase = (unsigned char *)SCIF_BASE,
344 .mapbase = SCIF_BASE,
345 .type = SCIF_BASE_PORT,
Marek Vasutb811f9b2023-02-28 22:17:21 +0100346#ifdef CFG_SCIF_USE_EXT_CLK
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900347 .clk_mode = EXT_CLK,
348#endif
349};
350
351static void sh_serial_setbrg(void)
352{
353 DECLARE_GLOBAL_DATA_PTR;
354 struct uart_port *port = &sh_sci;
355
356 sh_serial_setbrg_generic(port, CONFIG_SH_SCIF_CLK_FREQ, gd->baudrate);
357}
358
359static int sh_serial_init(void)
360{
Marek Vasut98ae2812023-02-28 22:17:22 +0100361 sh_serial_init_nodm(&sh_sci);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900362
363 return 0;
364}
365
366static void sh_serial_putc(const char c)
367{
Marek Vasut98ae2812023-02-28 22:17:22 +0100368 sh_serial_putc_nondm(&sh_sci, c);
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900369}
370
371static int sh_serial_tstc(void)
372{
373 struct uart_port *port = &sh_sci;
374
375 return sh_serial_tstc_generic(port);
376}
377
378static int sh_serial_getc(void)
379{
380 struct uart_port *port = &sh_sci;
381 int ch;
382
383 while (1) {
384 ch = sh_serial_getc_generic(port);
385 if (ch != -EAGAIN)
386 break;
387 }
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900388
Nobuhiro Iwamatsu6564b1a2008-06-06 16:16:08 +0900389 return ch;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +0900390}
Marek Vasut904d3d72012-09-14 22:40:08 +0200391
Marek Vasut904d3d72012-09-14 22:40:08 +0200392static struct serial_device sh_serial_drv = {
393 .name = "sh_serial",
394 .start = sh_serial_init,
395 .stop = NULL,
396 .setbrg = sh_serial_setbrg,
397 .putc = sh_serial_putc,
Marek Vasutd9c64492012-10-06 14:07:02 +0000398 .puts = default_serial_puts,
Marek Vasut904d3d72012-09-14 22:40:08 +0200399 .getc = sh_serial_getc,
400 .tstc = sh_serial_tstc,
401};
402
403void sh_serial_initialize(void)
404{
405 serial_register(&sh_serial_drv);
406}
407
408__weak struct serial_device *default_serial_console(void)
409{
410 return &sh_serial_drv;
411}
Nobuhiro Iwamatsu6d020352015-02-12 13:48:04 +0900412#endif /* CONFIG_DM_SERIAL */
Marek Vasut98ae2812023-02-28 22:17:22 +0100413
414#ifdef CONFIG_DEBUG_UART_SCIF
415#include <debug_uart.h>
416
417static struct uart_port debug_uart_sci = {
418 .membase = (unsigned char *)CONFIG_DEBUG_UART_BASE,
419 .mapbase = CONFIG_DEBUG_UART_BASE,
420 .type = SCIF_BASE_PORT,
421#ifdef CFG_SCIF_USE_EXT_CLK
422 .clk_mode = EXT_CLK,
423#endif
424};
425
426static inline void _debug_uart_init(void)
427{
428 sh_serial_init_nodm(&debug_uart_sci);
429}
430
431static inline void _debug_uart_putc(int c)
432{
433 sh_serial_putc_nondm(&debug_uart_sci, c);
434}
435
436DEBUG_UART_FUNCS
437
438#endif