Date: Mon, 18 Apr 2016 06:15:58 +0000 (UTC) From: Stanislav Galabov <sgalabov@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298185 - head/sys/mips/mediatek Message-ID: <201604180615.u3I6Fw19037068@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sgalabov Date: Mon Apr 18 06:15:58 2016 New Revision: 298185 URL: https://svnweb.freebsd.org/changeset/base/298185 Log: Allow RT3350 CPU clock to be detected as part of RT3050/RT3052 detection OpenWRT's dts files treat RT3050/RT3052/RT3350 within the same SoC dtsi file, so we need to distinguish between the three dynamically, mainly because the bit we use to determine the clock speed on RT3050/RT3052 can actually be floating on RT3350 and RT3350 is always at 320MHz. Approved by: adrian (mentor) Sponsored by: Smartcom - Bulgaria AD Differential Revision: https://reviews.freebsd.org/D5983 Modified: head/sys/mips/mediatek/mtk_soc.c head/sys/mips/mediatek/mtk_sysctl.h Modified: head/sys/mips/mediatek/mtk_soc.c ============================================================================== --- head/sys/mips/mediatek/mtk_soc.c Mon Apr 18 06:12:00 2016 (r298184) +++ head/sys/mips/mediatek/mtk_soc.c Mon Apr 18 06:15:58 2016 (r298185) @@ -76,13 +76,17 @@ static const struct ofw_compat_data comp static uint32_t mtk_detect_cpuclk_rt305x(bus_space_tag_t bst, bus_space_handle_t bsh) { - uint32_t clk; + uint32_t val; + + val = bus_space_read_4(bst, bsh, SYSCTL_CHIPID0_3); + if (val == RT3350_CHIPID0_3) + return (MTK_CPU_CLK_320MHZ); - clk = bus_space_read_4(bst, bsh, SYSCTL_SYSCFG); - clk >>= RT305X_CPU_CLKSEL_OFF; - clk &= RT305X_CPU_CLKSEL_MSK; + val = bus_space_read_4(bst, bsh, SYSCTL_SYSCFG); + val >>= RT305X_CPU_CLKSEL_OFF; + val &= RT305X_CPU_CLKSEL_MSK; - return ((clk == 0) ? MTK_CPU_CLK_320MHZ : MTK_CPU_CLK_384MHZ); + return ((val == 0) ? MTK_CPU_CLK_320MHZ : MTK_CPU_CLK_384MHZ); } static uint32_t @@ -265,10 +269,8 @@ mtk_soc_try_early_detect(void) switch (mtk_soc_socid) { case MTK_SOC_RT3050: /* fallthrough */ case MTK_SOC_RT3052: - mtk_soc_cpuclk = mtk_detect_cpuclk_rt305x(bst, bsh); - break; case MTK_SOC_RT3350: - mtk_soc_cpuclk = MTK_CPU_CLK_320MHZ; + mtk_soc_cpuclk = mtk_detect_cpuclk_rt305x(bst, bsh); break; case MTK_SOC_RT3352: mtk_soc_cpuclk = mtk_detect_cpuclk_rt3352(bst, bsh); Modified: head/sys/mips/mediatek/mtk_sysctl.h ============================================================================== --- head/sys/mips/mediatek/mtk_sysctl.h Mon Apr 18 06:12:00 2016 (r298184) +++ head/sys/mips/mediatek/mtk_sysctl.h Mon Apr 18 06:15:58 2016 (r298185) @@ -52,6 +52,8 @@ #define SYSCFG1_USB_HOST_MODE (1<<10) +#define RT3350_CHIPID0_3 0x33335452 + extern uint32_t mtk_sysctl_get(uint32_t); extern void mtk_sysctl_set(uint32_t, uint32_t); extern void mtk_sysctl_clr_set(uint32_t, uint32_t, uint32_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604180615.u3I6Fw19037068>