wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, <wd@denx.de> |
| 4 | * |
| 5 | * (C) Copyright 2002 |
| 6 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 7 | * Marius Groeger <mgroeger@sysgo.de> |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 11 | * Alex Zuepke <azu@sysgo.de> |
| 12 | * |
| 13 | * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or modify |
| 16 | * it under the terms of the GNU General Public License as published by |
| 17 | * the Free Software Foundation; either version 2 of the License, or |
| 18 | * (at your option) any later version. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, write to the Free Software |
| 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <common.h> |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 32 | #include <watchdog.h> |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 33 | #include <serial.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 34 | #include <asm/arch/pxa-regs.h> |
| 35 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 38 | #define FFUART_INDEX 0 |
| 39 | #define BTUART_INDEX 1 |
| 40 | #define STUART_INDEX 2 |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 41 | |
| 42 | #ifndef CONFIG_SERIAL_MULTI |
| 43 | #if defined (CONFIG_FFUART) |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 44 | #define UART_INDEX FFUART_INDEX |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 45 | #elif defined (CONFIG_BTUART) |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 46 | #define UART_INDEX BTUART_INDEX |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 47 | #elif defined (CONFIG_STUART) |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 48 | #define UART_INDEX STUART_INDEX |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 49 | #else |
| 50 | #error "Bad: you didn't configure serial ..." |
| 51 | #endif |
| 52 | #endif |
| 53 | |
| 54 | void pxa_setbrg_dev (unsigned int uart_index) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 55 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 56 | unsigned int quot = 0; |
| 57 | |
| 58 | if (gd->baudrate == 1200) |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 59 | quot = 768; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 60 | else if (gd->baudrate == 9600) |
| 61 | quot = 96; |
| 62 | else if (gd->baudrate == 19200) |
| 63 | quot = 48; |
| 64 | else if (gd->baudrate == 38400) |
| 65 | quot = 24; |
| 66 | else if (gd->baudrate == 57600) |
| 67 | quot = 16; |
| 68 | else if (gd->baudrate == 115200) |
| 69 | quot = 8; |
| 70 | else |
| 71 | hang (); |
| 72 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 73 | switch (uart_index) { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 74 | case FFUART_INDEX: |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 75 | #ifdef CONFIG_CPU_MONAHANS |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 76 | CKENA |= CKENA_22_FFUART; |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 77 | #else |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 78 | CKEN |= CKEN6_FFUART; |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 79 | #endif /* CONFIG_CPU_MONAHANS */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 80 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 81 | FFIER = 0; /* Disable for now */ |
| 82 | FFFCR = 0; /* No fifos enabled */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 83 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 84 | /* set baud rate */ |
| 85 | FFLCR = LCR_WLS0 | LCR_WLS1 | LCR_DLAB; |
| 86 | FFDLL = quot & 0xff; |
| 87 | FFDLH = quot >> 8; |
| 88 | FFLCR = LCR_WLS0 | LCR_WLS1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 89 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 90 | FFIER = IER_UUE; /* Enable FFUART */ |
| 91 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 92 | |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 93 | case BTUART_INDEX: |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 94 | #ifdef CONFIG_CPU_MONAHANS |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 95 | CKENA |= CKENA_21_BTUART; |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 96 | #else |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 97 | CKEN |= CKEN7_BTUART; |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 98 | #endif /* CONFIG_CPU_MONAHANS */ |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 99 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 100 | BTIER = 0; |
| 101 | BTFCR = 0; |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 102 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 103 | /* set baud rate */ |
| 104 | BTLCR = LCR_DLAB; |
| 105 | BTDLL = quot & 0xff; |
| 106 | BTDLH = quot >> 8; |
| 107 | BTLCR = LCR_WLS0 | LCR_WLS1; |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 108 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 109 | BTIER = IER_UUE; /* Enable BFUART */ |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 110 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 111 | break; |
| 112 | |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 113 | case STUART_INDEX: |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 114 | #ifdef CONFIG_CPU_MONAHANS |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 115 | CKENA |= CKENA_23_STUART; |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 116 | #else |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 117 | CKEN |= CKEN5_STUART; |
Markus Klotzbücher | e026957 | 2006-02-07 20:04:48 +0100 | [diff] [blame] | 118 | #endif /* CONFIG_CPU_MONAHANS */ |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 119 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 120 | STIER = 0; |
| 121 | STFCR = 0; |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 122 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 123 | /* set baud rate */ |
| 124 | STLCR = LCR_DLAB; |
| 125 | STDLL = quot & 0xff; |
| 126 | STDLH = quot >> 8; |
| 127 | STLCR = LCR_WLS0 | LCR_WLS1; |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 128 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 129 | STIER = IER_UUE; /* Enable STUART */ |
| 130 | break; |
wdenk | 5f535fe | 2003-09-18 09:21:33 +0000 | [diff] [blame] | 131 | |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 132 | default: |
| 133 | hang(); |
| 134 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | |
| 138 | /* |
| 139 | * Initialise the serial port with the given baudrate. The settings |
| 140 | * are always 8 data bits, no parity, 1 stop bit, no start bits. |
| 141 | * |
| 142 | */ |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 143 | int pxa_init_dev (unsigned int uart_index) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 144 | { |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 145 | pxa_setbrg_dev (uart_index); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 146 | |
| 147 | return (0); |
| 148 | } |
| 149 | |
| 150 | |
| 151 | /* |
| 152 | * Output a single byte to the serial port. |
| 153 | */ |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 154 | void pxa_putc_dev (unsigned int uart_index,const char c) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 155 | { |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 156 | switch (uart_index) { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 157 | case FFUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 158 | /* wait for room in the tx FIFO on FFUART */ |
| 159 | while ((FFLSR & LSR_TEMT) == 0) |
| 160 | WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */ |
| 161 | FFTHR = c; |
| 162 | break; |
| 163 | |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 164 | case BTUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 165 | while ((BTLSR & LSR_TEMT ) == 0 ) |
| 166 | WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */ |
| 167 | BTTHR = c; |
| 168 | break; |
| 169 | |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 170 | case STUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 171 | while ((STLSR & LSR_TEMT ) == 0 ) |
| 172 | WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */ |
| 173 | STTHR = c; |
| 174 | break; |
| 175 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 176 | |
| 177 | /* If \n, also do \r */ |
| 178 | if (c == '\n') |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 179 | pxa_putc_dev (uart_index,'\r'); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /* |
| 183 | * Read a single byte from the serial port. Returns 1 on success, 0 |
| 184 | * otherwise. When the function is succesfull, the character read is |
| 185 | * written into its argument c. |
| 186 | */ |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 187 | int pxa_tstc_dev (unsigned int uart_index) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 188 | { |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 189 | switch (uart_index) { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 190 | case FFUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 191 | return FFLSR & LSR_DR; |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 192 | case BTUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 193 | return BTLSR & LSR_DR; |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 194 | case STUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 195 | return STLSR & LSR_DR; |
| 196 | } |
| 197 | return -1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /* |
| 201 | * Read a single byte from the serial port. Returns 1 on success, 0 |
| 202 | * otherwise. When the function is succesfull, the character read is |
| 203 | * written into its argument c. |
| 204 | */ |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 205 | int pxa_getc_dev (unsigned int uart_index) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 206 | { |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 207 | switch (uart_index) { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 208 | case FFUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 209 | while (!(FFLSR & LSR_DR)) |
| 210 | WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */ |
| 211 | return (char) FFRBR & 0xff; |
| 212 | |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 213 | case BTUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 214 | while (!(BTLSR & LSR_DR)) |
| 215 | WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */ |
| 216 | return (char) BTRBR & 0xff; |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 217 | case STUART_INDEX: |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 218 | while (!(STLSR & LSR_DR)) |
| 219 | WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */ |
| 220 | return (char) STRBR & 0xff; |
| 221 | } |
| 222 | return -1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | void |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 226 | pxa_puts_dev (unsigned int uart_index,const char *s) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 227 | { |
| 228 | while (*s) { |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 229 | pxa_putc_dev (uart_index,*s++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 232 | |
| 233 | #if defined (CONFIG_FFUART) |
| 234 | static int ffuart_init(void) |
| 235 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 236 | return pxa_init_dev(FFUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | static void ffuart_setbrg(void) |
| 240 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 241 | return pxa_setbrg_dev(FFUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | static void ffuart_putc(const char c) |
| 245 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 246 | return pxa_putc_dev(FFUART_INDEX,c); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | static void ffuart_puts(const char *s) |
| 250 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 251 | return pxa_puts_dev(FFUART_INDEX,s); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | static int ffuart_getc(void) |
| 255 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 256 | return pxa_getc_dev(FFUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static int ffuart_tstc(void) |
| 260 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 261 | return pxa_tstc_dev(FFUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | struct serial_device serial_ffuart_device = |
| 265 | { |
| 266 | "serial_ffuart", |
| 267 | "PXA", |
| 268 | ffuart_init, |
| 269 | ffuart_setbrg, |
| 270 | ffuart_getc, |
| 271 | ffuart_tstc, |
| 272 | ffuart_putc, |
| 273 | ffuart_puts, |
| 274 | }; |
| 275 | #endif |
| 276 | |
| 277 | #if defined (CONFIG_BTUART) |
| 278 | static int btuart_init(void) |
| 279 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 280 | return pxa_init_dev(BTUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | static void btuart_setbrg(void) |
| 284 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 285 | return pxa_setbrg_dev(BTUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static void btuart_putc(const char c) |
| 289 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 290 | return pxa_putc_dev(BTUART_INDEX,c); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | static void btuart_puts(const char *s) |
| 294 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 295 | return pxa_puts_dev(BTUART_INDEX,s); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | static int btuart_getc(void) |
| 299 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 300 | return pxa_getc_dev(BTUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | static int btuart_tstc(void) |
| 304 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 305 | return pxa_tstc_dev(BTUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | struct serial_device serial_btuart_device = |
| 309 | { |
| 310 | "serial_btuart", |
| 311 | "PXA", |
| 312 | btuart_init, |
| 313 | btuart_setbrg, |
| 314 | btuart_getc, |
| 315 | btuart_tstc, |
| 316 | btuart_putc, |
| 317 | btuart_puts, |
| 318 | }; |
| 319 | #endif |
| 320 | |
| 321 | #if defined (CONFIG_STUART) |
| 322 | static int stuart_init(void) |
| 323 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 324 | return pxa_init_dev(STUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | static void stuart_setbrg(void) |
| 328 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 329 | return pxa_setbrg_dev(STUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | static void stuart_putc(const char c) |
| 333 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 334 | return pxa_putc_dev(STUART_INDEX,c); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | static void stuart_puts(const char *s) |
| 338 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 339 | return pxa_puts_dev(STUART_INDEX,s); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | static int stuart_getc(void) |
| 343 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 344 | return pxa_getc_dev(STUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | static int stuart_tstc(void) |
| 348 | { |
Marcel Ziswiler | 2a4741d | 2007-10-19 00:25:33 +0200 | [diff] [blame] | 349 | return pxa_tstc_dev(STUART_INDEX); |
stefano babic | 80172c6 | 2007-08-30 22:57:04 +0200 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | struct serial_device serial_stuart_device = |
| 353 | { |
| 354 | "serial_stuart", |
| 355 | "PXA", |
| 356 | stuart_init, |
| 357 | stuart_setbrg, |
| 358 | stuart_getc, |
| 359 | stuart_tstc, |
| 360 | stuart_putc, |
| 361 | stuart_puts, |
| 362 | }; |
| 363 | #endif |
| 364 | |
| 365 | |
| 366 | #ifndef CONFIG_SERIAL_MULTI |
| 367 | inline int serial_init(void) { |
| 368 | return (pxa_init_dev(UART_INDEX)); |
| 369 | } |
| 370 | void serial_setbrg(void) { |
| 371 | pxa_setbrg_dev(UART_INDEX); |
| 372 | } |
| 373 | int serial_getc(void) { |
| 374 | return(pxa_getc_dev(UART_INDEX)); |
| 375 | } |
| 376 | int serial_tstc(void) { |
| 377 | return(pxa_tstc_dev(UART_INDEX)); |
| 378 | } |
| 379 | void serial_putc(const char c) { |
| 380 | pxa_putc_dev(UART_INDEX,c); |
| 381 | } |
| 382 | void serial_puts(const char *s) { |
| 383 | pxa_puts_dev(UART_INDEX,s); |
| 384 | } |
| 385 | #endif /* CONFIG_SERIAL_MULTI */ |