Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3395765ybl; Mon, 20 Jan 2020 23:25:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxYwbNyV0qrDbVTCjzX5DEJtOFfVKO/DzHHOeXHwIKssWo9pw8a1ZHlX4WMbQHBR7HrP5oY X-Received: by 2002:aca:50cd:: with SMTP id e196mr2010857oib.178.1579591502426; Mon, 20 Jan 2020 23:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579591502; cv=none; d=google.com; s=arc-20160816; b=AsE2jQRgQ1+w3oeioBjfS/+VOBPhDNMs/siLCKZkEEoMzYoWSDJvHfrwdwuQAYXJbG EZWa7A6jZLBH5AxfzeoXbMWOdRPCgkoL3pUYdvo9cpI6GeHUntPjPQugAjABnuhOKfxS /X13iAh1jrADL+ts7eIm+64wePd39AM5waOgyTsuxUF49IXyiTIPwvg5idkm3rWaUKgI M1IXB/98OFOSs+oeCvfg3ILXFXzsF9v/osYBVwwTi76lR8rDyW1dSgsfMEWJY1W274wo E9XdTwbN7FuX9n4NM09Ov+Bf9PSYuavgiBKkr1ZqgDaIwD3sAZIVGBB21V940PPYE1qX EP2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=mlCaxydkOgZv4ICsJLgzeMxdhOBrk2+0L4LhoOYBItQ=; b=VCUIRFaWu7WEy8JtnlY5ex5UeTP+p5HuxRPOzQfwppVzA0uHzzky2IEOXB52AaL3jw 6Zo/WkaZYWAi3Utw9hTsqnSfaW0rSwRWNQ3QrgOuGFkbeblXZ4MUANdi7E1l6iNeHwe6 Fnr3YLeB9bs7WtQdKyPG0xozMCsKlFy6VOEydmMKPyUSPlNEHpvQn4linEPTdRQEr8Pz PaLzLvOZedO4aXgy7Nas9LF8IZRCMBoR5b3VmlrxwunVHyWRA0OJ2Apr6qtDQ0tGtTbi mkGeptzlTihhuG3Eu4dWb9Twq3v1ZS26Vn+jWUZE/C3Vm/Zs8yUiQn8aoQRi+4XEYmBp ReAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YA2vPBq0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si21258692otq.83.2020.01.20.23.24.50; Mon, 20 Jan 2020 23:25:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YA2vPBq0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728811AbgAUHX6 (ORCPT + 99 others); Tue, 21 Jan 2020 02:23:58 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:54427 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbgAUHX6 (ORCPT ); Tue, 21 Jan 2020 02:23:58 -0500 Received: by mail-pj1-f67.google.com with SMTP id kx11so929030pjb.4 for ; Mon, 20 Jan 2020 23:23:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=mlCaxydkOgZv4ICsJLgzeMxdhOBrk2+0L4LhoOYBItQ=; b=YA2vPBq0mvDVXP8id2Mt+w6fhK+0j+w96F+sTtR46ecrXWWm5mihMNdZA0EBwrxV5W T48gHL/VukRPT0lY0JDHqc85r9U9TVwS3pK/EytkWy6PzFgod7I0J/kygHhxCb82K6cR MgY6eXsdO6BLOnxHwfKKiYer/PjvxC90hiygpj0qZUgNmAvTkAtX85gBk1KxNObDFy8A YP1t0c0RyG1xCX0GmabiEt7hNp84d4+SNrZh1v3cN9iBaS55hdxKvjbFhZP0025kRkxT rOAC7VuqnvTQsJBQvIQlzhe1MfUt+7Qi3zskvjw8gVAYT6WWhCCx3zRFu0LAv81aXO0U NwBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mlCaxydkOgZv4ICsJLgzeMxdhOBrk2+0L4LhoOYBItQ=; b=NmEY2LNAPU+CUG/AwUYh4mq3uDkrm+OO0doT1H1kA2H8XEWGKP6NKNtFaHmLOE71AG pOwbXbsTf5NWo4gejceggLiA14N3qemvLbkVN7JZJHRPsN7rvfX+ysTO/mua3l0YvDMc N1ZAUvuNIrNc6EiNNKLcsUuqvD1TJd5Vjzxqfc8GYJz+pDuv7EVSwxIOY9Azw7eU3y4H IJIb6RrsiV8+ceqycieF96JsSIeGpreDr4g9lu8siEY6Sz9kVzwGF7R8gJT+06waiPNm 1eH6y+/01noXm2O6UG/Xgn+sVEvEiQo5QKTl5JapGyQ/MHJYG5R2cf1RqvPTg5dNyKuY txFg== X-Gm-Message-State: APjAAAU+lpUQugrm5vad7h/7aa19yRWpDCRIgALS/PkJ+rMAC+Q9XaG2 NHz/HP2I+M95bRlmtjsE0Og= X-Received: by 2002:a17:90b:8b:: with SMTP id bb11mr3865357pjb.27.1579591437792; Mon, 20 Jan 2020 23:23:57 -0800 (PST) Received: from lenovo.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id a9sm41495866pfn.38.2020.01.20.23.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jan 2020 23:23:57 -0800 (PST) From: Orson Zhai To: Lee Jones , Arnd Bergmann Cc: linux-kernel@vger.kernel.org, baolin.wang@unisoc.com, chunyan.zhang@unisoc.com, Orson Zhai Subject: [PATCH V5] mfd: syscon: Add arguments support for syscon reference Date: Tue, 21 Jan 2020 15:09:38 +0800 Message-Id: <1579590578-8709-1-git-send-email-orson.unisoc@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Orson Zhai There are a lot of similar global registers being used across multiple SoCs from Unisoc. But most of these registers are assigned with different offset for different SoCs. It is hard to handle all of them in an all-in-one kernel image. Add a helper function to get regmap with arguments where we could put some extra information such as the offset value. Signed-off-by: Orson Zhai Tested-by: Baolin Wang Reviewed-by: Arnd Bergmann Acked-by: Lee Jones --- Change V5: Removed unexpected preceding spaces replaced by email system. The patch has been tested for local mailing and applying. drivers/mfd/syscon.c | 29 +++++++++++++++++++++++++++++ include/linux/mfd/syscon.h | 14 ++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index e22197c..2918b05 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -224,6 +224,35 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np, } EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle); +struct regmap *syscon_regmap_lookup_by_phandle_args(struct device_node *np, + const char *property, + int arg_count, + unsigned int *out_args) +{ + struct device_node *syscon_np; + struct of_phandle_args args; + struct regmap *regmap; + unsigned int index; + int rc; + + rc = of_parse_phandle_with_fixed_args(np, property, arg_count, + 0, &args); + if (rc) + return ERR_PTR(rc); + + syscon_np = args.np; + if (!syscon_np) + return ERR_PTR(-ENODEV); + + regmap = syscon_node_to_regmap(syscon_np); + for (index = 0; index < arg_count; index++) + out_args[index] = args.args[index]; + of_node_put(syscon_np); + + return regmap; +} +EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle_args); + static int syscon_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h index 112dc66..714cab1 100644 --- a/include/linux/mfd/syscon.h +++ b/include/linux/mfd/syscon.h @@ -23,6 +23,11 @@ extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s); extern struct regmap *syscon_regmap_lookup_by_phandle( struct device_node *np, const char *property); +extern struct regmap *syscon_regmap_lookup_by_phandle_args( + struct device_node *np, + const char *property, + int arg_count, + unsigned int *out_args); #else static inline struct regmap *device_node_to_regmap(struct device_node *np) { @@ -45,6 +50,15 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle( { return ERR_PTR(-ENOTSUPP); } + +static struct regmap *syscon_regmap_lookup_by_phandle_args( + struct device_node *np, + const char *property, + int arg_count, + unsigned int *out_args) +{ + return ERR_PTR(-ENOTSUPP); +} #endif #endif /* __LINUX_MFD_SYSCON_H__ */ -- 2.7.4