All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/3] Add RK818 PMIC support
@ 2016-04-08  9:47 ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel, linux-rockchip, devicetree
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	lee.jones, lgirdwood, broonie, dianders, zyw

Hello,

this patch adds support for rockchip's RK818 PMIC.

I am not sure if I have to rename all filenames and all relevant variable names
after adding a second supported device to the RK808 driver, e.g:

  mfd/rk8xx.c
  regulator/rk8xx-regulator.c
  clk/clk-rk8xx.c

Regards,
Wadim

Wadim Egorov (3):
  mfd: RK808: Add RK818 support
  regulator: rk808: Add support for rk818
  mfd: dt-bindings: Add RK818 device tree bindings document

 Documentation/devicetree/bindings/mfd/rk808.txt |  37 ++-
 drivers/mfd/Kconfig                             |   6 +-
 drivers/mfd/rk808.c                             | 279 +++++++++++++++----
 drivers/regulator/rk808-regulator.c             | 343 ++++++++++++++++++++++--
 include/linux/mfd/rk808.h                       | 182 ++++++++++++-
 5 files changed, 761 insertions(+), 86 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [RFC 0/3] Add RK818 PMIC support
@ 2016-04-08  9:47 ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: mark.rutland-5wv7dgnIgG8, pawel.moll-5wv7dgnIgG8,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, zyw-TNX95d0MmH7DzftRWevZcw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A

Hello,

this patch adds support for rockchip's RK818 PMIC.

I am not sure if I have to rename all filenames and all relevant variable names
after adding a second supported device to the RK808 driver, e.g:

  mfd/rk8xx.c
  regulator/rk8xx-regulator.c
  clk/clk-rk8xx.c

Regards,
Wadim

Wadim Egorov (3):
  mfd: RK808: Add RK818 support
  regulator: rk808: Add support for rk818
  mfd: dt-bindings: Add RK818 device tree bindings document

 Documentation/devicetree/bindings/mfd/rk808.txt |  37 ++-
 drivers/mfd/Kconfig                             |   6 +-
 drivers/mfd/rk808.c                             | 279 +++++++++++++++----
 drivers/regulator/rk808-regulator.c             | 343 ++++++++++++++++++++++--
 include/linux/mfd/rk808.h                       | 182 ++++++++++++-
 5 files changed, 761 insertions(+), 86 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [RFC 1/3] mfd: RK808: Add RK818 support
@ 2016-04-08  9:47   ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel, linux-rockchip, devicetree
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	lee.jones, lgirdwood, broonie, dianders, zyw

The RK818 chip is a power management IC for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clkout
- battery support

Both chips RK808 and RK818 are using a similar register map.
So we can reuse the RTC and Clkout functionality.

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
 drivers/mfd/Kconfig       |   6 +-
 drivers/mfd/rk808.c       | 279 +++++++++++++++++++++++++++++++++++++---------
 include/linux/mfd/rk808.h | 182 ++++++++++++++++++++++++++++--
 3 files changed, 405 insertions(+), 62 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index eea61e3..7cbbfa4 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -813,14 +813,14 @@ config MFD_RC5T583
 	  Additional drivers must be enabled in order to use the
 	  different functionality of the device.
 
-config MFD_RK808
-	tristate "Rockchip RK808 Power Management chip"
+config MFD_RK8XX
+	tristate "Rockchip RK8xx Power Management chip"
 	depends on I2C && OF
 	select MFD_CORE
 	select REGMAP_I2C
 	select REGMAP_IRQ
 	help
