Merge tag 'ptrace-cleanups-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / drivers / phy / broadcom / phy-brcm-usb.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * phy-brcm-usb.c - Broadcom USB Phy Driver
4  *
5  * Copyright (C) 2015-2017 Broadcom
6  */
7
8 #include <linux/clk.h>
9 #include <linux/delay.h>
10 #include <linux/err.h>
11 #include <linux/io.h>
12 #include <linux/module.h>
13 #include <linux/of.h>
14 #include <linux/of_device.h>
15 #include <linux/phy/phy.h>
16 #include <linux/platform_device.h>
17 #include <linux/interrupt.h>
18 #include <linux/soc/brcmstb/brcmstb.h>
19 #include <dt-bindings/phy/phy.h>
20 #include <linux/mfd/syscon.h>
21 #include <linux/suspend.h>
22
23 #include "phy-brcm-usb-init.h"
24
25 static DEFINE_MUTEX(sysfs_lock);
26
27 enum brcm_usb_phy_id {
28         BRCM_USB_PHY_2_0 = 0,
29         BRCM_USB_PHY_3_0,
30         BRCM_USB_PHY_ID_MAX
31 };
32
33 struct value_to_name_map {
34         int value;
35         const char *name;
36 };
37
38 struct match_chip_info {
39         void (*init_func)(struct brcm_usb_init_params *params);
40         u8 required_regs[BRCM_REGS_MAX + 1];
41         u8 optional_reg;
42 };
43
44 static const struct value_to_name_map brcm_dr_mode_to_name[] = {
45         { USB_CTLR_MODE_HOST, "host" },
46         { USB_CTLR_MODE_DEVICE, "peripheral" },
47         { USB_CTLR_MODE_DRD, "drd" },
48         { USB_CTLR_MODE_TYPEC_PD, "typec-pd" }
49 };
50
51 static const struct value_to_name_map brcm_dual_mode_to_name[] = {
52         { 0, "host" },
53         { 1, "device" },
54         { 2, "auto" },
55 };
56
57 struct brcm_usb_phy {
58         struct phy *phy;
59         unsigned int id;
60         bool inited;
61 };
62
63 struct brcm_usb_phy_data {
64         struct  brcm_usb_init_params ini;
65         bool                    has_eohci;
66         bool                    has_xhci;
67         struct clk              *usb_20_clk;
68         struct clk              *usb_30_clk;
69         struct clk              *suspend_clk;
70         struct mutex            mutex;  /* serialize phy init */
71         int                     init_count;
72         int                     wake_irq;
73         struct brcm_usb_phy     phys[BRCM_USB_PHY_ID_MAX];
74         struct notifier_block   pm_notifier;
75         bool                    pm_active;
76 };
77
78 static s8 *node_reg_names[BRCM_REGS_MAX] = {
79         "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec"
80 };
81
82 static int brcm_pm_notifier(struct notifier_block *notifier,
83                             unsigned long pm_event,
84                             void *unused)
85 {
86         struct brcm_usb_phy_data *priv =
87                 container_of(notifier, struct brcm_usb_phy_data, pm_notifier);
88
89         switch (pm_event) {
90         case PM_HIBERNATION_PREPARE:
91         case PM_SUSPEND_PREPARE:
92                 priv->pm_active = true;
93                 break;
94         case PM_POST_RESTORE:
95         case PM_POST_HIBERNATION:
96         case PM_POST_SUSPEND:
97                 priv->pm_active = false;
98                 break;
99         }
100         return NOTIFY_DONE;
101 }
102
103 static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id)
104 {
105         struct phy *gphy = dev_id;
106
107         pm_wakeup_event(&gphy->dev, 0);
108
109         return IRQ_HANDLED;
110 }
111
112 static int brcm_usb_phy_init(struct phy *gphy)
113 {
114         struct brcm_usb_phy *phy = phy_get_drvdata(gphy);
115         struct brcm_usb_phy_data *priv =
116                 container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
117
118         if (priv->pm_active)
119                 return 0;
120
121         /*
122          * Use a lock to make sure a second caller waits until
123          * the base phy is inited before using it.
124          */
125         mutex_lock(&priv->mutex);
126         if (priv->init_count++ == 0) {
127                 clk_prepare_enable(priv->usb_20_clk);
128                 clk_prepare_enable(priv->usb_30_clk);
129                 clk_prepare_enable(priv->suspend_clk);
130                 brcm_usb_init_common(&priv->ini);
131         }
132         mutex_unlock(&priv->mutex);
133         if (phy->id == BRCM_USB_PHY_2_0)
134                 brcm_usb_init_eohci(&priv->ini);
135         else if (phy->id == BRCM_USB_PHY_3_0)
136                 brcm_usb_init_xhci(&priv->ini);
137         phy->inited = true;
138         dev_dbg(&gphy->dev, "INIT, id: %d, total: %d\n", phy->id,
139                 priv->init_count);
140
141         return 0;
142 }
143
144 static int brcm_usb_phy_exit(struct phy *gphy)
145 {
146         struct brcm_usb_phy *phy = phy_get_drvdata(gphy);
147         struct brcm_usb_phy_data *priv =
148                 container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
149
150         if (priv->pm_active)
151                 return 0;
152
153         dev_dbg(&gphy->dev, "EXIT\n");
154         if (phy->id == BRCM_USB_PHY_2_0)
155                 brcm_usb_uninit_eohci(&priv->ini);
156         if (phy->id == BRCM_USB_PHY_3_0)
157                 brcm_usb_uninit_xhci(&priv->ini);
158
159         /* If both xhci and eohci are gone, reset everything else */
160         mutex_lock(&priv->mutex);
161         if (--priv->init_count == 0) {
162                 brcm_usb_uninit_common(&priv->ini);
163                 clk_disable_unprepare(priv->usb_20_clk);
164                 clk_disable_unprepare(priv->usb_30_clk);
165                 clk_disable_unprepare(priv->suspend_clk);
166         }
167         mutex_unlock(&priv->mutex);
168         phy->inited = false;
169         return 0;
170 }
171
172 static const struct phy_ops brcm_usb_phy_ops = {
173         .init           = brcm_usb_phy_init,
174         .exit           = brcm_usb_phy_exit,
175         .owner          = THIS_MODULE,
176 };
177
178 static struct phy *brcm_usb_phy_xlate(struct device *dev,
179                                       struct of_phandle_args *args)
180 {
181         struct brcm_usb_phy_data *data = dev_get_drvdata(dev);
182
183         /*
184          * values 0 and 1 are for backward compatibility with
185          * device tree nodes from older bootloaders.
186          */
187         switch (args->args[0]) {
188         case 0:
189         case PHY_TYPE_USB2:
190                 if (data->phys[BRCM_USB_PHY_2_0].phy)
191                         return data->phys[BRCM_USB_PHY_2_0].phy;
192                 dev_warn(dev, "Error, 2.0 Phy not found\n");
193                 break;
194         case 1:
195         case PHY_TYPE_USB3:
196                 if (data->phys[BRCM_USB_PHY_3_0].phy)
197                         return data->phys[BRCM_USB_PHY_3_0].phy;
198                 dev_warn(dev, "Error, 3.0 Phy not found\n");
199                 break;
200         }
201         return ERR_PTR(-ENODEV);
202 }
203
204 static int name_to_value(const struct value_to_name_map *table, int count,
205                          const char *name, int *value)
206 {
207         int x;
208
209         *value = 0;
210         for (x = 0; x < count; x++) {
211                 if (sysfs_streq(name, table[x].name)) {
212                         *value = x;
213                         return 0;
214                 }
215         }
216         return -EINVAL;
217 }
218
219 static const char *value_to_name(const struct value_to_name_map *table, int count,
220                                  int value)
221 {
222         if (value >= count)
223                 return "unknown";
224         return table[value].name;
225 }
226
227 static ssize_t dr_mode_show(struct device *dev,
228                             struct device_attribute *attr,
229                             char *buf)
230 {
231         struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
232
233         return sprintf(buf, "%s\n",
234                 value_to_name(&brcm_dr_mode_to_name[0],
235                               ARRAY_SIZE(brcm_dr_mode_to_name),
236                               priv->ini.mode));
237 }
238 static DEVICE_ATTR_RO(dr_mode);
239
240 static ssize_t dual_select_store(struct device *dev,
241                                  struct device_attribute *attr,
242                                  const char *buf, size_t len)
243 {
244         struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
245         int value;
246         int res;
247
248         mutex_lock(&sysfs_lock);
249         res = name_to_value(&brcm_dual_mode_to_name[0],
250                             ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value);
251         if (!res) {
252                 brcm_usb_set_dual_select(&priv->ini, value);
253                 res = len;
254         }
255         mutex_unlock(&sysfs_lock);
256         return res;
257 }
258
259 static ssize_t dual_select_show(struct device *dev,
260                                 struct device_attribute *attr,
261                                 char *buf)
262 {
263         struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
264         int value;
265
266         mutex_lock(&sysfs_lock);
267         value = brcm_usb_get_dual_select(&priv->ini);
268         mutex_unlock(&sysfs_lock);
269         return sprintf(buf, "%s\n",
270                 value_to_name(&brcm_dual_mode_to_name[0],
271                               ARRAY_SIZE(brcm_dual_mode_to_name),
272                               value));
273 }
274 static DEVICE_ATTR_RW(dual_select);
275
276 static struct attribute *brcm_usb_phy_attrs[] = {
277         &dev_attr_dr_mode.attr,
278         &dev_attr_dual_select.attr,
279         NULL
280 };
281
282 static const struct attribute_group brcm_usb_phy_group = {
283         .attrs = brcm_usb_phy_attrs,
284 };
285
286 static const struct match_chip_info chip_info_4908 = {
287         .init_func = &brcm_usb_dvr_init_4908,
288         .required_regs = {
289                 BRCM_REGS_CTRL,
290                 BRCM_REGS_XHCI_EC,
291                 -1,
292         },
293 };
294
295 static const struct match_chip_info chip_info_7216 = {
296         .init_func = &brcm_usb_dvr_init_7216,
297         .required_regs = {
298                 BRCM_REGS_CTRL,
299                 BRCM_REGS_XHCI_EC,
300                 BRCM_REGS_XHCI_GBL,
301                 -1,
302         },
303 };
304
305 static const struct match_chip_info chip_info_7211b0 = {
306         .init_func = &brcm_usb_dvr_init_7211b0,
307         .required_regs = {
308                 BRCM_REGS_CTRL,
309                 BRCM_REGS_XHCI_EC,
310                 BRCM_REGS_XHCI_GBL,
311                 BRCM_REGS_USB_PHY,
312                 BRCM_REGS_USB_MDIO,
313                 -1,
314         },
315         .optional_reg = BRCM_REGS_BDC_EC,
316 };
317
318 static const struct match_chip_info chip_info_7445 = {
319         .init_func = &brcm_usb_dvr_init_7445,
320         .required_regs = {
321                 BRCM_REGS_CTRL,
322                 BRCM_REGS_XHCI_EC,
323                 -1,
324         },
325 };
326
327 static const struct of_device_id brcm_usb_dt_ids[] = {
328         {
329                 .compatible = "brcm,bcm4908-usb-phy",
330                 .data = &chip_info_4908,
331         },
332         {
333                 .compatible = "brcm,bcm7216-usb-phy",
334                 .data = &chip_info_7216,
335         },
336         {
337                 .compatible = "brcm,bcm7211-usb-phy",
338                 .data = &chip_info_7211b0,
339         },
340         {
341                 .compatible = "brcm,brcmstb-usb-phy",
342                 .data = &chip_info_7445,
343         },
344         { /* sentinel */ }
345 };
346
347 static int brcm_usb_get_regs(struct platform_device *pdev,
348                              enum brcmusb_reg_sel regs,
349                              struct  brcm_usb_init_params *ini,
350                              bool optional)
351 {
352         struct resource *res;
353
354         /* Older DT nodes have ctrl and optional xhci_ec by index only */
355         res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
356                                                 node_reg_names[regs]);
357         if (res == NULL) {
358                 if (regs == BRCM_REGS_CTRL) {
359                         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
360                 } else if (regs == BRCM_REGS_XHCI_EC) {
361                         res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
362                         /* XHCI_EC registers are optional */
363                         if (res == NULL)
364                                 return 0;
365                 }
366                 if (res == NULL) {
367                         if (optional) {
368                                 dev_dbg(&pdev->dev,
369                                         "Optional reg %s not found\n",
370                                         node_reg_names[regs]);
371                                 return 0;
372                         }
373                         dev_err(&pdev->dev, "can't get %s base addr\n",
374                                 node_reg_names[regs]);
375                         return 1;
376                 }
377         }
378         ini->regs[regs] = devm_ioremap_resource(&pdev->dev, res);
379         if (IS_ERR(ini->regs[regs])) {
380                 dev_err(&pdev->dev, "can't map %s register space\n",
381                         node_reg_names[regs]);
382                 return 1;
383         }
384         return 0;
385 }
386
387 static int brcm_usb_phy_dvr_init(struct platform_device *pdev,
388                                  struct brcm_usb_phy_data *priv,
389                                  struct device_node *dn)
390 {
391         struct device *dev = &pdev->dev;
392         struct phy *gphy = NULL;
393         int err;
394
395         priv->usb_20_clk = of_clk_get_by_name(dn, "sw_usb");
396         if (IS_ERR(priv->usb_20_clk)) {
397                 if (PTR_ERR(priv->usb_20_clk) == -EPROBE_DEFER)
398                         return -EPROBE_DEFER;
399                 dev_info(dev, "Clock not found in Device Tree\n");
400                 priv->usb_20_clk = NULL;
401         }
402         err = clk_prepare_enable(priv->usb_20_clk);
403         if (err)
404                 return err;
405
406         if (priv->has_eohci) {
407                 gphy = devm_phy_create(dev, NULL, &brcm_usb_phy_ops);
408                 if (IS_ERR(gphy)) {
409                         dev_err(dev, "failed to create EHCI/OHCI PHY\n");
410                         return PTR_ERR(gphy);
411                 }
412                 priv->phys[BRCM_USB_PHY_2_0].phy = gphy;
413                 priv->phys[BRCM_USB_PHY_2_0].id = BRCM_USB_PHY_2_0;
414                 phy_set_drvdata(gphy, &priv->phys[BRCM_USB_PHY_2_0]);
415         }
416
417         if (priv->has_xhci) {
418                 gphy = devm_phy_create(dev, NULL, &brcm_usb_phy_ops);
419                 if (IS_ERR(gphy)) {
420                         dev_err(dev, "failed to create XHCI PHY\n");
421                         return PTR_ERR(gphy);
422                 }
423                 priv->phys[BRCM_USB_PHY_3_0].phy = gphy;
424                 priv->phys[BRCM_USB_PHY_3_0].id = BRCM_USB_PHY_3_0;
425                 phy_set_drvdata(gphy, &priv->phys[BRCM_USB_PHY_3_0]);
426
427                 priv->usb_30_clk = of_clk_get_by_name(dn, "sw_usb3");
428                 if (IS_ERR(priv->usb_30_clk)) {
429                         if (PTR_ERR(priv->usb_30_clk) == -EPROBE_DEFER)
430                                 return -EPROBE_DEFER;
431                         dev_info(dev,
432                                  "USB3.0 clock not found in Device Tree\n");
433                         priv->usb_30_clk = NULL;
434                 }
435                 err = clk_prepare_enable(priv->usb_30_clk);
436                 if (err)
437                         return err;
438         }
439
440         priv->suspend_clk = clk_get(dev, "usb0_freerun");
441         if (IS_ERR(priv->suspend_clk)) {
442                 if (PTR_ERR(priv->suspend_clk) == -EPROBE_DEFER)
443                         return -EPROBE_DEFER;
444                 dev_err(dev, "Suspend Clock not found in Device Tree\n");
445                 priv->suspend_clk = NULL;
446         }
447
448         priv->wake_irq = platform_get_irq_byname(pdev, "wake");
449         if (priv->wake_irq < 0)
450                 priv->wake_irq = platform_get_irq_byname(pdev, "wakeup");
451         if (priv->wake_irq >= 0) {
452                 err = devm_request_irq(dev, priv->wake_irq,
453                                        brcm_usb_phy_wake_isr, 0,
454                                        dev_name(dev), gphy);
455                 if (err < 0)
456                         return err;
457                 device_set_wakeup_capable(dev, 1);
458         } else {
459                 dev_info(dev,
460                          "Wake interrupt missing, system wake not supported\n");
461         }
462
463         return 0;
464 }
465
466 static int brcm_usb_phy_probe(struct platform_device *pdev)
467 {
468         struct device *dev = &pdev->dev;
469         struct brcm_usb_phy_data *priv;
470         struct phy_provider *phy_provider;
471         struct device_node *dn = pdev->dev.of_node;
472         int err;
473         const char *mode;
474         const struct match_chip_info *info;
475         struct regmap *rmap;
476         int x;
477
478         priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
479         if (!priv)
480                 return -ENOMEM;
481         platform_set_drvdata(pdev, priv);
482
483         priv->ini.family_id = brcmstb_get_family_id();
484         priv->ini.product_id = brcmstb_get_product_id();
485
486         info = of_device_get_match_data(&pdev->dev);
487         if (!info)
488                 return -ENOENT;
489
490         info->init_func(&priv->ini);
491
492         dev_dbg(dev, "Best mapping table is for %s\n",
493                 priv->ini.family_name);
494
495         of_property_read_u32(dn, "brcm,ipp", &priv->ini.ipp);
496         of_property_read_u32(dn, "brcm,ioc", &priv->ini.ioc);
497
498         priv->ini.mode = USB_CTLR_MODE_HOST;
499         err = of_property_read_string(dn, "dr_mode", &mode);
500         if (err == 0) {
501                 name_to_value(&brcm_dr_mode_to_name[0],
502                               ARRAY_SIZE(brcm_dr_mode_to_name),
503                         mode, &priv->ini.mode);
504         }
505         if (of_property_read_bool(dn, "brcm,has-xhci"))
506                 priv->has_xhci = true;
507         if (of_property_read_bool(dn, "brcm,has-eohci"))
508                 priv->has_eohci = true;
509
510         for (x = 0; x < BRCM_REGS_MAX; x++) {
511                 if (info->required_regs[x] >= BRCM_REGS_MAX)
512                         break;
513
514                 err = brcm_usb_get_regs(pdev, info->required_regs[x],
515                                         &priv->ini, false);
516                 if (err)
517                         return -EINVAL;
518         }
519         if (info->optional_reg) {
520                 err = brcm_usb_get_regs(pdev, info->optional_reg,
521                                         &priv->ini, true);
522                 if (err)
523                         return -EINVAL;
524         }
525
526         err = brcm_usb_phy_dvr_init(pdev, priv, dn);
527         if (err)
528                 return err;
529
530         priv->pm_notifier.notifier_call = brcm_pm_notifier;
531         register_pm_notifier(&priv->pm_notifier);
532
533         mutex_init(&priv->mutex);
534
535         /* make sure invert settings are correct */
536         brcm_usb_init_ipp(&priv->ini);
537
538         /*
539          * Create sysfs entries for mode.
540          * Remove "dual_select" attribute if not in dual mode
541          */
542         if (priv->ini.mode != USB_CTLR_MODE_DRD)
543                 brcm_usb_phy_attrs[1] = NULL;
544         err = sysfs_create_group(&dev->kobj, &brcm_usb_phy_group);
545         if (err)
546                 dev_warn(dev, "Error creating sysfs attributes\n");
547
548         /* Get piarbctl syscon if it exists */
549         rmap = syscon_regmap_lookup_by_phandle(dev->of_node,
550                                                  "syscon-piarbctl");
551         if (IS_ERR(rmap))
552                 rmap = syscon_regmap_lookup_by_phandle(dev->of_node,
553                                                        "brcm,syscon-piarbctl");
554         if (!IS_ERR(rmap))
555                 priv->ini.syscon_piarbctl = rmap;
556
557         /* start with everything off */
558         if (priv->has_xhci)
559                 brcm_usb_uninit_xhci(&priv->ini);
560         if (priv->has_eohci)
561                 brcm_usb_uninit_eohci(&priv->ini);
562         brcm_usb_uninit_common(&priv->ini);
563         clk_disable_unprepare(priv->usb_20_clk);
564         clk_disable_unprepare(priv->usb_30_clk);
565
566         phy_provider = devm_of_phy_provider_register(dev, brcm_usb_phy_xlate);
567
568         return PTR_ERR_OR_ZERO(phy_provider);
569 }
570
571 static int brcm_usb_phy_remove(struct platform_device *pdev)
572 {
573         struct brcm_usb_phy_data *priv = dev_get_drvdata(&pdev->dev);
574
575         sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group);
576         unregister_pm_notifier(&priv->pm_notifier);
577
578         return 0;
579 }
580
581 #ifdef CONFIG_PM_SLEEP
582 static int brcm_usb_phy_suspend(struct device *dev)
583 {
584         struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
585
586         if (priv->init_count) {
587                 dev_dbg(dev, "SUSPEND\n");
588                 priv->ini.wake_enabled = device_may_wakeup(dev);
589                 if (priv->phys[BRCM_USB_PHY_3_0].inited)
590                         brcm_usb_uninit_xhci(&priv->ini);
591                 if (priv->phys[BRCM_USB_PHY_2_0].inited)
592                         brcm_usb_uninit_eohci(&priv->ini);
593                 brcm_usb_uninit_common(&priv->ini);
594
595                 /*
596                  * Handle the clocks unless needed for wake. This has
597                  * to work for both older XHCI->3.0-clks, EOHCI->2.0-clks
598                  * and newer XHCI->2.0-clks/3.0-clks.
599                  */
600
601                 if (!priv->ini.suspend_with_clocks) {
602                         if (priv->phys[BRCM_USB_PHY_3_0].inited)
603                                 clk_disable_unprepare(priv->usb_30_clk);
604                         if (priv->phys[BRCM_USB_PHY_2_0].inited ||
605                             !priv->has_eohci)
606                                 clk_disable_unprepare(priv->usb_20_clk);
607                 }
608                 if (priv->wake_irq >= 0)
609                         enable_irq_wake(priv->wake_irq);
610         }
611         return 0;
612 }
613
614 static int brcm_usb_phy_resume(struct device *dev)
615 {
616         struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
617
618         clk_prepare_enable(priv->usb_20_clk);
619         clk_prepare_enable(priv->usb_30_clk);
620         brcm_usb_init_ipp(&priv->ini);
621
622         /*
623          * Initialize anything that was previously initialized.
624          * Uninitialize anything that wasn't previously initialized.
625          */
626         if (priv->init_count) {
627                 dev_dbg(dev, "RESUME\n");
628                 if (priv->wake_irq >= 0)
629                         disable_irq_wake(priv->wake_irq);
630                 brcm_usb_init_common(&priv->ini);
631                 if (priv->phys[BRCM_USB_PHY_2_0].inited) {
632                         brcm_usb_init_eohci(&priv->ini);
633                 } else if (priv->has_eohci) {
634                         brcm_usb_uninit_eohci(&priv->ini);
635                         clk_disable_unprepare(priv->usb_20_clk);
636                 }
637                 if (priv->phys[BRCM_USB_PHY_3_0].inited) {
638                         brcm_usb_init_xhci(&priv->ini);
639                 } else if (priv->has_xhci) {
640                         brcm_usb_uninit_xhci(&priv->ini);
641                         clk_disable_unprepare(priv->usb_30_clk);
642                         if (!priv->has_eohci)
643                                 clk_disable_unprepare(priv->usb_20_clk);
644                 }
645         } else {
646                 if (priv->has_xhci)
647                         brcm_usb_uninit_xhci(&priv->ini);
648                 if (priv->has_eohci)
649                         brcm_usb_uninit_eohci(&priv->ini);
650                 brcm_usb_uninit_common(&priv->ini);
651                 clk_disable_unprepare(priv->usb_20_clk);
652                 clk_disable_unprepare(priv->usb_30_clk);
653         }
654         priv->ini.wake_enabled = false;
655         return 0;
656 }
657 #endif /* CONFIG_PM_SLEEP */
658
659 static const struct dev_pm_ops brcm_usb_phy_pm_ops = {
660         SET_LATE_SYSTEM_SLEEP_PM_OPS(brcm_usb_phy_suspend, brcm_usb_phy_resume)
661 };
662
663 MODULE_DEVICE_TABLE(of, brcm_usb_dt_ids);
664
665 static struct platform_driver brcm_usb_driver = {
666         .probe          = brcm_usb_phy_probe,
667         .remove         = brcm_usb_phy_remove,
668         .driver         = {
669                 .name   = "brcmstb-usb-phy",
670                 .pm = &brcm_usb_phy_pm_ops,
671                 .of_match_table = brcm_usb_dt_ids,
672         },
673 };
674
675 module_platform_driver(brcm_usb_driver);
676
677 MODULE_ALIAS("platform:brcmstb-usb-phy");
678 MODULE_AUTHOR("Al Cooper <acooper@broadcom.com>");
679 MODULE_DESCRIPTION("BRCM USB PHY driver");
680 MODULE_LICENSE("GPL v2");