Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Initial Allwinner A80 support.
details: https://anonhg.NetBSD.org/src/rev/68dd90c255d8
branches: trunk
changeset: 804884:68dd90c255d8
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Dec 05 01:13:11 2014 +0000
description:
Initial Allwinner A80 support.
diffstat:
sys/arch/arm/allwinner/awin_board.c | 19 +-
sys/arch/arm/allwinner/awin_com.c | 7 +-
sys/arch/arm/allwinner/awin_intr.h | 24 ++-
sys/arch/arm/allwinner/awin_io.c | 19 +-
sys/arch/arm/allwinner/awin_reg.h | 39 ++++
sys/arch/arm/allwinner/awin_var.h | 4 +-
sys/arch/evbarm/awin/awin_machdep.c | 22 ++-
sys/arch/evbarm/conf/ALLWINNER_A80 | 319 ++++++++++++++++++++++++++++++++++++
8 files changed, 439 insertions(+), 14 deletions(-)
diffs (truncated from 680 to 300 lines):
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/arm/allwinner/awin_board.c
--- a/sys/arch/arm/allwinner/awin_board.c Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_board.c Fri Dec 05 01:13:11 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_board.c,v 1.29 2014/12/04 02:12:07 jmcneill Exp $ */
+/* $NetBSD: awin_board.c,v 1.30 2014/12/05 01:13:11 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.29 2014/12/04 02:12:07 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.30 2014/12/05 01:13:11 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -124,6 +124,15 @@
awin_cpu_clk(void)
{
struct cpu_info * const ci = curcpu();
+
+#if defined(ALLWINNER_A80)
+ const uint32_t c0cpux = bus_space_read_4(&awin_bs_tag, awin_core_bsh,
+ AWIN_A80_CCU_OFFSET + AWIN_A80_CCU_PLL_C0CPUX_CTRL_REG);
+ const u_int p = (c0cpux & AWIN_A80_CCU_PLL_OUT_EXT_DIVP) ? 4 : 1;
+ const u_int n = __SHIFTOUT(c0cpux, AWIN_A80_CCU_PLL_FACTOR_N);
+
+ ci->ci_data.cpu_cc_freq = ((uint64_t)AWIN_REF_FREQ * n) / p;
+#else
u_int reg = awin_chip_id() == AWIN_CHIP_ID_A31 ?
AWIN_A31_CPU_AXI_CFG_REG :
AWIN_CPU_AHB_APB0_CFG_REG;
@@ -160,6 +169,7 @@
ci->ci_data.cpu_cc_freq = 200000000;
break;
}
+#endif
}
void
@@ -279,6 +289,9 @@
uint16_t
awin_chip_id(void)
{
+#if defined(ALLWINNER_A80)
+ return AWIN_CHIP_ID_A80;
+#else
static uint16_t chip_id = 0;
uint32_t ver;
@@ -295,6 +308,7 @@
}
return chip_id;
+#endif
}
const char *
@@ -308,6 +322,7 @@
case AWIN_CHIP_ID_A20: return "A20";
case AWIN_CHIP_ID_A23: return "A23";
case AWIN_CHIP_ID_A31: return "A31";
+ case AWIN_CHIP_ID_A80: return "A80";
default: return "unknown chip";
}
}
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/arm/allwinner/awin_com.c
--- a/sys/arch/arm/allwinner/awin_com.c Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_com.c Fri Dec 05 01:13:11 2014 +0000
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: awin_com.c,v 1.7 2014/10/29 10:47:46 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_com.c,v 1.8 2014/12/05 01:13:11 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -103,8 +103,13 @@
}
KASSERT(!strcmp(cf->cf_name, loc->loc_name));
+#if defined(ALLWINNER_A80)
+ KASSERT(loc->loc_offset >= AWIN_A80_UART0_OFFSET);
+ KASSERT(loc->loc_offset <= AWIN_A80_UART5_OFFSET);
+#else
KASSERT(loc->loc_offset >= AWIN_UART0_OFFSET);
KASSERT(loc->loc_offset <= AWIN_UART7_OFFSET);
+#endif
KASSERT((loc->loc_offset & 0x3ff) == 0);
KASSERT((awin_com_ports & __BIT(loc->loc_port)) == 0);
KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/arm/allwinner/awin_intr.h
--- a/sys/arch/arm/allwinner/awin_intr.h Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_intr.h Fri Dec 05 01:13:11 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_intr.h,v 1.10 2014/12/04 11:16:38 jmcneill Exp $ */
+/* $NetBSD: awin_intr.h,v 1.11 2014/12/05 01:13:11 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -31,8 +31,15 @@
#ifndef _ARM_ALLWINNER_AWIN_INTR_H_
#define _ARM_ALLWINNER_AWIN_INTR_H_
+#include "opt_allwinner.h"
+
+#if defined(ALLWINNER_A80)
+#define PIC_MAXSOURCES 224
+#define PIC_MAXMAXSOURCES 256
+#else
#define PIC_MAXSOURCES 160
#define PIC_MAXMAXSOURCES 192
+#endif
/*
* The Allwinner can use a generic interrupt controller so pull in that stuff.
@@ -164,4 +171,19 @@
#define AWIN_A31_IRQ_MP 115
#define AWIN_A31_IRQ_HDMI 120
+/*
+ * A80
+ */
+#define AWIN_A80_IRQ_UART0 32
+#define AWIN_A80_IRQ_UART1 33
+#define AWIN_A80_IRQ_UART2 34
+#define AWIN_A80_IRQ_UART3 35
+#define AWIN_A80_IRQ_UART4 36
+#define AWIN_A80_IRQ_UART5 37
+#define AWIN_A80_IRQ_TWI0 38
+#define AWIN_A80_IRQ_TWI1 39
+#define AWIN_A80_IRQ_TWI2 40
+#define AWIN_A80_IRQ_TWI3 41
+#define AWIN_A80_IRQ_TWI4 42
+
#endif /* _ARM_ALLWINNER_AWIN_INTR_H_ */
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/arm/allwinner/awin_io.c
--- a/sys/arch/arm/allwinner/awin_io.c Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_io.c Fri Dec 05 01:13:11 2014 +0000
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.29 2014/12/04 11:16:38 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.30 2014/12/05 01:13:11 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -89,12 +89,13 @@
#define A10 AWINIO_ONLY_A10
#define A20 AWINIO_ONLY_A20
#define A31 AWINIO_ONLY_A31
+#define A80 AWINIO_ONLY_A80
#define REQ AWINIO_REQUIRED
static const struct awin_locators awin_locators[] = {
{ "awinicu", OFFANDSIZE(INTC), NOPORT, NOINTR, A10|REQ },
{ "awingpio", OFFANDSIZE(PIO), NOPORT, NOINTR, AANY|REQ },
- { "awindma", OFFANDSIZE(DMA), NOPORT, AWIN_IRQ_DMA, A10|A20|REQ },
+ { "awindma", OFFANDSIZE(DMA), NOPORT, AWIN_IRQ_DMA, A10|A20 },
{ "awindma", OFFANDSIZE(DMA), NOPORT, AWIN_A31_IRQ_DMA, A31 },
{ "awintmr", OFFANDSIZE(TMR), NOPORT, AWIN_IRQ_TMR0, A10 },
{ "awincnt", OFFANDSIZE(CPUCFG), NOPORT, NOINTR, A20 },
@@ -108,14 +109,15 @@
{ "com", OFFANDSIZE(UART6), 6, AWIN_IRQ_UART6, A10|A20 },
{ "com", OFFANDSIZE(UART7), 7, AWIN_IRQ_UART7, A10|A20 },
{ "com", OFFANDSIZE(UART0), 0, AWIN_A31_IRQ_UART0, A31 },
+ { "com", OFFANDSIZE(A80_UART0), 0, AWIN_A80_IRQ_UART0, A80 },
{ "awinmp", OFFANDSIZE(MP), NOPORT, AWIN_A31_IRQ_MP, A31 },
- { "awindebe", AWIN_DE_BE0_OFFSET, 0x1000, 0, NOINTR, AANY },
- { "awindebe", AWIN_DE_BE1_OFFSET, 0x1000, 1, NOINTR, AANY },
- { "awintcon", OFFANDSIZE(LCD0), 0, NOINTR, AANY },
- { "awintcon", OFFANDSIZE(LCD1), 1, NOINTR, AANY },
+ { "awindebe", AWIN_DE_BE0_OFFSET, 0x1000, 0, NOINTR, A20|A31 },
+ { "awindebe", AWIN_DE_BE1_OFFSET, 0x1000, 1, NOINTR, A20|A31 },
+ { "awintcon", OFFANDSIZE(LCD0), 0, NOINTR, A20|A31 },
+ { "awintcon", OFFANDSIZE(LCD1), 1, NOINTR, A20|A31 },
{ "awinhdmi", OFFANDSIZE(HDMI), NOPORT, AWIN_IRQ_HDMI0, A20 },
{ "awinhdmi", OFFANDSIZE(HDMI), NOPORT, AWIN_A31_IRQ_HDMI, A31 },
- { "awinwdt", OFFANDSIZE(TMR), NOPORT, NOINTR, AANY },
+ { "awinwdt", OFFANDSIZE(TMR), NOPORT, NOINTR, A10|A20|A31 },
{ "awinrtc", OFFANDSIZE(TMR), NOPORT, NOINTR, A10|A20 },
{ "awinrtc", OFFANDSIZE(A31_RTC), NOPORT, NOINTR, A31 },
{ "awinusb", OFFANDSIZE(USB1), 0, NOINTR, A10|A20 },
@@ -185,6 +187,7 @@
const bool a10_p = chip_id == AWIN_CHIP_ID_A10;
const bool a20_p = chip_id == AWIN_CHIP_ID_A20;
const bool a31_p = chip_id == AWIN_CHIP_ID_A31;
+ const bool a80_p = chip_id == AWIN_CHIP_ID_A80;
prop_dictionary_t dict = device_properties(self);
sc->sc_dev = self;
@@ -223,6 +226,8 @@
continue;
if (a31_p && !(loc->loc_flags & AWINIO_ONLY_A31))
continue;
+ if (a80_p && !(loc->loc_flags & AWINIO_ONLY_A80))
+ continue;
}
struct awinio_attach_args aio = {
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/arm/allwinner/awin_reg.h
--- a/sys/arch/arm/allwinner/awin_reg.h Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_reg.h Fri Dec 05 01:13:11 2014 +0000
@@ -52,7 +52,11 @@
#define AWIN_SRAMB_SIZE 0x00010000 /* Secure */
#define AWIN_CORE_PBASE 0x01C00000
+#if defined(ALLWINNER_A80)
+#define AWIN_CORE_SIZE 0x06400000 /* XXX */
+#else
#define AWIN_CORE_SIZE 0x00400000
+#endif
#define AWIN_SRAM_OFFSET 0x00000000
#define AWIN_DRAM_OFFSET 0x00001000
#define AWIN_DMA_OFFSET 0x00002000
@@ -2645,4 +2649,39 @@
#define AWIN_A31_PIO_PM_PINS 8
+/*
+ * A80 registers
+ */
+#define AWIN_A80_GIC_BASE 0x01c40000
+
+#define AWIN_A80_CCU_OFFSET 0x04400000
+#define AWIN_A80_CCU_SCLK_OFFSET 0x04400400
+#define AWIN_A80_PIO_OFFSET 0x04400800
+#define AWIN_A80_TIMER_OFFSET 0x04400c00
+#define AWIN_A80_PWM_OFFSET 0x04401400
+#define AWIN_A80_KEYADC_OFFSET 0x04401800
+#define AWIN_A80_SMTA_OFFSET 0x04403400
+#define AWIN_A80_GPADC_OFFSET 0x04404c00
+
+#define AWIN_A80_UART0_OFFSET 0x05400000
+#define AWIN_A80_UART1_OFFSET 0x05400400
+#define AWIN_A80_UART2_OFFSET 0x05400800
+#define AWIN_A80_UART3_OFFSET 0x05400c00
+#define AWIN_A80_UART4_OFFSET 0x05401000
+#define AWIN_A80_UART5_OFFSET 0x05401400
+#define AWIN_A80_TWI0_OFFSET 0x05402800
+#define AWIN_A80_TWI1_OFFSET 0x05402c00
+#define AWIN_A80_TWI2_OFFSET 0x05403000
+#define AWIN_A80_TWI3_OFFSET 0x05403400
+#define AWIN_A80_TWI4_OFFSET 0x05403800
+
+#define AWIN_A80_CCU_PLL_C0CPUX_CTRL_REG 0x0000
+#define AWIN_A80_CCU_PLL_C1CPUX_CTRL_REG 0x0000
+
+#define AWIN_A80_CCU_PLL_ENABLE __BIT(31)
+#define AWIN_A80_CCU_PLL_LOCK_TIME __BITS(26,24)
+#define AWIN_A80_CCU_PLL_OUT_EXT_DIVP __BIT(16)
+#define AWIN_A80_CCU_PLL_FACTOR_N __BITS(15,8)
+#define AWIN_A80_CCU_PLL_POSTDIV_M __BITS(1,0)
+
#endif /* _ARM_ALLWINNER_AWIN_REG_H_ */
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/arm/allwinner/awin_var.h
--- a/sys/arch/arm/allwinner/awin_var.h Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_var.h Fri Dec 05 01:13:11 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.27 2014/12/04 11:16:38 jmcneill Exp $ */
+/* $NetBSD: awin_var.h,v 1.28 2014/12/05 01:13:11 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -47,6 +47,7 @@
int loc_flags;
#define AWINIO_REQUIRED __BIT(8)
#define AWINIO_ONLY __BITS(7,0)
+#define AWINIO_ONLY_A80 __BIT(3)
#define AWINIO_ONLY_A31 __BIT(2)
#define AWINIO_ONLY_A20 __BIT(1)
#define AWINIO_ONLY_A10 __BIT(0)
@@ -109,6 +110,7 @@
#define AWIN_CHIP_ID_A31 AWIN_SRAM_VER_KEY_A31
#define AWIN_CHIP_ID_A23 AWIN_SRAM_VER_KEY_A23
#define AWIN_CHIP_ID_A20 AWIN_SRAM_VER_KEY_A20
+#define AWIN_CHIP_ID_A80 0xff80 /* fake; no chip ID register */
uint16_t awin_chip_id(void);
const char *awin_chip_name(void);
diff -r 10977f965c6a -r 68dd90c255d8 sys/arch/evbarm/awin/awin_machdep.c
--- a/sys/arch/evbarm/awin/awin_machdep.c Fri Dec 05 01:11:25 2014 +0000
+++ b/sys/arch/evbarm/awin/awin_machdep.c Fri Dec 05 01:13:11 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_machdep.c,v 1.29 2014/11/17 00:50:40 jmcneill Exp $ */
+/* $NetBSD: awin_machdep.c,v 1.30 2014/12/05 01:13:11 jmcneill Exp $ */
/*
* Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.29 2014/11/17 00:50:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.30 2014/12/05 01:13:11 jmcneill Exp $");
Home |
Main Index |
Thread Index |
Old Index