From patchwork Thu Jun 8 22:08:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 103426 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2649670qgd; Thu, 8 Jun 2017 15:10:07 -0700 (PDT) X-Received: by 10.84.247.2 with SMTP id n2mr35933174pll.74.1496959807524; Thu, 08 Jun 2017 15:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496959807; cv=none; d=google.com; s=arc-20160816; b=IaqBCTBvn4Z8CopqOnR8G9wq7cEo4uQsaIO25+QBcoQgvY/YSp895HTrJMZ9JNHugX pzmIwrgua0AFGD46Seg+eCkkOrw/7zEaXQDmYbaDLcAEKcT2FoWNN2WuCVxPcxuQpX1s mGG6bMJLbh8s0FApE6773rvwQR4LZaR1u1ywiYxcya8p7k2hJWaP5qFa2GzRG1h2u1uI hqTrh2gkop6o8Rb/h1PlSYjwBYXx4nl33ksQdXAZfJiHV7PTW7OAQ9oCNSkH24MiUq9h PMZMFYSYS+GG65pom+uS90c9j3HjAy1DHeRmaK+gAFQw19j0oweZjso9mDDpL/10avho t1pQ== 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=yi+QXUO/n3Dw891XN02ALKvcuL9v2luu0S2UvhmEuw0=; b=pOUhIW0SbMVXyUjpN2jVLjVA/lo3Vu2NryAeKprKM8g3Wm4Inkg/s9Ar+qbrV8alcf 2GdByQKOu1IKjrszo/ZcifdZLfonq72e6hNMmaVB7dA8kSTr382/EtBRspYayKan7s92 VzzWoefXfvzfA8eC4DkgsK/ps5phs8jghZuPd4pNHOYPj/Y/PLc3BEiXM6IY54pEMLKB faiuBkM9DUSMjjaeb+ZfT0nKfkauCFmpbeeswjccA+JQK65GWOjgarp2ZF+1VKwYETxY LKvGRyzp4Y5LJjtNpGKdZ11TDVh/j5Ye28iUQhX+zYF65sWt2FNwQml/aGdDmXeY4Ouz kxdA== 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 t10si5288833plh.401.2017.06.08.15.10.07; Thu, 08 Jun 2017 15:10:07 -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 S1751935AbdFHWKC (ORCPT + 7 others); Thu, 8 Jun 2017 18:10:02 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:35260 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbdFHWKB (ORCPT ); Thu, 8 Jun 2017 18:10:01 -0400 Received: by mail-pf0-f178.google.com with SMTP id l89so21574924pfi.2 for ; Thu, 08 Jun 2017 15:10:00 -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=8y6Mm56GpXJdaHP+5SlUe5BYJRH8SIF4HNwWWLbOnV4=; b=NIT10JhQ5byBNye2MSRC64QthjE3UIT0XgfHDSPWi+jni1M3EkqiMlSSlr+R1KIQ2s BH3nA0vboS4EtOxSSXYgtVScQsn0q/WZwTw9290868JrmCe03JpiKwycNbtp+oi6AIe6 iaV/vKtVrSiXGnAGSwlsPiqCZyRy9fcRjRlnc= 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=8y6Mm56GpXJdaHP+5SlUe5BYJRH8SIF4HNwWWLbOnV4=; b=aIYCrT/4XwBxC2vGJ0TKGLQYlptCsfczgR3tECgfJAOGicTZZ5OyPIL/s8tmLmOPkB /vF4ThiuHAq2INeECahUKjbV+t54rC4OziVWhD/eIZE7hHw4QYa3vKArSAtlwBIf6tfK FA+VSLJSoPwayOvDZmZF1N7Jl930Ll4xEa/hq3Zo2J0wYprJs/Q5Ez5UJgd6subuas5e aj/finLnwiHHvo5CGyrKVx8coIX+AsS2fsmPocs/wv4DrSrsrvPbgR2sJSCH+q3Ux8EZ xgm3PbbhHE/e0Pg6VYGvcHrfKF8lD4DyTOFoGlxQ0Sb9aqDGmdw7XWTi5u0PmOTcKG7g coRg== X-Gm-Message-State: AODbwcDWQN4/onq1CpfiLWkomX2UTV3m3HGZ2u0v8/0f1y8PzuVJFZ1X 2O6/MBouTp/Xxyg4 X-Received: by 10.84.229.70 with SMTP id d6mr36653592pln.263.1496959800286; Thu, 08 Jun 2017 15:10:00 -0700 (PDT) Received: from docularxu-ThinkPad-T440p.219.146.1.66 ([45.56.159.87]) by smtp.gmail.com with ESMTPSA id r85sm11963639pfb.61.2017.06.08.15.09.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Jun 2017 15:09:59 -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 v6 4/8] mfd: hi6421-pmic: add support for HiSilicon Hi6421v530 Date: Fri, 9 Jun 2017 06:08:37 +0800 Message-Id: <20170608220841.26531-5-guodong.xu@linaro.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170608220841.26531-1-guodong.xu@linaro.org> References: <20170608220841.26531-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 Acked-by: Arnd Bergmann --- drivers/mfd/hi6421-pmic-core.c | 70 ++++++++++++++++++++++++++++++----------- include/linux/mfd/hi6421-pmic.h | 5 +++ 2 files changed, 57 insertions(+), 18 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 b1139d4..6fb7ba2 100644 --- a/drivers/mfd/hi6421-pmic-core.c +++ b/drivers/mfd/hi6421-pmic-core.c @@ -1,9 +1,9 @@ /* - * Device driver for Hi6421 IC + * Device driver for Hi6421 PMIC * * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd. * http://www.hisilicon.com - * Copyright (c) <2013-2014> Linaro Ltd. + * Copyright (c) <2013-2017> Linaro Ltd. * http://www.linaro.org * * Author: Guodong Xu @@ -16,16 +16,20 @@ #include #include #include +#include #include -#include +#include #include #include -#include 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, @@ -33,12 +37,33 @@ 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[] = { + { + .compatible = "hisilicon,hi6421-pmic", + .data = (void *)HI6421 + }, + { + .compatible = "hisilicon,hi6421v530-pmic", + .data = (void *)HI6421_V530 + }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match); + static int hi6421_pmic_probe(struct platform_device *pdev) { struct hi6421_pmic *pmic; struct resource *res; + const struct of_device_id *id; + const struct mfd_cell *subdevs; + enum hi6421_type type; void __iomem *base; - int ret; + int n_subdevs, ret; + + id = of_match_device(of_hi6421_pmic_match, &pdev->dev); + if (!id) + return -EINVAL; + type = (enum hi6421_type)id->data; pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); if (!pmic) @@ -57,18 +82,33 @@ 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 %d\n", + (unsigned int)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, PLATFORM_DEVID_NONE, + subdevs, n_subdevs, NULL, 0, NULL); if (ret) { dev_err(&pdev->dev, "Failed to add child devices: %d\n", ret); return ret; @@ -77,16 +117,10 @@ 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", - .of_match_table = of_hi6421_pmic_match_tbl, + .name = "hi6421_pmic", + .of_match_table = of_hi6421_pmic_match, }, .probe = hi6421_pmic_probe, }; diff --git a/include/linux/mfd/hi6421-pmic.h b/include/linux/mfd/hi6421-pmic.h index 587273e..2580c08 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 = 0, + HI6421_V530, +}; + #endif /* __HI6421_PMIC_H */