aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2016-01-07 04:18:13 -0500
committerFelipe Balbi <balbi@kernel.org>2016-03-04 08:14:28 -0500
commitde18757e272d0e948bfa3e083a1771887f719c05 (patch)
treec5b2bd79980a70a5e872b641fe0ff271b69bb60e
parent7580862b3e80af9b90dd12daeedee63e3f5683c2 (diff)
usb: renesas_usbhs: add R-Car Gen3 power control
Since the usb2 phy driver for gen3 (phy-rcar-gen3-usb2) cannot access LPSTS and UGCTRL2 registers in the HSUSB module, this driver have to initialize the registers. So, this patch adds such handling code into rcar3.c. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
-rw-r--r--drivers/usb/renesas_usbhs/Makefile2
-rw-r--r--drivers/usb/renesas_usbhs/common.c14
-rw-r--r--drivers/usb/renesas_usbhs/rcar3.c54
-rw-r--r--drivers/usb/renesas_usbhs/rcar3.h3
-rw-r--r--include/linux/usb/renesas_usbhs.h1
5 files changed, 69 insertions, 5 deletions
diff --git a/drivers/usb/renesas_usbhs/Makefile b/drivers/usb/renesas_usbhs/Makefile
index 9e47f477b6d2..d787d05f6546 100644
--- a/drivers/usb/renesas_usbhs/Makefile
+++ b/drivers/usb/renesas_usbhs/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs.o 5obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs.o
6 6
7renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o 7renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o
8 8
9ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),) 9ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),)
10 renesas_usbhs-y += mod_host.o 10 renesas_usbhs-y += mod_host.o
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 5af9ca5d54ab..baeb7d23bf24 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -25,6 +25,7 @@
25#include <linux/sysfs.h> 25#include <linux/sysfs.h>
26#include "common.h" 26#include "common.h"
27#include "rcar2.h" 27#include "rcar2.h"
28#include "rcar3.h"
28 29
29/* 30/*
30 * image of renesas_usbhs 31 * image of renesas_usbhs
@@ -477,18 +478,16 @@ static const struct of_device_id usbhs_of_match[] = {
477 .data = (void *)USBHS_TYPE_RCAR_GEN2, 478 .data = (void *)USBHS_TYPE_RCAR_GEN2,
478 }, 479 },
479 { 480 {
480 /* Gen3 is compatible with Gen2 */
481 .compatible = "renesas,usbhs-r8a7795", 481 .compatible = "renesas,usbhs-r8a7795",
482 .data = (void *)USBHS_TYPE_RCAR_GEN2, 482 .data = (void *)USBHS_TYPE_RCAR_GEN3,
483 }, 483 },
484 { 484 {
485 .compatible = "renesas,rcar-gen2-usbhs", 485 .compatible = "renesas,rcar-gen2-usbhs",
486 .data = (void *)USBHS_TYPE_RCAR_GEN2, 486 .data = (void *)USBHS_TYPE_RCAR_GEN2,
487 }, 487 },
488 { 488 {
489 /* Gen3 is compatible with Gen2 */
490 .compatible = "renesas,rcar-gen3-usbhs", 489 .compatible = "renesas,rcar-gen3-usbhs",
491 .data = (void *)USBHS_TYPE_RCAR_GEN2, 490 .data = (void *)USBHS_TYPE_RCAR_GEN3,
492 }, 491 },
493 { }, 492 { },
494}; 493};
@@ -578,6 +577,13 @@ static int usbhs_probe(struct platform_device *pdev)
578 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); 577 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
579 } 578 }
580 break; 579 break;
580 case USBHS_TYPE_RCAR_GEN3:
581 priv->pfunc = usbhs_rcar3_ops;
582 if (!priv->dparam.pipe_configs) {
583 priv->dparam.pipe_configs = usbhsc_new_pipe;
584 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
585 }
586 break;
581 default: 587 default:
582 if (!info->platform_callback.get_id) { 588 if (!info->platform_callback.get_id) {
583 dev_err(&pdev->dev, "no platform callbacks"); 589 dev_err(&pdev->dev, "no platform callbacks");
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c
new file mode 100644
index 000000000000..38b01f2aeeb0
--- /dev/null
+++ b/drivers/usb/renesas_usbhs/rcar3.c
@@ -0,0 +1,54 @@
1/*
2 * Renesas USB driver R-Car Gen. 3 initialization and power control
3 *
4 * Copyright (C) 2016 Renesas Electronics Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/io.h>
13#include "common.h"
14#include "rcar3.h"
15
16#define LPSTS 0x102
17#define UGCTRL2 0x184 /* 32-bit register */
18
19/* Low Power Status register (LPSTS) */
20#define LPSTS_SUSPM 0x4000
21
22/* USB General control register 2 (UGCTRL2), bit[31:6] should be 0 */
23#define UGCTRL2_RESERVED_3 0x00000001 /* bit[3:0] should be B'0001 */
24#define UGCTRL2_USB0SEL_OTG 0x00000030
25
26void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data)
27{
28 iowrite32(data, priv->base + reg);
29}
30
31static int usbhs_rcar3_power_ctrl(struct platform_device *pdev,
32 void __iomem *base, int enable)
33{
34 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
35
36 usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG);
37
38 if (enable)
39 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM);
40 else
41 usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0);
42
43 return 0;
44}
45
46static int usbhs_rcar3_get_id(struct platform_device *pdev)
47{
48 return USBHS_GADGET;
49}
50
51const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {
52 .power_ctrl = usbhs_rcar3_power_ctrl,
53 .get_id = usbhs_rcar3_get_id,
54};
diff --git a/drivers/usb/renesas_usbhs/rcar3.h b/drivers/usb/renesas_usbhs/rcar3.h
new file mode 100644
index 000000000000..5f850b23ff18
--- /dev/null
+++ b/drivers/usb/renesas_usbhs/rcar3.h
@@ -0,0 +1,3 @@
1#include "common.h"
2
3extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops;
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 4db191fe8c2c..00a47d058d83 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -184,6 +184,7 @@ struct renesas_usbhs_driver_param {
184}; 184};
185 185
186#define USBHS_TYPE_RCAR_GEN2 1 186#define USBHS_TYPE_RCAR_GEN2 1
187#define USBHS_TYPE_RCAR_GEN3 2
187 188
188/* 189/*
189 * option: 190 * option: