Skip to contentSkip to conversation

LPC fixes

PATCH Superseded Joel Stanley 3 participants 10 messages Feb 8, 2018 – Feb 9, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joel Stanley

author maintainer
#0 lore raw

cover LPC fixes

These patches were developed when bringing up dev-4.13 on Romulus. We need to ensure the LPC clock is enabled, now that the clock driver turns off any unused clocks. We also need to enable the LPC firmware cycles bit as we no longer have the aspeed.c hack.

Joel Stanley (3):
ARM: dts: aspeed: Add LPC clock phandles
misc: aspeed-lpc: Enable clock
soc: aspeed-lpc-ctrl: Enable FWH cycles

 arch/arm/boot/dts/aspeed-g4.dtsi |  1 +
 arch/arm/boot/dts/aspeed-g5.dtsi |  1 +
 drivers/misc/aspeed-lpc-ctrl.c   | 31 +++++++++++++++++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)
Signature · 1 line
2.15.1
author maintainer
#1 lore raw

PATCH 1/3 ARM: dts: aspeed: Add LPC clock phandles

The LPC device uses LCLK.

---
 arch/arm/boot/dts/aspeed-g4.dtsi | 1 +
 arch/arm/boot/dts/aspeed-g5.dtsi | 1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/aspeed-g4.dtsi +1 -0
index 1fb5b410917a..d697380f2f39 100644
@@ -233,6 +233,7 @@
 					lpc_ctrl: lpc-ctrl@0 {
 						compatible = "aspeed,ast2400-lpc-ctrl";
 						reg = <0x0 0x80>;
+						clocks = <&syscon ASPEED_CLK_GATE_LCLK>;
 						status = "disabled";
 					};
 
arch/arm/boot/dts/aspeed-g5.dtsi +1 -0
index 77d6d98d24a0..89ef960c4ef3 100644
@@ -283,6 +283,7 @@
 					lpc_ctrl: lpc-ctrl@0 {
 						compatible = "aspeed,ast2500-lpc-ctrl";
 						reg = <0x0 0x80>;
+						clocks = <&syscon ASPEED_CLK_GATE_LCLK>;
 						status = "disabled";
 					};
 
Signature · 1 line
2.15.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH linux dev-4.13 1/3] ARM: dts: aspeed: Add LPC clock phandles

Quoted 3 lines · Joel Stanley

The LPC device uses LCLK.

Obviously we need to modify the bindings docs and send it all upstream (and deal with the "You're breaking the bindings" / "They were always broken" fallout).

Quoted 29 lines
---
 arch/arm/boot/dts/aspeed-g4.dtsi | 1 +
 arch/arm/boot/dts/aspeed-g5.dtsi | 1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/aspeed-g4.dtsi +1 -0
index 1fb5b410917a..d697380f2f39 100644
@@ -233,6 +233,7 @@
 					lpc_ctrl: lpc-ctrl@0 {
 						compatible = "aspeed,ast2400-lpc-ctrl";
 						reg = <0x0 0x80>;
+						clocks = <&syscon ASPEED_CLK_GATE_LCLK>;
 						status = "disabled";
 					};
 
arch/arm/boot/dts/aspeed-g5.dtsi +1 -0
index 77d6d98d24a0..89ef960c4ef3 100644
@@ -283,6 +283,7 @@
 					lpc_ctrl: lpc-ctrl@0 {
 						compatible = "aspeed,ast2500-lpc-ctrl";
 						reg = <0x0 0x80>;
+						clocks = <&syscon ASPEED_CLK_GATE_LCLK>;
 						status = "disabled";
 					};
 
author maintainer
#3 lore raw

PATCH 2/3 misc: aspeed-lpc: Enable clock

In reply to Joel Stanley

The LPC device needs to ensure it's clock is enabled before it can do anything.

---
 drivers/misc/aspeed-lpc-ctrl.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/misc/aspeed-lpc-ctrl.c +14 -0
index b5439643f54b..4a818ad3827e 100644
@@ -7,6 +7,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/clk.h>
 #include <linux/mfd/syscon.h>
 #include <linux/miscdevice.h>
 #include <linux/mm.h>
