hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/usb/renesas_usbhs/common.c
....@@ -3,15 +3,17 @@
33 * Renesas USB driver
44 *
55 * Copyright (C) 2011 Renesas Solutions Corp.
6
+ * Copyright (C) 2019 Renesas Electronics Corporation
67 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
78 */
9
+#include <linux/clk.h>
810 #include <linux/err.h>
9
-#include <linux/gpio.h>
11
+#include <linux/gpio/consumer.h>
1012 #include <linux/io.h>
1113 #include <linux/module.h>
1214 #include <linux/of_device.h>
13
-#include <linux/of_gpio.h>
1415 #include <linux/pm_runtime.h>
16
+#include <linux/reset.h>
1517 #include <linux/slab.h>
1618 #include <linux/sysfs.h>
1719 #include "common.h"
....@@ -41,15 +43,6 @@
4143 * | .... | +-----------+
4244 */
4345
44
-
45
-#define USBHSF_RUNTIME_PWCTRL (1 << 0)
46
-
47
-/* status */
48
-#define usbhsc_flags_init(p) do {(p)->flags = 0; } while (0)
49
-#define usbhsc_flags_set(p, b) ((p)->flags |= (b))
50
-#define usbhsc_flags_clr(p, b) ((p)->flags &= ~(b))
51
-#define usbhsc_flags_has(p, b) ((p)->flags & (b))
52
-
5346 /*
5447 * platform call back
5548 *
....@@ -59,8 +52,8 @@
5952 */
6053 #define usbhs_platform_call(priv, func, args...)\
6154 (!(priv) ? -ENODEV : \
62
- !((priv)->pfunc.func) ? 0 : \
63
- (priv)->pfunc.func(args))
55
+ !((priv)->pfunc->func) ? 0 : \
56
+ (priv)->pfunc->func(args))
6457
6558 /*
6659 * common functions
....@@ -90,6 +83,11 @@
9083 return dev_get_drvdata(&pdev->dev);
9184 }
9285
86
+int usbhs_get_id_as_gadget(struct platform_device *pdev)
87
+{
88
+ return USBHS_GADGET;
89
+}
90
+
9391 /*
9492 * syscfg functions
9593 */
....@@ -102,10 +100,6 @@
102100 {
103101 u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
104102 u16 val = DCFM | DRPD | HSE | USBE;
105
- int has_otg = usbhs_get_dparam(priv, has_otg);
106
-
107
- if (has_otg)
108
- usbhs_bset(priv, DVSTCTR, (EXTLP | PWEN), (EXTLP | PWEN));
109103
110104 /*
111105 * if enable
....@@ -120,6 +114,12 @@
120114 {
121115 u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
122116 u16 val = HSE | USBE;
117
+
118
+ /* CNEN bit is required for function operation */
119
+ if (usbhs_get_dparam(priv, has_cnen)) {
120
+ mask |= CNEN;
121
+ val |= CNEN;
122
+ }
123123
124124 /*
125125 * if enable
....@@ -161,17 +161,17 @@
161161 req->bRequest = (val >> 8) & 0xFF;
162162 req->bRequestType = (val >> 0) & 0xFF;
163163
164
- req->wValue = usbhs_read(priv, USBVAL);
165
- req->wIndex = usbhs_read(priv, USBINDX);
166
- req->wLength = usbhs_read(priv, USBLENG);
164
+ req->wValue = cpu_to_le16(usbhs_read(priv, USBVAL));
165
+ req->wIndex = cpu_to_le16(usbhs_read(priv, USBINDX));
166
+ req->wLength = cpu_to_le16(usbhs_read(priv, USBLENG));
167167 }
168168
169169 void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
170170 {
171171 usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType);
172
- usbhs_write(priv, USBVAL, req->wValue);
173
- usbhs_write(priv, USBINDX, req->wIndex);
174
- usbhs_write(priv, USBLENG, req->wLength);
172
+ usbhs_write(priv, USBVAL, le16_to_cpu(req->wValue));
173
+ usbhs_write(priv, USBINDX, le16_to_cpu(req->wIndex));
174
+ usbhs_write(priv, USBLENG, le16_to_cpu(req->wLength));
175175
176176 usbhs_bset(priv, DCPCTR, SUREQ, SUREQ);
177177 }
....@@ -290,6 +290,75 @@
290290 usbhs_bset(priv, BUSWAIT, 0x000F, wait);
291291 }
292292
293
+static bool usbhsc_is_multi_clks(struct usbhs_priv *priv)
294
+{
295
+ return priv->dparam.multi_clks;
296
+}
297
+
298
+static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv)
299
+{
300
+ if (!usbhsc_is_multi_clks(priv))
301
+ return 0;
302
+
303
+ /* The first clock should exist */
304
+ priv->clks[0] = of_clk_get(dev_of_node(dev), 0);
305
+ if (IS_ERR(priv->clks[0]))
306
+ return PTR_ERR(priv->clks[0]);
307
+
308
+ /*
309
+ * To backward compatibility with old DT, this driver checks the return
310
+ * value if it's -ENOENT or not.
311
+ */
312
+ priv->clks[1] = of_clk_get(dev_of_node(dev), 1);
313
+ if (PTR_ERR(priv->clks[1]) == -ENOENT)
314
+ priv->clks[1] = NULL;
315
+ else if (IS_ERR(priv->clks[1]))
316
+ return PTR_ERR(priv->clks[1]);
317
+
318
+ return 0;
319
+}
320
+
321
+static void usbhsc_clk_put(struct usbhs_priv *priv)
322
+{
323
+ int i;
324
+
325
+ if (!usbhsc_is_multi_clks(priv))
326
+ return;
327
+
328
+ for (i = 0; i < ARRAY_SIZE(priv->clks); i++)
329
+ clk_put(priv->clks[i]);
330
+}
331
+
332
+static int usbhsc_clk_prepare_enable(struct usbhs_priv *priv)
333
+{
334
+ int i, ret;
335
+
336
+ if (!usbhsc_is_multi_clks(priv))
337
+ return 0;
338
+
339
+ for (i = 0; i < ARRAY_SIZE(priv->clks); i++) {
340
+ ret = clk_prepare_enable(priv->clks[i]);
341
+ if (ret) {
342
+ while (--i >= 0)
343
+ clk_disable_unprepare(priv->clks[i]);
344
+ return ret;
345
+ }
346
+ }
347
+
348
+ return ret;
349
+}
350
+
351
+static void usbhsc_clk_disable_unprepare(struct usbhs_priv *priv)
352
+{
353
+ int i;
354
+
355
+ if (!usbhsc_is_multi_clks(priv))
356
+ return;
357
+
358
+ for (i = 0; i < ARRAY_SIZE(priv->clks); i++)
359
+ clk_disable_unprepare(priv->clks[i]);
360
+}
361
+
293362 /*
294363 * platform default param
295364 */
....@@ -340,6 +409,10 @@
340409 /* enable PM */
341410 pm_runtime_get_sync(dev);
342411
412
+ /* enable clks */
413
+ if (usbhsc_clk_prepare_enable(priv))
414
+ return;
415
+
343416 /* enable platform power */
344417 usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable);
345418
....@@ -351,6 +424,9 @@
351424
352425 /* disable platform power */
353426 usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable);
427
+
428
+ /* disable clks */
429
+ usbhsc_clk_disable_unprepare(priv);
354430
355431 /* disable PM */
356432 pm_runtime_put_sync(dev);
....@@ -372,7 +448,7 @@
372448 /*
373449 * get vbus status from platform
374450 */
375
- enable = usbhs_platform_call(priv, get_vbus, pdev);
451
+ enable = usbhs_mod_info_call(priv, get_vbus, pdev);
376452
377453 /*
378454 * get id from platform
....@@ -397,7 +473,7 @@
397473 dev_dbg(&pdev->dev, "%s enable\n", __func__);
398474
399475 /* power on */
400
- if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
476
+ if (usbhs_get_dparam(priv, runtime_pwctrl))
401477 usbhsc_power_ctrl(priv, enable);
402478
403479 /* bus init */
....@@ -417,7 +493,7 @@
417493 usbhsc_bus_init(priv);
418494
419495 /* power off */
420
- if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
496
+ if (usbhs_get_dparam(priv, runtime_pwctrl))
421497 usbhsc_power_ctrl(priv, enable);
422498
423499 usbhs_mod_change(priv, -1);
....@@ -438,7 +514,7 @@
438514 usbhsc_hotplug(priv);
439515 }
440516
441
-static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
517
+int usbhsc_schedule_notify_hotplug(struct platform_device *pdev)
442518 {
443519 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
444520 int delay = usbhs_get_dparam(priv, detection_delay);
....@@ -459,182 +535,136 @@
459535 static const struct of_device_id usbhs_of_match[] = {
460536 {
461537 .compatible = "renesas,usbhs-r8a774c0",
462
- .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL,
538
+ .data = &usbhs_rcar_gen3_with_pll_plat_info,
463539 },
464540 {
465541 .compatible = "renesas,usbhs-r8a7790",
466
- .data = (void *)USBHS_TYPE_RCAR_GEN2,
542
+ .data = &usbhs_rcar_gen2_plat_info,
467543 },
468544 {
469545 .compatible = "renesas,usbhs-r8a7791",
470
- .data = (void *)USBHS_TYPE_RCAR_GEN2,
546
+ .data = &usbhs_rcar_gen2_plat_info,
471547 },
472548 {
473549 .compatible = "renesas,usbhs-r8a7794",
474
- .data = (void *)USBHS_TYPE_RCAR_GEN2,
550
+ .data = &usbhs_rcar_gen2_plat_info,
475551 },
476552 {
477553 .compatible = "renesas,usbhs-r8a7795",
478
- .data = (void *)USBHS_TYPE_RCAR_GEN3,
554
+ .data = &usbhs_rcar_gen3_plat_info,
479555 },
480556 {
481557 .compatible = "renesas,usbhs-r8a7796",
482
- .data = (void *)USBHS_TYPE_RCAR_GEN3,
558
+ .data = &usbhs_rcar_gen3_plat_info,
559
+ },
560
+ {
561
+ .compatible = "renesas,usbhs-r8a77990",
562
+ .data = &usbhs_rcar_gen3_with_pll_plat_info,
483563 },
484564 {
485565 .compatible = "renesas,usbhs-r8a77995",
486
- .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL,
566
+ .data = &usbhs_rcar_gen3_with_pll_plat_info,
487567 },
488568 {
489569 .compatible = "renesas,rcar-gen2-usbhs",
490
- .data = (void *)USBHS_TYPE_RCAR_GEN2,
570
+ .data = &usbhs_rcar_gen2_plat_info,
491571 },
492572 {
493573 .compatible = "renesas,rcar-gen3-usbhs",
494
- .data = (void *)USBHS_TYPE_RCAR_GEN3,
574
+ .data = &usbhs_rcar_gen3_plat_info,
495575 },
496576 {
497577 .compatible = "renesas,rza1-usbhs",
498
- .data = (void *)USBHS_TYPE_RZA1,
578
+ .data = &usbhs_rza1_plat_info,
579
+ },
580
+ {
581
+ .compatible = "renesas,rza2-usbhs",
582
+ .data = &usbhs_rza2_plat_info,
499583 },
500584 { },
501585 };
502586 MODULE_DEVICE_TABLE(of, usbhs_of_match);
503587
504
-static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
505
-{
506
- struct renesas_usbhs_platform_info *info;
507
- struct renesas_usbhs_driver_param *dparam;
508
- u32 tmp;
509
- int gpio;
510
-
511
- info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
512
- if (!info)
513
- return NULL;
514
-
515
- dparam = &info->driver_param;
516
- dparam->type = (uintptr_t)of_device_get_match_data(dev);
517
- if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
518
- dparam->buswait_bwait = tmp;
519
- gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
520
- NULL);
521
- if (gpio > 0)
522
- dparam->enable_gpio = gpio;
523
-
524
- if (dparam->type == USBHS_TYPE_RCAR_GEN2 ||
525
- dparam->type == USBHS_TYPE_RCAR_GEN3 ||
526
- dparam->type == USBHS_TYPE_RCAR_GEN3_WITH_PLL) {
527
- dparam->has_usb_dmac = 1;
528
- dparam->pipe_configs = usbhsc_new_pipe;
529
- dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
530
- }
531
-
532
- if (dparam->type == USBHS_TYPE_RZA1) {
533
- dparam->pipe_configs = usbhsc_new_pipe;
534
- dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
535
- }
536
-
537
- return info;
538
-}
539
-
540588 static int usbhs_probe(struct platform_device *pdev)
541589 {
542
- struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
543
- struct renesas_usbhs_driver_callback *dfunc;
590
+ const struct renesas_usbhs_platform_info *info;
544591 struct usbhs_priv *priv;
545
- struct resource *res, *irq_res;
592
+ struct resource *irq_res;
593
+ struct device *dev = &pdev->dev;
594
+ struct gpio_desc *gpiod;
546595 int ret;
596
+ u32 tmp;
547597
548598 /* check device node */
549
- if (pdev->dev.of_node)
550
- info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
599
+ if (dev_of_node(dev))
600
+ info = of_device_get_match_data(dev);
601
+ else
602
+ info = renesas_usbhs_get_info(pdev);
551603
552604 /* check platform information */
553605 if (!info) {
554
- dev_err(&pdev->dev, "no platform information\n");
606
+ dev_err(dev, "no platform information\n");
555607 return -EINVAL;
556608 }
557609
558610 /* platform data */
559611 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
560612 if (!irq_res) {
561
- dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n");
613
+ dev_err(dev, "Not enough Renesas USB platform resources.\n");
562614 return -ENODEV;
563615 }
564616
565617 /* usb private data */
566
- priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
618
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
567619 if (!priv)
568620 return -ENOMEM;
569621
570
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
571
- priv->base = devm_ioremap_resource(&pdev->dev, res);
622
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
572623 if (IS_ERR(priv->base))
573624 return PTR_ERR(priv->base);
574625
575
- if (of_property_read_bool(pdev->dev.of_node, "extcon")) {
576
- priv->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
626
+ if (of_property_read_bool(dev_of_node(dev), "extcon")) {
627
+ priv->edev = extcon_get_edev_by_phandle(dev, 0);
577628 if (IS_ERR(priv->edev))
578629 return PTR_ERR(priv->edev);
579630 }
631
+
632
+ priv->rsts = devm_reset_control_array_get_optional_shared(dev);
633
+ if (IS_ERR(priv->rsts))
634
+ return PTR_ERR(priv->rsts);
580635
581636 /*
582637 * care platform info
583638 */
584639
585
- memcpy(&priv->dparam,
586
- &info->driver_param,
587
- sizeof(struct renesas_usbhs_driver_param));
640
+ priv->dparam = info->driver_param;
588641
589
- switch (priv->dparam.type) {
590
- case USBHS_TYPE_RCAR_GEN2:
591
- priv->pfunc = usbhs_rcar2_ops;
592
- break;
593
- case USBHS_TYPE_RCAR_GEN3:
594
- priv->pfunc = usbhs_rcar3_ops;
595
- break;
596
- case USBHS_TYPE_RCAR_GEN3_WITH_PLL:
597
- priv->pfunc = usbhs_rcar3_with_pll_ops;
598
- if (!IS_ERR_OR_NULL(priv->edev)) {
599
- priv->nb.notifier_call = priv->pfunc.notifier;
600
- ret = devm_extcon_register_notifier(&pdev->dev,
601
- priv->edev,
602
- EXTCON_USB_HOST,
603
- &priv->nb);
604
- if (ret < 0)
605
- dev_err(&pdev->dev, "no notifier registered\n");
606
- }
607
- break;
608
- case USBHS_TYPE_RZA1:
609
- priv->pfunc = usbhs_rza1_ops;
610
- break;
611
- default:
612
- if (!info->platform_callback.get_id) {
613
- dev_err(&pdev->dev, "no platform callbacks");
614
- return -EINVAL;
615
- }
616
- memcpy(&priv->pfunc,
617
- &info->platform_callback,
618
- sizeof(struct renesas_usbhs_platform_callback));
619
- break;
642
+ if (!info->platform_callback.get_id) {
643
+ dev_err(dev, "no platform callbacks\n");
644
+ return -EINVAL;
620645 }
621
-
622
- /* set driver callback functions for platform */
623
- dfunc = &info->driver_callback;
624
- dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug;
646
+ priv->pfunc = &info->platform_callback;
625647
626648 /* set default param if platform doesn't have */
627
- if (!priv->dparam.pipe_configs) {
649
+ if (usbhs_get_dparam(priv, has_new_pipe_configs)) {
650
+ priv->dparam.pipe_configs = usbhsc_new_pipe;
651
+ priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
652
+ } else if (!priv->dparam.pipe_configs) {
628653 priv->dparam.pipe_configs = usbhsc_default_pipe;
629654 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe);
630655 }
631656 if (!priv->dparam.pio_dma_border)
632657 priv->dparam.pio_dma_border = 64; /* 64byte */
658
+ if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp))
659
+ priv->dparam.buswait_bwait = tmp;
660
+ gpiod = devm_gpiod_get_optional(dev, "renesas,enable", GPIOD_IN);
661
+ if (IS_ERR(gpiod))
662
+ return PTR_ERR(gpiod);
633663
634664 /* FIXME */
635665 /* runtime power control ? */
636
- if (priv->pfunc.get_vbus)
637
- usbhsc_flags_set(priv, USBHSF_RUNTIME_PWCTRL);
666
+ if (priv->pfunc->get_vbus)
667
+ usbhs_get_dparam(priv, runtime_pwctrl) = 1;
638668
639669 /*
640670 * priv settings
....@@ -662,6 +692,14 @@
662692 /* dev_set_drvdata should be called after usbhs_mod_init */
663693 platform_set_drvdata(pdev, priv);
664694
695
+ ret = reset_control_deassert(priv->rsts);
696
+ if (ret)
697
+ goto probe_fail_rst;
698
+
699
+ ret = usbhsc_clk_get(dev, priv);
700
+ if (ret)
701
+ goto probe_fail_clks;
702
+
665703 /*
666704 * deviece reset here because
667705 * USB device might be used in boot loader.
....@@ -669,14 +707,10 @@
669707 usbhs_sys_clock_ctrl(priv, 0);
670708
671709 /* check GPIO determining if USB function should be enabled */
672
- if (priv->dparam.enable_gpio) {
673
- gpio_request_one(priv->dparam.enable_gpio, GPIOF_IN, NULL);
674
- ret = !gpio_get_value(priv->dparam.enable_gpio);
675
- gpio_free(priv->dparam.enable_gpio);
710
+ if (gpiod) {
711
+ ret = !gpiod_get_value(gpiod);
676712 if (ret) {
677
- dev_warn(&pdev->dev,
678
- "USB function not selected (GPIO %d)\n",
679
- priv->dparam.enable_gpio);
713
+ dev_warn(dev, "USB function not selected (GPIO)\n");
680714 ret = -ENOTSUPP;
681715 goto probe_end_mod_exit;
682716 }
....@@ -691,7 +725,7 @@
691725 */
692726 ret = usbhs_platform_call(priv, hardware_init, pdev);
693727 if (ret < 0) {
694
- dev_err(&pdev->dev, "platform init failed.\n");
728
+ dev_err(dev, "platform init failed.\n");
695729 goto probe_end_mod_exit;
696730 }
697731
....@@ -699,29 +733,35 @@
699733 usbhs_platform_call(priv, phy_reset, pdev);
700734
701735 /* power control */
702
- pm_runtime_enable(&pdev->dev);
703
- if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
736
+ pm_runtime_enable(dev);
737
+ if (!usbhs_get_dparam(priv, runtime_pwctrl)) {
704738 usbhsc_power_ctrl(priv, 1);
705739 usbhs_mod_autonomy_mode(priv);
740
+ } else {
741
+ usbhs_mod_non_autonomy_mode(priv);
706742 }
707743
708744 /*
709745 * manual call notify_hotplug for cold plug
710746 */
711
- usbhsc_drvcllbck_notify_hotplug(pdev);
747
+ usbhsc_schedule_notify_hotplug(pdev);
712748
713
- dev_info(&pdev->dev, "probed\n");
749
+ dev_info(dev, "probed\n");
714750
715751 return ret;
716752
717753 probe_end_mod_exit:
754
+ usbhsc_clk_put(priv);
755
+probe_fail_clks:
756
+ reset_control_assert(priv->rsts);
757
+probe_fail_rst:
718758 usbhs_mod_remove(priv);
719759 probe_end_fifo_exit:
720760 usbhs_fifo_remove(priv);
721761 probe_end_pipe_exit:
722762 usbhs_pipe_remove(priv);
723763
724
- dev_info(&pdev->dev, "probe failed (%d)\n", ret);
764
+ dev_info(dev, "probe failed (%d)\n", ret);
725765
726766 return ret;
727767 }
....@@ -729,20 +769,18 @@
729769 static int usbhs_remove(struct platform_device *pdev)
730770 {
731771 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
732
- struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
733
- struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback;
734772
735773 dev_dbg(&pdev->dev, "usb remove\n");
736774
737
- dfunc->notify_hotplug = NULL;
738
-
739775 /* power off */
740
- if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
776
+ if (!usbhs_get_dparam(priv, runtime_pwctrl))
741777 usbhsc_power_ctrl(priv, 0);
742778
743779 pm_runtime_disable(&pdev->dev);
744780
745781 usbhs_platform_call(priv, hardware_exit, pdev);
782
+ usbhsc_clk_put(priv);
783
+ reset_control_assert(priv->rsts);
746784 usbhs_mod_remove(priv);
747785 usbhs_fifo_remove(priv);
748786 usbhs_pipe_remove(priv);
....@@ -750,7 +788,7 @@
750788 return 0;
751789 }
752790
753
-static int usbhsc_suspend(struct device *dev)
791
+static __maybe_unused int usbhsc_suspend(struct device *dev)
754792 {
755793 struct usbhs_priv *priv = dev_get_drvdata(dev);
756794 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
....@@ -760,47 +798,30 @@
760798 usbhs_mod_change(priv, -1);
761799 }
762800
763
- if (mod || !usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
801
+ if (mod || !usbhs_get_dparam(priv, runtime_pwctrl))
764802 usbhsc_power_ctrl(priv, 0);
765803
766804 return 0;
767805 }
768806
769
-static int usbhsc_resume(struct device *dev)
807
+static __maybe_unused int usbhsc_resume(struct device *dev)
770808 {
771809 struct usbhs_priv *priv = dev_get_drvdata(dev);
772810 struct platform_device *pdev = usbhs_priv_to_pdev(priv);
773811
774
- if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
812
+ if (!usbhs_get_dparam(priv, runtime_pwctrl)) {
775813 usbhsc_power_ctrl(priv, 1);
776814 usbhs_mod_autonomy_mode(priv);
777815 }
778816
779817 usbhs_platform_call(priv, phy_reset, pdev);
780818
781
- usbhsc_drvcllbck_notify_hotplug(pdev);
819
+ usbhsc_schedule_notify_hotplug(pdev);
782820
783821 return 0;
784822 }
785823
786
-static int usbhsc_runtime_nop(struct device *dev)
787
-{
788
- /* Runtime PM callback shared between ->runtime_suspend()
789
- * and ->runtime_resume(). Simply returns success.
790
- *
791
- * This driver re-initializes all registers after
792
- * pm_runtime_get_sync() anyway so there is no need
793
- * to save and restore registers here.
794
- */
795
- return 0;
796
-}
797
-
798
-static const struct dev_pm_ops usbhsc_pm_ops = {
799
- .suspend = usbhsc_suspend,
800
- .resume = usbhsc_resume,
801
- .runtime_suspend = usbhsc_runtime_nop,
802
- .runtime_resume = usbhsc_runtime_nop,
803
-};
824
+static SIMPLE_DEV_PM_OPS(usbhsc_pm_ops, usbhsc_suspend, usbhsc_resume);
804825
805826 static struct platform_driver renesas_usbhs_driver = {
806827 .driver = {