LPC fixes
Joel Stanley
maintainercover 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
Joel Stanley
maintainerPATCH 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
@@ -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
@@ -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
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.
Signed-off-by Joel Stanley <[email protected]>
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@@ -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@@ -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"; };
Joel Stanley
maintainerPATCH 2/3 misc: aspeed-lpc: Enable clock
In reply to Joel StanleyThe 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
@@ -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
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.
Signed-off-by Joel Stanley <[email protected]>
Quoted 50 lines
--- drivers/misc/aspeed-lpc-ctrl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/misc/aspeed-lpc-ctrl.c +14
-0@@ -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 ; }
Joel Stanley
maintainerPATCH 3/3 soc: aspeed-lpc-ctrl: Enable FWH cycles
In reply to Joel StanleyTo 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
@@ -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
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.
Signed-off-by Joel Stanley <[email protected]>--- drivers/misc/aspeed-lpc-ctrl.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)drivers/misc/aspeed-lpc-ctrl.c +0
-0
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 ;
Joel Stanley
maintainerRe: [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_ENFWHbelow?
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
Joel Stanley
maintainerRe: [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_ENFWHbelow?
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
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.chack.Joel Stanley (3):
ARM: dts: aspeed: Add LPC clock phandles
misc: aspeed-lpc: Enable clock
soc: aspeed-lpc-ctrl: Enable FWH cyclesarch/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