drivers: can: kvaser_pci: Convert to use dynamic BDF lookup
Use the new PCIe core infrastructure for looking up the BDF at runtime based on the VID/DID values. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
c905b4dded
commit
e9b39efe9e
3 changed files with 13 additions and 16 deletions
|
@ -51,10 +51,11 @@
|
||||||
compatible = "intel,pcie";
|
compatible = "intel,pcie";
|
||||||
ranges;
|
ranges;
|
||||||
|
|
||||||
can0: can@1000 {
|
can0: can0 {
|
||||||
compatible = "kvaser,pcican";
|
compatible = "kvaser,pcican";
|
||||||
status = "okay";
|
status = "okay";
|
||||||
reg = <PCIE_BDF(0,2,0) PCIE_ID(0x10e8,0x8406)>;
|
vendor-id = <0x10e8>;
|
||||||
|
device-id = <0x8406>;
|
||||||
interrupts = <11 IRQ_TYPE_LOWEST_LEVEL_LOW 3>;
|
interrupts = <11 IRQ_TYPE_LOWEST_LEVEL_LOW 3>;
|
||||||
interrupt-parent = <&intc>;
|
interrupt-parent = <&intc>;
|
||||||
sjw = <1>;
|
sjw = <1>;
|
||||||
|
|
|
@ -25,9 +25,8 @@ LOG_MODULE_REGISTER(can_kvaser_pci, CONFIG_CAN_LOG_LEVEL);
|
||||||
#define XLNX_VERINT_VERSION_POS 4U
|
#define XLNX_VERINT_VERSION_POS 4U
|
||||||
|
|
||||||
struct can_kvaser_pci_config {
|
struct can_kvaser_pci_config {
|
||||||
pcie_bdf_t pcie_bdf;
|
|
||||||
pcie_id_t pcie_id;
|
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
|
struct pcie_dev *pcie;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct can_kvaser_pci_data {
|
struct can_kvaser_pci_data {
|
||||||
|
@ -74,15 +73,15 @@ static int can_kvaser_pci_init(const struct device *dev)
|
||||||
uint32_t intcsr;
|
uint32_t intcsr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!pcie_probe(kvaser_config->pcie_bdf, kvaser_config->pcie_id)) {
|
if (kvaser_config->pcie->bdf == PCIE_BDF_NONE) {
|
||||||
LOG_ERR("failed to probe PCI(e)");
|
LOG_ERR("failed to find PCIe device");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcie_set_cmd(kvaser_config->pcie_bdf, PCIE_CONF_CMDSTAT_IO, true);
|
pcie_set_cmd(kvaser_config->pcie->bdf, PCIE_CONF_CMDSTAT_IO, true);
|
||||||
|
|
||||||
/* AMCC S5920 registers */
|
/* AMCC S5920 registers */
|
||||||
if (!pcie_probe_iobar(kvaser_config->pcie_bdf, 0, &iobar)) {
|
if (!pcie_probe_iobar(kvaser_config->pcie->bdf, 0, &iobar)) {
|
||||||
LOG_ERR("failed to probe AMCC S5920 I/O BAR");
|
LOG_ERR("failed to probe AMCC S5920 I/O BAR");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +89,7 @@ static int can_kvaser_pci_init(const struct device *dev)
|
||||||
amcc_base = iobar.phys_addr;
|
amcc_base = iobar.phys_addr;
|
||||||
|
|
||||||
/* SJA1000 registers */
|
/* SJA1000 registers */
|
||||||
if (!pcie_probe_iobar(kvaser_config->pcie_bdf, 1, &iobar)) {
|
if (!pcie_probe_iobar(kvaser_config->pcie->bdf, 1, &iobar)) {
|
||||||
LOG_ERR("failed to probe SJA1000 I/O BAR");
|
LOG_ERR("failed to probe SJA1000 I/O BAR");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +97,7 @@ static int can_kvaser_pci_init(const struct device *dev)
|
||||||
kvaser_data->sja1000_base = iobar.phys_addr;
|
kvaser_data->sja1000_base = iobar.phys_addr;
|
||||||
|
|
||||||
/* Xilinx registers */
|
/* Xilinx registers */
|
||||||
if (!pcie_probe_iobar(kvaser_config->pcie_bdf, 2, &iobar)) {
|
if (!pcie_probe_iobar(kvaser_config->pcie->bdf, 2, &iobar)) {
|
||||||
LOG_ERR("failed to probe Xilinx I/O BAR");
|
LOG_ERR("failed to probe Xilinx I/O BAR");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
@ -160,10 +159,10 @@ const struct can_driver_api can_kvaser_pci_driver_api = {
|
||||||
|
|
||||||
#define CAN_KVASER_PCI_INIT(inst) \
|
#define CAN_KVASER_PCI_INIT(inst) \
|
||||||
static void can_kvaser_pci_config_func_##inst(const struct device *dev); \
|
static void can_kvaser_pci_config_func_##inst(const struct device *dev); \
|
||||||
|
DEVICE_PCIE_INST_DECLARE(inst); \
|
||||||
\
|
\
|
||||||
static const struct can_kvaser_pci_config can_kvaser_pci_config_##inst = { \
|
static const struct can_kvaser_pci_config can_kvaser_pci_config_##inst = { \
|
||||||
.pcie_bdf = DT_INST_REG_ADDR(inst), \
|
DEVICE_PCIE_INST_INIT(inst, pcie), \
|
||||||
.pcie_id = DT_INST_REG_SIZE(inst), \
|
|
||||||
.irq_config_func = can_kvaser_pci_config_func_##inst \
|
.irq_config_func = can_kvaser_pci_config_func_##inst \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -5,11 +5,8 @@ description: Kvaser PCIcan
|
||||||
|
|
||||||
compatible: "kvaser,pcican"
|
compatible: "kvaser,pcican"
|
||||||
|
|
||||||
include: can-controller.yaml
|
include: [can-controller.yaml, pcie-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
interrupts:
|
interrupts:
|
||||||
required: true
|
required: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue