Scott Wood | c374e00 | 2007-07-16 11:43:43 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Common CPM code |
| 3 | * |
| 4 | * Author: Scott Wood <scottwood@freescale.com> |
| 5 | * |
| 6 | * Copyright 2007 Freescale Semiconductor, Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of version 2 of the GNU General Public License as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <asm/udbg.h> |
| 15 | #include <asm/io.h> |
| 16 | #include <asm/system.h> |
| 17 | #include <mm/mmu_decl.h> |
| 18 | |
| 19 | #ifdef CONFIG_PPC_EARLY_DEBUG_CPM |
| 20 | static u32 __iomem *cpm_udbg_txdesc = |
| 21 | (u32 __iomem __force *)CONFIG_PPC_EARLY_DEBUG_CPM_ADDR; |
| 22 | |
| 23 | static void udbg_putc_cpm(char c) |
| 24 | { |
| 25 | u8 __iomem *txbuf = (u8 __iomem __force *)in_be32(&cpm_udbg_txdesc[1]); |
| 26 | |
| 27 | if (c == '\n') |
| 28 | udbg_putc('\r'); |
| 29 | |
| 30 | while (in_be32(&cpm_udbg_txdesc[0]) & 0x80000000) |
| 31 | ; |
| 32 | |
| 33 | out_8(txbuf, c); |
| 34 | out_be32(&cpm_udbg_txdesc[0], 0xa0000001); |
| 35 | } |
| 36 | |
| 37 | void __init udbg_init_cpm(void) |
| 38 | { |
| 39 | if (cpm_udbg_txdesc) { |
| 40 | #ifdef CONFIG_CPM2 |
| 41 | setbat(1, 0xf0000000, 0xf0000000, 1024*1024, _PAGE_IO); |
| 42 | #endif |
| 43 | udbg_putc = udbg_putc_cpm; |
| 44 | } |
| 45 | } |
| 46 | #endif |