Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yoshihiro Shimoda and committed by
Felipe Balbi
de18757e 7580862b

+69 -5
+1 -1
drivers/usb/renesas_usbhs/Makefile
··· 4 4 5 5 obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs.o 6 6 7 - renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o 7 + renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o 8 8 9 9 ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),) 10 10 renesas_usbhs-y += mod_host.o
+10 -4
drivers/usb/renesas_usbhs/common.c
··· 25 25 #include <linux/sysfs.h> 26 26 #include "common.h" 27 27 #include "rcar2.h" 28 + #include "rcar3.h" 28 29 29 30 /* 30 31 * image of renesas_usbhs ··· 478 477 .data = (void *)USBHS_TYPE_RCAR_GEN2, 479 478 }, 480 479 { 481 - /* Gen3 is compatible with Gen2 */ 482 480 .compatible = "renesas,usbhs-r8a7795", 483 - .data = (void *)USBHS_TYPE_RCAR_GEN2, 481 + .data = (void *)USBHS_TYPE_RCAR_GEN3, 484 482 }, 485 483 { 486 484 .compatible = "renesas,rcar-gen2-usbhs", 487 485 .data = (void *)USBHS_TYPE_RCAR_GEN2, 488 486 }, 489 487 { 490 - /* Gen3 is compatible with Gen2 */ 491 488 .compatible = "renesas,rcar-gen3-usbhs", 492 - .data = (void *)USBHS_TYPE_RCAR_GEN2, 489 + .data = (void *)USBHS_TYPE_RCAR_GEN3, 493 490 }, 494 491 { }, 495 492 }; ··· 572 573 switch (priv->dparam.type) { 573 574 case USBHS_TYPE_RCAR_GEN2: 574 575 priv->pfunc = usbhs_rcar2_ops; 576 + if (!priv->dparam.pipe_configs) { 577 + priv->dparam.pipe_configs = usbhsc_new_pipe; 578 + priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); 579 + } 580 + break; 581 + case USBHS_TYPE_RCAR_GEN3: 582 + priv->pfunc = usbhs_rcar3_ops; 575 583 if (!priv->dparam.pipe_configs) { 576 584 priv->dparam.pipe_configs = usbhsc_new_pipe; 577 585 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
+54
drivers/usb/renesas_usbhs/rcar3.c
··· 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 + 26 + void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data) 27 + { 28 + iowrite32(data, priv->base + reg); 29 + } 30 + 31 + static 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 + 46 + static int usbhs_rcar3_get_id(struct platform_device *pdev) 47 + { 48 + return USBHS_GADGET; 49 + } 50 + 51 + const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = { 52 + .power_ctrl = usbhs_rcar3_power_ctrl, 53 + .get_id = usbhs_rcar3_get_id, 54 + };
+3
drivers/usb/renesas_usbhs/rcar3.h
··· 1 + #include "common.h" 2 + 3 + extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops;
+1
include/linux/usb/renesas_usbhs.h
··· 184 184 }; 185 185 186 186 #define USBHS_TYPE_RCAR_GEN2 1 187 + #define USBHS_TYPE_RCAR_GEN3 2 187 188 188 189 /* 189 190 * option: