Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2004-2006 Atmel Corporation |
| 4 | * |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 5 | * Modified to support C structur SoC access by |
| 6 | * Andreas Bießmann <biessmann@corscience.de> |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 7 | */ |
| 8 | #include <common.h> |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 9 | #include <clk.h> |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 10 | #include <dm.h> |
| 11 | #include <errno.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 12 | #include <malloc.h> |
Jean-Christophe PLAGNIOL-VILLARD | d5ee38e | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 13 | #include <watchdog.h> |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 14 | #include <serial.h> |
Wenyou Yang | 6b611e6 | 2016-10-17 09:49:55 +0800 | [diff] [blame] | 15 | #include <debug_uart.h> |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 16 | #include <linux/compiler.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 17 | #include <linux/delay.h> |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 18 | |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 19 | #include <asm/io.h> |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 20 | #ifdef CONFIG_DM_SERIAL |
| 21 | #include <asm/arch/atmel_serial.h> |
| 22 | #endif |
Haavard Skinnemoen | 0a2743f | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 23 | #include <asm/arch/clk.h> |
Reinhard Meyer | 7f619cb | 2010-11-03 16:32:56 +0100 | [diff] [blame] | 24 | #include <asm/arch/hardware.h> |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 25 | |
| 26 | #include "atmel_usart.h" |
| 27 | |
| 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
Wenyou Yang | b045a60 | 2017-04-14 15:01:27 +0800 | [diff] [blame] | 30 | #ifndef CONFIG_DM_SERIAL |
Simon Glass | 1e5c2a8 | 2014-10-29 13:08:59 -0600 | [diff] [blame] | 31 | static void atmel_serial_setbrg_internal(atmel_usart3_t *usart, int id, |
| 32 | int baudrate) |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 33 | { |
| 34 | unsigned long divisor; |
| 35 | unsigned long usart_hz; |
| 36 | |
| 37 | /* |
| 38 | * Master Clock |
| 39 | * Baud Rate = -------------- |
| 40 | * 16 * CD |
| 41 | */ |
Simon Glass | 1e5c2a8 | 2014-10-29 13:08:59 -0600 | [diff] [blame] | 42 | usart_hz = get_usart_clk_rate(id); |
| 43 | divisor = (usart_hz / 16 + baudrate / 2) / baudrate; |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 44 | writel(USART3_BF(CD, divisor), &usart->brgr); |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Simon Glass | 1e5c2a8 | 2014-10-29 13:08:59 -0600 | [diff] [blame] | 47 | static void atmel_serial_init_internal(atmel_usart3_t *usart) |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 48 | { |
Xu, Hong | 9db5799 | 2011-08-02 01:05:04 +0000 | [diff] [blame] | 49 | /* |
| 50 | * Just in case: drain transmitter register |
| 51 | * 1000us is enough for baudrate >= 9600 |
| 52 | */ |
| 53 | if (!(readl(&usart->csr) & USART3_BIT(TXEMPTY))) |
| 54 | __udelay(1000); |
| 55 | |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 56 | writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), &usart->cr); |
Simon Glass | 1e5c2a8 | 2014-10-29 13:08:59 -0600 | [diff] [blame] | 57 | } |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 58 | |
Simon Glass | 1e5c2a8 | 2014-10-29 13:08:59 -0600 | [diff] [blame] | 59 | static void atmel_serial_activate(atmel_usart3_t *usart) |
| 60 | { |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 61 | writel((USART3_BF(USART_MODE, USART3_USART_MODE_NORMAL) |
Haavard Skinnemoen | 0a2743f | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 62 | | USART3_BF(USCLKS, USART3_USCLKS_MCK) |
| 63 | | USART3_BF(CHRL, USART3_CHRL_8) |
| 64 | | USART3_BF(PAR, USART3_PAR_NONE) |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 65 | | USART3_BF(NBSTOP, USART3_NBSTOP_1)), |
| 66 | &usart->mr); |
Xu, Hong | 9db5799 | 2011-08-02 01:05:04 +0000 | [diff] [blame] | 67 | writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), &usart->cr); |
| 68 | /* 100us is enough for the new settings to be settled */ |
| 69 | __udelay(100); |
Simon Glass | 1e5c2a8 | 2014-10-29 13:08:59 -0600 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | static void atmel_serial_setbrg(void) |
| 73 | { |
| 74 | atmel_serial_setbrg_internal((atmel_usart3_t *)CONFIG_USART_BASE, |
| 75 | CONFIG_USART_ID, gd->baudrate); |
| 76 | } |
| 77 | |
| 78 | static int atmel_serial_init(void) |
| 79 | { |
| 80 | atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE; |
| 81 | |
| 82 | atmel_serial_init_internal(usart); |
| 83 | serial_setbrg(); |
| 84 | atmel_serial_activate(usart); |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 89 | static void atmel_serial_putc(char c) |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 90 | { |
Reinhard Meyer | 7f619cb | 2010-11-03 16:32:56 +0100 | [diff] [blame] | 91 | atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE; |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 92 | |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 93 | if (c == '\n') |
| 94 | serial_putc('\r'); |
| 95 | |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 96 | while (!(readl(&usart->csr) & USART3_BIT(TXRDY))); |
| 97 | writel(c, &usart->thr); |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 98 | } |
| 99 | |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 100 | static int atmel_serial_getc(void) |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 101 | { |
Reinhard Meyer | 7f619cb | 2010-11-03 16:32:56 +0100 | [diff] [blame] | 102 | atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE; |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 103 | |
| 104 | while (!(readl(&usart->csr) & USART3_BIT(RXRDY))) |
Jean-Christophe PLAGNIOL-VILLARD | d5ee38e | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 105 | WATCHDOG_RESET(); |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 106 | return readl(&usart->rhr); |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 107 | } |
| 108 | |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 109 | static int atmel_serial_tstc(void) |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 110 | { |
Reinhard Meyer | 7f619cb | 2010-11-03 16:32:56 +0100 | [diff] [blame] | 111 | atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE; |
Andreas Bießmann | fb37868 | 2010-09-03 10:28:05 +0200 | [diff] [blame] | 112 | return (readl(&usart->csr) & USART3_BIT(RXRDY)) != 0; |
Wolfgang Denk | 5e1d9ec | 2006-10-24 14:31:24 +0200 | [diff] [blame] | 113 | } |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 114 | |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 115 | static struct serial_device atmel_serial_drv = { |
| 116 | .name = "atmel_serial", |
| 117 | .start = atmel_serial_init, |
| 118 | .stop = NULL, |
| 119 | .setbrg = atmel_serial_setbrg, |
| 120 | .putc = atmel_serial_putc, |
Marek Vasut | d9c6449 | 2012-10-06 14:07:02 +0000 | [diff] [blame] | 121 | .puts = default_serial_puts, |
Marek Vasut | ff093ed | 2012-09-13 16:50:30 +0200 | [diff] [blame] | 122 | .getc = atmel_serial_getc, |
| 123 | .tstc = atmel_serial_tstc, |
| 124 | }; |
| 125 | |
| 126 | void atmel_serial_initialize(void) |
| 127 | { |
| 128 | serial_register(&atmel_serial_drv); |
| 129 | } |
| 130 | |
| 131 | __weak struct serial_device *default_serial_console(void) |
| 132 | { |
| 133 | return &atmel_serial_drv; |
| 134 | } |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 135 | #endif |
| 136 | |
| 137 | #ifdef CONFIG_DM_SERIAL |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 138 | enum serial_clk_type { |
| 139 | CLK_TYPE_NORMAL = 0, |
| 140 | CLK_TYPE_DBGU, |
| 141 | }; |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 142 | |
| 143 | struct atmel_serial_priv { |
| 144 | atmel_usart3_t *usart; |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 145 | ulong usart_clk_rate; |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 146 | }; |
| 147 | |
Wenyou Yang | b045a60 | 2017-04-14 15:01:27 +0800 | [diff] [blame] | 148 | static void _atmel_serial_set_brg(atmel_usart3_t *usart, |
| 149 | ulong usart_clk_rate, int baudrate) |
| 150 | { |
| 151 | unsigned long divisor; |
| 152 | |
| 153 | divisor = (usart_clk_rate / 16 + baudrate / 2) / baudrate; |
| 154 | writel(USART3_BF(CD, divisor), &usart->brgr); |
| 155 | } |
| 156 | |
| 157 | void _atmel_serial_init(atmel_usart3_t *usart, |
| 158 | ulong usart_clk_rate, int baudrate) |
| 159 | { |
| 160 | writel(USART3_BIT(RXDIS) | USART3_BIT(TXDIS), &usart->cr); |
| 161 | |
| 162 | writel((USART3_BF(USART_MODE, USART3_USART_MODE_NORMAL) | |
| 163 | USART3_BF(USCLKS, USART3_USCLKS_MCK) | |
| 164 | USART3_BF(CHRL, USART3_CHRL_8) | |
| 165 | USART3_BF(PAR, USART3_PAR_NONE) | |
| 166 | USART3_BF(NBSTOP, USART3_NBSTOP_1)), &usart->mr); |
| 167 | |
| 168 | _atmel_serial_set_brg(usart, usart_clk_rate, baudrate); |
| 169 | |
| 170 | writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), &usart->cr); |
| 171 | writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), &usart->cr); |
| 172 | } |
| 173 | |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 174 | int atmel_serial_setbrg(struct udevice *dev, int baudrate) |
| 175 | { |
| 176 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
| 177 | |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 178 | _atmel_serial_set_brg(priv->usart, priv->usart_clk_rate, baudrate); |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 179 | |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | static int atmel_serial_getc(struct udevice *dev) |
| 184 | { |
| 185 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
| 186 | |
| 187 | if (!(readl(&priv->usart->csr) & USART3_BIT(RXRDY))) |
| 188 | return -EAGAIN; |
| 189 | |
| 190 | return readl(&priv->usart->rhr); |
| 191 | } |
| 192 | |
| 193 | static int atmel_serial_putc(struct udevice *dev, const char ch) |
| 194 | { |
| 195 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
| 196 | |
| 197 | if (!(readl(&priv->usart->csr) & USART3_BIT(TXRDY))) |
| 198 | return -EAGAIN; |
| 199 | |
| 200 | writel(ch, &priv->usart->thr); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static int atmel_serial_pending(struct udevice *dev, bool input) |
| 206 | { |
| 207 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
| 208 | uint32_t csr = readl(&priv->usart->csr); |
| 209 | |
| 210 | if (input) |
| 211 | return csr & USART3_BIT(RXRDY) ? 1 : 0; |
| 212 | else |
| 213 | return csr & USART3_BIT(TXEMPTY) ? 0 : 1; |
| 214 | } |
| 215 | |
| 216 | static const struct dm_serial_ops atmel_serial_ops = { |
| 217 | .putc = atmel_serial_putc, |
| 218 | .pending = atmel_serial_pending, |
| 219 | .getc = atmel_serial_getc, |
| 220 | .setbrg = atmel_serial_setbrg, |
| 221 | }; |
| 222 | |
Stefan Roese | b1f3da8 | 2019-04-03 15:24:19 +0200 | [diff] [blame] | 223 | #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_CLK) |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 224 | static int atmel_serial_enable_clk(struct udevice *dev) |
| 225 | { |
| 226 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
Stefan Roese | b1f3da8 | 2019-04-03 15:24:19 +0200 | [diff] [blame] | 227 | |
| 228 | /* Use fixed clock value in SPL */ |
| 229 | priv->usart_clk_rate = CONFIG_SPL_UART_CLOCK; |
| 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | #else |
| 234 | static int atmel_serial_enable_clk(struct udevice *dev) |
| 235 | { |
| 236 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 237 | struct clk clk; |
| 238 | ulong clk_rate; |
| 239 | int ret; |
| 240 | |
| 241 | ret = clk_get_by_index(dev, 0, &clk); |
| 242 | if (ret) |
| 243 | return -EINVAL; |
| 244 | |
| 245 | if (dev_get_driver_data(dev) == CLK_TYPE_NORMAL) { |
| 246 | ret = clk_enable(&clk); |
| 247 | if (ret) |
| 248 | return ret; |
| 249 | } |
| 250 | |
| 251 | clk_rate = clk_get_rate(&clk); |
| 252 | if (!clk_rate) |
| 253 | return -EINVAL; |
| 254 | |
| 255 | priv->usart_clk_rate = clk_rate; |
| 256 | |
| 257 | clk_free(&clk); |
| 258 | |
| 259 | return 0; |
| 260 | } |
Stefan Roese | b1f3da8 | 2019-04-03 15:24:19 +0200 | [diff] [blame] | 261 | #endif |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 262 | |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 263 | static int atmel_serial_probe(struct udevice *dev) |
| 264 | { |
| 265 | struct atmel_serial_platdata *plat = dev->platdata; |
| 266 | struct atmel_serial_priv *priv = dev_get_priv(dev); |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 267 | int ret; |
Wenyou Yang | b0e59ee | 2016-06-01 08:36:56 +0800 | [diff] [blame] | 268 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
| 269 | fdt_addr_t addr_base; |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 270 | |
Simon Glass | ba1dea4 | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 271 | addr_base = devfdt_get_addr(dev); |
Wenyou Yang | b0e59ee | 2016-06-01 08:36:56 +0800 | [diff] [blame] | 272 | if (addr_base == FDT_ADDR_T_NONE) |
| 273 | return -ENODEV; |
| 274 | |
| 275 | plat->base_addr = (uint32_t)addr_base; |
| 276 | #endif |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 277 | priv->usart = (atmel_usart3_t *)plat->base_addr; |
Wenyou Yang | b045a60 | 2017-04-14 15:01:27 +0800 | [diff] [blame] | 278 | |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 279 | ret = atmel_serial_enable_clk(dev); |
| 280 | if (ret) |
| 281 | return ret; |
| 282 | |
| 283 | _atmel_serial_init(priv->usart, priv->usart_clk_rate, gd->baudrate); |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
Wenyou Yang | b0e59ee | 2016-06-01 08:36:56 +0800 | [diff] [blame] | 288 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
| 289 | static const struct udevice_id atmel_serial_ids[] = { |
Wenyou Yang | 7c56e10 | 2017-04-14 15:01:28 +0800 | [diff] [blame] | 290 | { |
| 291 | .compatible = "atmel,at91sam9260-dbgu", |
| 292 | .data = CLK_TYPE_DBGU, |
| 293 | }, |
| 294 | { |
| 295 | .compatible = "atmel,at91sam9260-usart", |
| 296 | .data = CLK_TYPE_NORMAL, |
| 297 | }, |
Wenyou Yang | b0e59ee | 2016-06-01 08:36:56 +0800 | [diff] [blame] | 298 | { } |
| 299 | }; |
| 300 | #endif |
| 301 | |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 302 | U_BOOT_DRIVER(serial_atmel) = { |
| 303 | .name = "serial_atmel", |
| 304 | .id = UCLASS_SERIAL, |
Wenyou Yang | b0e59ee | 2016-06-01 08:36:56 +0800 | [diff] [blame] | 305 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
| 306 | .of_match = atmel_serial_ids, |
| 307 | .platdata_auto_alloc_size = sizeof(struct atmel_serial_platdata), |
| 308 | #endif |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 309 | .probe = atmel_serial_probe, |
| 310 | .ops = &atmel_serial_ops, |
Bin Meng | bdb33d8 | 2018-10-24 06:36:36 -0700 | [diff] [blame] | 311 | #if !CONFIG_IS_ENABLED(OF_CONTROL) |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 312 | .flags = DM_FLAG_PRE_RELOC, |
Bin Meng | bdb33d8 | 2018-10-24 06:36:36 -0700 | [diff] [blame] | 313 | #endif |
Simon Glass | 7cbab24 | 2014-10-29 13:09:00 -0600 | [diff] [blame] | 314 | .priv_auto_alloc_size = sizeof(struct atmel_serial_priv), |
| 315 | }; |
| 316 | #endif |
Wenyou Yang | 6b611e6 | 2016-10-17 09:49:55 +0800 | [diff] [blame] | 317 | |
| 318 | #ifdef CONFIG_DEBUG_UART_ATMEL |
| 319 | static inline void _debug_uart_init(void) |
| 320 | { |
| 321 | atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; |
| 322 | |
Wenyou Yang | b045a60 | 2017-04-14 15:01:27 +0800 | [diff] [blame] | 323 | _atmel_serial_init(usart, CONFIG_DEBUG_UART_CLOCK, CONFIG_BAUDRATE); |
Wenyou Yang | 6b611e6 | 2016-10-17 09:49:55 +0800 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static inline void _debug_uart_putc(int ch) |
| 327 | { |
| 328 | atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; |
| 329 | |
| 330 | while (!(readl(&usart->csr) & USART3_BIT(TXRDY))) |
| 331 | ; |
| 332 | |
| 333 | writel(ch, &usart->thr); |
| 334 | } |
| 335 | |
| 336 | DEBUG_UART_FUNCS |
| 337 | #endif |