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: 9761971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5F9E60365 for ; Fri, 2 Jun 2017 08:53:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D855328414 for ; Fri, 2 Jun 2017 08:53:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC0A928549; Fri, 2 Jun 2017 08:53:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4935028414 for ; Fri, 2 Jun 2017 08:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6G2B4+AsqXoToqeuJun5o93vRmSPFaSZ8rlD3OAzcyE=; b=AtxlBfh+1D0pBwEymavg6BZ1rg XaRS8oxy4PUV/IzFp9hfnfEeILi+NxdVYoXXuspFGUn/D7+ZZqtXWcfbnD0jGYb8/BfM55WTTVwUX G2IBi4EnlGWb55mN9HalKukxy4YOtdj3fA3FvKAd98xJ8EXFiIwEndqa9Sl6kMZaX3Xj24LGSh4wq 2FGf1WYVXaNHz86qkY1y4TbXHjVHMVKO2nohTAXg53I+F65Q0QhNmBNHEOD+TG12or3iA/NKBKRgV MiRpPFciUUUcPFOStMiHUAmm/E9JA43B/VhlKIlaCcEOAFX/dJie02N9ivDl8aJuOViaCJspG61yf cWOCQEEA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dGiKi-00009i-6t; Fri, 02 Jun 2017 08:53:24 +0000 Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dGiKb-0008NN-2r for linux-arm-kernel@lists.infradead.org; Fri, 02 Jun 2017 08:53:21 +0000 Received: by mail-it0-x233.google.com with SMTP id m47so547211iti.1 for ; Fri, 02 Jun 2017 01:52:56 -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=hAjECNUX10xA8ANd5mv8XSlhEJY8+Rxw3ukJ9wZpJUgCZWyVFKUClSC50et4lZFa7r G61NjeEB3edZgZ47oXwANev/Vfp38iSj6bkDjmmD4z+e3BoHRmwMRQAWkOPQDlxSXGsm STq0zJGYkt/fhicklGTZbhZmbU+TrISJRz/JXXVtU8ECct6ToJMypgO/GjPzFFKf5Xj7 ZqnvvQlKo4vEJVAJsAyfPaoq9jWCbScvP3HcyqO5SBBxverNF2Ki802OoPcqhcII76q0 HvUgkOuFPARQC6w3dczqkDEBw+TKfKdMb8L6EO3UfKUlbrsW4+7oaF2t7XITt2EuHeYT Fp9A== X-Gm-Message-State: AODbwcBQ+57i7e1jSGxcepivRxVtxoVv7MplfjvRJVx3NTTSaYwmfK2V edUknaKxj2RnHEv2 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170602_015317_269662_DBFCDA38 X-CRM114-Status: GOOD ( 15.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Guodong Xu , hw.wangxiaoyin@hisilicon.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 */