mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-26 23:55:40 +08:00
platform/x86: ISST: Allow configurable offset range
The mmio offset range can be different based on the PCI device id. Here for INTEL_RAPL_PRIO_DEVID_1, the range is increased from 45 to 64. Pass the range as the driver_data. Also account for different ranges during save/restore via suspend/resume callbacks. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20201204015746.1168941-2-srinivas.pandruvada@linux.intel.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
a552f204b0
commit
761f0ee0e8
@ -20,15 +20,21 @@ struct isst_mmio_range {
|
|||||||
int end;
|
int end;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct isst_mmio_range mmio_range[] = {
|
struct isst_mmio_range mmio_range_devid_0[] = {
|
||||||
{0x04, 0x14},
|
{0x04, 0x14},
|
||||||
{0x20, 0xD0},
|
{0x20, 0xD0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct isst_mmio_range mmio_range_devid_1[] = {
|
||||||
|
{0x04, 0x14},
|
||||||
|
{0x20, 0x11C},
|
||||||
|
};
|
||||||
|
|
||||||
struct isst_if_device {
|
struct isst_if_device {
|
||||||
void __iomem *punit_mmio;
|
void __iomem *punit_mmio;
|
||||||
u32 range_0[5];
|
u32 range_0[5];
|
||||||
u32 range_1[45];
|
u32 range_1[64];
|
||||||
|
struct isst_mmio_range *mmio_range;
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,8 +45,6 @@ static long isst_if_mmio_rd_wr(u8 *cmd_ptr, int *write_only, int resume)
|
|||||||
struct pci_dev *pdev;
|
struct pci_dev *pdev;
|
||||||
|
|
||||||
io_reg = (struct isst_if_io_reg *)cmd_ptr;
|
io_reg = (struct isst_if_io_reg *)cmd_ptr;
|
||||||
if (io_reg->reg < 0x04 || io_reg->reg > 0xD0)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (io_reg->reg % 4)
|
if (io_reg->reg % 4)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -56,6 +60,10 @@ static long isst_if_mmio_rd_wr(u8 *cmd_ptr, int *write_only, int resume)
|
|||||||
if (!punit_dev)
|
if (!punit_dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (io_reg->reg < punit_dev->mmio_range[0].beg ||
|
||||||
|
io_reg->reg > punit_dev->mmio_range[1].end)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that operation is complete on a PCI device to avoid read
|
* Ensure that operation is complete on a PCI device to avoid read
|
||||||
* write race by using per PCI device mutex.
|
* write race by using per PCI device mutex.
|
||||||
@ -74,8 +82,10 @@ static long isst_if_mmio_rd_wr(u8 *cmd_ptr, int *write_only, int resume)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_device_id isst_if_ids[] = {
|
static const struct pci_device_id isst_if_ids[] = {
|
||||||
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, INTEL_RAPL_PRIO_DEVID_0)},
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, INTEL_RAPL_PRIO_DEVID_0),
|
||||||
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, INTEL_RAPL_PRIO_DEVID_1)},
|
.driver_data = (kernel_ulong_t)&mmio_range_devid_0},
|
||||||
|
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, INTEL_RAPL_PRIO_DEVID_1),
|
||||||
|
.driver_data = (kernel_ulong_t)&mmio_range_devid_1},
|
||||||
{ 0 },
|
{ 0 },
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(pci, isst_if_ids);
|
MODULE_DEVICE_TABLE(pci, isst_if_ids);
|
||||||
@ -112,6 +122,7 @@ static int isst_if_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
|
|
||||||
mutex_init(&punit_dev->mutex);
|
mutex_init(&punit_dev->mutex);
|
||||||
pci_set_drvdata(pdev, punit_dev);
|
pci_set_drvdata(pdev, punit_dev);
|
||||||
|
punit_dev->mmio_range = (struct isst_mmio_range *) ent->driver_data;
|
||||||
|
|
||||||
memset(&cb, 0, sizeof(cb));
|
memset(&cb, 0, sizeof(cb));
|
||||||
cb.cmd_size = sizeof(struct isst_if_io_reg);
|
cb.cmd_size = sizeof(struct isst_if_io_reg);
|
||||||
@ -141,10 +152,15 @@ static int __maybe_unused isst_if_suspend(struct device *device)
|
|||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(punit_dev->range_0); ++i)
|
for (i = 0; i < ARRAY_SIZE(punit_dev->range_0); ++i)
|
||||||
punit_dev->range_0[i] = readl(punit_dev->punit_mmio +
|
punit_dev->range_0[i] = readl(punit_dev->punit_mmio +
|
||||||
mmio_range[0].beg + 4 * i);
|
punit_dev->mmio_range[0].beg + 4 * i);
|
||||||
for (i = 0; i < ARRAY_SIZE(punit_dev->range_1); ++i)
|
for (i = 0; i < ARRAY_SIZE(punit_dev->range_1); ++i) {
|
||||||
punit_dev->range_1[i] = readl(punit_dev->punit_mmio +
|
u32 addr;
|
||||||
mmio_range[1].beg + 4 * i);
|
|
||||||
|
addr = punit_dev->mmio_range[1].beg + 4 * i;
|
||||||
|
if (addr > punit_dev->mmio_range[1].end)
|
||||||
|
break;
|
||||||
|
punit_dev->range_1[i] = readl(punit_dev->punit_mmio + addr);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -156,10 +172,16 @@ static int __maybe_unused isst_if_resume(struct device *device)
|
|||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(punit_dev->range_0); ++i)
|
for (i = 0; i < ARRAY_SIZE(punit_dev->range_0); ++i)
|
||||||
writel(punit_dev->range_0[i], punit_dev->punit_mmio +
|
writel(punit_dev->range_0[i], punit_dev->punit_mmio +
|
||||||
mmio_range[0].beg + 4 * i);
|
punit_dev->mmio_range[0].beg + 4 * i);
|
||||||
for (i = 0; i < ARRAY_SIZE(punit_dev->range_1); ++i)
|
for (i = 0; i < ARRAY_SIZE(punit_dev->range_1); ++i) {
|
||||||
writel(punit_dev->range_1[i], punit_dev->punit_mmio +
|
u32 addr;
|
||||||
mmio_range[1].beg + 4 * i);
|
|
||||||
|
addr = punit_dev->mmio_range[1].beg + 4 * i;
|
||||||
|
if (addr > punit_dev->mmio_range[1].end)
|
||||||
|
break;
|
||||||
|
|
||||||
|
writel(punit_dev->range_1[i], punit_dev->punit_mmio + addr);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user