Received: by 10.223.185.116 with SMTP id b49csp163524wrg; Thu, 8 Mar 2018 14:55:37 -0800 (PST) X-Google-Smtp-Source: AG47ELtH2mdbncoku78HXjseYVCVKTojfqi/GYgnjY6vzrpJ5LUuxbhVvghiAOGlYFWKToLUgtHN X-Received: by 10.99.166.10 with SMTP id t10mr22308116pge.198.1520549737382; Thu, 08 Mar 2018 14:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520549737; cv=none; d=google.com; s=arc-20160816; b=b89+PGtDsw5Z+IjK3InkiGiTEvuqMIE9CrQy0LvM6d1KLnikibjRWiDw+Rnn6xfp1q 2v4DZp9l8h/cD0pQ+B+Ml15vIGOqaXSQxdSkwdq8gCprs1t/Opd1R6Dum3rjSMJqtQly YMyFrF60g+VCQ5LEaFvj5k+6OZY9BgduRdS0C4bKVhG/SmaM9nDftvJYLidtI8ur4dSw soHtrqRLY9Y/oEIK9+8Go/uZ1cqUQn6WcHpnVO+ZjHJgA4I7VrBbQy4wdCbZH40Aq5Vw uZoOYloX/KH7ZaSVuXItWQlX594IU01LIMDz6CxhjK1eabjp5+X+pN5x4+oQ2cYqEUvb Jj2Q== 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:arc-authentication-results; bh=IYZdW8QyYNpl57oBI3LTZZN7jPhbTf6SWM8o2ROESR4=; b=qXCa+/zJQiv798OKZr6UZ7/PQ5jv8gO2KwxcAozCTECVl7lxTdhEhDnHR5xj+pknKH Yk4g0MEcKQwWB9nhoKaEEKQjvBvP9/ZzReOASv53H0B5+czn3oJPwZMrAaE6dpndUzgB f3o7mCJKm8wsk3PKd5Gw9wsNS2rXxxqG4iXDBCTeciW10pA+Q842Ma8F8pGEoYScTtJw RDL+r2Lsv1048I32VZP7tC88dtbMCsBBZe5IRVg7Y35DtoH/ZQqOPvOlnaL4Y9NZoksS ldwCS7TJOWjnPocbBsAB1bvPpSldYY6jqM6xtPljgGMTa8LinHPCw/cbsC4qJwfIea9A LK6g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si15511358pld.259.2018.03.08.14.55.22; Thu, 08 Mar 2018 14:55:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751198AbeCHWxg (ORCPT + 99 others); Thu, 8 Mar 2018 17:53:36 -0500 Received: from bran.ispras.ru ([83.149.199.196]:10325 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751046AbeCHWxf (ORCPT ); Thu, 8 Mar 2018 17:53:35 -0500 Received: from monopod.intra.ispras.ru (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id 3412E230E1; Fri, 9 Mar 2018 01:53:33 +0300 (MSK) From: Alexander Monakov To: linux-kernel@vger.kernel.org Cc: Mark Brown , devicetree@vger.kernel.org, Rob Herring , Mark Rutland , Alexander Monakov , Jisheng Zhang Subject: [PATCH 2/2] regulator: 88pg86x: new i2c dual regulator chip Date: Fri, 9 Mar 2018 01:53:03 +0300 Message-Id: <20180308225303.329-2-amonakov@ispras.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180308225303.329-1-amonakov@ispras.ru> References: <20180308225303.329-1-amonakov@ispras.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This chip is found on Google Chromecast and Valve Steam Link devices. It provides two DC regulators with I2C voltage control, separate GPIO enable pins and one sleep mode pin. This driver does not expose GPIO functionality, but supports voltage control in 1.0-2.2V range, based on I2C register information given in Chromecast kernel driver by Jisheng Zhang. Cc: Jisheng Zhang Signed-off-by: Alexander Monakov --- Hello, Some high-level information on the chip is available in Marvell's PDF titled "DC/DC Power Regulators Product Portfolio" [1]. Chromecast's drivers show two linear ranges: 1.0-1.6V at 25mV steps and 1.6-2.2V at 50mV steps. The brochure says that programmable range is 0.6-3.3V, though, so this patch doesn't support the full voltage range. I've also opted not to support GPIO sleep and enable pins over concerns that it would be a dead weight. I'd like to use this for controlling the voltage regulator on Steam Link device. Thanks. Alexander [1] https://www.marvell.com/power-management/assets/Marvell-DC-DC-Power-Regulators-Product-Portfolio.pdf drivers/regulator/88pg86x.c | 114 ++++++++++++++++++++++++++++++++++++++++++++ drivers/regulator/Kconfig | 9 ++++ drivers/regulator/Makefile | 1 + 3 files changed, 124 insertions(+) create mode 100644 drivers/regulator/88pg86x.c diff --git a/drivers/regulator/88pg86x.c b/drivers/regulator/88pg86x.c new file mode 100644 index 000000000000..d5ef55c81185 --- /dev/null +++ b/drivers/regulator/88pg86x.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include + +static const struct regulator_ops pg86x_ops = { + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_linear_range, +}; + +static const struct regulator_linear_range pg86x_buck1_ranges[] = { + REGULATOR_LINEAR_RANGE( 0, 0, 10, 0), + REGULATOR_LINEAR_RANGE(1000000, 11, 34, 25000), + REGULATOR_LINEAR_RANGE(1600000, 35, 47, 50000), +}; + +static const struct regulator_linear_range pg86x_buck2_ranges[] = { + REGULATOR_LINEAR_RANGE( 0, 0, 15, 0), + REGULATOR_LINEAR_RANGE(1000000, 16, 39, 25000), + REGULATOR_LINEAR_RANGE(1600000, 40, 52, 50000), +}; + +static const struct regulator_desc pg86x_regulators[] = { + { + .id = 0, + .type = REGULATOR_VOLTAGE, + .name = "buck1", + .of_match = of_match_ptr("buck1"), + .n_voltages = 11 + 24 + 13, + .linear_ranges = pg86x_buck1_ranges, + .n_linear_ranges = 3, + .vsel_reg = 0x24, + .vsel_mask = 0xff, + .ops = &pg86x_ops, + .owner = THIS_MODULE + }, + { + .id = 1, + .type = REGULATOR_VOLTAGE, + .name = "buck2", + .of_match = of_match_ptr("buck2"), + .n_voltages = 16 + 24 + 13, + .linear_ranges = pg86x_buck2_ranges, + .n_linear_ranges = 3, + .vsel_reg = 0x13, + .vsel_mask = 0xff, + .ops = &pg86x_ops, + .owner = THIS_MODULE + }, +}; + +static const struct regmap_config pg86x_regmap = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int pg86x_i2c_probe(struct i2c_client *i2c) +{ + int id, ret; + struct regulator_config config = {.dev = &i2c->dev}; + struct regmap *regmap = devm_regmap_init_i2c(i2c, &pg86x_regmap); + + if (IS_ERR(regmap)) { + ret = PTR_ERR(regmap); + dev_err(&i2c->dev, "regmap init failed: %d\n", ret); + return ret; + } + + for (id = 0; id < ARRAY_SIZE(pg86x_regulators); id++) { + struct regulator_dev *rdev; + rdev = devm_regulator_register(&i2c->dev, + &pg86x_regulators[id], + &config); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); + dev_err(&i2c->dev, "failed to register %s: %d\n", + pg86x_regulators[id].name, ret); + return ret; + } + } + return 0; +} + +static const struct of_device_id pg86x_dt_ids [] = { + { .compatible = "marvell,88pg867" }, + { .compatible = "marvell,88pg868" }, + { } +}; +MODULE_DEVICE_TABLE(of, pg86x_dt_ids); + +static const struct i2c_device_id pg86x_i2c_id[] = { + { "88pg867", }, + { "88pg868", }, + { } +}; +MODULE_DEVICE_TABLE(i2c, pg86x_i2c_id); + +static struct i2c_driver pg86x_regulator_driver = { + .driver = { + .name = "88pg86x", + .of_match_table = of_match_ptr(pg86x_dt_ids), + }, + .probe_new = pg86x_i2c_probe, + .id_table = pg86x_i2c_id, +}; + +module_i2c_driver(pg86x_regulator_driver); + +MODULE_DESCRIPTION("Marvell 88PG86X voltage regulator"); +MODULE_AUTHOR("Alexander Monakov "); +MODULE_LICENSE("GPL"); diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 96cd55f9e3c5..16afb644aee7 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -54,6 +54,15 @@ config REGULATOR_USERSPACE_CONSUMER If unsure, say no. +config REGULATOR_88PG86X + tristate "Marvell 88PG86X voltage regulators" + depends on I2C + select REGMAP_I2C + help + This driver supports Marvell 88PG867 and 88PG868 voltage regulators. + They provide two I2C-controlled DC/DC step-down converters with + sleep mode and separate enable pins. + config REGULATOR_88PM800 tristate "Marvell 88PM800 Power regulators" depends on MFD_88PM800 diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 80ffc57a9ca3..fbd5e91dd981 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o +obj-$(CONFIG_REGULATOR_88PG86X) += 88pg86x.o obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o obj-$(CONFIG_REGULATOR_CPCAP) += cpcap-regulator.o -- 2.11.0