OSDN Git Service

usb: dwc2: Enable RPi in ACPI mode
authorJeremy Linton <jeremy.linton@arm.com>
Tue, 13 Apr 2021 21:58:34 +0000 (16:58 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Apr 2021 08:55:54 +0000 (10:55 +0200)
The dwc2 driver has everything we need to run
in ACPI mode except for the ACPI module device table
boilerplate. With that added and identified as "BCM2848",
an id in use by other OSs for this device, the dw2
controller on the BCM2711 will work.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Link: https://lore.kernel.org/r/20210413215834.3126447-2-jeremy.linton@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc2/core.h
drivers/usb/dwc2/params.c
drivers/usb/dwc2/platform.c

index 8c12b30..e927701 100644 (file)
@@ -38,6 +38,7 @@
 #ifndef __DWC2_CORE_H__
 #define __DWC2_CORE_H__
 
+#include <linux/acpi.h>
 #include <linux/phy/phy.h>
 #include <linux/regulator/consumer.h>
 #include <linux/usb/gadget.h>
@@ -1342,6 +1343,7 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
 
 /* The device ID match table */
 extern const struct of_device_id dwc2_of_match_table[];
+extern const struct acpi_device_id dwc2_acpi_match[];
 
 int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg);
 int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg);
index 92df3d6..7a6089f 100644 (file)
@@ -232,6 +232,12 @@ const struct of_device_id dwc2_of_match_table[] = {
 };
 MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
 
+const struct acpi_device_id dwc2_acpi_match[] = {
+       { "BCM2848", (kernel_ulong_t)dwc2_set_bcm_params },
+       { },
+};
+MODULE_DEVICE_TABLE(acpi, dwc2_acpi_match);
+
 static void dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg)
 {
        u8 val;
@@ -866,10 +872,12 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
        return 0;
 }
 
+typedef void (*set_params_cb)(struct dwc2_hsotg *data);
+
 int dwc2_init_params(struct dwc2_hsotg *hsotg)
 {
        const struct of_device_id *match;
-       void (*set_params)(struct dwc2_hsotg *data);
+       set_params_cb set_params;
 
        dwc2_set_default_params(hsotg);
        dwc2_get_device_properties(hsotg);
@@ -878,6 +886,14 @@ int dwc2_init_params(struct dwc2_hsotg *hsotg)
        if (match && match->data) {
                set_params = match->data;
                set_params(hsotg);
+       } else {
+               const struct acpi_device_id *amatch;
+
+               amatch = acpi_match_device(dwc2_acpi_match, hsotg->dev);
+               if (amatch && amatch->driver_data) {
+                       set_params = (set_params_cb)amatch->driver_data;
+                       set_params(hsotg);
+               }
        }
 
        dwc2_check_params(hsotg);
index f8b819c..1249a23 100644 (file)
@@ -752,6 +752,7 @@ static struct platform_driver dwc2_platform_driver = {
        .driver = {
                .name = dwc2_driver_name,
                .of_match_table = dwc2_of_match_table,
+               .acpi_match_table = ACPI_PTR(dwc2_acpi_match),
                .pm = &dwc2_dev_pm_ops,
        },
        .probe = dwc2_driver_probe,