-	  If you say yes here you get support for the RK808
+	  If you say yes here you get support for the RK808 and RK818
 	  Power Management chips.
 	  This driver provides common support for accessing the device
 	  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 4b1e439..d3fd8ef 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -1,11 +1,14 @@
 /*
- * MFD core driver for Rockchip RK808
+ * MFD core driver for Rockchip RK8xx
  *
  * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
  *
  * Author: Chris Zhong <zyw@rock-chips.com>
  * Author: Zhang Qing <zhangqing@rock-chips.com>
  *
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov@phytec.de>
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -22,14 +25,14 @@
 #include <linux/mfd/core.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/of_device.h>
 
-struct rk808_reg_data {
-	int addr;
-	int mask;
-	int value;
+static const char * const rk8xx_model_names[] = {
+	"RK808",
+	"RK818",
 };
 
-static bool rk808_is_volatile_reg(struct device *dev, unsigned int reg)
+static bool rk8xx_is_volatile_reg(struct device *dev, unsigned int reg)
 {
 	/*
 	 * Notes:
@@ -62,7 +65,15 @@ static const struct regmap_config rk808_regmap_config = {
 	.val_bits = 8,
 	.max_register = RK808_IO_POL_REG,
 	.cache_type = REGCACHE_RBTREE,
-	.volatile_reg = rk808_is_volatile_reg,
+	.volatile_reg = rk8xx_is_volatile_reg,
+};
+
+static const struct regmap_config rk818_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = RK818_USB_CTRL_REG,
+	.cache_type = REGCACHE_RBTREE,
+	.volatile_reg = rk8xx_is_volatile_reg,
 };
 
 static struct resource rtc_resources[] = {
@@ -83,7 +94,17 @@ static const struct mfd_cell rk808s[] = {
 	},
 };
 
-static const struct rk808_reg_data pre_init_reg[] = {
+static const struct mfd_cell rk818s[] = {
+	{ .name = "rk808-clkout", },
+	{ .name = "rk808-regulator", },
+	{
+		.name = "rk808-rtc",
+		.num_resources = ARRAY_SIZE(rtc_resources),
+		.resources = &rtc_resources[0],
+	},
+};
+
+static const struct rk8xx_reg_data rk808_pre_init_reg[] = {
 	{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
 	{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
 	{ RK808_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA },
@@ -94,6 +115,27 @@ static const struct rk808_reg_data pre_init_reg[] = {
 						    VB_LO_SEL_3500MV },
 };
 
+static const struct rk8xx_reg_data rk818_pre_init_reg[] = {
+	{ RK818_USB_CTRL_REG,	RK818_USB_ILIM_SEL_MASK,
+						RK818_USB_ILMIN_2000MA },
+	/* close charger when usb lower then 3.4V */
+	{ RK818_USB_CTRL_REG,	RK818_USB_CHG_SD_VSEL_MASK, (0x7 << 4) },
+	/* no action when vref */
+	{ RK818_H5V_EN_REG,	(0x1 << 1),	RK818_REF_RDY_CTRL },
+
+	/* enable HDMI 5V */
+	{ RK818_H5V_EN_REG,	(0x1 << 0),	RK818_H5V_EN },
+
+	/* improve efficiency */
+	{ RK818_BUCK2_CONFIG_REG, BUCK2_RATE_MASK,  BUCK_ILMIN_250MA },
+	{ RK818_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_250MA },
+
+	{ RK818_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA },
+
+	{ RK808_VB_MON_REG,       MASK_ALL,         VB_LO_ACT |
+						    VB_LO_SEL_3500MV },
+};
+
 static const struct regmap_irq rk808_irqs[] = {
 	/* INT_STS */
 	[RK808_IRQ_VOUT_LO] = {
@@ -136,6 +178,81 @@ static const struct regmap_irq rk808_irqs[] = {
 	},
 };
 
+static const struct regmap_irq rk818_irqs[] = {
+	/* INT_STS */
+	[RK818_IRQ_VOUT_LO] = {
+		.mask = RK818_IRQ_VOUT_LO_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_VB_LO] = {
+		.mask = RK818_IRQ_VB_LO_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_PWRON] = {
+		.mask = RK818_IRQ_PWRON_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_PWRON_LP] = {
+		.mask = RK818_IRQ_PWRON_LP_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_HOTDIE] = {
+		.mask = RK818_IRQ_HOTDIE_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_RTC_ALARM] = {
+		.mask = RK818_IRQ_RTC_ALARM_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_RTC_PERIOD] = {
+		.mask = RK818_IRQ_RTC_PERIOD_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_USB_OV] = {
+		.mask = RK818_IRQ_USB_OV_MSK,
+		.reg_offset = 0,
+	},
+
+	/* INT_STS2 */
+	[RK818_IRQ_PLUG_IN] = {
+		.mask = RK818_IRQ_PLUG_IN_MSK,
+		.reg_offset = 1,
+	},
+	[RK818_IRQ_PLUG_OUT] = {
+		.mask = RK818_IRQ_PLUG_OUT_MSK,
+		.reg_offset = 1,
+	},
+	[RK818_IRQ_CHG_OK] = {
+		.mask = RK818_IRQ_CHG_OK_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_CHG_TE] = {
+		.mask = RK818_IRQ_CHG_TE_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_CHG_TS1] = {
+		.mask = RK818_IRQ_CHG_TS1_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_TS2] = {
+		.mask = RK818_IRQ_TS2_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_CHG_CVTLIM] = {
+		.mask = RK818_IRQ_CHG_CVTLIM_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_DISCHG_ILIM] = {
+		.mask = RK818_IRQ_DISCHG_ILIM_MSK,
+		.reg_offset = 1,
+	},
+};
+
 static struct regmap_irq_chip rk808_irq_chip = {
 	.name = "rk808",
 	.irqs = rk808_irqs,
@@ -148,15 +265,27 @@ static struct regmap_irq_chip rk808_irq_chip = {
 	.init_ack_masked = true,
 };
 
-static struct i2c_client *rk808_i2c_client;
+static struct regmap_irq_chip rk818_irq_chip = {
+	.name = "rk818",
+	.irqs = rk818_irqs,
+	.num_irqs = ARRAY_SIZE(rk808_irqs),
+	.num_regs = 2,
+	.irq_reg_stride = 2,
+	.status_base = RK808_INT_STS_REG1,
+	.mask_base = RK808_INT_STS_MSK_REG1,
+	.ack_base = RK808_INT_STS_REG1,
+	.init_ack_masked = true,
+};
+
+static struct i2c_client *rk8xx_i2c_client;
 static void rk808_device_shutdown(void)
 {
 	int ret;
-	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+	struct rk808 *rk808 = i2c_get_clientdata(rk8xx_i2c_client);
 
 	if (!rk808) {
-		dev_warn(&rk808_i2c_client->dev,
-			 "have no rk808, so do nothing here\n");
+		dev_warn(&rk8xx_i2c_client->dev,
+			 "have no rk8xx, so do nothing here\n");
 		return;
 	}
 
@@ -164,10 +293,57 @@ static void rk808_device_shutdown(void)
 				 RK808_DEVCTRL_REG,
 				 DEV_OFF_RST, DEV_OFF_RST);
 	if (ret)
-		dev_err(&rk808_i2c_client->dev, "power off error!\n");
+		dev_err(&rk8xx_i2c_client->dev, "power off error!\n");
+}
+
+static const struct of_device_id rk8xx_of_match[] = {
+	{ .compatible = "rockchip,rk808", .data = (void *) RK808_ID },
+	{ .compatible = "rockchip,rk818", .data = (void *) RK818_ID },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rk8xx_of_match);
+
+static int rk8xx_match_device(struct rk808 *rk808, struct device *dev)
+{
+	const struct of_device_id *of_id;
+
+	if (dev->of_node) {
+		of_id = of_match_device(rk8xx_of_match, dev);
+		if (!of_id) {
+			dev_err(dev, "Unable to match OF ID\n");
+			return -ENODEV;
+		}
+		rk808->variant = (long) of_id->data;
+	}
+
+	switch (rk808->variant) {
+	case RK808_ID:
+		rk808->nr_cells = ARRAY_SIZE(rk808s);
+		rk808->cells = rk808s;
+		rk808->regmap_cfg = &rk808_regmap_config;
+		rk808->regmap_irq_chip = &rk808_irq_chip;
+		rk808->pre_init_reg = rk808_pre_init_reg;
+		rk808->nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
+		break;
+	case RK818_ID:
+		rk808->nr_cells = ARRAY_SIZE(rk818s);
+		rk808->cells = rk818s;
+		rk808->regmap_cfg = &rk818_regmap_config;
+		rk808->regmap_irq_chip = &rk818_irq_chip;
+		rk808->pre_init_reg = rk818_pre_init_reg;
+		rk808->nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
+		break;
+	default:
+		dev_err(dev, "unsupported RK8XX ID %lu\n", rk808->variant);
+		return -EINVAL;
+	}
+	dev_info(dev, "RK8XX variant %s found\n",
+		rk8xx_model_names[rk808->variant]);
+
+	return 0;
 }
 
-static int rk808_probe(struct i2c_client *client,
+static int rk8xx_probe(struct i2c_client *client,
 		       const struct i2c_device_id *id)
 {
 	struct device_node *np = client->dev.of_node;
@@ -176,45 +352,51 @@ static int rk808_probe(struct i2c_client *client,
 	int ret;
 	int i;
 
-	if (!client->irq) {
-		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
-		return -EINVAL;
-	}
-
 	rk808 = devm_kzalloc(&client->dev, sizeof(*rk808), GFP_KERNEL);
 	if (!rk808)
 		return -ENOMEM;
 
-	rk808->regmap = devm_regmap_init_i2c(client, &rk808_regmap_config);
+	ret = rk8xx_match_device(rk808, &client->dev);
+	if (ret)
+		return ret;
+
+	rk808->i2c = client;
+	i2c_set_clientdata(client, rk808);
+
+	rk808->regmap = devm_regmap_init_i2c(client, rk808->regmap_cfg);
 	if (IS_ERR(rk808->regmap)) {
 		dev_err(&client->dev, "regmap initialization failed\n");
 		return PTR_ERR(rk808->regmap);
 	}
 
-	for (i = 0; i < ARRAY_SIZE(pre_init_reg); i++) {
-		ret = regmap_update_bits(rk808->regmap, pre_init_reg[i].addr,
-					 pre_init_reg[i].mask,
-					 pre_init_reg[i].value);
-		if (ret) {
-			dev_err(&client->dev,
-				"0x%x write err\n", pre_init_reg[i].addr);
-			return ret;
-		}
+	if (!client->irq) {
+		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
+		return -EINVAL;
 	}
 
 	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
 				  IRQF_ONESHOT, -1,
-				  &rk808_irq_chip, &rk808->irq_data);
+				  rk808->regmap_irq_chip, &rk808->irq_data);
 	if (ret) {
 		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
 		return ret;
 	}
 
-	rk808->i2c = client;
-	i2c_set_clientdata(client, rk808);
+	for (i = 0; i < rk808->nr_pre_init_regs; i++) {
+		ret = regmap_update_bits(rk808->regmap,
+					rk808->pre_init_reg[i].addr,
+					rk808->pre_init_reg[i].mask,
+					rk808->pre_init_reg[i].value);
+		if (ret) {
+			dev_err(&client->dev,
+				"0x%x write err\n",
+				rk808->pre_init_reg[i].addr);
+			return ret;
+		}
+	}
 
 	ret = mfd_add_devices(&client->dev, -1,
-			      rk808s, ARRAY_SIZE(rk808s),
+			      rk808->cells, rk808->nr_cells,
 			      NULL, 0, regmap_irq_get_domain(rk808->irq_data));
 	if (ret) {
 		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
@@ -224,7 +406,7 @@ static int rk808_probe(struct i2c_client *client,
 	pm_off = of_property_read_bool(np,
 				"rockchip,system-power-controller");
 	if (pm_off && !pm_power_off) {
-		rk808_i2c_client = client;
+		rk8xx_i2c_client = client;
 		pm_power_off = rk808_device_shutdown;
 	}
 
@@ -235,7 +417,7 @@ err_irq:
 	return ret;
 }
 
-static int rk808_remove(struct i2c_client *client)
+static int rk8xx_remove(struct i2c_client *client)
 {
 	struct rk808 *rk808 = i2c_get_clientdata(client);
 
@@ -246,31 +428,26 @@ static int rk808_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct of_device_id rk808_of_match[] = {
-	{ .compatible = "rockchip,rk808" },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, rk808_of_match);
-
-static const struct i2c_device_id rk808_ids[] = {
+static const struct i2c_device_id rk8xx_ids[] = {
 	{ "rk808" },
+	{ "rk818" },
 	{ },
 };
-MODULE_DEVICE_TABLE(i2c, rk808_ids);
+MODULE_DEVICE_TABLE(i2c, rk8xx_ids);
 
-static struct i2c_driver rk808_i2c_driver = {
+static struct i2c_driver rk8xx_i2c_driver = {
 	.driver = {
-		.name = "rk808",
-		.of_match_table = rk808_of_match,
+		.name = "rk8xx",
+		.of_match_table = rk8xx_of_match,
 	},
-	.probe    = rk808_probe,
-	.remove   = rk808_remove,
-	.id_table = rk808_ids,
+	.probe    = rk8xx_probe,
+	.remove   = rk8xx_remove,
+	.id_table = rk8xx_ids,
 };
 
-module_i2c_driver(rk808_i2c_driver);
+module_i2c_driver(rk8xx_i2c_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
 MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");
-MODULE_DESCRIPTION("RK808 PMIC driver");
+MODULE_DESCRIPTION("RK8xx PMIC driver");
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 441b6ee..0858219 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -1,11 +1,14 @@
 /*
- * rk808.h for Rockchip RK808
+ * rk808.h for Rockchip RK8xx
  *
  * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
  *
  * Author: Chris Zhong <zyw@rock-chips.com>
  * Author: Zhang Qing <zhangqing@rock-chips.com>
  *
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov@phytec.de>
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -16,8 +19,8 @@
  * more details.
  */
 
-#ifndef __LINUX_REGULATOR_rk808_H
-#define __LINUX_REGULATOR_rk808_H
+#ifndef __LINUX_REGULATOR_rk8xx_H
+#define __LINUX_REGULATOR_rk8xx_H
 
 #include <linux/regulator/machine.h>
 #include <linux/regmap.h>
@@ -47,6 +50,28 @@ enum rk808_reg {
 	RK808_ID_SWITCH2,
 };
 
+#define RK818_NUM_REGULATORS	17
+
+enum rk818_reg {
+	RK818_ID_DCDC1,
+	RK818_ID_DCDC2,
+	RK818_ID_DCDC3,
+	RK818_ID_DCDC4,
+	RK818_ID_BOOST,
+	RK818_ID_LDO1,
+	RK818_ID_LDO2,
+	RK818_ID_LDO3,
+	RK818_ID_LDO4,
+	RK818_ID_LDO5,
+	RK818_ID_LDO6,
+	RK818_ID_LDO7,
+	RK818_ID_LDO8,
+	RK818_ID_LDO9,
+	RK818_ID_SWITCH,
+	RK818_ID_HDMI_SWITCH,
+	RK818_ID_OTG_SWITCH,
+};
+
 #define RK808_SECONDS_REG	0x00
 #define RK808_MINUTES_REG	0x01
 #define RK808_HOURS_REG		0x02
@@ -115,7 +140,92 @@ enum rk808_reg {
 #define RK808_INT_STS_MSK_REG2	0x4f
 #define RK808_IO_POL_REG	0x50
 
-/* IRQ Definitions */
+/* RK818 */
+#define RK818_DCDC1			0
+#define RK818_LDO1			4
+
+#define RK818_SECONDS_REG		0x00
+#define RK818_MINUTES_REG		0x01
+#define RK818_HOURS_REG			0x02
+#define RK818_DAYS_REG			0x03
+#define RK818_MONTHS_REG		0x04
+#define RK818_YEARS_REG			0x05
+#define RK818_WEEKS_REG			0x06
+#define RK818_ALARM_SECONDS_REG		0x07
+#define RK818_ALARM_MINUTES_REG		0x08
+#define RK818_ALARM_HOURS_REG		0x09
+#define RK818_ALARM_DAYS_REG		0x0a
+#define RK818_ALARM_MONTHS_REG		0x0b
+#define RK818_ALARM_YEARS_REG		0x0c
+#define RK818_RTC_CTRL_REG		0x10
+#define RK818_RTC_STATUS_REG		0x11
+#define RK818_RTC_INT_REG		0x12
+#define RK818_RTC_COMP_LSB_REG		0x13
+#define RK818_RTC_COMP_MSB_REG		0x14
+#define RK818_CLK32OUT_REG		0x20
+#define RK818_VB_MON_REG		0x21
+#define RK818_THERMAL_REG		0x22
+#define RK818_DCDC_EN_REG		0x23
+#define RK818_LDO_EN_REG		0x24
+#define RK818_SLEEP_SET_OFF_REG1	0x25
+#define RK818_SLEEP_SET_OFF_REG2	0x26
+#define RK818_DCDC_UV_STS_REG		0x27
+#define RK818_DCDC_UV_ACT_REG		0x28
+#define RK818_LDO_UV_STS_REG		0x29
+#define RK818_LDO_UV_ACT_REG		0x2a
+#define RK818_DCDC_PG_REG		0x2b
+#define RK818_LDO_PG_REG		0x2c
+#define RK818_VOUT_MON_TDB_REG		0x2d
+#define RK818_BUCK1_CONFIG_REG		0x2e
+#define RK818_BUCK1_ON_VSEL_REG		0x2f
+#define RK818_BUCK1_SLP_VSEL_REG	0x30
+#define RK818_BUCK2_CONFIG_REG		0x32
+#define RK818_BUCK2_ON_VSEL_REG		0x33
+#define RK818_BUCK2_SLP_VSEL_REG	0x34
+#define RK818_BUCK3_CONFIG_REG		0x36
+#define RK818_BUCK4_CONFIG_REG		0x37
+#define RK818_BUCK4_ON_VSEL_REG		0x38
+#define RK818_BUCK4_SLP_VSEL_REG	0x39
+#define RK818_BOOST_CONFIG_REG		0x3a
+#define RK818_LDO1_ON_VSEL_REG		0x3b
+#define RK818_LDO1_SLP_VSEL_REG		0x3c
+#define RK818_LDO2_ON_VSEL_REG		0x3d
+#define RK818_LDO2_SLP_VSEL_REG		0x3e
+#define RK818_LDO3_ON_VSEL_REG		0x3f
+#define RK818_LDO3_SLP_VSEL_REG		0x40
+#define RK818_LDO4_ON_VSEL_REG		0x41
+#define RK818_LDO4_SLP_VSEL_REG		0x42
+#define RK818_LDO5_ON_VSEL_REG		0x43
+#define RK818_LDO5_SLP_VSEL_REG		0x44
+#define RK818_LDO6_ON_VSEL_REG		0x45
+#define RK818_LDO6_SLP_VSEL_REG		0x46
+#define RK818_LDO7_ON_VSEL_REG		0x47
+#define RK818_LDO7_SLP_VSEL_REG		0x48
+#define RK818_LDO8_ON_VSEL_REG		0x49
+#define RK818_LDO8_SLP_VSEL_REG		0x4a
+#define RK818_BOOST_LDO9_ON_VSEL_REG	0x54
+#define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
+#define RK818_DEVCTRL_REG		0x4b
+#define RK818_INT_STS_REG1		0X4c
+#define RK818_INT_STS_MSK_REG1		0x4d
+#define RK818_INT_STS_REG2		0x4e
+#define RK818_INT_STS_MSK_REG2		0x4f
+#define RK818_IO_POL_REG		0x50
+#define RK818_H5V_EN_REG		0x52
+#define RK818_SLEEP_SET_OFF_REG3	0x53
+#define RK818_BOOST_LDO9_ON_VSEL_REG	0x54
+#define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
+#define RK818_BOOST_CTRL_REG		0x56
+#define RK818_DCDC_ILMAX		0x90
+#define RK818_USB_CTRL_REG		0xa1
+
+#define RK818_H5V_EN			BIT(0)
+#define RK818_REF_RDY_CTRL		BIT(1)
+#define RK818_USB_ILIM_SEL_MASK		0xf
+#define RK818_USB_ILMIN_2000MA		0x7
+#define RK818_USB_CHG_SD_VSEL_MASK	0x70
+
+/* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO	0
 #define RK808_IRQ_VB_LO		1
 #define RK808_IRQ_PWRON		2
@@ -137,6 +247,44 @@ enum rk808_reg {
 #define RK808_IRQ_PLUG_IN_INT_MSK	BIT(0)
 #define RK808_IRQ_PLUG_OUT_INT_MSK	BIT(1)
 
+/* RK818 IRQ Definitions */
+#define RK818_IRQ_VOUT_LO	0
+#define RK818_IRQ_VB_LO		1
+#define RK818_IRQ_PWRON		2
+#define RK818_IRQ_PWRON_LP	3
+#define RK818_IRQ_HOTDIE	4
+#define RK818_IRQ_RTC_ALARM	5
+#define RK818_IRQ_RTC_PERIOD	6
+#define RK818_IRQ_USB_OV	7
+#define RK818_IRQ_PLUG_IN	8
+#define RK818_IRQ_PLUG_OUT	9
+#define RK818_IRQ_CHG_OK	10
+#define RK818_IRQ_CHG_TE	11
+#define RK818_IRQ_CHG_TS1	12
+#define RK818_IRQ_TS2		13
+#define RK818_IRQ_CHG_CVTLIM	14
+#define RK818_IRQ_DISCHG_ILIM	7
+
+#define RK818_IRQ_VOUT_LO_MSK		BIT(0)
+#define RK818_IRQ_VB_LO_MSK		BIT(1)
+#define RK818_IRQ_PWRON_MSK		BIT(2)
+#define RK818_IRQ_PWRON_LP_MSK		BIT(3)
+#define RK818_IRQ_HOTDIE_MSK		BIT(4)
+#define RK818_IRQ_RTC_ALARM_MSK		BIT(5)
+#define RK818_IRQ_RTC_PERIOD_MSK	BIT(6)
+#define RK818_IRQ_USB_OV_MSK		BIT(7)
+#define RK818_IRQ_PLUG_IN_MSK		BIT(0)
+#define RK818_IRQ_PLUG_OUT_MSK		BIT(1)
+#define RK818_IRQ_CHG_OK_MSK		BIT(2)
+#define RK818_IRQ_CHG_TE_MSK		BIT(3)
+#define RK818_IRQ_CHG_TS1_MSK		BIT(4)
+#define RK818_IRQ_TS2_MSK		BIT(5)
+#define RK818_IRQ_CHG_CVTLIM_MSK	BIT(6)
+#define RK818_IRQ_DISCHG_ILIM_MSK	BIT(7)
+
+#define RK818_NUM_IRQ		16
+
+
 #define RK808_VBAT_LOW_2V8	0x00
 #define RK808_VBAT_LOW_2V9	0x01
 #define RK808_VBAT_LOW_3V0	0x02
@@ -191,9 +339,27 @@ enum {
 	BOOST_ILMIN_250MA,
 };
 
+enum {
+	RK808_ID = 0,
+	RK818_ID,
+};
+
+struct rk8xx_reg_data {
+	int addr;
+	int mask;
+	int value;
+};
+
 struct rk808 {
-	struct i2c_client *i2c;
-	struct regmap_irq_chip_data *irq_data;
-	struct regmap *regmap;
+	struct i2c_client		*i2c;
+	struct regmap_irq_chip_data	*irq_data;
+	struct regmap			*regmap;
+	long				variant;
+	int				nr_cells;
+	const struct mfd_cell		*cells;
+	const struct regmap_config	*regmap_cfg;
+	const struct regmap_irq_chip	*regmap_irq_chip;
+	const struct rk8xx_reg_data	*pre_init_reg;
+	int				nr_pre_init_regs;
 };
-#endif /* __LINUX_REGULATOR_rk808_H */
+#endif /* __LINUX_REGULATOR_rk8xx_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC 1/3] mfd: RK808: Add RK818 support
@ 2016-04-08  9:47   ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: mark.rutland-5wv7dgnIgG8, pawel.moll-5wv7dgnIgG8,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, zyw-TNX95d0MmH7DzftRWevZcw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A

The RK818 chip is a power management IC for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clkout
- battery support

Both chips RK808 and RK818 are using a similar register map.
So we can reuse the RTC and Clkout functionality.

Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
---
 drivers/mfd/Kconfig       |   6 +-
 drivers/mfd/rk808.c       | 279 +++++++++++++++++++++++++++++++++++++---------
 include/linux/mfd/rk808.h | 182 ++++++++++++++++++++++++++++--
 3 files changed, 405 insertions(+), 62 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index eea61e3..7cbbfa4 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -813,14 +813,14 @@ config MFD_RC5T583
 	  Additional drivers must be enabled in order to use the
 	  different functionality of the device.
 
-config MFD_RK808
-	tristate "Rockchip RK808 Power Management chip"
+config MFD_RK8XX
+	tristate "Rockchip RK8xx Power Management chip"
 	depends on I2C && OF
 	select MFD_CORE
 	select REGMAP_I2C
 	select REGMAP_IRQ
 	help
-	  If you say yes here you get support for the RK808
+	  If you say yes here you get support for the RK808 and RK818
 	  Power Management chips.
 	  This driver provides common support for accessing the device
 	  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 4b1e439..d3fd8ef 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -1,11 +1,14 @@
 /*
- * MFD core driver for Rockchip RK808
+ * MFD core driver for Rockchip RK8xx
  *
  * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
  *
  * Author: Chris Zhong <zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  * Author: Zhang Qing <zhangqing-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  *
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -22,14 +25,14 @@
 #include <linux/mfd/core.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/of_device.h>
 
-struct rk808_reg_data {
-	int addr;
-	int mask;
-	int value;
+static const char * const rk8xx_model_names[] = {
+	"RK808",
+	"RK818",
 };
 
-static bool rk808_is_volatile_reg(struct device *dev, unsigned int reg)
+static bool rk8xx_is_volatile_reg(struct device *dev, unsigned int reg)
 {
 	/*
 	 * Notes:
@@ -62,7 +65,15 @@ static const struct regmap_config rk808_regmap_config = {
 	.val_bits = 8,
 	.max_register = RK808_IO_POL_REG,
 	.cache_type = REGCACHE_RBTREE,
-	.volatile_reg = rk808_is_volatile_reg,
+	.volatile_reg = rk8xx_is_volatile_reg,
+};
+
+static const struct regmap_config rk818_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = RK818_USB_CTRL_REG,
+	.cache_type = REGCACHE_RBTREE,
+	.volatile_reg = rk8xx_is_volatile_reg,
 };
 
 static struct resource rtc_resources[] = {
@@ -83,7 +94,17 @@ static const struct mfd_cell rk808s[] = {
 	},
 };
 
-static const struct rk808_reg_data pre_init_reg[] = {
+static const struct mfd_cell rk818s[] = {
+	{ .name = "rk808-clkout", },
+	{ .name = "rk808-regulator", },
+	{
+		.name = "rk808-rtc",
+		.num_resources = ARRAY_SIZE(rtc_resources),
+		.resources = &rtc_resources[0],
+	},
+};
+
+static const struct rk8xx_reg_data rk808_pre_init_reg[] = {
 	{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
 	{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
 	{ RK808_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA },
@@ -94,6 +115,27 @@ static const struct rk808_reg_data pre_init_reg[] = {
 						    VB_LO_SEL_3500MV },
 };
 
+static const struct rk8xx_reg_data rk818_pre_init_reg[] = {
+	{ RK818_USB_CTRL_REG,	RK818_USB_ILIM_SEL_MASK,
+						RK818_USB_ILMIN_2000MA },
+	/* close charger when usb lower then 3.4V */
+	{ RK818_USB_CTRL_REG,	RK818_USB_CHG_SD_VSEL_MASK, (0x7 << 4) },
+	/* no action when vref */
+	{ RK818_H5V_EN_REG,	(0x1 << 1),	RK818_REF_RDY_CTRL },
+
+	/* enable HDMI 5V */
+	{ RK818_H5V_EN_REG,	(0x1 << 0),	RK818_H5V_EN },
+
+	/* improve efficiency */
+	{ RK818_BUCK2_CONFIG_REG, BUCK2_RATE_MASK,  BUCK_ILMIN_250MA },
+	{ RK818_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_250MA },
+
+	{ RK818_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA },
+
+	{ RK808_VB_MON_REG,       MASK_ALL,         VB_LO_ACT |
+						    VB_LO_SEL_3500MV },
+};
+
 static const struct regmap_irq rk808_irqs[] = {
 	/* INT_STS */
 	[RK808_IRQ_VOUT_LO] = {
@@ -136,6 +178,81 @@ static const struct regmap_irq rk808_irqs[] = {
 	},
 };
 
+static const struct regmap_irq rk818_irqs[] = {
+	/* INT_STS */
+	[RK818_IRQ_VOUT_LO] = {
+		.mask = RK818_IRQ_VOUT_LO_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_VB_LO] = {
+		.mask = RK818_IRQ_VB_LO_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_PWRON] = {
+		.mask = RK818_IRQ_PWRON_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_PWRON_LP] = {
+		.mask = RK818_IRQ_PWRON_LP_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_HOTDIE] = {
+		.mask = RK818_IRQ_HOTDIE_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_RTC_ALARM] = {
+		.mask = RK818_IRQ_RTC_ALARM_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_RTC_PERIOD] = {
+		.mask = RK818_IRQ_RTC_PERIOD_MSK,
+		.reg_offset = 0,
+	},
+	[RK818_IRQ_USB_OV] = {
+		.mask = RK818_IRQ_USB_OV_MSK,
+		.reg_offset = 0,
+	},
+
+	/* INT_STS2 */
+	[RK818_IRQ_PLUG_IN] = {
+		.mask = RK818_IRQ_PLUG_IN_MSK,
+		.reg_offset = 1,
+	},
+	[RK818_IRQ_PLUG_OUT] = {
+		.mask = RK818_IRQ_PLUG_OUT_MSK,
+		.reg_offset = 1,
+	},
+	[RK818_IRQ_CHG_OK] = {
+		.mask = RK818_IRQ_CHG_OK_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_CHG_TE] = {
+		.mask = RK818_IRQ_CHG_TE_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_CHG_TS1] = {
+		.mask = RK818_IRQ_CHG_TS1_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_TS2] = {
+		.mask = RK818_IRQ_TS2_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_CHG_CVTLIM] = {
+		.mask = RK818_IRQ_CHG_CVTLIM_MSK,
+		.reg_offset = 1,
+	},
+
+	[RK818_IRQ_DISCHG_ILIM] = {
+		.mask = RK818_IRQ_DISCHG_ILIM_MSK,
+		.reg_offset = 1,
+	},
+};
+
 static struct regmap_irq_chip rk808_irq_chip = {
 	.name = "rk808",
 	.irqs = rk808_irqs,
@@ -148,15 +265,27 @@ static struct regmap_irq_chip rk808_irq_chip = {
 	.init_ack_masked = true,
 };
 
-static struct i2c_client *rk808_i2c_client;
+static struct regmap_irq_chip rk818_irq_chip = {
+	.name = "rk818",
+	.irqs = rk818_irqs,
+	.num_irqs = ARRAY_SIZE(rk808_irqs),
+	.num_regs = 2,
+	.irq_reg_stride = 2,
+	.status_base = RK808_INT_STS_REG1,
+	.mask_base = RK808_INT_STS_MSK_REG1,
+	.ack_base = RK808_INT_STS_REG1,
+	.init_ack_masked = true,
+};
+
+static struct i2c_client *rk8xx_i2c_client;
 static void rk808_device_shutdown(void)
 {
 	int ret;
-	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+	struct rk808 *rk808 = i2c_get_clientdata(rk8xx_i2c_client);
 
 	if (!rk808) {
-		dev_warn(&rk808_i2c_client->dev,
-			 "have no rk808, so do nothing here\n");
+		dev_warn(&rk8xx_i2c_client->dev,
+			 "have no rk8xx, so do nothing here\n");
 		return;
 	}
 
@@ -164,10 +293,57 @@ static void rk808_device_shutdown(void)
 				 RK808_DEVCTRL_REG,
 				 DEV_OFF_RST, DEV_OFF_RST);
 	if (ret)
-		dev_err(&rk808_i2c_client->dev, "power off error!\n");
+		dev_err(&rk8xx_i2c_client->dev, "power off error!\n");
+}
+
+static const struct of_device_id rk8xx_of_match[] = {
+	{ .compatible = "rockchip,rk808", .data = (void *) RK808_ID },
+	{ .compatible = "rockchip,rk818", .data = (void *) RK818_ID },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rk8xx_of_match);
+
+static int rk8xx_match_device(struct rk808 *rk808, struct device *dev)
+{
+	const struct of_device_id *of_id;
+
+	if (dev->of_node) {
+		of_id = of_match_device(rk8xx_of_match, dev);
+		if (!of_id) {
+			dev_err(dev, "Unable to match OF ID\n");
+			return -ENODEV;
+		}
+		rk808->variant = (long) of_id->data;
+	}
+
+	switch (rk808->variant) {
+	case RK808_ID:
+		rk808->nr_cells = ARRAY_SIZE(rk808s);
+		rk808->cells = rk808s;
+		rk808->regmap_cfg = &rk808_regmap_config;
+		rk808->regmap_irq_chip = &rk808_irq_chip;
+		rk808->pre_init_reg = rk808_pre_init_reg;
+		rk808->nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
+		break;
+	case RK818_ID:
+		rk808->nr_cells = ARRAY_SIZE(rk818s);
+		rk808->cells = rk818s;
+		rk808->regmap_cfg = &rk818_regmap_config;
+		rk808->regmap_irq_chip = &rk818_irq_chip;
+		rk808->pre_init_reg = rk818_pre_init_reg;
+		rk808->nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
+		break;
+	default:
+		dev_err(dev, "unsupported RK8XX ID %lu\n", rk808->variant);
+		return -EINVAL;
+	}
+	dev_info(dev, "RK8XX variant %s found\n",
+		rk8xx_model_names[rk808->variant]);
+
+	return 0;
 }
 
-static int rk808_probe(struct i2c_client *client,
+static int rk8xx_probe(struct i2c_client *client,
 		       const struct i2c_device_id *id)
 {
 	struct device_node *np = client->dev.of_node;
@@ -176,45 +352,51 @@ static int rk808_probe(struct i2c_client *client,
 	int ret;
 	int i;
 
-	if (!client->irq) {
-		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
-		return -EINVAL;
-	}
-
 	rk808 = devm_kzalloc(&client->dev, sizeof(*rk808), GFP_KERNEL);
 	if (!rk808)
 		return -ENOMEM;
 
-	rk808->regmap = devm_regmap_init_i2c(client, &rk808_regmap_config);
+	ret = rk8xx_match_device(rk808, &client->dev);
+	if (ret)
+		return ret;
+
+	rk808->i2c = client;
+	i2c_set_clientdata(client, rk808);
+
+	rk808->regmap = devm_regmap_init_i2c(client, rk808->regmap_cfg);
 	if (IS_ERR(rk808->regmap)) {
 		dev_err(&client->dev, "regmap initialization failed\n");
 		return PTR_ERR(rk808->regmap);
 	}
 
-	for (i = 0; i < ARRAY_SIZE(pre_init_reg); i++) {
-		ret = regmap_update_bits(rk808->regmap, pre_init_reg[i].addr,
-					 pre_init_reg[i].mask,
-					 pre_init_reg[i].value);
-		if (ret) {
-			dev_err(&client->dev,
-				"0x%x write err\n", pre_init_reg[i].addr);
-			return ret;
-		}
+	if (!client->irq) {
+		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
+		return -EINVAL;
 	}
 
 	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
 				  IRQF_ONESHOT, -1,
-				  &rk808_irq_chip, &rk808->irq_data);
+				  rk808->regmap_irq_chip, &rk808->irq_data);
 	if (ret) {
 		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
 		return ret;
 	}
 
-	rk808->i2c = client;
-	i2c_set_clientdata(client, rk808);
+	for (i = 0; i < rk808->nr_pre_init_regs; i++) {
+		ret = regmap_update_bits(rk808->regmap,
+					rk808->pre_init_reg[i].addr,
+					rk808->pre_init_reg[i].mask,
+					rk808->pre_init_reg[i].value);
+		if (ret) {
+			dev_err(&client->dev,
+				"0x%x write err\n",
+				rk808->pre_init_reg[i].addr);
+			return ret;
+		}
+	}
 
 	ret = mfd_add_devices(&client->dev, -1,
-			      rk808s, ARRAY_SIZE(rk808s),
+			      rk808->cells, rk808->nr_cells,
 			      NULL, 0, regmap_irq_get_domain(rk808->irq_data));
 	if (ret) {
 		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
@@ -224,7 +406,7 @@ static int rk808_probe(struct i2c_client *client,
 	pm_off = of_property_read_bool(np,
 				"rockchip,system-power-controller");
 	if (pm_off && !pm_power_off) {
-		rk808_i2c_client = client;
+		rk8xx_i2c_client = client;
 		pm_power_off = rk808_device_shutdown;
 	}
 
@@ -235,7 +417,7 @@ err_irq:
 	return ret;
 }
 
-static int rk808_remove(struct i2c_client *client)
+static int rk8xx_remove(struct i2c_client *client)
 {
 	struct rk808 *rk808 = i2c_get_clientdata(client);
 
@@ -246,31 +428,26 @@ static int rk808_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct of_device_id rk808_of_match[] = {
-	{ .compatible = "rockchip,rk808" },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, rk808_of_match);
-
-static const struct i2c_device_id rk808_ids[] = {
+static const struct i2c_device_id rk8xx_ids[] = {
 	{ "rk808" },
+	{ "rk818" },
 	{ },
 };
-MODULE_DEVICE_TABLE(i2c, rk808_ids);
+MODULE_DEVICE_TABLE(i2c, rk8xx_ids);
 
-static struct i2c_driver rk808_i2c_driver = {
+static struct i2c_driver rk8xx_i2c_driver = {
 	.driver = {
-		.name = "rk808",
-		.of_match_table = rk808_of_match,
+		.name = "rk8xx",
+		.of_match_table = rk8xx_of_match,
 	},
-	.probe    = rk808_probe,
-	.remove   = rk808_remove,
-	.id_table = rk808_ids,
+	.probe    = rk8xx_probe,
+	.remove   = rk8xx_remove,
+	.id_table = rk8xx_ids,
 };
 
-module_i2c_driver(rk808_i2c_driver);
+module_i2c_driver(rk8xx_i2c_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Chris Zhong <zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org>");
 MODULE_AUTHOR("Zhang Qing <zhangqing-TNX95d0MmH7DzftRWevZcw@public.gmane.org>");
-MODULE_DESCRIPTION("RK808 PMIC driver");
+MODULE_DESCRIPTION("RK8xx PMIC driver");
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 441b6ee..0858219 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -1,11 +1,14 @@
 /*
- * rk808.h for Rockchip RK808
+ * rk808.h for Rockchip RK8xx
  *
  * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
  *
  * Author: Chris Zhong <zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  * Author: Zhang Qing <zhangqing-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  *
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -16,8 +19,8 @@
  * more details.
  */
 
-#ifndef __LINUX_REGULATOR_rk808_H
-#define __LINUX_REGULATOR_rk808_H
+#ifndef __LINUX_REGULATOR_rk8xx_H
+#define __LINUX_REGULATOR_rk8xx_H
 
 #include <linux/regulator/machine.h>
 #include <linux/regmap.h>
@@ -47,6 +50,28 @@ enum rk808_reg {
 	RK808_ID_SWITCH2,
 };
 
+#define RK818_NUM_REGULATORS	17
+
+enum rk818_reg {
+	RK818_ID_DCDC1,
+	RK818_ID_DCDC2,
+	RK818_ID_DCDC3,
+	RK818_ID_DCDC4,
+	RK818_ID_BOOST,
+	RK818_ID_LDO1,
+	RK818_ID_LDO2,
+	RK818_ID_LDO3,
+	RK818_ID_LDO4,
+	RK818_ID_LDO5,
+	RK818_ID_LDO6,
+	RK818_ID_LDO7,
+	RK818_ID_LDO8,
+	RK818_ID_LDO9,
+	RK818_ID_SWITCH,
+	RK818_ID_HDMI_SWITCH,
+	RK818_ID_OTG_SWITCH,
+};
+
 #define RK808_SECONDS_REG	0x00
 #define RK808_MINUTES_REG	0x01
 #define RK808_HOURS_REG		0x02
@@ -115,7 +140,92 @@ enum rk808_reg {
 #define RK808_INT_STS_MSK_REG2	0x4f
 #define RK808_IO_POL_REG	0x50
 
-/* IRQ Definitions */
+/* RK818 */
+#define RK818_DCDC1			0
+#define RK818_LDO1			4
+
+#define RK818_SECONDS_REG		0x00
+#define RK818_MINUTES_REG		0x01
+#define RK818_HOURS_REG			0x02
+#define RK818_DAYS_REG			0x03
+#define RK818_MONTHS_REG		0x04
+#define RK818_YEARS_REG			0x05
+#define RK818_WEEKS_REG			0x06
+#define RK818_ALARM_SECONDS_REG		0x07
+#define RK818_ALARM_MINUTES_REG		0x08
+#define RK818_ALARM_HOURS_REG		0x09
+#define RK818_ALARM_DAYS_REG		0x0a
+#define RK818_ALARM_MONTHS_REG		0x0b
+#define RK818_ALARM_YEARS_REG		0x0c
+#define RK818_RTC_CTRL_REG		0x10
+#define RK818_RTC_STATUS_REG		0x11
+#define RK818_RTC_INT_REG		0x12
+#define RK818_RTC_COMP_LSB_REG		0x13
+#define RK818_RTC_COMP_MSB_REG		0x14
+#define RK818_CLK32OUT_REG		0x20
+#define RK818_VB_MON_REG		0x21
+#define RK818_THERMAL_REG		0x22
+#define RK818_DCDC_EN_REG		0x23
+#define RK818_LDO_EN_REG		0x24
+#define RK818_SLEEP_SET_OFF_REG1	0x25
+#define RK818_SLEEP_SET_OFF_REG2	0x26
+#define RK818_DCDC_UV_STS_REG		0x27
+#define RK818_DCDC_UV_ACT_REG		0x28
+#define RK818_LDO_UV_STS_REG		0x29
+#define RK818_LDO_UV_ACT_REG		0x2a
+#define RK818_DCDC_PG_REG		0x2b
+#define RK818_LDO_PG_REG		0x2c
+#define RK818_VOUT_MON_TDB_REG		0x2d
+#define RK818_BUCK1_CONFIG_REG		0x2e
+#define RK818_BUCK1_ON_VSEL_REG		0x2f
+#define RK818_BUCK1_SLP_VSEL_REG	0x30
+#define RK818_BUCK2_CONFIG_REG		0x32
+#define RK818_BUCK2_ON_VSEL_REG		0x33
+#define RK818_BUCK2_SLP_VSEL_REG	0x34
+#define RK818_BUCK3_CONFIG_REG		0x36
+#define RK818_BUCK4_CONFIG_REG		0x37
+#define RK818_BUCK4_ON_VSEL_REG		0x38
+#define RK818_BUCK4_SLP_VSEL_REG	0x39
+#define RK818_BOOST_CONFIG_REG		0x3a
+#define RK818_LDO1_ON_VSEL_REG		0x3b
+#define RK818_LDO1_SLP_VSEL_REG		0x3c
+#define RK818_LDO2_ON_VSEL_REG		0x3d
+#define RK818_LDO2_SLP_VSEL_REG		0x3e
+#define RK818_LDO3_ON_VSEL_REG		0x3f
+#define RK818_LDO3_SLP_VSEL_REG		0x40
+#define RK818_LDO4_ON_VSEL_REG		0x41
+#define RK818_LDO4_SLP_VSEL_REG		0x42
+#define RK818_LDO5_ON_VSEL_REG		0x43
+#define RK818_LDO5_SLP_VSEL_REG		0x44
+#define RK818_LDO6_ON_VSEL_REG		0x45
+#define RK818_LDO6_SLP_VSEL_REG		0x46
+#define RK818_LDO7_ON_VSEL_REG		0x47
+#define RK818_LDO7_SLP_VSEL_REG		0x48
+#define RK818_LDO8_ON_VSEL_REG		0x49
+#define RK818_LDO8_SLP_VSEL_REG		0x4a
+#define RK818_BOOST_LDO9_ON_VSEL_REG	0x54
+#define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
+#define RK818_DEVCTRL_REG		0x4b
+#define RK818_INT_STS_REG1		0X4c
+#define RK818_INT_STS_MSK_REG1		0x4d
+#define RK818_INT_STS_REG2		0x4e
+#define RK818_INT_STS_MSK_REG2		0x4f
+#define RK818_IO_POL_REG		0x50
+#define RK818_H5V_EN_REG		0x52
+#define RK818_SLEEP_SET_OFF_REG3	0x53
+#define RK818_BOOST_LDO9_ON_VSEL_REG	0x54
+#define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
+#define RK818_BOOST_CTRL_REG		0x56
+#define RK818_DCDC_ILMAX		0x90
+#define RK818_USB_CTRL_REG		0xa1
+
+#define RK818_H5V_EN			BIT(0)
+#define RK818_REF_RDY_CTRL		BIT(1)
+#define RK818_USB_ILIM_SEL_MASK		0xf
+#define RK818_USB_ILMIN_2000MA		0x7
+#define RK818_USB_CHG_SD_VSEL_MASK	0x70
+
+/* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO	0
 #define RK808_IRQ_VB_LO		1
 #define RK808_IRQ_PWRON		2
@@ -137,6 +247,44 @@ enum rk808_reg {
 #define RK808_IRQ_PLUG_IN_INT_MSK	BIT(0)
 #define RK808_IRQ_PLUG_OUT_INT_MSK	BIT(1)
 
+/* RK818 IRQ Definitions */
+#define RK818_IRQ_VOUT_LO	0
+#define RK818_IRQ_VB_LO		1
+#define RK818_IRQ_PWRON		2
+#define RK818_IRQ_PWRON_LP	3
+#define RK818_IRQ_HOTDIE	4
+#define RK818_IRQ_RTC_ALARM	5
+#define RK818_IRQ_RTC_PERIOD	6
+#define RK818_IRQ_USB_OV	7
+#define RK818_IRQ_PLUG_IN	8
+#define RK818_IRQ_PLUG_OUT	9
+#define RK818_IRQ_CHG_OK	10
+#define RK818_IRQ_CHG_TE	11
+#define RK818_IRQ_CHG_TS1	12
+#define RK818_IRQ_TS2		13
+#define RK818_IRQ_CHG_CVTLIM	14
+#define RK818_IRQ_DISCHG_ILIM	7
+
+#define RK818_IRQ_VOUT_LO_MSK		BIT(0)
+#define RK818_IRQ_VB_LO_MSK		BIT(1)
+#define RK818_IRQ_PWRON_MSK		BIT(2)
+#define RK818_IRQ_PWRON_LP_MSK		BIT(3)
+#define RK818_IRQ_HOTDIE_MSK		BIT(4)
+#define RK818_IRQ_RTC_ALARM_MSK		BIT(5)
+#define RK818_IRQ_RTC_PERIOD_MSK	BIT(6)
+#define RK818_IRQ_USB_OV_MSK		BIT(7)
+#define RK818_IRQ_PLUG_IN_MSK		BIT(0)
+#define RK818_IRQ_PLUG_OUT_MSK		BIT(1)
+#define RK818_IRQ_CHG_OK_MSK		BIT(2)
+#define RK818_IRQ_CHG_TE_MSK		BIT(3)
+#define RK818_IRQ_CHG_TS1_MSK		BIT(4)
+#define RK818_IRQ_TS2_MSK		BIT(5)
+#define RK818_IRQ_CHG_CVTLIM_MSK	BIT(6)
+#define RK818_IRQ_DISCHG_ILIM_MSK	BIT(7)
+
+#define RK818_NUM_IRQ		16
+
+
 #define RK808_VBAT_LOW_2V8	0x00
 #define RK808_VBAT_LOW_2V9	0x01
 #define RK808_VBAT_LOW_3V0	0x02
@@ -191,9 +339,27 @@ enum {
 	BOOST_ILMIN_250MA,
 };
 
+enum {
+	RK808_ID = 0,
+	RK818_ID,
+};
+
+struct rk8xx_reg_data {
+	int addr;
+	int mask;
+	int value;
+};
+
 struct rk808 {
-	struct i2c_client *i2c;
-	struct regmap_irq_chip_data *irq_data;
-	struct regmap *regmap;
+	struct i2c_client		*i2c;
+	struct regmap_irq_chip_data	*irq_data;
+	struct regmap			*regmap;
+	long				variant;
+	int				nr_cells;
+	const struct mfd_cell		*cells;
+	const struct regmap_config	*regmap_cfg;
+	const struct regmap_irq_chip	*regmap_irq_chip;
+	const struct rk8xx_reg_data	*pre_init_reg;
+	int				nr_pre_init_regs;
 };
-#endif /* __LINUX_REGULATOR_rk808_H */
+#endif /* __LINUX_REGULATOR_rk8xx_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC 2/3] regulator: rk808: Add support for rk818
@ 2016-04-08  9:47   ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel, linux-rockchip, devicetree
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	lee.jones, lgirdwood, broonie, dianders, zyw

Add support for the rk818 regulator. The regulator module consists
of 4 DCDCs, 9 LDOs, 1 switch and 1 BOOST converter which is used to
power OTG and HDMI5V.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
 drivers/regulator/rk808-regulator.c | 343 +++++++++++++++++++++++++++++++++---
 1 file changed, 322 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index d86a3dc..b2bbca7 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -6,6 +6,9 @@
  * Author: Chris Zhong <zyw@rock-chips.com>
  * Author: Zhang Qing <zhangqing@rock-chips.com>
  *
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov@phytec.de>
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -32,6 +35,12 @@
 #define RK808_BUCK4_VSEL_MASK	0xf
 #define RK808_LDO_VSEL_MASK	0x1f
 
+#define RK818_BUCK_VSEL_MASK		0x3f
+#define RK818_BUCK4_VSEL_MASK		0x1f
+#define RK818_LDO_VSEL_MASK		0x1f
+#define RK818_LDO3_ON_VSEL_MASK		0xf
+#define RK818_BOOST_ON_VSEL_MASK	0xe0
+
 /* Ramp rate definitions for buck1 / buck2 only */
 #define RK808_RAMP_RATE_OFFSET		3
 #define RK808_RAMP_RATE_MASK		(3 << RK808_RAMP_RATE_OFFSET)
@@ -87,6 +96,15 @@ static const struct regulator_linear_range rk808_ldo6_voltage_ranges[] = {
 	REGULATOR_LINEAR_RANGE(800000, 0, 17, 100000),
 };
 
+static const struct regulator_linear_range rk818_buck4_voltage_ranges[] = {
+	REGULATOR_LINEAR_RANGE(1800000, 0, 18, 100000),
+};
+
+static const struct regulator_linear_range rk818_boost_voltage_ranges[] = {
+	REGULATOR_LINEAR_RANGE(4700000, 0, 7, 100000),
+};
+
+
 static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev)
 {
 	struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
@@ -506,6 +524,238 @@ static const struct regulator_desc rk808_reg[] = {
 	},
 };
 
+static const struct regulator_desc rk818_reg[] = {
+	{
+		.name = "DCDC_REG1",
+		.supply_name = "vcc1",
+		.id = RK818_ID_DCDC1,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 64,
+		.linear_ranges = rk808_buck_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_buck_voltage_ranges),
+		.vsel_reg = RK818_BUCK1_ON_VSEL_REG,
+		.vsel_mask = RK818_BUCK_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(0),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG2",
+		.supply_name = "vcc2",
+		.id = RK818_ID_DCDC2,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 64,
+		.linear_ranges = rk808_buck_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_buck_voltage_ranges),
+		.vsel_reg = RK818_BUCK2_ON_VSEL_REG,
+		.vsel_mask = RK818_BUCK_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(1),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG3",
+		.supply_name = "vcc3",
+		.id = RK818_ID_DCDC3,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 1,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(2),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG4",
+		.supply_name = "vcc4",
+		.id = RK818_ID_DCDC4,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 19,
+		.linear_ranges = rk818_buck4_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk818_buck4_voltage_ranges),
+		.vsel_reg = RK818_BUCK4_ON_VSEL_REG,
+		.vsel_mask = RK818_BUCK4_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(3),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_BOOST",
+		.supply_name = "boost",
+		.id = RK818_ID_BOOST,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 8,
+		.linear_ranges = rk818_boost_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk818_boost_voltage_ranges),
+		.vsel_reg = RK818_BOOST_LDO9_ON_VSEL_REG,
+		.vsel_mask = RK818_BOOST_ON_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(4),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG1",
+		.supply_name = "vcc6",
+		.id = RK818_ID_LDO1,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO1_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(0),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG2",
+		.supply_name = "vcc6",
+		.id = RK818_ID_LDO2,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO2_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(1),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG3",
+		.supply_name = "vcc7",
+		.id = RK818_ID_LDO3,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 16,
+		.linear_ranges = rk808_ldo3_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges),
+		.vsel_reg = RK818_LDO3_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO3_ON_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(2),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG4",
+		.supply_name = "vcc8",
+		.id = RK818_ID_LDO4,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO4_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(3),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG5",
+		.supply_name = "vcc7",
+		.id = RK818_ID_LDO5,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO5_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(4),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG6",
+		.supply_name = "vcc8",
+		.id = RK818_ID_LDO6,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 18,
+		.linear_ranges = rk808_ldo6_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo6_voltage_ranges),
+		.vsel_reg = RK818_LDO6_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(5),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG7",
+		.supply_name = "vcc7",
+		.id = RK818_ID_LDO7,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 18,
+		.linear_ranges = rk808_ldo6_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo6_voltage_ranges),
+		.vsel_reg = RK818_LDO7_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(6),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG8",
+		.supply_name = "vcc8",
+		.id = RK818_ID_LDO8,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO8_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(7),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG9",
+		.supply_name = "vcc9",
+		.id = RK818_ID_LDO9,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_BOOST_LDO9_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(5),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "SWITCH_REG",
+		.supply_name = "vcc9",
+		.id = RK818_ID_SWITCH,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(6),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "HDMI_SWITCH",
+		.supply_name = "h_5v",
+		.id = RK818_ID_HDMI_SWITCH,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.enable_reg = RK818_H5V_EN_REG,
+		.enable_mask = BIT(0),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "OTG_SWITCH",
+		.supply_name = "usb",
+		.id = RK818_ID_OTG_SWITCH,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(7),
+		.owner = THIS_MODULE,
+	},
+};
+
 static struct of_regulator_match rk808_reg_matches[] = {
 	[RK808_ID_DCDC1]	= { .name = "DCDC_REG1" },
 	[RK808_ID_DCDC2]	= { .name = "DCDC_REG2" },
@@ -523,11 +773,32 @@ static struct of_regulator_match rk808_reg_matches[] = {
 	[RK808_ID_SWITCH2]	= { .name = "SWITCH_REG2" },
 };
 
+static struct of_regulator_match rk818_reg_matches[] = {
+	[RK818_ID_DCDC1]	= { .name = "DCDC_REG1" },
+	[RK818_ID_DCDC2]	= { .name = "DCDC_REG2" },
+	[RK818_ID_DCDC3]	= { .name = "DCDC_REG3" },
+	[RK818_ID_DCDC4]	= { .name = "DCDC_REG4" },
+	[RK818_ID_BOOST]	= { .name = "DCDC_BOOST" },
+	[RK818_ID_LDO1]		= { .name = "LDO_REG1" },
+	[RK818_ID_LDO2]		= { .name = "LDO_REG2" },
+	[RK818_ID_LDO3]		= { .name = "LDO_REG3" },
+	[RK818_ID_LDO4]		= { .name = "LDO_REG4" },
+	[RK818_ID_LDO5]		= { .name = "LDO_REG5" },
+	[RK818_ID_LDO6]		= { .name = "LDO_REG6" },
+	[RK818_ID_LDO7]		= { .name = "LDO_REG7" },
+	[RK818_ID_LDO8]		= { .name = "LDO_REG8" },
+	[RK818_ID_LDO9]		= { .name = "LDO_REG9" },
+	[RK818_ID_SWITCH]	= { .name = "SWITCH_REG" },
+	[RK818_ID_HDMI_SWITCH]	= { .name = "HDMI_SWITCH" },
+	[RK818_ID_OTG_SWITCH]	= { .name = "OTG_SWITCH" },
+};
+
 static int rk808_regulator_dt_parse_pdata(struct device *dev,
 				   struct device *client_dev,
 				   struct regmap *map,
 				   struct rk808_regulator_data *pdata)
 {
+	struct rk808 *rk808 = dev_get_drvdata(dev->parent);
 	struct device_node *np;
 	int tmp, ret, i;
 
@@ -535,8 +806,12 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
 	if (!np)
 		return -ENXIO;
 
-	ret = of_regulator_match(dev, np, rk808_reg_matches,
-				 RK808_NUM_REGULATORS);
+	if (rk808->variant == RK808_ID)
+		ret = of_regulator_match(dev, np, rk808_reg_matches,
+					 RK808_NUM_REGULATORS);
+	else if (rk808->variant == RK818_ID)
+		ret = of_regulator_match(dev, np, rk818_reg_matches,
+					RK818_NUM_REGULATORS);
 	if (ret < 0)
 		goto dt_parse_end;
 
@@ -586,27 +861,53 @@ static int rk808_regulator_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pdata);
 
-	/* Instantiate the regulators */
-	for (i = 0; i < RK808_NUM_REGULATORS; i++) {
-		if (!rk808_reg_matches[i].init_data ||
-		    !rk808_reg_matches[i].of_node)
-			continue;
-
-		config.dev = &client->dev;
-		config.driver_data = pdata;
-		config.regmap = rk808->regmap;
-		config.of_node = rk808_reg_matches[i].of_node;
-		config.init_data = rk808_reg_matches[i].init_data;
-
-		rk808_rdev = devm_regulator_register(&pdev->dev,
-						     &rk808_reg[i], &config);
-		if (IS_ERR(rk808_rdev)) {
-			dev_err(&client->dev,
-				"failed to register %d regulator\n", i);
-			return PTR_ERR(rk808_rdev);
+	if (rk808->variant == RK818_ID) {
+		/* Instantiate the regulators */
+		for (i = 0; i < RK818_NUM_REGULATORS; i++) {
+			if (!rk818_reg_matches[i].init_data ||
+			    !rk818_reg_matches[i].of_node)
+				continue;
+
+			config.dev = &client->dev;
+			config.driver_data = pdata;
+			config.regmap = rk808->regmap;
+			config.of_node = rk818_reg_matches[i].of_node;
+			config.init_data = rk818_reg_matches[i].init_data;
+
+			rk808_rdev = devm_regulator_register(&pdev->dev,
+					&rk818_reg[i], &config);
+			if (IS_ERR(rk808_rdev)) {
+				dev_err(&client->dev,
+					"failed to register %d regulator\n", i);
+				return PTR_ERR(rk808_rdev);
+			}
+		}
+	} else if (rk808->variant == RK808_ID) {
+		/* Instantiate the regulators */
+		for (i = 0; i < RK808_NUM_REGULATORS; i++) {
+			if (!rk808_reg_matches[i].init_data ||
+			    !rk808_reg_matches[i].of_node)
+				continue;
+
+			config.dev = &client->dev;
+			config.driver_data = pdata;
+			config.regmap = rk808->regmap;
+			config.of_node = rk808_reg_matches[i].of_node;
+			config.init_data = rk808_reg_matches[i].init_data;
+
+			rk808_rdev = devm_regulator_register(&pdev->dev,
+					&rk808_reg[i], &config);
+			if (IS_ERR(rk808_rdev)) {
+				dev_err(&client->dev,
+					"failed to register %d regulator\n", i);
+				return PTR_ERR(rk808_rdev);
+			}
 		}
+	} else {
+		dev_err(&client->dev, "unsupported RK8XX ID %lu\n",
+			rk808->variant);
+		return -EINVAL;
 	}
-
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC 2/3] regulator: rk808: Add support for rk818
@ 2016-04-08  9:47   ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: mark.rutland-5wv7dgnIgG8, pawel.moll-5wv7dgnIgG8,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, zyw-TNX95d0MmH7DzftRWevZcw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A

Add support for the rk818 regulator. The regulator module consists
of 4 DCDCs, 9 LDOs, 1 switch and 1 BOOST converter which is used to
power OTG and HDMI5V.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
---
 drivers/regulator/rk808-regulator.c | 343 +++++++++++++++++++++++++++++++++---
 1 file changed, 322 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index d86a3dc..b2bbca7 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -6,6 +6,9 @@
  * Author: Chris Zhong <zyw-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  * Author: Zhang Qing <zhangqing-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  *
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -32,6 +35,12 @@
 #define RK808_BUCK4_VSEL_MASK	0xf
 #define RK808_LDO_VSEL_MASK	0x1f
 
+#define RK818_BUCK_VSEL_MASK		0x3f
+#define RK818_BUCK4_VSEL_MASK		0x1f
+#define RK818_LDO_VSEL_MASK		0x1f
+#define RK818_LDO3_ON_VSEL_MASK		0xf
+#define RK818_BOOST_ON_VSEL_MASK	0xe0
+
 /* Ramp rate definitions for buck1 / buck2 only */
 #define RK808_RAMP_RATE_OFFSET		3
 #define RK808_RAMP_RATE_MASK		(3 << RK808_RAMP_RATE_OFFSET)
@@ -87,6 +96,15 @@ static const struct regulator_linear_range rk808_ldo6_voltage_ranges[] = {
 	REGULATOR_LINEAR_RANGE(800000, 0, 17, 100000),
 };
 
+static const struct regulator_linear_range rk818_buck4_voltage_ranges[] = {
+	REGULATOR_LINEAR_RANGE(1800000, 0, 18, 100000),
+};
+
+static const struct regulator_linear_range rk818_boost_voltage_ranges[] = {
+	REGULATOR_LINEAR_RANGE(4700000, 0, 7, 100000),
+};
+
+
 static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev)
 {
 	struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
@@ -506,6 +524,238 @@ static const struct regulator_desc rk808_reg[] = {
 	},
 };
 
+static const struct regulator_desc rk818_reg[] = {
+	{
+		.name = "DCDC_REG1",
+		.supply_name = "vcc1",
+		.id = RK818_ID_DCDC1,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 64,
+		.linear_ranges = rk808_buck_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_buck_voltage_ranges),
+		.vsel_reg = RK818_BUCK1_ON_VSEL_REG,
+		.vsel_mask = RK818_BUCK_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(0),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG2",
+		.supply_name = "vcc2",
+		.id = RK818_ID_DCDC2,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 64,
+		.linear_ranges = rk808_buck_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_buck_voltage_ranges),
+		.vsel_reg = RK818_BUCK2_ON_VSEL_REG,
+		.vsel_mask = RK818_BUCK_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(1),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG3",
+		.supply_name = "vcc3",
+		.id = RK818_ID_DCDC3,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 1,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(2),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG4",
+		.supply_name = "vcc4",
+		.id = RK818_ID_DCDC4,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 19,
+		.linear_ranges = rk818_buck4_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk818_buck4_voltage_ranges),
+		.vsel_reg = RK818_BUCK4_ON_VSEL_REG,
+		.vsel_mask = RK818_BUCK4_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(3),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_BOOST",
+		.supply_name = "boost",
+		.id = RK818_ID_BOOST,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 8,
+		.linear_ranges = rk818_boost_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk818_boost_voltage_ranges),
+		.vsel_reg = RK818_BOOST_LDO9_ON_VSEL_REG,
+		.vsel_mask = RK818_BOOST_ON_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(4),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG1",
+		.supply_name = "vcc6",
+		.id = RK818_ID_LDO1,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO1_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(0),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG2",
+		.supply_name = "vcc6",
+		.id = RK818_ID_LDO2,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO2_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(1),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG3",
+		.supply_name = "vcc7",
+		.id = RK818_ID_LDO3,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 16,
+		.linear_ranges = rk808_ldo3_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges),
+		.vsel_reg = RK818_LDO3_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO3_ON_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(2),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG4",
+		.supply_name = "vcc8",
+		.id = RK818_ID_LDO4,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO4_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(3),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG5",
+		.supply_name = "vcc7",
+		.id = RK818_ID_LDO5,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO5_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(4),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG6",
+		.supply_name = "vcc8",
+		.id = RK818_ID_LDO6,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 18,
+		.linear_ranges = rk808_ldo6_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo6_voltage_ranges),
+		.vsel_reg = RK818_LDO6_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(5),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG7",
+		.supply_name = "vcc7",
+		.id = RK818_ID_LDO7,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 18,
+		.linear_ranges = rk808_ldo6_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo6_voltage_ranges),
+		.vsel_reg = RK818_LDO7_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(6),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG8",
+		.supply_name = "vcc8",
+		.id = RK818_ID_LDO8,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_LDO8_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_LDO_EN_REG,
+		.enable_mask = BIT(7),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG9",
+		.supply_name = "vcc9",
+		.id = RK818_ID_LDO9,
+		.ops = &rk808_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 17,
+		.linear_ranges = rk808_ldo_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(rk808_ldo_voltage_ranges),
+		.vsel_reg = RK818_BOOST_LDO9_ON_VSEL_REG,
+		.vsel_mask = RK818_LDO_VSEL_MASK,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(5),
+		.enable_time = 400,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "SWITCH_REG",
+		.supply_name = "vcc9",
+		.id = RK818_ID_SWITCH,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(6),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "HDMI_SWITCH",
+		.supply_name = "h_5v",
+		.id = RK818_ID_HDMI_SWITCH,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.enable_reg = RK818_H5V_EN_REG,
+		.enable_mask = BIT(0),
+		.owner = THIS_MODULE,
+	}, {
+		.name = "OTG_SWITCH",
+		.supply_name = "usb",
+		.id = RK818_ID_OTG_SWITCH,
+		.ops = &rk808_switch_ops,
+		.type = REGULATOR_VOLTAGE,
+		.enable_reg = RK818_DCDC_EN_REG,
+		.enable_mask = BIT(7),
+		.owner = THIS_MODULE,
+	},
+};
+
 static struct of_regulator_match rk808_reg_matches[] = {
 	[RK808_ID_DCDC1]	= { .name = "DCDC_REG1" },
 	[RK808_ID_DCDC2]	= { .name = "DCDC_REG2" },
@@ -523,11 +773,32 @@ static struct of_regulator_match rk808_reg_matches[] = {
 	[RK808_ID_SWITCH2]	= { .name = "SWITCH_REG2" },
 };
 
+static struct of_regulator_match rk818_reg_matches[] = {
+	[RK818_ID_DCDC1]	= { .name = "DCDC_REG1" },
+	[RK818_ID_DCDC2]	= { .name = "DCDC_REG2" },
+	[RK818_ID_DCDC3]	= { .name = "DCDC_REG3" },
+	[RK818_ID_DCDC4]	= { .name = "DCDC_REG4" },
+	[RK818_ID_BOOST]	= { .name = "DCDC_BOOST" },
+	[RK818_ID_LDO1]		= { .name = "LDO_REG1" },
+	[RK818_ID_LDO2]		= { .name = "LDO_REG2" },
+	[RK818_ID_LDO3]		= { .name = "LDO_REG3" },
+	[RK818_ID_LDO4]		= { .name = "LDO_REG4" },
+	[RK818_ID_LDO5]		= { .name = "LDO_REG5" },
+	[RK818_ID_LDO6]		= { .name = "LDO_REG6" },
+	[RK818_ID_LDO7]		= { .name = "LDO_REG7" },
+	[RK818_ID_LDO8]		= { .name = "LDO_REG8" },
+	[RK818_ID_LDO9]		= { .name = "LDO_REG9" },
+	[RK818_ID_SWITCH]	= { .name = "SWITCH_REG" },
+	[RK818_ID_HDMI_SWITCH]	= { .name = "HDMI_SWITCH" },
+	[RK818_ID_OTG_SWITCH]	= { .name = "OTG_SWITCH" },
+};
+
 static int rk808_regulator_dt_parse_pdata(struct device *dev,
 				   struct device *client_dev,
 				   struct regmap *map,
 				   struct rk808_regulator_data *pdata)
 {
+	struct rk808 *rk808 = dev_get_drvdata(dev->parent);
 	struct device_node *np;
 	int tmp, ret, i;
 
@@ -535,8 +806,12 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
 	if (!np)
 		return -ENXIO;
 
-	ret = of_regulator_match(dev, np, rk808_reg_matches,
-				 RK808_NUM_REGULATORS);
+	if (rk808->variant == RK808_ID)
+		ret = of_regulator_match(dev, np, rk808_reg_matches,
+					 RK808_NUM_REGULATORS);
+	else if (rk808->variant == RK818_ID)
+		ret = of_regulator_match(dev, np, rk818_reg_matches,
+					RK818_NUM_REGULATORS);
 	if (ret < 0)
 		goto dt_parse_end;
 
@@ -586,27 +861,53 @@ static int rk808_regulator_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pdata);
 
-	/* Instantiate the regulators */
-	for (i = 0; i < RK808_NUM_REGULATORS; i++) {
-		if (!rk808_reg_matches[i].init_data ||
-		    !rk808_reg_matches[i].of_node)
-			continue;
-
-		config.dev = &client->dev;
-		config.driver_data = pdata;
-		config.regmap = rk808->regmap;
-		config.of_node = rk808_reg_matches[i].of_node;
-		config.init_data = rk808_reg_matches[i].init_data;
-
-		rk808_rdev = devm_regulator_register(&pdev->dev,
-						     &rk808_reg[i], &config);
-		if (IS_ERR(rk808_rdev)) {
-			dev_err(&client->dev,
-				"failed to register %d regulator\n", i);
-			return PTR_ERR(rk808_rdev);
+	if (rk808->variant == RK818_ID) {
+		/* Instantiate the regulators */
+		for (i = 0; i < RK818_NUM_REGULATORS; i++) {
+			if (!rk818_reg_matches[i].init_data ||
+			    !rk818_reg_matches[i].of_node)
+				continue;
+
+			config.dev = &client->dev;
+			config.driver_data = pdata;
+			config.regmap = rk808->regmap;
+			config.of_node = rk818_reg_matches[i].of_node;
+			config.init_data = rk818_reg_matches[i].init_data;
+
+			rk808_rdev = devm_regulator_register(&pdev->dev,
+					&rk818_reg[i], &config);
+			if (IS_ERR(rk808_rdev)) {
+				dev_err(&client->dev,
+					"failed to register %d regulator\n", i);
+				return PTR_ERR(rk808_rdev);
+			}
+		}
+	} else if (rk808->variant == RK808_ID) {
+		/* Instantiate the regulators */
+		for (i = 0; i < RK808_NUM_REGULATORS; i++) {
+			if (!rk808_reg_matches[i].init_data ||
+			    !rk808_reg_matches[i].of_node)
+				continue;
+
+			config.dev = &client->dev;
+			config.driver_data = pdata;
+			config.regmap = rk808->regmap;
+			config.of_node = rk808_reg_matches[i].of_node;
+			config.init_data = rk808_reg_matches[i].init_data;
+
+			rk808_rdev = devm_regulator_register(&pdev->dev,
+					&rk808_reg[i], &config);
+			if (IS_ERR(rk808_rdev)) {
+				dev_err(&client->dev,
+					"failed to register %d regulator\n", i);
+				return PTR_ERR(rk808_rdev);
+			}
 		}
+	} else {
+		dev_err(&client->dev, "unsupported RK8XX ID %lu\n",
+			rk808->variant);
+		return -EINVAL;
 	}
-
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-08  9:47   ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel, linux-rockchip, devicetree
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	lee.jones, lgirdwood, broonie, dianders, zyw

Add device tree bindings documentation for rockchip's RK818 pmic.

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
index 4ca6aab..8cceb07 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,7 +1,11 @@
-RK808 Power Management Integrated Circuit
+RK8xx Power Management Integrated Circuit
+
+The rk8xx family current members:
+rk808
+rk818
 
 Required properties:
-- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk808", "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -13,6 +17,8 @@ Optional properties:
   default output clock name
 - rockchip,system-power-controller: Telling whether or not this pmic is controlling
   the system power.
+
+Optional rk808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
 - vcc3-supply:  The input supply for DCDC_REG3
@@ -29,7 +35,20 @@ Optional properties:
   the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
   very quickly with no slow ramp time.
 
-Regulators: All the regulators of RK808 to be instantiated shall be
+Optional rk818 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- boost-supply: The input supply for DCDC_BOOST
+- vcc6-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc7-supply:  The input supply for LDO_REG3, LDO_REG5 and LDO_REG7
+- vcc8-supply:  The input supply for LDO_REG4, LDO_REG6 and LDO_REG8
+- vcc9-supply:  The input supply for LDO_REG9 and SWITCH_REG
+- h_5v-supply:  The input supply for HDMI_SWITCH
+- usb-supply:   The input supply for OTG_SWITCH
+
+Regulators: All the regulators of RK8xx to be instantiated shall be
 listed in a child node named 'regulators'. Each regulator is represented
 by a child node of the 'regulators' node.
 
@@ -48,6 +67,18 @@ number as described in RK808 datasheet.
 	- SWITCH_REGn
 		- valid values for n are 1 to 2
 
+Following regulators of the RK818 PMIC block are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK818 datasheet.
+
+	- DCDC_REGn
+		- valid values for n are 1 to 4.
+	- LDO_REGn
+		- valid values for n are 1 to 9.
+	- SWITCH_REG
+	- HDMI_SWITCH
+	- OTG_SWITCH
+
 Standard regulator bindings are used inside regulator subnodes. Check
   Documentation/devicetree/bindings/regulator/regulator.txt
 for more details
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-08  9:47   ` Wadim Egorov
  0 siblings, 0 replies; 18+ messages in thread
From: Wadim Egorov @ 2016-04-08  9:47 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: mark.rutland-5wv7dgnIgG8, pawel.moll-5wv7dgnIgG8,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, zyw-TNX95d0MmH7DzftRWevZcw,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A

Add device tree bindings documentation for rockchip's RK818 pmic.

Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
index 4ca6aab..8cceb07 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,7 +1,11 @@
-RK808 Power Management Integrated Circuit
+RK8xx Power Management Integrated Circuit
+
+The rk8xx family current members:
+rk808
+rk818
 
 Required properties:
-- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk808", "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -13,6 +17,8 @@ Optional properties:
   default output clock name
 - rockchip,system-power-controller: Telling whether or not this pmic is controlling
   the system power.
+
+Optional rk808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
 - vcc3-supply:  The input supply for DCDC_REG3
@@ -29,7 +35,20 @@ Optional properties:
   the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
   very quickly with no slow ramp time.
 
-Regulators: All the regulators of RK808 to be instantiated shall be
+Optional rk818 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- boost-supply: The input supply for DCDC_BOOST
+- vcc6-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc7-supply:  The input supply for LDO_REG3, LDO_REG5 and LDO_REG7
+- vcc8-supply:  The input supply for LDO_REG4, LDO_REG6 and LDO_REG8
+- vcc9-supply:  The input supply for LDO_REG9 and SWITCH_REG
+- h_5v-supply:  The input supply for HDMI_SWITCH
+- usb-supply:   The input supply for OTG_SWITCH
+
+Regulators: All the regulators of RK8xx to be instantiated shall be
 listed in a child node named 'regulators'. Each regulator is represented
 by a child node of the 'regulators' node.
 
@@ -48,6 +67,18 @@ number as described in RK808 datasheet.
 	- SWITCH_REGn
 		- valid values for n are 1 to 2
 
+Following regulators of the RK818 PMIC block are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK818 datasheet.
+
+	- DCDC_REGn
+		- valid values for n are 1 to 4.
+	- LDO_REGn
+		- valid values for n are 1 to 9.
+	- SWITCH_REG
+	- HDMI_SWITCH
+	- OTG_SWITCH
+
 Standard regulator bindings are used inside regulator subnodes. Check
   Documentation/devicetree/bindings/regulator/regulator.txt
 for more details
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [RFC 2/3] regulator: rk808: Add support for rk818
  2016-04-08  9:47   ` Wadim Egorov
  (?)
@ 2016-04-10 19:04   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2016-04-10 19:04 UTC (permalink / raw)
  To: Wadim Egorov
  Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, lee.jones, lgirdwood,
	dianders, zyw

[-- Attachment #1: Type: text/plain, Size: 998 bytes --]

On Fri, Apr 08, 2016 at 11:47:40AM +0200, Wadim Egorov wrote:

> +static const struct regulator_linear_range rk818_buck4_voltage_ranges[] = {
> +	REGULATOR_LINEAR_RANGE(1800000, 0, 18, 100000),
> +};
> +
> +static const struct regulator_linear_range rk818_boost_voltage_ranges[] = {
> +	REGULATOR_LINEAR_RANGE(4700000, 0, 7, 100000),
> +};

Why are these done as linear ranges when there's only one range?  This
just adds overhead, just specify the one range directly in the desc and
use the appropriate ops.

> +	if (rk808->variant == RK808_ID)
> +		ret = of_regulator_match(dev, np, rk808_reg_matches,
> +					 RK808_NUM_REGULATORS);
> +	else if (rk808->variant == RK818_ID)
> +		ret = of_regulator_match(dev, np, rk818_reg_matches,
> +					RK818_NUM_REGULATORS);

Don't use of_regulator_match, just specify the DT names for the
regulator in the desc.  Also it looks like you're trying to write a
switch statement with ifs here, just write a switch statement.  It's
clearer and less error prone.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 1/3] mfd: RK808: Add RK818 support
  2016-04-08  9:47   ` Wadim Egorov
  (?)
@ 2016-04-11  8:41   ` Lee Jones
  -1 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2016-04-11  8:41 UTC (permalink / raw)
  To: Wadim Egorov
  Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, lgirdwood, broonie,
	dianders, zyw

On Fri, 08 Apr 2016, Wadim Egorov wrote:

> The RK818 chip is a power management IC for multimedia and handheld
> devices. It contains the following components:
> 
> - Regulators
> - RTC
> - Clkout
> - battery support
> 
> Both chips RK808 and RK818 are using a similar register map.
> So we can reuse the RTC and Clkout functionality.
> 
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> ---
>  drivers/mfd/Kconfig       |   6 +-
>  drivers/mfd/rk808.c       | 279 +++++++++++++++++++++++++++++++++++++---------
>  include/linux/mfd/rk808.h | 182 ++++++++++++++++++++++++++++--
>  3 files changed, 405 insertions(+), 62 deletions(-)

Split this up into 2 seperate patches;
  - Generify driver i.e. rk808 => rk8xx
  - Add support for RK818

> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index eea61e3..7cbbfa4 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -813,14 +813,14 @@ config MFD_RC5T583
>  	  Additional drivers must be enabled in order to use the
>  	  different functionality of the device.
>  
> -config MFD_RK808
> -	tristate "Rockchip RK808 Power Management chip"
> +config MFD_RK8XX
> +	tristate "Rockchip RK8xx Power Management chip"
>  	depends on I2C && OF
>  	select MFD_CORE
>  	select REGMAP_I2C
>  	select REGMAP_IRQ
>  	help
> -	  If you say yes here you get support for the RK808
> +	  If you say yes here you get support for the RK808 and RK818
>  	  Power Management chips.
>  	  This driver provides common support for accessing the device
>  	  through I2C interface. The device supports multiple sub-devices
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index 4b1e439..d3fd8ef 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -1,11 +1,14 @@
>  /*
> - * MFD core driver for Rockchip RK808
> + * MFD core driver for Rockchip RK8xx
>   *
>   * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
>   *
>   * Author: Chris Zhong <zyw@rock-chips.com>
>   * Author: Zhang Qing <zhangqing@rock-chips.com>
>   *
> + * Copyright (C) 2016 PHYTEC Messtechnik GmbH
> + * Author: Wadim Egorov <w.egorov@phytec.de>
> + *

Use the same format as your predecessor, i.e. '\n' after Copyright.

>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms and conditions of the GNU General Public License,
>   * version 2, as published by the Free Software Foundation.
> @@ -22,14 +25,14 @@
>  #include <linux/mfd/core.h>
>  #include <linux/module.h>
>  #include <linux/regmap.h>
> +#include <linux/of_device.h>
>  
> -struct rk808_reg_data {
> -	int addr;
> -	int mask;
> -	int value;
> +static const char * const rk8xx_model_names[] = {
> +	"RK808",
> +	"RK818",
>  };
>  
> -static bool rk808_is_volatile_reg(struct device *dev, unsigned int reg)
> +static bool rk8xx_is_volatile_reg(struct device *dev, unsigned int reg)
>  {
>  	/*
>  	 * Notes:
> @@ -62,7 +65,15 @@ static const struct regmap_config rk808_regmap_config = {
>  	.val_bits = 8,
>  	.max_register = RK808_IO_POL_REG,
>  	.cache_type = REGCACHE_RBTREE,
> -	.volatile_reg = rk808_is_volatile_reg,
> +	.volatile_reg = rk8xx_is_volatile_reg,
> +};
> +
> +static const struct regmap_config rk818_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = RK818_USB_CTRL_REG,
> +	.cache_type = REGCACHE_RBTREE,
> +	.volatile_reg = rk8xx_is_volatile_reg,
>  };
>  
>  static struct resource rtc_resources[] = {
> @@ -83,7 +94,17 @@ static const struct mfd_cell rk808s[] = {
>  	},
>  };
>  
> -static const struct rk808_reg_data pre_init_reg[] = {
> +static const struct mfd_cell rk818s[] = {
> +	{ .name = "rk808-clkout", },
> +	{ .name = "rk808-regulator", },
> +	{
> +		.name = "rk808-rtc",
> +		.num_resources = ARRAY_SIZE(rtc_resources),
> +		.resources = &rtc_resources[0],
> +	},
> +};
> +
> +static const struct rk8xx_reg_data rk808_pre_init_reg[] = {
>  	{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
>  	{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
>  	{ RK808_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA },
> @@ -94,6 +115,27 @@ static const struct rk808_reg_data pre_init_reg[] = {
>  						    VB_LO_SEL_3500MV },
>  };
>  
> +static const struct rk8xx_reg_data rk818_pre_init_reg[] = {
> +	{ RK818_USB_CTRL_REG,	RK818_USB_ILIM_SEL_MASK,
> +						RK818_USB_ILMIN_2000MA },
> +	/* close charger when usb lower then 3.4V */
> +	{ RK818_USB_CTRL_REG,	RK818_USB_CHG_SD_VSEL_MASK, (0x7 << 4) },
> +	/* no action when vref */
> +	{ RK818_H5V_EN_REG,	(0x1 << 1),	RK818_REF_RDY_CTRL },

BIT()

> +
> +	/* enable HDMI 5V */
> +	{ RK818_H5V_EN_REG,	(0x1 << 0),	RK818_H5V_EN },

BIT()

> +
> +	/* improve efficiency */
> +	{ RK818_BUCK2_CONFIG_REG, BUCK2_RATE_MASK,  BUCK_ILMIN_250MA },
> +	{ RK818_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_250MA },
> +
> +	{ RK818_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA },
> +
> +	{ RK808_VB_MON_REG,       MASK_ALL,         VB_LO_ACT |
> +						    VB_LO_SEL_3500MV },
> +};
> +
>  static const struct regmap_irq rk808_irqs[] = {
>  	/* INT_STS */
>  	[RK808_IRQ_VOUT_LO] = {
> @@ -136,6 +178,81 @@ static const struct regmap_irq rk808_irqs[] = {
>  	},
>  };
>  
> +static const struct regmap_irq rk818_irqs[] = {
> +	/* INT_STS */
> +	[RK818_IRQ_VOUT_LO] = {
> +		.mask = RK818_IRQ_VOUT_LO_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_VB_LO] = {
> +		.mask = RK818_IRQ_VB_LO_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_PWRON] = {
> +		.mask = RK818_IRQ_PWRON_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_PWRON_LP] = {
> +		.mask = RK818_IRQ_PWRON_LP_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_HOTDIE] = {
> +		.mask = RK818_IRQ_HOTDIE_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_RTC_ALARM] = {
> +		.mask = RK818_IRQ_RTC_ALARM_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_RTC_PERIOD] = {
> +		.mask = RK818_IRQ_RTC_PERIOD_MSK,
> +		.reg_offset = 0,
> +	},
> +	[RK818_IRQ_USB_OV] = {
> +		.mask = RK818_IRQ_USB_OV_MSK,
> +		.reg_offset = 0,
> +	},
> +
> +	/* INT_STS2 */
> +	[RK818_IRQ_PLUG_IN] = {
> +		.mask = RK818_IRQ_PLUG_IN_MSK,
> +		.reg_offset = 1,
> +	},
> +	[RK818_IRQ_PLUG_OUT] = {
> +		.mask = RK818_IRQ_PLUG_OUT_MSK,
> +		.reg_offset = 1,
> +	},
> +	[RK818_IRQ_CHG_OK] = {
> +		.mask = RK818_IRQ_CHG_OK_MSK,
> +		.reg_offset = 1,
> +	},
> +
> +	[RK818_IRQ_CHG_TE] = {
> +		.mask = RK818_IRQ_CHG_TE_MSK,
> +		.reg_offset = 1,
> +	},
> +
> +	[RK818_IRQ_CHG_TS1] = {
> +		.mask = RK818_IRQ_CHG_TS1_MSK,
> +		.reg_offset = 1,
> +	},
> +
> +	[RK818_IRQ_TS2] = {
> +		.mask = RK818_IRQ_TS2_MSK,
> +		.reg_offset = 1,
> +	},
> +
> +	[RK818_IRQ_CHG_CVTLIM] = {
> +		.mask = RK818_IRQ_CHG_CVTLIM_MSK,
> +		.reg_offset = 1,
> +	},
> +
> +	[RK818_IRQ_DISCHG_ILIM] = {
> +		.mask = RK818_IRQ_DISCHG_ILIM_MSK,
> +		.reg_offset = 1,
> +	},
> +};
> +
>  static struct regmap_irq_chip rk808_irq_chip = {
>  	.name = "rk808",
>  	.irqs = rk808_irqs,
> @@ -148,15 +265,27 @@ static struct regmap_irq_chip rk808_irq_chip = {
>  	.init_ack_masked = true,
>  };
>  
> -static struct i2c_client *rk808_i2c_client;
> +static struct regmap_irq_chip rk818_irq_chip = {
> +	.name = "rk818",
> +	.irqs = rk818_irqs,
> +	.num_irqs = ARRAY_SIZE(rk808_irqs),
> +	.num_regs = 2,
> +	.irq_reg_stride = 2,
> +	.status_base = RK808_INT_STS_REG1,
> +	.mask_base = RK808_INT_STS_MSK_REG1,
> +	.ack_base = RK808_INT_STS_REG1,
> +	.init_ack_masked = true,
> +};
> +
> +static struct i2c_client *rk8xx_i2c_client;
>  static void rk808_device_shutdown(void)
>  {
>  	int ret;
> -	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
> +	struct rk808 *rk808 = i2c_get_clientdata(rk8xx_i2c_client);
>  
>  	if (!rk808) {
> -		dev_warn(&rk808_i2c_client->dev,
> -			 "have no rk808, so do nothing here\n");
> +		dev_warn(&rk8xx_i2c_client->dev,
> +			 "have no rk8xx, so do nothing here\n");
>  		return;
>  	}
>  
> @@ -164,10 +293,57 @@ static void rk808_device_shutdown(void)
>  				 RK808_DEVCTRL_REG,
>  				 DEV_OFF_RST, DEV_OFF_RST);
>  	if (ret)
> -		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> +		dev_err(&rk8xx_i2c_client->dev, "power off error!\n");
> +}
> +
> +static const struct of_device_id rk8xx_of_match[] = {
> +	{ .compatible = "rockchip,rk808", .data = (void *) RK808_ID },
> +	{ .compatible = "rockchip,rk818", .data = (void *) RK818_ID },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, rk8xx_of_match);
> +
> +static int rk8xx_match_device(struct rk808 *rk808, struct device *dev)
> +{
> +	const struct of_device_id *of_id;
> +
> +	if (dev->of_node) {

It is not possible for this to be NULL.  No need for the check.

> +		of_id = of_match_device(rk8xx_of_match, dev);
> +		if (!of_id) {
> +			dev_err(dev, "Unable to match OF ID\n");
> +			return -ENODEV;
> +		}
> +		rk808->variant = (long) of_id->data;

Is there no way to fetch this from the device, i.e. though a register
read?

> +	}
> +
> +	switch (rk808->variant) {
> +	case RK808_ID:
> +		rk808->nr_cells = ARRAY_SIZE(rk808s);
> +		rk808->cells = rk808s;
> +		rk808->regmap_cfg = &rk808_regmap_config;
> +		rk808->regmap_irq_chip = &rk808_irq_chip;
> +		rk808->pre_init_reg = rk808_pre_init_reg;
> +		rk808->nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
> +		break;
> +	case RK818_ID:
> +		rk808->nr_cells = ARRAY_SIZE(rk818s);
> +		rk808->cells = rk818s;
> +		rk808->regmap_cfg = &rk818_regmap_config;
> +		rk808->regmap_irq_chip = &rk818_irq_chip;
> +		rk808->pre_init_reg = rk818_pre_init_reg;
> +		rk808->nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
> +		break;
> +	default:
> +		dev_err(dev, "unsupported RK8XX ID %lu\n", rk808->variant);
> +		return -EINVAL;
> +	}
> +	dev_info(dev, "RK8XX variant %s found\n",

It wasn't "found".  The device hasn't been probed.  You are assuming
this device is connected because that's what the DT says.  Only print
these types of dev_info() prints when you have actually talked to the
device and confirmed it's presence.

> +		rk8xx_model_names[rk808->variant]);
> +
> +	return 0;
>  }
>  
> -static int rk808_probe(struct i2c_client *client,
> +static int rk8xx_probe(struct i2c_client *client,
>  		       const struct i2c_device_id *id)
>  {
>  	struct device_node *np = client->dev.of_node;
> @@ -176,45 +352,51 @@ static int rk808_probe(struct i2c_client *client,
>  	int ret;
>  	int i;
>  
> -	if (!client->irq) {
> -		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
> -		return -EINVAL;
> -	}
> -
>  	rk808 = devm_kzalloc(&client->dev, sizeof(*rk808), GFP_KERNEL);
>  	if (!rk808)
>  		return -ENOMEM;
>  
> -	rk808->regmap = devm_regmap_init_i2c(client, &rk808_regmap_config);
> +	ret = rk8xx_match_device(rk808, &client->dev);
> +	if (ret)
> +		return ret;
> +
> +	rk808->i2c = client;
> +	i2c_set_clientdata(client, rk808);
> +
> +	rk808->regmap = devm_regmap_init_i2c(client, rk808->regmap_cfg);
>  	if (IS_ERR(rk808->regmap)) {
>  		dev_err(&client->dev, "regmap initialization failed\n");
>  		return PTR_ERR(rk808->regmap);
>  	}
>  
> -	for (i = 0; i < ARRAY_SIZE(pre_init_reg); i++) {
> -		ret = regmap_update_bits(rk808->regmap, pre_init_reg[i].addr,
> -					 pre_init_reg[i].mask,
> -					 pre_init_reg[i].value);
> -		if (ret) {
> -			dev_err(&client->dev,
> -				"0x%x write err\n", pre_init_reg[i].addr);
> -			return ret;
> -		}
> +	if (!client->irq) {
> +		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
> +		return -EINVAL;
>  	}
>  
>  	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
>  				  IRQF_ONESHOT, -1,
> -				  &rk808_irq_chip, &rk808->irq_data);
> +				  rk808->regmap_irq_chip, &rk808->irq_data);
>  	if (ret) {
>  		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
>  		return ret;
>  	}
>  
> -	rk808->i2c = client;
> -	i2c_set_clientdata(client, rk808);
> +	for (i = 0; i < rk808->nr_pre_init_regs; i++) {
> +		ret = regmap_update_bits(rk808->regmap,
> +					rk808->pre_init_reg[i].addr,
> +					rk808->pre_init_reg[i].mask,
> +					rk808->pre_init_reg[i].value);
> +		if (ret) {
> +			dev_err(&client->dev,
> +				"0x%x write err\n",
> +				rk808->pre_init_reg[i].addr);
> +			return ret;
> +		}
> +	}
>  
>  	ret = mfd_add_devices(&client->dev, -1,

Use the correct #defines.

> -			      rk808s, ARRAY_SIZE(rk808s),
> +			      rk808->cells, rk808->nr_cells,
>  			      NULL, 0, regmap_irq_get_domain(rk808->irq_data));
>  	if (ret) {
>  		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
> @@ -224,7 +406,7 @@ static int rk808_probe(struct i2c_client *client,
>  	pm_off = of_property_read_bool(np,
>  				"rockchip,system-power-controller");
>  	if (pm_off && !pm_power_off) {
> -		rk808_i2c_client = client;
> +		rk8xx_i2c_client = client;
>  		pm_power_off = rk808_device_shutdown;
>  	}
>  
> @@ -235,7 +417,7 @@ err_irq:
>  	return ret;
>  }
>  
> -static int rk808_remove(struct i2c_client *client)
> +static int rk8xx_remove(struct i2c_client *client)
>  {
>  	struct rk808 *rk808 = i2c_get_clientdata(client);
>  
> @@ -246,31 +428,26 @@ static int rk808_remove(struct i2c_client *client)
>  	return 0;
>  }
>  
> -static const struct of_device_id rk808_of_match[] = {
> -	{ .compatible = "rockchip,rk808" },
> -	{ },
> -};
> -MODULE_DEVICE_TABLE(of, rk808_of_match);
> -
> -static const struct i2c_device_id rk808_ids[] = {
> +static const struct i2c_device_id rk8xx_ids[] = {
>  	{ "rk808" },
> +	{ "rk818" },
>  	{ },
>  };
> -MODULE_DEVICE_TABLE(i2c, rk808_ids);
> +MODULE_DEVICE_TABLE(i2c, rk8xx_ids);
>  
> -static struct i2c_driver rk808_i2c_driver = {
> +static struct i2c_driver rk8xx_i2c_driver = {
>  	.driver = {
> -		.name = "rk808",
> -		.of_match_table = rk808_of_match,
> +		.name = "rk8xx",
> +		.of_match_table = rk8xx_of_match,
>  	},
> -	.probe    = rk808_probe,
> -	.remove   = rk808_remove,
> -	.id_table = rk808_ids,
> +	.probe    = rk8xx_probe,
> +	.remove   = rk8xx_remove,
> +	.id_table = rk8xx_ids,
>  };
>  
> -module_i2c_driver(rk808_i2c_driver);
> +module_i2c_driver(rk8xx_i2c_driver);
>  
>  MODULE_LICENSE("GPL");
>  MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
>  MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");
> -MODULE_DESCRIPTION("RK808 PMIC driver");
> +MODULE_DESCRIPTION("RK8xx PMIC driver");

s/xx/XX/

> diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
> index 441b6ee..0858219 100644
> --- a/include/linux/mfd/rk808.h
> +++ b/include/linux/mfd/rk808.h
> @@ -1,11 +1,14 @@
>  /*
> - * rk808.h for Rockchip RK808
> + * rk808.h for Rockchip RK8xx

Please remove the filename completely.  They have a habit of becoming
wrong.

s/xx/XX/

>   * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
>   *
>   * Author: Chris Zhong <zyw@rock-chips.com>
>   * Author: Zhang Qing <zhangqing@rock-chips.com>
>   *
> + * Copyright (C) 2016 PHYTEC Messtechnik GmbH
> + * Author: Wadim Egorov <w.egorov@phytec.de>

Use the same format as above.

>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms and conditions of the GNU General Public License,
>   * version 2, as published by the Free Software Foundation.
> @@ -16,8 +19,8 @@
>   * more details.
>   */
>  
> -#ifndef __LINUX_REGULATOR_rk808_H
> -#define __LINUX_REGULATOR_rk808_H
> +#ifndef __LINUX_REGULATOR_rk8xx_H
> +#define __LINUX_REGULATOR_rk8xx_H

These should really all be uppercase.

>  #include <linux/regulator/machine.h>
>  #include <linux/regmap.h>
> @@ -47,6 +50,28 @@ enum rk808_reg {
>  	RK808_ID_SWITCH2,
>  };
>  
> +#define RK818_NUM_REGULATORS	17
> +
> +enum rk818_reg {
> +	RK818_ID_DCDC1,
> +	RK818_ID_DCDC2,
> +	RK818_ID_DCDC3,
> +	RK818_ID_DCDC4,
> +	RK818_ID_BOOST,
> +	RK818_ID_LDO1,
> +	RK818_ID_LDO2,
> +	RK818_ID_LDO3,
> +	RK818_ID_LDO4,
> +	RK818_ID_LDO5,
> +	RK818_ID_LDO6,
> +	RK818_ID_LDO7,
> +	RK818_ID_LDO8,
> +	RK818_ID_LDO9,
> +	RK818_ID_SWITCH,
> +	RK818_ID_HDMI_SWITCH,
> +	RK818_ID_OTG_SWITCH,
> +};
> +
>  #define RK808_SECONDS_REG	0x00
>  #define RK808_MINUTES_REG	0x01
>  #define RK808_HOURS_REG		0x02
> @@ -115,7 +140,92 @@ enum rk808_reg {
>  #define RK808_INT_STS_MSK_REG2	0x4f
>  #define RK808_IO_POL_REG	0x50
>  
> -/* IRQ Definitions */
> +/* RK818 */
> +#define RK818_DCDC1			0
> +#define RK818_LDO1			4
> +
> +#define RK818_SECONDS_REG		0x00
> +#define RK818_MINUTES_REG		0x01
> +#define RK818_HOURS_REG			0x02
> +#define RK818_DAYS_REG			0x03
> +#define RK818_MONTHS_REG		0x04
> +#define RK818_YEARS_REG			0x05
> +#define RK818_WEEKS_REG			0x06
> +#define RK818_ALARM_SECONDS_REG		0x07
> +#define RK818_ALARM_MINUTES_REG		0x08
> +#define RK818_ALARM_HOURS_REG		0x09
> +#define RK818_ALARM_DAYS_REG		0x0a
> +#define RK818_ALARM_MONTHS_REG		0x0b
> +#define RK818_ALARM_YEARS_REG		0x0c
> +#define RK818_RTC_CTRL_REG		0x10
> +#define RK818_RTC_STATUS_REG		0x11
> +#define RK818_RTC_INT_REG		0x12
> +#define RK818_RTC_COMP_LSB_REG		0x13
> +#define RK818_RTC_COMP_MSB_REG		0x14
> +#define RK818_CLK32OUT_REG		0x20
> +#define RK818_VB_MON_REG		0x21
> +#define RK818_THERMAL_REG		0x22
> +#define RK818_DCDC_EN_REG		0x23
> +#define RK818_LDO_EN_REG		0x24
> +#define RK818_SLEEP_SET_OFF_REG1	0x25
> +#define RK818_SLEEP_SET_OFF_REG2	0x26
> +#define RK818_DCDC_UV_STS_REG		0x27
> +#define RK818_DCDC_UV_ACT_REG		0x28
> +#define RK818_LDO_UV_STS_REG		0x29
> +#define RK818_LDO_UV_ACT_REG		0x2a
> +#define RK818_DCDC_PG_REG		0x2b
> +#define RK818_LDO_PG_REG		0x2c
> +#define RK818_VOUT_MON_TDB_REG		0x2d
> +#define RK818_BUCK1_CONFIG_REG		0x2e
> +#define RK818_BUCK1_ON_VSEL_REG		0x2f
> +#define RK818_BUCK1_SLP_VSEL_REG	0x30
> +#define RK818_BUCK2_CONFIG_REG		0x32
> +#define RK818_BUCK2_ON_VSEL_REG		0x33
> +#define RK818_BUCK2_SLP_VSEL_REG	0x34
> +#define RK818_BUCK3_CONFIG_REG		0x36
> +#define RK818_BUCK4_CONFIG_REG		0x37
> +#define RK818_BUCK4_ON_VSEL_REG		0x38
> +#define RK818_BUCK4_SLP_VSEL_REG	0x39
> +#define RK818_BOOST_CONFIG_REG		0x3a
> +#define RK818_LDO1_ON_VSEL_REG		0x3b
> +#define RK818_LDO1_SLP_VSEL_REG		0x3c
> +#define RK818_LDO2_ON_VSEL_REG		0x3d
> +#define RK818_LDO2_SLP_VSEL_REG		0x3e
> +#define RK818_LDO3_ON_VSEL_REG		0x3f
> +#define RK818_LDO3_SLP_VSEL_REG		0x40
> +#define RK818_LDO4_ON_VSEL_REG		0x41
> +#define RK818_LDO4_SLP_VSEL_REG		0x42
> +#define RK818_LDO5_ON_VSEL_REG		0x43
> +#define RK818_LDO5_SLP_VSEL_REG		0x44
> +#define RK818_LDO6_ON_VSEL_REG		0x45
> +#define RK818_LDO6_SLP_VSEL_REG		0x46
> +#define RK818_LDO7_ON_VSEL_REG		0x47
> +#define RK818_LDO7_SLP_VSEL_REG		0x48
> +#define RK818_LDO8_ON_VSEL_REG		0x49
> +#define RK818_LDO8_SLP_VSEL_REG		0x4a
> +#define RK818_BOOST_LDO9_ON_VSEL_REG	0x54
> +#define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
> +#define RK818_DEVCTRL_REG		0x4b
> +#define RK818_INT_STS_REG1		0X4c
> +#define RK818_INT_STS_MSK_REG1		0x4d
> +#define RK818_INT_STS_REG2		0x4e
> +#define RK818_INT_STS_MSK_REG2		0x4f
> +#define RK818_IO_POL_REG		0x50
> +#define RK818_H5V_EN_REG		0x52
> +#define RK818_SLEEP_SET_OFF_REG3	0x53
> +#define RK818_BOOST_LDO9_ON_VSEL_REG	0x54
> +#define RK818_BOOST_LDO9_SLP_VSEL_REG	0x55
> +#define RK818_BOOST_CTRL_REG		0x56
> +#define RK818_DCDC_ILMAX		0x90
> +#define RK818_USB_CTRL_REG		0xa1
> +
> +#define RK818_H5V_EN			BIT(0)
> +#define RK818_REF_RDY_CTRL		BIT(1)
> +#define RK818_USB_ILIM_SEL_MASK		0xf
> +#define RK818_USB_ILMIN_2000MA		0x7
> +#define RK818_USB_CHG_SD_VSEL_MASK	0x70
> +
> +/* RK808 IRQ Definitions */
>  #define RK808_IRQ_VOUT_LO	0
>  #define RK808_IRQ_VB_LO		1
>  #define RK808_IRQ_PWRON		2
> @@ -137,6 +247,44 @@ enum rk808_reg {
>  #define RK808_IRQ_PLUG_IN_INT_MSK	BIT(0)
>  #define RK808_IRQ_PLUG_OUT_INT_MSK	BIT(1)
>  
> +/* RK818 IRQ Definitions */
> +#define RK818_IRQ_VOUT_LO	0
> +#define RK818_IRQ_VB_LO		1
> +#define RK818_IRQ_PWRON		2
> +#define RK818_IRQ_PWRON_LP	3
> +#define RK818_IRQ_HOTDIE	4
> +#define RK818_IRQ_RTC_ALARM	5
> +#define RK818_IRQ_RTC_PERIOD	6
> +#define RK818_IRQ_USB_OV	7
> +#define RK818_IRQ_PLUG_IN	8
> +#define RK818_IRQ_PLUG_OUT	9
> +#define RK818_IRQ_CHG_OK	10
> +#define RK818_IRQ_CHG_TE	11
> +#define RK818_IRQ_CHG_TS1	12
> +#define RK818_IRQ_TS2		13
> +#define RK818_IRQ_CHG_CVTLIM	14
> +#define RK818_IRQ_DISCHG_ILIM	7
> +
> +#define RK818_IRQ_VOUT_LO_MSK		BIT(0)
> +#define RK818_IRQ_VB_LO_MSK		BIT(1)
> +#define RK818_IRQ_PWRON_MSK		BIT(2)
> +#define RK818_IRQ_PWRON_LP_MSK		BIT(3)
> +#define RK818_IRQ_HOTDIE_MSK		BIT(4)
> +#define RK818_IRQ_RTC_ALARM_MSK		BIT(5)
> +#define RK818_IRQ_RTC_PERIOD_MSK	BIT(6)
> +#define RK818_IRQ_USB_OV_MSK		BIT(7)
> +#define RK818_IRQ_PLUG_IN_MSK		BIT(0)
> +#define RK818_IRQ_PLUG_OUT_MSK		BIT(1)
> +#define RK818_IRQ_CHG_OK_MSK		BIT(2)
> +#define RK818_IRQ_CHG_TE_MSK		BIT(3)
> +#define RK818_IRQ_CHG_TS1_MSK		BIT(4)
> +#define RK818_IRQ_TS2_MSK		BIT(5)
> +#define RK818_IRQ_CHG_CVTLIM_MSK	BIT(6)
> +#define RK818_IRQ_DISCHG_ILIM_MSK	BIT(7)
> +
> +#define RK818_NUM_IRQ		16
> +
> +
>  #define RK808_VBAT_LOW_2V8	0x00
>  #define RK808_VBAT_LOW_2V9	0x01
>  #define RK808_VBAT_LOW_3V0	0x02
> @@ -191,9 +339,27 @@ enum {
>  	BOOST_ILMIN_250MA,
>  };
>  
> +enum {
> +	RK808_ID = 0,
> +	RK818_ID,
> +};
> +
> +struct rk8xx_reg_data {
> +	int addr;
> +	int mask;
> +	int value;
> +};
> +
>  struct rk808 {
> -	struct i2c_client *i2c;
> -	struct regmap_irq_chip_data *irq_data;
> -	struct regmap *regmap;
> +	struct i2c_client		*i2c;
> +	struct regmap_irq_chip_data	*irq_data;
> +	struct regmap			*regmap;
> +	long				variant;
> +	int				nr_cells;
> +	const struct mfd_cell		*cells;
> +	const struct regmap_config	*regmap_cfg;
> +	const struct regmap_irq_chip	*regmap_irq_chip;
> +	const struct rk8xx_reg_data	*pre_init_reg;
> +	int				nr_pre_init_regs;
>  };
> -#endif /* __LINUX_REGULATOR_rk808_H */
> +#endif /* __LINUX_REGULATOR_rk8xx_H */

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-11  8:44     ` Lee Jones
  0 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2016-04-11  8:44 UTC (permalink / raw)
  To: Wadim Egorov
  Cc: linux-kernel, linux-rockchip, devicetree, robh+dt, pawel.moll,
	mark.rutland, ijc+devicetree, galak, lgirdwood, broonie,
	dianders, zyw

On Fri, 08 Apr 2016, Wadim Egorov wrote:

> Add device tree bindings documentation for rockchip's RK818 pmic.
> 
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> ---
>  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> index 4ca6aab..8cceb07 100644
> --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> @@ -1,7 +1,11 @@
> -RK808 Power Management Integrated Circuit
> +RK8xx Power Management Integrated Circuit

s/xx/XX/

> +The rk8xx family current members:
> +rk808
> +rk818
>  
>  Required properties:
> -- compatible: "rockchip,rk808"
> +- compatible: "rockchip,rk808", "rockchip,rk818"
>  - reg: I2C slave address
>  - interrupt-parent: The parent interrupt controller.
>  - interrupts: the interrupt outputs of the controller.
> @@ -13,6 +17,8 @@ Optional properties:
>    default output clock name
>  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
>    the system power.
> +
> +Optional rk808 properties:

When mentioning the chip by name, you should always do so using
uppercase, as it is in the datasheet.

>  - vcc1-supply:  The input supply for DCDC_REG1
>  - vcc2-supply:  The input supply for DCDC_REG2
>  - vcc3-supply:  The input supply for DCDC_REG3
> @@ -29,7 +35,20 @@ Optional properties:
>    the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
>    very quickly with no slow ramp time.
>  
> -Regulators: All the regulators of RK808 to be instantiated shall be
> +Optional rk818 properties:

Uppercase.

> +- vcc1-supply:  The input supply for DCDC_REG1
> +- vcc2-supply:  The input supply for DCDC_REG2
> +- vcc3-supply:  The input supply for DCDC_REG3
> +- vcc4-supply:  The input supply for DCDC_REG4
> +- boost-supply: The input supply for DCDC_BOOST
> +- vcc6-supply:  The input supply for LDO_REG1 and LDO_REG2
> +- vcc7-supply:  The input supply for LDO_REG3, LDO_REG5 and LDO_REG7
> +- vcc8-supply:  The input supply for LDO_REG4, LDO_REG6 and LDO_REG8
> +- vcc9-supply:  The input supply for LDO_REG9 and SWITCH_REG
> +- h_5v-supply:  The input supply for HDMI_SWITCH
> +- usb-supply:   The input supply for OTG_SWITCH
> +
> +Regulators: All the regulators of RK8xx to be instantiated shall be
>  listed in a child node named 'regulators'. Each regulator is represented
>  by a child node of the 'regulators' node.
>  
> @@ -48,6 +67,18 @@ number as described in RK808 datasheet.
>  	- SWITCH_REGn
>  		- valid values for n are 1 to 2
>  
> +Following regulators of the RK818 PMIC block are supported. Note that
> +the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
> +number as described in RK818 datasheet.
> +
> +	- DCDC_REGn
> +		- valid values for n are 1 to 4.
> +	- LDO_REGn
> +		- valid values for n are 1 to 9.
> +	- SWITCH_REG
> +	- HDMI_SWITCH
> +	- OTG_SWITCH
> +
>  Standard regulator bindings are used inside regulator subnodes. Check
>    Documentation/devicetree/bindings/regulator/regulator.txt
>  for more details

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-11  8:44     ` Lee Jones
  0 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2016-04-11  8:44 UTC (permalink / raw)
  To: Wadim Egorov
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, dianders-F7+t8E8rja9g9hUCZPvPmw,
	zyw-TNX95d0MmH7DzftRWevZcw

On Fri, 08 Apr 2016, Wadim Egorov wrote:

> Add device tree bindings documentation for rockchip's RK818 pmic.
> 
> Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> index 4ca6aab..8cceb07 100644
> --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> @@ -1,7 +1,11 @@
> -RK808 Power Management Integrated Circuit
> +RK8xx Power Management Integrated Circuit

s/xx/XX/

> +The rk8xx family current members:
> +rk808
> +rk818
>  
>  Required properties:
> -- compatible: "rockchip,rk808"
> +- compatible: "rockchip,rk808", "rockchip,rk818"
>  - reg: I2C slave address
>  - interrupt-parent: The parent interrupt controller.
>  - interrupts: the interrupt outputs of the controller.
> @@ -13,6 +17,8 @@ Optional properties:
>    default output clock name
>  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
>    the system power.
> +
> +Optional rk808 properties:

When mentioning the chip by name, you should always do so using
uppercase, as it is in the datasheet.

>  - vcc1-supply:  The input supply for DCDC_REG1
>  - vcc2-supply:  The input supply for DCDC_REG2
>  - vcc3-supply:  The input supply for DCDC_REG3
> @@ -29,7 +35,20 @@ Optional properties:
>    the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
>    very quickly with no slow ramp time.
>  
> -Regulators: All the regulators of RK808 to be instantiated shall be
> +Optional rk818 properties:

Uppercase.

> +- vcc1-supply:  The input supply for DCDC_REG1
> +- vcc2-supply:  The input supply for DCDC_REG2
> +- vcc3-supply:  The input supply for DCDC_REG3
> +- vcc4-supply:  The input supply for DCDC_REG4
> +- boost-supply: The input supply for DCDC_BOOST
> +- vcc6-supply:  The input supply for LDO_REG1 and LDO_REG2
> +- vcc7-supply:  The input supply for LDO_REG3, LDO_REG5 and LDO_REG7
> +- vcc8-supply:  The input supply for LDO_REG4, LDO_REG6 and LDO_REG8
> +- vcc9-supply:  The input supply for LDO_REG9 and SWITCH_REG
> +- h_5v-supply:  The input supply for HDMI_SWITCH
> +- usb-supply:   The input supply for OTG_SWITCH
> +
> +Regulators: All the regulators of RK8xx to be instantiated shall be
>  listed in a child node named 'regulators'. Each regulator is represented
>  by a child node of the 'regulators' node.
>  
> @@ -48,6 +67,18 @@ number as described in RK808 datasheet.
>  	- SWITCH_REGn
>  		- valid values for n are 1 to 2
>  
> +Following regulators of the RK818 PMIC block are supported. Note that
> +the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
> +number as described in RK818 datasheet.
> +
> +	- DCDC_REGn
> +		- valid values for n are 1 to 4.
> +	- LDO_REGn
> +		- valid values for n are 1 to 9.
> +	- SWITCH_REG
> +	- HDMI_SWITCH
> +	- OTG_SWITCH
> +
>  Standard regulator bindings are used inside regulator subnodes. Check
>    Documentation/devicetree/bindings/regulator/regulator.txt
>  for more details

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-11 15:48     ` Rob Herring
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-04-11 15:48 UTC (permalink / raw)
  To: Wadim Egorov
  Cc: linux-kernel, linux-rockchip, devicetree, pawel.moll,
	mark.rutland, ijc+devicetree, galak, lee.jones, lgirdwood,
	broonie, dianders, zyw

On Fri, Apr 08, 2016 at 11:47:41AM +0200, Wadim Egorov wrote:
> Add device tree bindings documentation for rockchip's RK818 pmic.
> 
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> ---
>  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> index 4ca6aab..8cceb07 100644
> --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> @@ -1,7 +1,11 @@
> -RK808 Power Management Integrated Circuit
> +RK8xx Power Management Integrated Circuit
> +
> +The rk8xx family current members:
> +rk808
> +rk818
>  
>  Required properties:
> -- compatible: "rockchip,rk808"
> +- compatible: "rockchip,rk808", "rockchip,rk818"

Do one per line please.

>  - reg: I2C slave address
>  - interrupt-parent: The parent interrupt controller.
>  - interrupts: the interrupt outputs of the controller.
> @@ -13,6 +17,8 @@ Optional properties:
>    default output clock name
>  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
>    the system power.
> +
> +Optional rk808 properties:
>  - vcc1-supply:  The input supply for DCDC_REG1
>  - vcc2-supply:  The input supply for DCDC_REG2
>  - vcc3-supply:  The input supply for DCDC_REG3
> @@ -29,7 +35,20 @@ Optional properties:
>    the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
>    very quickly with no slow ramp time.
>  
> -Regulators: All the regulators of RK808 to be instantiated shall be
> +Optional rk818 properties:
> +- vcc1-supply:  The input supply for DCDC_REG1
> +- vcc2-supply:  The input supply for DCDC_REG2
> +- vcc3-supply:  The input supply for DCDC_REG3
> +- vcc4-supply:  The input supply for DCDC_REG4
> +- boost-supply: The input supply for DCDC_BOOST
> +- vcc6-supply:  The input supply for LDO_REG1 and LDO_REG2
> +- vcc7-supply:  The input supply for LDO_REG3, LDO_REG5 and LDO_REG7
> +- vcc8-supply:  The input supply for LDO_REG4, LDO_REG6 and LDO_REG8
> +- vcc9-supply:  The input supply for LDO_REG9 and SWITCH_REG
> +- h_5v-supply:  The input supply for HDMI_SWITCH
> +- usb-supply:   The input supply for OTG_SWITCH
> +
> +Regulators: All the regulators of RK8xx to be instantiated shall be
>  listed in a child node named 'regulators'. Each regulator is represented
>  by a child node of the 'regulators' node.
>  
> @@ -48,6 +67,18 @@ number as described in RK808 datasheet.
>  	- SWITCH_REGn
>  		- valid values for n are 1 to 2
>  
> +Following regulators of the RK818 PMIC block are supported. Note that
> +the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
> +number as described in RK818 datasheet.
> +
> +	- DCDC_REGn
> +		- valid values for n are 1 to 4.
> +	- LDO_REGn
> +		- valid values for n are 1 to 9.
> +	- SWITCH_REG
> +	- HDMI_SWITCH
> +	- OTG_SWITCH
> +
>  Standard regulator bindings are used inside regulator subnodes. Check
>    Documentation/devicetree/bindings/regulator/regulator.txt
>  for more details
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-11 15:48     ` Rob Herring
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-04-11 15:48 UTC (permalink / raw)
  To: Wadim Egorov
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	dianders-F7+t8E8rja9g9hUCZPvPmw, zyw-TNX95d0MmH7DzftRWevZcw

On Fri, Apr 08, 2016 at 11:47:41AM +0200, Wadim Egorov wrote:
> Add device tree bindings documentation for rockchip's RK818 pmic.
> 
> Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> index 4ca6aab..8cceb07 100644
> --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> @@ -1,7 +1,11 @@
> -RK808 Power Management Integrated Circuit
> +RK8xx Power Management Integrated Circuit
> +
> +The rk8xx family current members:
> +rk808
> +rk818
>  
>  Required properties:
> -- compatible: "rockchip,rk808"
> +- compatible: "rockchip,rk808", "rockchip,rk818"

Do one per line please.

>  - reg: I2C slave address
>  - interrupt-parent: The parent interrupt controller.
>  - interrupts: the interrupt outputs of the controller.
> @@ -13,6 +17,8 @@ Optional properties:
>    default output clock name
>  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
>    the system power.
> +
> +Optional rk808 properties:
>  - vcc1-supply:  The input supply for DCDC_REG1
>  - vcc2-supply:  The input supply for DCDC_REG2
>  - vcc3-supply:  The input supply for DCDC_REG3
> @@ -29,7 +35,20 @@ Optional properties:
>    the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
>    very quickly with no slow ramp time.
>  
> -Regulators: All the regulators of RK808 to be instantiated shall be
> +Optional rk818 properties:
> +- vcc1-supply:  The input supply for DCDC_REG1
> +- vcc2-supply:  The input supply for DCDC_REG2
> +- vcc3-supply:  The input supply for DCDC_REG3
> +- vcc4-supply:  The input supply for DCDC_REG4
> +- boost-supply: The input supply for DCDC_BOOST
> +- vcc6-supply:  The input supply for LDO_REG1 and LDO_REG2
> +- vcc7-supply:  The input supply for LDO_REG3, LDO_REG5 and LDO_REG7
> +- vcc8-supply:  The input supply for LDO_REG4, LDO_REG6 and LDO_REG8
> +- vcc9-supply:  The input supply for LDO_REG9 and SWITCH_REG
> +- h_5v-supply:  The input supply for HDMI_SWITCH
> +- usb-supply:   The input supply for OTG_SWITCH
> +
> +Regulators: All the regulators of RK8xx to be instantiated shall be
>  listed in a child node named 'regulators'. Each regulator is represented
>  by a child node of the 'regulators' node.
>  
> @@ -48,6 +67,18 @@ number as described in RK808 datasheet.
>  	- SWITCH_REGn
>  		- valid values for n are 1 to 2
>  
> +Following regulators of the RK818 PMIC block are supported. Note that
> +the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
> +number as described in RK818 datasheet.
> +
> +	- DCDC_REGn
> +		- valid values for n are 1 to 4.
> +	- LDO_REGn
> +		- valid values for n are 1 to 9.
> +	- SWITCH_REG
> +	- HDMI_SWITCH
> +	- OTG_SWITCH
> +
>  Standard regulator bindings are used inside regulator subnodes. Check
>    Documentation/devicetree/bindings/regulator/regulator.txt
>  for more details
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
  2016-04-11  8:44     ` Lee Jones
@ 2016-04-11 16:03       ` Rob Herring
  -1 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-04-11 16:03 UTC (permalink / raw)
  To: Lee Jones
  Cc: Wadim Egorov, linux-kernel, linux-rockchip, devicetree,
	pawel.moll, mark.rutland, ijc+devicetree, galak, lgirdwood,
	broonie, dianders, zyw

On Mon, Apr 11, 2016 at 09:44:34AM +0100, Lee Jones wrote:
> On Fri, 08 Apr 2016, Wadim Egorov wrote:
> 
> > Add device tree bindings documentation for rockchip's RK818 pmic.
> > 
> > Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> > ---
> >  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
> >  1 file changed, 34 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> > index 4ca6aab..8cceb07 100644
> > --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> > +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> > @@ -1,7 +1,11 @@
> > -RK808 Power Management Integrated Circuit
> > +RK8xx Power Management Integrated Circuit
> 
> s/xx/XX/

And others say this bikeshed should be lowercase...

I say fine as is for bindings. Uppercase for actual part letters, 
lowercase for wildcards.

> 
> > +The rk8xx family current members:
> > +rk808
> > +rk818
> >  
> >  Required properties:
> > -- compatible: "rockchip,rk808"
> > +- compatible: "rockchip,rk808", "rockchip,rk818"
> >  - reg: I2C slave address
> >  - interrupt-parent: The parent interrupt controller.
> >  - interrupts: the interrupt outputs of the controller.
> > @@ -13,6 +17,8 @@ Optional properties:
> >    default output clock name
> >  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
> >    the system power.
> > +
> > +Optional rk808 properties:
> 
> When mentioning the chip by name, you should always do so using
> uppercase, as it is in the datasheet.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-11 16:03       ` Rob Herring
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-04-11 16:03 UTC (permalink / raw)
  To: Lee Jones
  Cc: Wadim Egorov, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, dianders-F7+t8E8rja9g9hUCZPvPmw,
	zyw-TNX95d0MmH7DzftRWevZcw

On Mon, Apr 11, 2016 at 09:44:34AM +0100, Lee Jones wrote:
> On Fri, 08 Apr 2016, Wadim Egorov wrote:
> 
> > Add device tree bindings documentation for rockchip's RK818 pmic.
> > 
> > Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
> > ---
> >  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
> >  1 file changed, 34 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> > index 4ca6aab..8cceb07 100644
> > --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> > +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> > @@ -1,7 +1,11 @@
> > -RK808 Power Management Integrated Circuit
> > +RK8xx Power Management Integrated Circuit
> 
> s/xx/XX/

And others say this bikeshed should be lowercase...

I say fine as is for bindings. Uppercase for actual part letters, 
lowercase for wildcards.

> 
> > +The rk8xx family current members:
> > +rk808
> > +rk818
> >  
> >  Required properties:
> > -- compatible: "rockchip,rk808"
> > +- compatible: "rockchip,rk808", "rockchip,rk818"
> >  - reg: I2C slave address
> >  - interrupt-parent: The parent interrupt controller.
> >  - interrupts: the interrupt outputs of the controller.
> > @@ -13,6 +17,8 @@ Optional properties:
> >    default output clock name
> >  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
> >    the system power.
> > +
> > +Optional rk808 properties:
> 
> When mentioning the chip by name, you should always do so using
> uppercase, as it is in the datasheet.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
  2016-04-11 16:03       ` Rob Herring
@ 2016-04-11 16:19         ` Lee Jones
  -1 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2016-04-11 16:19 UTC (permalink / raw)
  To: Rob Herring
  Cc: Wadim Egorov, linux-kernel, linux-rockchip, devicetree,
	pawel.moll, mark.rutland, ijc+devicetree, galak, lgirdwood,
	broonie, dianders, zyw

On Mon, 11 Apr 2016, Rob Herring wrote:

> On Mon, Apr 11, 2016 at 09:44:34AM +0100, Lee Jones wrote:
> > On Fri, 08 Apr 2016, Wadim Egorov wrote:
> > 
> > > Add device tree bindings documentation for rockchip's RK818 pmic.
> > > 
> > > Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> > > ---
> > >  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
> > >  1 file changed, 34 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> > > index 4ca6aab..8cceb07 100644
> > > --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> > > +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> > > @@ -1,7 +1,11 @@
> > > -RK808 Power Management Integrated Circuit
> > > +RK8xx Power Management Integrated Circuit
> > 
> > s/xx/XX/
> 
> And others say this bikeshed should be lowercase...
> 
> I say fine as is for bindings. Uppercase for actual part letters, 
> lowercase for wildcards.

Fair enough.

NB: It should be fine to bikeshed on an RFC.  I could understand your
point better if we were coming to completion, or already on v5 or
something.

> > > +The rk8xx family current members:
> > > +rk808
> > > +rk818
> > >  
> > >  Required properties:
> > > -- compatible: "rockchip,rk808"
> > > +- compatible: "rockchip,rk808", "rockchip,rk818"
> > >  - reg: I2C slave address
> > >  - interrupt-parent: The parent interrupt controller.
> > >  - interrupts: the interrupt outputs of the controller.
> > > @@ -13,6 +17,8 @@ Optional properties:
> > >    default output clock name
> > >  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
> > >    the system power.
> > > +
> > > +Optional rk808 properties:
> > 
> > When mentioning the chip by name, you should always do so using
> > uppercase, as it is in the datasheet.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document
@ 2016-04-11 16:19         ` Lee Jones
  0 siblings, 0 replies; 18+ messages in thread
From: Lee Jones @ 2016-04-11 16:19 UTC (permalink / raw)
  To: Rob Herring
  Cc: Wadim Egorov, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, dianders-F7+t8E8rja9g9hUCZPvPmw,
	zyw-TNX95d0MmH7DzftRWevZcw

On Mon, 11 Apr 2016, Rob Herring wrote:

> On Mon, Apr 11, 2016 at 09:44:34AM +0100, Lee Jones wrote:
> > On Fri, 08 Apr 2016, Wadim Egorov wrote:
> > 
> > > Add device tree bindings documentation for rockchip's RK818 pmic.
> > > 
> > > Signed-off-by: Wadim Egorov <w.egorov-guT5V/WYfQezQB+pC5nmwQ@public.gmane.org>
> > > ---
> > >  Documentation/devicetree/bindings/mfd/rk808.txt | 37 +++++++++++++++++++++++--
> > >  1 file changed, 34 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
> > > index 4ca6aab..8cceb07 100644
> > > --- a/Documentation/devicetree/bindings/mfd/rk808.txt
> > > +++ b/Documentation/devicetree/bindings/mfd/rk808.txt
> > > @@ -1,7 +1,11 @@
> > > -RK808 Power Management Integrated Circuit
> > > +RK8xx Power Management Integrated Circuit
> > 
> > s/xx/XX/
> 
> And others say this bikeshed should be lowercase...
> 
> I say fine as is for bindings. Uppercase for actual part letters, 
> lowercase for wildcards.

Fair enough.

NB: It should be fine to bikeshed on an RFC.  I could understand your
point better if we were coming to completion, or already on v5 or
something.

> > > +The rk8xx family current members:
> > > +rk808
> > > +rk818
> > >  
> > >  Required properties:
> > > -- compatible: "rockchip,rk808"
> > > +- compatible: "rockchip,rk808", "rockchip,rk818"
> > >  - reg: I2C slave address
> > >  - interrupt-parent: The parent interrupt controller.
> > >  - interrupts: the interrupt outputs of the controller.
> > > @@ -13,6 +17,8 @@ Optional properties:
> > >    default output clock name
> > >  - rockchip,system-power-controller: Telling whether or not this pmic is controlling
> > >    the system power.
> > > +
> > > +Optional rk808 properties:
> > 
> > When mentioning the chip by name, you should always do so using
> > uppercase, as it is in the datasheet.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-04-11 16:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08  9:47 [RFC 0/3] Add RK818 PMIC support Wadim Egorov
2016-04-08  9:47 ` Wadim Egorov
2016-04-08  9:47 ` [RFC 1/3] mfd: RK808: Add RK818 support Wadim Egorov
2016-04-08  9:47   ` Wadim Egorov
2016-04-11  8:41   ` Lee Jones
2016-04-08  9:47 ` [RFC 2/3] regulator: rk808: Add support for rk818 Wadim Egorov
2016-04-08  9:47   ` Wadim Egorov
2016-04-10 19:04   ` Mark Brown
2016-04-08  9:47 ` [RFC 3/3] mfd: dt-bindings: Add RK818 device tree bindings document Wadim Egorov
2016-04-08  9:47   ` Wadim Egorov
2016-04-11  8:44   ` Lee Jones
2016-04-11  8:44     ` Lee Jones
2016-04-11 16:03     ` Rob Herring
2016-04-11 16:03       ` Rob Herring
2016-04-11 16:19       ` Lee Jones
2016-04-11 16:19         ` Lee Jones
2016-04-11 15:48   ` Rob Herring
2016-04-11 15:48     ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.