| @@ -47,7 +47,7 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data) · 46 unmodified lines |
| 47 | 47 | unsigned int i; |
| 48 | 48 | u32 status; |
| 49 | 49 | |
| 50 | | − for (i = 0; i < vsp1->pdata.wpf_count; ++i) { |
| 50 | + for (i = 0; i < vsp1->info->wpf_count; ++i) { |
| 51 | 51 | struct vsp1_rwpf *wpf = vsp1->wpf[i]; |
| 52 | 52 | struct vsp1_pipeline *pipe; |
| 53 | 53 | |
| @@ -153,7 +153,7 @@ static int vsp1_uapi_create_links(struct vsp1_device *vsp1) · 99 unmodified lines |
| 153 | 153 | return ret; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | | − if (vsp1->pdata.features & VSP1_HAS_LIF) { |
| 156 | + if (vsp1->info->features & VSP1_HAS_LIF) { |
| 157 | 157 | ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity, |
| 158 | 158 | RWPF_PAD_SOURCE, |
| 159 | 159 | &vsp1->lif->entity.subdev.entity, |
| @@ -162,7 +162,7 @@ static int vsp1_uapi_create_links(struct vsp1_device *vsp1) · 2 unmodified lines |
| 162 | 162 | return ret; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | | − for (i = 0; i < vsp1->pdata.rpf_count; ++i) { |
| 165 | + for (i = 0; i < vsp1->info->rpf_count; ++i) { |
| 166 | 166 | struct vsp1_rwpf *rpf = vsp1->rpf[i]; |
| 167 | 167 | |
| 168 | 168 | ret = media_create_pad_link(&rpf->video->video.entity, 0, |
| @@ -174,7 +174,7 @@ static int vsp1_uapi_create_links(struct vsp1_device *vsp1) · 5 unmodified lines |
| 174 | 174 | return ret; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | | − for (i = 0; i < vsp1->pdata.wpf_count; ++i) { |
| 177 | + for (i = 0; i < vsp1->info->wpf_count; ++i) { |
| 178 | 178 | /* Connect the video device to the WPF. All connections are |
| 179 | 179 | * immutable except for the WPF0 source link if a LIF is |
| 180 | 180 | * present. |
| @@ -182,7 +182,7 @@ static int vsp1_uapi_create_links(struct vsp1_device *vsp1) · 1 unmodified line |
| 182 | 182 | struct vsp1_rwpf *wpf = vsp1->wpf[i]; |
| 183 | 183 | unsigned int flags = MEDIA_LNK_FL_ENABLED; |
| 184 | 184 | |
| 185 | | − if (!(vsp1->pdata.features & VSP1_HAS_LIF) || i != 0) |
| 185 | + if (!(vsp1->info->features & VSP1_HAS_LIF) || i != 0) |
| 186 | 186 | flags |= MEDIA_LNK_FL_IMMUTABLE; |
| 187 | 187 | |
| 188 | 188 | ret = media_create_pad_link(&wpf->entity.subdev.entity, |
| @@ -215,7 +215,7 @@ static void vsp1_destroy_entities(struct vsp1_device *vsp1) · 26 unmodified lines |
| 215 | 215 | media_device_unregister(&vsp1->media_dev); |
| 216 | 216 | media_device_cleanup(&vsp1->media_dev); |
| 217 | 217 | |
| 218 | | − if (!vsp1->pdata.uapi) |
| 218 | + if (!vsp1->info->uapi) |
| 219 | 219 | vsp1_drm_cleanup(vsp1); |
| 220 | 220 | } |
| 221 | 221 | |
| @@ -238,7 +238,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 16 unmodified lines |
| 238 | 238 | * the pipeline is configured internally by the driver in that case, and |
| 239 | 239 | * its configuration can thus be trusted. |
| 240 | 240 | */ |
| 241 | | − if (vsp1->pdata.uapi) |
| 241 | + if (vsp1->info->uapi) |
| 242 | 242 | vsp1->media_ops.link_validate = v4l2_subdev_link_validate; |
| 243 | 243 | |
| 244 | 244 | vdev->mdev = mdev; |
| @@ -250,7 +250,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 5 unmodified lines |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /* Instantiate all the entities. */ |
| 253 | | − if (vsp1->pdata.features & VSP1_HAS_BRU) { |
| 253 | + if (vsp1->info->features & VSP1_HAS_BRU) { |
| 254 | 254 | vsp1->bru = vsp1_bru_create(vsp1); |
| 255 | 255 | if (IS_ERR(vsp1->bru)) { |
| 256 | 256 | ret = PTR_ERR(vsp1->bru); |
| @@ -276,7 +276,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 19 unmodified lines |
| 276 | 276 | |
| 277 | 277 | list_add_tail(&vsp1->hst->entity.list_dev, &vsp1->entities); |
| 278 | 278 | |
| 279 | | − if (vsp1->pdata.features & VSP1_HAS_LIF) { |
| 279 | + if (vsp1->info->features & VSP1_HAS_LIF) { |
| 280 | 280 | vsp1->lif = vsp1_lif_create(vsp1); |
| 281 | 281 | if (IS_ERR(vsp1->lif)) { |
| 282 | 282 | ret = PTR_ERR(vsp1->lif); |
| @@ -286,7 +286,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 3 unmodified lines |
| 286 | 286 | list_add_tail(&vsp1->lif->entity.list_dev, &vsp1->entities); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | | − if (vsp1->pdata.features & VSP1_HAS_LUT) { |
| 289 | + if (vsp1->info->features & VSP1_HAS_LUT) { |
| 290 | 290 | vsp1->lut = vsp1_lut_create(vsp1); |
| 291 | 291 | if (IS_ERR(vsp1->lut)) { |
| 292 | 292 | ret = PTR_ERR(vsp1->lut); |
| @@ -296,7 +296,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 3 unmodified lines |
| 296 | 296 | list_add_tail(&vsp1->lut->entity.list_dev, &vsp1->entities); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | | − for (i = 0; i < vsp1->pdata.rpf_count; ++i) { |
| 299 | + for (i = 0; i < vsp1->info->rpf_count; ++i) { |
| 300 | 300 | struct vsp1_rwpf *rpf; |
| 301 | 301 | |
| 302 | 302 | rpf = vsp1_rpf_create(vsp1, i); |
| @@ -308,7 +308,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 5 unmodified lines |
| 308 | 308 | vsp1->rpf[i] = rpf; |
| 309 | 309 | list_add_tail(&rpf->entity.list_dev, &vsp1->entities); |
| 310 | 310 | |
| 311 | | − if (vsp1->pdata.uapi) { |
| 311 | + if (vsp1->info->uapi) { |
| 312 | 312 | struct vsp1_video *video = vsp1_video_create(vsp1, rpf); |
| 313 | 313 | |
| 314 | 314 | if (IS_ERR(video)) { |
| @@ -320,7 +320,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 5 unmodified lines |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | | − if (vsp1->pdata.features & VSP1_HAS_SRU) { |
| 323 | + if (vsp1->info->features & VSP1_HAS_SRU) { |
| 324 | 324 | vsp1->sru = vsp1_sru_create(vsp1); |
| 325 | 325 | if (IS_ERR(vsp1->sru)) { |
| 326 | 326 | ret = PTR_ERR(vsp1->sru); |
| @@ -330,7 +330,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 3 unmodified lines |
| 330 | 330 | list_add_tail(&vsp1->sru->entity.list_dev, &vsp1->entities); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | | − for (i = 0; i < vsp1->pdata.uds_count; ++i) { |
| 333 | + for (i = 0; i < vsp1->info->uds_count; ++i) { |
| 334 | 334 | struct vsp1_uds *uds; |
| 335 | 335 | |
| 336 | 336 | uds = vsp1_uds_create(vsp1, i); |
| @@ -343,7 +343,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 6 unmodified lines |
| 343 | 343 | list_add_tail(&uds->entity.list_dev, &vsp1->entities); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | | − for (i = 0; i < vsp1->pdata.wpf_count; ++i) { |
| 346 | + for (i = 0; i < vsp1->info->wpf_count; ++i) { |
| 347 | 347 | struct vsp1_rwpf *wpf; |
| 348 | 348 | |
| 349 | 349 | wpf = vsp1_wpf_create(vsp1, i); |
| @@ -355,7 +355,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 5 unmodified lines |
| 355 | 355 | vsp1->wpf[i] = wpf; |
| 356 | 356 | list_add_tail(&wpf->entity.list_dev, &vsp1->entities); |
| 357 | 357 | |
| 358 | | − if (vsp1->pdata.uapi) { |
| 358 | + if (vsp1->info->uapi) { |
| 359 | 359 | struct vsp1_video *video = vsp1_video_create(vsp1, wpf); |
| 360 | 360 | |
| 361 | 361 | if (IS_ERR(video)) { |
| @@ -377,7 +377,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 15 unmodified lines |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /* Create links. */ |
| 380 | | − if (vsp1->pdata.uapi) |
| 380 | + if (vsp1->info->uapi) |
| 381 | 381 | ret = vsp1_uapi_create_links(vsp1); |
| 382 | 382 | else |
| 383 | 383 | ret = vsp1_drm_create_links(vsp1); |
| @@ -387,7 +387,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) · 3 unmodified lines |
| 387 | 387 | /* Register subdev nodes if the userspace API is enabled or initialize |
| 388 | 388 | * the DRM pipeline otherwise. |
| 389 | 389 | */ |
| 390 | | − if (vsp1->pdata.uapi) { |
| 390 | + if (vsp1->info->uapi) { |
| 391 | 391 | vsp1->use_dl = false; |
| 392 | 392 | ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev); |
| 393 | 393 | } else { |
| @@ -438,7 +438,7 @@ static int vsp1_device_init(struct vsp1_device *vsp1) · 44 unmodified lines |
| 438 | 438 | int ret; |
| 439 | 439 | |
| 440 | 440 | /* Reset any channel that might be running. */ |
| 441 | | − for (i = 0; i < vsp1->pdata.wpf_count; ++i) { |
| 441 | + for (i = 0; i < vsp1->info->wpf_count; ++i) { |
| 442 | 442 | ret = vsp1_reset_wpf(vsp1, i); |
| 443 | 443 | if (ret < 0) |
| 444 | 444 | return ret; |
| @@ -447,10 +447,10 @@ static int vsp1_device_init(struct vsp1_device *vsp1) · 2 unmodified lines |
| 447 | 447 | vsp1_write(vsp1, VI6_CLK_DCSWT, (8 << VI6_CLK_DCSWT_CSTPW_SHIFT) | |
| 448 | 448 | (8 << VI6_CLK_DCSWT_CSTRW_SHIFT)); |
| 449 | 449 | |
| 450 | | − for (i = 0; i < vsp1->pdata.rpf_count; ++i) |
| 450 | + for (i = 0; i < vsp1->info->rpf_count; ++i) |
| 451 | 451 | vsp1_write(vsp1, VI6_DPR_RPF_ROUTE(i), VI6_DPR_NODE_UNUSED); |
| 452 | 452 | |
| 453 | | − for (i = 0; i < vsp1->pdata.uds_count; ++i) |
| 453 | + for (i = 0; i < vsp1->info->uds_count; ++i) |
| 454 | 454 | vsp1_write(vsp1, VI6_DPR_UDS_ROUTE(i), VI6_DPR_NODE_UNUSED); |
| 455 | 455 | |
| 456 | 456 | vsp1_write(vsp1, VI6_DPR_SRU_ROUTE, VI6_DPR_NODE_UNUSED); |
| @@ -567,52 +567,75 @@ static const struct dev_pm_ops vsp1_pm_ops = { · 110 unmodified lines |
| 567 | 567 | * Platform Driver |
| 568 | 568 | */ |
| 569 | 569 | |
| 570 | | −static int vsp1_parse_dt(struct vsp1_device *vsp1) |
| 571 | | −{ |
| 572 | | − struct device_node *np = vsp1->dev->of_node; |
| 573 | | − struct vsp1_platform_data *pdata = &vsp1->pdata; |
| 574 | | − |
| 575 | | − if (of_property_read_bool(np, "renesas,has-lif")) |
| 576 | | − pdata->features |= VSP1_HAS_LIF; |
| 577 | | − if (of_property_read_bool(np, "renesas,has-lut")) |
| 578 | | − pdata->features |= VSP1_HAS_LUT; |
| 579 | | − if (of_property_read_bool(np, "renesas,has-sru")) |
| 580 | | − pdata->features |= VSP1_HAS_SRU; |
| 581 | | − |
| 582 | | − of_property_read_u32(np, "renesas,#rpf", &pdata->rpf_count); |
| 583 | | − of_property_read_u32(np, "renesas,#uds", &pdata->uds_count); |
| 584 | | − of_property_read_u32(np, "renesas,#wpf", &pdata->wpf_count); |
| 585 | | − |
| 586 | | − if (pdata->rpf_count <= 0 || pdata->rpf_count > VSP1_MAX_RPF) { |
| 587 | | − dev_err(vsp1->dev, "invalid number of RPF (%u)\n", |
| 588 | | − pdata->rpf_count); |
| 589 | | − return -EINVAL; |
| 590 | | − } |
| 591 | | − |
| 592 | | − if (pdata->uds_count > VSP1_MAX_UDS) { |
| 593 | | − dev_err(vsp1->dev, "invalid number of UDS (%u)\n", |
| 594 | | − pdata->uds_count); |
| 595 | | − return -EINVAL; |
| 596 | | − } |
| 597 | | − |
| 598 | | − if (pdata->wpf_count <= 0 || pdata->wpf_count > VSP1_MAX_WPF) { |
| 599 | | − dev_err(vsp1->dev, "invalid number of WPF (%u)\n", |
| 600 | | − pdata->wpf_count); |
| 601 | | − return -EINVAL; |
| 602 | | − } |
| 603 | | − |
| 604 | | − pdata->features |= VSP1_HAS_BRU; |
| 605 | | − pdata->num_bru_inputs = 4; |
| 606 | | − pdata->uapi = true; |
| 607 | | − |
| 608 | | − return 0; |
| 609 | | −} |
| 570 | +static const struct vsp1_device_info vsp1_device_infos[] = { |
| 571 | + { |
| 572 | + .version = VI6_IP_VERSION_MODEL_VSPS_H2, |
| 573 | + .features = VSP1_HAS_BRU | VSP1_HAS_LUT | VSP1_HAS_SRU, |
| 574 | + .rpf_count = 5, |
| 575 | + .uds_count = 3, |
| 576 | + .wpf_count = 4, |
| 577 | + .num_bru_inputs = 4, |
| 578 | + .uapi = true, |
| 579 | + }, { |
| 580 | + .version = VI6_IP_VERSION_MODEL_VSPR_H2, |
| 581 | + .features = VSP1_HAS_BRU | VSP1_HAS_SRU, |
| 582 | + .rpf_count = 5, |
| 583 | + .uds_count = 1, |
| 584 | + .wpf_count = 4, |
| 585 | + .num_bru_inputs = 4, |
| 586 | + .uapi = true, |
| 587 | + }, { |
| 588 | + .version = VI6_IP_VERSION_MODEL_VSPD_GEN2, |
| 589 | + .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_LUT, |
| 590 | + .rpf_count = 4, |
| 591 | + .uds_count = 1, |
| 592 | + .wpf_count = 4, |
| 593 | + .num_bru_inputs = 4, |
| 594 | + .uapi = true, |
| 595 | + }, { |
| 596 | + .version = VI6_IP_VERSION_MODEL_VSPS_M2, |
| 597 | + .features = VSP1_HAS_BRU | VSP1_HAS_LUT | VSP1_HAS_SRU, |
| 598 | + .rpf_count = 5, |
| 599 | + .uds_count = 3, |
| 600 | + .wpf_count = 4, |
| 601 | + .num_bru_inputs = 4, |
| 602 | + .uapi = true, |
| 603 | + }, { |
| 604 | + .version = VI6_IP_VERSION_MODEL_VSPI_GEN3, |
| 605 | + .features = VSP1_HAS_LUT | VSP1_HAS_SRU, |
| 606 | + .rpf_count = 1, |
| 607 | + .uds_count = 1, |
| 608 | + .wpf_count = 1, |
| 609 | + .uapi = true, |
| 610 | + }, { |
| 611 | + .version = VI6_IP_VERSION_MODEL_VSPBD_GEN3, |
| 612 | + .features = VSP1_HAS_BRU, |
| 613 | + .rpf_count = 5, |
| 614 | + .wpf_count = 1, |
| 615 | + .num_bru_inputs = 5, |
| 616 | + .uapi = true, |
| 617 | + }, { |
| 618 | + .version = VI6_IP_VERSION_MODEL_VSPBC_GEN3, |
| 619 | + .features = VSP1_HAS_BRU | VSP1_HAS_LUT, |
| 620 | + .rpf_count = 5, |
| 621 | + .wpf_count = 1, |
| 622 | + .num_bru_inputs = 5, |
| 623 | + .uapi = true, |
| 624 | + }, { |
| 625 | + .version = VI6_IP_VERSION_MODEL_VSPD_GEN3, |
| 626 | + .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_LUT, |
| 627 | + .rpf_count = 5, |
| 628 | + .wpf_count = 2, |
| 629 | + .num_bru_inputs = 5, |
| 630 | + }, |
| 631 | +}; |
| 610 | 632 | |
| 611 | 633 | static int vsp1_probe(struct platform_device *pdev) |
| 612 | 634 | { |
| 613 | 635 | struct vsp1_device *vsp1; |
| 614 | 636 | struct resource *irq; |
| 615 | 637 | struct resource *io; |
| 638 | + unsigned int i; |
| 616 | 639 | u32 version; |
| 617 | 640 | int ret; |
| 618 | 641 | |
| @@ -625,10 +648,6 @@ static int vsp1_probe(struct platform_device *pdev) · 6 unmodified lines |
| 625 | 648 | INIT_LIST_HEAD(&vsp1->entities); |
| 626 | 649 | INIT_LIST_HEAD(&vsp1->videos); |
| 627 | 650 | |
| 628 | | − ret = vsp1_parse_dt(vsp1); |
| 629 | | − if (ret < 0) |
| 630 | | − return ret; |
| 631 | | − |
| 632 | 651 | /* I/O, IRQ and clock resources */ |
| 633 | 652 | io = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 634 | 653 | vsp1->mmio = devm_ioremap_resource(&pdev->dev, io); |
| @@ -662,21 +681,21 @@ static int vsp1_probe(struct platform_device *pdev) · 27 unmodified lines |
| 662 | 681 | version = vsp1_read(vsp1, VI6_IP_VERSION); |
| 663 | 682 | clk_disable_unprepare(vsp1->clock); |
| 664 | 683 | |
| 665 | | − dev_dbg(&pdev->dev, "IP version 0x%08x\n", version); |
| 684 | + for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) { |
| 685 | + if ((version & VI6_IP_VERSION_MODEL_MASK) == |
| 686 | + vsp1_device_infos[i].version) { |
| 687 | + vsp1->info = &vsp1_device_infos[i]; |
| 688 | + break; |
| 689 | + } |
| 690 | + } |
| 666 | 691 | |
| 667 | | − switch (version & VI6_IP_VERSION_MODEL_MASK) { |
| 668 | | − case VI6_IP_VERSION_MODEL_VSPD_GEN3: |
| 669 | | − vsp1->pdata.num_bru_inputs = 5; |
| 670 | | − vsp1->pdata.uapi = false; |
| 671 | | − break; |
| 672 | | − |
| 673 | | − case VI6_IP_VERSION_MODEL_VSPI_GEN3: |
| 674 | | − case VI6_IP_VERSION_MODEL_VSPBD_GEN3: |
| 675 | | − case VI6_IP_VERSION_MODEL_VSPBC_GEN3: |
| 676 | | − vsp1->pdata.features &= ~VSP1_HAS_BRU; |
| 677 | | − break; |
| 692 | + if (!vsp1->info) { |
| 693 | + dev_err(&pdev->dev, "unsupported IP version 0x%08x\n", version); |
| 694 | + return -ENXIO; |
| 678 | 695 | } |
| 679 | 696 | |
| 697 | + dev_dbg(&pdev->dev, "IP version 0x%08x\n", version); |
| 698 | + |
| 680 | 699 | /* Instanciate entities */ |
| 681 | 700 | ret = vsp1_create_entities(vsp1); |
| 682 | 701 | if (ret < 0) { |