summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrejs Cainikovs <andrejs.cainikovs@toradex.com>2023-03-07 16:03:32 +0100
committerAndrejs Cainikovs <andrejs.cainikovs@toradex.com>2023-04-03 13:18:38 +0200
commitec944a17cc06b176dcbed41b1df084f83aa25eca (patch)
treeedecef42ab08f6db74bc1606178a34e9f71e6a18
parent0e1f11392251850c36a049200557a10278093c95 (diff)
colibri-imx8x: add usb support
Add USB support. Upstream-Status: Pending As of now, no iMX8 USB support present in mainline. Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
-rw-r--r--arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi68
-rw-r--r--arch/arm/dts/fsl-imx8qxp-colibri.dts15
-rw-r--r--board/toradex/colibri-imx8x/colibri-imx8x.c31
-rw-r--r--configs/colibri-imx8x_defconfig14
-rw-r--r--include/configs/colibri-imx8x.h5
5 files changed, 132 insertions, 1 deletions
diff --git a/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi b/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
index 322429a98a..2720844109 100644
--- a/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
@@ -3,6 +3,34 @@
* Copyright 2019 Toradex AG
*/
+/ {
+ aliases {
+ usbgadget0 = &usbg1;
+ usbhost1 = &usbh3;
+ };
+
+ reg_usbh_vbus: regulator-usbh-vbus {
+ status = "okay";
+ u-boot,dm-pre-proper;
+ };
+
+ usbg1: usbg1 {
+ compatible = "fsl,imx27-usb-gadget";
+ chipidea,usb = <&usbotg1>;
+ dr_mode = "peripheral";
+ status = "okay";
+ u-boot,dm-pre-proper;
+ };
+
+ usbh3: usbh3 {
+ compatible = "Cadence,usb3-host";
+ cdns3,usb = <&usbotg3>;
+ dr_mode = "host";
+ status = "okay";
+ u-boot,dm-pre-proper;
+ };
+};
+
&{/imx8qx-pm} {
u-boot,dm-pre-proper;
@@ -72,6 +100,22 @@
u-boot,dm-pre-proper;
};
+&pd_conn_usbotg0 {
+ u-boot,dm-pre-proper;
+};
+
+&pd_conn_usbotg0_phy {
+ u-boot,dm-pre-proper;
+};
+
+&pd_conn_usb2 {
+ u-boot,dm-pre-proper;
+};
+
+&pd_conn_usb2_phy {
+ u-boot,dm-pre-proper;
+};
+
&pd_conn_sdch0 {
u-boot,dm-pre-proper;
};
@@ -120,6 +164,30 @@
u-boot,dm-pre-proper;
};
+&usbmisc1 {
+ u-boot,dm-pre-proper;
+};
+
+&usbphy1 {
+ u-boot,dm-pre-proper;
+};
+
+&usbotg1 {
+ u-boot,dm-pre-proper;
+};
+
+&usbotg3 {
+ phys = <&usbphynop1>;
+ u-boot,dm-pre-proper;
+};
+
+&usbphynop1 {
+ compatible = "cdns,usb3-phy";
+ #phy-cells = <0>;
+ reg = <0x0 0x5B160000 0x0 0x40000>;
+ u-boot,dm-pre-proper;
+};
+
&usdhc1 {
u-boot,dm-pre-proper;
};
diff --git a/arch/arm/dts/fsl-imx8qxp-colibri.dts b/arch/arm/dts/fsl-imx8qxp-colibri.dts
index df992ac639..f8415986ae 100644
--- a/arch/arm/dts/fsl-imx8qxp-colibri.dts
+++ b/arch/arm/dts/fsl-imx8qxp-colibri.dts
@@ -353,3 +353,18 @@
pinctrl-2 = <&pinctrl_usdhc2_200mhz>, <&pinctrl_usdhc2_gpio>;
status = "okay";
};
+
+&usbotg1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_usbc_det>;
+ adp-disable;
+ hnp-disable;
+ srp-disable;
+ disable-over-current;
+ status = "okay";
+};
+
+&usbotg3 {
+ vbus-supply = <&reg_usbh_vbus>;
+ status = "okay";
+};
diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c b/board/toradex/colibri-imx8x/colibri-imx8x.c
index 6ed9cc4fa8..3caaa12cb5 100644
--- a/board/toradex/colibri-imx8x/colibri-imx8x.c
+++ b/board/toradex/colibri-imx8x/colibri-imx8x.c
@@ -18,11 +18,14 @@
#include <env.h>
#include <errno.h>
#include <linux/libfdt.h>
+#include <usb.h>
#include "../common/tdx-cfg-block.h"
DECLARE_GLOBAL_DATA_PTR;
+static struct gpio_desc gpio_usb_cdet;
+
#define UART_PAD_CTRL ((SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
(SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
(SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
@@ -40,6 +43,25 @@ static void setup_iomux_uart(void)
imx8_iomux_setup_multiple_pads(uart3_pads, ARRAY_SIZE(uart3_pads));
}
+int board_ci_udc_phy_mode(void *__iomem phy_base, int phy_off)
+{
+ int ret;
+
+ switch ((phys_addr_t)phy_base) {
+ case USB_BASE_ADDR:
+ if (!dm_gpio_is_valid(&gpio_usb_cdet))
+ return -ENODEV;
+
+ ret = dm_gpio_get_value(&gpio_usb_cdet);
+ if (ret < 0)
+ return ret;
+
+ return ret ? USB_INIT_DEVICE : USB_INIT_HOST;
+ default:
+ return USB_INIT_HOST;
+ }
+}
+
static int is_imx8dx(void)
{
u32 val = 0;
@@ -95,7 +117,14 @@ int board_early_init_f(void)
#if IS_ENABLED(CONFIG_DM_GPIO)
static void board_gpio_init(void)
{
- /* TODO */
+ if (dm_gpio_lookup_name("GPIO5_9", &gpio_usb_cdet))
+ return;
+
+ if (dm_gpio_request(&gpio_usb_cdet, "usb_c_det"))
+ return;
+
+ if (dm_gpio_set_dir_flags(&gpio_usb_cdet, GPIOD_IS_IN))
+ return;
}
#else
static inline void board_gpio_init(void) {}
diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 8dbc40fa03..248808ab4e 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -37,6 +37,8 @@ CONFIG_CMD_FUSE=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_I2C=y
CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
CONFIG_CMD_CACHE=y
CONFIG_CMD_UUID=y
CONFIG_CMD_EXT4_WRITE=y
@@ -68,6 +70,8 @@ CONFIG_FEC_MXC_SHARE_MDIO=y
CONFIG_FEC_MXC_MDIO_BASE=0x5B040000
CONFIG_FEC_MXC=y
CONFIG_MII=y
+CONFIG_PHY=y
+CONFIG_CDNS3_USB_PHY=y
CONFIG_PINCTRL=y
CONFIG_PINCTRL_IMX8=y
CONFIG_POWER_DOMAIN=y
@@ -79,5 +83,15 @@ CONFIG_DM_SERIAL=y
CONFIG_FSL_LPUART=y
CONFIG_DM_THERMAL=y
CONFIG_IMX_SCU_THERMAL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_CDNS3=y
+CONFIG_USB_CDNS3_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_OF_LIBFDT_OVERLAY=y
# CONFIG_EFI_LOADER is not set
diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index cf1e3db83a..0f4e415678 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -31,6 +31,7 @@
#define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
func(MMC, mmc, 0) \
+ func(USB, usb, 0) \
func(DHCP, dhcp, na)
#include <config_distro_bootcmd.h>
@@ -72,4 +73,8 @@
/* Generic Timer Definitions */
#define COUNTER_FREQUENCY 8000000 /* 8MHz */
+/* USB Config */
+#define CONFIG_USBD_HS
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
+
#endif /* __COLIBRI_IMX8X_H */