2010-05-29 10:32:21 -06:00
|
|
|
/*
|
|
|
|
* OMAP Voltage Management Routines
|
|
|
|
*
|
|
|
|
* Author: Thara Gopinath <thara@ti.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Texas Instruments, Inc.
|
|
|
|
* Thara Gopinath <thara@ti.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
|
|
|
|
#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
|
|
|
|
|
2011-01-05 03:57:04 -07:00
|
|
|
#include <linux/err.h>
|
|
|
|
|
2011-03-10 22:17:45 -07:00
|
|
|
#include "vc.h"
|
|
|
|
#include "vp.h"
|
|
|
|
|
2011-03-16 17:13:15 -06:00
|
|
|
struct powerdomain;
|
|
|
|
|
2011-03-10 22:17:45 -07:00
|
|
|
/* XXX document */
|
2010-05-29 10:32:21 -06:00
|
|
|
#define VOLTSCALE_VPFORCEUPDATE 1
|
|
|
|
#define VOLTSCALE_VCBYPASS 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OMAP3 GENERIC setup times. Revisit to see if these needs to be
|
|
|
|
* passed from board or PMIC file
|
|
|
|
*/
|
|
|
|
#define OMAP3_CLKSETUP 0xff
|
|
|
|
#define OMAP3_VOLTOFFSET 0xff
|
|
|
|
#define OMAP3_VOLTSETUP2 0xff
|
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
struct omap_vdd_info;
|
|
|
|
|
2011-03-10 22:17:45 -07:00
|
|
|
/**
|
2011-03-29 15:36:04 -06:00
|
|
|
* struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
|
2011-03-10 22:17:45 -07:00
|
|
|
* data
|
|
|
|
* @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
|
|
|
|
* @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
|
|
|
|
*
|
|
|
|
* XXX What about VOLTOFFSET/VOLTCTRL?
|
|
|
|
*/
|
2011-03-29 15:36:04 -06:00
|
|
|
struct omap_vfsm_instance {
|
2011-03-10 22:17:45 -07:00
|
|
|
u32 voltsetup_mask;
|
|
|
|
u8 voltsetup_reg;
|
|
|
|
};
|
2010-12-10 10:45:23 -07:00
|
|
|
|
2010-05-29 10:32:21 -06:00
|
|
|
/**
|
|
|
|
* struct voltagedomain - omap voltage domain global structure.
|
2011-03-16 15:25:45 -06:00
|
|
|
* @name: Name of the voltage domain which can be used as a unique identifier.
|
2011-03-23 18:00:21 -06:00
|
|
|
* @scalable: Whether or not this voltage domain is scalable
|
2011-03-16 15:25:45 -06:00
|
|
|
* @node: list_head linking all voltage domains
|
2011-03-16 17:13:15 -06:00
|
|
|
* @pwrdm_list: list_head linking all powerdomains in this voltagedomain
|
2011-03-22 17:14:57 -06:00
|
|
|
* @vc: pointer to VC channel associated with this voltagedomain
|
2011-04-04 16:25:07 -06:00
|
|
|
* @vp: pointer to VP associated with this voltagedomain
|
2011-03-28 11:40:15 -06:00
|
|
|
* @read: read a VC/VP register
|
|
|
|
* @write: write a VC/VP register
|
|
|
|
* @read: read-modify-write a VC/VP register
|
2011-03-16 15:25:45 -06:00
|
|
|
* @vdd: to be removed
|
2010-05-29 10:32:21 -06:00
|
|
|
*/
|
|
|
|
struct voltagedomain {
|
|
|
|
char *name;
|
2011-03-23 18:00:21 -06:00
|
|
|
bool scalable;
|
2011-03-16 15:25:45 -06:00
|
|
|
struct list_head node;
|
2011-03-16 17:13:15 -06:00
|
|
|
struct list_head pwrdm_list;
|
2011-03-22 17:14:57 -06:00
|
|
|
struct omap_vc_channel *vc;
|
2011-03-29 15:36:04 -06:00
|
|
|
const struct omap_vfsm_instance *vfsm;
|
2011-04-04 16:25:07 -06:00
|
|
|
struct omap_vp_instance *vp;
|
2011-03-30 12:01:10 -06:00
|
|
|
struct omap_voltdm_pmic *pmic;
|
2011-03-22 17:14:57 -06:00
|
|
|
|
2011-03-28 11:40:15 -06:00
|
|
|
/* 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);
|
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
struct omap_vdd_info *vdd;
|
2010-05-29 10:32:21 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct omap_volt_data - Omap voltage specific data.
|
|
|
|
* @voltage_nominal: The possible voltage value in uV
|
|
|
|
* @sr_efuse_offs: The offset of the efuse register(from system
|
|
|
|
* control module base address) from where to read
|
|
|
|
* the n-target value for the smartreflex module.
|
|
|
|
* @sr_errminlimit: Error min limit value for smartreflex. This value
|
|
|
|
* differs at differnet opp and thus is linked
|
|
|
|
* with voltage.
|
|
|
|
* @vp_errorgain: Error gain value for the voltage processor. This
|
|
|
|
* field also differs according to the voltage/opp.
|
|
|
|
*/
|
|
|
|
struct omap_volt_data {
|
|
|
|
u32 volt_nominal;
|
|
|
|
u32 sr_efuse_offs;
|
|
|
|
u8 sr_errminlimit;
|
|
|
|
u8 vp_errgain;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-03-30 12:01:10 -06:00
|
|
|
* struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
|
2010-05-29 10:32:21 -06:00
|
|
|
* @slew_rate: PMIC slew rate (in uv/us)
|
|
|
|
* @step_size: PMIC voltage step size (in uv)
|
2011-03-29 15:02:36 -06:00
|
|
|
* @i2c_slave_addr: I2C slave address of PMIC
|
2011-03-22 15:12:37 -06:00
|
|
|
* @volt_reg_addr: voltage configuration register address
|
|
|
|
* @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
|
2011-03-30 17:36:30 -06:00
|
|
|
* @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
|
|
|
|
* @i2c_mcode: master code value for I2C high-speed preamble transmission
|
2011-06-09 12:01:55 -06:00
|
|
|
* @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.
|
2010-05-29 10:32:21 -06:00
|
|
|
*/
|
2011-03-30 12:01:10 -06:00
|
|
|
struct omap_voltdm_pmic {
|
2010-05-29 10:32:21 -06:00
|
|
|
int slew_rate;
|
|
|
|
int step_size;
|
|
|
|
u32 on_volt;
|
|
|
|
u32 onlp_volt;
|
|
|
|
u32 ret_volt;
|
|
|
|
u32 off_volt;
|
|
|
|
u16 volt_setup_time;
|
2011-03-29 15:02:36 -06:00
|
|
|
u16 i2c_slave_addr;
|
2011-06-09 12:01:55 -06:00
|
|
|
u16 volt_reg_addr;
|
|
|
|
u16 cmd_reg_addr;
|
2010-05-29 10:32:21 -06:00
|
|
|
u8 vp_erroroffset;
|
|
|
|
u8 vp_vstepmin;
|
|
|
|
u8 vp_vstepmax;
|
|
|
|
u8 vp_vddmin;
|
|
|
|
u8 vp_vddmax;
|
|
|
|
u8 vp_timeout_us;
|
2011-03-30 17:36:30 -06:00
|
|
|
bool i2c_high_speed;
|
|
|
|
u8 i2c_mcode;
|
2010-05-29 10:32:21 -06:00
|
|
|
unsigned long (*vsel_to_uv) (const u8 vsel);
|
|
|
|
u8 (*uv_to_vsel) (unsigned long uV);
|
|
|
|
};
|
|
|
|
|
2011-03-10 22:17:45 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @vp_rt_data : VP data derived at runtime, not predefined
|
|
|
|
* @curr_volt : current voltage for this vdd.
|
|
|
|
* @volt_scale : API to scale the voltage of the vdd.
|
|
|
|
*/
|
|
|
|
struct omap_vdd_info {
|
|
|
|
struct omap_volt_data *volt_data;
|
|
|
|
struct omap_vp_runtime_data vp_rt_data;
|
|
|
|
u32 curr_volt;
|
2011-03-16 14:35:22 -06:00
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
int (*volt_scale) (struct voltagedomain *voltdm,
|
2011-03-10 22:17:45 -07:00
|
|
|
unsigned long target_volt);
|
|
|
|
};
|
|
|
|
|
2010-05-29 10:32:21 -06:00
|
|
|
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);
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
int omap_voltage_register_pmic(struct voltagedomain *voltdm,
|
2011-03-30 12:01:10 -06:00
|
|
|
struct omap_voltdm_pmic *pmic);
|
2010-05-29 10:32:21 -06:00
|
|
|
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,
|
2011-03-30 12:01:10 -06:00
|
|
|
struct omap_voltdm_pmic *pmic)
|
2011-01-05 03:57:02 -07:00
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-05-29 10:32:21 -06:00
|
|
|
static inline void omap_change_voltscale_method(struct voltagedomain *voltdm,
|
|
|
|
int voltscale_method) {}
|
|
|
|
static inline int omap_voltage_late_init(void)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-23 17:09:41 -06:00
|
|
|
extern void omap2xxx_voltagedomains_init(void);
|
2011-03-16 15:25:45 -06:00
|
|
|
extern void omap3xxx_voltagedomains_init(void);
|
|
|
|
extern void omap44xx_voltagedomains_init(void);
|
|
|
|
|
|
|
|
struct voltagedomain *voltdm_lookup(const char *name);
|
|
|
|
void voltdm_init(struct voltagedomain **voltdm_list);
|
2011-03-16 16:52:47 -06:00
|
|
|
int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
|
2011-03-16 17:13:15 -06:00
|
|
|
int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
|
|
|
|
void *user);
|
|
|
|
int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
|
|
|
|
int (*fn)(struct voltagedomain *voltdm,
|
|
|
|
struct powerdomain *pwrdm));
|
2010-05-29 10:32:21 -06:00
|
|
|
#endif
|