From patchwork Sat Dec 30 12:44:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 854102 X-Patchwork-Delegate: jagannadh.teki@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=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3z837F0T5Rz9t32 for ; Sat, 30 Dec 2017 23:44:24 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5A30BC21DCA; Sat, 30 Dec 2017 12:44:19 +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 B21C0C21D9F; Sat, 30 Dec 2017 12:44:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B927EC21C59; Sat, 30 Dec 2017 12:44:15 +0000 (UTC) Received: from wens.csie.org (mirror2.csie.ntu.edu.tw [140.112.30.76]) by lists.denx.de (Postfix) with ESMTPS id DDB90C21C34 for ; Sat, 30 Dec 2017 12:44:14 +0000 (UTC) Received: by wens.csie.org (Postfix, from userid 1000) id 7EA345FA91; Sat, 30 Dec 2017 20:44:09 +0800 (CST) From: Chen-Yu Tsai To: u-boot@lists.denx.de Date: Sat, 30 Dec 2017 20:44:07 +0800 Message-Id: <20171230124407.14988-1-wens@csie.org> X-Mailer: git-send-email 2.15.1 Cc: Marek Vasut , Maxime Ripard Subject: [U-Boot] [PATCH v2] musb: sunxi: Use base address from device tree 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" Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code. Fixes: 3a61b080acee ("musb: sunxi: switch to the device model") Signed-off-by: Chen-Yu Tsai Acked-by: Maxime Ripard --- Changes since v1: - Check return value dev_read_addr_ptr() IMHO, having NULL represent an error for dev_read_addr_ptr() doesn't work so well as in the kernel, because U-boot doesn't acually map addresses. So NULL (or 0x0) is in fact a valid address. Something like ~0x0 might work better, but that's a whole other changeset. --- drivers/usb/musb-new/sunxi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 7ee44ea91900..aedc24b93711 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -312,13 +312,16 @@ static int musb_usb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); + void *base = dev_read_addr_ptr(dev); int ret; + if (!base) + return -EINVAL; + priv->desc_before_addr = true; #ifdef CONFIG_USB_MUSB_HOST - host->host = musb_init_controller(&musb_plat, NULL, - (void *)SUNXI_USB0_BASE); + host->host = musb_init_controller(&musb_plat, NULL, base); if (!host->host) return -EIO; @@ -326,7 +329,7 @@ static int musb_usb_probe(struct udevice *dev) if (!ret) printf("Allwinner mUSB OTG (Host)\n"); #else - ret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + ret = musb_register(&musb_plat, NULL, base); if (!ret) printf("Allwinner mUSB OTG (Peripheral)\n"); #endif