2015-07-16 17:58:16

by Vaibhav Hiremath

[permalink] [raw]
Subject: [PATCH-v3 0/2] mfd: 88pm800: Add 88pm860 device support

88PM860 falls under 88pm800 family of devices, with some feature
additions, for example, support for dual phase on BUCK1.

This patch series, enabled chip ID support for 88pm860 in the driver
and adds Init time configuration support based on chip ID

V2 => V3
=======
Link to V2: https://www.mail-archive.com/[email protected]/msg931170.html

- Mistakenly introduced warning in V2, unused variable 'val'
Fixed it.
Note that no other code change compared to V2.

V1 => V2
========
- Dropped PATCH [03/06 to 06/06]
PATCH [03 & 04]: New clock provider driver is under development for
32KHz clock output enable/disable

PATCH [05 & 06]: Moved to regulator driver and will be part of regulator
changes patch-series, as dual-phase configuration belongs to regulator.

- Added Acked-by of "Krzysztof Kozlowski"

- Added comment into the code for missing init configuration for
88pm800 & 88pm805 device.

TODO:
- Some of init time configurations are common to both 88pm800 and 88pm860
devices, but since I can not validate it, decided to move it to
88pm860 block only.
But if someone is willing to help me in validation, we can move it to
common code later. No issues there.
- Sleep/low-power-mode related configuration is also part of init time,
but since we are too far from sleep mode support and without testing
I do not want add anything, decided to take it later when we actually
start looking at sleep support.
- Init time configuration also includes pinmux setting for the device.
I am working on using pinctrl-single driver to have standard and generic
interface, hopefully it will get handled through pinctrl subsystem.
Link to RFC - https://patches.linaro.org/50604/

Vaibhav Hiremath (2):
mfd: 88pm80x: Add 88pm860 chip type support
mfd: 88pm800: Add init time initial configuration support

drivers/mfd/88pm800.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
drivers/mfd/88pm80x.c | 2 ++
include/linux/mfd/88pm80x.h | 14 +++++++++
3 files changed, 86 insertions(+)

--
1.9.1


2015-07-16 17:58:21

by Vaibhav Hiremath

[permalink] [raw]
Subject: [PATCH-v3 1/2] mfd: 88pm80x: Add 88pm860 chip type support

Add chip identification support for 88PM860 device
to the pm80x_chip_mapping table.

Signed-off-by: Vaibhav Hiremath <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>
---
drivers/mfd/88pm80x.c | 2 ++
include/linux/mfd/88pm80x.h | 1 +
2 files changed, 3 insertions(+)

diff --git a/drivers/mfd/88pm80x.c b/drivers/mfd/88pm80x.c
index 5e72f65..63445ea 100644
--- a/drivers/mfd/88pm80x.c
+++ b/drivers/mfd/88pm80x.c
@@ -33,6 +33,8 @@ static struct pm80x_chip_mapping chip_mapping[] = {
{0x3, CHIP_PM800},
/* 88PM805 chip id number */
{0x0, CHIP_PM805},
+ /* 88PM860 chip id number */
+ {0x4, CHIP_PM860},
};

