From patchwork Tue Sep 12 19:01:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 112371 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp5605489qgf; Tue, 12 Sep 2017 12:03:56 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7TCtQjat2Y7Em8bMFkCOwUdP7sHeyI9LQIIDb6XXnIgS8d37+swjnHxaX4Qgh4/D6x8YhZ X-Received: by 10.80.196.3 with SMTP id v3mr11192847edf.272.1505243035907; Tue, 12 Sep 2017 12:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505243035; cv=none; d=google.com; s=arc-20160816; b=wfJWgStrIse0dI1kZE9M20lo3YU3+HKq9HFeg8Ouhs2lV7/VCT9KOEm1z1a7qwxuyk OJZkhGCU1mwxrbTHCERk6s3TSwYC+CYN9EEbdZyPIQW6xDzd6+nu3o4o8dtqOli8DpUP cK5NuAyJFMARWU5PiyGYSBkRdhQBMGPtzjjNCpNLf7U3bQ5p4V43vf9wNkNGjeS8qMvt /sfxNtJlit3lDaXD7uQvhW0RELE46uYZRou6cRxODiQg7z+TARZsw5Zd4+VFrZ8mXd4s 3Td7Oxq1aPr3EBCE5LCHyPrgjLyk0QNA4tBtQt/tZI11FRe7BWjZidef/1amL0h8uvcI 0woQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=YDdNi7QUR2Ohql9nPymCh6UgrbN/BYR3WoY3kBDVNDE=; b=DGuk77faR/SJnGxezfM5QuCDG+8QhHoNEYQZPNbnuzBUlhQMwzFFKiDJGzffzBzF65 c0N0uNQX7eH0VZY+0HmOxN/1QfHUy8YaI0E2KxcRzlN9hAn8pOa7itzvnNQIAgdDOa6r OJPz7Fe5J99HdUBYk8+QGQdRqsX3FEPXEfJZw6WfaInWhnixIR7T5xDb4iiXW+M7c2TT rKNXyfBY0sA+0+3AwGPXUEh7fFWgITDkGx31eL/RPYT7WvdZPAOyHmAKyPZMzBFMXUfF L3igkoYDLsNCc29cVsMbWpOA2gvN3PMnb9w0XkBfikkuU4fVqUOro4O1Dyb18Wke0y42 Phmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id n30si11199941edc.462.2017.09.12.12.03.55; Tue, 12 Sep 2017 12:03:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 73FE3C221BA; Tue, 12 Sep 2017 19:03:50 +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=none 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 50758C220ED; Tue, 12 Sep 2017 19:01:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CF4A6C21C40; Tue, 12 Sep 2017 19:01:47 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 8B27CC21D78 for ; Tue, 12 Sep 2017 19:01:47 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 5B8C020981; Tue, 12 Sep 2017 21:01:47 +0200 (CEST) Received: from localhost (LFbn-TOU-1-209-191.w86-201.abo.wanadoo.fr [86.201.56.191]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2BF7C2091D; Tue, 12 Sep 2017 21:01:47 +0200 (CEST) From: Maxime Ripard To: Tom Rini , Jagan Teki Date: Tue, 12 Sep 2017 21:01:39 +0200 Message-Id: X-Mailer: git-send-email 2.13.5 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , marex@denx.de, u-boot@lists.denx.de, Maxime Ripard Subject: [U-Boot] [PATCH v2 11/14] musb: sunxi: switch to the device model 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 device model was implemented so far using a hook that needed to be called from the board support, without DT support and only for the host. Switch to probing both in peripheral and host mode through the DT. Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard Reviewed-by: Ɓukasz Majewski --- arch/arm/include/asm/arch-sunxi/usb_phy.h | 7 +--- board/sunxi/board.c | 1 +- drivers/usb/musb-new/sunxi.c | 56 +++++++++++------------- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/arch/arm/include/asm/arch-sunxi/usb_phy.h b/arch/arm/include/asm/arch-sunxi/usb_phy.h index cef6c985bc8d..5a9cacb6f4a3 100644 --- a/arch/arm/include/asm/arch-sunxi/usb_phy.h +++ b/arch/arm/include/asm/arch-sunxi/usb_phy.h @@ -19,10 +19,3 @@ void sunxi_usb_phy_power_off(int index); int sunxi_usb_phy_vbus_detect(int index); int sunxi_usb_phy_id_detect(int index); void sunxi_usb_phy_enable_squelch_detect(int index, int enable); - -/* Not really phy related, but we have to declare this somewhere ... */ -#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET) -void sunxi_musb_board_init(void); -#else -#define sunxi_musb_board_init() -#endif diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 70e01437c4f4..f9224360d758 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -736,7 +736,6 @@ int misc_init_r(void) if (ret) return ret; #endif - sunxi_musb_board_init(); return 0; } diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 5c1a902e42dc..7ee44ea91900 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -308,9 +308,6 @@ static struct musb_hdrc_platform_data musb_plat = { .platform_ops = &sunxi_musb_ops, }; -#ifdef CONFIG_USB_MUSB_HOST -static int musb_usb_remove(struct udevice *dev); - static int musb_usb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -319,16 +316,20 @@ static int musb_usb_probe(struct udevice *dev) priv->desc_before_addr = true; +#ifdef CONFIG_USB_MUSB_HOST host->host = musb_init_controller(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); if (!host->host) return -EIO; ret = musb_lowlevel_init(host); - if (ret == 0) - printf("MUSB OTG\n"); - else - musb_usb_remove(dev); + if (!ret) + printf("Allwinner mUSB OTG (Host)\n"); +#else + ret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + if (!ret) + printf("Allwinner mUSB OTG (Peripheral)\n"); +#endif return ret; } @@ -352,30 +353,27 @@ static int musb_usb_remove(struct udevice *dev) return 0; } -U_BOOT_DRIVER(usb_musb) = { - .name = "sunxi-musb", - .id = UCLASS_USB, - .probe = musb_usb_probe, - .remove = musb_usb_remove, - .ops = &musb_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct musb_host_data), +static const struct udevice_id sunxi_musb_ids[] = { + { .compatible = "allwinner,sun4i-a10-musb" }, + { .compatible = "allwinner,sun6i-a31-musb" }, + { .compatible = "allwinner,sun8i-a33-musb" }, + { .compatible = "allwinner,sun8i-h3-musb" }, + { } }; -#endif -void sunxi_musb_board_init(void) -{ +U_BOOT_DRIVER(usb_musb) = { + .name = "sunxi-musb", #ifdef CONFIG_USB_MUSB_HOST - struct udevice *dev; - - /* - * Bind the driver directly for now as musb linux kernel support is - * still pending upstream so our dts files do not have the necessary - * nodes yet. TODO: Remove this as soon as the dts nodes are in place - * and bind by compatible instead. - */ - device_bind_driver(dm_root(), "sunxi-musb", "sunxi-musb", &dev); + .id = UCLASS_USB, #else - musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + .id = UCLASS_USB_DEV_GENERIC, #endif -} + .of_match = sunxi_musb_ids, + .probe = musb_usb_probe, + .remove = musb_usb_remove, +#ifdef CONFIG_USB_MUSB_HOST + .ops = &musb_usb_ops, +#endif + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct musb_host_data), +};