From patchwork Fri May 5 02:39:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 758839 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wJx304QKnz9s8V for ; Fri, 5 May 2017 12:40:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="StHSpD4A"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 02624C21C45; Fri, 5 May 2017 02:40:30 +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=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 4A520C21BE6; Fri, 5 May 2017 02:40:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2F33AC21BE6; Fri, 5 May 2017 02:40:27 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by lists.denx.de (Postfix) with ESMTPS id A8AC3C21BE5 for ; Fri, 5 May 2017 02:40:24 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id b23so4294808pfc.0 for ; Thu, 04 May 2017 19:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=SCJWLhhAYYBgxc2yNeH4ZjzlauoCTzZ/1NcRGIL/jTQ=; b=StHSpD4A6cNuMeJdc18DBofdvyZcfBt59eP9nwPj3fzbQYxwxY5lEY748UR5E7bcTT sJpUdk7q+HgHLcNWo6DiTpX4/FFU81N293cHsf/Kk8oRbQvejmPqlVkrZ2NA4DRZv1PN rKqUEbnr7OKYRL+LY9cxbhB8ZFf5QOjHt8bpistdncZhlsvYBwyInGGSpXjJCRXXEqqR O4ynIsBU6LnCP4Srnpxl2MbDeoTupvUnBZN3vg3GZQkWs1VZ17ZeMr1RLGWulDp2wkLL HUzV9UF5W2XcOVngBRkLauPZMvFp0ijyk+mJbB96eF4hZacqB7639GXtmnUxPIn+eFYB sLVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=SCJWLhhAYYBgxc2yNeH4ZjzlauoCTzZ/1NcRGIL/jTQ=; b=eacDhW2ZlzBgjXmbk2ynhBXlgtjbMNzbe+vLqz6RCY/0TFbDjJxZ/r7Sd6ry7EoePR b+mhHVftVovVUEUn91ju8xBjTx1RmWYRu30+QqLAK5txpObj6Kz7MIkx7oyXorendvEM ZL75PAmBfEWTXOVnNIlNfIRNdkm7P3bhV5v/+e6tIfCgpZXovsq0FZKMFvfQMhVDEfr5 igCRi8eOLdeGS98WFyo70p/d8zV259DkW9ZYL4itDpwO/eVp4UrTOPc/ONe/RCQS//VP WX7Ga2vAMIqJBpRFBps7Ca543uh30aiIJ0g2XLDmYMiLh+Czr9FBHiVLsdj2KwDe6vbT +YeQ== X-Gm-Message-State: AN3rC/7pUUC/VJyv0B49G7+xZl/EBresH7FC+FOQbXNmqHGzACKtbnY6 rrpUPYKR7KUjfw== X-Received: by 10.84.137.129 with SMTP id 1mr60252711pln.134.1493952022975; Thu, 04 May 2017 19:40:22 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id a21sm7129514pfc.60.2017.05.04.19.40.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 May 2017 19:40:22 -0700 (PDT) From: Kever Yang To: sjg@chromium.org Date: Fri, 5 May 2017 10:39:35 +0800 Message-Id: <1493952008-9762-1-git-send-email-kever.yang@rock-chips.com> X-Mailer: git-send-email 1.9.1 Cc: Tony O'Brien , u-boot@lists.denx.de, Chris Packham Subject: [U-Boot] [PATCH v3] regmap: add support for address cell 2 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" ARM64 is using 64bit address which address cell is 2 instead of 1, update to support it when of-platdata enabled. Signed-off-by: Kever Yang --- Changes in v3: - move of_plat_get_number() into lib/of_plat.c Changes in v2: - rename the fdtdec_get_number() to of_plat_get_number() drivers/core/regmap.c | 9 +++++++++ include/of_plat.h | 22 ++++++++++++++++++++++ lib/Makefile | 3 +++ lib/of_plat.c | 17 +++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 include/of_plat.h create mode 100644 lib/of_plat.c diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 3bec3df..c03279e 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -49,11 +50,19 @@ int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count, if (!map) return -ENOMEM; +#ifdef CONFIG_PHYS_64BIT + map->base = of_plat_get_number(reg, 2); + for (range = map->range; count > 0; reg += 4, range++, count--) { + range->start = of_plat_get_number(reg, 2); + range->size = of_plat_get_number(reg + 2, 2); + } +#else map->base = *reg; for (range = map->range; count > 0; reg += 2, range++, count--) { range->start = *reg; range->size = reg[1]; } +#endif *mapp = map; diff --git a/include/of_plat.h b/include/of_plat.h new file mode 100644 index 0000000..0badabb --- /dev/null +++ b/include/of_plat.h @@ -0,0 +1,22 @@ +/* + * (C) Copyright 2017 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __of_plat_h +#define __of_plat_h + +#include "libfdt_env.h" +/** + * Get a variable-sized number from a property + * + * This reads a number from one or more cells. + * + * @param ptr Pointer to property + * @param cells Number of cells containing the number + * @return the value in the cells + */ +u64 of_plat_get_number(const fdt32_t *ptr, unsigned int cells); + +#endif diff --git a/lib/Makefile b/lib/Makefile index 23e9f1e..a988965 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -55,6 +55,9 @@ obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o endif +ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy) +obj-$(CONFIG_$(SPL_)OF_CONTROL) += of_plat.o +endif ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o obj-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o diff --git a/lib/of_plat.c b/lib/of_plat.c new file mode 100644 index 0000000..cf1cd1e --- /dev/null +++ b/lib/of_plat.c @@ -0,0 +1,17 @@ +/* + * (C) Copyright 2017 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "of_plat.h" + +u64 of_plat_get_number(const u32 *ptr, unsigned int cells) +{ + u64 number = 0; + + while (cells--) + number = (number << 32) | (*ptr++); + + return number; +}