* [PATCH 0/2] mfd: tps65910: add support for enabling external 32-kHz oscillator @ 2012-06-28 10:20 Johan Hovold 2012-06-28 10:20 ` [PATCH 1/2] " Johan Hovold ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Johan Hovold @ 2012-06-28 10:20 UTC (permalink / raw) To: Samuel Ortiz Cc: Grant Likely, Rob Herring, devicetree-discuss, linux-kernel, 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. 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(-) -- 1.7.8.6 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] mfd: tps65910: add support for enabling external 32-kHz oscillator 2012-06-28 10:20 [PATCH 0/2] mfd: tps65910: add support for enabling external 32-kHz oscillator Johan Hovold @ 2012-06-28 10:20 ` Johan Hovold 2012-06-28 10:20 ` [PATCH 2/2] mfd: tps65910: add device-tree entry to enable " Johan Hovold [not found] ` <1340878822-28444-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2 siblings, 0 replies; 6+ messages in thread From: Johan Hovold @ 2012-06-28 10:20 UTC (permalink / raw) To: Samuel Ortiz Cc: Grant Likely, Rob Herring, devicetree-discuss, linux-kernel, Johan Hovold 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. Signed-off-by: Johan Hovold <jhovold@gmail.com> --- drivers/mfd/tps65910.c | 21 ++++++++++++++++++++- include/linux/mfd/tps65910.h | 1 + 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index be9e07b..b0526b7d 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -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; diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h index dd8dc0a..a989d2b 100644 --- a/include/linux/mfd/tps65910.h +++ b/include/linux/mfd/tps65910.h @@ -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]; -- 1.7.8.6 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] mfd: tps65910: add device-tree entry to enable external 32-kHz oscillator 2012-06-28 10:20 [PATCH 0/2] mfd: tps65910: add support for enabling external 32-kHz oscillator Johan Hovold 2012-06-28 10:20 ` [PATCH 1/2] " Johan Hovold @ 2012-06-28 10:20 ` Johan Hovold [not found] ` <1340878822-28444-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2 siblings, 0 replies; 6+ messages in thread From: Johan Hovold @ 2012-06-28 10:20 UTC (permalink / raw) To: Samuel Ortiz Cc: Grant Likely, Rob Herring, devicetree-discuss, linux-kernel, Johan Hovold Add device-tree entry to enable external 32-kHz crystal oscillator input. Compile-only tested. Signed-off-by: Johan Hovold <jhovold@gmail.com> --- Documentation/devicetree/bindings/mfd/tps65910.txt | 4 +++- drivers/mfd/tps65910.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/tps65910.txt b/Documentation/devicetree/bindings/mfd/tps65910.txt index 645f5eaa..0f5d9b7 100644 --- a/Documentation/devicetree/bindings/mfd/tps65910.txt +++ b/Documentation/devicetree/bindings/mfd/tps65910.txt @@ -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 { diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index b0526b7d..3f27ea1 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -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; -- 1.7.8.6 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1340878822-28444-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 0/2] mfd: tps65910: add support for enabling external 32-kHz oscillator [not found] ` <1340878822-28444-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2012-07-05 15:23 ` Samuel Ortiz 2012-07-11 13:44 ` [PATCH] mfd: add tps65910 32-kHz-crystal-input init Johan Hovold 0 siblings, 1 reply; 6+ messages in thread From: Samuel Ortiz @ 2012-07-05 15:23 UTC (permalink / raw) To: Johan Hovold Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring Hi Johan, On Thu, Jun 28, 2012 at 12:20:20PM +0200, Johan Hovold wrote: > 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 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. -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mfd: add tps65910 32-kHz-crystal-input init 2012-07-05 15:23 ` [PATCH 0/2] mfd: tps65910: add support for enabling " Samuel Ortiz @ 2012-07-11 13:44 ` Johan Hovold [not found] ` <1342014273-31665-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Johan Hovold @ 2012-07-11 13:44 UTC (permalink / raw) To: Samuel Ortiz Cc: Grant Likely, Rob Herring, devicetree-discuss, linux-kernel, Johan Hovold Replace tps65910_misc_init with a dedicated init function for the 32-kHz-crystal input. Signed-off-by: Johan Hovold <jhovold@gmail.com> --- 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(-) diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index 3f27ea1..1c56379 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -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; -- 1.7.8.6 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1342014273-31665-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] mfd: add tps65910 32-kHz-crystal-input init [not found] ` <1342014273-31665-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2012-07-16 13:43 ` Samuel Ortiz 0 siblings, 0 replies; 6+ messages in thread From: Samuel Ortiz @ 2012-07-16 13:43 UTC (permalink / raw) To: Johan Hovold Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring Hi Johan, On Wed, Jul 11, 2012 at 03:44:33PM +0200, Johan Hovold wrote: > Replace tps65910_misc_init with a dedicated init function for the > 32-kHz-crystal input. > > Signed-off-by: Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > > 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. -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-07-16 13:43 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-28 10:20 [PATCH 0/2] mfd: tps65910: add support for enabling external 32-kHz oscillator Johan Hovold 2012-06-28 10:20 ` [PATCH 1/2] " Johan Hovold 2012-06-28 10:20 ` [PATCH 2/2] mfd: tps65910: add device-tree entry to enable " Johan Hovold [not found] ` <1340878822-28444-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2012-07-05 15:23 ` [PATCH 0/2] mfd: tps65910: add support for enabling " Samuel Ortiz 2012-07-11 13:44 ` [PATCH] mfd: add tps65910 32-kHz-crystal-input init Johan Hovold [not found] ` <1342014273-31665-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2012-07-16 13:43 ` Samuel Ortiz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).