diff --git a/Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt b/Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt new file mode 100755 index 000000000000..26cab738ac7b --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt @@ -0,0 +1,21 @@ +Hisilicon hi3660 usb PHY +----------------------- + +Required properties: +- compatible: should be "hisilicon,hi3660-usb-phy" +- #phy-cells: must be 0 +- hisilicon,pericrg-syscon: phandle of syscon used to control phy. +- hisilicon,pctrl-syscon: phandle of syscon used to control phy. +- hisilicon,usb3-otg-bc-syscon: phandle of syscon used to control phy. +- eye-diagram-param: parameter set for phy +Refer to phy/phy-bindings.txt for the generic PHY binding properties + +Example: + usb_phy: usbphy { + compatible = "hisilicon,hi3660-usb-phy"; + #phy-cells = <0>; + hisilicon,pericrg-syscon = <&crg_ctrl>; + hisilicon,pctrl-syscon = <&pctrl>; + hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>; + eye-diagram-param = <0x22466e4>; + }; diff --git a/Documentation/devicetree/bindings/usb/dwc3-hisi.txt b/Documentation/devicetree/bindings/usb/dwc3-hisi.txt new file mode 100755 index 000000000000..f178973ea029 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/dwc3-hisi.txt @@ -0,0 +1,91 @@ +HiSilicon DWC3 USB SoC controller + +This file documents the parameters for the dwc3-hisi driver. + +Required properties: +- compatible: should be "hisilicon,hi3660-dwc3" or "hisilicon,kirin970-dwc3" +- clocks: A list of phandle + clock-specifier pairs for the + clocks listed in clock-names +- clock-names: Specify clock names +- resets: list of phandle and reset specifier pairs. + +Sub-nodes: +The dwc3 core should be added as subnode to HiSilicon DWC3 as shown in the +example below. The DT binding details of dwc3 can be found in: +Documentation/devicetree/bindings/usb/dwc3.txt + +Example: + usb3: hisi_dwc3 { + compatible = "hisilicon,hi3660-dwc3"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + clocks = <&crg_ctrl HI3660_CLK_ABB_USB>, + <&crg_ctrl HI3660_ACLK_GATE_USB3OTG>; + clock-names = "clk_usb3phy_ref", "aclk_usb3otg"; + assigned-clocks = <&crg_ctrl HI3660_ACLK_GATE_USB3OTG>; + assigned-clock-rates = <229000000>; + resets = <&crg_rst 0x90 8>, + <&crg_rst 0x90 7>, + <&crg_rst 0x90 6>, + <&crg_rst 0x90 5>; + + dwc3: dwc3@ff100000 { + compatible = "snps,dwc3"; + reg = <0x0 0xff100000 0x0 0x100000>; + interrupts = <0 159 4>, <0 161 4>; + phys = <&usb_phy>; + phy-names = "usb3-phy"; + dr_mode = "otg"; + maximum-speed = "super-speed"; + phy_type = "utmi"; + snps,dis-del-phy-power-chg-quirk; + snps,lfps_filter_quirk; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + snps,tx_de_emphasis_quirk; + snps,tx_de_emphasis = <1>; + snps,dis_enblslpm_quirk; + extcon = <&hisi_pd>; + }; + }; + + usb3: hisi_dwc3 { + compatible = "hisilicon,kirin970-dwc3"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + clocks = <&crg_ctrl KIRIN970_CLK_GATE_ABB_USB>, + <&crg_ctrl KIRIN970_HCLK_GATE_USB3OTG>, + <&crg_ctrl KIRIN970_CLK_GATE_USB3OTG_REF>, + <&crg_ctrl KIRIN970_ACLK_GATE_USB3DVFS>; + clock-names = "clk_gate_abb_usb", + "hclk_gate_usb3otg", + "clk_gate_usb3otg_ref", + "aclk_gate_usb3dvfs"; + assigned-clocks = <&crg_ctrl KIRIN970_ACLK_GATE_USB3DVFS>; + assigned-clock-rates = <238000000>; + resets = <&crg_rst 0x90 6>, + <&crg_rst 0x90 7>, + <&usb31_misc_rst 0xA0 8>, + <&usb31_misc_rst 0xA0 9>; + + dwc3: dwc3@ff100000 { + compatible = "snps,dwc3"; + reg = <0x0 0xff100000 0x0 0x100000>; + interrupts = <0 159 4>, <0 161 4>; + phys = <&usb_phy>; + phy-names = "usb3-phy"; + dr_mode = "otg"; + maximum-speed = "super-speed"; + phy_type = "utmi"; + snps,dis-del-phy-power-chg-quirk; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + snps,tx_de_emphasis_quirk; + snps,tx_de_emphasis = <1>; + extcon = <&hisi_pd>; + }; + }; diff --git a/Documentation/devicetree/bindings/usb/hisilicon-hikey-usb.txt b/Documentation/devicetree/bindings/usb/hisilicon-hikey-usb.txt new file mode 100644 index 000000000000..4a959f6174cb --- /dev/null +++ b/Documentation/devicetree/bindings/usb/hisilicon-hikey-usb.txt @@ -0,0 +1,21 @@ +Hisilicon support hub controller +----------------------------- + + +Required properties: +- compatible: "hisilicon,gpio_hubv1","hisilicon,gpio_hubv2" + +Example +----- + + hubv2: gpio_hubv2 { + compatible = "hisilicon,gpio_hubv2"; + typc_vbus_int_gpio,typec-gpios = <&gpio25 2 0>; + typc_vbus_enable_val = <1>; + otg_gpio = <&gpio25 6 0>; + hub_vdd12_en_gpio = <&gpio2 1 0>; + hub_vdd33_en_gpio = <&gpio5 6 0>; + hub_reset_en_gpio = <&gpio4 4 0>; + pinctrl-names = "default"; + pinctrl-0 = <&usbhub5734_pmx_func>; + }; diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index 070cfe65b353..0dabc701640b 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -527,7 +527,7 @@ }; }; - pd_dpm { + hisi_pd: pd_dpm { compatible = "hisilicon,pd_dpm"; tcp_name = "type_c_port0"; status = "ok"; @@ -1203,29 +1203,53 @@ pinctrl-0 = <&usbhub5734_pmx_func>; }; - hisi_usb@ff200000 { + usb3_otg_bc: usb3_otg_bc@ff200000 { + compatible = "syscon"; + reg = <0x0 0xff200000 0x0 0x1000>; + }; + + usb_phy: usbphy { + compatible = "hisilicon,hi3660-usb-phy"; + #phy-cells = <0>; + hisilicon,pericrg-syscon = <&crg_ctrl>; + hisilicon,pctrl-syscon = <&pctrl>; + hisilicon,usb3-otg-bc-syscon = <&usb3_otg_bc>; + eye-diagram-param = <0x22466e4>; + }; + + usb3: hisi_dwc3 { + compatible = "hisilicon,hi3660-dwc3"; #address-cells = <2>; #size-cells = <2>; - compatible = "hisilicon,hi3660-dwc3"; - reg = <0x0 0xff200000 0x0 0x1000 0x0 0xff100000 0x0 0x100000>; ranges; - bc_again_flag = <1>; clocks = <&crg_ctrl HI3660_CLK_ABB_USB>, <&crg_ctrl HI3660_ACLK_GATE_USB3OTG>; clock-names = "clk_usb3phy_ref", "aclk_usb3otg"; - eye_diagram_param = <0x1c466e3>; - eye_diagram_host_param = <0x1c466e3>; - usb3_phy_cr_param = <0xb80>; - usb3_phy_host_cr_param = <0x980>; - usb3_phy_tx_vboost_lvl = <0x5>; + assigned-clocks = <&crg_ctrl HI3660_ACLK_GATE_USB3OTG>; + assigned-clock-rates = <229000000>; + resets = <&crg_rst 0x90 8>, + <&crg_rst 0x90 7>, + <&crg_rst 0x90 6>, + <&crg_rst 0x90 5>; - dwc3@ff100000 { + dwc3: dwc3@ff100000 { compatible = "snps,dwc3"; reg = <0x0 0xff100000 0x0 0x100000>; interrupts = <0 159 4>, <0 161 4>; + phys = <&usb_phy>; + phy-names = "usb3-phy"; dr_mode = "otg"; maximum-speed = "super-speed"; + phy_type = "utmi"; + snps,dis-del-phy-power-chg-quirk; + snps,lfps_filter_quirk; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + snps,tx_de_emphasis_quirk; + snps,tx_de_emphasis = <1>; + snps,dis_enblslpm_quirk; + extcon = <&hisi_pd>; }; }; diff --git a/arch/arm64/configs/hikey960_defconfig b/arch/arm64/configs/hikey960_defconfig index 1439134c5cf7..5d0373f36d4f 100644 --- a/arch/arm64/configs/hikey960_defconfig +++ b/arch/arm64/configs/hikey960_defconfig @@ -214,7 +214,7 @@ CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_SIZE=16384 CONFIG_VIRTIO_BLK=y CONFIG_UID_SYS_STATS=y -CONFIG_HUB_USB5734=y +CONFIG_HISI_HIKEY_USB=y # CONFIG_SCSI_PROC_FS is not set CONFIG_BLK_DEV_SD=y CONFIG_SCSI_UFSHCD=y @@ -386,6 +386,7 @@ CONFIG_USB_OHCI_HCD_PLATFORM=y CONFIG_USB_ACM=y CONFIG_USB_STORAGE=y CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_HISI=y CONFIG_USB_DWC2=y CONFIG_USB_ISP1760=y CONFIG_TCPC_CLASS=y @@ -461,6 +462,7 @@ CONFIG_MALI_EXPERT=y CONFIG_MALI_PLATFORM_FAKE=y CONFIG_MALI_PLATFORM_HISILICON=y CONFIG_PHY_HI6220_USB=y +CONFIG_PHY_HI3660_USB=y CONFIG_PHY_XGENE=y CONFIG_ANDROID=y CONFIG_ANDROID_BINDER_IPC=y diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 5a126f6973e3..ba7a6674cbee 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -787,6 +787,13 @@ config MEMORY_STATE_TIME help Memory time statistics exported to /sys/kernel/memory_state_time +config HISI_HIKEY_USB + tristate "USB functionality of HiSilicon Hikey Platform" + depends on GPIOLIB + default n + help + If you say yes here you get support for usb functionality of HiSilicon Hikey Platform. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" @@ -799,5 +806,4 @@ source "drivers/misc/mic/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" source "drivers/misc/cxl/Kconfig" -source "drivers/misc/microchip/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 21d43ab8db76..a5576a985aba 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -53,7 +53,7 @@ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_PANEL) += panel.o -obj-y += microchip/ +obj-$(CONFIG_HISI_HIKEY_USB) +=hisi_hikey_usb.o obj-$(CONFIG_UID_SYS_STATS) += uid_sys_stats.o obj-$(CONFIG_MEMORY_STATE_TIME) += memory_state_time.o diff --git a/drivers/misc/microchip/hub/hub_usb5734.c b/drivers/misc/hisi_hikey_usb.c similarity index 72% rename from drivers/misc/microchip/hub/hub_usb5734.c rename to drivers/misc/hisi_hikey_usb.c index e71c9934b0b8..5951bbda91f5 100644 --- a/drivers/misc/microchip/hub/hub_usb5734.c +++ b/drivers/misc/hisi_hikey_usb.c @@ -1,5 +1,5 @@ /* - * otgid_gpio_hub.c + *hisi_hikey_usb.c * * Copyright (c) Hisilicon Tech. Co., Ltd. All rights reserved. * @@ -14,34 +14,12 @@ * GNU General Public License for more details. * */ -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include -#include -#define DEVICE_DRIVER_NAME "gpio_hub_for_usb5734" + +#define DEVICE_DRIVER_NAME "hisi_hikey_usb" #define GPIO_HUB_OTG_HOST 1 #define GPIO_HUB_OTG_DEVICE 0 @@ -54,8 +32,6 @@ /* SOC_CRGPERIPH_PEREN1_UNION */ #define SOC_CRGPERIPH_PEREN1_ADDR(base) ((base) + (0x010)) -#define HISILOG_TAG GPIO_HUB -HISILOG_REGIST(); struct gpio_hub_info { struct platform_device *pdev; @@ -77,12 +53,12 @@ void gpio_hub_power_off(void) if (gpio_is_valid(gpio_hub_driver_info.hub_vbus_gpio)) { gpio_set_value(gpio_hub_driver_info.hub_vbus_gpio, GPIO_HUB_VBUS_NO_POWER); - hisilog_info("%s: gpio hub hub vbus no power set success", + pr_info("%s: gpio hub hub vbus no power set success", __func__); - } else { - hisilog_err("%s: gpio hub hub vbus no power set err", + } else + pr_err("%s: gpio hub hub vbus no power set err", __func__); - } + } void gpio_hub_power_on(void) @@ -91,7 +67,7 @@ void gpio_hub_power_on(void) gpio_set_value(gpio_hub_driver_info.hub_vbus_gpio, GPIO_HUB_VBUS_POWER); else - hisilog_err("%s: gpio hub hub vbus set err", __func__); + pr_err("%s: gpio hub hub vbus set err", __func__); } void gpio_hub_switch_to_hub(void) @@ -99,17 +75,17 @@ void gpio_hub_switch_to_hub(void) int gpio = gpio_hub_driver_info.otg_switch_gpio; if (!gpio_is_valid(gpio)) { - hisilog_err("%s: otg_switch_gpio is err\n", __func__); + pr_err("%s: otg_switch_gpio is err\n", __func__); return; } if (gpio_get_value(gpio)) { - hisilog_info("%s: already switch to hub\n", __func__); + pr_info("%s: already switch to hub\n", __func__); return; } gpio_direction_output(gpio, 1); - hisilog_err("%s: switch to hub\n", __func__); + pr_info("%s: switch to hub\n", __func__); } EXPORT_SYMBOL_GPL(gpio_hub_switch_to_hub); @@ -118,34 +94,34 @@ void gpio_hub_switch_to_typec(void) int gpio = gpio_hub_driver_info.otg_switch_gpio; if (!gpio_is_valid(gpio)) { - hisilog_err("%s: otg_switch_gpio is err\n", __func__); + pr_err("%s: otg_switch_gpio is err\n", __func__); return; } if (!gpio_get_value(gpio)) { - hisilog_info("%s: already switch to typec\n", __func__); + pr_info("%s: already switch to typec\n", __func__); return; } gpio_direction_output(gpio, 0); - hisilog_err("%s: switch to typec\n", __func__); + pr_info("%s: switch to typec\n", __func__); } EXPORT_SYMBOL_GPL(gpio_hub_switch_to_typec); static void gpio_hub_change_typec_power(int gpio, int on) { if (!gpio_is_valid(gpio)) { - hisilog_err("%s: typec power gpio is err\n", __func__); + pr_err("%s: typec power gpio is err\n", __func__); return; } if (gpio_get_value(gpio) == on) { - hisilog_info("%s: typec power no change\n", __func__); + pr_info("%s: typec power no change\n", __func__); return; } gpio_direction_output(gpio, on); - hisilog_info("%s: set typec vbus gpio to %d\n", __func__, on); + pr_info("%s: set typec vbus gpio to %d\n", __func__, on); } void gpio_hub_typec_power_on(void) @@ -172,40 +148,37 @@ static int gpio_hub_probe(struct platform_device *pdev) struct device_node *root = pdev->dev.of_node; struct gpio_hub_info *info = &gpio_hub_driver_info; - hisilog_info("%s: step in\n", __func__); + pr_info("%s: step in\n", __func__); info->pdev = pdev; - if (!pdev) - return -EBUSY; - info->hub_vbus_gpio = of_get_named_gpio(root, "hub_vdd33_en_gpio", 0); if (!gpio_is_valid(info->hub_vbus_gpio)) { - hisilog_err("%s: hub_vbus_gpio is err\n", __func__); - return info->hub_vbus_gpio; + pr_err("%s: hub_vbus_gpio is err\n", __func__); + return -EINVAL; } ret = gpio_request(info->hub_vbus_gpio, "hub_vbus_int_gpio"); if (ret) { - hisilog_err("%s: request hub_vbus_gpio err\n", __func__); + pr_err("%s: request hub_vbus_gpio err\n", __func__); return ret; } info->typec_vbus_gpio = of_get_named_gpio(root, "typc_vbus_int_gpio,typec-gpios", 0); if (!gpio_is_valid(info->hub_vbus_gpio)) { - hisilog_err("%s: typec_vbus_gpio is err\n", __func__); + pr_err("%s: typec_vbus_gpio is err\n", __func__); ret = info->typec_vbus_gpio; goto free_gpio1; } ret = gpio_request(info->typec_vbus_gpio, "typc_vbus_int_gpio"); if (ret) { - hisilog_err("%s: request typec_vbus_gpio err\n", __func__); + pr_err("%s: request typec_vbus_gpio err\n", __func__); goto free_gpio1; } ret = of_property_read_u32(root, "typc_vbus_enable_val", &info->typec_vbus_enable_val); if (ret) { - hisilog_err("%s: typc_vbus_enable_val can't get\n", __func__); + pr_err("%s: typc_vbus_enable_val can't get\n", __func__); goto free_gpio2; } info->typec_vbus_enable_val = !!info->typec_vbus_enable_val; @@ -213,20 +186,20 @@ static int gpio_hub_probe(struct platform_device *pdev) /* only for v2 */ info->otg_switch_gpio = of_get_named_gpio(root, "otg_gpio", 0); if (!gpio_is_valid(info->otg_switch_gpio)) { - hisilog_info("%s: otg_switch_gpio is err\n", __func__); + pr_info("%s: otg_switch_gpio is err\n", __func__); info->otg_switch_gpio = -1; } ret = gpio_direction_output(info->hub_vbus_gpio, GPIO_HUB_VBUS_POWER); if (ret) { - hisilog_err("%s: power on hub vbus err\n", __func__); + pr_err("%s: power on hub vbus err\n", __func__); goto free_gpio2; } ret = gpio_direction_output(info->typec_vbus_gpio, info->typec_vbus_enable_val); if (ret) { - hisilog_err("%s: power on typec vbus err", __func__); + pr_err("%s: power on typec vbus err", __func__); goto free_gpio2; } @@ -283,7 +256,7 @@ static int __init gpio_hub_init(void) { int ret = platform_driver_register(&gpio_hub_driver); - hisilog_info("%s:gpio hub init status:%d\n", __func__, ret); + pr_info("%s:gpio hub init status:%d\n", __func__, ret); return ret; } diff --git a/drivers/misc/microchip/Kconfig b/drivers/misc/microchip/Kconfig deleted file mode 100644 index 9e4e4cd505a6..000000000000 --- a/drivers/misc/microchip/Kconfig +++ /dev/null @@ -1,7 +0,0 @@ -# -# Microchip devices -# - -menu "Microchip devices" -source "drivers/misc/microchip/hub/Kconfig" -endmenu diff --git a/drivers/misc/microchip/Makefile b/drivers/misc/microchip/Makefile deleted file mode 100644 index cc71719d7ecf..000000000000 --- a/drivers/misc/microchip/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# -# Makefile for microchip devices that really don't fit anywhere else. -# -obj-y += hub/ \ No newline at end of file diff --git a/drivers/misc/microchip/hub/Kconfig b/drivers/misc/microchip/hub/Kconfig deleted file mode 100644 index 258be0073082..000000000000 --- a/drivers/misc/microchip/hub/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -config HUB_USB5734 - tristate "HUB_USB5734" - depends on GPIOLIB - default n - help - If you say yes here you get support for HUB_USB5734. diff --git a/drivers/misc/microchip/hub/Makefile b/drivers/misc/microchip/hub/Makefile deleted file mode 100644 index 3ff884cd5da4..000000000000 --- a/drivers/misc/microchip/hub/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_HUB_USB5734) +=hub_usb5734.o diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 7dc726d7fbde..225f02acabdb 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -261,6 +261,16 @@ config PHY_HI6220_USB To compile this driver as a module, choose M here. +config PHY_HI3660_USB + tristate "hi3660 USB PHY support" + depends on (ARCH_HISI && ARM64) || COMPILE_TEST + select GENERIC_PHY + select MFD_SYSCON + help + Enable this to support the HISILICON HI3660 USB PHY. + + To compile this driver as a module, choose M here. + config PHY_SUN4I_USB tristate "Allwinner sunxi SoC USB PHY driver" depends on ARCH_SUNXI && HAS_IOMEM && OF diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index a534cf5be07d..b303283ed294 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o obj-$(CONFIG_PHY_HI6220_USB) += phy-hi6220-usb.o +obj-$(CONFIG_PHY_HI3660_USB) += phy-hi3660-usb3.o obj-$(CONFIG_PHY_MT65XX_USB3) += phy-mt65xx-usb3.o obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SUN9I_USB) += phy-sun9i-usb.o diff --git a/drivers/phy/phy-hi3660-usb3.c b/drivers/phy/phy-hi3660-usb3.c new file mode 100755 index 000000000000..d1bb9cac2333 --- /dev/null +++ b/drivers/phy/phy-hi3660-usb3.c @@ -0,0 +1,253 @@ +/* + * Phy provider for USB 3.0 controller on HiSilicon 3660 platform + * + * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd. + * http://www.huawei.com + * + * Authors: Yu Chen + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 of + * the License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include + +#define PERI_CRG_CLK_EN4 (0x40) +#define PERI_CRG_CLK_DIS4 (0x44) +#define GT_CLK_USB3OTG_REF BIT(0) +#define GT_ACLK_USB3OTG BIT(1) + +#define PERI_CRG_RSTEN4 (0x90) +#define PERI_CRG_RSTDIS4 (0x94) +#define IP_RST_USB3OTGPHY_POR BIT(3) +#define IP_RST_USB3OTG BIT(5) + +#define PERI_CRG_ISODIS (0x148) +#define USB_REFCLK_ISO_EN BIT(25) + +#define PCTRL_PERI_CTRL3 (0x10) +#define PCTRL_PERI_CTRL3_MSK_START (16) +#define USB_TCXO_EN BIT(1) + +#define PCTRL_PERI_CTRL24 (0x64) +#define SC_CLK_USB3PHY_3MUX1_SEL BIT(25) + +#define USBOTG3_CTRL0 (0x00) +#define SC_USB3PHY_ABB_GT_EN BIT(15) + +#define USBOTG3_CTRL2 (0x08) +#define USBOTG3CTRL2_POWERDOWN_HSP BIT(0) +#define USBOTG3CTRL2_POWERDOWN_SSP BIT(1) + +#define USBOTG3_CTRL3 (0x0C) +#define USBOTG3_CTRL3_VBUSVLDEXT BIT(6) +#define USBOTG3_CTRL3_VBUSVLDEXTSEL BIT(5) + +#define USBOTG3_CTRL4 (0x10) + +#define USBOTG3_CTRL7 (0x1c) +#define REF_SSP_EN BIT(16) + +#define HI3660_USB_DEFAULT_PHY_PARAM (0x1c466e3) + +struct hi3660_priv { + struct device *dev; + struct regmap *peri_crg; + struct regmap *pctrl; + struct regmap *otg_bc; + u32 eye_diagram_param; + + u32 peri_crg_offset; + u32 pctrl_offset; + u32 otg_bc_offset; +}; + +static int hi3660_phy_init(struct phy *phy) +{ + struct hi3660_priv *priv = phy_get_drvdata(phy); + u32 val, mask; + int ret; + + /* usb refclk iso disable */ + ret = regmap_write(priv->peri_crg, PERI_CRG_ISODIS, USB_REFCLK_ISO_EN); + if (ret) + goto out; + + /* enable usb_tcxo_en */ + val = USB_TCXO_EN | (USB_TCXO_EN << PCTRL_PERI_CTRL3_MSK_START); + ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, val); + if (ret) + goto out; + + /* select usbphy clk from abb */ + mask = SC_CLK_USB3PHY_3MUX1_SEL; + ret = regmap_update_bits(priv->pctrl, PCTRL_PERI_CTRL24, mask, 0); + if (ret) + goto out; + + /* assert phy */ + val = IP_RST_USB3OTGPHY_POR | IP_RST_USB3OTG; + ret = regmap_write(priv->peri_crg, PERI_CRG_RSTEN4, val); + if (ret) + goto out; + + /* enable phy ref clk */ + val = SC_USB3PHY_ABB_GT_EN; + mask = val; + ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL0, mask, val); + if (ret) + goto out; + + val = REF_SSP_EN; + mask = val; + ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL7, mask, val); + if (ret) + goto out; + + /* exit from IDDQ mode */ + mask = USBOTG3CTRL2_POWERDOWN_HSP | USBOTG3CTRL2_POWERDOWN_SSP; + ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL2, mask, 0); + if (ret) + goto out; + + udelay(100); + + /* deassert phy */ + val = IP_RST_USB3OTGPHY_POR | IP_RST_USB3OTG; + ret = regmap_write(priv->peri_crg, PERI_CRG_RSTDIS4, val); + if (ret) + goto out; + + usleep_range(10000, 15000); + + /* fake vbus valid signal */ + val = USBOTG3_CTRL3_VBUSVLDEXT | USBOTG3_CTRL3_VBUSVLDEXTSEL; + mask = val; + ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL3, mask, val); + if (ret) + goto out; + + udelay(100); + + ret = regmap_write(priv->otg_bc, USBOTG3_CTRL4, + priv->eye_diagram_param); + if (ret) + goto out; + + return 0; +out: + dev_err(priv->dev, "failed to init phy ret: %d\n", ret); + return ret; +} + +static int hi3660_phy_exit(struct phy *phy) +{ + struct hi3660_priv *priv = phy_get_drvdata(phy); + u32 val, mask; + int ret; + + /* assert phy */ + val = IP_RST_USB3OTGPHY_POR; + ret = regmap_write(priv->peri_crg, PERI_CRG_RSTEN4, val); + if (ret) + goto out; + + val = SC_CLK_USB3PHY_3MUX1_SEL; + mask = SC_CLK_USB3PHY_3MUX1_SEL; + ret = regmap_update_bits(priv->pctrl, PCTRL_PERI_CTRL24, mask, val); + if (ret) + goto out; + + /* disable usb_tcxo_en */ + val = USB_TCXO_EN << PCTRL_PERI_CTRL3_MSK_START; + ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, val); + if (ret) + goto out; + + return 0; +out: + dev_err(priv->dev, "failed to exit phy ret: %d\n", ret); + return ret; +} + +static struct phy_ops hi3660_phy_ops = { + .init = hi3660_phy_init, + .exit = hi3660_phy_exit, + .owner = THIS_MODULE, +}; + +static int hi3660_phy_probe(struct platform_device *pdev) +{ + struct phy_provider *phy_provider; + struct device *dev = &pdev->dev; + struct phy *phy; + struct hi3660_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + priv->peri_crg = syscon_regmap_lookup_by_phandle(dev->of_node, + "hisilicon,pericrg-syscon"); + if (IS_ERR(priv->peri_crg)) { + dev_err(dev, "no hisilicon,pericrg-syscon\n"); + return PTR_ERR(priv->peri_crg); + } + + priv->pctrl = syscon_regmap_lookup_by_phandle(dev->of_node, + "hisilicon,pctrl-syscon"); + if (IS_ERR(priv->pctrl)) { + dev_err(dev, "no hisilicon,pctrl-syscon\n"); + return PTR_ERR(priv->pctrl); + } + + priv->otg_bc = syscon_regmap_lookup_by_phandle(dev->of_node, + "hisilicon,usb3-otg-bc-syscon"); + if (IS_ERR(priv->otg_bc)) { + dev_err(dev, "no hisilicon,usb3-otg-bc-syscon\n"); + return PTR_ERR(priv->otg_bc); + } + + if (of_property_read_u32(dev->of_node, "eye-diagram-param", + &(priv->eye_diagram_param))) + priv->eye_diagram_param = HI3660_USB_DEFAULT_PHY_PARAM; + + phy = devm_phy_create(dev, NULL, &hi3660_phy_ops); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + phy_set_drvdata(phy, priv); + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + return PTR_ERR_OR_ZERO(phy_provider); +} + +static const struct of_device_id hi3660_phy_of_match[] = { + {.compatible = "hisilicon,hi3660-usb-phy",}, + { }, +}; +MODULE_DEVICE_TABLE(of, hi3660_phy_of_match); + +static struct platform_driver hi3660_phy_driver = { + .probe = hi3660_phy_probe, + .driver = { + .name = "hi3660-usb-phy", + .of_match_table = hi3660_phy_of_match, + } +}; +module_platform_driver(hi3660_phy_driver); + +MODULE_AUTHOR("Yu Chen "); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Hilisicon Hi3660 USB3 PHY Driver"); diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index aee55114d269..556521cf4fd5 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -106,4 +106,12 @@ config USB_DWC3_ST inside (i.e. STiH407). Say 'Y' or 'M' if you have one such device. +config USB_DWC3_HISI + tristate "HiSilicon Kirin Platforms" + depends on ((ARCH_HISI && ARM64) || COMPILE_TEST) && OF + default USB_DWC3 + help + Support of USB2/3 functionality in HiSilicon Kirin platforms. + Say 'Y' or 'M' if you have one such device. + endif diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index f15fabbd1e59..eef713b7cbdd 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -47,3 +47,4 @@ obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o obj-$(CONFIG_USB_DWC3_OF_SIMPLE) += dwc3-of-simple.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_HISI) += dwc3-hisi.o diff --git a/drivers/usb/dwc3/dwc3-hisi.c b/drivers/usb/dwc3/dwc3-hisi.c new file mode 100755 index 000000000000..9b40b5ec6ead --- /dev/null +++ b/drivers/usb/dwc3/dwc3-hisi.c @@ -0,0 +1,329 @@ +/** + * dwc3-hisi.c - Support for dwc3 platform devices on HiSilicon platforms + * + * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd. + * http://www.huawei.com + * + * Authors: Yu Chen + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 of + * the License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct dwc3_hisi { + struct device *dev; + struct regulator *usb_regu; + struct clk **clks; + int num_clocks; + struct reset_control **rstcs; + int num_rstcs; +}; + +struct dwc3_hisi *g_dwc3_hisi; + +static int dwc3_hisi_init_clks(struct dwc3_hisi *dwc3_hisi, + struct device_node *np) +{ + struct device *dev = dwc3_hisi->dev; + int i; + + dwc3_hisi->num_clocks = of_clk_get_parent_count(np); + if (!dwc3_hisi->num_clocks) + return -ENOENT; + + dwc3_hisi->clks = devm_kcalloc(dev, dwc3_hisi->num_clocks, + sizeof(struct clk *), GFP_KERNEL); + if (!dwc3_hisi->clks) + return -ENOMEM; + + for (i = 0; i < dwc3_hisi->num_clocks; i++) { + struct clk *clk; + + clk = of_clk_get(np, i); + if (IS_ERR(clk)) { + while (--i >= 0) + clk_put(dwc3_hisi->clks[i]); + + return PTR_ERR(clk); + } + + dwc3_hisi->clks[i] = clk; + } + + return 0; +} + +static int dwc3_hisi_enable_clks(struct dwc3_hisi *dwc3_hisi) +{ + int i; + int ret; + + for (i = 0; i < dwc3_hisi->num_clocks; i++) { + ret = clk_prepare_enable(dwc3_hisi->clks[i]); + if (ret < 0) { + while (--i >= 0) + clk_disable_unprepare(dwc3_hisi->clks[i]); + + return ret; + } + } + + return 0; +} + +static void dwc3_hisi_disable_clks(struct dwc3_hisi *dwc3_hisi) +{ + int i; + + for (i = 0; i < dwc3_hisi->num_clocks; i++) + clk_disable_unprepare(dwc3_hisi->clks[i]); +} + +static int dwc3_hisi_get_rstcs(struct dwc3_hisi *dwc3_hisi, + struct device_node *np) +{ + struct device *dev = dwc3_hisi->dev; + int i; + + dwc3_hisi->num_rstcs = of_count_phandle_with_args(np, + "resets", "#reset-cells"); + if (!dwc3_hisi->num_rstcs) + return -ENOENT; + + dwc3_hisi->rstcs = devm_kcalloc(dev, dwc3_hisi->num_rstcs, + sizeof(struct reset_control *), GFP_KERNEL); + if (!dwc3_hisi->rstcs) + return -ENOMEM; + + for (i = 0; i < dwc3_hisi->num_rstcs; i++) { + struct reset_control *rstc; + + rstc = of_reset_control_get_shared_by_index(np, i); + if (IS_ERR(rstc)) { + while (--i >= 0) + reset_control_put(dwc3_hisi->rstcs[i]); + return PTR_ERR(rstc); + } + + dwc3_hisi->rstcs[i] = rstc; + } + + return 0; +} + +static int dwc3_hisi_reset_control_assert(struct dwc3_hisi *dwc3_hisi) +{ + int i, ret; + + for (i = dwc3_hisi->num_rstcs - 1; i >= 0 ; i--) { + ret = reset_control_assert(dwc3_hisi->rstcs[i]); + if (ret) { + while (--i >= 0) + reset_control_deassert(dwc3_hisi->rstcs[i]); + return ret; + } + udelay(10); + } + + return 0; +} + +static int dwc3_hisi_reset_control_deassert(struct dwc3_hisi *dwc3_hisi) +{ + int i, ret; + + for (i = 0; i < dwc3_hisi->num_rstcs; i++) { + ret = reset_control_deassert(dwc3_hisi->rstcs[i]); + if (ret) { + while (--i >= 0) + reset_control_assert(dwc3_hisi->rstcs[i]); + return ret; + } + udelay(10); + } + + return 0; +} + +static int dwc3_hisi_probe(struct platform_device *pdev) +{ + struct dwc3_hisi *dwc3_hisi; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + + int ret; + int i; + + dwc3_hisi = devm_kzalloc(dev, sizeof(*dwc3_hisi), GFP_KERNEL); + if (!dwc3_hisi) + return -ENOMEM; + + platform_set_drvdata(pdev, dwc3_hisi); + dwc3_hisi->dev = dev; + + ret = dwc3_hisi_init_clks(dwc3_hisi, np); + if (ret) { + dev_err(dev, "could not get clocks\n"); + return ret; + } + + ret = dwc3_hisi_enable_clks(dwc3_hisi); + if (ret) { + dev_err(dev, "could not enable clocks\n"); + goto err_put_clks; + } + + ret = dwc3_hisi_get_rstcs(dwc3_hisi, np); + if (ret) { + dev_err(dev, "could not get reset controllers\n"); + goto err_disable_clks; + } + ret = dwc3_hisi_reset_control_deassert(dwc3_hisi); + if (ret) { + dev_err(dev, "reset control deassert failed\n"); + goto err_put_rstcs; + } + + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); + + ret = of_platform_populate(np, NULL, NULL, dev); + if (ret) { + dev_err(dev, "failed to add dwc3 core\n"); + goto err_reset_assert; + } + + g_dwc3_hisi = dwc3_hisi; + return 0; + +err_reset_assert: + ret = dwc3_hisi_reset_control_assert(dwc3_hisi); + if (ret) + dev_err(dev, "reset control assert failed\n"); +err_put_rstcs: + for (i = 0; i < dwc3_hisi->num_rstcs; i++) + reset_control_put(dwc3_hisi->rstcs[i]); +err_disable_clks: + dwc3_hisi_disable_clks(dwc3_hisi); +err_put_clks: + for (i = 0; i < dwc3_hisi->num_clocks; i++) + clk_put(dwc3_hisi->clks[i]); + + return ret; +} + +static int dwc3_hisi_remove(struct platform_device *pdev) +{ + struct dwc3_hisi *dwc3_hisi = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + int i, ret; + + of_platform_depopulate(dev); + + ret = dwc3_hisi_reset_control_assert(dwc3_hisi); + if (ret) { + dev_err(dev, "reset control assert failed\n"); + return ret; + } + + for (i = 0; i < dwc3_hisi->num_clocks; i++) { + clk_disable_unprepare(dwc3_hisi->clks[i]); + clk_put(dwc3_hisi->clks[i]); + } + + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int dwc3_hisi_suspend(struct device *dev) +{ + struct dwc3_hisi *dwc3_hisi = dev_get_drvdata(dev); + int ret; + + dev_info(dev, "%s\n", __func__); + + ret = dwc3_hisi_reset_control_assert(dwc3_hisi); + if (ret) { + dev_err(dev, "reset control assert failed\n"); + return ret; + } + + dwc3_hisi_disable_clks(dwc3_hisi); + pinctrl_pm_select_default_state(dev); + return 0; +} + +static int dwc3_hisi_resume(struct device *dev) +{ + struct dwc3_hisi *dwc3_hisi = dev_get_drvdata(dev); + int ret; + + dev_info(dev, "%s\n", __func__); + pinctrl_pm_select_default_state(dev); + + ret = dwc3_hisi_enable_clks(dwc3_hisi); + if (ret) { + dev_err(dev, "could not enable clocks\n"); + return ret; + } + + ret = dwc3_hisi_reset_control_deassert(dwc3_hisi); + if (ret) { + dev_err(dev, "reset control deassert failed\n"); + return ret; + } + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(dwc3_hisi_dev_pm_ops, + dwc3_hisi_suspend, dwc3_hisi_resume); + +static const struct of_device_id dwc3_hisi_match[] = { + { .compatible = "hisilicon,hi3660-dwc3" }, + { .compatible = "hisilicon,kirin970-dwc3" }, + { /* sentinel */ }, +}; + +MODULE_DEVICE_TABLE(of, dwc3_hisi_match); + +static struct platform_driver dwc3_hisi_driver = { + .probe = dwc3_hisi_probe, + .remove = dwc3_hisi_remove, + .driver = { + .name = "usb-hisi-dwc3", + .of_match_table = dwc3_hisi_match, + .pm = &dwc3_hisi_dev_pm_ops, + }, +}; + +module_platform_driver(dwc3_hisi_driver); + +MODULE_AUTHOR("Yu Chen "); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("DesignWare USB3 HiSilicon Glue Layer"); diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index b1d22d8c9f7e..4aa14d9f1e44 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1566,7 +1566,7 @@ static const struct usb_gadget_driver configfs_driver_template = { .owner = THIS_MODULE, .name = "configfs-gadget", }, - .match_existing_only = 1, + .match_existing_only = 0, }; #ifdef CONFIG_USB_CONFIGFS_UEVENT diff --git a/drivers/usb/pd/hisi_pd.c b/drivers/usb/pd/hisi_pd.c index 5fe0f46bd1e9..909bece8ac5e 100644 --- a/drivers/usb/pd/hisi_pd.c +++ b/drivers/usb/pd/hisi_pd.c @@ -36,9 +36,9 @@ #include #include #include +#include #include #include -#include #include struct pd_dpm_info *g_pd_di; @@ -52,6 +52,12 @@ static int pd_dpm_typec_state; HISILOG_REGIST(); #endif +static const unsigned int usb_extcon_cable[] = { + EXTCON_USB, + EXTCON_USB_HOST, + EXTCON_NONE, +}; + static bool pd_dpm_get_cc_orientation(void) { hisilog_info("%s cc_orientation =%d\n", __func__, g_pd_cc_orientation); @@ -283,13 +289,16 @@ static inline void pd_dpm_report_device_attach(void) if (pd_dpm_get_pd_finish_flag()) { hisilog_info("%s, in pd process, report charger connect event\n", __func__); - hisi_usb_otg_event(CHARGER_CONNECT_EVENT); } + extcon_set_state_sync(g_pd_di->edev, EXTCON_USB_HOST, false); + extcon_set_state_sync(g_pd_di->edev, EXTCON_USB, true); } static inline void pd_dpm_report_host_attach(void) { hisilog_info("%s \r\n", __func__); + extcon_set_state_sync(g_pd_di->edev, EXTCON_USB, false); + extcon_set_state_sync(g_pd_di->edev, EXTCON_USB_HOST, true); } static inline void pd_dpm_report_device_detach(void) @@ -298,8 +307,9 @@ static inline void pd_dpm_report_device_detach(void) if (pd_dpm_get_pd_finish_flag()) { hisilog_info("%s, in pd process, report charger connect event\n", __func__); - hisi_usb_otg_event(CHARGER_DISCONNECT_EVENT); } + extcon_set_state_sync(g_pd_di->edev, EXTCON_USB, false); + extcon_set_state_sync(g_pd_di->edev, EXTCON_USB_HOST, true); pd_dpm_vbus_notifier_call(g_pd_di, CHARGER_TYPE_NONE, NULL); } @@ -530,11 +540,6 @@ static int pd_dpm_probe(struct platform_device *pdev) ATOMIC_INIT_NOTIFIER_HEAD(&di->pd_evt_nh); ATOMIC_INIT_NOTIFIER_HEAD(&di->pd_wake_unlock_evt_nh); - di->usb_nb.notifier_call = pd_dpm_report_bc12; - ret = hisi_charger_type_notifier_register(&di->usb_nb); - if (ret < 0) - hisilog_err("hisi_charger_type_notifier_register failed\n"); - if (typec_class) { typec_dev = device_create(typec_class, NULL, 0, NULL, "typec"); ret = sysfs_create_group(&typec_dev->kobj, &pd_dpm_attr_group); @@ -543,6 +548,19 @@ static int pd_dpm_probe(struct platform_device *pdev) __func__); } + di->edev = devm_extcon_dev_allocate(di->dev, usb_extcon_cable); + if (IS_ERR(di->edev)) { + dev_err(di->dev, "failed to allocate extcon device\n"); + return -ENOMEM; + } + + ret = devm_extcon_dev_register(di->dev, di->edev); + if (ret < 0) { + dev_err(di->dev, "failed to register extcon device\n"); + return ret; + } + extcon_set_state(g_pd_di->edev, EXTCON_USB_HOST, true); + hisilog_info("%s ++++\r\n\r\n", __func__); di->last_usb_event = PD_DPM_USB_TYPEC_NONE; diff --git a/drivers/usb/pd/richtek/tcpci_typec.c b/drivers/usb/pd/richtek/tcpci_typec.c index 65b08a399b77..58b35fccbb90 100644 --- a/drivers/usb/pd/richtek/tcpci_typec.c +++ b/drivers/usb/pd/richtek/tcpci_typec.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_TYPEC_CAP_TRY_SOURCE @@ -375,14 +375,10 @@ static void typec_unattached_entry(struct tcpc_device *tcpc_dev) oldstatus, tcpc_dev->typec_state); gpio_hub_power_on(); - hisi_usb_otg_event(CHARGER_DISCONNECT_EVENT); - hisi_usb_otg_event(ID_FALL_EVENT); oldstatus = TYPEC_HOST; } else if (oldstatus == TYPEC_INIT) { TYPEC_DBG("init otg host no insert.\r\n"); gpio_hub_power_on(); - hisi_usb_otg_event(CHARGER_DISCONNECT_EVENT); - hisi_usb_otg_event(ID_FALL_EVENT); oldstatus = TYPEC_HOST; } else { TYPEC_DBG("host off, otg host:%d:%d\r\n", @@ -501,8 +497,6 @@ static inline void typec_custom_src_attached_entry( gpio_hub_power_off(); gpio_hub_typec_power_off(); - hisi_usb_otg_event(ID_RISE_EVENT); - hisi_usb_otg_event(CHARGER_CONNECT_EVENT); return; } #endif /* CONFIG_TYPEC_CAP_CUSTOM_SRC */ @@ -668,9 +662,7 @@ static inline void typec_cc_snk_detect_vsafe5v_entry( oldstatus = TYPEC_DEVICE; gpio_hub_power_off(); gpio_hub_typec_power_off(); - hisi_usb_otg_event(ID_RISE_EVENT); gpio_hub_switch_to_typec(); - hisi_usb_otg_event(CHARGER_CONNECT_EVENT); #ifdef CONFIG_TYPEC_CAP_TRY_SOURCE if (tcpc_dev->typec_role == TYPEC_ROLE_TRY_SRC) { if (tcpc_dev->typec_state == typec_attachwait_snk) { @@ -1590,9 +1582,7 @@ static int typec_init_power_off_charge(struct tcpc_device *tcpc_dev) gpio_hub_power_on(); gpio_hub_typec_power_off(); - hisi_usb_otg_event(CHARGER_DISCONNECT_EVENT); gpio_hub_switch_to_hub(); - hisi_usb_otg_event(ID_FALL_EVENT); oldstatus = TYPEC_HOST; TYPEC_NEW_STATE(typec_unattached_snk); diff --git a/include/linux/hisi/usb/hub/hisi_hub.h b/include/linux/hisi/usb/hisi_hikey_usb.h similarity index 97% rename from include/linux/hisi/usb/hub/hisi_hub.h rename to include/linux/hisi/usb/hisi_hikey_usb.h index 99df5772df96..66dad3156946 100644 --- a/include/linux/hisi/usb/hub/hisi_hub.h +++ b/include/linux/hisi/usb/hisi_hikey_usb.h @@ -1,5 +1,5 @@ /* - * hub_usb5734.h + * hisi_hikey_usb.h * * Copyright (c) Hisilicon Tech. Co., Ltd. All rights reserved. * diff --git a/include/linux/hisi/usb/hisi_pd_dev.h b/include/linux/hisi/usb/hisi_pd_dev.h index 68b6fc9356d9..c660de24a790 100644 --- a/include/linux/hisi/usb/hisi_pd_dev.h +++ b/include/linux/hisi/usb/hisi_pd_dev.h @@ -14,7 +14,6 @@ #define __HISI_PD_DEV_H__ #include -#include #include #define CONFIG_DPM_USB_PD_CUSTOM_DBGACC @@ -144,6 +143,17 @@ struct pd_dpm_vbus_state { u8 vbus_type; }; +enum hisi_charger_type { + CHARGER_TYPE_SDP = 0, /* Standard Downstreame Port */ + CHARGER_TYPE_CDP, /* Charging Downstreame Port */ + CHARGER_TYPE_DCP, /* Dedicate Charging Port */ + CHARGER_TYPE_UNKNOWN, /* non-standard */ + CHARGER_TYPE_NONE, /* not connected */ + + /* other messages */ + PLEASE_PROVIDE_POWER, /* host mode, provide power */ +}; + struct pd_dpm_info { struct i2c_client *client; struct device *dev; @@ -153,7 +163,6 @@ struct pd_dpm_info { struct dual_role_phy_instance *dual_role; struct dual_role_phy_desc *desc; - enum hisi_charger_type charger_type; struct notifier_block usb_nb; struct atomic_notifier_head pd_evt_nh; struct atomic_notifier_head pd_wake_unlock_evt_nh; @@ -175,6 +184,8 @@ struct pd_dpm_info { bool pd_source_vbus; struct pd_dpm_vbus_state bc12_sink_vbus_state; + + struct extcon_dev *edev; }; /* for chip layer to get class created by core layer */