2 * Copyright (c) 2016, Hiroki Mori
3 * Copyright (c) 2010 Adrian Chadd
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
32 #include "opt_ar531x.h"
34 #include <sys/param.h>
36 #include <sys/kernel.h>
37 #include <sys/systm.h>
41 #include <sys/reboot.h>
44 #include <vm/vm_page.h>
46 #include <net/ethernet.h>
48 #include <machine/clock.h>
49 #include <machine/cpu.h>
50 #include <machine/cpuregs.h>
51 #include <machine/hwfunc.h>
52 #include <machine/md_var.h>
53 #include <machine/trap.h>
54 #include <machine/vmparam.h>
56 #include <mips/atheros/ar531x/ar5315reg.h>
57 #include <mips/atheros/ar531x/ar5312reg.h>
58 #include <mips/atheros/ar531x/ar5315_setup.h>
60 #include <mips/atheros/ar531x/ar5315_cpudef.h>
62 #include <mips/atheros/ar531x/ar5315_chip.h>
63 #include <mips/atheros/ar531x/ar5312_chip.h>
64 #include <mips/atheros/ar724x_chip.h>
65 #include <mips/atheros/ar91xx_chip.h>
67 #include <dev/ath/ath_hal/ah_soc.h>
69 #define AR5315_SYS_TYPE_LEN 128
71 static char ar5315_sys_type[AR5315_SYS_TYPE_LEN];
72 enum ar531x_soc_type ar531x_soc;
73 struct ar5315_cpu_def * ar5315_cpu_ops = NULL;
76 ar5315_detect_sys_type(void)
82 const uint8_t *ptr, *end;
83 static const struct ar531x_boarddata *board = NULL;
85 ptr = (const uint8_t *) MIPS_PHYS_TO_KSEG1(AR5315_CONFIG_END
88 end = (const uint8_t *)AR5315_CONFIG_BASE;
90 for (; ptr > end; ptr -= 0x1000) {
91 if (*(const uint32_t *)ptr == AR531X_BD_MAGIC) {
92 board = (const struct ar531x_boarddata *) ptr;
100 #ifdef AR531X_1ST_GENERATION
101 soctype = AR_FIRST_GEN;
103 soctype = AR_SECOND_GEN;
106 if(soctype == AR_SECOND_GEN) {
107 ar5315_cpu_ops = &ar5315_chip_def;
109 ver = ATH_READ_REG(AR5315_SYSREG_BASE +
114 ar531x_soc = AR531X_SOC_AR5315;
118 ar531x_soc = AR531X_SOC_AR5316;
122 ar531x_soc = AR531X_SOC_AR5317;
126 ar531x_soc = AR531X_SOC_AR5318;
131 ar5315_cpu_ops = &ar5312_chip_def;
133 ver = ATH_READ_REG(AR5312_SYSREG_BASE +
134 AR5312_SYSREG_REVISION);
135 rev = AR5312_REVISION_MINOR(ver);
137 switch (AR5312_REVISION_MAJOR(ver)) {
138 case AR5312_REVISION_MAJ_AR5311:
139 ar531x_soc = AR531X_SOC_AR5311;
142 case AR5312_REVISION_MAJ_AR5312:
143 ar531x_soc = AR531X_SOC_AR5312;
146 case AR5312_REVISION_MAJ_AR2313:
147 ar531x_soc = AR531X_SOC_AR5313;
153 sprintf(ar5315_sys_type, "Atheros AR%s rev %u", chip, rev);
157 ar5315_get_system_type(void)
159 return ar5315_sys_type;