From patchwork Wed Apr 18 02:38:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 133592 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp5391475ljb; Tue, 17 Apr 2018 19:41:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx48zwBqhisgLpHgsRFsokNQFzSZdhQvWbebKc4Qdz6QFqSsGlRK53UE/fuGyNsUS1J83gC7U X-Received: by 10.80.128.5 with SMTP id 5mr796014eda.130.1524019289207; Tue, 17 Apr 2018 19:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524019289; cv=none; d=google.com; s=arc-20160816; b=rjBu0LTo5QEuNQOfnSAc4m5geN9pj97wnk4QSdOdwuE/zYsPYRqirWgmQ6uhTXiMm5 rBVGdg6CCjP0A0I/aYfGbsZoz0H4fZthLKeeOw3PoUcKSxOCASvhpXTjBs9w4ZuyaxB/ ZlXQ2UiH4868SqxcJMtelF9NDd/9ubVozj2fntKW5wBCMRLPIqlbPAhfpDKR42OnQrbm eIVHG/vvDAGs/zTD2F/W0O02UIEyOedm6K8UzY3lC0xdfx/AjviAibtSV8plfKjhuImL yv+a6txXp8OAA/xz/QTMeBM8OT5wk/FuJxjLkNDE0Pml2Moq0ImQ0c+w88q0J6hZuQJs LyTw== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=w0VDYYHB++DRVhETIKsduI3socrNcDjFugVvkktP1BU=; b=YTW7F1warMoF0/BUtZijrK0aXfYvoy4n4IeozKr8sDEId58R1Najo0U3XTwAtbLMTI ttwerUUQzK2fJSnLJfO4LkXDYfU7kPBDnNYUUpFpCii/C+od2mM/53Ni30tQcuJG1gXM JL7TLLuXfRdubKHTPx5Ikv64R8jO2uAU6li3G9SNYMClzbmUGnW5/jli4C3FxtkSgi0K ZPYqtkPseryIGW4YG/b6N+rnyi1otwhoWnf6S672lyrvHbwSFak5b/s90airz+gJRxgL 5MqyazQ5gEfVogWru5JNnTywms4owDKPzkfCGpNPfec0w6l49fKNEQCHyR6royeoSEtO 6ERQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=q+0Jf+Wm; 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 h1si195681ede.397.2018.04.17.19.41.28; Tue, 17 Apr 2018 19:41:29 -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; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=q+0Jf+Wm; 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 C4FA9C21E3B; Wed, 18 Apr 2018 02:40:38 +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=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 E229CC21E76; Wed, 18 Apr 2018 02:40:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6CBE8C21E76; Wed, 18 Apr 2018 02:39:39 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id 9E24BC21E89 for ; Wed, 18 Apr 2018 02:39:35 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w3I2culF028728; Wed, 18 Apr 2018 11:38:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w3I2culF028728 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1524019139; bh=qlqzDsi+mBcuG6yjjndvpMtS6Hzfuesej+nDjtQxORM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+0Jf+WmGrpPzbtHGXY8t4tkIKEJND3G4aPm9Nl4cwoiUuDSNQLI7zc4Rys1M0PRk 0Hox+GfftCzrEqKOapzJH2PcnSsklRINxcre5wqFOPOlhnrr7Dgwyr393D3C+NwC9e 41446Ccfvcm1jS/HmCCXv+8+poU+T3S1+WF9DoSNB1AkqHrRsaEad878lo6V6Fhh+P bdJa8EcKHTUVoy+faQzuORyv8H51PHOx1DCmL5MK6Eyui+CaJfLFjfUdfrsqhkyA5U /r32ue8lTJiS6g5QzrJNrS4WrMWFnIlhUZO03HXEfG8gbKikymkF5eZOnBNmE7iq21 RS9qO3yDDDRkQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 18 Apr 2018 11:38:44 +0900 Message-Id: <1524019125-26287-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524019125-26287-1-git-send-email-yamada.masahiro@socionext.com> References: <1524019125-26287-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 3/4] regmap: change regmap_init_mem() to take ofnode instead udevice 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" Currently, regmap_init_mem() takes udevice. This requires the node has already been associated with a device. It prevents syscon/regmap from behaving like those in Linux. Change the first argumenet to take the device node. Signed-off-by: Masahiro Yamada Acked-by: Neil Armstrong --- arch/arm/mach-aspeed/ast2500/sdram_ast2500.c | 2 +- drivers/core/regmap.c | 11 +++++------ drivers/core/syscon-uclass.c | 2 +- drivers/phy/meson-gxl-usb2.c | 2 +- drivers/phy/meson-gxl-usb3.c | 2 +- drivers/ram/rockchip/dmc-rk3368.c | 2 +- drivers/ram/rockchip/sdram_rk3188.c | 2 +- drivers/ram/rockchip/sdram_rk322x.c | 2 +- drivers/ram/rockchip/sdram_rk3288.c | 2 +- drivers/ram/rockchip/sdram_rk3399.c | 2 +- drivers/ram/stm32mp1/stm32mp1_ram.c | 2 +- drivers/reset/reset-meson.c | 2 +- include/regmap.h | 4 ++-- 13 files changed, 18 insertions(+), 19 deletions(-) diff --git a/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c b/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c index 6383f72..f267c58 100644 --- a/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c +++ b/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c @@ -392,7 +392,7 @@ static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev) struct regmap *map; int ret; - ret = regmap_init_mem(dev, &map); + ret = regmap_init_mem(dev_ofnode(dev), &map); if (ret) return ret; diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 6c3dbe9..1185a44 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -51,7 +51,7 @@ int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count, return 0; } #else -int regmap_init_mem(struct udevice *dev, struct regmap **mapp) +int regmap_init_mem(ofnode node, struct regmap **mapp) { struct regmap_range *range; struct regmap *map; @@ -59,14 +59,13 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp) int addr_len, size_len, both_len; int len; int index; - ofnode node = dev_ofnode(dev); struct resource r; - addr_len = dev_read_simple_addr_cells(dev->parent); - size_len = dev_read_simple_size_cells(dev->parent); + addr_len = ofnode_read_simple_addr_cells(ofnode_get_parent(node)); + size_len = ofnode_read_simple_size_cells(ofnode_get_parent(node)); both_len = addr_len + size_len; - len = dev_read_size(dev, "reg"); + len = ofnode_read_size(node, "reg"); if (len < 0) return len; len /= sizeof(fdt32_t); @@ -87,7 +86,7 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp) range->size = r.end - r.start + 1; } else { range->start = fdtdec_get_addr_size_fixed(gd->fdt_blob, - dev_of_offset(dev), "reg", index, + ofnode_to_offset(node), "reg", index, addr_len, size_len, &sz, true); range->size = sz; } diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index a69937e..c99409b 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -41,7 +41,7 @@ static int syscon_pre_probe(struct udevice *dev) return regmap_init_mem_platdata(dev, plat->reg, ARRAY_SIZE(plat->reg), &priv->regmap); #else - return regmap_init_mem(dev, &priv->regmap); + return regmap_init_mem(dev_ofnode(dev), &priv->regmap); #endif } diff --git a/drivers/phy/meson-gxl-usb2.c b/drivers/phy/meson-gxl-usb2.c index 15c9c89..7242bf6 100644 --- a/drivers/phy/meson-gxl-usb2.c +++ b/drivers/phy/meson-gxl-usb2.c @@ -195,7 +195,7 @@ int meson_gxl_usb2_phy_probe(struct udevice *dev) struct phy_meson_gxl_usb2_priv *priv = dev_get_priv(dev); int ret; - ret = regmap_init_mem(dev, &priv->regmap); + ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap); if (ret) return ret; diff --git a/drivers/phy/meson-gxl-usb3.c b/drivers/phy/meson-gxl-usb3.c index a385fbd..47a41fd 100644 --- a/drivers/phy/meson-gxl-usb3.c +++ b/drivers/phy/meson-gxl-usb3.c @@ -166,7 +166,7 @@ int meson_gxl_usb3_phy_probe(struct udevice *dev) struct phy_meson_gxl_usb3_priv *priv = dev_get_priv(dev); int ret; - ret = regmap_init_mem(dev, &priv->regmap); + ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap); if (ret) return ret; diff --git a/drivers/ram/rockchip/dmc-rk3368.c b/drivers/ram/rockchip/dmc-rk3368.c index bfcb1dd..9bf64bf 100644 --- a/drivers/ram/rockchip/dmc-rk3368.c +++ b/drivers/ram/rockchip/dmc-rk3368.c @@ -880,7 +880,7 @@ static int rk3368_dmc_ofdata_to_platdata(struct udevice *dev) #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3368_sdram_params *plat = dev_get_platdata(dev); - ret = regmap_init_mem(dev, &plat->map); + ret = regmap_init_mem(dev_ofnode(dev), &plat->map); if (ret) return ret; #endif diff --git a/drivers/ram/rockchip/sdram_rk3188.c b/drivers/ram/rockchip/sdram_rk3188.c index 365d00e..c0a2618 100644 --- a/drivers/ram/rockchip/sdram_rk3188.c +++ b/drivers/ram/rockchip/sdram_rk3188.c @@ -842,7 +842,7 @@ static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev) printf("%s: Cannot read rockchip,sdram-params\n", __func__); return -EINVAL; } - ret = regmap_init_mem(dev, ¶ms->map); + ret = regmap_init_mem(dev_ofnode(dev), ¶ms->map); if (ret) return ret; #endif diff --git a/drivers/ram/rockchip/sdram_rk322x.c b/drivers/ram/rockchip/sdram_rk322x.c index cc3138b..dca07db 100644 --- a/drivers/ram/rockchip/sdram_rk322x.c +++ b/drivers/ram/rockchip/sdram_rk322x.c @@ -744,7 +744,7 @@ static int rk322x_dmc_ofdata_to_platdata(struct udevice *dev) printf("%s: Cannot read rockchip,sdram-params\n", __func__); return -EINVAL; } - ret = regmap_init_mem(dev, ¶ms->map); + ret = regmap_init_mem(dev_ofnode(dev), ¶ms->map); if (ret) return ret; #endif diff --git a/drivers/ram/rockchip/sdram_rk3288.c b/drivers/ram/rockchip/sdram_rk3288.c index 95efb11..ffb663c 100644 --- a/drivers/ram/rockchip/sdram_rk3288.c +++ b/drivers/ram/rockchip/sdram_rk3288.c @@ -1003,7 +1003,7 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev) priv->is_veyron = !fdt_node_check_compatible(blob, 0, "google,veyron"); #endif - ret = regmap_init_mem(dev, ¶ms->map); + ret = regmap_init_mem(dev_ofnode(dev), ¶ms->map); if (ret) return ret; #endif diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 5cb470c..6e2a39e 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -1100,7 +1100,7 @@ static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev) __func__, ret); return ret; } - ret = regmap_init_mem(dev, &plat->map); + ret = regmap_init_mem(dev_ofnode(dev), &plat->map); if (ret) printf("%s: regmap failed %d\n", __func__, ret); diff --git a/drivers/ram/stm32mp1/stm32mp1_ram.c b/drivers/ram/stm32mp1/stm32mp1_ram.c index 9599444..a4d5906 100644 --- a/drivers/ram/stm32mp1/stm32mp1_ram.c +++ b/drivers/ram/stm32mp1/stm32mp1_ram.c @@ -149,7 +149,7 @@ static int stm32mp1_ddr_probe(struct udevice *dev) debug("STM32MP1 DDR probe\n"); priv->dev = dev; - ret = regmap_init_mem(dev, &map); + ret = regmap_init_mem(dev_ofnode(dev), &map); if (ret) return ret; diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 5324f86..c41d176 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -77,7 +77,7 @@ static int meson_reset_probe(struct udevice *dev) { struct meson_reset_priv *priv = dev_get_priv(dev); - return regmap_init_mem(dev, &priv->regmap); + return regmap_init_mem(dev_ofnode(dev), &priv->regmap); } U_BOOT_DRIVER(meson_reset) = { diff --git a/include/regmap.h b/include/regmap.h index 858aa7e..c8a1df0 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -48,10 +48,10 @@ int regmap_read(struct regmap *map, uint offset, uint *valp); * * Use regmap_uninit() to free it. * - * @dev: Device that uses this map + * @node: Device node that uses this map * @mapp: Returns allocated map */ -int regmap_init_mem(struct udevice *dev, struct regmap **mapp); +int regmap_init_mem(ofnode node, struct regmap **mapp); /** * regmap_init_mem_platdata() - Set up a new memory register map for of-platdata