Skip to content

Commit 2f9b25f

Browse files
committed
soc: aspeed: Re-enable FWH2AHB on AST2600
Recent builds of the vendor u-boot tree disable features of the BMC that may allow unwanted access if not correctly configured. This includes the firmware hub to ahb bridge (FWH2AHB), which is used by this driver. The bit to "un-disable" it is in the SCU. Set it only when the ioctl is called and we are running on the ast2600, as to not open up the 'backdoor' unless there's userspace trying to use it. Fixes: deb5031 ("soc: aspeed-lpc-ctrl: LPC to AHB mapping on ast2600") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joel Stanley <[email protected]>
1 parent 8812dff commit 2f9b25f

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

drivers/soc/aspeed/aspeed-lpc-ctrl.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct aspeed_lpc_ctrl {
3737
u32 pnor_size;
3838
u32 pnor_base;
3939
bool fwh2ahb;
40+
struct regmap *scu;
4041
};
4142

4243
static struct aspeed_lpc_ctrl *file_aspeed_lpc_ctrl(struct file *file)
@@ -183,13 +184,22 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd,
183184

184185
/*
185186
* Switch to FWH2AHB mode, AST2600 only.
186-
*
187-
* The other bits in this register are interrupt status bits
188-
* that are cleared by writing 1. As we don't want to clear
189-
* them, set only the bit of interest.
190187
*/
191-
if (lpc_ctrl->fwh2ahb)
188+
if (lpc_ctrl->fwh2ahb) {
189+
/*
190+
* Enable FWH2AHB in SCU debug control register 2. This
191+
* does not turn it on, but makes it available for it
192+
* to be configured in HICR6.
193+
*/
194+
regmap_update_bits(lpc_ctrl->scu, 0x0D8, BIT(2), 0);
195+
196+
/*
197+
* The other bits in this register are interrupt status bits
198+
* that are cleared by writing 1. As we don't want to clear
199+
* them, set only the bit of interest.
200+
*/
192201
regmap_write(lpc_ctrl->regmap, HICR6, SW_FWH2AHB);
202+
}
193203

194204
/*
195205
* Enable LPC FHW cycles. This is required for the host to
@@ -296,9 +306,16 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
296306
return rc;
297307
}
298308

299-
if (of_device_is_compatible(dev->of_node, "aspeed,ast2600-lpc-ctrl"))
309+
if (of_device_is_compatible(dev->of_node, "aspeed,ast2600-lpc-ctrl")) {
300310
lpc_ctrl->fwh2ahb = true;
301311

312+
lpc_ctrl->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2600-scu");
313+
if (IS_ERR(lpc_ctrl->scu)) {
314+
dev_err(dev, "couldn't find scu\n");
315+
return PTR_ERR(lpc_ctrl->scu);
316+
}
317+
}
318+
302319
lpc_ctrl->miscdev.minor = MISC_DYNAMIC_MINOR;
303320
lpc_ctrl->miscdev.name = DEVICE_NAME;
304321
lpc_ctrl->miscdev.fops = &aspeed_lpc_ctrl_fops;

0 commit comments

Comments
 (0)