Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1250451
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> |
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH v4 2/3] phy: rcar-gen3-usb2: change the mode to OTG on the combined channel |
| Date | Mon, 19 Oct 2015 10:40:01 +0200 |
| Message-ID | <qle93-7rs-9@gated-at.bofh.it> (permalink) |
| References | <qj50d-3He-9@gated-at.bofh.it> <qkoNc-7xp-11@gated-at.bofh.it> <qkoNb-7xp-9@gated-at.bofh.it> |
| X-Original-To | Kishon Vijay Abraham I <kishon@ti.com>, "robh+dt@kernel.org" <robh+dt@kernel.org>, "pawel.moll@arm.com" <pawel.moll@arm.com>, "mark.rutland@arm.com" <mark.rutland@arm.com>, "ijc+devicetree@hellion.org.uk" <ijc+devicetree@hellion.org.uk>, "galak@codeaurora.org" <galak@codeaurora.org> |
| X-Ironport-Av | E=Sophos;i="5.17,700,1437404400"; d="scan'208";a="197933487" |
| Thread-Topic | [PATCH v4 2/3] phy: rcar-gen3-usb2: change the mode to OTG on the combined channel |
| Thread-Index | AQHRBaEMBb/NL1eMb0SwfcH3J4fZZp5u8HcAgAOVCIA= |
| Accept-Language | ja-JP, en-US |
| Content-Language | ja-JP |
| Authentication-Results | spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; |
| X-Originating-IP | [211.11.155.144] |
| X-Microsoft-Exchange-Diagnostics | 1;SG2PR06MB0917;5:jDbNSQ/dn2ZkRIu8FJtkA3bWiZEgIVzMF3Y5uTVN/Hxp0Ui222QLaoV7cCBqSy2m6qGew3Bl9J3Fq5sQWVXFvEa7gQpLiOSKdCUyHIm7osveF/YUmW2HsEwR/yubX5fti4koEl5KT/tsCwPYcw6N8A==;24:tiAH6dy6N4QomrCjnwBur+dI8gYOK4NUQ/IvGWiG2RrHU4UwoaR6ke35UjfHlRDHDb5YY6nR36eJyOXowEXMPMjDi02qjAGtxjCtzh4Iu8w=;20:HFHhnub0ueyx30Gltgty2muyC/gRQv8WDIqrHt0RmcYFtabviGpeZU3YfHVMTeRoyy48pK+AuhyqTVC+7WtRi3B1e7rh1Lny7LjJwwJYPOHCqYgQA6hVO72aIS1Ov29xmhAFRQEPE/Y5mbOCaf466dR1+dbbviGxDdN3IcOv0r8= |
| X-Microsoft-Antispam | UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0917; |
| X-Microsoft-Antispam-Prvs | <SG2PR06MB09173B76FE1434021968F479D83A0@SG2PR06MB0917.apcprd06.prod.outlook.com> |
| X-Exchange-Antispam-Report-Test | UriScan:(85106069007906); |
| X-Exchange-Antispam-Report-Cfa-Test | BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001);SRVR:SG2PR06MB0917;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0917; |
| X-Forefront-Prvs | 07349BFAD2 |
| X-Forefront-Antispam-Report | SFV:NSPM;SFS:(10019020)(979002)(6009001)(24454002)(199003)(189002)(377454003)(76576001)(33656002)(575784001)(102836002)(86362001)(10400500002)(77096005)(11100500001)(2950100001)(2900100001)(101416001)(74316001)(189998001)(5004730100002)(97736004)(81156007)(5007970100001)(66066001)(5001770100001)(5002640100001)(5001960100002)(122556002)(92566002)(76176999)(64706001)(87936001)(106116001)(106356001)(40100003)(19580395003)(50986999)(5003600100002)(46102003)(105586002)(230783001)(2501003)(19580405001)(5008740100001)(54356999)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB0917;H:SG2PR06MB0919.apcprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; |
| Spamdiagnosticoutput | 1:23 |
| Spamdiagnosticmetadata | NSPM |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Transfer-Encoding | 8BIT |
| MIME-Version | 1.0 |
| X-Originatororg | renesas.com |
| X-Ms-Exchange-Crosstenant-Originalarrivaltime | 19 Oct 2015 08:32:01.6196 (UTC) |
| X-Ms-Exchange-Crosstenant-Fromentityheader | Hosted |
| X-Ms-Exchange-Crosstenant-ID | 53d82571-da19-47e4-9cb4-625a166a4a2a |
| X-Ms-Exchange-Transport-Crosstenantheadersstamped | SG2PR06MB0917 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 170 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, "linux-sh@vger.kernel.org" <linux-sh@vger.kernel.org> |
| X-Original-Date | Mon, 19 Oct 2015 08:32:01 +0000 |
| X-Original-Message-ID | <SG2PR06MB0919C048D317BC39347782BFD83A0@SG2PR06MB0919.apcprd06.prod.outlook.com> |
| X-Original-References | <1444731726-5328-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1444731726-5328-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> <5621A8D4.40405@ti.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1250451 |
Show key headers only | View raw
Hi,
> Sent: Saturday, October 17, 2015 10:48 AM
>
> Hi,
>
> On Tuesday 13 October 2015 03:52 PM, Yoshihiro Shimoda wrote:
> > To use the channel 0 of R-Car gen3 as periperal mode, This patch changes
> > the mode to OTG instead of HOST. Then, this driver needs to set some
> > registers to enable host mode and detects ID pin and VBUS pin at
> > phy_init() timing.
> >
> > For now, the channel 0 can be used as host mode only.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> > drivers/phy/phy-rcar-gen3-usb2.c | 126 ++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 124 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c
> > index d90dfcf..03d7079 100644
> > --- a/drivers/phy/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/phy-rcar-gen3-usb2.c
> > @@ -25,6 +25,10 @@
> > #define USB2_USBCTR 0x00c
> > #define USB2_SPD_RSM_TIMSET 0x10c
> > #define USB2_OC_TIMSET 0x110
> > +#define USB2_COMMCTRL 0x600
> > +#define USB2_VBCTRL 0x60c
> > +#define USB2_LINECTRL1 0x610
> > +#define USB2_ADPCTRL 0x630
> >
> > /* INT_ENABLE */
> > #define USB2_INT_ENABLE_USBH_INTB_EN BIT(2)
> > @@ -42,6 +46,24 @@
> > /* OC_TIMSET */
> > #define USB2_OC_TIMSET_INIT 0x000209ab
> >
> > +/* COMMCTRL */
> > +#define USB2_COMMCTRL_OTG_PERI BIT(31) /* 1 = Peripheral mode */
> > +
> > +/* VBCTRL */
> > +#define USB2_VBCTRL_DRVVBUSSEL BIT(8)
> > +
> > +/* LINECTRL1 */
> > +#define USB2_LINECTRL1_DPRPD_EN BIT(19)
> > +#define USB2_LINECTRL1_DP_RPD BIT(18)
> > +#define USB2_LINECTRL1_DMRPD_EN BIT(17)
> > +#define USB2_LINECTRL1_DM_RPD BIT(16)
> > +
> > +/* ADPCTRL */
> > +#define USB2_ADPCTRL_OTGSESSVLD BIT(20)
> > +#define USB2_ADPCTRL_IDDIG BIT(19)
> > +#define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */
> > +#define USB2_ADPCTRL_DRVVBUS BIT(4)
> > +
> > /******* HSUSB registers (original offset is +0x100) *******/
> > #define HSUSB_LPSTS 0x02
> > #define HSUSB_UGCTRL2 0x84
> > @@ -68,6 +90,104 @@ struct rcar_gen3_chan {
> > spinlock_t lock;
> > };
> >
> > +static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host)
> > +{
> > + void __iomem *usb2_base = ch->usb2.base;
> > + u32 tmp = readl(usb2_base + USB2_COMMCTRL);
>
> It's your preference but I'd like to have something like val instead of tmp.
I got it. I will change the name.
> > +
> > + dev_dbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, tmp, host);
>
> This shoulod be dev_vdbg.
I got it. I will fix it.
> > + if (host)
> > + tmp &= ~USB2_COMMCTRL_OTG_PERI;
> > + else
> > + tmp |= USB2_COMMCTRL_OTG_PERI;
> > + writel(tmp, usb2_base + USB2_COMMCTRL);
> > +}
> > +
> > +static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
> > +{
> > + void __iomem *usb2_base = ch->usb2.base;
> > + u32 tmp = readl(usb2_base + USB2_LINECTRL1);
> > +
> > + dev_dbg(&ch->phy->dev, "%s: %08x, %d, %d\n", __func__, tmp, dp, dm);
>
> same here.
I got it.
> > + tmp &= ~(USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
> > + if (dp)
> > + tmp |= USB2_LINECTRL1_DP_RPD;
> > + if (dm)
> > + tmp |= USB2_LINECTRL1_DM_RPD;
> > + writel(tmp, usb2_base + USB2_LINECTRL1);
> > +}
> > +
> > +static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
> > +{
> > + void __iomem *usb2_base = ch->usb2.base;
> > + u32 tmp = readl(usb2_base + USB2_ADPCTRL);
> > +
> > + dev_dbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, tmp, vbus);
>
> here too.
I will fix it.
> > + if (vbus)
> > + tmp |= USB2_ADPCTRL_DRVVBUS;
> > + else
> > + tmp &= ~USB2_ADPCTRL_DRVVBUS;
> > + writel(tmp, usb2_base + USB2_ADPCTRL);
> > +}
> > +
> > +static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch)
> > +{
> > + rcar_gen3_set_linectrl(ch, 1, 1);
> > + rcar_gen3_set_host_mode(ch, 1);
> > + rcar_gen3_enable_vbus_ctrl(ch, 1);
> > +}
> > +
> > +static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch)
> > +{
> > + rcar_gen3_set_linectrl(ch, 0, 1);
> > + rcar_gen3_set_host_mode(ch, 0);
> > + rcar_gen3_enable_vbus_ctrl(ch, 0);
> > +}
> > +
> > +static bool rcar_gen3_check_vbus(struct rcar_gen3_chan *ch)
> > +{
> > + return !!(readl(ch->usb2.base + USB2_ADPCTRL) &
> > + USB2_ADPCTRL_OTGSESSVLD);
> > +}
> > +
> > +static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
> > +{
> > + return !!(readl(ch->usb2.base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
> > +}
> > +
> > +static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch)
> > +{
> > + bool is_host = true;
> > +
> > + if (rcar_gen3_check_id(ch)) {
> > + /* B-device? */
> > + if (rcar_gen3_check_vbus(ch))
>
> This can be rcar_gen3_check_id(ch) && rcar_gen3_check_vbus(ch) no?
Thank you for the point. I will change such a condition.
Best regards,
Yoshihiro Shimoda
> Thanks
> Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v4 0/3] phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> - 2015-10-13 12:30 +0200
Re: [PATCH v4 1/3] phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver Kishon Vijay Abraham I <kishon@ti.com> - 2015-10-17 03:50 +0200
RE: [PATCH v4 1/3] phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> - 2015-10-19 10:40 +0200
Re: [PATCH v4 2/3] phy: rcar-gen3-usb2: change the mode to OTG on the combined channel Kishon Vijay Abraham I <kishon@ti.com> - 2015-10-17 03:50 +0200
RE: [PATCH v4 2/3] phy: rcar-gen3-usb2: change the mode to OTG on the combined channel Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> - 2015-10-19 10:40 +0200
Re: [PATCH v4 2/3] phy: rcar-gen3-usb2: change the mode to OTG on the combined channel Khiem Nguyen <khiem.nguyen.xt@rvc.renesas.com> - 2015-10-19 14:00 +0200
Re: [PATCH v4 3/3] phy: rcar-gen3-usb2: add runtime ID/VBUS pin detection Kishon Vijay Abraham I <kishon@ti.com> - 2015-10-17 04:00 +0200
RE: [PATCH v4 3/3] phy: rcar-gen3-usb2: add runtime ID/VBUS pin detection Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> - 2015-10-19 10:40 +0200
csiph-web