/*
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h
index 9c5773b..2e25fb1 100644
--- a/include/linux/mfd/88pm80x.h
+++ b/include/linux/mfd/88pm80x.h
@@ -21,6 +21,7 @@ enum {
CHIP_INVALID = 0,
CHIP_PM800,
CHIP_PM805,
+ CHIP_PM860,
CHIP_MAX,
};

--
1.9.1

2015-07-16 17:58:26

by Vaibhav Hiremath

[permalink] [raw]
Subject: [PATCH-v3 2/2] mfd: 88pm800: Add init time initial configuration support

This patch adds init time configuration of 88PM800/805 and
88PM860. It includes,

- Enable BUCK clock gating in low power mode
- Full mode support for BUCK2 and 4
- Enable voltage change (LPF, DVC) in PMIC

Note that both 88PM800 and 88PM860 do share common configurations,
but since I can not validate the configuration on 88PM800,
restricting myself only to 88PM860.
If anyone can validate on 88PM800, we can move common code accordingly.

Signed-off-by: Vaibhav Hiremath <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>
---
drivers/mfd/88pm800.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
include/linux/mfd/88pm80x.h | 13 +++++++++
2 files changed, 83 insertions(+)

diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
index 95c8ad4..f104a32 100644
--- a/drivers/mfd/88pm800.c
+++ b/drivers/mfd/88pm800.c
@@ -521,6 +521,69 @@ out:
return ret;
}

+static int pm800_init_config(struct pm80x_chip *chip, struct device_node *np)
+{
+ int ret;
+
+ /*
+ * Although both 88PM800 & 88PM860 do share some common configurations,
+ * and should have common code wherever possible. But due to lack of
+ * testing on 88pm800/88pm805 device, common code is avoided as of now.
+ *
+ * Once it is tested on 88PM800, it can be moved to common code.
+ */
+ switch (chip->type) {
+ case CHIP_PM800:
+ case CHIP_PM805:
+ break;
+ case CHIP_PM860:
+ /* Enable LDO and BUCK clock gating in low power mode */
+ ret = regmap_update_bits(chip->regmap, PM800_LOW_POWER_CONFIG3,
+ PM800_LDOBK_FREEZE, PM800_LDOBK_FREEZE);
+ if (ret)
+ goto error;
+
+ /* Enable voltage change in pmic, POWER_HOLD = 1 */
+ ret = regmap_update_bits(chip->regmap, PM800_WAKEUP1,
+ PM800_PWR_HOLD_EN, PM800_PWR_HOLD_EN);
+ if (ret)
+ goto error;
+
+ /*
+ * Set buck2 and buck4 driver selection to be full.
+ * The default value is 0, for full drive support
+ * it should be set to 1.
+ * In A1 version it will be set to 1 by default.
+ * To be on safer side, set it explicitly
+ */
+ ret = regmap_update_bits(chip->subchip->regmap_power,
+ PM860_BUCK2_MISC2,
+ PM860_BUCK2_FULL_DRV,
+ PM860_BUCK2_FULL_DRV);
+ if (ret)
+ goto error;
+
+ ret = regmap_update_bits(chip->subchip->regmap_power,
+ PM860_BUCK4_MISC2,
+ PM860_BUCK4_FULL_DRV,
+ PM860_BUCK4_FULL_DRV);
+ if (ret)
+ goto error;
+
+
+ break;
+ default:
+ dev_err(chip->dev, "Unknown device type: %d\n", chip->type);
+ break;
+ }
+
+ return 0;
+
+error:
+ dev_err(chip->dev, "failed to access registers\n");
+ return ret;
+}
+
static int pm800_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -585,6 +648,13 @@ static int pm800_probe(struct i2c_client *client,
if (pdata->plat_config)
pdata->plat_config(chip, pdata);

+ /* common register configurations , init time only */
+ ret = pm800_init_config(chip, np);
+ if (ret) {
+ dev_err(chip->dev, "Failed to configure 88pm800 devices\n");
+ goto err_device_init;
+ }
+
return 0;

err_device_init:
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h
index 2e25fb1..2ef62af 100644
--- a/include/linux/mfd/88pm80x.h
+++ b/include/linux/mfd/88pm80x.h
@@ -74,6 +74,7 @@ enum {

/* Wakeup Registers */
#define PM800_WAKEUP1 (0x0D)
+#define PM800_PWR_HOLD_EN BIT(7)

#define PM800_WAKEUP2 (0x0E)
#define PM800_WAKEUP2_INV_INT BIT(0)
@@ -87,7 +88,10 @@ enum {
/* Referance and low power registers */
#define PM800_LOW_POWER1 (0x20)
#define PM800_LOW_POWER2 (0x21)
+
#define PM800_LOW_POWER_CONFIG3 (0x22)
+#define PM800_LDOBK_FREEZE BIT(7)
+
#define PM800_LOW_POWER_CONFIG4 (0x23)

/* GPIO register */
@@ -279,6 +283,15 @@ enum {
#define PM805_EARPHONE_SETTING (0x29)
#define PM805_AUTO_SEQ_SETTING (0x2A)

+
+/* 88PM860 Registers */
+
+#define PM860_BUCK2_MISC2 (0x7C)
+#define PM860_BUCK2_FULL_DRV BIT(2)
+
+#define PM860_BUCK4_MISC2 (0x82)
+#define PM860_BUCK4_FULL_DRV BIT(2)
+
struct pm80x_rtc_pdata {
int vrtc;
int rtc_wakeup;
--
1.9.1