Re: [PATCH v5 (RESEND) 1/7] phy: phy-hi3670-usb3: move driver from staging into phy

2021-03-31 Thread Vinod Koul
On 25-03-21, 19:05, Mauro Carvalho Chehab wrote:
> The phy USB3 driver for Hisilicon 970 (hi3670) is ready
> for mainstream. Mode it from staging into the main driver's
> phy/ directory.

Overall lgtm, some nits below. With those fixed:

Acked-By: Vinod Koul 

> +static int hi3670_phy_cr_clk(struct regmap *usb31misc)
> +{
> + int ret;
> +
> + /* Clock up */
> + ret = regmap_update_bits(usb31misc, USB_MISC_CFG54,
> +  CFG54_USB31PHY_CR_CLK, CFG54_USB31PHY_CR_CLK);
> + if (ret)
> + return ret;
> +
> + /* Clock down */
> + ret = regmap_update_bits(usb31misc, USB_MISC_CFG54,
> +  CFG54_USB31PHY_CR_CLK, 0);
> +
> + return ret;

return regmap_update_bits() ?
 (i see few more in driver like this, pls change others as well)

> +static int hi3670_phy_cr_read(struct regmap *usb31misc, u32 addr, u32 *val)
> +{
> + int reg;
> + int i;
> + int ret;

all these could be in a single line

-- 
~Vinod


[PATCH v5 (RESEND) 1/7] phy: phy-hi3670-usb3: move driver from staging into phy

2021-03-25 Thread Mauro Carvalho Chehab
The phy USB3 driver for Hisilicon 970 (hi3670) is ready
for mainstream. Mode it from staging into the main driver's
phy/ directory.

Acked-by: Rob Herring 
Signed-off-by: Mauro Carvalho Chehab 
---
 .../bindings/phy/hisilicon,hi3670-usb3.yaml   |  73 ++
 MAINTAINERS   |   9 +-
 drivers/phy/hisilicon/Kconfig |  10 +
 drivers/phy/hisilicon/Makefile|   1 +
 drivers/phy/hisilicon/phy-hi3670-usb3.c   | 668 ++
 drivers/staging/hikey9xx/Kconfig  |  11 -
 drivers/staging/hikey9xx/Makefile |   2 -
 drivers/staging/hikey9xx/phy-hi3670-usb3.c| 668 --
 drivers/staging/hikey9xx/phy-hi3670-usb3.yaml |  73 --
 9 files changed, 760 insertions(+), 755 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml
 create mode 100644 drivers/phy/hisilicon/phy-hi3670-usb3.c
 delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.c
 delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.yaml

diff --git a/Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml 
b/Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml
new file mode 100644
index ..ebd78acfe2de
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/hisilicon,hi3670-usb3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Hisilicon Kirin970 USB PHY
+
+maintainers:
+  - Mauro Carvalho Chehab 
+
+description: |+
+  Bindings for USB3 PHY on HiSilicon Kirin 970.
+
+properties:
+  compatible:
+const: hisilicon,hi3670-usb-phy
+
+  "#phy-cells":
+const: 0
+
+  hisilicon,pericrg-syscon:
+$ref: '/schemas/types.yaml#/definitions/phandle'
+description: phandle of syscon used to control iso refclk.
+
+  hisilicon,pctrl-syscon:
+$ref: '/schemas/types.yaml#/definitions/phandle'
+description: phandle of syscon used to control usb tcxo.
+
+  hisilicon,sctrl-syscon:
+$ref: '/schemas/types.yaml#/definitions/phandle'
+description: phandle of syscon used to control phy deep sleep.
+
+  hisilicon,eye-diagram-param:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: Eye diagram for phy.
+
+  hisilicon,tx-vboost-lvl:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: TX level vboost for phy.
+
+required:
+  - compatible
+  - hisilicon,pericrg-syscon
+  - hisilicon,pctrl-syscon
+  - hisilicon,sctrl-syscon
+  - hisilicon,eye-diagram-param
+  - hisilicon,tx-vboost-lvl
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+bus {
+  #address-cells = <2>;
+  #size-cells = <2>;
+
+  usb3_otg_bc: usb3_otg_bc@ff20 {
+compatible = "syscon", "simple-mfd";
+reg = <0x0 0xff20 0x0 0x1000>;
+
+usb_phy {
+  compatible = "hisilicon,hi3670-usb-phy";
+  #phy-cells = <0>;
+  hisilicon,pericrg-syscon = <_ctrl>;
+  hisilicon,pctrl-syscon = <>;
+  hisilicon,sctrl-syscon = <>;
+  hisilicon,eye-diagram-param = <0xfdfee4>;
+  hisilicon,tx-vboost-lvl = <0x5>;
+};
+  };
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 8c44fd8fd85d..a37489f5b070 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18654,7 +18654,7 @@ L:  linux-...@vger.kernel.org
 S: Maintained
 F: drivers/usb/roles/intel-xhci-usb-role-switch.c
 
-USB IP DRIVER FOR HISILICON KIRIN
+USB IP DRIVER FOR HISILICON KIRIN 960
 M: Yu Chen 
 M: Binghui Wang 
 L: linux-...@vger.kernel.org
@@ -18662,6 +18662,13 @@ S: Maintained
 F: Documentation/devicetree/bindings/phy/hisilicon,hi3660-usb3.yaml
 F: drivers/phy/hisilicon/phy-hi3660-usb3.c
 
+USB IP DRIVER FOR HISILICON KIRIN 970
+M: Mauro Carvalho Chehab 
+L: linux-...@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/phy/hisilicon,kirin970-usb3.yaml
+F: drivers/phy/hisilicon/phy-kirin970-usb3.c
+
 USB ISP116X DRIVER
 M: Olav Kongas 
 L: linux-...@vger.kernel.org
diff --git a/drivers/phy/hisilicon/Kconfig b/drivers/phy/hisilicon/Kconfig
index 1c73053bcc98..4d008cfc279c 100644
--- a/drivers/phy/hisilicon/Kconfig
+++ b/drivers/phy/hisilicon/Kconfig
@@ -23,6 +23,16 @@ config PHY_HI3660_USB
 
  To compile this driver as a module, choose M here.
 
+config PHY_HI3670_USB
+   tristate "hi3670 USB PHY support"
+   depends on (ARCH_HISI && ARM64) || COMPILE_TEST
+   select GENERIC_PHY
+   select MFD_SYSCON
+   help
+ Enable this to support the HISILICON HI3670 USB PHY.
+
+ To compile this driver as a module, choose M here.
+
 config PHY_HISTB_COMBPHY
tristate "HiSilicon STB SoCs COMBPHY support"
depends on (ARCH_HISI && ARM64) || COMPILE_TEST
diff --git a/drivers/phy/hisilicon/Makefile b/drivers/phy/hisilicon/Makefile
index