PCI/switchtec: Add 'generation' variable
Add a generation variable passed through the device ID table and test for Gen3-specific registers. This will allow us to add Gen4 and other devices that extend the programming model. Link: https://lore.kernel.org/r/20200115035648.2578-3-logang@deltatee.com Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
fcccd282b6
commit
b13313a01a
@ -326,7 +326,21 @@ static DEVICE_ATTR_RO(field)
|
||||
DEVICE_ATTR_SYS_INFO_STR(vendor_id);
|
||||
DEVICE_ATTR_SYS_INFO_STR(product_id);
|
||||
DEVICE_ATTR_SYS_INFO_STR(product_revision);
|
||||
DEVICE_ATTR_SYS_INFO_STR(component_vendor);
|
||||
|
||||
static ssize_t component_vendor_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct switchtec_dev *stdev = to_stdev(dev);
|
||||
struct sys_info_regs __iomem *si = stdev->mmio_sys_info;
|
||||
|
||||
/* component_vendor field not supported after gen3 */
|
||||
if (stdev->gen != SWITCHTEC_GEN3)
|
||||
return sprintf(buf, "none\n");
|
||||
|
||||
return io_string_show(buf, &si->component_vendor,
|
||||
sizeof(si->component_vendor));
|
||||
}
|
||||
static DEVICE_ATTR_RO(component_vendor);
|
||||
|
||||
static ssize_t component_id_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
@ -334,6 +348,10 @@ static ssize_t component_id_show(struct device *dev,
|
||||
struct switchtec_dev *stdev = to_stdev(dev);
|
||||
int id = ioread16(&stdev->mmio_sys_info->component_id);
|
||||
|
||||
/* component_id field not supported after gen3 */
|
||||
if (stdev->gen != SWITCHTEC_GEN3)
|
||||
return sprintf(buf, "none\n");
|
||||
|
||||
return sprintf(buf, "PM%04X\n", id);
|
||||
}
|
||||
static DEVICE_ATTR_RO(component_id);
|
||||
@ -344,6 +362,10 @@ static ssize_t component_revision_show(struct device *dev,
|
||||
struct switchtec_dev *stdev = to_stdev(dev);
|
||||
int rev = ioread8(&stdev->mmio_sys_info->component_revision);
|
||||
|
||||
/* component_revision field not supported after gen3 */
|
||||
if (stdev->gen != SWITCHTEC_GEN3)
|
||||
return sprintf(buf, "255\n");
|
||||
|
||||
return sprintf(buf, "%d\n", rev);
|
||||
}
|
||||
static DEVICE_ATTR_RO(component_revision);
|
||||
@ -1420,6 +1442,8 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
|
||||
if (IS_ERR(stdev))
|
||||
return PTR_ERR(stdev);
|
||||
|
||||
stdev->gen = id->driver_data;
|
||||
|
||||
rc = switchtec_init_pci(stdev, pdev);
|
||||
if (rc)
|
||||
goto err_put;
|
||||
@ -1467,7 +1491,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
|
||||
put_device(&stdev->dev);
|
||||
}
|
||||
|
||||
#define SWITCHTEC_PCI_DEVICE(device_id) \
|
||||
#define SWITCHTEC_PCI_DEVICE(device_id, gen) \
|
||||
{ \
|
||||
.vendor = PCI_VENDOR_ID_MICROSEMI, \
|
||||
.device = device_id, \
|
||||
@ -1475,6 +1499,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
|
||||
.subdevice = PCI_ANY_ID, \
|
||||
.class = (PCI_CLASS_MEMORY_OTHER << 8), \
|
||||
.class_mask = 0xFFFFFFFF, \
|
||||
.driver_data = gen, \
|
||||
}, \
|
||||
{ \
|
||||
.vendor = PCI_VENDOR_ID_MICROSEMI, \
|
||||
@ -1483,39 +1508,40 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
|
||||
.subdevice = PCI_ANY_ID, \
|
||||
.class = (PCI_CLASS_BRIDGE_OTHER << 8), \
|
||||
.class_mask = 0xFFFFFFFF, \
|
||||
.driver_data = gen, \
|
||||
}
|
||||
|
||||
static const struct pci_device_id switchtec_pci_tbl[] = {
|
||||
SWITCHTEC_PCI_DEVICE(0x8531), //PFX 24xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8532), //PFX 32xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8533), //PFX 48xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8534), //PFX 64xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8535), //PFX 80xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8536), //PFX 96xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8541), //PSX 24xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8542), //PSX 32xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8543), //PSX 48xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8544), //PSX 64xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8545), //PSX 80xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8546), //PSX 96xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8551), //PAX 24XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8552), //PAX 32XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8553), //PAX 48XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8554), //PAX 64XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8555), //PAX 80XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8556), //PAX 96XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8561), //PFXL 24XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8562), //PFXL 32XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8563), //PFXL 48XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8564), //PFXL 64XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8565), //PFXL 80XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8566), //PFXL 96XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8571), //PFXI 24XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8572), //PFXI 32XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8573), //PFXI 48XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8574), //PFXI 64XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8575), //PFXI 80XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8576), //PFXI 96XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8531, SWITCHTEC_GEN3), //PFX 24xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8532, SWITCHTEC_GEN3), //PFX 32xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8533, SWITCHTEC_GEN3), //PFX 48xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8534, SWITCHTEC_GEN3), //PFX 64xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8535, SWITCHTEC_GEN3), //PFX 80xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8536, SWITCHTEC_GEN3), //PFX 96xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8541, SWITCHTEC_GEN3), //PSX 24xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8542, SWITCHTEC_GEN3), //PSX 32xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8543, SWITCHTEC_GEN3), //PSX 48xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8544, SWITCHTEC_GEN3), //PSX 64xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8545, SWITCHTEC_GEN3), //PSX 80xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8546, SWITCHTEC_GEN3), //PSX 96xG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8551, SWITCHTEC_GEN3), //PAX 24XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8552, SWITCHTEC_GEN3), //PAX 32XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8553, SWITCHTEC_GEN3), //PAX 48XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8554, SWITCHTEC_GEN3), //PAX 64XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8555, SWITCHTEC_GEN3), //PAX 80XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8556, SWITCHTEC_GEN3), //PAX 96XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8561, SWITCHTEC_GEN3), //PFXL 24XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8562, SWITCHTEC_GEN3), //PFXL 32XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8563, SWITCHTEC_GEN3), //PFXL 48XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8564, SWITCHTEC_GEN3), //PFXL 64XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8565, SWITCHTEC_GEN3), //PFXL 80XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8566, SWITCHTEC_GEN3), //PFXL 96XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8571, SWITCHTEC_GEN3), //PFXI 24XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8572, SWITCHTEC_GEN3), //PFXI 32XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8573, SWITCHTEC_GEN3), //PFXI 48XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8574, SWITCHTEC_GEN3), //PFXI 64XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8575, SWITCHTEC_GEN3), //PFXI 80XG3
|
||||
SWITCHTEC_PCI_DEVICE(0x8576, SWITCHTEC_GEN3), //PFXI 96XG3
|
||||
{0}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, switchtec_pci_tbl);
|
||||
|
@ -32,6 +32,10 @@ enum {
|
||||
SWITCHTEC_GAS_PFF_CSR_OFFSET = 0x134000,
|
||||
};
|
||||
|
||||
enum switchtec_gen {
|
||||
SWITCHTEC_GEN3,
|
||||
};
|
||||
|
||||
struct mrpc_regs {
|
||||
u8 input_data[SWITCHTEC_MRPC_PAYLOAD_SIZE];
|
||||
u8 output_data[SWITCHTEC_MRPC_PAYLOAD_SIZE];
|
||||
@ -358,6 +362,8 @@ struct switchtec_dev {
|
||||
struct device dev;
|
||||
struct cdev cdev;
|
||||
|
||||
enum switchtec_gen gen;
|
||||
|
||||
int partition;
|
||||
int partition_count;
|
||||
int pff_csr_count;
|
||||
|
Loading…
Reference in New Issue
Block a user