]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mfd: Function for obtaining the db8500 prcmu firmware version
authorMattias Nilsson <mattias.i.nilsson@stericsson.com>
Fri, 13 Jan 2012 15:20:10 +0000 (16:20 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 6 Mar 2012 17:46:31 +0000 (18:46 +0100)
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>
drivers/mfd/db8500-prcmu.c
include/linux/mfd/db8500-prcmu.h

index b91196368501c1e754ecf0dcc0e39de5e948e50f..12519935da62b804d1e027c78511a0ced89514ff 100644 (file)
 /* Offset for the firmware version within the TCPM */
 #define PRCMU_FW_VERSION_OFFSET 0xA4
 
-/* PRCMU project numbers, defined by PRCMU FW */
-#define PRCMU_PROJECT_ID_8500V1_0 1
-#define PRCMU_PROJECT_ID_8500V2_0 2
-#define PRCMU_PROJECT_ID_8400V2_0 3
-
 /* Index of different voltages to be used when accessing AVSData */
 #define PRCM_AVS_BASE          0x2FC
 #define PRCM_AVS_VBB_RET       (PRCM_AVS_BASE + 0x0)
 #define WAKEUP_BIT_GPIO7 BIT(30)
 #define WAKEUP_BIT_GPIO8 BIT(31)
 
+static struct {
+       bool valid;
+       struct prcmu_fw_version version;
+} fw_info;
+
 /*
  * This vector maps irq numbers to the bits in the bit field used in
  * communication with the PRCMU firmware.
@@ -522,14 +522,6 @@ static const char *hwacc_ret_regulator_name[NUM_HW_ACC] = {
 
 #define PRCMU_PLLDSI_LOCKP_LOCKED      0x3
 
-static struct {
-       u8 project_number;
-       u8 api_version;
-       u8 func_version;
-       u8 errata;
-} prcmu_version;
-
-
 int db8500_prcmu_enable_dsipll(void)
 {
        int i;
@@ -619,6 +611,11 @@ void prcmu_disable_spi2(void)
        spin_unlock_irqrestore(&gpiocr_lock, flags);
 }
 
+struct prcmu_fw_version *prcmu_get_fw_version(void)
+{
+       return fw_info.valid ? &fw_info.version : NULL;
+}
+
 bool prcmu_has_arm_maxopp(void)
 {
        return (readb(tcdm_base + PRCM_AVS_VARM_MAX_OPP) &
@@ -2077,6 +2074,22 @@ static struct irq_chip prcmu_irq_chip = {
        .irq_unmask     = prcmu_irq_unmask,
 };
 
+static char *fw_project_name(u8 project)
+{
+       switch (project) {
+       case PRCMU_FW_PROJECT_U8500:
+               return "U8500";
+       case PRCMU_FW_PROJECT_U8500_C2:
+               return "U8500 C2";
+       case PRCMU_FW_PROJECT_U9500:
+               return "U9500";
+       case PRCMU_FW_PROJECT_U9500_C2:
+               return "U9500 C2";
+       default:
+               return "Unknown";
+       }
+}
+
 void __init db8500_prcmu_early_init(void)
 {
        unsigned int i;
@@ -2086,11 +2099,13 @@ void __init db8500_prcmu_early_init(void)
                if (tcpm_base != NULL) {
                        u32 version;
                        version = readl(tcpm_base + PRCMU_FW_VERSION_OFFSET);
-                       prcmu_version.project_number = version & 0xFF;
-                       prcmu_version.api_version = (version >> 8) & 0xFF;
-                       prcmu_version.func_version = (version >> 16) & 0xFF;
-                       prcmu_version.errata = (version >> 24) & 0xFF;
-                       pr_info("PRCMU firmware version %d.%d.%d\n",
+                       fw_info.version.project = version & 0xFF;
+                       fw_info.version.api_version = (version >> 8) & 0xFF;
+                       fw_info.version.func_version = (version >> 16) & 0xFF;
+                       fw_info.version.errata = (version >> 24) & 0xFF;
+                       fw_info.valid = true;
+                       pr_info("PRCMU firmware: %s, version %d.%d.%d\n",
+                               fw_project_name(fw_info.version.project),
                                (version >> 8) & 0xFF, (version >> 16) & 0xFF,
                                (version >> 24) & 0xFF);
                        iounmap(tcpm_base);
index 0dc9017272bc2510d1a54bd89e75513e62d42151..18959171f446b2efa9ed11803262df56b3128e9c 100644 (file)
@@ -493,6 +493,18 @@ struct prcmu_auto_pm_config {
        u8 sva_policy;
 };
 
+#define PRCMU_FW_PROJECT_U8500         2
+#define PRCMU_FW_PROJECT_U9500         4
+#define PRCMU_FW_PROJECT_U8500_C2      7
+#define PRCMU_FW_PROJECT_U9500_C2      11
+
+struct prcmu_fw_version {
+       u8 project;
+       u8 api_version;
+       u8 func_version;
+       u8 errata;
+};
+
 #ifdef CONFIG_MFD_DB8500_PRCMU
 
 void db8500_prcmu_early_init(void);
@@ -502,6 +514,7 @@ enum ap_pwrst prcmu_get_xp70_current_state(void);
 bool prcmu_has_arm_maxopp(void);
 int prcmu_set_ape_opp(u8 opp);
 int prcmu_get_ape_opp(void);
+struct prcmu_fw_version *prcmu_get_fw_version(void);
 int prcmu_request_ape_opp_100_voltage(bool enable);
 int prcmu_release_usb_wakeup_state(void);
 int prcmu_set_ddr_opp(u8 opp);
@@ -573,6 +586,11 @@ static inline bool prcmu_has_arm_maxopp(void)
        return false;
 }
 
+static inline struct prcmu_fw_version *prcmu_get_fw_version(void)
+{
+       return NULL;
+}
+
 static inline int prcmu_set_ape_opp(u8 opp)
 {
        return 0;