Loading...
1/*
2 * OMAP Voltage Management Routines
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2009 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
15#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
16
17#include <linux/err.h>
18
19#include "vc.h"
20#include "vp.h"
21
22struct powerdomain;
23
24/* XXX document */
25#define VOLTSCALE_VPFORCEUPDATE 1
26#define VOLTSCALE_VCBYPASS 2
27
28/*
29 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
30 * passed from board or PMIC file
31 */
32#define OMAP3_CLKSETUP 0xff
33#define OMAP3_VOLTOFFSET 0xff
34#define OMAP3_VOLTSETUP2 0xff
35
36/**
37 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
38 * data
39 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
40 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
41 *
42 * XXX What about VOLTOFFSET/VOLTCTRL?
43 */
44struct omap_vfsm_instance {
45 u32 voltsetup_mask;
46 u8 voltsetup_reg;
47};
48
49/**
50 * struct voltagedomain - omap voltage domain global structure.
51 * @name: Name of the voltage domain which can be used as a unique identifier.
52 * @scalable: Whether or not this voltage domain is scalable
53 * @node: list_head linking all voltage domains
54 * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
55 * @vc: pointer to VC channel associated with this voltagedomain
56 * @vp: pointer to VP associated with this voltagedomain
57 * @read: read a VC/VP register
58 * @write: write a VC/VP register
59 * @read: read-modify-write a VC/VP register
60 * @sys_clk: system clock name/frequency, used for various timing calculations
61 * @scale: function used to scale the voltage of the voltagedomain
62 * @nominal_volt: current nominal voltage for this voltage domain
63 * @volt_data: voltage table having the distinct voltages supported
64 * by the domain and other associated per voltage data.
65 */
66struct voltagedomain {
67 char *name;
68 bool scalable;
69 struct list_head node;
70 struct list_head pwrdm_list;
71 struct omap_vc_channel *vc;
72 const struct omap_vfsm_instance *vfsm;
73 struct omap_vp_instance *vp;
74 struct omap_voltdm_pmic *pmic;
75
76 /* VC/VP register access functions: SoC specific */
77 u32 (*read) (u8 offset);
78 void (*write) (u32 val, u8 offset);
79 u32 (*rmw)(u32 mask, u32 bits, u8 offset);
80
81 union {
82 const char *name;
83 u32 rate;
84 } sys_clk;
85
86 int (*scale) (struct voltagedomain *voltdm,
87 unsigned long target_volt);
88
89 u32 nominal_volt;
90 struct omap_volt_data *volt_data;
91};
92
93/**
94 * struct omap_volt_data - Omap voltage specific data.
95 * @voltage_nominal: The possible voltage value in uV
96 * @sr_efuse_offs: The offset of the efuse register(from system
97 * control module base address) from where to read
98 * the n-target value for the smartreflex module.
99 * @sr_errminlimit: Error min limit value for smartreflex. This value
100 * differs at differnet opp and thus is linked
101 * with voltage.
102 * @vp_errorgain: Error gain value for the voltage processor. This
103 * field also differs according to the voltage/opp.
104 */
105struct omap_volt_data {
106 u32 volt_nominal;
107 u32 sr_efuse_offs;
108 u8 sr_errminlimit;
109 u8 vp_errgain;
110};
111
112/**
113 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
114 * @slew_rate: PMIC slew rate (in uv/us)
115 * @step_size: PMIC voltage step size (in uv)
116 * @i2c_slave_addr: I2C slave address of PMIC
117 * @volt_reg_addr: voltage configuration register address
118 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
119 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
120 * @i2c_mcode: master code value for I2C high-speed preamble transmission
121 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
122 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
123 */
124struct omap_voltdm_pmic {
125 int slew_rate;
126 int step_size;
127 u32 on_volt;
128 u32 onlp_volt;
129 u32 ret_volt;
130 u32 off_volt;
131 u16 volt_setup_time;
132 u16 i2c_slave_addr;
133 u16 volt_reg_addr;
134 u16 cmd_reg_addr;
135 u8 vp_erroroffset;
136 u8 vp_vstepmin;
137 u8 vp_vstepmax;
138 u8 vp_vddmin;
139 u8 vp_vddmax;
140 u8 vp_timeout_us;
141 bool i2c_high_speed;
142 u8 i2c_mcode;
143 unsigned long (*vsel_to_uv) (const u8 vsel);
144 u8 (*uv_to_vsel) (unsigned long uV);
145};
146
147void omap_voltage_get_volttable(struct voltagedomain *voltdm,
148 struct omap_volt_data **volt_data);
149struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
150 unsigned long volt);
151int omap_voltage_register_pmic(struct voltagedomain *voltdm,
152 struct omap_voltdm_pmic *pmic);
153void omap_change_voltscale_method(struct voltagedomain *voltdm,
154 int voltscale_method);
155int omap_voltage_late_init(void);
156
157extern void omap2xxx_voltagedomains_init(void);
158extern void omap3xxx_voltagedomains_init(void);
159extern void omap44xx_voltagedomains_init(void);
160
161struct voltagedomain *voltdm_lookup(const char *name);
162void voltdm_init(struct voltagedomain **voltdm_list);
163int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
164int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
165 void *user);
166int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
167 int (*fn)(struct voltagedomain *voltdm,
168 struct powerdomain *pwrdm));
169int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
170void voltdm_reset(struct voltagedomain *voltdm);
171unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
172#endif
1/*
2 * OMAP Voltage Management Routines
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2009 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
15#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
16
17#include <linux/err.h>
18
19#include <linux/platform_data/voltage-omap.h>
20
21#include "vc.h"
22#include "vp.h"
23
24struct powerdomain;
25
26/*
27 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
28 * passed from board or PMIC file
29 */
30#define OMAP3_CLKSETUP 0xff
31#define OMAP3_VOLTOFFSET 0xff
32#define OMAP3_VOLTSETUP2 0xff
33
34/**
35 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
36 * data
37 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
38 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
39 * @voltsetup_off_reg: register offset of PRM_VOLTSETUP_OFF from PRM base
40 *
41 * XXX What about VOLTOFFSET/VOLTCTRL?
42 */
43struct omap_vfsm_instance {
44 u32 voltsetup_mask;
45 u8 voltsetup_reg;
46 u8 voltsetup_off_reg;
47};
48
49/**
50 * struct voltagedomain - omap voltage domain global structure.
51 * @name: Name of the voltage domain which can be used as a unique identifier.
52 * @scalable: Whether or not this voltage domain is scalable
53 * @node: list_head linking all voltage domains
54 * @vc: pointer to VC channel associated with this voltagedomain
55 * @vp: pointer to VP associated with this voltagedomain
56 * @read: read a VC/VP register
57 * @write: write a VC/VP register
58 * @read: read-modify-write a VC/VP register
59 * @sys_clk: system clock name/frequency, used for various timing calculations
60 * @scale: function used to scale the voltage of the voltagedomain
61 * @nominal_volt: current nominal voltage for this voltage domain
62 * @volt_data: voltage table having the distinct voltages supported
63 * by the domain and other associated per voltage data.
64 */
65struct voltagedomain {
66 char *name;
67 bool scalable;
68 struct list_head node;
69 struct omap_vc_channel *vc;
70 const struct omap_vfsm_instance *vfsm;
71 struct omap_vp_instance *vp;
72 struct omap_voltdm_pmic *pmic;
73 struct omap_vp_param *vp_param;
74 struct omap_vc_param *vc_param;
75
76 /* VC/VP register access functions: SoC specific */
77 u32 (*read) (u8 offset);
78 void (*write) (u32 val, u8 offset);
79 u32 (*rmw)(u32 mask, u32 bits, u8 offset);
80
81 union {
82 const char *name;
83 u32 rate;
84 } sys_clk;
85
86 int (*scale) (struct voltagedomain *voltdm,
87 unsigned long target_volt);
88
89 u32 nominal_volt;
90 struct omap_volt_data *volt_data;
91};
92
93/* Min and max voltages from OMAP perspective */
94#define OMAP3430_VP1_VLIMITTO_VDDMIN 850000
95#define OMAP3430_VP1_VLIMITTO_VDDMAX 1425000
96#define OMAP3430_VP2_VLIMITTO_VDDMIN 900000
97#define OMAP3430_VP2_VLIMITTO_VDDMAX 1150000
98
99#define OMAP3630_VP1_VLIMITTO_VDDMIN 900000
100#define OMAP3630_VP1_VLIMITTO_VDDMAX 1350000
101#define OMAP3630_VP2_VLIMITTO_VDDMIN 900000
102#define OMAP3630_VP2_VLIMITTO_VDDMAX 1200000
103
104#define OMAP4_VP_MPU_VLIMITTO_VDDMIN 830000
105#define OMAP4_VP_MPU_VLIMITTO_VDDMAX 1410000
106#define OMAP4_VP_IVA_VLIMITTO_VDDMIN 830000
107#define OMAP4_VP_IVA_VLIMITTO_VDDMAX 1260000
108#define OMAP4_VP_CORE_VLIMITTO_VDDMIN 830000
109#define OMAP4_VP_CORE_VLIMITTO_VDDMAX 1200000
110
111/**
112 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
113 * @slew_rate: PMIC slew rate (in uv/us)
114 * @step_size: PMIC voltage step size (in uv)
115 * @i2c_slave_addr: I2C slave address of PMIC
116 * @volt_reg_addr: voltage configuration register address
117 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
118 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
119 * @i2c_mcode: master code value for I2C high-speed preamble transmission
120 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
121 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
122 */
123struct omap_voltdm_pmic {
124 int slew_rate;
125 int step_size;
126 u16 i2c_slave_addr;
127 u16 volt_reg_addr;
128 u16 cmd_reg_addr;
129 u8 vp_erroroffset;
130 u8 vp_vstepmin;
131 u8 vp_vstepmax;
132 u32 vddmin;
133 u32 vddmax;
134 u8 vp_timeout_us;
135 bool i2c_high_speed;
136 u32 i2c_pad_load;
137 u8 i2c_mcode;
138 unsigned long (*vsel_to_uv) (const u8 vsel);
139 u8 (*uv_to_vsel) (unsigned long uV);
140};
141
142struct omap_vp_param {
143 u32 vddmax;
144 u32 vddmin;
145};
146
147struct omap_vc_param {
148 u32 on;
149 u32 onlp;
150 u32 ret;
151 u32 off;
152};
153
154void omap_voltage_get_volttable(struct voltagedomain *voltdm,
155 struct omap_volt_data **volt_data);
156struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
157 unsigned long volt);
158int omap_voltage_register_pmic(struct voltagedomain *voltdm,
159 struct omap_voltdm_pmic *pmic);
160int omap_voltage_late_init(void);
161
162extern void omap2xxx_voltagedomains_init(void);
163extern void omap3xxx_voltagedomains_init(void);
164extern void omap44xx_voltagedomains_init(void);
165extern void omap54xx_voltagedomains_init(void);
166
167struct voltagedomain *voltdm_lookup(const char *name);
168void voltdm_init(struct voltagedomain **voltdm_list);
169int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
170int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
171void voltdm_reset(struct voltagedomain *voltdm);
172unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
173#endif