aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/patches-4.14/0026-MIPS-ath79-export-switch-MDIO-reference-clock.patch
blob: 27adb56f560c3bb095540a2e480d233a02031ce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 78538d673801902108797f2c813e70cfbce280c9 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Tue, 6 Mar 2018 13:27:28 +0100
Subject: [PATCH 26/33] MIPS: ath79: export switch MDIO reference clock

On AR934x, the MDIO reference clock can be configured to a fixed 100 MHz
clock. If that feature is not used, it defaults to the main reference
clock, like on all other SoC.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: John Crispin <john@phrozen.org>
---
 arch/mips/ath79/clock.c               | 8 ++++++++
 include/dt-bindings/clock/ath79-clk.h | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

--- a/arch/mips/ath79/clock.c
+++ b/arch/mips/ath79/clock.c
@@ -42,6 +42,7 @@ static const char * const clk_names[ATH7
 	[ATH79_CLK_DDR] = "ddr",
 	[ATH79_CLK_AHB] = "ahb",
 	[ATH79_CLK_REF] = "ref",
+	[ATH79_CLK_MDIO] = "mdio",
 };
 
 static const char * __init ath79_clk_name(int type)
@@ -342,6 +343,10 @@ static void __init ar934x_clocks_init(vo
 	ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
 	ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
 
+	clk_ctrl = __raw_readl(pll_base + AR934X_PLL_SWITCH_CLOCK_CONTROL_REG);
+	if (clk_ctrl & AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL)
+		ath79_set_clk(ATH79_CLK_MDIO, 100 * 1000 * 1000);
+
 	iounmap(dpll_base);
 }
 
@@ -698,6 +703,9 @@ static void __init ath79_clocks_init_dt(
 	else if (of_device_is_compatible(np, "qca,qca9560-pll"))
 		qca956x_clocks_init(pll_base);
 
+	if (!clks[ATH79_CLK_MDIO])
+		clks[ATH79_CLK_MDIO] = clks[ATH79_CLK_REF];
+
 	if (of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data)) {
 		pr_err("%pOF: could not register clk provider\n", np);
 		goto err_iounmap;
--- a/include/dt-bindings/clock/ath79-clk.h
+++ b/include/dt-bindings/clock/ath79-clk.h
@@ -14,7 +14,8 @@
 #define ATH79_CLK_DDR		1
 #define ATH79_CLK_AHB		2
 #define ATH79_CLK_REF		3
+#define ATH79_CLK_MDIO		4
 
-#define ATH79_CLK_END		4
+#define ATH79_CLK_END		5
 
 #endif /* __DT_BINDINGS_ATH79_CLK_H */
p">include $(INCLUDE_DIR)/unpack.mk include $(INCLUDE_DIR)/depends.mk BUILD_TYPES += host HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),))) HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed override MAKEFLAGS= include $(INCLUDE_DIR)/download.mk include $(INCLUDE_DIR)/quilt.mk Host/Patch:=$(Host/Patch/Default) ifneq ($(strip $(HOST_UNPACK)),) define Host/Prepare/Default $(HOST_UNPACK) $(Host/Patch) endef endif define Host/Prepare $(call Host/Prepare/Default) endef HOST_CONFIGURE_VARS = \ CPPFLAGS="$(HOST_CFLAGS)" \ LDFLAGS="$(HOST_LDFLAGS)" \ SHELL="$(BASH)" HOST_CONFIGURE_ARGS = \ --target=$(GNU_HOST_NAME) \ --host=$(GNU_HOST_NAME) \ --build=$(GNU_HOST_NAME) \ --program-prefix="" \ --program-suffix="" \ --prefix=$(STAGING_DIR_HOST) \ --exec-prefix=$(STAGING_DIR_HOST) \ --sysconfdir=$(STAGING_DIR_HOST)/etc \ --localstatedir=$(STAGING_DIR_HOST)/var HOST_CONFIGURE_CMD = ./configure define Host/Configure/Default @(cd $(HOST_BUILD_DIR)/$(3); \ if [ -x configure ]; then \ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \ $(2) \ $(HOST_CONFIGURE_CMD) \ $(HOST_CONFIGURE_VARS) \ $(HOST_CONFIGURE_ARGS) \ $(1); \ fi \ ) endef define Host/Configure $(call Host/Configure/Default) endef define Host/Compile/Default $(MAKE) -C $(HOST_BUILD_DIR) $(1) endef define Host/Compile $(call Host/Compile/Default) endef define Host/Install/Default $(MAKE) -C $(HOST_BUILD_DIR) install endef define Host/Install $(call Host/Install/Default) endef ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),) define HostHost/Autoclean $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(HOST_STAMP_PREPARED)) $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT))) endef endif define Download/default FILE:=$(PKG_SOURCE) URL:=$(PKG_SOURCE_URL) PROTO:=$(PKG_SOURCE_PROTO) SUBDIR:=$(PKG_SOURCE_SUBDIR) VERSION:=$(PKG_SOURCE_VERSION) MD5SUM:=$(PKG_MD5SUM) endef ifndef DUMP define HostBuild $(if $(HOST_QUILT),$(Host/Quilt)) $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) $(if $(DUMP),,$(call HostHost/Autoclean)) $(HOST_STAMP_PREPARED): @-rm -rf $(HOST_BUILD_DIR) @mkdir -p $(HOST_BUILD_DIR) $(call Host/Prepare) touch $$@ $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED) $(call Host/Configure) touch $$@ $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED) $(call Host/Compile) touch $$@ $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(call Host/Install) mkdir -p $$(shell dirname $$@) touch $$@ ifdef Host/Install host-install: $(HOST_STAMP_INSTALLED) endif ifndef STAMP_BUILT prepare: host-prepare compile: host-compile install: host-install clean: host-clean update: host-update else host-compile: $(HOST_STAMP_INSTALLED) endif host-prepare: $(HOST_STAMP_PREPARED) host-configure: $(HOST_STAMP_CONFIGURED) host-compile: $(HOST_STAMP_BUILT) host-install: host-clean: FORCE $(call Host/Clean) $(call Host/Uninstall) rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT) endef download: prepare: compile: install: clean: endif