diff options
Diffstat (limited to 'drivers/platform/x86/intel_pmc_ipc.c')
-rw-r--r-- | drivers/platform/x86/intel_pmc_ipc.c | 110 |
1 files changed, 33 insertions, 77 deletions
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c index a511d518206b..0bf51d574fa9 100644 --- a/drivers/platform/x86/intel_pmc_ipc.c +++ b/drivers/platform/x86/intel_pmc_ipc.c | |||
@@ -522,48 +522,36 @@ static struct resource telemetry_res[] = { | |||
522 | static int ipc_create_punit_device(void) | 522 | static int ipc_create_punit_device(void) |
523 | { | 523 | { |
524 | struct platform_device *pdev; | 524 | struct platform_device *pdev; |
525 | int ret; | 525 | const struct platform_device_info pdevinfo = { |
526 | 526 | .parent = ipcdev.dev, | |
527 | pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1); | 527 | .name = PUNIT_DEVICE_NAME, |
528 | if (!pdev) { | 528 | .id = -1, |
529 | dev_err(ipcdev.dev, "Failed to alloc punit platform device\n"); | 529 | .res = punit_res_array, |
530 | return -ENOMEM; | 530 | .num_res = ARRAY_SIZE(punit_res_array), |
531 | } | 531 | }; |
532 | 532 | ||
533 | pdev->dev.parent = ipcdev.dev; | 533 | pdev = platform_device_register_full(&pdevinfo); |
534 | ret = platform_device_add_resources(pdev, punit_res_array, | 534 | if (IS_ERR(pdev)) |
535 | ARRAY_SIZE(punit_res_array)); | 535 | return PTR_ERR(pdev); |
536 | if (ret) { | ||
537 | dev_err(ipcdev.dev, "Failed to add platform punit resources\n"); | ||
538 | goto err; | ||
539 | } | ||
540 | 536 | ||
541 | ret = platform_device_add(pdev); | ||
542 | if (ret) { | ||
543 | dev_err(ipcdev.dev, "Failed to add punit platform device\n"); | ||
544 | goto err; | ||
545 | } | ||
546 | ipcdev.punit_dev = pdev; | 537 | ipcdev.punit_dev = pdev; |
547 | 538 | ||
548 | return 0; | 539 | return 0; |
549 | err: | ||
550 | platform_device_put(pdev); | ||
551 | return ret; | ||
552 | } | 540 | } |
553 | 541 | ||
554 | static int ipc_create_tco_device(void) | 542 | static int ipc_create_tco_device(void) |
555 | { | 543 | { |
556 | struct platform_device *pdev; | 544 | struct platform_device *pdev; |
557 | struct resource *res; | 545 | struct resource *res; |
558 | int ret; | 546 | const struct platform_device_info pdevinfo = { |
559 | 547 | .parent = ipcdev.dev, | |
560 | pdev = platform_device_alloc(TCO_DEVICE_NAME, -1); | 548 | .name = TCO_DEVICE_NAME, |
561 | if (!pdev) { | 549 | .id = -1, |
562 | dev_err(ipcdev.dev, "Failed to alloc tco platform device\n"); | 550 | .res = tco_res, |
563 | return -ENOMEM; | 551 | .num_res = ARRAY_SIZE(tco_res), |
564 | } | 552 | .data = &tco_info, |
565 | 553 | .size_data = sizeof(tco_info), | |
566 | pdev->dev.parent = ipcdev.dev; | 554 | }; |
567 | 555 | ||
568 | res = tco_res + TCO_RESOURCE_ACPI_IO; | 556 | res = tco_res + TCO_RESOURCE_ACPI_IO; |
569 | res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET; | 557 | res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET; |
@@ -577,45 +565,26 @@ static int ipc_create_tco_device(void) | |||
577 | res->start = ipcdev.gcr_base + TCO_PMC_OFFSET; | 565 | res->start = ipcdev.gcr_base + TCO_PMC_OFFSET; |
578 | res->end = res->start + TCO_PMC_SIZE - 1; | 566 | res->end = res->start + TCO_PMC_SIZE - 1; |
579 | 567 | ||
580 | ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res)); | 568 | pdev = platform_device_register_full(&pdevinfo); |
581 | if (ret) { | 569 | if (IS_ERR(pdev)) |
582 | dev_err(ipcdev.dev, "Failed to add tco platform resources\n"); | 570 | return PTR_ERR(pdev); |
583 | goto err; | ||
584 | } | ||
585 | 571 | ||
586 | ret = platform_device_add_data(pdev, &tco_info, sizeof(tco_info)); | ||
587 | if (ret) { | ||
588 | dev_err(ipcdev.dev, "Failed to add tco platform data\n"); | ||
589 | goto err; | ||
590 | } | ||
591 | |||
592 | ret = platform_device_add(pdev); | ||
593 | if (ret) { | ||
594 | dev_err(ipcdev.dev, "Failed to add tco platform device\n"); | ||
595 | goto err; | ||
596 | } | ||
597 | ipcdev.tco_dev = pdev; | 572 | ipcdev.tco_dev = pdev; |
598 | 573 | ||
599 | return 0; | 574 | return 0; |
600 | err: | ||
601 | platform_device_put(pdev); | ||
602 | return ret; | ||
603 | } | 575 | } |
604 | 576 | ||
605 | static int ipc_create_telemetry_device(void) | 577 | static int ipc_create_telemetry_device(void) |
606 | { | 578 | { |
607 | struct platform_device *pdev; | 579 | struct platform_device *pdev; |
608 | struct resource *res; | 580 | struct resource *res; |
609 | int ret; | 581 | const struct platform_device_info pdevinfo = { |
610 | 582 | .parent = ipcdev.dev, | |
611 | pdev = platform_device_alloc(TELEMETRY_DEVICE_NAME, -1); | 583 | .name = TELEMETRY_DEVICE_NAME, |
612 | if (!pdev) { | 584 | .id = -1, |
613 | dev_err(ipcdev.dev, | 585 | .res = telemetry_res, |
614 | "Failed to allocate telemetry platform device\n"); | 586 | .num_res = ARRAY_SIZE(telemetry_res), |
615 | return -ENOMEM; | 587 | }; |
616 | } | ||
617 | |||
618 | pdev->dev.parent = ipcdev.dev; | ||
619 | 588 | ||
620 | res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM; | 589 | res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM; |
621 | res->start = ipcdev.telem_punit_ssram_base; | 590 | res->start = ipcdev.telem_punit_ssram_base; |
@@ -625,26 +594,13 @@ static int ipc_create_telemetry_device(void) | |||
625 | res->start = ipcdev.telem_pmc_ssram_base; | 594 | res->start = ipcdev.telem_pmc_ssram_base; |
626 | res->end = res->start + ipcdev.telem_pmc_ssram_size - 1; | 595 | res->end = res->start + ipcdev.telem_pmc_ssram_size - 1; |
627 | 596 | ||
628 | ret = platform_device_add_resources(pdev, telemetry_res, | 597 | pdev = platform_device_register_full(&pdevinfo); |
629 | ARRAY_SIZE(telemetry_res)); | 598 | if (IS_ERR(pdev)) |
630 | if (ret) { | 599 | return PTR_ERR(pdev); |
631 | dev_err(ipcdev.dev, | ||
632 | "Failed to add telemetry platform resources\n"); | ||
633 | goto err; | ||
634 | } | ||
635 | 600 | ||
636 | ret = platform_device_add(pdev); | ||
637 | if (ret) { | ||
638 | dev_err(ipcdev.dev, | ||
639 | "Failed to add telemetry platform device\n"); | ||
640 | goto err; | ||
641 | } | ||
642 | ipcdev.telemetry_dev = pdev; | 601 | ipcdev.telemetry_dev = pdev; |
643 | 602 | ||
644 | return 0; | 603 | return 0; |
645 | err: | ||
646 | platform_device_put(pdev); | ||
647 | return ret; | ||
648 | } | 604 | } |
649 | 605 | ||
650 | static int ipc_create_pmc_devices(void) | 606 | static int ipc_create_pmc_devices(void) |