From patchwork Fri Jun 2 08:51:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 100993 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp284225qge; Fri, 2 Jun 2017 01:53:03 -0700 (PDT) X-Received: by 10.98.61.207 with SMTP id x76mr5663133pfj.170.1496393583170; Fri, 02 Jun 2017 01:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496393583; cv=none; d=google.com; s=arc-20160816; b=BgENRVL0kn/dDvAHUgrgSOjIhgPifWj3ZvTvtYabFj5XbytHN2TUK5XOZlqktPhMLl TxNcdAb+J4iFicCDIQEch3Xs5c7qgt8bajR6GlA2f2CmQi0K+p21qAtI/GEXHUadB6WH KHgg4RPpDSnDZhHxLHYTheLef+/iTgP2MY6rTuzJvC9TdEdYJtA/Bf9+DkKStcO3xKF8 yQnLSB6VJfyd/ePCTlBMaAuCOvhYejPs0rfUnrioZjABqu2cFAKhVPE33Wgsl6WksdTd K72bFhsiH1TAcU56mTuIY8Hc8P1nAmHG3oS9sxv1US7uImiHuJ+h7DiNW/BDZzDdCJwP jBeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=PP+cxYzx+epasFaiqQEisBX9xZNKkFJu+vGxkefemZg=; b=TAmNw7eOCTXkNgJfu7rVuxNvThxhBQNTPbmfqB+QH2CeCsbz0ea02Wc5Nc2Pxd3sRg iJ8izBIYsi9YhybAGN4MmnqxuOxSRO9Qh8jgiDwYhczQkZBUncG1forhVkste3aphxRP iCF1Pf4LjNOMl9F1v6DEamHUkbR58nC+iLhH/m+zSEG5Pq7mEYI7MdiqeQ7jEnuqDbcI quMj4AFylutKXeBZZ/lN+4AuKs00Z/rGDCs6kn1w3/lYp5E8zReaL076LKYcdfB7QLtS b7JAe7AMEfaushbZT0RNSw0UzPL5IhhBM10l/7sZeHTdfxf94XXYJooUONQcK/mGF9gQ d1cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n13si22455191pgc.250.2017.06.02.01.53.02; Fri, 02 Jun 2017 01:53:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751135AbdFBIw7 (ORCPT + 7 others); Fri, 2 Jun 2017 04:52:59 -0400 Received: from mail-it0-f50.google.com ([209.85.214.50]:36788 "EHLO mail-it0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751130AbdFBIw5 (ORCPT ); Fri, 2 Jun 2017 04:52:57 -0400 Received: by mail-it0-f50.google.com with SMTP id m47so547212iti.1 for ; Fri, 02 Jun 2017 01:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sa12Nv5YBukV+hPJxqhHiZsqERRqdABGIuyF78gOPnQ=; b=Hhro04DaG3UmFicZdnvFnp63DCEj3IUqXlkV8bjYA0+E7E8SNfBQ48R1uZDQxJfmqX zN7ATtx2kY4Y9K60MI+UnNbpwBajMteI9tYOEKnXaABrwYJfIOYM2Q9E3xX8dT/FtO5F EyXFsFtbx+uNvywpnY7/IdZF43mBjqBCfqxLA= 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:in-reply-to :references; bh=Sa12Nv5YBukV+hPJxqhHiZsqERRqdABGIuyF78gOPnQ=; b=Z0SSali8FY7aW3Q/ibyRrWaQQaDY+lNua/dlV8imXgPfKYFx8eEKVQQp1HX1EXRP8K C5YusRuBB1r1gX4GrjDMA4uy+na/xbJVNGzQofNROjrehuhAbqeGTImE0gkoOLEXmpBh OexkGUEecTHeAGptydJwGkKUKU1A1qLuCmMt1RUHaNM4ys1IX6R/iemEx6llOG6Zx6ts lspPNKchRDUNHrbCZdxoX9Sy50Qbuj0qEcKN692pLz+VXiWRKsjBnRrwV9k1ll//w/PU qkCuc/e+96b2XNJoct4mgBkwvLyLCd5Ttn59FNks4HHFWstlP/J/yULw/ORirvb9Ktg/ 3j9g== X-Gm-Message-State: AODbwcBwL5wi6mfbE5lRxL3CXv/WBdbl/d7PdP4DyTDQaq3xsxxoAF6H pvCBcy7XVpBL6zpe X-Received: by 10.99.139.194 with SMTP id j185mr6033546pge.126.1496393513918; Fri, 02 Jun 2017 01:51:53 -0700 (PDT) Received: from localhost.localdomain ([45.56.159.223]) by smtp.gmail.com with ESMTPSA id d185sm32608146pgc.39.2017.06.02.01.51.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jun 2017 01:51:53 -0700 (PDT) From: Guodong Xu To: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, xuwei5@hisilicon.com, catalin.marinas@arm.com, will.deacon@arm.com, lgirdwood@gmail.com, broonie@kernel.org, khilman@baylibre.com, arnd@arndb.de, gregory.clement@free-electrons.com, horms+renesas@verge.net.au, olof@lixom.net, thomas.petazzoni@free-electrons.com, yamada.masahiro@socionext.com, riku.voipio@linaro.org, treding@nvidia.com, krzk@kernel.org, eric@anholt.net, damm+renesas@opensource.se, ard.biesheuvel@linaro.org, linus.walleij@linaro.org, geert+renesas@glider.be Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, hw.wangxiaoyin@hisilicon.com, Guodong Xu Subject: [PATCH v2 2/6] mfd: hi6421-pmic: add support for HiSilicon Hi6421v530 Date: Fri, 2 Jun 2017 16:51:13 +0800 Message-Id: <20170602085117.27474-3-guodong.xu@linaro.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170602085117.27474-1-guodong.xu@linaro.org> References: <20170602085117.27474-1-guodong.xu@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for HiSilicon Hi6421v530 PMIC. Hi6421v530 communicates with main SoC via memory-mapped I/O. Hi6421v530 and Hi6421 are PMIC chips from the same vendor, HiSilicon, but at different revisions. They share the same memory-mapped I/O design. They differ in integrated devices, such as regulator details, LDO voltage points. Signed-off-by: Wang Xiaoyin Signed-off-by: Guodong Xu --- drivers/mfd/hi6421-pmic-core.c | 56 +++++++++++++++++++++++++++++++---------- include/linux/mfd/hi6421-pmic.h | 5 ++++ 2 files changed, 48 insertions(+), 13 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mfd/hi6421-pmic-core.c b/drivers/mfd/hi6421-pmic-core.c index 3fd703f..6d40485 100644 --- a/drivers/mfd/hi6421-pmic-core.c +++ b/drivers/mfd/hi6421-pmic-core.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,6 +35,10 @@ static const struct mfd_cell hi6421_devs[] = { { .name = "hi6421-regulator", }, }; +static const struct mfd_cell hi6421v530_devs[] = { + { .name = "hi6421v530-regulator", }, +}; + static const struct regmap_config hi6421_regmap_config = { .reg_bits = 32, .reg_stride = 4, @@ -42,12 +46,30 @@ static const struct regmap_config hi6421_regmap_config = { .max_register = HI6421_REG_TO_BUS_ADDR(HI6421_REG_MAX), }; +static const struct of_device_id of_hi6421_pmic_match_tbl[] = { + { .compatible = "hisilicon,hi6421-pmic", + .data = (void *)HI6421 }, + { .compatible = "hisilicon,hi6421v530-pmic", + .data = (void *)HI6421_V530 }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match_tbl); + static int hi6421_pmic_probe(struct platform_device *pdev) { struct hi6421_pmic *pmic; struct resource *res; void __iomem *base; - int ret; + const struct of_device_id *id; + unsigned long type; + const struct mfd_cell *subdevs = NULL; + int n_subdevs, ret; + + id = of_match_device(of_hi6421_pmic_match_tbl, &pdev->dev); + if (id) + type = (unsigned long)id->data; + else + return -EINVAL; pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); if (!pmic) @@ -66,18 +88,32 @@ static int hi6421_pmic_probe(struct platform_device *pdev) return PTR_ERR(pmic->regmap); } - /* set over-current protection debounce 8ms */ - regmap_update_bits(pmic->regmap, HI6421_OCP_DEB_CTRL_REG, + platform_set_drvdata(pdev, pmic); + + switch (type) { + case HI6421: + /* set over-current protection debounce 8ms */ + regmap_update_bits(pmic->regmap, HI6421_OCP_DEB_CTRL_REG, (HI6421_OCP_DEB_SEL_MASK | HI6421_OCP_EN_DEBOUNCE_MASK | HI6421_OCP_AUTO_STOP_MASK), (HI6421_OCP_DEB_SEL_8MS | HI6421_OCP_EN_DEBOUNCE_ENABLE)); - platform_set_drvdata(pdev, pmic); + subdevs = hi6421_devs; + n_subdevs = ARRAY_SIZE(hi6421_devs); + break; + case HI6421_V530: + subdevs = hi6421v530_devs; + n_subdevs = ARRAY_SIZE(hi6421v530_devs); + break; + default: + dev_err(&pdev->dev, "Unknown device type %ld\n", type); + return -EINVAL; + } - ret = devm_mfd_add_devices(&pdev->dev, 0, hi6421_devs, - ARRAY_SIZE(hi6421_devs), NULL, 0, NULL); + ret = devm_mfd_add_devices(&pdev->dev, 0, subdevs, + n_subdevs, NULL, 0, NULL); if (ret) { dev_err(&pdev->dev, "add mfd devices failed: %d\n", ret); return ret; @@ -86,12 +122,6 @@ static int hi6421_pmic_probe(struct platform_device *pdev) return 0; } -static const struct of_device_id of_hi6421_pmic_match_tbl[] = { - { .compatible = "hisilicon,hi6421-pmic", }, - { }, -}; -MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match_tbl); - static struct platform_driver hi6421_pmic_driver = { .driver = { .name = "hi6421_pmic", diff --git a/include/linux/mfd/hi6421-pmic.h b/include/linux/mfd/hi6421-pmic.h index 587273e..2457438 100644 --- a/include/linux/mfd/hi6421-pmic.h +++ b/include/linux/mfd/hi6421-pmic.h @@ -38,4 +38,9 @@ struct hi6421_pmic { struct regmap *regmap; }; +enum hi6421_type { + HI6421 = 1, + HI6421_V530 = 2, +}; + #endif /* __HI6421_PMIC_H */