From patchwork Sun Jun 30 22:21:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 1125016 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OeGRoYBJ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45cQ2V4Jdqz9s00 for ; Mon, 1 Jul 2019 08:21:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4F623C21DFB; Sun, 30 Jun 2019 22:21:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9F792C21D8E; Sun, 30 Jun 2019 22:21:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E96E8C21D8E; Sun, 30 Jun 2019 22:21:08 +0000 (UTC) Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by lists.denx.de (Postfix) with ESMTPS id 71324C21BE5 for ; Sun, 30 Jun 2019 22:21:08 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id r185so24368295iod.6 for ; Sun, 30 Jun 2019 15:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cyrb2kukLuVEeD0o0/aFoDVdZli0R5R3H04WcEO5Y58=; b=OeGRoYBJVZkyqCaZIIvnUV5roZqUrpFX4ZN/wBzHwCnMKNdGGOL/xLFiP82KPQv+Fz A+nZhxKEOUZn0eteArvtvfw+Aj2OijvZYXaubWskp0FQw4/UplyTXYjFgXO/kzmZK+m2 c5AaGuPnxvDHejHOBIzodASfYZvUNFjG1PMZfCuwfSWULbK3ejspjsr3yNpRP1llDgnq BkOoPZnKJYmsxjt/w2y6DcjZ0ePJU6HhEvNTkQn6zqbPtTCIjm/Ttw0IS+PxUvRLHGUZ tdYm9BwqFoQBaa5JvbqP4qNF8eamOMLKAB+zRlDgRUqhNY/XQZ8eWE+mSh21iNgoWvdn nkaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cyrb2kukLuVEeD0o0/aFoDVdZli0R5R3H04WcEO5Y58=; b=fQRgXJqH0yOTxTnwVcH2OczuIFB8bWGCqCbfbDAq7GUEcwe593lV0FEii+1M2QIg/a Lrpu51UZoneJCmi8/jwHct2/+8LatygvzWgnpqdfFunVbITwu+ABf+6hAtMWULR5cEFG ZYG5H81K6rVlGoeYfb9l6oYnikiuLxJQY9eBFMdt3xa6xjnGlZWztiKzRT3MUd8CM0uk 3oFcr6KMoVTG+lFyT5ld/pHj0JByhXfJBZYnpCtyv24NtaM1Az9qpklynPeC3bqpHjS8 a6mThPKSQJ33Y24kRhZZtCyVfIGkqa4GuV108Zt7CFShkWQ+wML5kSkJWM39zSSOgAUx XpvA== X-Gm-Message-State: APjAAAVx26lCExtvvswNTWhARUCxrk3NVU8SdLRzAO+fM5x/0J6Z6ee/ wMpSy6b9LJYxezK2FnH8lQKkLvWr X-Google-Smtp-Source: APXvYqzZ+gCMT3DSw0N6ISZKjGVSbV8yq3OnimihLWrWz4gOzz6l7kY+9CoW7Tq8OV0wA9s8QK7XIA== X-Received: by 2002:a6b:cf17:: with SMTP id o23mr23910951ioa.176.1561933266643; Sun, 30 Jun 2019 15:21:06 -0700 (PDT) Received: from localhost.localdomain (c-73-37-219-234.hsd1.mn.comcast.net. [73.37.219.234]) by smtp.gmail.com with ESMTPSA id c81sm18160653iof.28.2019.06.30.15.21.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 15:21:05 -0700 (PDT) From: Adam Ford To: u-boot@lists.denx.de Date: Sun, 30 Jun 2019 17:21:00 -0500 Message-Id: <20190630222100.30171-1-aford173@gmail.com> X-Mailer: git-send-email 2.17.1 Cc: marex@denx.de, adam.ford@logicpd.com Subject: [U-Boot] [PATCH] usb: ehci-omap: Add Support DM_USB and OF_CONTROL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The omap3.dtsi file shows the usbhshost node with two sub-nodes for ohci and ehci. This patch file creates the usbhshost, and pulls the portX-mode information. It then locates the EHCI sub-node, and initializes the EHCI controller with the info pulled from the usbhshost node. There is still more to do since there isn't an actual link between the 'phys' reference and the corresponding phy driver, and there is no nop-xceiv driver yet. In the meantime, the older style reference to CONFIG_OMAP_EHCI_PHYx_RESET_GPIO is still needed to pull the phy out of reset until the phy driver is completed and the phandle reference is made. Signed-off-by: Adam Ford diff --git a/arch/arm/include/asm/ehci-omap.h b/arch/arm/include/asm/ehci-omap.h index 1549f7bf21..f970bba937 100644 --- a/arch/arm/include/asm/ehci-omap.h +++ b/arch/arm/include/asm/ehci-omap.h @@ -123,6 +123,7 @@ struct omap_ehci { u32 insreg08; /* 0xb0 */ }; +#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL) /* * FIXME: forward declaration of this structs needed because omap got the * ehci implementation backwards. move out ehci_hcd_x from board files @@ -133,5 +134,6 @@ struct ehci_hcor; int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, struct ehci_hccr **hccr, struct ehci_hcor **hcor); int omap_ehci_hcd_stop(void); +#endif #endif /* _OMAP_COMMON_EHCI_H_ */ diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index ab459c8cc9..bf83a4adb3 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -9,7 +9,6 @@ * Shashi Ranjan * */ - #include #include #include @@ -18,6 +17,10 @@ #include #include #include +#include +#include +#include +#include #include "ehci.h" @@ -177,8 +180,13 @@ int omap_ehci_hcd_stop(void) * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1 * See there for additional Copyrights. */ +#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL) + int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, struct ehci_hccr **hccr, struct ehci_hcor **hcor) +#else +int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata) +#endif { int ret; unsigned int i, reg = 0, rev = 0; @@ -285,10 +293,130 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, for (i = 0; i < OMAP_HS_USB_PORTS; i++) if (is_ehci_phy_mode(usbhs_pdata->port_mode[i])) omap_ehci_soft_phy_reset(i); - +#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL) *hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE); *hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE + 0x10); +#endif debug("OMAP EHCI init done\n"); return 0; } + +#if CONFIG_IS_ENABLED(DM_USB) + +struct ehci_omap_priv_data { + struct ehci_ctrl ctrl; + struct omap_ehci *ehci; +#ifdef CONFIG_DM_REGULATOR + struct udevice *vbus_supply; +#endif + enum usb_init_type init_type; + int portnr; + struct phy phy[OMAP_HS_USB_PORTS]; + int nports; +}; + +static struct omap_usbhs_board_data usbhs_bdata = { + .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED, + .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, + .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, +}; + +/* Match this order enums usbhs_omap_port_mode */ +static char *phy_strings[] = { + "", + "ehci-phy", + "ehci-tll", + "ehci-hsic", +}; + +static int find_phy_mode(const char *phy_type) +{ + int i; + + for (i = 0; i < OMAP_HS_USB_PORTS; i++) { + if (!strcmp(phy_type, phy_strings[i])) + return i; + } + return 0; +} + +static const struct ehci_ops omap_ehci_ops = { +}; + +static int ehci_usb_probe(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + const void *fdt = gd->fdt_blob; + struct omap_ehci *ehci; + struct ehci_omap_priv_data *priv = dev_get_priv(dev); + struct ehci_hccr *hccr; + struct ehci_hcor *hcor; + ofnode node; + ofnode parent_node = dev->node; + int ret = -1; + int off, i; + const char *mode; + char prop[11]; + + priv->ehci = (struct omap_ehci *)devfdt_get_addr(dev); + priv->portnr = dev->seq; + priv->init_type = plat->init_type; + + /* Go through each port portX-mode to determing phy mode */ + for (i = 0; i < 3; i++) { + snprintf(prop, sizeof(prop), "port%d-mode", i + 1); + mode = dev_read_string(dev, prop); + if (mode) + usbhs_bdata.port_mode[i] = find_phy_mode(mode); + } + + ofnode_for_each_subnode(node, parent_node) { + /* Locate node for ti,ehci-omap */ + off = ofnode_to_offset(node); + ret = fdt_node_check_compatible(fdt, off, "ti,ehci-omap"); + + if (!ret) { + /* If EHCI node is found, set the pointer to it */ + ehci = (struct omap_ehci *)ofnode_get_addr(node); + hccr = (struct ehci_hccr *)&ehci->hccapbase; + hcor = (struct ehci_hcor *)&ehci->usbcmd; + + /* Do the actual EHCI initialization */ + omap_ehci_hcd_init(0, &usbhs_bdata); + ret = ehci_register(dev, hccr, hcor, &omap_ehci_ops, 0, + USB_INIT_HOST); + } + } + + return ret; +} + +static const struct udevice_id omap_ehci_dt_ids[] = { + { .compatible = "ti,usbhs-host" }, + { } +}; + +static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + + plat->init_type = USB_INIT_HOST; + + return 0; +} + +U_BOOT_DRIVER(usb_omaphs_host) = { + .name = "usbhs-host", + .id = UCLASS_USB, + .of_match = omap_ehci_dt_ids, + .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .probe = ehci_usb_probe, + .remove = ehci_deregister, + .ops = &ehci_usb_ops, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct ehci_omap_priv_data), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; + +#endif diff --git a/include/configs/omap3_logic.h b/include/configs/omap3_logic.h index e318a9f896..65d8487c18 100644 --- a/include/configs/omap3_logic.h +++ b/include/configs/omap3_logic.h @@ -30,6 +30,8 @@ /* I2C */ #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* EEPROM AT24C64 */ +#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 4 + /* Board NAND Info. */ #ifdef CONFIG_NAND #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of */