From patchwork Mon Jun 17 15:50:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 167076 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3027534ilk; Mon, 17 Jun 2019 08:50:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqweQwdNziD47guWb39ypgoxecte9iREWhCBGAKq8eEU5/GSXtkfvkFfyRIqdblR4LureVCd X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr26853626pjl.78.1560786650836; Mon, 17 Jun 2019 08:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560786650; cv=none; d=google.com; s=arc-20160816; b=MApp14sqLJ3pqISk9OF9qnwC3XTWaJ6aV9n0lJvBNw0A+kF8PWCYICS+/RvxkmpYsj 71djvXIYNBMNpWBT7toqyUCo7ey0mW7zHgzLv8ZZEOafmG8nyIvY9ZTkOWXY9DeZG+zx ahsclzXM05BsZl5vRcLHqQX6EjopkwH7YxtETJKYJYP5GTv341hCcGLy/K3/+gALQrFU NfU+S9FLjMDtjRnWGS+18T3cioe3hxzqBJPwYEXPdw14rEus5acj0qxiz00VPG+0DwA1 Msl4ezCfjZPczVOdy6HztyBU9bF7uX0rx1Sqv3u6U2/SvqRqpzzOHRhE3TYxE8Yzw32t kuDA== 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; bh=swE05brVXtK4K444C06Ee7EjL8AS/Iz3XKQck7SeOkQ=; b=xqr4O2lSIWIR5EHnjFcvHajOReYGeMMcIuRh7ESVySffuiJUt8dYYIXb8Q4umrZIAd iYDDosLi8HH7u8xwvVN8bbOaLbJzJaw+c6w8sLX5LyXt1/Y93MNDaqExDQNvJ6bx82ZK 9sZEMpa1pMvyaacdK0kzcE+3+tK6NwDyq/xMSoWB414S0Uc7V71vOzFuUp+N3BRkRrJ1 ywGQ1So5vTN2RJPK/q8z/Zb0VxaRT2YypaHWMRX5lqh934jr+Yb6WKMs5n0HPg2XG9CQ SlJxnldN0/9pnWTSVDPMsCijvul1o7r2XDNhhEmXeNuv3OlTspqRLf+iQJJQ0C6eX3dK 01SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zNXCeH0d; 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=pass (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 i4si10513786pfa.218.2019.06.17.08.50.50; Mon, 17 Jun 2019 08:50:50 -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=pass header.i=@linaro.org header.s=google header.b=zNXCeH0d; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbfFQPuu (ORCPT + 8 others); Mon, 17 Jun 2019 11:50:50 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37958 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbfFQPut (ORCPT ); Mon, 17 Jun 2019 11:50:49 -0400 Received: by mail-pg1-f194.google.com with SMTP id v11so6049500pgl.5 for ; Mon, 17 Jun 2019 08:50:49 -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=swE05brVXtK4K444C06Ee7EjL8AS/Iz3XKQck7SeOkQ=; b=zNXCeH0d5MSZ48Szd4E1IfUmCprVMeRqZeqnCoGUphntbzXQcv3HkNPwo21TENmxrC gdO/l70dCXWO1c1OfgNP1+r5auTbIVulw210l8401N2uvETaZ20ncCY+abtvfzR032Re b6FDCsj6BEtSgDZ8rnQgJYEUS29/0tm/NSrQ0N/3WKs2KyUAs6Zvh9iWiGgllyY7nZ8T BvonxTtt9v75Ycglh2mPjYQd5IYmM/JNzuq46QthbwQNEeQ3dUKZiD6bHbYmyxuLzAXV bBOl1DaLeYyRbDP3e8t0mo7oU3ycmzKXYmQ6R4g5RiriIq9Au6a6Qskx10/V3D3wT3NR 8RsA== 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=swE05brVXtK4K444C06Ee7EjL8AS/Iz3XKQck7SeOkQ=; b=TLvIEQT4abyZJDxjTn9Ze4Aj0ERSTUAIzR93pnXEDvXRcgpW/9BfbKhBp09FUdIdi9 BHMhskcxfwhZsGJLv2wnG77Zxt6dL0jarATByKuJSxLStyE5BzZn2IG1yYyIMIIM8ij/ MVTsgwImUjWXOXMRWWK86OZqASWNQcSLjb3xZ5VzAf7iHVVcGdF5kCxL7lYeW/h83zki 9RXDpCd6B19nQWkYcAO7+gSMBI1URwG4EQPwZrbKpCAy6C17wiWM8JVxtJhGMuHs2eO1 UZfI/tEuATuLF1mpzGf84k0QvoSWUPi2NGW1RSxuylqOadabaLObtc+Tkeagb/3rvQZ4 kvYA== X-Gm-Message-State: APjAAAU7RX1LdyJ6dTOPTZBIWG0HXIwFkfCHIMdYBPBo0gvMyOMcLvPc EZXuQhocCw3ofc6WZb2Rvy2JDDlgVw== X-Received: by 2002:a17:90a:216f:: with SMTP id a102mr27370280pje.29.1560786648652; Mon, 17 Jun 2019 08:50:48 -0700 (PDT) Received: from localhost.localdomain ([2409:4072:629b:c246:9431:2a24:7932:6dba]) by smtp.gmail.com with ESMTPSA id n2sm11023603pff.104.2019.06.17.08.50.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 08:50:48 -0700 (PDT) From: Manivannan Sadhasivam To: lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org Cc: afaerber@suse.de, linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org, thomas.liau@actions-semi.com, devicetree@vger.kernel.org, linus.walleij@linaro.org, Manivannan Sadhasivam Subject: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs Date: Mon, 17 Jun 2019 21:20:10 +0530 Message-Id: <20190617155011.15376-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190617155011.15376-1-manivannan.sadhasivam@linaro.org> References: <20190617155011.15376-1-manivannan.sadhasivam@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add regulator driver for Actions Semi ATC260x PMICs. This driver supports 5 DC-DC converters and 10 LDO regulators found in ATC2609A PMIC variant. Signed-off-by: Manivannan Sadhasivam --- drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/atc260x-regulator.c | 389 ++++++++++++++++++++++++++ 3 files changed, 398 insertions(+) create mode 100644 drivers/regulator/atc260x-regulator.c -- 2.17.1 diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 8553bdf87c1d..acaf447ecdc6 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -166,6 +166,14 @@ config REGULATOR_AS3722 AS3722 PMIC. This will enable support for all the software controllable DCDC/LDO regulators. +config REGULATOR_ATC260X + tristate "Actions Semi ATC260x PMIC Regulators" + depends on MFD_ATC260X + help + This driver provides support for the voltage regulators on the + ATC260x PMICs. This will enable support for all the software + controllable DCDC/LDO regulators. + config REGULATOR_AXP20X tristate "X-POWERS AXP20X PMIC Regulators" depends on MFD_AXP20X diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 93f53840e8f1..600d01d082a3 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_REGULATOR_ARIZONA_LDO1) += arizona-ldo1.o obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o +obj-$(CONFIG_REGULATOR_ATC260X) += atc260x-regulator.o obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o obj-$(CONFIG_REGULATOR_BD70528) += bd70528-regulator.o diff --git a/drivers/regulator/atc260x-regulator.c b/drivers/regulator/atc260x-regulator.c new file mode 100644 index 000000000000..e9e11f2567b2 --- /dev/null +++ b/drivers/regulator/atc260x-regulator.c @@ -0,0 +1,389 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Regulator driver for ATC260x PMICs + * + * Copyright (C) 2019 Manivannan Sadhasivam + */ + +#include +#include +#include +#include +#include + +#define ATC2609A_DCDC_VSEL_MASK 0xff00 +#define ATC2609A_DCDC_MIN_UV 600000 +#define ATC2609A_DCDC_UV_STEP 6250 +#define ATC2609A_DCDC_NR_VOLT 256 + +#define ATC2609A_LDO_VSEL_MASK0 0x003c +#define ATC2609A_LDO_VSEL_MASK1 0x001e +#define ATC2609A_LDO_VSEL_MASK2 0xe000 +#define ATC2609A_LDO_VSEL_RANGE_MASK 0x0020 + +static const struct regulator_linear_range atc260x_ldo_voltage_ranges0[] = { + REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000), + REGULATOR_LINEAR_RANGE(2100000, 16, 28, 100000), +}; + +static const struct regulator_linear_range atc260x_ldo_voltage_ranges1[] = { + REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000), + REGULATOR_LINEAR_RANGE(2100000, 16, 27, 100000), +}; + +static const unsigned int atc260x_ldo_voltage_range_sel[] = { + 0x0, 0x1, +}; + +static const struct regulator_linear_range atc260x_dcdc_voltage_ranges[] = { + REGULATOR_LINEAR_RANGE(600000, 0, 127, 6250), + REGULATOR_LINEAR_RANGE(1400000, 128, 232, 25000), +}; + +static const struct regulator_ops atc260x_reg_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .list_voltage = regulator_list_voltage_linear, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, +}; + +static const struct regulator_ops atc260x_reg_fixed_ops = { + .list_voltage = regulator_list_voltage_linear, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, +}; + +static const struct regulator_ops atc260x_reg_range0_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .list_voltage = regulator_list_voltage_pickable_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_pickable_regmap, + .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap, +}; + +static const struct regulator_ops atc260x_reg_range1_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .list_voltage = regulator_list_voltage_linear_range, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, +}; + +static const struct regulator_desc atc2609a_reg[] = { + { + .name = "DCDC_REG0", + .supply_name = "vcc0", + .of_match = of_match_ptr("DCDC_REG0"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_DCDC0, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = ATC2609A_DCDC_MIN_UV, + .uV_step = ATC2609A_DCDC_UV_STEP, + .n_voltages = ATC2609A_DCDC_NR_VOLT, + .vsel_reg = ATC2609A_PMU_DC0_CTL0, + .vsel_mask = ATC2609A_DCDC_VSEL_MASK, + .enable_reg = ATC2609A_PMU_DC_OSC, + .enable_mask = BIT(4), + .enable_time = 800, + .owner = THIS_MODULE, + }, { + .name = "DCDC_REG1", + .supply_name = "vcc1", + .of_match = of_match_ptr("DCDC_REG1"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_DCDC1, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = ATC2609A_DCDC_MIN_UV, + .uV_step = ATC2609A_DCDC_UV_STEP, + .n_voltages = ATC2609A_DCDC_NR_VOLT, + .vsel_reg = ATC2609A_PMU_DC1_CTL0, + .vsel_mask = ATC2609A_DCDC_VSEL_MASK, + .enable_reg = ATC2609A_PMU_DC_OSC, + .enable_mask = BIT(5), + .enable_time = 800, + .owner = THIS_MODULE, + }, { + .name = "DCDC_REG2", + .supply_name = "vcc2", + .of_match = of_match_ptr("DCDC_REG2"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_DCDC2, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = ATC2609A_DCDC_MIN_UV, + .uV_step = ATC2609A_DCDC_UV_STEP, + .n_voltages = ATC2609A_DCDC_NR_VOLT, + .vsel_reg = ATC2609A_PMU_DC2_CTL0, + .vsel_mask = ATC2609A_DCDC_VSEL_MASK, + .enable_reg = ATC2609A_PMU_DC_OSC, + .enable_mask = BIT(6), + .enable_time = 800, + .owner = THIS_MODULE, + }, { + .name = "DCDC_REG3", + .supply_name = "vcc3", + .of_match = of_match_ptr("DCDC_REG3"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_DCDC3, + .ops = &atc260x_reg_range1_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = 233, + .linear_ranges = atc260x_dcdc_voltage_ranges, + .n_linear_ranges = ARRAY_SIZE(atc260x_dcdc_voltage_ranges), + .vsel_reg = ATC2609A_PMU_DC3_CTL0, + .vsel_mask = ATC2609A_DCDC_VSEL_MASK, + .enable_reg = ATC2609A_PMU_DC_OSC, + .enable_mask = BIT(7), + .enable_time = 800, + .owner = THIS_MODULE, + }, { + .name = "DCDC_REG4", + .supply_name = "vcc4", + .of_match = of_match_ptr("DCDC_REG4"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_DCDC4, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = ATC2609A_DCDC_MIN_UV, + .uV_step = ATC2609A_DCDC_UV_STEP, + .n_voltages = ATC2609A_DCDC_NR_VOLT, + .vsel_reg = ATC2609A_PMU_DC4_CTL0, + .vsel_mask = ATC2609A_DCDC_VSEL_MASK, + .enable_reg = ATC2609A_PMU_DC_OSC, + .enable_mask = BIT(8), + .enable_time = 800, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG0", + .supply_name = "vcc5", + .of_match = of_match_ptr("LDO_REG0"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO0, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = 2300000, + .uV_step = 100000, + .n_voltages = 12, + .vsel_reg = ATC2609A_PMU_LDO0_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK0, + .enable_reg = ATC2609A_PMU_LDO0_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG1", + .supply_name = "vcc6", + .of_match = of_match_ptr("LDO_REG1"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO1, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = 2300000, + .uV_step = 100000, + .n_voltages = 12, + .vsel_reg = ATC2609A_PMU_LDO1_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK0, + .enable_reg = ATC2609A_PMU_LDO1_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG2", + .supply_name = "vcc7", + .of_match = of_match_ptr("LDO_REG2"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO2, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = 2300000, + .uV_step = 100000, + .n_voltages = 12, + .vsel_reg = ATC2609A_PMU_LDO2_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK0, + .enable_reg = ATC2609A_PMU_LDO2_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG3", + .supply_name = "vcc8", + .of_match = of_match_ptr("LDO_REG3"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO3, + .ops = &atc260x_reg_range0_ops, + .type = REGULATOR_VOLTAGE, + .linear_ranges = atc260x_ldo_voltage_ranges0, + .n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0), + .vsel_reg = ATC2609A_PMU_LDO3_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK1, + .vsel_range_reg = ATC2609A_PMU_LDO3_CTL0, + .vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK, + .linear_range_selectors = atc260x_ldo_voltage_range_sel, + .enable_reg = ATC2609A_PMU_LDO3_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG4", + .supply_name = "vcc9", + .of_match = of_match_ptr("LDO_REG4"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO4, + .ops = &atc260x_reg_range0_ops, + .type = REGULATOR_VOLTAGE, + .linear_ranges = atc260x_ldo_voltage_ranges0, + .n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0), + .vsel_reg = ATC2609A_PMU_LDO4_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK1, + .vsel_range_reg = ATC2609A_PMU_LDO4_CTL0, + .vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK, + .linear_range_selectors = atc260x_ldo_voltage_range_sel, + .enable_reg = ATC2609A_PMU_LDO4_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG5", + .supply_name = "vcc10", + .of_match = of_match_ptr("LDO_REG5"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO5, + .ops = &atc260x_reg_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = 700000, + .uV_step = 100000, + .n_voltages = 16, + .vsel_reg = ATC2609A_PMU_LDO5_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK1, + .enable_reg = ATC2609A_PMU_LDO5_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG6", + .supply_name = "vcc11", + .of_match = of_match_ptr("LDO_REG6"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO6, + .ops = &atc260x_reg_range0_ops, + .type = REGULATOR_VOLTAGE, + .linear_ranges = atc260x_ldo_voltage_ranges1, + .n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges1), + .vsel_reg = ATC2609A_PMU_LDO6_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK1, + .vsel_range_reg = ATC2609A_PMU_LDO6_CTL0, + .vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK, + .linear_range_selectors = atc260x_ldo_voltage_range_sel, + .enable_reg = ATC2609A_PMU_LDO6_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG7", + .supply_name = "vcc12", + .of_match = of_match_ptr("LDO_REG7"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO7, + .ops = &atc260x_reg_range0_ops, + .type = REGULATOR_VOLTAGE, + .linear_ranges = atc260x_ldo_voltage_ranges0, + .n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0), + .vsel_reg = ATC2609A_PMU_LDO7_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK1, + .vsel_range_reg = ATC2609A_PMU_LDO7_CTL0, + .vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK, + .linear_range_selectors = atc260x_ldo_voltage_range_sel, + .enable_reg = ATC2609A_PMU_LDO7_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG8", + .supply_name = "vcc13", + .of_match = of_match_ptr("LDO_REG8"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO8, + .ops = &atc260x_reg_range0_ops, + .type = REGULATOR_VOLTAGE, + .linear_ranges = atc260x_ldo_voltage_ranges0, + .n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0), + .vsel_reg = ATC2609A_PMU_LDO8_CTL0, + .vsel_mask = ATC2609A_LDO_VSEL_MASK1, + .vsel_range_reg = ATC2609A_PMU_LDO8_CTL0, + .vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK, + .linear_range_selectors = atc260x_ldo_voltage_range_sel, + .enable_reg = ATC2609A_PMU_LDO8_CTL0, + .enable_mask = BIT(0), + .enable_time = 2000, + .owner = THIS_MODULE, + }, { + .name = "LDO_REG9", + .supply_name = "vcc14", + .of_match = of_match_ptr("LDO_REG9"), + .regulators_node = of_match_ptr("regulators"), + .id = ATC2609A_ID_LDO9, + .ops = &atc260x_reg_fixed_ops, + .type = REGULATOR_VOLTAGE, + .min_uV = 2600000, + .uV_step = 100000, + .n_voltages = 8, + .vsel_reg = ATC2609A_PMU_LDO9_CTL, + .vsel_mask = ATC2609A_LDO_VSEL_MASK2, + .enable_time = 2000, + .owner = THIS_MODULE, + }, +}; + +static int atc260x_regulator_probe(struct platform_device *pdev) +{ + struct atc260x *atc260x = dev_get_drvdata(pdev->dev.parent); + struct device *dev = atc260x->dev; + struct regulator_config config = {}; + struct regulator_dev *atc260x_rdev; + const struct regulator_desc *regulators; + int i, nregulators; + + switch (atc260x->type) { + case ATC2609A: + regulators = atc2609a_reg; + nregulators = ATC2609A_ID_MAX; + break; + default: + dev_err(dev, "unsupported ATC260X ID %d\n", atc260x->type); + return -EINVAL; + } + + config.dev = dev; + config.regmap = atc260x->regmap; + + /* Instantiate the regulators */ + for (i = 0; i < nregulators; i++) { + atc260x_rdev = devm_regulator_register(&pdev->dev, + ®ulators[i], &config); + if (IS_ERR(atc260x_rdev)) { + dev_err(dev, "failed to register regulator: %d\n", i); + return PTR_ERR(atc260x_rdev); + } + } + + return 0; +} + +static struct platform_driver atc260x_regulator_driver = { + .probe = atc260x_regulator_probe, + .driver = { + .name = "atc260x-regulator" + }, +}; + +module_platform_driver(atc260x_regulator_driver); + +MODULE_DESCRIPTION("Regulator driver for ATC260x PMICs"); +MODULE_AUTHOR("Manivannan Sadhasivam "); +MODULE_LICENSE("GPL");