Skip to content

Commit 9dbacd4

Browse files
committed
Merge tag 'aspeed-5.15-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/bmc into arm/soc
ASPEED soc updates for 5.15 * Two fixes for drivers that control the mapping of BMC memory over PCIe and LPC * Re-enable FWH2AHB on systems that have it closed off by default * A new id for the AST2625, an AST2600 variant * tag 'aspeed-5.15-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/bmc: soc: aspeed: Re-enable FWH2AHB on AST2600 soc: aspeed: socinfo: Add AST2625 variant soc: aspeed: p2a-ctrl: Fix boundary check for mmap soc: aspeed: lpc-ctrl: Fix boundary check for mmap Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 0fbd740 + 2f9b25f commit 9dbacd4

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

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

Lines changed: 24 additions & 7 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)
@@ -51,7 +52,7 @@ static int aspeed_lpc_ctrl_mmap(struct file *file, struct vm_area_struct *vma)
5152
unsigned long vsize = vma->vm_end - vma->vm_start;
5253
pgprot_t prot = vma->vm_page_prot;
5354

54-
if (vma->vm_pgoff + vsize > lpc_ctrl->mem_base + lpc_ctrl->mem_size)
55+
if (vma->vm_pgoff + vma_pages(vma) > lpc_ctrl->mem_size >> PAGE_SHIFT)
5556
return -EINVAL;
5657

5758
/* ast2400/2500 AHB accesses are not cache coherent */
@@ -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;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int aspeed_p2a_mmap(struct file *file, struct vm_area_struct *vma)
110110
vsize = vma->vm_end - vma->vm_start;
111111
prot = vma->vm_page_prot;
112112

113-
if (vma->vm_pgoff + vsize > ctrl->mem_base + ctrl->mem_size)
113+
if (vma->vm_pgoff + vma_pages(vma) > ctrl->mem_size >> PAGE_SHIFT)
114114
return -EINVAL;
115115

116116
/* ast2400/2500 AHB accesses are not cache coherent */

drivers/soc/aspeed/aspeed-socinfo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static struct {
2626
{ "AST2600", 0x05000303 },
2727
{ "AST2620", 0x05010203 },
2828
{ "AST2605", 0x05030103 },
29+
{ "AST2625", 0x05030403 },
2930
};
3031

3132
static const char *siliconid_to_name(u32 siliconid)

0 commit comments

Comments
 (0)