Skip to contentSkip to conversation

clk: aspeed: Add 24MHz fixed clock

PATCH In review Lei YU 2 participants 3 messages May 9, 2018 – May 18, 2018

Subsystems (3)
lore
Share & tools
lore

Lei YU

author
#0 lore raw

PATCH 1/2 clk: aspeed: Add 24MHz fixed clock

Add a 24MHz fixed clock.
This clock will be used for certain devices, e.g. pwm.

---
 drivers/clk/clk-aspeed.c                 | 8 +++++++-
 include/dt-bindings/clock/aspeed-clock.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/clk/clk-aspeed.c +7 -1
index c5d2af2..2ea1ec1 100644
@@ -23,7 +23,7 @@
 
 #include <dt-bindings/clock/aspeed-clock.h>
 
-#define ASPEED_NUM_CLKS		35
+#define ASPEED_NUM_CLKS		36
 
 #define ASPEED_RESET2_OFFSET	32
 
@@ -517,6 +517,12 @@ static int aspeed_clk_probe(struct platform_device *pdev)
 		return PTR_ERR(hw);
 	aspeed_clk_data->hws[ASPEED_CLK_BCLK] = hw;
 
+	/* Fixed 24MHz clock */
+	hw = clk_hw_register_fixed_rate(NULL, "fixed-24m", NULL, 0, 24000000);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+	aspeed_clk_data->hws[ASPEED_CLK_24M] = hw;
+
 	/*
 	 * TODO: There are a number of clocks that not included in this driver
 	 * as more information is required:
include/dt-bindings/clock/aspeed-clock.h +1 -0
index e983d17..9733c77 100644
@@ -37,6 +37,7 @@
 #define ASPEED_CLK_MAC			32
 #define ASPEED_CLK_BCLK			33
 #define ASPEED_CLK_MPLL			34
+#define ASPEED_CLK_24M			35
 
 #define ASPEED_RESET_XDMA		0
 #define ASPEED_RESET_MCTP		1
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 ARM: dts: aspeed: Use 24MHz fixed clock for pwm

The aspeed pwm driver always sets the clock source to 24MHz, specify the fixed clock in device tree to make sure the driver is using the correct clock frequency to calculate the fan speed.

---
 arch/arm/boot/dts/aspeed-g4.dtsi | 2 +-
 arch/arm/boot/dts/aspeed-g5.dtsi | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/aspeed-g4.dtsi +1 -1
index 50bc661..9354ac9 100644
@@ -201,7 +201,7 @@
 				#address-cells = <1>;
 				#size-cells = <0>;
 				reg = <0x1e786000 0x1000>;
-				clocks = <&syscon ASPEED_CLK_APB>;
+				clocks = <&syscon ASPEED_CLK_24M>;
 				resets = <&syscon ASPEED_RESET_PWM>;
 				status = "disabled";
 			};
arch/arm/boot/dts/aspeed-g5.dtsi +1 -1
index e9e039a..0633162 100644
@@ -259,7 +259,7 @@
 				#address-cells = <1>;
 				#size-cells = <0>;
 				reg = <0x1e786000 0x1000>;
-				clocks = <&syscon ASPEED_CLK_APB>;
+				clocks = <&syscon ASPEED_CLK_24M>;
 				resets = <&syscon ASPEED_RESET_PWM>;
 				status = "disabled";
 			};
Signature · 1 line
2.7.4
maintainer
#2 lore raw
In reply to Lei YU
Quoted 23 lines · Lei YU

Add a 24MHz fixed clock.
This clock will be used for certain devices, e.g. pwm.

---
 drivers/clk/clk-aspeed.c                 | 8 +++++++-
 include/dt-bindings/clock/aspeed-clock.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/clk/clk-aspeed.c +1 -1
index c5d2af2..2ea1ec1 100644
@@ -23,7 +23,7 @@
 
 #include <dt-bindings/clock/aspeed-clock.h>
 
-#define ASPEED_NUM_CLKS                35
+#define ASPEED_NUM_CLKS                36
 
 #define ASPEED_RESET2_OFFSET   32
 

drivers/clk/clk-aspeed.c static int aspeed_clk_probe(struct platform_device *pdev) · line 521

Quoted 5 lines
drivers/clk/clk-aspeed.c +2 -0
@@ -517,6 +517,12 @@ static int aspeed_clk_probe(struct platform_device *pdev)
                return PTR_ERR(hw);
        aspeed_clk_data->hws[ASPEED_CLK_BCLK] = hw;
 
+       /* Fixed 24MHz clock */
+       hw = clk_hw_register_fixed_rate(NULL, "fixed-24m", NULL, 0, 24000000);

Ryan had this to say:

drivers/clk/clk-aspeed.c static int aspeed_clk_probe(struct platform_device *pdev) · line 522

Quoted 1 line
drivers/clk/clk-aspeed.c +0 -0
 it comes from external osc is soc input clock source.

So we should set the parent to be "clkin".

Please add that and send upstream. I'll have this with the fix to dev-4.13.

Cheers,

Joel

Quoted 22 lines
drivers/clk/clk-aspeed.c +4 -0
+       if (IS_ERR(hw))
+               return PTR_ERR(hw);
+       aspeed_clk_data->hws[ASPEED_CLK_24M] = hw;
+
        /*
         * TODO: There are a number of clocks that not included in this driver

* as more information is required:

include/dt-bindings/clock/aspeed-clock.h +1 -1
index e983d17..9733c77 100644
@@ -37,6 +37,7 @@
 #define ASPEED_CLK_MAC                 32
 #define ASPEED_CLK_BCLK                        33
 #define ASPEED_CLK_MPLL                        34
+#define ASPEED_CLK_24M                 35
 
 #define ASPEED_RESET_XDMA              0
 #define ASPEED_RESET_MCTP              1
--

2.7.4