From 4d8abe669caabac7a2fccd19027786b4b00e9141 Mon Sep 17 00:00:00 2001 From: Yue Wang Date: Tue, 28 Mar 2017 11:11:55 +0800 Subject: [PATCH] usb: enable meson8b usb driver PD#141217: usb: enable meson8b usb driver Change-Id: I4c7e99b83322da8a691293f4cee45a91d7e0b38e Signed-off-by: Yue Wang --- arch/arm/boot/dts/amlogic/meson8b.dtsi | 57 +++++++++ arch/arm/configs/meson32_defconfig | 31 ++++- drivers/amlogic/usb/phy/usbphy.c | 162 ++++++++++++------------- 3 files changed, 168 insertions(+), 82 deletions(-) diff --git a/arch/arm/boot/dts/amlogic/meson8b.dtsi b/arch/arm/boot/dts/amlogic/meson8b.dtsi index e2c79c21f135..d2535edb4965 100644 --- a/arch/arm/boot/dts/amlogic/meson8b.dtsi +++ b/arch/arm/boot/dts/amlogic/meson8b.dtsi @@ -223,5 +223,62 @@ }; }; }; +dwc2_b { + compatible = "amlogic,dwc2"; + device_name = "dwc2_b"; + reg = <0xC90C0000 0x40000>; + interrupts = <0 31 4>; + status = "okay"; + pl-periph-id = <1>; /** lm name */ + clock-src = "usb1"; /** clock src */ + port-id = <1>; /** ref to mach/usb.h */ + port-type = <1>; /** 0: otg, 1: host, 2: slave */ + port-speed = <0>; /** 0: default, 1: high, 2: full */ + port-config = <0>; /** 0: default */ + port-dma = <0>; /** 0: default, 1: single, 2: incr, 3: incr4, 4: incr8, 5: incr16, 6: disable*/ + port-id-mode = <1>; /** 0: hardware, 1: sw_host, 2: sw_slave*/ + phy-reg = <0xc1108820>; + phy-reg-size = <0x20>; + usb-fifo = <1024>; + host-only-core = <1>; + pmu-apply-power = <1>; + cpu-type = "meson8"; + clocks = <&clkc CLKID_USB + &clkc CLKID_USB1_DDR_BRIDGE + &clkc CLKID_USB1>; + clock-names = "usb_general", + "usb1_to_ddr", + "usb1"; + }; + + dwc2_a { + compatible = "amlogic,dwc2"; + device_name = "dwc2_a"; + reg = <0xC9040000 0x40000>; + interrupts = <0 30 4>; + status = "okay"; + pl-periph-id = <0>; /** lm name */ + clock-src = "usb0"; /** clock src */ + port-id = <0>; /** ref to mach/usb.h */ + port-type = <0>; /** 0: otg, 1: host, 2: slave */ + port-speed = <0>; /** 0: default, high, 1: full */ + port-config = <0>; /** 0: default */ + port-dma = <0>; /** 0: default, 1: single, 2: incr, 3: incr4, 4: incr8, 5: incr16, 6: disable*/ + port-id-mode = <0>; /** 0: hardware, 1: sw_host, 2: sw_slave*/ + gpio-vbus-power = "GPIODV_24"; + gpios = <&gpio GPIODV_24 0>; + gpio-work-mask = <1>; /**0: work on pulldown,1:work on pullup*/ + phy-reg = <0xc1108800>; + phy-reg-size = <0x20>; + usb-fifo = <1024>; + cpu-type = "meson8"; + clocks = <&clkc CLKID_USB + &clkc CLKID_USB0_DDR_BRIDGE + &clkc CLKID_USB0>; + clock-names = "usb_general", + "usb0_to_ddr", + "usb0"; + }; + }; }; /* end of / */ diff --git a/arch/arm/configs/meson32_defconfig b/arch/arm/configs/meson32_defconfig index 1571b7c1a06a..ae8dc7aef357 100644 --- a/arch/arm/configs/meson32_defconfig +++ b/arch/arm/configs/meson32_defconfig @@ -50,6 +50,13 @@ CONFIG_DEVTMPFS_MOUNT=y CONFIG_DMA_CMA=y CONFIG_CMA_SIZE_MBYTES=64 CONFIG_BLK_DEV_LOOP=y +CONFIG_SCSI=y +CONFIG_BLK_DEV_SD=y +CONFIG_BLK_DEV_SR=y +CONFIG_MD=y +CONFIG_BLK_DEV_DM=y +CONFIG_DM_CRYPT=y +CONFIG_DM_VERITY=y CONFIG_SRAM=y # CONFIG_INPUT_MOUSEDEV is not set # CONFIG_INPUT_KEYBOARD is not set @@ -77,7 +84,6 @@ CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y # CONFIG_HID is not set -# CONFIG_USB_SUPPORT is not set CONFIG_STAGING=y CONFIG_CHROME_PLATFORMS=y CONFIG_ARM_TIMER_SP804=y @@ -114,5 +120,28 @@ CONFIG_CRYPTO_SEQIV=y CONFIG_CRYPTO_DEFLATE=y CONFIG_CRYPTO_LZO=y # CONFIG_CRYPTO_HW is not set +CONFIG_USB=y +CONFIG_USB_SUPPORT=y +CONFIG_USB_PHY=y +CONFIG_USB_HIDDEV=y +CONFIG_USB_ANNOUNCE_NEW_DEVICES=y +CONFIG_USB_ACM=y +CONFIG_USB_STORAGE=y +CONFIG_USB_SERIAL=y +CONFIG_USB_SERIAL_OPTION=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DWC_OTG=y +CONFIG_USB_G_ANDROID=y +CONFIG_AMLOGIC_USB=y +CONFIG_AMLOGIC_USBPHY=y +CONFIG_AMLOGIC_USB_DWC_OTG_HCD=y +CONFIG_AMLOGIC_USB_HOST_ELECT_TEST=y +CONFIG_USB_LIBCOMPOSITE=y +CONFIG_USB_CONFIGFS_F_MTP=y +CONFIG_USB_CONFIGFS_F_PTP=y +CONFIG_USB_CONFIGFS_F_FS=y +CONFIG_USB_CONFIGFS=y +CONFIG_USB_CONFIGFS_UEVENT=y +CONFIG_USB_CONFIGFS_F_ACC=y CONFIG_CRC_CCITT=m CONFIG_CRC_ITU_T=m diff --git a/drivers/amlogic/usb/phy/usbphy.c b/drivers/amlogic/usb/phy/usbphy.c index fb9cec1120d1..b1b5c6aec3cc 100644 --- a/drivers/amlogic/usb/phy/usbphy.c +++ b/drivers/amlogic/usb/phy/usbphy.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include /* * M chip USB clock setting @@ -43,9 +45,9 @@ static int init_count; struct clk_reset { - struct reset_control *usb_reset_usb_general; - struct reset_control *usb_reset_usb; - struct reset_control *usb_reset_usb_to_ddr; + struct clk *usb_reset_usb_general; + struct clk *usb_reset_usb; + struct clk *usb_reset_usb_to_ddr; }; struct clk_reset p_clk_reset[4]; @@ -81,7 +83,7 @@ int clk_enable_usb_meson8(struct platform_device *pdev, int clk_sel, clk_div, clk_src; int time_dly = 500; int i = 0; - struct reset_control *usb_reset; + struct clk *usb_reset; if (!init_count) { init_count++; @@ -93,29 +95,27 @@ int clk_enable_usb_meson8(struct platform_device *pdev, clk_name = s_clock_name; if (!strcmp(clk_name, "usb0")) { - usb_reset = devm_reset_control_get(&pdev->dev, "usb_general"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb_general"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_general = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb0"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb0"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb0_to_ddr"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb0_to_ddr"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_to_ddr = usb_reset; - peri = (usb_peri_reg_t *)usb_peri_reg; port_idx = USB_PORT_IDX_A; } else if (!strcmp(clk_name, "usb1")) { - usb_reset = devm_reset_control_get(&pdev->dev, "usb_general"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb_general"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_general = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1_to_ddr"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1_to_ddr"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_to_ddr = usb_reset; - peri = (usb_peri_reg_t *)usb_peri_reg; port_idx = USB_PORT_IDX_B; } else { @@ -175,24 +175,24 @@ int clk_resume_usb_meson8(struct platform_device *pdev, unsigned long usb_peri_reg) { const char *clk_name; - struct reset_control *usb_reset; + struct clk *usb_reset; clk_name = s_clock_name; if (0 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); } else if (1 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); } else { dev_err(&pdev->dev, "bad usb clk name: %s\n", clk_name); return -1; @@ -217,7 +217,7 @@ int clk_enable_usb_gxbaby(struct platform_device *pdev, int clk_sel, clk_div, clk_src; int time_dly = 500; int i = 0; - struct reset_control *usb_reset; + struct clk *usb_reset; if (!init_count) { init_count++; @@ -229,27 +229,27 @@ int clk_enable_usb_gxbaby(struct platform_device *pdev, clk_name = s_clock_name; if (!strcmp(clk_name, "usb0")) { - usb_reset = devm_reset_control_get(&pdev->dev, "usb_general"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb_general"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_general = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb0"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb0"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb0_to_ddr"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb0_to_ddr"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_to_ddr = usb_reset; peri = (usb_peri_reg_t *)usb_peri_reg; port_idx = USB_PORT_IDX_A; } else if (!strcmp(clk_name, "usb1")) { - usb_reset = devm_reset_control_get(&pdev->dev, "usb_general"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb_general"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_general = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1_to_ddr"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1_to_ddr"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_to_ddr = usb_reset; peri = (usb_peri_reg_t *)usb_peri_reg; @@ -305,22 +305,22 @@ void clk_disable_usb_gxbaby(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg) { - struct reset_control *usb_reset; + struct clk *usb_reset; if (0 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); } else if (1 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); } else { dev_err(&pdev->dev, "bad usb clk name.\n"); return; @@ -374,15 +374,15 @@ int clk_enable_usb_gxbabytv(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg, int controller_type) { - struct reset_control *usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb_general"); - reset_control_deassert(usb_reset); + struct clk *usb_reset; + usb_reset = devm_clk_get(&pdev->dev, "usb_general"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_general = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1_to_ddr"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1_to_ddr"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_to_ddr = usb_reset; set_device_mode(pdev, usb_peri_reg, controller_type); return 0; @@ -393,16 +393,16 @@ int clk_enable_usb_gxl(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg, int controller_type) { - struct reset_control *usb_reset; + struct clk *usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb_general"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb_general"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_general = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb = usb_reset; - usb_reset = devm_reset_control_get(&pdev->dev, "usb1_to_ddr"); - reset_control_deassert(usb_reset); + usb_reset = devm_clk_get(&pdev->dev, "usb1_to_ddr"); + clk_prepare_enable(usb_reset); p_clk_reset[pdev->id].usb_reset_usb_to_ddr = usb_reset; set_device_mode(pdev, usb_peri_reg, controller_type); return 0; @@ -413,14 +413,14 @@ void clk_disable_usb_gxbabytv(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg) { - struct reset_control *usb_reset; + struct clk *usb_reset; usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); return; } @@ -428,14 +428,14 @@ void clk_disable_usb_gxl(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg) { - struct reset_control *usb_reset; + struct clk *usb_reset; usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_assert(usb_reset); + clk_disable_unprepare(usb_reset); return; } @@ -443,22 +443,22 @@ int clk_resume_usb_gxbaby(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg) { - struct reset_control *usb_reset; + struct clk *usb_reset; if (0 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); } else if (1 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); } else { dev_err(&pdev->dev, "bad usb clk name.\n"); return -1; @@ -473,22 +473,22 @@ int clk_resume_usb_gxl(struct platform_device *pdev, const char *s_clock_name, unsigned long usb_peri_reg) { - struct reset_control *usb_reset; + struct clk *usb_reset; if (0 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); } else if (1 == pdev->id) { usb_reset = p_clk_reset[pdev->id].usb_reset_usb_general; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); usb_reset = p_clk_reset[pdev->id].usb_reset_usb_to_ddr; - reset_control_deassert(usb_reset); + clk_prepare_enable(usb_reset); } else { dev_err(&pdev->dev, "bad usb clk name.\n"); return -1; -- 2.20.1