2 * carl9170 firmware - used by the ar9170 wireless device
4 * UART debug interface functions.
6 * Copyright (c) 2000-2005 ZyDAS Technology Corporation
7 * Copyright (c) 2007-2009 Atheros Communications, Inc.
8 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
9 * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #ifdef CONFIG_CARL9170FW_DEBUG_UART
31 void uart_putc(const char c)
33 set(AR9170_UART_REG_TX_HOLDING, c);
35 while (get(AR9170_UART_REG_LINE_STATUS) &
36 AR9170_UART_LINE_STS_TX_FIFO_NEAR_EMPTY) {
38 * wait until the byte has made it
43 void uart_print_hex_dump(const void *buf, const int len)
45 unsigned int offset = 0;
52 uart_putc(*((uint8_t *) buf + offset));
59 unsigned int timeout = 0;
61 #ifdef CONFIG_CARL9170FW_UART_CLOCK_25M
62 set(AR9170_UART_REG_DIVISOR_LSB, 0xc);
63 #elif CONFIG_CARL9170FW_UART_CLOCK_40M
64 set(AR9170_UART_REG_DIVISOR_LSB, 0x14); /* 40 MHz */
65 set(AR9170_UART_REG_REMAINDER, 0xb38e);
67 #error "Unsupported UART clock"
68 #endif /* CARL9170FW_UART_CLOCK_25M */
70 while (get(AR9170_UART_REG_LINE_STATUS) &
71 AR9170_UART_LINE_STS_TRANSMITTER_EMPTY) {
72 if (timeout++ >= 10000)
76 #endif /* CONFIG_CARL9170FW_DEBUG_UART */