1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
220c9226cSAndreas Engel /*
320c9226cSAndreas Engel * (C) Copyright 2000
420c9226cSAndreas Engel * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
520c9226cSAndreas Engel *
620c9226cSAndreas Engel * (C) Copyright 2004
720c9226cSAndreas Engel * ARM Ltd.
820c9226cSAndreas Engel * Philippe Robin, <philippe.robin@arm.com>
920c9226cSAndreas Engel */
1020c9226cSAndreas Engel
1148d0192fSAndreas Engel /* Simple U-Boot driver for the PrimeCell PL010/PL011 UARTs */
1220c9226cSAndreas Engel
1320c9226cSAndreas Engel #include <common.h>
148a9cd5adSSimon Glass #include <dm.h>
15aed2fbefSSimon Glass #include <errno.h>
1620c9226cSAndreas Engel #include <watchdog.h>
17249d5219SMatt Waddel #include <asm/io.h>
1839f61477SMarek Vasut #include <serial.h>
1986256b79SMasahiro Yamada #include <dm/platform_data/serial_pl01x.h>
2039f61477SMarek Vasut #include <linux/compiler.h>
21aed2fbefSSimon Glass #include "serial_pl01x_internal.h"
2269751729SVikas Manocha
2369751729SVikas Manocha DECLARE_GLOBAL_DATA_PTR;
2420c9226cSAndreas Engel
258a9cd5adSSimon Glass #ifndef CONFIG_DM_SERIAL
268a9cd5adSSimon Glass
2720c9226cSAndreas Engel static volatile unsigned char *const port[] = CONFIG_PL01x_PORTS;
28aed2fbefSSimon Glass static enum pl01x_type pl01x_type __attribute__ ((section(".data")));
29aed2fbefSSimon Glass static struct pl01x_regs *base_regs __attribute__ ((section(".data")));
3020c9226cSAndreas Engel #define NUM_PORTS (sizeof(port)/sizeof(port[0]))
3120c9226cSAndreas Engel
328a9cd5adSSimon Glass #endif
3320c9226cSAndreas Engel
pl01x_putc(struct pl01x_regs * regs,char c)34aed2fbefSSimon Glass static int pl01x_putc(struct pl01x_regs *regs, char c)
3572d5e44cSRabin Vincent {
3620c9226cSAndreas Engel /* Wait until there is space in the FIFO */
37aed2fbefSSimon Glass if (readl(®s->fr) & UART_PL01x_FR_TXFF)
38aed2fbefSSimon Glass return -EAGAIN;
3920c9226cSAndreas Engel
4020c9226cSAndreas Engel /* Send the character */
4172d5e44cSRabin Vincent writel(c, ®s->dr);
42aed2fbefSSimon Glass
43aed2fbefSSimon Glass return 0;
4420c9226cSAndreas Engel }
4520c9226cSAndreas Engel
pl01x_getc(struct pl01x_regs * regs)46aed2fbefSSimon Glass static int pl01x_getc(struct pl01x_regs *regs)
4720c9226cSAndreas Engel {
4820c9226cSAndreas Engel unsigned int data;
4920c9226cSAndreas Engel
5020c9226cSAndreas Engel /* Wait until there is data in the FIFO */
51aed2fbefSSimon Glass if (readl(®s->fr) & UART_PL01x_FR_RXFE)
52aed2fbefSSimon Glass return -EAGAIN;
5320c9226cSAndreas Engel
5472d5e44cSRabin Vincent data = readl(®s->dr);
5520c9226cSAndreas Engel
5620c9226cSAndreas Engel /* Check for an error flag */
5720c9226cSAndreas Engel if (data & 0xFFFFFF00) {
5820c9226cSAndreas Engel /* Clear the error */
5972d5e44cSRabin Vincent writel(0xFFFFFFFF, ®s->ecr);
6020c9226cSAndreas Engel return -1;
6120c9226cSAndreas Engel }
6220c9226cSAndreas Engel
6320c9226cSAndreas Engel return (int) data;
6420c9226cSAndreas Engel }
6520c9226cSAndreas Engel
pl01x_tstc(struct pl01x_regs * regs)66aed2fbefSSimon Glass static int pl01x_tstc(struct pl01x_regs *regs)
6720c9226cSAndreas Engel {
6820c9226cSAndreas Engel WATCHDOG_RESET();
6972d5e44cSRabin Vincent return !(readl(®s->fr) & UART_PL01x_FR_RXFE);
7020c9226cSAndreas Engel }
7139f61477SMarek Vasut
pl01x_generic_serial_init(struct pl01x_regs * regs,enum pl01x_type type)72aed2fbefSSimon Glass static int pl01x_generic_serial_init(struct pl01x_regs *regs,
73aed2fbefSSimon Glass enum pl01x_type type)
74aed2fbefSSimon Glass {
75aed2fbefSSimon Glass switch (type) {
76aed2fbefSSimon Glass case TYPE_PL010:
77f7e517b4SVikas Manocha /* disable everything */
78f7e517b4SVikas Manocha writel(0, ®s->pl010_cr);
79aed2fbefSSimon Glass break;
80d2ca9fd2SVikas Manocha case TYPE_PL011:
81f7e517b4SVikas Manocha /* disable everything */
82f7e517b4SVikas Manocha writel(0, ®s->pl011_cr);
83d2ca9fd2SVikas Manocha break;
84d2ca9fd2SVikas Manocha default:
85d2ca9fd2SVikas Manocha return -EINVAL;
86d2ca9fd2SVikas Manocha }
87d2ca9fd2SVikas Manocha
88d2ca9fd2SVikas Manocha return 0;
89d2ca9fd2SVikas Manocha }
90d2ca9fd2SVikas Manocha
pl011_set_line_control(struct pl01x_regs * regs)91d77447fdSLinus Walleij static int pl011_set_line_control(struct pl01x_regs *regs)
92d2ca9fd2SVikas Manocha {
93d2ca9fd2SVikas Manocha unsigned int lcr;
94d2ca9fd2SVikas Manocha /*
95d2ca9fd2SVikas Manocha * Internal update of baud rate register require line
96d2ca9fd2SVikas Manocha * control register write
97d2ca9fd2SVikas Manocha */
98d2ca9fd2SVikas Manocha lcr = UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN;
99d2ca9fd2SVikas Manocha writel(lcr, ®s->pl011_lcrh);
100aed2fbefSSimon Glass return 0;
101aed2fbefSSimon Glass }
102aed2fbefSSimon Glass
pl01x_generic_setbrg(struct pl01x_regs * regs,enum pl01x_type type,int clock,int baudrate)103aed2fbefSSimon Glass static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
104aed2fbefSSimon Glass int clock, int baudrate)
105aed2fbefSSimon Glass {
106aed2fbefSSimon Glass switch (type) {
107aed2fbefSSimon Glass case TYPE_PL010: {
108aed2fbefSSimon Glass unsigned int divisor;
109aed2fbefSSimon Glass
110d77447fdSLinus Walleij /* disable everything */
111d77447fdSLinus Walleij writel(0, ®s->pl010_cr);
112d77447fdSLinus Walleij
113aed2fbefSSimon Glass switch (baudrate) {
114aed2fbefSSimon Glass case 9600:
115aed2fbefSSimon Glass divisor = UART_PL010_BAUD_9600;
116aed2fbefSSimon Glass break;
117aed2fbefSSimon Glass case 19200:
118b2aa8894SAlyssa Rosenzweig divisor = UART_PL010_BAUD_19200;
119aed2fbefSSimon Glass break;
120aed2fbefSSimon Glass case 38400:
121aed2fbefSSimon Glass divisor = UART_PL010_BAUD_38400;
122aed2fbefSSimon Glass break;
123aed2fbefSSimon Glass case 57600:
124aed2fbefSSimon Glass divisor = UART_PL010_BAUD_57600;
125aed2fbefSSimon Glass break;
126aed2fbefSSimon Glass case 115200:
127aed2fbefSSimon Glass divisor = UART_PL010_BAUD_115200;
128aed2fbefSSimon Glass break;
129aed2fbefSSimon Glass default:
130aed2fbefSSimon Glass divisor = UART_PL010_BAUD_38400;
131aed2fbefSSimon Glass }
132aed2fbefSSimon Glass
133aed2fbefSSimon Glass writel((divisor & 0xf00) >> 8, ®s->pl010_lcrm);
134aed2fbefSSimon Glass writel(divisor & 0xff, ®s->pl010_lcrl);
135aed2fbefSSimon Glass
136d77447fdSLinus Walleij /*
137d77447fdSLinus Walleij * Set line control for the PL010 to be 8 bits, 1 stop bit,
138d77447fdSLinus Walleij * no parity, fifo enabled
139d77447fdSLinus Walleij */
140d77447fdSLinus Walleij writel(UART_PL010_LCRH_WLEN_8 | UART_PL010_LCRH_FEN,
141d77447fdSLinus Walleij ®s->pl010_lcrh);
142aed2fbefSSimon Glass /* Finally, enable the UART */
143aed2fbefSSimon Glass writel(UART_PL010_CR_UARTEN, ®s->pl010_cr);
144aed2fbefSSimon Glass break;
145aed2fbefSSimon Glass }
146aed2fbefSSimon Glass case TYPE_PL011: {
147aed2fbefSSimon Glass unsigned int temp;
148aed2fbefSSimon Glass unsigned int divider;
149aed2fbefSSimon Glass unsigned int remainder;
150aed2fbefSSimon Glass unsigned int fraction;
151aed2fbefSSimon Glass
152aed2fbefSSimon Glass /*
153aed2fbefSSimon Glass * Set baud rate
154aed2fbefSSimon Glass *
155aed2fbefSSimon Glass * IBRD = UART_CLK / (16 * BAUD_RATE)
156aed2fbefSSimon Glass * FBRD = RND((64 * MOD(UART_CLK,(16 * BAUD_RATE)))
157aed2fbefSSimon Glass * / (16 * BAUD_RATE))
158aed2fbefSSimon Glass */
159aed2fbefSSimon Glass temp = 16 * baudrate;
160aed2fbefSSimon Glass divider = clock / temp;
161aed2fbefSSimon Glass remainder = clock % temp;
162aed2fbefSSimon Glass temp = (8 * remainder) / baudrate;
163aed2fbefSSimon Glass fraction = (temp >> 1) + (temp & 1);
164aed2fbefSSimon Glass
165aed2fbefSSimon Glass writel(divider, ®s->pl011_ibrd);
166aed2fbefSSimon Glass writel(fraction, ®s->pl011_fbrd);
167aed2fbefSSimon Glass
168d77447fdSLinus Walleij pl011_set_line_control(regs);
169aed2fbefSSimon Glass /* Finally, enable the UART */
170aed2fbefSSimon Glass writel(UART_PL011_CR_UARTEN | UART_PL011_CR_TXE |
171aed2fbefSSimon Glass UART_PL011_CR_RXE | UART_PL011_CR_RTS, ®s->pl011_cr);
172aed2fbefSSimon Glass break;
173aed2fbefSSimon Glass }
174aed2fbefSSimon Glass default:
175aed2fbefSSimon Glass return -EINVAL;
176aed2fbefSSimon Glass }
177aed2fbefSSimon Glass
178aed2fbefSSimon Glass return 0;
179aed2fbefSSimon Glass }
180aed2fbefSSimon Glass
181aed2fbefSSimon Glass #ifndef CONFIG_DM_SERIAL
pl01x_serial_init_baud(int baudrate)182aed2fbefSSimon Glass static void pl01x_serial_init_baud(int baudrate)
183aed2fbefSSimon Glass {
184aed2fbefSSimon Glass int clock = 0;
185aed2fbefSSimon Glass
186aed2fbefSSimon Glass #if defined(CONFIG_PL010_SERIAL)
187aed2fbefSSimon Glass pl01x_type = TYPE_PL010;
188aed2fbefSSimon Glass #elif defined(CONFIG_PL011_SERIAL)
189aed2fbefSSimon Glass pl01x_type = TYPE_PL011;
190aed2fbefSSimon Glass clock = CONFIG_PL011_CLOCK;
191aed2fbefSSimon Glass #endif
192aed2fbefSSimon Glass base_regs = (struct pl01x_regs *)port[CONFIG_CONS_INDEX];
193aed2fbefSSimon Glass
194aed2fbefSSimon Glass pl01x_generic_serial_init(base_regs, pl01x_type);
195a7deea69SVikas Manocha pl01x_generic_setbrg(base_regs, pl01x_type, clock, baudrate);
196aed2fbefSSimon Glass }
197aed2fbefSSimon Glass
198aed2fbefSSimon Glass /*
199aed2fbefSSimon Glass * Integrator AP has two UARTs, we use the first one, at 38400-8-N-1
200aed2fbefSSimon Glass * Integrator CP has two UARTs, use the first one, at 38400-8-N-1
201aed2fbefSSimon Glass * Versatile PB has four UARTs.
202aed2fbefSSimon Glass */
pl01x_serial_init(void)203aed2fbefSSimon Glass int pl01x_serial_init(void)
204aed2fbefSSimon Glass {
205aed2fbefSSimon Glass pl01x_serial_init_baud(CONFIG_BAUDRATE);
206aed2fbefSSimon Glass
207aed2fbefSSimon Glass return 0;
208aed2fbefSSimon Glass }
209aed2fbefSSimon Glass
pl01x_serial_putc(const char c)210aed2fbefSSimon Glass static void pl01x_serial_putc(const char c)
211aed2fbefSSimon Glass {
212aed2fbefSSimon Glass if (c == '\n')
213aed2fbefSSimon Glass while (pl01x_putc(base_regs, '\r') == -EAGAIN);
214aed2fbefSSimon Glass
215aed2fbefSSimon Glass while (pl01x_putc(base_regs, c) == -EAGAIN);
216aed2fbefSSimon Glass }
217aed2fbefSSimon Glass
pl01x_serial_getc(void)218aed2fbefSSimon Glass static int pl01x_serial_getc(void)
219aed2fbefSSimon Glass {
220aed2fbefSSimon Glass while (1) {
221aed2fbefSSimon Glass int ch = pl01x_getc(base_regs);
222aed2fbefSSimon Glass
223aed2fbefSSimon Glass if (ch == -EAGAIN) {
224aed2fbefSSimon Glass WATCHDOG_RESET();
225aed2fbefSSimon Glass continue;
226aed2fbefSSimon Glass }
227aed2fbefSSimon Glass
228aed2fbefSSimon Glass return ch;
229aed2fbefSSimon Glass }
230aed2fbefSSimon Glass }
231aed2fbefSSimon Glass
pl01x_serial_tstc(void)232aed2fbefSSimon Glass static int pl01x_serial_tstc(void)
233aed2fbefSSimon Glass {
234aed2fbefSSimon Glass return pl01x_tstc(base_regs);
235aed2fbefSSimon Glass }
236aed2fbefSSimon Glass
pl01x_serial_setbrg(void)237aed2fbefSSimon Glass static void pl01x_serial_setbrg(void)
238aed2fbefSSimon Glass {
239aed2fbefSSimon Glass /*
240aed2fbefSSimon Glass * Flush FIFO and wait for non-busy before changing baudrate to avoid
241aed2fbefSSimon Glass * crap in console
242aed2fbefSSimon Glass */
243aed2fbefSSimon Glass while (!(readl(&base_regs->fr) & UART_PL01x_FR_TXFE))
244aed2fbefSSimon Glass WATCHDOG_RESET();
245aed2fbefSSimon Glass while (readl(&base_regs->fr) & UART_PL01x_FR_BUSY)
246aed2fbefSSimon Glass WATCHDOG_RESET();
247aed2fbefSSimon Glass pl01x_serial_init_baud(gd->baudrate);
248aed2fbefSSimon Glass }
249aed2fbefSSimon Glass
25039f61477SMarek Vasut static struct serial_device pl01x_serial_drv = {
25139f61477SMarek Vasut .name = "pl01x_serial",
25239f61477SMarek Vasut .start = pl01x_serial_init,
25339f61477SMarek Vasut .stop = NULL,
25439f61477SMarek Vasut .setbrg = pl01x_serial_setbrg,
25539f61477SMarek Vasut .putc = pl01x_serial_putc,
256ec3fd689SMarek Vasut .puts = default_serial_puts,
25739f61477SMarek Vasut .getc = pl01x_serial_getc,
25839f61477SMarek Vasut .tstc = pl01x_serial_tstc,
25939f61477SMarek Vasut };
26039f61477SMarek Vasut
pl01x_serial_initialize(void)26139f61477SMarek Vasut void pl01x_serial_initialize(void)
26239f61477SMarek Vasut {
26339f61477SMarek Vasut serial_register(&pl01x_serial_drv);
26439f61477SMarek Vasut }
26539f61477SMarek Vasut
default_serial_console(void)26639f61477SMarek Vasut __weak struct serial_device *default_serial_console(void)
26739f61477SMarek Vasut {
26839f61477SMarek Vasut return &pl01x_serial_drv;
26939f61477SMarek Vasut }
270aed2fbefSSimon Glass
271aed2fbefSSimon Glass #endif /* nCONFIG_DM_SERIAL */
2728a9cd5adSSimon Glass
2738a9cd5adSSimon Glass #ifdef CONFIG_DM_SERIAL
2748a9cd5adSSimon Glass
pl01x_serial_setbrg(struct udevice * dev,int baudrate)275c9bf43ddSAlexander Graf int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
2768a9cd5adSSimon Glass {
2778a9cd5adSSimon Glass struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
2788a9cd5adSSimon Glass struct pl01x_priv *priv = dev_get_priv(dev);
2798a9cd5adSSimon Glass
280cd0fa5bfSEric Anholt if (!plat->skip_init) {
281cd0fa5bfSEric Anholt pl01x_generic_setbrg(priv->regs, priv->type, plat->clock,
282cd0fa5bfSEric Anholt baudrate);
283cd0fa5bfSEric Anholt }
2848a9cd5adSSimon Glass
2858a9cd5adSSimon Glass return 0;
2868a9cd5adSSimon Glass }
2878a9cd5adSSimon Glass
pl01x_serial_probe(struct udevice * dev)2886001985fSAlexander Graf int pl01x_serial_probe(struct udevice *dev)
2898a9cd5adSSimon Glass {
2908a9cd5adSSimon Glass struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
2918a9cd5adSSimon Glass struct pl01x_priv *priv = dev_get_priv(dev);
2928a9cd5adSSimon Glass
2938a9cd5adSSimon Glass priv->regs = (struct pl01x_regs *)plat->base;
2948a9cd5adSSimon Glass priv->type = plat->type;
295cd0fa5bfSEric Anholt if (!plat->skip_init)
2968a9cd5adSSimon Glass return pl01x_generic_serial_init(priv->regs, priv->type);
297cd0fa5bfSEric Anholt else
298cd0fa5bfSEric Anholt return 0;
2998a9cd5adSSimon Glass }
3008a9cd5adSSimon Glass
pl01x_serial_getc(struct udevice * dev)301c9bf43ddSAlexander Graf int pl01x_serial_getc(struct udevice *dev)
3028a9cd5adSSimon Glass {
3038a9cd5adSSimon Glass struct pl01x_priv *priv = dev_get_priv(dev);
3048a9cd5adSSimon Glass
3058a9cd5adSSimon Glass return pl01x_getc(priv->regs);
3068a9cd5adSSimon Glass }
3078a9cd5adSSimon Glass
pl01x_serial_putc(struct udevice * dev,const char ch)308c9bf43ddSAlexander Graf int pl01x_serial_putc(struct udevice *dev, const char ch)
3098a9cd5adSSimon Glass {
3108a9cd5adSSimon Glass struct pl01x_priv *priv = dev_get_priv(dev);
3118a9cd5adSSimon Glass
3128a9cd5adSSimon Glass return pl01x_putc(priv->regs, ch);
3138a9cd5adSSimon Glass }
3148a9cd5adSSimon Glass
pl01x_serial_pending(struct udevice * dev,bool input)315c9bf43ddSAlexander Graf int pl01x_serial_pending(struct udevice *dev, bool input)
3168a9cd5adSSimon Glass {
3178a9cd5adSSimon Glass struct pl01x_priv *priv = dev_get_priv(dev);
3188a9cd5adSSimon Glass unsigned int fr = readl(&priv->regs->fr);
3198a9cd5adSSimon Glass
3208a9cd5adSSimon Glass if (input)
3218a9cd5adSSimon Glass return pl01x_tstc(priv->regs);
3228a9cd5adSSimon Glass else
3238a9cd5adSSimon Glass return fr & UART_PL01x_FR_TXFF ? 0 : 1;
3248a9cd5adSSimon Glass }
3258a9cd5adSSimon Glass
326c9bf43ddSAlexander Graf static const struct dm_serial_ops pl01x_serial_ops = {
3278a9cd5adSSimon Glass .putc = pl01x_serial_putc,
3288a9cd5adSSimon Glass .pending = pl01x_serial_pending,
3298a9cd5adSSimon Glass .getc = pl01x_serial_getc,
3308a9cd5adSSimon Glass .setbrg = pl01x_serial_setbrg,
3318a9cd5adSSimon Glass };
3328a9cd5adSSimon Glass
3330f925822SMasahiro Yamada #if CONFIG_IS_ENABLED(OF_CONTROL)
33469751729SVikas Manocha static const struct udevice_id pl01x_serial_id[] ={
33569751729SVikas Manocha {.compatible = "arm,pl011", .data = TYPE_PL011},
33669751729SVikas Manocha {.compatible = "arm,pl010", .data = TYPE_PL010},
33769751729SVikas Manocha {}
33869751729SVikas Manocha };
33969751729SVikas Manocha
pl01x_serial_ofdata_to_platdata(struct udevice * dev)3406001985fSAlexander Graf int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
34169751729SVikas Manocha {
34269751729SVikas Manocha struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
34369751729SVikas Manocha fdt_addr_t addr;
34469751729SVikas Manocha
345a821c4afSSimon Glass addr = devfdt_get_addr(dev);
34669751729SVikas Manocha if (addr == FDT_ADDR_T_NONE)
34769751729SVikas Manocha return -EINVAL;
34869751729SVikas Manocha
34969751729SVikas Manocha plat->base = addr;
350b3111630SAlexander Graf plat->clock = dev_read_u32_default(dev, "clock", 1);
35169751729SVikas Manocha plat->type = dev_get_driver_data(dev);
352b3111630SAlexander Graf plat->skip_init = dev_read_bool(dev, "skip-init");
353b3111630SAlexander Graf
35469751729SVikas Manocha return 0;
35569751729SVikas Manocha }
35669751729SVikas Manocha #endif
35769751729SVikas Manocha
3588a9cd5adSSimon Glass U_BOOT_DRIVER(serial_pl01x) = {
3598a9cd5adSSimon Glass .name = "serial_pl01x",
3608a9cd5adSSimon Glass .id = UCLASS_SERIAL,
36169751729SVikas Manocha .of_match = of_match_ptr(pl01x_serial_id),
36269751729SVikas Manocha .ofdata_to_platdata = of_match_ptr(pl01x_serial_ofdata_to_platdata),
36369751729SVikas Manocha .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata),
3648a9cd5adSSimon Glass .probe = pl01x_serial_probe,
3658a9cd5adSSimon Glass .ops = &pl01x_serial_ops,
3668a9cd5adSSimon Glass .flags = DM_FLAG_PRE_RELOC,
36759c73d75SSimon Glass .priv_auto_alloc_size = sizeof(struct pl01x_priv),
3688a9cd5adSSimon Glass };
3698a9cd5adSSimon Glass
3708a9cd5adSSimon Glass #endif
371b81406dbSSergey Temerkhanov
372b81406dbSSergey Temerkhanov #if defined(CONFIG_DEBUG_UART_PL010) || defined(CONFIG_DEBUG_UART_PL011)
373b81406dbSSergey Temerkhanov
374b81406dbSSergey Temerkhanov #include <debug_uart.h>
375b81406dbSSergey Temerkhanov
_debug_uart_init(void)376b81406dbSSergey Temerkhanov static void _debug_uart_init(void)
377b81406dbSSergey Temerkhanov {
378b81406dbSSergey Temerkhanov #ifndef CONFIG_DEBUG_UART_SKIP_INIT
379b81406dbSSergey Temerkhanov struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE;
380b81406dbSSergey Temerkhanov enum pl01x_type type = CONFIG_IS_ENABLED(DEBUG_UART_PL011) ?
381b81406dbSSergey Temerkhanov TYPE_PL011 : TYPE_PL010;
382b81406dbSSergey Temerkhanov
383b81406dbSSergey Temerkhanov pl01x_generic_serial_init(regs, type);
384b81406dbSSergey Temerkhanov pl01x_generic_setbrg(regs, type,
385b81406dbSSergey Temerkhanov CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE);
386b81406dbSSergey Temerkhanov #endif
387b81406dbSSergey Temerkhanov }
388b81406dbSSergey Temerkhanov
_debug_uart_putc(int ch)389b81406dbSSergey Temerkhanov static inline void _debug_uart_putc(int ch)
390b81406dbSSergey Temerkhanov {
391b81406dbSSergey Temerkhanov struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE;
392b81406dbSSergey Temerkhanov
393b81406dbSSergey Temerkhanov pl01x_putc(regs, ch);
394b81406dbSSergey Temerkhanov }
395b81406dbSSergey Temerkhanov
396b81406dbSSergey Temerkhanov DEBUG_UART_FUNCS
397b81406dbSSergey Temerkhanov
398b81406dbSSergey Temerkhanov #endif
399