Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <commproc.h> |
| 10 | #include <command.h> |
| 11 | #include <serial.h> |
| 12 | #include <watchdog.h> |
| 13 | #include <linux/compiler.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | #if !defined(CONFIG_8xx_CONS_NONE) /* No Console at all */ |
| 18 | |
| 19 | #if defined(CONFIG_8xx_CONS_SMC1) /* Console on SMC1 */ |
| 20 | #define SMC_INDEX 0 |
| 21 | #define PROFF_SMC PROFF_SMC1 |
| 22 | #define CPM_CR_CH_SMC CPM_CR_CH_SMC1 |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 23 | #define IOPINS 0xc0 |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 24 | |
| 25 | #elif defined(CONFIG_8xx_CONS_SMC2) /* Console on SMC2 */ |
| 26 | #define SMC_INDEX 1 |
| 27 | #define PROFF_SMC PROFF_SMC2 |
| 28 | #define CPM_CR_CH_SMC CPM_CR_CH_SMC2 |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 29 | #define IOPINS 0xc00 |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 30 | |
| 31 | #endif /* CONFIG_8xx_CONS_SMCx */ |
| 32 | |
| 33 | #if !defined(CONFIG_SYS_SMC_RXBUFLEN) |
| 34 | #define CONFIG_SYS_SMC_RXBUFLEN 1 |
| 35 | #define CONFIG_SYS_MAXIDLE 0 |
| 36 | #else |
| 37 | #if !defined(CONFIG_SYS_MAXIDLE) |
| 38 | #error "you must define CONFIG_SYS_MAXIDLE" |
| 39 | #endif |
| 40 | #endif |
| 41 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 42 | struct serialbuffer { |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 43 | cbd_t rxbd; /* Rx BD */ |
| 44 | cbd_t txbd; /* Tx BD */ |
| 45 | uint rxindex; /* index for next character to read */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 46 | uchar rxbuf[CONFIG_SYS_SMC_RXBUFLEN];/* rx buffers */ |
| 47 | uchar txbuf; /* tx buffers */ |
| 48 | }; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 49 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 50 | static void serial_setdivisor(cpm8xx_t __iomem *cp) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 51 | { |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 52 | int divisor = (gd->cpu_clk + 8 * gd->baudrate) / 16 / gd->baudrate; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 53 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 54 | if (divisor / 16 > 0x1000) { |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 55 | /* bad divisor, assume 50MHz clock and 9600 baud */ |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 56 | divisor = (50 * 1000 * 1000 + 8 * 9600) / 16 / 9600; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | #ifdef CONFIG_SYS_BRGCLK_PRESCALE |
| 60 | divisor /= CONFIG_SYS_BRGCLK_PRESCALE; |
| 61 | #endif |
| 62 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 63 | if (divisor <= 0x1000) |
| 64 | out_be32(&cp->cp_brgc1, ((divisor - 1) << 1) | CPM_BRG_EN); |
| 65 | else |
| 66 | out_be32(&cp->cp_brgc1, ((divisor / 16 - 1) << 1) | CPM_BRG_EN | |
| 67 | CPM_BRG_DIV16); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Minimal serial functions needed to use one of the SMC ports |
| 72 | * as serial console interface. |
| 73 | */ |
| 74 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 75 | static void smc_setbrg(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 76 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 77 | immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 78 | cpm8xx_t __iomem *cp = &(im->im_cpm); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 79 | |
| 80 | /* Set up the baud rate generator. |
| 81 | * See 8xx_io/commproc.c for details. |
| 82 | * |
| 83 | * Wire BRG1 to SMCx |
| 84 | */ |
| 85 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 86 | out_be32(&cp->cp_simode, 0); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 87 | |
| 88 | serial_setdivisor(cp); |
| 89 | } |
| 90 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 91 | static int smc_init(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 92 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 93 | immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 94 | smc_t __iomem *sp; |
| 95 | smc_uart_t __iomem *up; |
| 96 | cpm8xx_t __iomem *cp = &(im->im_cpm); |
| 97 | struct serialbuffer __iomem *rtx; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 98 | |
| 99 | /* initialize pointers to SMC */ |
| 100 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 101 | sp = cp->cp_smc + SMC_INDEX; |
| 102 | up = (smc_uart_t __iomem *)&cp->cp_dparam[PROFF_SMC]; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 103 | /* Disable relocation */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 104 | out_be16(&up->smc_rpbase, 0); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 105 | |
| 106 | /* Disable transmitter/receiver. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 107 | clrbits_be16(&sp->smc_smcmr, SMCMR_REN | SMCMR_TEN); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 108 | |
| 109 | /* Enable SDMA. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 110 | out_be32(&im->im_siu_conf.sc_sdcr, 1); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 111 | |
| 112 | /* clear error conditions */ |
| 113 | #ifdef CONFIG_SYS_SDSR |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 114 | out_8(&im->im_sdma.sdma_sdsr, CONFIG_SYS_SDSR); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 115 | #else |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 116 | out_8(&im->im_sdma.sdma_sdsr, 0x83); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 117 | #endif |
| 118 | |
| 119 | /* clear SDMA interrupt mask */ |
| 120 | #ifdef CONFIG_SYS_SDMR |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 121 | out_8(&im->im_sdma.sdma_sdmr, CONFIG_SYS_SDMR); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 122 | #else |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 123 | out_8(&im->im_sdma.sdma_sdmr, 0x00); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 124 | #endif |
| 125 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 126 | /* Use Port B for SMCx instead of other functions. */ |
| 127 | setbits_be32(&cp->cp_pbpar, IOPINS); |
| 128 | clrbits_be32(&cp->cp_pbdir, IOPINS); |
| 129 | clrbits_be16(&cp->cp_pbodr, IOPINS); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 130 | |
| 131 | /* Set the physical address of the host memory buffers in |
| 132 | * the buffer descriptors. |
| 133 | */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 134 | rtx = (struct serialbuffer __iomem *)&cp->cp_dpmem[CPM_SERIAL_BASE]; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 135 | /* Allocate space for two buffer descriptors in the DP ram. |
| 136 | * For now, this address seems OK, but it may have to |
| 137 | * change with newer versions of the firmware. |
| 138 | * damm: allocating space after the two buffers for rx/tx data |
| 139 | */ |
| 140 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 141 | out_be32(&rtx->rxbd.cbd_bufaddr, (__force uint)&rtx->rxbuf); |
| 142 | out_be16(&rtx->rxbd.cbd_sc, 0); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 143 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 144 | out_be32(&rtx->txbd.cbd_bufaddr, (__force uint)&rtx->txbuf); |
| 145 | out_be16(&rtx->txbd.cbd_sc, 0); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 146 | |
| 147 | /* Set up the uart parameters in the parameter ram. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 148 | out_be16(&up->smc_rbase, CPM_SERIAL_BASE); |
| 149 | out_be16(&up->smc_tbase, CPM_SERIAL_BASE + sizeof(cbd_t)); |
| 150 | out_8(&up->smc_rfcr, SMC_EB); |
| 151 | out_8(&up->smc_tfcr, SMC_EB); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 152 | |
| 153 | /* Set UART mode, 8 bit, no parity, one stop. |
| 154 | * Enable receive and transmit. |
| 155 | */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 156 | out_be16(&sp->smc_smcmr, smcr_mk_clen(9) | SMCMR_SM_UART); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 157 | |
| 158 | /* Mask all interrupts and remove anything pending. |
| 159 | */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 160 | out_8(&sp->smc_smcm, 0); |
| 161 | out_8(&sp->smc_smce, 0xff); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 162 | |
| 163 | /* Set up the baud rate generator */ |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 164 | smc_setbrg(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 165 | |
| 166 | /* Make the first buffer the only buffer. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 167 | setbits_be16(&rtx->txbd.cbd_sc, BD_SC_WRAP); |
| 168 | setbits_be16(&rtx->rxbd.cbd_sc, BD_SC_EMPTY | BD_SC_WRAP); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 169 | |
| 170 | /* single/multi character receive. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 171 | out_be16(&up->smc_mrblr, CONFIG_SYS_SMC_RXBUFLEN); |
| 172 | out_be16(&up->smc_maxidl, CONFIG_SYS_MAXIDLE); |
| 173 | out_be32(&rtx->rxindex, 0); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 174 | |
| 175 | /* Initialize Tx/Rx parameters. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 176 | while (in_be16(&cp->cp_cpcr) & CPM_CR_FLG) /* wait if cp is busy */ |
| 177 | ; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 178 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 179 | out_be16(&cp->cp_cpcr, |
| 180 | mk_cr_cmd(CPM_CR_CH_SMC, CPM_CR_INIT_TRX) | CPM_CR_FLG); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 181 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 182 | while (in_be16(&cp->cp_cpcr) & CPM_CR_FLG) /* wait if cp is busy */ |
| 183 | ; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 184 | |
| 185 | /* Enable transmitter/receiver. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 186 | setbits_be16(&sp->smc_smcmr, SMCMR_REN | SMCMR_TEN); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 187 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 188 | return 0; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 189 | } |
| 190 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 191 | static void smc_putc(const char c) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 192 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 193 | immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 194 | cpm8xx_t __iomem *cpmp = &(im->im_cpm); |
| 195 | struct serialbuffer __iomem *rtx; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 196 | |
| 197 | if (c == '\n') |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 198 | smc_putc('\r'); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 199 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 200 | rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE]; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 201 | |
| 202 | /* Wait for last character to go. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 203 | out_8(&rtx->txbuf, c); |
| 204 | out_be16(&rtx->txbd.cbd_datlen, 1); |
| 205 | setbits_be16(&rtx->txbd.cbd_sc, BD_SC_READY); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 206 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 207 | while (in_be16(&rtx->txbd.cbd_sc) & BD_SC_READY) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 208 | WATCHDOG_RESET(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 209 | } |
| 210 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 211 | static void smc_puts(const char *s) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 212 | { |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 213 | while (*s) |
| 214 | smc_putc(*s++); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 215 | } |
| 216 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 217 | static int smc_getc(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 218 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 219 | immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 220 | cpm8xx_t __iomem *cpmp = &(im->im_cpm); |
| 221 | struct serialbuffer __iomem *rtx; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 222 | unsigned char c; |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 223 | uint rxindex; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 224 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 225 | rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE]; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 226 | |
| 227 | /* Wait for character to show up. */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 228 | while (in_be16(&rtx->rxbd.cbd_sc) & BD_SC_EMPTY) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 229 | WATCHDOG_RESET(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 230 | |
| 231 | /* the characters are read one by one, |
| 232 | * use the rxindex to know the next char to deliver |
| 233 | */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 234 | rxindex = in_be32(&rtx->rxindex); |
| 235 | c = in_8(rtx->rxbuf + rxindex); |
| 236 | rxindex++; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 237 | |
| 238 | /* check if all char are readout, then make prepare for next receive */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 239 | if (rxindex >= in_be16(&rtx->rxbd.cbd_datlen)) { |
| 240 | rxindex = 0; |
| 241 | setbits_be16(&rtx->rxbd.cbd_sc, BD_SC_EMPTY); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 242 | } |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 243 | out_be32(&rtx->rxindex, rxindex); |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 244 | return c; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 245 | } |
| 246 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 247 | static int smc_tstc(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 248 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 249 | immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 250 | cpm8xx_t __iomem *cpmp = &(im->im_cpm); |
| 251 | struct serialbuffer __iomem *rtx; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 252 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 253 | rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE]; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 254 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 255 | return !(in_be16(&rtx->rxbd.cbd_sc) & BD_SC_EMPTY); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 256 | } |
| 257 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame^] | 258 | struct serial_device serial_smc_device = { |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 259 | .name = "serial_smc", |
| 260 | .start = smc_init, |
| 261 | .stop = NULL, |
| 262 | .setbrg = smc_setbrg, |
| 263 | .getc = smc_getc, |
| 264 | .tstc = smc_tstc, |
| 265 | .putc = smc_putc, |
| 266 | .puts = smc_puts, |
| 267 | }; |
| 268 | |
| 269 | __weak struct serial_device *default_serial_console(void) |
| 270 | { |
| 271 | return &serial_smc_device; |
| 272 | } |
| 273 | |
| 274 | void mpc8xx_serial_initialize(void) |
| 275 | { |
| 276 | serial_register(&serial_smc_device); |
| 277 | } |
| 278 | |
| 279 | #endif /* CONFIG_8xx_CONS_NONE */ |