Skip to contentSkip to conversation

mfd: tps65910: add support for enabling external 32-kHz oscillator

PATCH In review Johan Hovold 2 participants 6 messages Jun 28, 2012 – Jul 16, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mfd: tps65910: add support for enabling external 32-kHz oscillator

These patches (against v3.5-rc4) add support for enabling the external 32-kHz oscillator input in tps6591x devices. Depending on boot-mode, the internal RC-oscillator may be used by default and the external crystal-oscillator input must be enabled by clearing a flag in the device-control register.

These patches are needed in order to get an accurate system clock on boards such as the Craneboard.

Thanks,
Johan

Johan Hovold (2):
mfd: tps65910: add support for enabling external 32-kHz oscillator
mfd: tps65910: add device-tree entry to enable external 32-kHz
oscillator

 Documentation/devicetree/bindings/mfd/tps65910.txt |    4 ++-
 drivers/mfd/tps65910.c                             |   24 +++++++++++++++++++-
 include/linux/mfd/tps65910.h                       |    1 +
 3 files changed, 27 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.8.6
#1 lore raw

PATCH 1/2 mfd: tps65910: add support for enabling external 32-kHz oscillator

Add flag to platform data to enable external 32-kHz crystal oscillator (or square wave) input.

The tps6591x can use either an internal 32-kHz RC oscillator or an external crystal (or square wave) to generate the 32-kHz clock.

The default setting depends on the selected boot mode. In boot mode 00 the internal RC oscillator is used at power-on, but the external crystal oscillator (or square wave) can be enabled by clearing the ck32k_ctrl flag in the device control register.

Note that there is no way to switch from the external crystal oscillator to the internal RC oscillator.

---
 drivers/mfd/tps65910.c       |   21 ++++++++++++++++++++-
 include/linux/mfd/tps65910.h |    1 +
 2 files changed, 21 insertions(+), 1 deletions(-)
drivers/mfd/tps65910.c +20 -1
index be9e07b..b0526b7d 100644
@@ -68,6 +68,25 @@ static const struct regmap_config tps65910_regmap_config = {
 	.cache_type = REGCACHE_RBTREE,
 };
 
