Deleted Added
full compact
mtk_soc.c (298059) mtk_soc.c (298185)
1/*-
2 * Copyright (c) 2016 Stanislav Galabov.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2016 Stanislav Galabov.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/mips/mediatek/mtk_soc.c 298059 2016-04-15 15:24:42Z sgalabov $");
28__FBSDID("$FreeBSD: head/sys/mips/mediatek/mtk_soc.c 298185 2016-04-18 06:15:58Z sgalabov $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/module.h>
35#include <sys/rman.h>
36

--- 34 unchanged lines hidden (view full) ---

71
72 /* Sentinel */
73 { NULL, MTK_SOC_UNKNOWN },
74};
75
76static uint32_t
77mtk_detect_cpuclk_rt305x(bus_space_tag_t bst, bus_space_handle_t bsh)
78{
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/module.h>
35#include <sys/rman.h>
36

--- 34 unchanged lines hidden (view full) ---

71
72 /* Sentinel */
73 { NULL, MTK_SOC_UNKNOWN },
74};
75
76static uint32_t
77mtk_detect_cpuclk_rt305x(bus_space_tag_t bst, bus_space_handle_t bsh)
78{
79 uint32_t clk;
79 uint32_t val;
80
80
81 clk = bus_space_read_4(bst, bsh, SYSCTL_SYSCFG);
82 clk >>= RT305X_CPU_CLKSEL_OFF;
83 clk &= RT305X_CPU_CLKSEL_MSK;
81 val = bus_space_read_4(bst, bsh, SYSCTL_CHIPID0_3);
82 if (val == RT3350_CHIPID0_3)
83 return (MTK_CPU_CLK_320MHZ);
84
84
85 return ((clk == 0) ? MTK_CPU_CLK_320MHZ : MTK_CPU_CLK_384MHZ);
85 val = bus_space_read_4(bst, bsh, SYSCTL_SYSCFG);
86 val >>= RT305X_CPU_CLKSEL_OFF;
87 val &= RT305X_CPU_CLKSEL_MSK;
88
89 return ((val == 0) ? MTK_CPU_CLK_320MHZ : MTK_CPU_CLK_384MHZ);
86}
87
88static uint32_t
89mtk_detect_cpuclk_rt3352(bus_space_tag_t bst, bus_space_handle_t bsh)
90{
91 uint32_t val;
92
93 val = bus_space_read_4(bst, bsh, SYSCTL_SYSCFG);

--- 166 unchanged lines hidden (view full) ---

260
261 if (bus_space_map(bst, base, MTK_DEFAULT_SIZE, 0, &bsh))
262 return;
263
264 /* First, figure out the CPU clock */
265 switch (mtk_soc_socid) {
266 case MTK_SOC_RT3050: /* fallthrough */
267 case MTK_SOC_RT3052:
90}
91
92static uint32_t
93mtk_detect_cpuclk_rt3352(bus_space_tag_t bst, bus_space_handle_t bsh)
94{
95 uint32_t val;
96
97 val = bus_space_read_4(bst, bsh, SYSCTL_SYSCFG);

--- 166 unchanged lines hidden (view full) ---

264
265 if (bus_space_map(bst, base, MTK_DEFAULT_SIZE, 0, &bsh))
266 return;
267
268 /* First, figure out the CPU clock */
269 switch (mtk_soc_socid) {
270 case MTK_SOC_RT3050: /* fallthrough */
271 case MTK_SOC_RT3052:
272 case MTK_SOC_RT3350:
268 mtk_soc_cpuclk = mtk_detect_cpuclk_rt305x(bst, bsh);
269 break;
273 mtk_soc_cpuclk = mtk_detect_cpuclk_rt305x(bst, bsh);
274 break;
270 case MTK_SOC_RT3350:
271 mtk_soc_cpuclk = MTK_CPU_CLK_320MHZ;
272 break;
273 case MTK_SOC_RT3352:
274 mtk_soc_cpuclk = mtk_detect_cpuclk_rt3352(bst, bsh);
275 break;
276 case MTK_SOC_RT3662: /* fallthrough */
277 case MTK_SOC_RT3883:
278 mtk_soc_cpuclk = mtk_detect_cpuclk_rt3883(bst, bsh);
279 break;
280 case MTK_SOC_RT5350:

--- 159 unchanged lines hidden ---
275 case MTK_SOC_RT3352:
276 mtk_soc_cpuclk = mtk_detect_cpuclk_rt3352(bst, bsh);
277 break;
278 case MTK_SOC_RT3662: /* fallthrough */
279 case MTK_SOC_RT3883:
280 mtk_soc_cpuclk = mtk_detect_cpuclk_rt3883(bst, bsh);
281 break;
282 case MTK_SOC_RT5350:

--- 159 unchanged lines hidden ---