@@ -26,6 +27,7 @@
 struct aspeed_lpc_ctrl {
 	struct miscdevice	miscdev;
 	struct regmap		*regmap;
+	struct clk		*clk;
 	phys_addr_t		mem_base;
 	resource_size_t		mem_size;
 	u32		pnor_size;
@@ -180,6 +182,17 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
 	if (!lpc_ctrl)
 		return -ENOMEM;
 
+	lpc_ctrl->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(lpc_ctrl->clk)) {
+		dev_err(dev, "couldn't get clock\n");
+		return PTR_ERR(lpc_ctrl->clk);
+	}
+	rc = clk_prepare_enable(lpc_ctrl->clk);
+	if (rc) {
+		dev_err(dev, "couldn't enable clock\n");
+		return rc;
+	}
+
 	node = of_parse_phandle(dev->of_node, "flash", 0);
 	if (!node) {
 		dev_err(dev, "Didn't find host pnor flash node\n");
@@ -239,6 +252,7 @@ static int aspeed_lpc_ctrl_remove(struct platform_device *pdev)
 	struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev);
 
 	misc_deregister(&lpc_ctrl->miscdev);
+	clk_disable_unprepare(lpc_ctrl->clk);
 
 	return 0;
 }
Signature · 1 line
2.15.1
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH linux dev-4.13 2/3] misc: aspeed-lpc: Enable clock

Quoted 4 lines · Joel Stanley

The LPC device needs to ensure it's clock is enabled before it can do anything.

Quoted 50 lines
---
 drivers/misc/aspeed-lpc-ctrl.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/misc/aspeed-lpc-ctrl.c +14 -0
index b5439643f54b..4a818ad3827e 100644
@@ -7,6 +7,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/clk.h>
 #include <linux/mfd/syscon.h>
 #include <linux/miscdevice.h>
 #include <linux/mm.h>
@@ -26,6 +27,7 @@
 struct aspeed_lpc_ctrl {
 	struct miscdevice	miscdev;
 	struct regmap		*regmap;
+	struct clk		*clk;
 	phys_addr_t		mem_base;
 	resource_size_t		mem_size;
 	u32		pnor_size;
@@ -180,6 +182,17 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
 	if (!lpc_ctrl)
 		return -ENOMEM;
 
+	lpc_ctrl->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(lpc_ctrl->clk)) {
+		dev_err(dev, "couldn't get clock\n");
+		return PTR_ERR(lpc_ctrl->clk);
+	}
+	rc = clk_prepare_enable(lpc_ctrl->clk);
+	if (rc) {
+		dev_err(dev, "couldn't enable clock\n");
+		return rc;
+	}
+
 	node = of_parse_phandle(dev->of_node, "flash", 0);
 	if (!node) {
 		dev_err(dev, "Didn't find host pnor flash node\n");
@@ -239,6 +252,7 @@ static int aspeed_lpc_ctrl_remove(struct platform_device *pdev)
 	struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev);
 
 	misc_deregister(&lpc_ctrl->miscdev);
+	clk_disable_unprepare(lpc_ctrl->clk);
 
 	return 0;
 }
author maintainer
#5 lore raw

PATCH 3/3 soc: aspeed-lpc-ctrl: Enable FWH cycles

In reply to Joel Stanley

To date this driver has relied on prevous BMC state in order to have the host be able to access data over the LPC bus.

Now we explicitly enable the FWH cycles from when the user first configures the address to map. We chose to do this then as before that time there is no way for the kernel to know where it is safe to point the LPC window.

---
 drivers/misc/aspeed-lpc-ctrl.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/misc/aspeed-lpc-ctrl.c +15 -2
index 4a818ad3827e..21b4ee9d0a38 100644
@@ -21,6 +21,10 @@
 
 #define DEVICE_NAME	"aspeed-lpc-ctrl"
 
+#define HICR5 0x0
+#define HICR5_ENL2H	BIT(8)
+#define HICR5_ENFWH	BIT(10)
+
 #define HICR7 0x8
 #define HICR8 0xc
 
@@ -155,8 +159,17 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,
 		if (rc)
 			return rc;
 
-		return regmap_write(lpc_ctrl->regmap, HICR8,
-			(~(map.size - 1)) | ((map.size >> 16) - 1));
+		rc = regmap_write(lpc_ctrl->regmap, HICR8,
+				(~(map.size - 1)) | ((map.size >> 16) - 1));
+		if (rc)
+			return rc;
+
+		/*
+		 * Enable LPC FHW cycles. This is required for the host to
+		 * access the regions specified.
+		 */
+		return regmap_update_bits(lpc_ctrl->regmap, HICR5,
+				HICR5_ENFWH, HICR5_ENFWH);
 	}
 
 	return -EINVAL;
Signature · 1 line
2.15.1
#6 lore raw

