* RID (Requester ID) is formatted such that: * Bits [15:8] are the Bus number. * Bits [7:3] are the Device number. * Bits [2:0] are the Function number. * * msi-map: Maps a Requester ID to an MSI controller and associated * msi-specifier data. The property is an arbitrary number of tuples of * (rid-base,msi-controller,msi-base,length), where: * * - rid-base is a single cell descri
| 461 | * }; |
| 462 | */ |
| 463 | static void ofw_msi_pic_init(struct rt_pci_device *pdev) |
| 464 | { |
| 465 | #ifdef RT_PCI_MSI |
| 466 | rt_uint32_t rid; |
| 467 | struct rt_pci_host_bridge *bridge; |
| 468 | struct rt_ofw_node *np, *msi_ic_np = RT_NULL; |
| 469 | |
| 470 | /* |
| 471 | * NOTE: Typically, a device's RID is equal to the PCI device's ID. |
| 472 | * However, in complex bus management scenarios such as servers and PCs, |
| 473 | * the RID needs to be associated with DMA. In these cases, |
| 474 | * the RID should be equal to the DMA alias assigned to the |
| 475 | * PCI device by the system bus. |
| 476 | */ |
| 477 | rid = rt_pci_dev_id(pdev); |
| 478 | |
| 479 | bridge = rt_pci_find_host_bridge(pdev->bus); |
| 480 | RT_ASSERT(bridge != RT_NULL); |
| 481 | |
| 482 | np = bridge->parent.ofw_node; |
| 483 | |
| 484 | if (!(msi_ic_np = rt_ofw_parse_phandle(np, "msi-parent", 0))) |
| 485 | { |
| 486 | rt_ofw_map_id(np, rid, "msi-map", "msi-map-mask", &msi_ic_np, RT_NULL); |
| 487 | } |
| 488 | |
| 489 | if (!msi_ic_np) |
| 490 | { |
| 491 | LOG_W("%s: MSI PIC not found", rt_dm_dev_get_name(&pdev->parent)); |
| 492 | |
| 493 | return; |
| 494 | } |
| 495 | |
| 496 | pdev->msi_pic = rt_pic_dynamic_cast(rt_ofw_data(msi_ic_np)); |
| 497 | |
| 498 | if (!pdev->msi_pic) |
| 499 | { |
| 500 | LOG_W("%s: '%s' not supported", rt_dm_dev_get_name(&pdev->parent), "msi-parent"); |
| 501 | |
| 502 | goto _out_put_msi_parent_node; |
| 503 | } |
| 504 | |
| 505 | if (!pdev->msi_pic->ops->irq_compose_msi_msg) |
| 506 | { |
| 507 | LOG_E("%s: MSI pic MUST implemented %s", |
| 508 | rt_ofw_node_full_name(msi_ic_np), "irq_compose_msi_msg"); |
| 509 | RT_ASSERT(0); |
| 510 | } |
| 511 | |
| 512 | if (!pdev->msi_pic->ops->irq_alloc_msi) |
| 513 | { |
| 514 | LOG_E("%s: MSI pic MUST implemented %s", |
| 515 | rt_ofw_node_full_name(msi_ic_np), "irq_alloc_msi"); |
| 516 | RT_ASSERT(0); |
| 517 | } |
| 518 | |
| 519 | if (!pdev->msi_pic->ops->irq_free_msi) |
| 520 | { |
no test coverage detected