Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc3: qcom: Remove ACPI support from glue driver

Minimal ACPI support was added to the Qualcomm DWC3 glue driver in order to
enable USB on SDM850 and SC8180X compute platforms. The support is still
functional, but unnoticed regressions in other drivers indicates that no
one actually booting any of platforms dependent on this implementation.

The functionality provides is the bare minimum and is not expected to aid
in the effort of bringing full ACPI support to the driver in the future.

Remove the ACPI code from the Qualcomm DWC3 glue driver to aid in the
implementation of improvements that are actually used like multiport and
flattening device tree.

Commit message by Bjorn Andersson.

Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20240305093216.3814787-1-quic_kriskura@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Krishna Kurapati and committed by
Greg Kroah-Hartman
41717b88 12fc84e8

+13 -265
+1 -1
drivers/usb/dwc3/Kconfig
··· 131 131 tristate "Qualcomm Platform" 132 132 depends on ARCH_QCOM || COMPILE_TEST 133 133 depends on EXTCON || !EXTCON 134 - depends on (OF || ACPI) 134 + depends on OF 135 135 default USB_DWC3 136 136 help 137 137 Some Qualcomm SoCs use DesignWare Core IP for USB2/3
+12 -264
drivers/usb/dwc3/dwc3-qcom.c
··· 4 4 * Inspired by dwc3-of-simple.c 5 5 */ 6 6 7 - #include <linux/acpi.h> 8 7 #include <linux/io.h> 9 8 #include <linux/of.h> 10 9 #include <linux/clk.h> ··· 52 53 #define APPS_USB_AVG_BW 0 53 54 #define APPS_USB_PEAK_BW MBps_to_icc(40) 54 55 55 - struct dwc3_acpi_pdata { 56 - u32 qscratch_base_offset; 57 - u32 qscratch_base_size; 58 - u32 dwc3_core_base_size; 59 - int qusb2_phy_irq_index; 60 - int dp_hs_phy_irq_index; 61 - int dm_hs_phy_irq_index; 62 - int ss_phy_irq_index; 63 - bool is_urs; 64 - }; 65 - 66 56 struct dwc3_qcom { 67 57 struct device *dev; 68 58 void __iomem *qscratch_base; 69 59 struct platform_device *dwc3; 70 - struct platform_device *urs_usb; 71 60 struct clk **clks; 72 61 int num_clocks; 73 62 struct reset_control *resets; ··· 70 83 struct extcon_dev *host_edev; 71 84 struct notifier_block vbus_nb; 72 85 struct notifier_block host_nb; 73 - 74 - const struct dwc3_acpi_pdata *acpi_pdata; 75 86 76 87 enum usb_dr_mode mode; 77 88 bool is_suspended; ··· 232 247 enum usb_device_speed max_speed; 233 248 struct device *dev = qcom->dev; 234 249 int ret; 235 - 236 - if (has_acpi_companion(dev)) 237 - return 0; 238 250 239 251 qcom->icc_path_ddr = of_icc_get(dev, "usb-ddr"); 240 252 if (IS_ERR(qcom->icc_path_ddr)) { ··· 501 519 PIPE_UTMI_CLK_DIS); 502 520 } 503 521 504 - static int dwc3_qcom_get_irq(struct platform_device *pdev, 505 - const char *name, int num) 506 - { 507 - struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 508 - struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : pdev; 509 - struct device_node *np = pdev->dev.of_node; 510 - int ret; 511 - 512 - if (np) 513 - ret = platform_get_irq_byname_optional(pdev_irq, name); 514 - else 515 - ret = platform_get_irq_optional(pdev_irq, num); 516 - 517 - return ret; 518 - } 519 - 520 522 static int dwc3_qcom_setup_irq(struct platform_device *pdev) 521 523 { 522 524 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 523 - const struct dwc3_acpi_pdata *pdata = qcom->acpi_pdata; 524 525 int irq; 525 526 int ret; 526 527 527 - irq = dwc3_qcom_get_irq(pdev, "qusb2_phy", 528 - pdata ? pdata->qusb2_phy_irq_index : -1); 528 + irq = platform_get_irq_byname_optional(pdev, "qusb2_phy"); 529 529 if (irq > 0) { 530 530 /* Keep wakeup interrupts disabled until suspend */ 531 531 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, ··· 521 557 qcom->qusb2_phy_irq = irq; 522 558 } 523 559 524 - irq = dwc3_qcom_get_irq(pdev, "dp_hs_phy_irq", 525 - pdata ? pdata->dp_hs_phy_irq_index : -1); 560 + irq = platform_get_irq_byname_optional(pdev, "dp_hs_phy_irq"); 526 561 if (irq > 0) { 527 562 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, 528 563 qcom_dwc3_resume_irq, ··· 534 571 qcom->dp_hs_phy_irq = irq; 535 572 } 536 573 537 - irq = dwc3_qcom_get_irq(pdev, "dm_hs_phy_irq", 538 - pdata ? pdata->dm_hs_phy_irq_index : -1); 574 + irq = platform_get_irq_byname_optional(pdev, "dm_hs_phy_irq"); 539 575 if (irq > 0) { 540 576 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, 541 577 qcom_dwc3_resume_irq, ··· 547 585 qcom->dm_hs_phy_irq = irq; 548 586 } 549 587 550 - irq = dwc3_qcom_get_irq(pdev, "ss_phy_irq", 551 - pdata ? pdata->ss_phy_irq_index : -1); 588 + irq = platform_get_irq_byname_optional(pdev, "ss_phy_irq"); 552 589 if (irq > 0) { 553 590 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, 554 591 qcom_dwc3_resume_irq, ··· 610 649 return 0; 611 650 } 612 651 613 - static const struct property_entry dwc3_qcom_acpi_properties[] = { 614 - PROPERTY_ENTRY_STRING("dr_mode", "host"), 615 - {} 616 - }; 617 - 618 - static const struct software_node dwc3_qcom_swnode = { 619 - .properties = dwc3_qcom_acpi_properties, 620 - }; 621 - 622 - static int dwc3_qcom_acpi_register_core(struct platform_device *pdev) 623 - { 624 - struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 625 - struct device *dev = &pdev->dev; 626 - struct resource *res, *child_res = NULL; 627 - struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : 628 - pdev; 629 - int irq; 630 - int ret; 631 - 632 - qcom->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); 633 - if (!qcom->dwc3) 634 - return -ENOMEM; 635 - 636 - qcom->dwc3->dev.parent = dev; 637 - qcom->dwc3->dev.type = dev->type; 638 - qcom->dwc3->dev.dma_mask = dev->dma_mask; 639 - qcom->dwc3->dev.dma_parms = dev->dma_parms; 640 - qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask; 641 - 642 - child_res = kcalloc(2, sizeof(*child_res), GFP_KERNEL); 643 - if (!child_res) { 644 - platform_device_put(qcom->dwc3); 645 - return -ENOMEM; 646 - } 647 - 648 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 649 - if (!res) { 650 - dev_err(&pdev->dev, "failed to get memory resource\n"); 651 - ret = -ENODEV; 652 - goto out; 653 - } 654 - 655 - child_res[0].flags = res->flags; 656 - child_res[0].start = res->start; 657 - child_res[0].end = child_res[0].start + 658 - qcom->acpi_pdata->dwc3_core_base_size; 659 - 660 - irq = platform_get_irq(pdev_irq, 0); 661 - if (irq < 0) { 662 - ret = irq; 663 - goto out; 664 - } 665 - child_res[1].flags = IORESOURCE_IRQ; 666 - child_res[1].start = child_res[1].end = irq; 667 - 668 - ret = platform_device_add_resources(qcom->dwc3, child_res, 2); 669 - if (ret) { 670 - dev_err(&pdev->dev, "failed to add resources\n"); 671 - goto out; 672 - } 673 - 674 - ret = device_add_software_node(&qcom->dwc3->dev, &dwc3_qcom_swnode); 675 - if (ret < 0) { 676 - dev_err(&pdev->dev, "failed to add properties\n"); 677 - goto out; 678 - } 679 - 680 - ret = platform_device_add(qcom->dwc3); 681 - if (ret) { 682 - dev_err(&pdev->dev, "failed to add device\n"); 683 - device_remove_software_node(&qcom->dwc3->dev); 684 - goto out; 685 - } 686 - kfree(child_res); 687 - return 0; 688 - 689 - out: 690 - platform_device_put(qcom->dwc3); 691 - kfree(child_res); 692 - return ret; 693 - } 694 - 695 652 static int dwc3_qcom_of_register_core(struct platform_device *pdev) 696 653 { 697 654 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); ··· 642 763 return ret; 643 764 } 644 765 645 - static struct platform_device *dwc3_qcom_create_urs_usb_platdev(struct device *dev) 646 - { 647 - struct platform_device *urs_usb = NULL; 648 - struct fwnode_handle *fwh; 649 - struct acpi_device *adev; 650 - char name[8]; 651 - int ret; 652 - int id; 653 - 654 - /* Figure out device id */ 655 - ret = sscanf(fwnode_get_name(dev->fwnode), "URS%d", &id); 656 - if (!ret) 657 - return NULL; 658 - 659 - /* Find the child using name */ 660 - snprintf(name, sizeof(name), "USB%d", id); 661 - fwh = fwnode_get_named_child_node(dev->fwnode, name); 662 - if (!fwh) 663 - return NULL; 664 - 665 - adev = to_acpi_device_node(fwh); 666 - if (!adev) 667 - goto err_put_handle; 668 - 669 - urs_usb = acpi_create_platform_device(adev, NULL); 670 - if (IS_ERR_OR_NULL(urs_usb)) 671 - goto err_put_handle; 672 - 673 - return urs_usb; 674 - 675 - err_put_handle: 676 - fwnode_handle_put(fwh); 677 - 678 - return urs_usb; 679 - } 680 - 681 - static void dwc3_qcom_destroy_urs_usb_platdev(struct platform_device *urs_usb) 682 - { 683 - struct fwnode_handle *fwh = urs_usb->dev.fwnode; 684 - 685 - platform_device_unregister(urs_usb); 686 - fwnode_handle_put(fwh); 687 - } 688 - 689 766 static int dwc3_qcom_probe(struct platform_device *pdev) 690 767 { 691 768 struct device_node *np = pdev->dev.of_node; 692 769 struct device *dev = &pdev->dev; 693 770 struct dwc3_qcom *qcom; 694 - struct resource *res, *parent_res = NULL; 695 - struct resource local_res; 771 + struct resource *res; 696 772 int ret, i; 697 773 bool ignore_pipe_clk; 698 774 bool wakeup_source; ··· 658 824 659 825 platform_set_drvdata(pdev, qcom); 660 826 qcom->dev = &pdev->dev; 661 - 662 - if (has_acpi_companion(dev)) { 663 - qcom->acpi_pdata = acpi_device_get_match_data(dev); 664 - if (!qcom->acpi_pdata) { 665 - dev_err(&pdev->dev, "no supporting ACPI device data\n"); 666 - return -EINVAL; 667 - } 668 - } 669 827 670 828 qcom->resets = devm_reset_control_array_get_optional_exclusive(dev); 671 829 if (IS_ERR(qcom->resets)) { ··· 687 861 688 862 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 689 863 690 - if (np) { 691 - parent_res = res; 692 - } else { 693 - memcpy(&local_res, res, sizeof(struct resource)); 694 - parent_res = &local_res; 695 - 696 - parent_res->start = res->start + 697 - qcom->acpi_pdata->qscratch_base_offset; 698 - parent_res->end = parent_res->start + 699 - qcom->acpi_pdata->qscratch_base_size; 700 - 701 - if (qcom->acpi_pdata->is_urs) { 702 - qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev); 703 - if (IS_ERR_OR_NULL(qcom->urs_usb)) { 704 - dev_err(dev, "failed to create URS USB platdev\n"); 705 - if (!qcom->urs_usb) 706 - ret = -ENODEV; 707 - else 708 - ret = PTR_ERR(qcom->urs_usb); 709 - goto clk_disable; 710 - } 711 - } 712 - } 713 - 714 - qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); 864 + qcom->qscratch_base = devm_ioremap_resource(dev, res); 715 865 if (IS_ERR(qcom->qscratch_base)) { 716 866 ret = PTR_ERR(qcom->qscratch_base); 717 - goto free_urs; 867 + goto clk_disable; 718 868 } 719 869 720 870 ret = dwc3_qcom_setup_irq(pdev); 721 871 if (ret) { 722 872 dev_err(dev, "failed to setup IRQs, err=%d\n", ret); 723 - goto free_urs; 873 + goto clk_disable; 724 874 } 725 875 726 876 /* ··· 708 906 if (ignore_pipe_clk) 709 907 dwc3_qcom_select_utmi_clk(qcom); 710 908 711 - if (np) 712 - ret = dwc3_qcom_of_register_core(pdev); 713 - else 714 - ret = dwc3_qcom_acpi_register_core(pdev); 715 - 909 + ret = dwc3_qcom_of_register_core(pdev); 716 910 if (ret) { 717 911 dev_err(dev, "failed to register DWC3 Core, err=%d\n", ret); 718 - goto free_urs; 912 + goto clk_disable; 719 913 } 720 914 721 915 ret = dwc3_qcom_interconnect_init(qcom); ··· 743 945 interconnect_exit: 744 946 dwc3_qcom_interconnect_exit(qcom); 745 947 depopulate: 746 - if (np) { 747 - of_platform_depopulate(&pdev->dev); 748 - } else { 749 - device_remove_software_node(&qcom->dwc3->dev); 750 - platform_device_del(qcom->dwc3); 751 - } 948 + of_platform_depopulate(&pdev->dev); 752 949 platform_device_put(qcom->dwc3); 753 - free_urs: 754 - if (qcom->urs_usb) 755 - dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb); 756 950 clk_disable: 757 951 for (i = qcom->num_clocks - 1; i >= 0; i--) { 758 952 clk_disable_unprepare(qcom->clks[i]); ··· 759 969 static void dwc3_qcom_remove(struct platform_device *pdev) 760 970 { 761 971 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); 762 - struct device_node *np = pdev->dev.of_node; 763 972 struct device *dev = &pdev->dev; 764 973 int i; 765 974 766 - if (np) { 767 - of_platform_depopulate(&pdev->dev); 768 - } else { 769 - device_remove_software_node(&qcom->dwc3->dev); 770 - platform_device_del(qcom->dwc3); 771 - } 975 + of_platform_depopulate(&pdev->dev); 772 976 platform_device_put(qcom->dwc3); 773 - 774 - if (qcom->urs_usb) 775 - dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb); 776 977 777 978 for (i = qcom->num_clocks - 1; i >= 0; i--) { 778 979 clk_disable_unprepare(qcom->clks[i]); ··· 834 1053 }; 835 1054 MODULE_DEVICE_TABLE(of, dwc3_qcom_of_match); 836 1055 837 - #ifdef CONFIG_ACPI 838 - static const struct dwc3_acpi_pdata sdm845_acpi_pdata = { 839 - .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, 840 - .qscratch_base_size = SDM845_QSCRATCH_SIZE, 841 - .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, 842 - .qusb2_phy_irq_index = 1, 843 - .dp_hs_phy_irq_index = 4, 844 - .dm_hs_phy_irq_index = 3, 845 - .ss_phy_irq_index = 2 846 - }; 847 - 848 - static const struct dwc3_acpi_pdata sdm845_acpi_urs_pdata = { 849 - .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, 850 - .qscratch_base_size = SDM845_QSCRATCH_SIZE, 851 - .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, 852 - .qusb2_phy_irq_index = 1, 853 - .dp_hs_phy_irq_index = 4, 854 - .dm_hs_phy_irq_index = 3, 855 - .ss_phy_irq_index = 2, 856 - .is_urs = true, 857 - }; 858 - 859 - static const struct acpi_device_id dwc3_qcom_acpi_match[] = { 860 - { "QCOM2430", (unsigned long)&sdm845_acpi_pdata }, 861 - { "QCOM0304", (unsigned long)&sdm845_acpi_urs_pdata }, 862 - { "QCOM0497", (unsigned long)&sdm845_acpi_urs_pdata }, 863 - { "QCOM04A6", (unsigned long)&sdm845_acpi_pdata }, 864 - { }, 865 - }; 866 - MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match); 867 - #endif 868 - 869 1056 static struct platform_driver dwc3_qcom_driver = { 870 1057 .probe = dwc3_qcom_probe, 871 1058 .remove_new = dwc3_qcom_remove, ··· 841 1092 .name = "dwc3-qcom", 842 1093 .pm = &dwc3_qcom_dev_pm_ops, 843 1094 .of_match_table = dwc3_qcom_of_match, 844 - .acpi_match_table = ACPI_PTR(dwc3_qcom_acpi_match), 845 1095 }, 846 1096 }; 847 1097