Re: [PATCH linux dev-4.13 3/3] soc: aspeed-lpc-ctrl: Enable FWH cycles

Quoted 18 lines · Joel Stanley

To date this driver has relied on prevous BMC state in order to have the host be able to access data over the LPC bus.

Now we explicitly enable the FWH cycles from when the user first configures the address to map. We chose to do this then as before that time there is no way for the kernel to know where it is safe to point the LPC window.

---
 drivers/misc/aspeed-lpc-ctrl.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/misc/aspeed-lpc-ctrl.c +0 -0
index 4a818ad3827e..21b4ee9d0a38 100644

drivers/misc/aspeed-lpc-ctrl.c line 25

Quoted 5 lines
drivers/misc/aspeed-lpc-ctrl.c +2 -0
@@ -21,6 +21,10 @@
 
 #define DEVICE_NAME	"aspeed-lpc-ctrl"
 
+#define HICR5 0x0
+#define HICR5_ENL2H	BIT(8)

Shouldn't we be setting this at the same time as HICR5_ENFWH below?

Quoted 25 lines
drivers/misc/aspeed-lpc-ctrl.c +13 -2
+#define HICR5_ENFWH	BIT(10)
+
 #define HICR7 0x8
 #define HICR8 0xc
 
@@ -155,8 +159,17 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,
 		if (rc)
 			return rc;
 
-		return regmap_write(lpc_ctrl->regmap, HICR8,
-			(~(map.size - 1)) | ((map.size >> 16) - 1));
+		rc = regmap_write(lpc_ctrl->regmap, HICR8,
+				(~(map.size - 1)) | ((map.size >> 16) - 1));
+		if (rc)
+			return rc;
+
+		/*
+		 * Enable LPC FHW cycles. This is required for the host to
+		 * access the regions specified.
+		 */
+		return regmap_update_bits(lpc_ctrl->regmap, HICR5,
+				HICR5_ENFWH, HICR5_ENFWH);
 	}
 
 	return -EINVAL;
author maintainer
#7 lore raw

Re: [PATCH linux dev-4.13 3/3] soc: aspeed-lpc-ctrl: Enable FWH cycles

Quoted 6 lines · Andrew Jeffery

drivers/misc/aspeed-lpc-ctrl.c line 25

Quoted 3 lines · Joel Stanley
drivers/misc/aspeed-lpc-ctrl.c +2 -0
+#define HICR5 0x0
+#define HICR5_ENL2H  BIT(8)

Shouldn't we be setting this at the same time as HICR5_ENFWH below?

In our testing we didn't require it.

Lei, can you double check that the patch works from a power cycle without setting bit 8 in 0x1e789080?

Cheers,

Joel

author maintainer
#8 lore raw

Re: [PATCH linux dev-4.13 3/3] soc: aspeed-lpc-ctrl: Enable FWH cycles

Quoted 8 lines · Joel Stanley
Quoted 6 lines · Andrew Jeffery

drivers/misc/aspeed-lpc-ctrl.c line 25

Quoted 3 lines · Joel Stanley
drivers/misc/aspeed-lpc-ctrl.c +2 -0
+#define HICR5 0x0
+#define HICR5_ENL2H  BIT(8)

Shouldn't we be setting this at the same time as HICR5_ENFWH below?

Quoted 4 lines

In our testing we didn't require it.

Lei, can you double check that the patch works from a power cycle without setting bit 8 in 0x1e789080?

Our testing was off. We discovered that bit 10 is always set (in this case by u-boot, in platform.S), but we need to set bit 8.

I will send a v2.

Cheers,

Joel

Tested-by on the v1 series
#9 lore raw
In reply to Joel Stanley

Without the patches, LPC is not working and SBE fails to fetch PNOR. With the patches, LPC is working and SBE starts host OK.

Quoted 18 lines · Joel Stanley

These patches were developed when bringing up dev-4.13 on Romulus. We need to ensure the LPC clock is enabled, now that the clock driver turns off any unused clocks. We also need to enable the LPC firmware cycles bit as we no longer have the aspeed.c hack.

Joel Stanley (3):
ARM: dts: aspeed: Add LPC clock phandles
misc: aspeed-lpc: Enable clock
soc: aspeed-lpc-ctrl: Enable FWH cycles

 arch/arm/boot/dts/aspeed-g4.dtsi |  1 +
 arch/arm/boot/dts/aspeed-g5.dtsi |  1 +
 drivers/misc/aspeed-lpc-ctrl.c   | 31 +++++++++++++++++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

--
2.15.1