aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-09-10 06:46:22 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-18 09:44:39 -0400
commit2275c544cb824b469a386e411cbcaa01a19d4f55 (patch)
tree3bc3a273d49bc2b21613721c8e8d91dd54f6db58
parentcdf4b67099ee8e038178a9e7d83c1aa16618c1ca (diff)
mfd: twl-core: Add API to query the HFCLK rate
CFG_BOOT register's HFCLK_FREQ field hold information about the used HFCLK frequency. Add possibility for users to get the configured rate based on this register. This register was configured during boot, without it the chip would not operate correctly, so we can trust on this information. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/mfd/twl-core.c32
-rw-r--r--include/linux/i2c/twl.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 1c32afed28aa..f162b68e78a8 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -552,6 +552,38 @@ int twl_get_version(void)
552} 552}
553EXPORT_SYMBOL_GPL(twl_get_version); 553EXPORT_SYMBOL_GPL(twl_get_version);
554 554
555/**
556 * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.
557 *
558 * Api to get the TWL HFCLK rate based on BOOT_CFG register.
559 */
560int twl_get_hfclk_rate(void)
561{
562 u8 ctrl;
563 int rate;
564
565 twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &ctrl, R_CFG_BOOT);
566
567 switch (ctrl & 0x3) {
568 case HFCLK_FREQ_19p2_MHZ:
569 rate = 19200000;
570 break;
571 case HFCLK_FREQ_26_MHZ:
572 rate = 26000000;
573 break;
574 case HFCLK_FREQ_38p4_MHZ:
575 rate = 38400000;
576 break;
577 default:
578 pr_err("TWL4030: HFCLK is not configured\n");
579 rate = -EINVAL;
580 break;
581 }
582
583 return rate;
584}
585EXPORT_SYMBOL_GPL(twl_get_hfclk_rate);
586
555static struct device * 587static struct device *
556add_numbered_child(unsigned chip, const char *name, int num, 588add_numbered_child(unsigned chip, const char *name, int num,
557 void *pdata, unsigned pdata_len, 589 void *pdata, unsigned pdata_len,
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 7ea898c55a60..ac6488c9f250 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -188,6 +188,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
188 188
189int twl_get_type(void); 189int twl_get_type(void);
190int twl_get_version(void); 190int twl_get_version(void);
191int twl_get_hfclk_rate(void);
191 192
192int twl6030_interrupt_unmask(u8 bit_mask, u8 offset); 193int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
193int twl6030_interrupt_mask(u8 bit_mask, u8 offset); 194int twl6030_interrupt_mask(u8 bit_mask, u8 offset);