From owner-svn-src-all@freebsd.org Mon Sep 7 06:39:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8C213EAB6B; Mon, 7 Sep 2020 06:39:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BlJXP4KZ9z3TkQ; Mon, 7 Sep 2020 06:39:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 596FD1B3DB; Mon, 7 Sep 2020 06:39:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0876d1vr039719; Mon, 7 Sep 2020 06:39:01 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0876d0ih039716; Mon, 7 Sep 2020 06:39:00 GMT (envelope-from avg@FreeBSD.org) Message-Id: <202009070639.0876d0ih039716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 7 Sep 2020 06:39:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365398 - in head/sys: arm/allwinner arm64/conf conf X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: arm/allwinner arm64/conf conf X-SVN-Commit-Revision: 365398 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2020 06:39:01 -0000 Author: avg Date: Mon Sep 7 06:39:00 2020 New Revision: 365398 URL: https://svnweb.freebsd.org/changeset/base/365398 Log: Allwinner USB DRD support (musb_otg) Allwinner USB DRD is based on the Mentor USB OTG controller, with a different register layout and a few missing registers. The code is by Andrew Turner (andrew). Reviewed by: hselasky, manu Obtained from: andrew MFC after: 5 weeks Differential Revision: https://reviews.freebsd.org/D5881 Modified: head/sys/arm/allwinner/aw_usbphy.c head/sys/arm/allwinner/files.allwinner head/sys/arm64/conf/GENERIC head/sys/conf/files.arm64 Modified: head/sys/arm/allwinner/aw_usbphy.c ============================================================================== --- head/sys/arm/allwinner/aw_usbphy.c Mon Sep 7 06:32:03 2020 (r365397) +++ head/sys/arm/allwinner/aw_usbphy.c Mon Sep 7 06:39:00 2020 (r365398) @@ -169,6 +169,18 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define CLR4(res, o, m) WR4(res, o, RD4(res, o) & ~(m)) #define SET4(res, o, m) WR4(res, o, RD4(res, o) | (m)) +#define PHY_CSR 0x00 +#define ID_PULLUP_EN (1 << 17) +#define DPDM_PULLUP_EN (1 << 16) +#define FORCE_ID (0x3 << 14) +#define FORCE_ID_SHIFT 14 +#define FORCE_ID_LOW 2 +#define FORCE_VBUS_VALID (0x3 << 12) +#define FORCE_VBUS_VALID_SHIFT 12 +#define FORCE_VBUS_VALID_HIGH 3 +#define VBUS_CHANGE_DET (1 << 6) +#define ID_CHANGE_DET (1 << 5) +#define DPDM_CHANGE_DET (1 << 4) #define OTG_PHY_CFG 0x20 #define OTG_PHY_ROUTE_OTG (1 << 0) #define PMU_IRQ_ENABLE 0x00 @@ -214,6 +226,7 @@ awusbphy_init(device_t dev) struct awusbphy_softc *sc; phandle_t node; char pname[20]; + uint32_t val; int error, off, rid; regulator_t reg; hwreset_t rst; @@ -288,6 +301,16 @@ awusbphy_init(device_t dev) return (ENXIO); } } + + /* Enable OTG PHY for host mode */ + val = bus_read_4(sc->phy_ctrl, PHY_CSR); + val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); + val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); + val &= ~FORCE_ID; + val |= (FORCE_ID_LOW << FORCE_ID_SHIFT); + val &= ~FORCE_VBUS_VALID; + val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT); + bus_write_4(sc->phy_ctrl, PHY_CSR, val); return (0); } Modified: head/sys/arm/allwinner/files.allwinner ============================================================================== --- head/sys/arm/allwinner/files.allwinner Mon Sep 7 06:32:03 2020 (r365397) +++ head/sys/arm/allwinner/files.allwinner Mon Sep 7 06:39:00 2020 (r365398) @@ -27,6 +27,7 @@ dev/usb/controller/generic_ohci.c optional ohci dev/usb/controller/generic_usb_if.m optional ohci dev/usb/controller/generic_ehci.c optional ehci dev/usb/controller/generic_ehci_fdt.c optional ehci +dev/usb/controller/musb_otg_allwinner.c optional musb arm/allwinner/aw_sid.c optional aw_sid arm/allwinner/aw_thermal.c optional aw_thermal arm/allwinner/aw_cir.c optional aw_cir evdev Modified: head/sys/arm64/conf/GENERIC ============================================================================== --- head/sys/arm64/conf/GENERIC Mon Sep 7 06:32:03 2020 (r365397) +++ head/sys/arm64/conf/GENERIC Mon Sep 7 06:39:00 2020 (r365398) @@ -222,6 +222,7 @@ device aw_usbphy # Allwinner USB PHY device rk_usb2phy # Rockchip USB2PHY device rk_typec_phy # Rockchip TypeC PHY device dwcotg # DWC OTG controller +device musb # Mentor Graphics USB OTG controller device ohci # OHCI USB interface device ehci # EHCI USB interface (USB 2.0) device ehci_mv # Marvell EHCI USB interface Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Mon Sep 7 06:32:03 2020 (r365397) +++ head/sys/conf/files.arm64 Mon Sep 7 06:39:00 2020 (r365398) @@ -339,6 +339,7 @@ dev/usb/controller/generic_ehci_acpi.c optional ehci a dev/usb/controller/generic_ehci_fdt.c optional ehci fdt dev/usb/controller/generic_ohci.c optional ohci fdt dev/usb/controller/generic_usb_if.m optional ohci fdt +dev/usb/controller/musb_otg_allwinner.c optional musb fdt soc_allwinner_a64 dev/usb/controller/usb_nop_xceiv.c optional fdt ext_resources dev/usb/controller/generic_xhci.c optional xhci dev/usb/controller/generic_xhci_acpi.c optional xhci acpi