Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-pxa/include/mach/uncompress.h |
| 3 | * |
| 4 | * Author: Nicolas Pitre |
| 5 | * Copyright: (C) 2001 MontaVista Software Inc. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/serial_reg.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 13 | #include <asm/mach-types.h> |
| 14 | |
Eric Miao | c95efee | 2010-02-19 13:49:39 +0800 | [diff] [blame] | 15 | #define FFUART_BASE (0x40100000) |
| 16 | #define BTUART_BASE (0x40200000) |
| 17 | #define STUART_BASE (0x40700000) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 18 | |
Nicolas Pitre | 8ea0de4 | 2011-04-28 17:00:17 -0400 | [diff] [blame] | 19 | unsigned long uart_base; |
| 20 | unsigned int uart_shift; |
| 21 | unsigned int uart_is_pxa; |
Eric Miao | c95efee | 2010-02-19 13:49:39 +0800 | [diff] [blame] | 22 | |
| 23 | static inline unsigned char uart_read(int offset) |
| 24 | { |
| 25 | return *(volatile unsigned char *)(uart_base + (offset << uart_shift)); |
| 26 | } |
| 27 | |
| 28 | static inline void uart_write(unsigned char val, int offset) |
| 29 | { |
| 30 | *(volatile unsigned char *)(uart_base + (offset << uart_shift)) = val; |
| 31 | } |
| 32 | |
| 33 | static inline int uart_is_enabled(void) |
| 34 | { |
| 35 | /* assume enabled by default for non-PXA uarts */ |
| 36 | return uart_is_pxa ? uart_read(UART_IER) & UART_IER_UUE : 1; |
| 37 | } |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 38 | |
| 39 | static inline void putc(char c) |
| 40 | { |
Eric Miao | c95efee | 2010-02-19 13:49:39 +0800 | [diff] [blame] | 41 | if (!uart_is_enabled()) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 42 | return; |
Eric Miao | c95efee | 2010-02-19 13:49:39 +0800 | [diff] [blame] | 43 | |
| 44 | while (!(uart_read(UART_LSR) & UART_LSR_THRE)) |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 45 | barrier(); |
Eric Miao | c95efee | 2010-02-19 13:49:39 +0800 | [diff] [blame] | 46 | |
| 47 | uart_write(c, UART_TX); |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /* |
| 51 | * This does not append a newline |
| 52 | */ |
| 53 | static inline void flush(void) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | static inline void arch_decomp_setup(void) |
| 58 | { |
Jonathan Cameron | 2a8ac18 | 2010-03-08 17:44:19 +0000 | [diff] [blame] | 59 | /* initialize to default */ |
| 60 | uart_base = FFUART_BASE; |
| 61 | uart_shift = 2; |
| 62 | uart_is_pxa = 1; |
| 63 | |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 64 | if (machine_is_littleton() || machine_is_intelmote2() |
Mike Rapoport | 321d9eb | 2009-06-04 10:44:53 +0300 | [diff] [blame] | 65 | || machine_is_csb726() || machine_is_stargate2() |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 66 | || machine_is_cm_x300() || machine_is_balloon3()) |
Eric Miao | c95efee | 2010-02-19 13:49:39 +0800 | [diff] [blame] | 67 | uart_base = STUART_BASE; |
Marc Zyngier | 662b0836 | 2010-02-19 14:07:37 +0800 | [diff] [blame] | 68 | |
| 69 | if (machine_is_arcom_zeus()) { |
| 70 | uart_base = 0x10000000; /* nCS4 */ |
| 71 | uart_shift = 1; |
| 72 | uart_is_pxa = 0; |
| 73 | } |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 74 | } |