Re: [PATCH v2 2/2] regulator: Add support for MAX77686.
Hi Mark, On Sun, May 20, 2012 at 3:30 PM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: On Thu, May 17, 2012 at 07:09:27PM +0530, Yadwinder Singh Brar wrote: Looks mostly good. A couple of fairly small things: +static int max77686_get_voltage_sel(struct regulator_dev *rdev) +{ This looks like it should be regulator_get_voltage_sel_regmap(). +static int max77686_set_voltage_sel(struct regulator_dev *rdev, + unsigned sel) +{ This looks like it should be regulator_set_voltage_sel_regmap(). Yes, We can use regulator_set_voltage_sel_regmap(), I will replace it. + max77686-ramp_delay = pdata-ramp_delay - 1; + max77686_update_reg(i2c, MAX77686_REG_BUCK2CTRL1, + RAMP_VALUE, RAMP_MASK); + max77686_update_reg(i2c, MAX77686_REG_BUCK3CTRL1, + RAMP_VALUE, RAMP_MASK); + max77686_update_reg(i2c, MAX77686_REG_BUCK4CTRL1, + RAMP_VALUE, RAMP_MASK); This code is unclear because RAMP_VALUE looks like a constant that has nothing to do with ramp_delay when in fact it's actually this: +#define RAMP_VALUE (max77686-ramp_delay 6) which isn't constant - this is why I queried this last time. Just remove the define and write this out directly. The way the code is written at the minute it looks like ramp_delay is just stored and not referred to unless you go searching around the rest of the driver. Ok, I will remove it. Thanks, Yadwinder. -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/2] regulator: Add support for MAX77686.
On Thu, May 17, 2012 at 07:09:27PM +0530, Yadwinder Singh Brar wrote: Looks mostly good. A couple of fairly small things: +static int max77686_get_voltage_sel(struct regulator_dev *rdev) +{ This looks like it should be regulator_get_voltage_sel_regmap(). +static int max77686_set_voltage_sel(struct regulator_dev *rdev, + unsigned sel) +{ This looks like it should be regulator_set_voltage_sel_regmap(). + max77686-ramp_delay = pdata-ramp_delay - 1; + max77686_update_reg(i2c, MAX77686_REG_BUCK2CTRL1, + RAMP_VALUE, RAMP_MASK); + max77686_update_reg(i2c, MAX77686_REG_BUCK3CTRL1, + RAMP_VALUE, RAMP_MASK); + max77686_update_reg(i2c, MAX77686_REG_BUCK4CTRL1, + RAMP_VALUE, RAMP_MASK); This code is unclear because RAMP_VALUE looks like a constant that has nothing to do with ramp_delay when in fact it's actually this: +#define RAMP_VALUE (max77686-ramp_delay 6) which isn't constant - this is why I queried this last time. Just remove the define and write this out directly. The way the code is written at the minute it looks like ramp_delay is just stored and not referred to unless you go searching around the rest of the driver. signature.asc Description: Digital signature
[PATCH v2 2/2] regulator: Add support for MAX77686.
Add support for PMIC/regulator portion of MAX77686 multifunction device. MAX77686 provides LDOs[1-26] and BUCKs[1-9]. This is initial release of driver which supports setting and getting the voltage of a regulator with I2C interface. Signed-off-by: Yadwinder Singh Brar yadi.b...@samsung.com --- drivers/regulator/Kconfig|9 + drivers/regulator/Makefile |1 + drivers/regulator/max77686.c | 512 ++ 3 files changed, 522 insertions(+), 0 deletions(-) create mode 100644 drivers/regulator/max77686.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 4ad4e8d..a41d2cf 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -195,6 +195,15 @@ config REGULATOR_MAX8998 via I2C bus. The provided regulator is suitable for S3C6410 and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. +config REGULATOR_MAX77686 + tristate Maxim 77686 regulator + depends on MFD_MAX77686 + help + This driver controls a Maxim 77686 voltage regulator via I2C + bus. The provided regulator is suitable for Exynos5 chips to + control VDD_ARM and VDD_INT voltages.It supports LDOs[1-26] + and BUCKs[1-9]. + config REGULATOR_PCAP tristate Motorola PCAP2 regulator driver depends on EZX_PCAP diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index dcc56dc..949b1f2 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o +obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c new file mode 100644 index 000..7379c29 --- /dev/null +++ b/drivers/regulator/max77686.c @@ -0,0 +1,512 @@ +/* + * max77686.c - Regulator driver for the Maxim 77686 + * + * Copyright (C) 2012 Samsung Electronics Co. Ltd. + * Chiwoong Byun woong.b...@samsung.com + * Yadwinder Singh Brar yadi.b...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * This driver is based on max8997.c + */ + +#include linux/module.h +#include linux/bug.h +#include linux/delay.h +#include linux/err.h +#include linux/gpio.h +#include linux/slab.h +#include linux/platform_device.h +#include linux/regulator/driver.h +#include linux/regulator/machine.h +#include linux/regulator/of_regulator.h +#include linux/mfd/max77686.h +#include linux/mfd/max77686-private.h + +#define RAMP_VALUE (max77686-ramp_delay 6) + +struct max77686_data { + struct device *dev; + struct max77686_dev *iodev; + int num_regulators; + struct regulator_dev **rdev; + int ramp_delay; /* index of ramp_delay */ + + /*GPIO-DVS feature is not enabled with the +*current version of MAX77686 driver.*/ +}; + +static int max77686_get_enable_register(struct regulator_dev *rdev, + int *reg, int *mask, int *pattern) +{ + int rid = rdev_get_id(rdev); + + switch (rid) { + case MAX77686_LDO1...MAX77686_LDO26: + *reg = MAX77686_REG_LDO1CTRL1 + (rid - MAX77686_LDO1); + *mask = 0xc0; + *pattern = 0xc0; + break; + case MAX77686_BUCK1: + *reg = MAX77686_REG_BUCK1CTRL; + *mask = 0x03; + *pattern = 0x03; + break; + case MAX77686_BUCK2: + *reg = MAX77686_REG_BUCK2CTRL1; + *mask = 0x30; + *pattern = 0x10; + break; + case MAX77686_BUCK3: + *reg = MAX77686_REG_BUCK3CTRL1; + *mask = 0x30; + *pattern = 0x10; + break; + case MAX77686_BUCK4: + *reg = MAX77686_REG_BUCK4CTRL1; + *mask = 0x30; + *pattern = 0x10; + break; + case MAX77686_BUCK5...MAX77686_BUCK9: + *reg =