1 // SPDX-License-Identifier: GPL-2.0
3 * Renesas R-Car Gen3 for USB2.0 PHY driver
5 * Copyright (C) 2015-2017 Renesas Electronics Corporation
7 * This is based on the phy-rcar-gen2 driver:
8 * Copyright (C) 2014 Renesas Solutions Corp.
9 * Copyright (C) 2014 Cogent Embedded, Inc.
12 #include <linux/extcon-provider.h>
13 #include <linux/interrupt.h>
15 #include <linux/module.h>
16 #include <linux/mutex.h>
18 #include <linux/of_address.h>
19 #include <linux/of_device.h>
20 #include <linux/phy/phy.h>
21 #include <linux/platform_device.h>
22 #include <linux/pm_runtime.h>
23 #include <linux/regulator/consumer.h>
24 #include <linux/string.h>
25 #include <linux/usb/of.h>
26 #include <linux/workqueue.h>
28 /******* USB2.0 Host registers (original offset is +0x200) *******/
29 #define USB2_INT_ENABLE 0x000
30 #define USB2_USBCTR 0x00c
31 #define USB2_SPD_RSM_TIMSET 0x10c
32 #define USB2_OC_TIMSET 0x110
33 #define USB2_COMMCTRL 0x600
34 #define USB2_OBINTSTA 0x604
35 #define USB2_OBINTEN 0x608
36 #define USB2_VBCTRL 0x60c
37 #define USB2_LINECTRL1 0x610
38 #define USB2_ADPCTRL 0x630
41 #define USB2_INT_ENABLE_UCOM_INTEN BIT(3)
42 #define USB2_INT_ENABLE_USBH_INTB_EN BIT(2) /* For EHCI */
43 #define USB2_INT_ENABLE_USBH_INTA_EN BIT(1) /* For OHCI */
46 #define USB2_USBCTR_DIRPD BIT(2)
47 #define USB2_USBCTR_PLL_RST BIT(1)
50 #define USB2_SPD_RSM_TIMSET_INIT 0x014e029b
53 #define USB2_OC_TIMSET_INIT 0x000209ab
56 #define USB2_COMMCTRL_OTG_PERI BIT(31) /* 1 = Peripheral mode */
58 /* OBINTSTA and OBINTEN */
59 #define USB2_OBINT_SESSVLDCHG BIT(12)
60 #define USB2_OBINT_IDDIGCHG BIT(11)
61 #define USB2_OBINT_BITS (USB2_OBINT_SESSVLDCHG | \
65 #define USB2_VBCTRL_OCCLREN BIT(16)
66 #define USB2_VBCTRL_DRVVBUSSEL BIT(8)
69 #define USB2_LINECTRL1_DPRPD_EN BIT(19)
70 #define USB2_LINECTRL1_DP_RPD BIT(18)
71 #define USB2_LINECTRL1_DMRPD_EN BIT(17)
72 #define USB2_LINECTRL1_DM_RPD BIT(16)
73 #define USB2_LINECTRL1_OPMODE_NODRV BIT(6)
76 #define USB2_ADPCTRL_OTGSESSVLD BIT(20)
77 #define USB2_ADPCTRL_IDDIG BIT(19)
78 #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */
79 #define USB2_ADPCTRL_DRVVBUS BIT(4)
82 enum rcar_gen3_phy_index
{
89 static const u32 rcar_gen3_int_enable
[NUM_OF_PHYS
] = {
90 USB2_INT_ENABLE_USBH_INTB_EN
| USB2_INT_ENABLE_USBH_INTA_EN
,
91 USB2_INT_ENABLE_USBH_INTA_EN
,
92 USB2_INT_ENABLE_USBH_INTB_EN
,
96 struct rcar_gen3_phy
{
98 struct rcar_gen3_chan
*ch
;
101 bool otg_initialized
;
105 struct rcar_gen3_chan
{
107 struct device
*dev
; /* platform_device's device */
108 struct extcon_dev
*extcon
;
109 struct rcar_gen3_phy rphys
[NUM_OF_PHYS
];
110 struct regulator
*vbus
;
111 struct work_struct work
;
112 struct mutex lock
; /* protects rphys[...].powered */
113 enum usb_dr_mode dr_mode
;
120 * Combination about is_otg_channel and uses_otg_pins:
122 * Parameters || Behaviors
123 * is_otg_channel | uses_otg_pins || irqs | role sysfs
124 * ---------------------+---------------++--------------+------------
125 * true | true || enabled | enabled
126 * true | false || disabled | enabled
127 * false | any || disabled | disabled
130 static void rcar_gen3_phy_usb2_work(struct work_struct
*work
)
132 struct rcar_gen3_chan
*ch
= container_of(work
, struct rcar_gen3_chan
,
135 if (ch
->extcon_host
) {
136 extcon_set_state_sync(ch
->extcon
, EXTCON_USB_HOST
, true);
137 extcon_set_state_sync(ch
->extcon
, EXTCON_USB
, false);
139 extcon_set_state_sync(ch
->extcon
, EXTCON_USB_HOST
, false);
140 extcon_set_state_sync(ch
->extcon
, EXTCON_USB
, true);
144 static void rcar_gen3_set_host_mode(struct rcar_gen3_chan
*ch
, int host
)
146 void __iomem
*usb2_base
= ch
->base
;
147 u32 val
= readl(usb2_base
+ USB2_COMMCTRL
);
149 dev_vdbg(ch
->dev
, "%s: %08x, %d\n", __func__
, val
, host
);
151 val
&= ~USB2_COMMCTRL_OTG_PERI
;
153 val
|= USB2_COMMCTRL_OTG_PERI
;
154 writel(val
, usb2_base
+ USB2_COMMCTRL
);
157 static void rcar_gen3_set_linectrl(struct rcar_gen3_chan
*ch
, int dp
, int dm
)
159 void __iomem
*usb2_base
= ch
->base
;
160 u32 val
= readl(usb2_base
+ USB2_LINECTRL1
);
162 dev_vdbg(ch
->dev
, "%s: %08x, %d, %d\n", __func__
, val
, dp
, dm
);
163 val
&= ~(USB2_LINECTRL1_DP_RPD
| USB2_LINECTRL1_DM_RPD
);
165 val
|= USB2_LINECTRL1_DP_RPD
;
167 val
|= USB2_LINECTRL1_DM_RPD
;
168 writel(val
, usb2_base
+ USB2_LINECTRL1
);
171 static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan
*ch
, int vbus
)
173 void __iomem
*usb2_base
= ch
->base
;
174 u32 val
= readl(usb2_base
+ USB2_ADPCTRL
);
176 dev_vdbg(ch
->dev
, "%s: %08x, %d\n", __func__
, val
, vbus
);
178 val
|= USB2_ADPCTRL_DRVVBUS
;
180 val
&= ~USB2_ADPCTRL_DRVVBUS
;
181 writel(val
, usb2_base
+ USB2_ADPCTRL
);
184 static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan
*ch
, int enable
)
186 void __iomem
*usb2_base
= ch
->base
;
187 u32 val
= readl(usb2_base
+ USB2_OBINTEN
);
189 if (ch
->uses_otg_pins
&& enable
)
190 val
|= USB2_OBINT_BITS
;
192 val
&= ~USB2_OBINT_BITS
;
193 writel(val
, usb2_base
+ USB2_OBINTEN
);
196 static void rcar_gen3_init_for_host(struct rcar_gen3_chan
*ch
)
198 rcar_gen3_set_linectrl(ch
, 1, 1);
199 rcar_gen3_set_host_mode(ch
, 1);
200 rcar_gen3_enable_vbus_ctrl(ch
, 1);
202 ch
->extcon_host
= true;
203 schedule_work(&ch
->work
);
206 static void rcar_gen3_init_for_peri(struct rcar_gen3_chan
*ch
)
208 rcar_gen3_set_linectrl(ch
, 0, 1);
209 rcar_gen3_set_host_mode(ch
, 0);
210 rcar_gen3_enable_vbus_ctrl(ch
, 0);
212 ch
->extcon_host
= false;
213 schedule_work(&ch
->work
);
216 static void rcar_gen3_init_for_b_host(struct rcar_gen3_chan
*ch
)
218 void __iomem
*usb2_base
= ch
->base
;
221 val
= readl(usb2_base
+ USB2_LINECTRL1
);
222 writel(val
| USB2_LINECTRL1_OPMODE_NODRV
, usb2_base
+ USB2_LINECTRL1
);
224 rcar_gen3_set_linectrl(ch
, 1, 1);
225 rcar_gen3_set_host_mode(ch
, 1);
226 rcar_gen3_enable_vbus_ctrl(ch
, 0);
228 val
= readl(usb2_base
+ USB2_LINECTRL1
);
229 writel(val
& ~USB2_LINECTRL1_OPMODE_NODRV
, usb2_base
+ USB2_LINECTRL1
);
232 static void rcar_gen3_init_for_a_peri(struct rcar_gen3_chan
*ch
)
234 rcar_gen3_set_linectrl(ch
, 0, 1);
235 rcar_gen3_set_host_mode(ch
, 0);
236 rcar_gen3_enable_vbus_ctrl(ch
, 1);
239 static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan
*ch
)
241 rcar_gen3_control_otg_irq(ch
, 0);
243 rcar_gen3_enable_vbus_ctrl(ch
, 1);
244 rcar_gen3_init_for_host(ch
);
246 rcar_gen3_control_otg_irq(ch
, 1);
249 static bool rcar_gen3_check_id(struct rcar_gen3_chan
*ch
)
251 if (!ch
->uses_otg_pins
)
252 return (ch
->dr_mode
== USB_DR_MODE_HOST
) ? false : true;
254 return !!(readl(ch
->base
+ USB2_ADPCTRL
) & USB2_ADPCTRL_IDDIG
);
257 static void rcar_gen3_device_recognition(struct rcar_gen3_chan
*ch
)
259 if (!rcar_gen3_check_id(ch
))
260 rcar_gen3_init_for_host(ch
);
262 rcar_gen3_init_for_peri(ch
);
265 static bool rcar_gen3_is_host(struct rcar_gen3_chan
*ch
)
267 return !(readl(ch
->base
+ USB2_COMMCTRL
) & USB2_COMMCTRL_OTG_PERI
);
270 static enum phy_mode
rcar_gen3_get_phy_mode(struct rcar_gen3_chan
*ch
)
272 if (rcar_gen3_is_host(ch
))
273 return PHY_MODE_USB_HOST
;
275 return PHY_MODE_USB_DEVICE
;
278 static bool rcar_gen3_is_any_rphy_initialized(struct rcar_gen3_chan
*ch
)
282 for (i
= 0; i
< NUM_OF_PHYS
; i
++) {
283 if (ch
->rphys
[i
].initialized
)
290 static bool rcar_gen3_needs_init_otg(struct rcar_gen3_chan
*ch
)
294 for (i
= 0; i
< NUM_OF_PHYS
; i
++) {
295 if (ch
->rphys
[i
].otg_initialized
)
302 static bool rcar_gen3_are_all_rphys_power_off(struct rcar_gen3_chan
*ch
)
306 for (i
= 0; i
< NUM_OF_PHYS
; i
++) {
307 if (ch
->rphys
[i
].powered
)
314 static ssize_t
role_store(struct device
*dev
, struct device_attribute
*attr
,
315 const char *buf
, size_t count
)
317 struct rcar_gen3_chan
*ch
= dev_get_drvdata(dev
);
319 enum phy_mode cur_mode
, new_mode
;
321 if (!ch
->is_otg_channel
|| !rcar_gen3_is_any_rphy_initialized(ch
))
324 if (sysfs_streq(buf
, "host"))
325 new_mode
= PHY_MODE_USB_HOST
;
326 else if (sysfs_streq(buf
, "peripheral"))
327 new_mode
= PHY_MODE_USB_DEVICE
;
331 /* is_b_device: true is B-Device. false is A-Device. */
332 is_b_device
= rcar_gen3_check_id(ch
);
333 cur_mode
= rcar_gen3_get_phy_mode(ch
);
335 /* If current and new mode is the same, this returns the error */
336 if (cur_mode
== new_mode
)
339 if (new_mode
== PHY_MODE_USB_HOST
) { /* And is_host must be false */
340 if (!is_b_device
) /* A-Peripheral */
341 rcar_gen3_init_from_a_peri_to_a_host(ch
);
342 else /* B-Peripheral */
343 rcar_gen3_init_for_b_host(ch
);
344 } else { /* And is_host must be true */
345 if (!is_b_device
) /* A-Host */
346 rcar_gen3_init_for_a_peri(ch
);
348 rcar_gen3_init_for_peri(ch
);
354 static ssize_t
role_show(struct device
*dev
, struct device_attribute
*attr
,
357 struct rcar_gen3_chan
*ch
= dev_get_drvdata(dev
);
359 if (!ch
->is_otg_channel
|| !rcar_gen3_is_any_rphy_initialized(ch
))
362 return sprintf(buf
, "%s\n", rcar_gen3_is_host(ch
) ? "host" :
365 static DEVICE_ATTR_RW(role
);
367 static void rcar_gen3_init_otg(struct rcar_gen3_chan
*ch
)
369 void __iomem
*usb2_base
= ch
->base
;
372 /* Should not use functions of read-modify-write a register */
373 val
= readl(usb2_base
+ USB2_LINECTRL1
);
374 val
= (val
& ~USB2_LINECTRL1_DP_RPD
) | USB2_LINECTRL1_DPRPD_EN
|
375 USB2_LINECTRL1_DMRPD_EN
| USB2_LINECTRL1_DM_RPD
;
376 writel(val
, usb2_base
+ USB2_LINECTRL1
);
378 val
= readl(usb2_base
+ USB2_VBCTRL
);
379 val
&= ~USB2_VBCTRL_OCCLREN
;
380 writel(val
| USB2_VBCTRL_DRVVBUSSEL
, usb2_base
+ USB2_VBCTRL
);
381 val
= readl(usb2_base
+ USB2_ADPCTRL
);
382 writel(val
| USB2_ADPCTRL_IDPULLUP
, usb2_base
+ USB2_ADPCTRL
);
386 writel(0xffffffff, usb2_base
+ USB2_OBINTSTA
);
387 writel(USB2_OBINT_BITS
, usb2_base
+ USB2_OBINTEN
);
389 rcar_gen3_device_recognition(ch
);
392 static int rcar_gen3_phy_usb2_init(struct phy
*p
)
394 struct rcar_gen3_phy
*rphy
= phy_get_drvdata(p
);
395 struct rcar_gen3_chan
*channel
= rphy
->ch
;
396 void __iomem
*usb2_base
= channel
->base
;
399 /* Initialize USB2 part */
400 val
= readl(usb2_base
+ USB2_INT_ENABLE
);
401 val
|= USB2_INT_ENABLE_UCOM_INTEN
| rphy
->int_enable_bits
;
402 writel(val
, usb2_base
+ USB2_INT_ENABLE
);
403 writel(USB2_SPD_RSM_TIMSET_INIT
, usb2_base
+ USB2_SPD_RSM_TIMSET
);
404 writel(USB2_OC_TIMSET_INIT
, usb2_base
+ USB2_OC_TIMSET
);
406 /* Initialize otg part */
407 if (channel
->is_otg_channel
) {
408 if (rcar_gen3_needs_init_otg(channel
))
409 rcar_gen3_init_otg(channel
);
410 rphy
->otg_initialized
= true;
413 rphy
->initialized
= true;
418 static int rcar_gen3_phy_usb2_exit(struct phy
*p
)
420 struct rcar_gen3_phy
*rphy
= phy_get_drvdata(p
);
421 struct rcar_gen3_chan
*channel
= rphy
->ch
;
422 void __iomem
*usb2_base
= channel
->base
;
425 rphy
->initialized
= false;
427 if (channel
->is_otg_channel
)
428 rphy
->otg_initialized
= false;
430 val
= readl(usb2_base
+ USB2_INT_ENABLE
);
431 val
&= ~rphy
->int_enable_bits
;
432 if (!rcar_gen3_is_any_rphy_initialized(channel
))
433 val
&= ~USB2_INT_ENABLE_UCOM_INTEN
;
434 writel(val
, usb2_base
+ USB2_INT_ENABLE
);
439 static int rcar_gen3_phy_usb2_power_on(struct phy
*p
)
441 struct rcar_gen3_phy
*rphy
= phy_get_drvdata(p
);
442 struct rcar_gen3_chan
*channel
= rphy
->ch
;
443 void __iomem
*usb2_base
= channel
->base
;
447 mutex_lock(&channel
->lock
);
448 if (!rcar_gen3_are_all_rphys_power_off(channel
))
452 ret
= regulator_enable(channel
->vbus
);
457 val
= readl(usb2_base
+ USB2_USBCTR
);
458 val
|= USB2_USBCTR_PLL_RST
;
459 writel(val
, usb2_base
+ USB2_USBCTR
);
460 val
&= ~USB2_USBCTR_PLL_RST
;
461 writel(val
, usb2_base
+ USB2_USBCTR
);
464 /* The powered flag should be set for any other phys anyway */
465 rphy
->powered
= true;
466 mutex_unlock(&channel
->lock
);
471 static int rcar_gen3_phy_usb2_power_off(struct phy
*p
)
473 struct rcar_gen3_phy
*rphy
= phy_get_drvdata(p
);
474 struct rcar_gen3_chan
*channel
= rphy
->ch
;
477 mutex_lock(&channel
->lock
);
478 rphy
->powered
= false;
480 if (!rcar_gen3_are_all_rphys_power_off(channel
))
484 ret
= regulator_disable(channel
->vbus
);
487 mutex_unlock(&channel
->lock
);
492 static const struct phy_ops rcar_gen3_phy_usb2_ops
= {
493 .init
= rcar_gen3_phy_usb2_init
,
494 .exit
= rcar_gen3_phy_usb2_exit
,
495 .power_on
= rcar_gen3_phy_usb2_power_on
,
496 .power_off
= rcar_gen3_phy_usb2_power_off
,
497 .owner
= THIS_MODULE
,
500 static const struct phy_ops rz_g1c_phy_usb2_ops
= {
501 .init
= rcar_gen3_phy_usb2_init
,
502 .exit
= rcar_gen3_phy_usb2_exit
,
503 .owner
= THIS_MODULE
,
506 static irqreturn_t
rcar_gen3_phy_usb2_irq(int irq
, void *_ch
)
508 struct rcar_gen3_chan
*ch
= _ch
;
509 void __iomem
*usb2_base
= ch
->base
;
510 u32 status
= readl(usb2_base
+ USB2_OBINTSTA
);
511 irqreturn_t ret
= IRQ_NONE
;
513 if (status
& USB2_OBINT_BITS
) {
514 dev_vdbg(ch
->dev
, "%s: %08x\n", __func__
, status
);
515 writel(USB2_OBINT_BITS
, usb2_base
+ USB2_OBINTSTA
);
516 rcar_gen3_device_recognition(ch
);
523 static const struct of_device_id rcar_gen3_phy_usb2_match_table
[] = {
525 .compatible
= "renesas,usb2-phy-r8a77470",
526 .data
= &rz_g1c_phy_usb2_ops
,
529 .compatible
= "renesas,usb2-phy-r8a7795",
530 .data
= &rcar_gen3_phy_usb2_ops
,
533 .compatible
= "renesas,usb2-phy-r8a7796",
534 .data
= &rcar_gen3_phy_usb2_ops
,
537 .compatible
= "renesas,usb2-phy-r8a77965",
538 .data
= &rcar_gen3_phy_usb2_ops
,
541 .compatible
= "renesas,rcar-gen3-usb2-phy",
542 .data
= &rcar_gen3_phy_usb2_ops
,
546 MODULE_DEVICE_TABLE(of
, rcar_gen3_phy_usb2_match_table
);
548 static const unsigned int rcar_gen3_phy_cable
[] = {
554 static struct phy
*rcar_gen3_phy_usb2_xlate(struct device
*dev
,
555 struct of_phandle_args
*args
)
557 struct rcar_gen3_chan
*ch
= dev_get_drvdata(dev
);
559 if (args
->args_count
== 0) /* For old version dts */
560 return ch
->rphys
[PHY_INDEX_BOTH_HC
].phy
;
561 else if (args
->args_count
> 1) /* Prevent invalid args count */
562 return ERR_PTR(-ENODEV
);
564 if (args
->args
[0] >= NUM_OF_PHYS
)
565 return ERR_PTR(-ENODEV
);
567 return ch
->rphys
[args
->args
[0]].phy
;
570 static enum usb_dr_mode
rcar_gen3_get_dr_mode(struct device_node
*np
)
572 enum usb_dr_mode candidate
= USB_DR_MODE_UNKNOWN
;
576 * If one of device nodes has other dr_mode except UNKNOWN,
577 * this function returns UNKNOWN. To achieve backward compatibility,
578 * this loop starts the index as 0.
580 for (i
= 0; i
< NUM_OF_PHYS
; i
++) {
581 enum usb_dr_mode mode
= of_usb_get_dr_mode_by_phy(np
, i
);
583 if (mode
!= USB_DR_MODE_UNKNOWN
) {
584 if (candidate
== USB_DR_MODE_UNKNOWN
)
586 else if (candidate
!= mode
)
587 return USB_DR_MODE_UNKNOWN
;
594 static int rcar_gen3_phy_usb2_probe(struct platform_device
*pdev
)
596 struct device
*dev
= &pdev
->dev
;
597 struct rcar_gen3_chan
*channel
;
598 struct phy_provider
*provider
;
599 struct resource
*res
;
600 const struct phy_ops
*phy_usb2_ops
;
604 dev_err(dev
, "This driver needs device tree\n");
608 channel
= devm_kzalloc(dev
, sizeof(*channel
), GFP_KERNEL
);
612 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
613 channel
->base
= devm_ioremap_resource(dev
, res
);
614 if (IS_ERR(channel
->base
))
615 return PTR_ERR(channel
->base
);
617 /* call request_irq for OTG */
618 irq
= platform_get_irq_optional(pdev
, 0);
620 INIT_WORK(&channel
->work
, rcar_gen3_phy_usb2_work
);
621 irq
= devm_request_irq(dev
, irq
, rcar_gen3_phy_usb2_irq
,
622 IRQF_SHARED
, dev_name(dev
), channel
);
624 dev_err(dev
, "No irq handler (%d)\n", irq
);
627 channel
->dr_mode
= rcar_gen3_get_dr_mode(dev
->of_node
);
628 if (channel
->dr_mode
!= USB_DR_MODE_UNKNOWN
) {
631 channel
->is_otg_channel
= true;
632 channel
->uses_otg_pins
= !of_property_read_bool(dev
->of_node
,
633 "renesas,no-otg-pins");
634 channel
->extcon
= devm_extcon_dev_allocate(dev
,
635 rcar_gen3_phy_cable
);
636 if (IS_ERR(channel
->extcon
))
637 return PTR_ERR(channel
->extcon
);
639 ret
= devm_extcon_dev_register(dev
, channel
->extcon
);
641 dev_err(dev
, "Failed to register extcon\n");
647 * devm_phy_create() will call pm_runtime_enable(&phy->dev);
648 * And then, phy-core will manage runtime pm for this device.
650 pm_runtime_enable(dev
);
651 phy_usb2_ops
= of_device_get_match_data(dev
);
655 mutex_init(&channel
->lock
);
656 for (i
= 0; i
< NUM_OF_PHYS
; i
++) {
657 channel
->rphys
[i
].phy
= devm_phy_create(dev
, NULL
,
659 if (IS_ERR(channel
->rphys
[i
].phy
)) {
660 dev_err(dev
, "Failed to create USB2 PHY\n");
661 ret
= PTR_ERR(channel
->rphys
[i
].phy
);
664 channel
->rphys
[i
].ch
= channel
;
665 channel
->rphys
[i
].int_enable_bits
= rcar_gen3_int_enable
[i
];
666 phy_set_drvdata(channel
->rphys
[i
].phy
, &channel
->rphys
[i
]);
669 channel
->vbus
= devm_regulator_get_optional(dev
, "vbus");
670 if (IS_ERR(channel
->vbus
)) {
671 if (PTR_ERR(channel
->vbus
) == -EPROBE_DEFER
) {
672 ret
= PTR_ERR(channel
->vbus
);
675 channel
->vbus
= NULL
;
678 platform_set_drvdata(pdev
, channel
);
681 provider
= devm_of_phy_provider_register(dev
, rcar_gen3_phy_usb2_xlate
);
682 if (IS_ERR(provider
)) {
683 dev_err(dev
, "Failed to register PHY provider\n");
684 ret
= PTR_ERR(provider
);
686 } else if (channel
->is_otg_channel
) {
689 ret
= device_create_file(dev
, &dev_attr_role
);
697 pm_runtime_disable(dev
);
702 static int rcar_gen3_phy_usb2_remove(struct platform_device
*pdev
)
704 struct rcar_gen3_chan
*channel
= platform_get_drvdata(pdev
);
706 if (channel
->is_otg_channel
)
707 device_remove_file(&pdev
->dev
, &dev_attr_role
);
709 pm_runtime_disable(&pdev
->dev
);
714 static struct platform_driver rcar_gen3_phy_usb2_driver
= {
716 .name
= "phy_rcar_gen3_usb2",
717 .of_match_table
= rcar_gen3_phy_usb2_match_table
,
719 .probe
= rcar_gen3_phy_usb2_probe
,
720 .remove
= rcar_gen3_phy_usb2_remove
,
722 module_platform_driver(rcar_gen3_phy_usb2_driver
);
724 MODULE_LICENSE("GPL v2");
725 MODULE_DESCRIPTION("Renesas R-Car Gen3 USB 2.0 PHY");
726 MODULE_AUTHOR("Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>");