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