summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Schenker <philippe.schenker@toradex.com>2020-04-10 01:40:16 +0200
committerPhilippe Schenker <philippe.schenker@toradex.com>2020-04-14 10:27:21 +0200
commitd626574ba1730aa25abe86d081c66d2616abfc75 (patch)
tree44bb3bb8c1fe06ab68373918cd83bacc8eb19505
parentd7643e40aa0fb5fefa92aa1603f0207628f0c62f (diff)
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
-rw-r--r--arch/arm/dts/fsl-imx8qxp-apalis.dts4
-rw-r--r--board/toradex/apalis-imx8x/apalis-imx8x.c115
-rw-r--r--configs/apalis-imx8x_defconfig1
3 files changed, 105 insertions, 15 deletions
diff --git a/arch/arm/dts/fsl-imx8qxp-apalis.dts b/arch/arm/dts/fsl-imx8qxp-apalis.dts
index 3d288da1621..62bbd4bbd8a 100644
--- a/arch/arm/dts/fsl-imx8qxp-apalis.dts
+++ b/arch/arm/dts/fsl-imx8qxp-apalis.dts
@@ -280,6 +280,10 @@
status = "okay";
};
+&usb2 {
+ status = "okay";
+};
+
/* On-module eMMC */
&usdhc1 {
bus-width = <8>;
diff --git a/board/toradex/apalis-imx8x/apalis-imx8x.c b/board/toradex/apalis-imx8x/apalis-imx8x.c
index aff6b6466c8..0f4ac351055 100644
--- a/board/toradex/apalis-imx8x/apalis-imx8x.c
+++ b/board/toradex/apalis-imx8x/apalis-imx8x.c
@@ -27,6 +27,7 @@
#include <asm/mach-imx/video.h>
#include <asm/arch/video_common.h>
#include <power-domain.h>
+#include <cdns3-uboot.h>
#include <asm/arch/lpcg.h>
#include "../common/tdx-cfg-block.h"
@@ -294,29 +295,113 @@ int checkboard(void)
return 0;
}
-/* Only Enable USB3 resources currently */
+#ifdef CONFIG_USB
+#ifdef CONFIG_USB_CDNS3
+static struct cdns3_device cdns3_device_data = {
+ .none_core_base = 0x5B110000,
+ .xhci_base = 0x5B130000,
+ .dev_base = 0x5B140000,
+ .phy_base = 0x5B160000,
+ .otg_base = 0x5B120000,
+ .dr_mode = USB_DR_MODE_HOST,
+ .index = 1,
+};
+#endif
+
int board_usb_init(int index, enum usb_init_type init)
{
-#ifndef CONFIG_DM_USB
- struct power_domain pd;
- int ret;
+ int ret = 0;
- /* Power on usb */
- if (!power_domain_lookup_name("conn_usb2", &pd)) {
- ret = power_domain_on(&pd);
- if (ret)
- printf("conn_usb2 Power up failed! (error = %d)\n", ret);
- }
+ if (index == 1) {
+ if (init == USB_INIT_HOST) {
+#ifdef CONFIG_USB_CDNS3
+ } else {
+#ifdef CONFIG_SPL_BUILD
+ sc_ipc_t ipcHndl = 0;
+
+ ipcHndl = gd->arch.ipc_channel_handle;
+
+ ret = sc_pm_set_resource_power_mode(ipcHndl, SC_R_USB_2, SC_PM_PW_MODE_ON);
+ if (ret != SC_ERR_NONE)
+ printf("conn_usb2 Power up failed! (error = %d)\n", ret);
+
+ ret = sc_pm_set_resource_power_mode(ipcHndl, SC_R_USB_2_PHY, SC_PM_PW_MODE_ON);
+ if (ret != SC_ERR_NONE)
+ printf("conn_usb2_phy Power up failed! (error = %d)\n", ret);
+#else
+ struct power_domain pd;
+ int ret;
+
+ /* Power on usb */
+ if (!power_domain_lookup_name("conn_usb2", &pd)) {
+ ret = power_domain_on(&pd);
+ if (ret)
+ printf("conn_usb2 Power up failed! (error = %d)\n", ret);
+ }
+
+ if (!power_domain_lookup_name("conn_usb2_phy", &pd)) {
+ ret = power_domain_on(&pd);
+ if (ret)
+ printf("conn_usb2_phy Power up failed! (error = %d)\n", ret);
+ }
+#endif
- if (!power_domain_lookup_name("conn_usb2_phy", &pd)) {
- ret = power_domain_on(&pd);
- if (ret)
- printf("conn_usb2_phy Power up failed! (error = %d)\n", ret);
+ ret = cdns3_uboot_init(&cdns3_device_data);
+ printf("%d cdns3_uboot_initmode %d\n", index, ret);
+#endif
+ }
}
+
+ return ret;
+
+}
+
+int board_usb_cleanup(int index, enum usb_init_type init)
+{
+ int ret = 0;
+
+ if (index == 1) {
+ if (init == USB_INIT_HOST) {
+#ifdef CONFIG_USB_CDNS3_GADGET
+ } else {
+ cdns3_uboot_exit(1);
+
+#ifdef CONFIG_SPL_BUILD
+ sc_ipc_t ipcHndl = 0;
+
+ ipcHndl = gd->arch.ipc_channel_handle;
+
+ ret = sc_pm_set_resource_power_mode(ipcHndl, SC_R_USB_2, SC_PM_PW_MODE_OFF);
+ if (ret != SC_ERR_NONE)
+ printf("conn_usb2 Power down failed! (error = %d)\n", ret);
+
+ ret = sc_pm_set_resource_power_mode(ipcHndl, SC_R_USB_2_PHY, SC_PM_PW_MODE_OFF);
+ if (ret != SC_ERR_NONE)
+ printf("conn_usb2_phy Power down failed! (error = %d)\n", ret);
+#else
+ struct power_domain pd;
+ int ret;
+
+ /* Power off usb */
+ if (!power_domain_lookup_name("conn_usb2", &pd)) {
+ ret = power_domain_off(&pd);
+ if (ret)
+ printf("conn_usb2 Power down failed! (error = %d)\n", ret);
+ }
+
+ if (!power_domain_lookup_name("conn_usb2_phy", &pd)) {
+ ret = power_domain_off(&pd);
+ if (ret)
+ printf("conn_usb2_phy Power down failed! (error = %d)\n", ret);
+ }
#endif
+#endif
+ }
+ }
- return 0;
+ return ret;
}
+#endif
int board_init(void)
{
diff --git a/configs/apalis-imx8x_defconfig b/configs/apalis-imx8x_defconfig
index bfed0375a03..9dce9863d06 100644
--- a/configs/apalis-imx8x_defconfig
+++ b/configs/apalis-imx8x_defconfig
@@ -60,6 +60,7 @@ CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_CDNS3=y
CONFIG_USB_STORAGE=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_MANUFACTURER="FSL"