+static int __devinit tps65910_misc_init(struct tps65910 *tps65910,
+					struct tps65910_board *pmic_pdata)
+{
+	struct device *dev = tps65910->dev;
+	int ret;
+
+	if (pmic_pdata->en_ck32k_xtal) {
+		ret = tps65910_reg_clear_bits(tps65910,
+						TPS65910_DEVCTRL,
+						DEVCTRL_CK32K_CTRL_MASK);
+		if (ret < 0) {
+			dev_err(dev, "clear ck32k_ctrl failed: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 static int __devinit tps65910_sleepinit(struct tps65910 *tps65910,
 		struct tps65910_board *pmic_pdata)
 {
@@ -243,7 +262,7 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
 	init_data->irq_base = pmic_plat_data->irq_base;
 
 	tps65910_irq_init(tps65910, init_data->irq, init_data);
-
+	tps65910_misc_init(tps65910, pmic_plat_data);
 	tps65910_sleepinit(tps65910, pmic_plat_data);
 
 	return ret;
include/linux/mfd/tps65910.h +1 -0
index dd8dc0a..a989d2b 100644
@@ -807,6 +807,7 @@ struct tps65910_board {
 	int irq_base;
 	int vmbch_threshold;
 	int vmbch2_threshold;
+	bool en_ck32k_xtal;
 	bool en_dev_slp;
 	struct tps65910_sleep_keepon_data *slp_keepon;
 	bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO];
Signature · 1 line
1.7.8.6
#2 lore raw

PATCH 2/2 mfd: tps65910: add device-tree entry to enable external 32-kHz oscillator

In reply to Johan Hovold

Add device-tree entry to enable external 32-kHz crystal oscillator input.

Compile-only tested.

---
 Documentation/devicetree/bindings/mfd/tps65910.txt |    4 +++-
 drivers/mfd/tps65910.c                             |    3 +++
 2 files changed, 6 insertions(+), 1 deletions(-)
Documentation/devicetree/bindings/mfd/tps65910.txt +3 -1
index 645f5eaa..0f5d9b7 100644
@@ -29,6 +29,8 @@ Optional properties:
   comparator. (see VMBCH_VSEL in TPS65910 datasheet)
 - ti,vmbch2-threshold: (tps65911) main battery discharged threshold
   comparator. (see VMBCH_VSEL in TPS65910 datasheet)
+- ti,en-ck32k-xtal: enable external 32-kHz crystal oscillator (see CK32K_CTRL
+  in TPS6591X datasheet)
 - ti,en-gpio-sleep: enable sleep control for gpios
   There should be 9 entries here, one for each gpio.
 
@@ -53,7 +55,7 @@ Example:
 
 		ti,vmbch-threshold = 0;
 		ti,vmbch2-threshold = 0;
-
+		ti,en-ck32k-xtal;
 		ti,en-gpio-sleep = <0 0 1 0 0 0 0 0 0>;
 
 		regulators {
drivers/mfd/tps65910.c +3 -0
index b0526b7d..3f27ea1 100644
@@ -194,6 +194,9 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
 	else if (*chip_id == TPS65911)
 		dev_warn(&client->dev, "VMBCH2-Threshold not specified");
 
+	prop = of_property_read_bool(np, "ti,en-ck32k-xtal");
+	board_info->en_ck32k_xtal = prop;
+
 	board_info->irq = client->irq;
 	board_info->irq_base = -1;
 
Signature · 1 line
1.7.8.6
#3 lore raw
In reply to Johan Hovold

Hi Johan,

Quoted 8 lines · Johan Hovold

These patches (against v3.5-rc4) add support for enabling the external 32-kHz oscillator input in tps6591x devices. Depending on boot-mode, the internal RC-oscillator may be used by default and the external crystal-oscillator input must be enabled by clearing a flag in the device-control register.

These patches are needed in order to get an accurate system clock on boards such as the Craneboard.

Quoted 7 lines

Thanks,
Johan

Johan Hovold (2):
mfd: tps65910: add support for enabling external 32-kHz oscillator
mfd: tps65910: add device-tree entry to enable external 32-kHz
oscillator

Both patches applied, although the misc_init() naming is quite vague. If you can come up with a follow up patch for a better name, I'll take it.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#4 lore raw

PATCH 1/1 mfd: add tps65910 32-kHz-crystal-input init

Replace tps65910_misc_init with a dedicated init function for the 32-kHz-crystal input.

---

Hi Samuel,

How about something like this? My thought with misc_init was that it could be extended should more simple initialisation like for the ck32k_xtal need to be done, but perhaps it's cleaner to stick with dedicated init functions through-out. At least for now.

Thanks,
Johan

 drivers/mfd/tps65910.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)
drivers/mfd/tps65910.c +9 -10
index 3f27ea1..1c56379 100644
@@ -68,20 +68,19 @@ static const struct regmap_config tps65910_regmap_config = {
 	.cache_type = REGCACHE_RBTREE,
 };
 
-static int __devinit tps65910_misc_init(struct tps65910 *tps65910,
+static int __devinit tps65910_ck32k_init(struct tps65910 *tps65910,
 					struct tps65910_board *pmic_pdata)
 {
-	struct device *dev = tps65910->dev;
 	int ret;
 
-	if (pmic_pdata->en_ck32k_xtal) {
-		ret = tps65910_reg_clear_bits(tps65910,
-						TPS65910_DEVCTRL,
+	if (!pmic_pdata->en_ck32k_xtal)
+		return 0;
+
+	ret = tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL,
 						DEVCTRL_CK32K_CTRL_MASK);
-		if (ret < 0) {
-			dev_err(dev, "clear ck32k_ctrl failed: %d\n", ret);
-			return ret;
-		}
+	if (ret < 0) {
+		dev_err(tps65910->dev, "clear ck32k_ctrl failed: %d\n", ret);
+		return ret;
 	}
 
 	return 0;
@@ -265,7 +264,7 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
 	init_data->irq_base = pmic_plat_data->irq_base;
 
 	tps65910_irq_init(tps65910, init_data->irq, init_data);
-	tps65910_misc_init(tps65910, pmic_plat_data);
+	tps65910_ck32k_init(tps65910, pmic_plat_data);
 	tps65910_sleepinit(tps65910, pmic_plat_data);
 
 	return ret;
Signature · 1 line
1.7.8.6
#5 lore raw

Re: [PATCH] mfd: add tps65910 32-kHz-crystal-input init

Hi Johan,

Quoted 4 lines · Johan Hovold

Replace tps65910_misc_init with a dedicated init function for the 32-kHz-crystal input.

Quoted 8 lines

---

Hi Samuel,

How about something like this? My thought with misc_init was that it could be extended should more simple initialisation like for the ck32k_xtal need to be done, but perhaps it's cleaner to stick with dedicated init functions through-out. At least for now.

Yes, it's clearer, at least to me.
I applied this patch, thanks for following up.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/