Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / arch / arm / mach-omap2 / voltage.h
index 4885764..16a1b09 100644 (file)
@@ -33,23 +33,17 @@ struct powerdomain;
 #define OMAP3_VOLTOFFSET       0xff
 #define OMAP3_VOLTSETUP2       0xff
 
-struct omap_vdd_info;
-
 /**
- * struct omap_vfsm_instance_data - per-voltage manager FSM register/bitfield
+ * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
  * data
  * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
  * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
- * @voltsetup_shift: SETUP_TIME* field shift in the PRM_VOLTSETUP* register
  *
  * XXX What about VOLTOFFSET/VOLTCTRL?
- * XXX It is not necessary to have both a _mask and a _shift for the same
- *     bitfield - remove one!
  */
-struct omap_vfsm_instance_data {
+struct omap_vfsm_instance {
        u32 voltsetup_mask;
        u8 voltsetup_reg;
-       u8 voltsetup_shift;
 };
 
 /**
@@ -59,7 +53,15 @@ struct omap_vfsm_instance_data {
  * @node: list_head linking all voltage domains
  * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
  * @vc: pointer to VC channel associated with this voltagedomain
- * @vdd: to be removed
+ * @vp: pointer to VP associated with this voltagedomain
+ * @read: read a VC/VP register
+ * @write: write a VC/VP register
+ * @read: read-modify-write a VC/VP register
+ * @sys_clk: system clock name/frequency, used for various timing calculations
+ * @scale: function used to scale the voltage of the voltagedomain
+ * @nominal_volt: current nominal voltage for this voltage domain
+ * @volt_data: voltage table having the distinct voltages supported
+ *             by the domain and other associated per voltage data.
  */
 struct voltagedomain {
        char *name;
@@ -67,8 +69,25 @@ struct voltagedomain {
        struct list_head node;
        struct list_head pwrdm_list;
        struct omap_vc_channel *vc;
+       const struct omap_vfsm_instance *vfsm;
+       struct omap_vp_instance *vp;
+       struct omap_voltdm_pmic *pmic;
+
+       /* VC/VP register access functions: SoC specific */
+       u32 (*read) (u8 offset);
+       void (*write) (u32 val, u8 offset);
+       u32 (*rmw)(u32 mask, u32 bits, u8 offset);
+
+       union {
+               const char *name;
+               u32 rate;
+       } sys_clk;
 
-       struct omap_vdd_info *vdd;
+       int (*scale) (struct voltagedomain *voltdm,
+                     unsigned long target_volt);
+
+       u32 nominal_volt;
+       struct omap_volt_data *volt_data;
 };
 
 /**
@@ -91,13 +110,18 @@ struct omap_volt_data {
 };
 
 /**
- * struct omap_volt_pmic_info - PMIC specific data required by voltage driver.
+ * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
  * @slew_rate: PMIC slew rate (in uv/us)
  * @step_size: PMIC voltage step size (in uv)
+ * @i2c_slave_addr: I2C slave address of PMIC
+ * @volt_reg_addr: voltage configuration register address
+ * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
+ * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
+ * @i2c_mcode: master code value for I2C high-speed preamble transmission
  * @vsel_to_uv:        PMIC API to convert vsel value to actual voltage in uV.
  * @uv_to_vsel:        PMIC API to convert voltage in uV to vsel value.
  */
-struct omap_volt_pmic_info {
+struct omap_voltdm_pmic {
        int slew_rate;
        int step_size;
        u32 on_volt;
@@ -105,84 +129,30 @@ struct omap_volt_pmic_info {
        u32 ret_volt;
        u32 off_volt;
        u16 volt_setup_time;
+       u16 i2c_slave_addr;
+       u16 volt_reg_addr;
+       u16 cmd_reg_addr;
        u8 vp_erroroffset;
        u8 vp_vstepmin;
        u8 vp_vstepmax;
        u8 vp_vddmin;
        u8 vp_vddmax;
        u8 vp_timeout_us;
-       u8 i2c_slave_addr;
-       u8 pmic_reg;
+       bool i2c_high_speed;
+       u8 i2c_mcode;
        unsigned long (*vsel_to_uv) (const u8 vsel);
        u8 (*uv_to_vsel) (unsigned long uV);
 };
 
-/**
- * omap_vdd_info - Per Voltage Domain info
- *
- * @volt_data          : voltage table having the distinct voltages supported
- *                       by the domain and other associated per voltage data.
- * @pmic_info          : pmic specific parameters which should be populted by
- *                       the pmic drivers.
- * @vp_data            : the register values, shifts, masks for various
- *                       vp registers
- * @vp_rt_data          : VP data derived at runtime, not predefined
- * @vfsm                : voltage manager FSM data
- * @debug_dir          : debug directory for this voltage domain.
- * @curr_volt          : current voltage for this vdd.
- * @prm_irqst_mod       : PRM module id used for PRM IRQ status register access
- * @vp_enabled         : flag to keep track of whether vp is enabled or not
- * @volt_scale         : API to scale the voltage of the vdd.
- */
-struct omap_vdd_info {
-       struct omap_volt_data *volt_data;
-       struct omap_volt_pmic_info *pmic_info;
-       struct omap_vp_instance_data *vp_data;
-       struct omap_vp_runtime_data vp_rt_data;
-       const struct omap_vfsm_instance_data *vfsm;
-       struct dentry *debug_dir;
-       u32 curr_volt;
-       bool vp_enabled;
-
-       s16 prm_irqst_mod;
-       u8 prm_irqst_reg;
-       u32 (*read_reg) (u16 mod, u8 offset);
-       void (*write_reg) (u32 val, u16 mod, u8 offset);
-       int (*volt_scale) (struct voltagedomain *voltdm,
-               unsigned long target_volt);
-};
-
-unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
-void omap_vp_enable(struct voltagedomain *voltdm);
-void omap_vp_disable(struct voltagedomain *voltdm);
-int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
-               unsigned long target_volt);
-void omap_voltage_reset(struct voltagedomain *voltdm);
 void omap_voltage_get_volttable(struct voltagedomain *voltdm,
                struct omap_volt_data **volt_data);
 struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
                unsigned long volt);
-unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
-struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm);
-#ifdef CONFIG_PM
 int omap_voltage_register_pmic(struct voltagedomain *voltdm,
-               struct omap_volt_pmic_info *pmic_info);
+                              struct omap_voltdm_pmic *pmic);
 void omap_change_voltscale_method(struct voltagedomain *voltdm,
                int voltscale_method);
 int omap_voltage_late_init(void);
-#else
-static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
-               struct omap_volt_pmic_info *pmic_info)
-{
-       return -EINVAL;
-}
-static inline  void omap_change_voltscale_method(struct voltagedomain *voltdm,
-               int voltscale_method) {}
-static inline int omap_voltage_late_init(void)
-{
-       return -EINVAL;
-}
-#endif
 
 extern void omap2xxx_voltagedomains_init(void);
 extern void omap3xxx_voltagedomains_init(void);
@@ -196,4 +166,7 @@ int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
 int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
                          int (*fn)(struct voltagedomain *voltdm,
                                    struct powerdomain *pwrdm));
+int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
+void voltdm_reset(struct voltagedomain *voltdm);
+unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
 #endif