diff mbox series

[v2,07/11] usb: dwc3: convert dwc3-of-simple to use match-data

Message ID 20220226184147.769964-8-pgwipeout@gmail.com
State New
Headers show
Series enable usb support on rk356x | expand

Commit Message

Peter Geis Feb. 26, 2022, 6:41 p.m. UTC
The upcoming support for rk3568 will reuse data from rk3399.
Instead of adding a bunch of of_device_is_compatible as we add support
for new devices, lets get ahead of the problem and use of_match_data
instead.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
 drivers/usb/dwc3/dwc3-of-simple.c | 39 ++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 9dc6295df6b1..57ba9427ad74 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -30,12 +30,16 @@  struct dwc3_of_simple {
 	bool			need_reset;
 };
 
+struct dwc3_of_simple_data {
+	bool			need_reset;
+};
+
 static int dwc3_of_simple_probe(struct platform_device *pdev)
 {
 	struct dwc3_of_simple	*simple;
 	struct device		*dev = &pdev->dev;
 	struct device_node	*np = dev->of_node;
-
+	const struct dwc3_of_simple_data *data = of_device_get_match_data(dev);
 	int			ret;
 
 	simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
@@ -49,8 +53,8 @@  static int dwc3_of_simple_probe(struct platform_device *pdev)
 	 * Some controllers need to toggle the usb3-otg reset before trying to
 	 * initialize the PHY, otherwise the PHY times out.
 	 */
-	if (of_device_is_compatible(np, "rockchip,rk3399-dwc3"))
-		simple->need_reset = true;
+	if (data->need_reset)
+		simple->need_reset = data->need_reset;
 
 	simple->resets = of_reset_control_array_get(np, false, true,
 						    true);
@@ -170,13 +174,30 @@  static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = {
 			dwc3_of_simple_runtime_resume, NULL)
 };
 
+static const struct dwc3_of_simple_data dwc3_of_simple_data_rk3399 = {
+	.need_reset = true,
+};
+
 static const struct of_device_id of_dwc3_simple_match[] = {
-	{ .compatible = "allwinner,sun50i-h6-dwc3" },
-	{ .compatible = "cavium,octeon-7130-usb-uctl" },
-	{ .compatible = "hisilicon,hi3670-dwc3" },
-	{ .compatible = "intel,keembay-dwc3" },
-	{ .compatible = "rockchip,rk3399-dwc3" },
-	{ .compatible = "sprd,sc9860-dwc3" },
+	{
+		.compatible = "allwinner,sun50i-h6-dwc3",
+	},
+	{
+		.compatible = "cavium,octeon-7130-usb-uctl",
+	},
+	{
+		.compatible = "hisilicon,hi3670-dwc3",
+	},
+	{
+		.compatible = "intel,keembay-dwc3",
+	},
+	{
+		.compatible = "rockchip,rk3399-dwc3",
+		.data = &dwc3_of_simple_data_rk3399,
+	},
+	{
+		.compatible = "sprd,sc9860-dwc3",
+	},
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, of_dwc3_simple_match);