aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/db8500-prcmu.c
diff options
context:
space:
mode:
authorMattias Nilsson <mattias.i.nilsson@stericsson.com>2012-01-13 10:20:10 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-03-06 12:46:31 -0500
commitb58d12fe6ccd16030e1a69b5c443075f7bed0f6d (patch)
tree13d9d0047374df218c92ed9f6080c20f1410f321 /drivers/mfd/db8500-prcmu.c
parentc72fe851df21603cd149320df49064eb2f903707 (diff)
mfd: Function for obtaining the db8500 prcmu firmware version
This patch exports a function that can be used to tell which version of the DB8500 PRCMU firmware is available, and revamps the firmware detection code a bit. Reviewed-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com> Reviewed-by: Jonas Aberg <jonas.aberg@stericsson.com> Signed-off-by: Mattias Nilsson <mattias.i.nilsson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/db8500-prcmu.c')
-rw-r--r--drivers/mfd/db8500-prcmu.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index b91196368501..12519935da62 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -39,11 +39,6 @@
39/* Offset for the firmware version within the TCPM */ 39/* Offset for the firmware version within the TCPM */
40#define PRCMU_FW_VERSION_OFFSET 0xA4 40#define PRCMU_FW_VERSION_OFFSET 0xA4
41 41
42/* PRCMU project numbers, defined by PRCMU FW */
43#define PRCMU_PROJECT_ID_8500V1_0 1
44#define PRCMU_PROJECT_ID_8500V2_0 2
45#define PRCMU_PROJECT_ID_8400V2_0 3
46
47/* Index of different voltages to be used when accessing AVSData */ 42/* Index of different voltages to be used when accessing AVSData */
48#define PRCM_AVS_BASE 0x2FC 43#define PRCM_AVS_BASE 0x2FC
49#define PRCM_AVS_VBB_RET (PRCM_AVS_BASE + 0x0) 44#define PRCM_AVS_VBB_RET (PRCM_AVS_BASE + 0x0)
@@ -266,6 +261,11 @@
266#define WAKEUP_BIT_GPIO7 BIT(30) 261#define WAKEUP_BIT_GPIO7 BIT(30)
267#define WAKEUP_BIT_GPIO8 BIT(31) 262#define WAKEUP_BIT_GPIO8 BIT(31)
268 263
264static struct {
265 bool valid;
266 struct prcmu_fw_version version;
267} fw_info;
268
269/* 269/*
270 * This vector maps irq numbers to the bits in the bit field used in 270 * This vector maps irq numbers to the bits in the bit field used in
271 * communication with the PRCMU firmware. 271 * communication with the PRCMU firmware.
@@ -522,14 +522,6 @@ static const char *hwacc_ret_regulator_name[NUM_HW_ACC] = {
522 522
523#define PRCMU_PLLDSI_LOCKP_LOCKED 0x3 523#define PRCMU_PLLDSI_LOCKP_LOCKED 0x3
524 524
525static struct {
526 u8 project_number;
527 u8 api_version;
528 u8 func_version;
529 u8 errata;
530} prcmu_version;
531
532
533int db8500_prcmu_enable_dsipll(void) 525int db8500_prcmu_enable_dsipll(void)
534{ 526{
535 int i; 527 int i;
@@ -619,6 +611,11 @@ void prcmu_disable_spi2(void)
619 spin_unlock_irqrestore(&gpiocr_lock, flags); 611 spin_unlock_irqrestore(&gpiocr_lock, flags);
620} 612}
621 613
614struct prcmu_fw_version *prcmu_get_fw_version(void)
615{
616 return fw_info.valid ? &fw_info.version : NULL;
617}
618
622bool prcmu_has_arm_maxopp(void) 619bool prcmu_has_arm_maxopp(void)
623{ 620{
624 return (readb(tcdm_base + PRCM_AVS_VARM_MAX_OPP) & 621 return (readb(tcdm_base + PRCM_AVS_VARM_MAX_OPP) &
@@ -2077,6 +2074,22 @@ static struct irq_chip prcmu_irq_chip = {
2077 .irq_unmask = prcmu_irq_unmask, 2074 .irq_unmask = prcmu_irq_unmask,
2078}; 2075};
2079 2076
2077static char *fw_project_name(u8 project)
2078{
2079 switch (project) {
2080 case PRCMU_FW_PROJECT_U8500:
2081 return "U8500";
2082 case PRCMU_FW_PROJECT_U8500_C2:
2083 return "U8500 C2";
2084 case PRCMU_FW_PROJECT_U9500:
2085 return "U9500";
2086 case PRCMU_FW_PROJECT_U9500_C2:
2087 return "U9500 C2";
2088 default:
2089 return "Unknown";
2090 }
2091}
2092
2080void __init db8500_prcmu_early_init(void) 2093void __init db8500_prcmu_early_init(void)
2081{ 2094{
2082 unsigned int i; 2095 unsigned int i;
@@ -2086,11 +2099,13 @@ void __init db8500_prcmu_early_init(void)
2086 if (tcpm_base != NULL) { 2099 if (tcpm_base != NULL) {
2087 u32 version; 2100 u32 version;
2088 version = readl(tcpm_base + PRCMU_FW_VERSION_OFFSET); 2101 version = readl(tcpm_base + PRCMU_FW_VERSION_OFFSET);
2089 prcmu_version.project_number = version & 0xFF; 2102 fw_info.version.project = version & 0xFF;
2090 prcmu_version.api_version = (version >> 8) & 0xFF; 2103 fw_info.version.api_version = (version >> 8) & 0xFF;
2091 prcmu_version.func_version = (version >> 16) & 0xFF; 2104 fw_info.version.func_version = (version >> 16) & 0xFF;
2092 prcmu_version.errata = (version >> 24) & 0xFF; 2105 fw_info.version.errata = (version >> 24) & 0xFF;
2093 pr_info("PRCMU firmware version %d.%d.%d\n", 2106 fw_info.valid = true;
2107 pr_info("PRCMU firmware: %s, version %d.%d.%d\n",
2108 fw_project_name(fw_info.version.project),
2094 (version >> 8) & 0xFF, (version >> 16) & 0xFF, 2109 (version >> 8) & 0xFF, (version >> 16) & 0xFF,
2095 (version >> 24) & 0xFF); 2110 (version >> 24) & 0xFF);
2096 iounmap(tcpm_base); 2111 iounmap(tcpm_base);