aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/files/arch
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-05-31 22:53:27 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-05-31 22:53:27 +0000
commit8fa9bf2dd7ee6d33c11abe4cdac6cac3725e6423 (patch)
tree835a24639e6fbfd51fae626401bc3162d2363825 /target/linux/ar71xx/files/arch
parent23388b4cd908142b969b7716771bde50013f2b66 (diff)
downloadmaster-187ad058-8fa9bf2dd7ee6d33c11abe4cdac6cac3725e6423.tar.gz
master-187ad058-8fa9bf2dd7ee6d33c11abe4cdac6cac3725e6423.tar.bz2
master-187ad058-8fa9bf2dd7ee6d33c11abe4cdac6cac3725e6423.zip
ar71xx: add AR933x specific early_printk support
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27055 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/files/arch')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/early_printk.c64
-rw-r--r--target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h3
2 files changed, 62 insertions, 5 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/early_printk.c b/target/linux/ar71xx/files/arch/mips/ar71xx/early_printk.c
index 76f69c562b..f84c76d753 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/early_printk.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/early_printk.c
@@ -1,7 +1,7 @@
/*
- * Atheros AR71xx SoC early printk support
+ * Atheros AR7xxx/AR9xxx SoC early printk support
*
- * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
@@ -9,19 +9,23 @@
* by the Free Software Foundation.
*/
+#include <linux/errno.h>
#include <linux/io.h>
#include <linux/serial_reg.h>
#include <asm/addrspace.h>
#include <asm/mach-ar71xx/ar71xx.h>
+static void __iomem *prom_uart_base;
+static void (*_putchar)(unsigned char);
+
#define UART_READ(r) \
- __raw_readl((void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE) + 4 * (r)))
+ __raw_readl(prom_uart_base + 4 * (r))
#define UART_WRITE(r, v) \
- __raw_writel((v), (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE) + 4*(r)))
+ __raw_writel((v), prom_uart_base + 4 * (r))
-void prom_putchar(unsigned char ch)
+static void prom_putchar_ar71xx(unsigned char ch)
{
while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0)
;
@@ -30,3 +34,53 @@ void prom_putchar(unsigned char ch)
;
}
+static void prom_putchar_ar933x(unsigned char ch)
+{
+ while (((UART_READ(0)) & 0x200) == 0)
+ ;
+ UART_WRITE(0, 0x200 | ch);
+ while (((UART_READ(0)) & 0x200) == 0)
+ ;
+}
+
+static int prom_putchar_init(void)
+{
+ if (_putchar)
+ return 0;
+
+ switch(ar71xx_soc) {
+ case AR71XX_SOC_AR7130:
+ case AR71XX_SOC_AR7141:
+ case AR71XX_SOC_AR7161:
+ case AR71XX_SOC_AR7240:
+ case AR71XX_SOC_AR7241:
+ case AR71XX_SOC_AR7242:
+ case AR71XX_SOC_AR9130:
+ case AR71XX_SOC_AR9132:
+ case AR71XX_SOC_AR9341:
+ case AR71XX_SOC_AR9342:
+ case AR71XX_SOC_AR9344:
+ prom_uart_base = (void __iomem *) KSEG1ADDR(AR71XX_UART_BASE);
+ _putchar = prom_putchar_ar71xx;
+ break;
+
+ case AR71XX_SOC_AR9330:
+ case AR71XX_SOC_AR9331:
+ prom_uart_base = (void __iomem *) KSEG1ADDR(AR933X_UART_BASE);
+ _putchar = prom_putchar_ar933x;
+ break;
+
+ default:
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+void prom_putchar(unsigned char ch)
+{
+ if (prom_putchar_init())
+ return;
+
+ _putchar(ch);
+}
diff --git a/target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h b/target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h
index 9dc15fea3d..47ad8a4bae 100644
--- a/target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h
+++ b/target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h
@@ -70,6 +70,9 @@
#define AR91XX_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
#define AR91XX_WMAC_SIZE 0x30000
+#define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000)
+#define AR933X_UART_SIZE 0x14
+
#define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
#define AR934X_WMAC_SIZE 0x20000