From patchwork Fri Aug 11 20:57:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Jarosz?= X-Patchwork-Id: 800755 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TKWxIVMv"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xTcwG16Gxz9sRq for ; Sat, 12 Aug 2017 07:05:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A90A3C21DCE; Fri, 11 Aug 2017 21:00:47 +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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 587E9C21E49; Fri, 11 Aug 2017 20:58:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6027CC21C4F; Fri, 11 Aug 2017 20:57:04 +0000 (UTC) Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by lists.denx.de (Postfix) with ESMTPS id ACB3FC21E33 for ; Fri, 11 Aug 2017 20:56:54 +0000 (UTC) Received: by mail-lf0-f68.google.com with SMTP id y15so2984637lfd.5 for ; Fri, 11 Aug 2017 13:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=7LsolN4JFJYH/aPSp1VWgQz6RLGbfEpCx1YsrDW5lOk=; b=TKWxIVMvtxuF8ucUy0pHCqIkDBhIy13XThB6u/8Kc2vJqqu2Mf9UfCr8G95BlfvmZb 7TXbvWZ/b4406QFMOUeRAER8gGvsuAo1w7Ly6ulbq8FKmR9WybxegpD1a3EIqo607V5z N4v7TSZ5DPUMX/mHIidX9h5ecpt54QXY21P9YMQWGRJ5C4xTo5NcwIAthI1t5eyG89ZF 388BpmV7hNN1RuQyc4/oayn0sng+l4DFU+u+2xAW1FOtCSTfcLRo2Aj9rWeL+nFROwyb uh0jLXIECRzJUdqpmUC3TLlclpnutiqG2DSYxnA0CnCoiSc87f8fnwufyTJZ59RHFb71 Eg0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=7LsolN4JFJYH/aPSp1VWgQz6RLGbfEpCx1YsrDW5lOk=; b=Nz8zJgnfNpH/64F3t8skRIDEI1tZ+bi4iSTLQXy2m1jlrwmdV4jgNSU0dYC4OmjJKC /7FWzFqWCZV496qLlk8U2MG2lz7hX4X52mIVGS0Mb4hcdgnOt7p/vhocTjG/m1SsdQFN hk/pIj4+KTOJ1T80hRjyKRfRU6BjxiIjJ9kEycng/iumeZIfoqfgjAdRaVmi+v2l7eVE 1l27hjh5UN79uIPG+0QCmKSG2ve+hfeCkwRwHmsWcn6Txpq/KUQPZ5gB2WI6i8tXubqf IFUUPz28jUvNtzO7SZWE6sSyTndxdBdw9wQCy7b0qi7jl1hWx4ZmmGEZ4Z3rpvVOak// Sq6A== X-Gm-Message-State: AHYfb5j3QesesG3+ejsjm5OWXyoFgxIrphPVxCGmV+jSaLSsS2dh5gV1 N5EgUj6WZIBV71toeKc= X-Received: by 10.46.19.10 with SMTP id 10mr5679289ljt.173.1502485014272; Fri, 11 Aug 2017 13:56:54 -0700 (PDT) Received: from vaio-ubuntu (admf2.neoplus.adsl.tpnet.pl. [79.185.35.2]) by smtp.gmail.com with ESMTPSA id g25sm249491ljd.25.2017.08.11.13.56.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Aug 2017 13:56:53 -0700 (PDT) Date: Fri, 11 Aug 2017 22:57:07 +0200 From: =?utf-8?B?UGF3ZcWC?= Jarosz To: u-boot@lists.denx.de Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Subject: [U-Boot] [PATCH v2 12/19] rockchip: board: rk3066: convert board_usb_init to live tree functions 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Use live tree functions to fill dwc2_plat_otg_data structure in board_usb_init. Signed-off-by: PaweÅ‚ Jarosz --- Changes since v1: - none arch/arm/mach-rockchip/rk3066-board.c | 52 +++++------------------------------ 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-rockchip/rk3066-board.c b/arch/arm/mach-rockchip/rk3066-board.c index 8fa06a2..2b96eb2 100644 --- a/arch/arm/mach-rockchip/rk3066-board.c +++ b/arch/arm/mach-rockchip/rk3066-board.c @@ -90,55 +90,17 @@ static struct dwc2_plat_otg_data rk3066_otg_data = { int board_usb_init(int index, enum usb_init_type init) { - int node, phy_node; - const char *mode; - bool matched = false; - const void *blob = gd->fdt_blob; - u32 grf_phy_offset; - - /* find the usb_otg node */ - node = fdt_node_offset_by_compatible(blob, -1, - "rockchip,rk3066-usb"); - - while (node > 0) { - mode = fdt_getprop(blob, node, "dr_mode", NULL); - if (mode && strcmp(mode, "otg") == 0) { - matched = true; - break; - } - - node = fdt_node_offset_by_compatible(blob, node, - "rockchip,rk3066-usb"); - } - if (!matched) { - debug("Not found usb_otg device\n"); - return -ENODEV; - } - rk3066_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg"); + ofnode otg_node; + u32 reg; - node = fdtdec_lookup_phandle(blob, node, "phys"); - if (node <= 0) { - debug("Not found usb phy device\n"); + otg_node = ofnode_path("/usb@10180000"); + if (!ofnode_valid(otg_node)) { + debug("Not found usb otg device\n"); return -ENODEV; } - phy_node = fdt_parent_offset(blob, node); - if (phy_node <= 0) { - debug("Not found usb phy device\n"); - return -ENODEV; - } - - rk3066_otg_data.phy_of_node = phy_node; - grf_phy_offset = fdtdec_get_addr(blob, node, "reg"); - - node = fdt_node_offset_by_compatible(blob, -1, - "rockchip,rk3066-grf"); - if (node <= 0) { - debug("Not found grf device\n"); - return -ENODEV; - } - rk3066_otg_data.regs_phy = grf_phy_offset + - fdtdec_get_addr(blob, node, "reg"); + ofnode_read_u32(otg_node, "reg", ®); + rk3066_otg_data.regs_otg = reg; return dwc2_udc_probe(&rk3066_otg_data); }