blob: 5998eed3a2d2d13943cda2059f5e54abc1ab4a76 [file] [log] [blame]
Thara Gopinath2f34ce82010-05-29 22:02:21 +05301/*
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
Santosh Shilimkarfaacebc2011-01-05 16:27:04 +053017#include <linux/err.h>
18
Arnd Bergmann22037472012-08-24 15:21:06 +020019#include <linux/platform_data/voltage-omap.h>
J Keerthyfa60be62012-04-25 11:14:31 +053020
Paul Walmsleyc0718df2011-03-10 22:17:45 -070021#include "vc.h"
22#include "vp.h"
23
Kevin Hilmane69c22b2011-03-16 16:13:15 -070024struct powerdomain;
25
Paul Walmsleyc0718df2011-03-10 22:17:45 -070026/* XXX document */
Thara Gopinath2f34ce82010-05-29 22:02:21 +053027#define VOLTSCALE_VPFORCEUPDATE 1
28#define VOLTSCALE_VCBYPASS 2
29
30/*
31 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
32 * passed from board or PMIC file
33 */
34#define OMAP3_CLKSETUP 0xff
35#define OMAP3_VOLTOFFSET 0xff
36#define OMAP3_VOLTSETUP2 0xff
37
Paul Walmsleyc0718df2011-03-10 22:17:45 -070038/**
Kevin Hilman5892bb12011-03-29 14:36:04 -070039 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
Paul Walmsleyc0718df2011-03-10 22:17:45 -070040 * data
41 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
42 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
Tero Kristo27c16b72012-09-25 19:33:37 +030043 * @voltsetup_off_reg: register offset of PRM_VOLTSETUP_OFF from PRM base
Paul Walmsleyc0718df2011-03-10 22:17:45 -070044 *
45 * XXX What about VOLTOFFSET/VOLTCTRL?
Paul Walmsleyc0718df2011-03-10 22:17:45 -070046 */
Kevin Hilman5892bb12011-03-29 14:36:04 -070047struct omap_vfsm_instance {
Paul Walmsleyc0718df2011-03-10 22:17:45 -070048 u32 voltsetup_mask;
49 u8 voltsetup_reg;
Tero Kristo27c16b72012-09-25 19:33:37 +030050 u8 voltsetup_off_reg;
Paul Walmsleyc0718df2011-03-10 22:17:45 -070051};
Thara Gopinathbd381072010-12-10 23:15:23 +053052
Thara Gopinath2f34ce82010-05-29 22:02:21 +053053/**
54 * struct voltagedomain - omap voltage domain global structure.
Kevin Hilman81a60482011-03-16 14:25:45 -070055 * @name: Name of the voltage domain which can be used as a unique identifier.
Kevin Hilman37efca72011-03-23 17:00:21 -070056 * @scalable: Whether or not this voltage domain is scalable
Kevin Hilman81a60482011-03-16 14:25:45 -070057 * @node: list_head linking all voltage domains
Kevin Hilmane69c22b2011-03-16 16:13:15 -070058 * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
Kevin Hilmand84adcf2011-03-22 16:14:57 -070059 * @vc: pointer to VC channel associated with this voltagedomain
Kevin Hilmanb7ea8032011-04-04 15:25:07 -070060 * @vp: pointer to VP associated with this voltagedomain
Kevin Hilman4bcc4752011-03-28 10:40:15 -070061 * @read: read a VC/VP register
62 * @write: write a VC/VP register
63 * @read: read-modify-write a VC/VP register
Kevin Hilman0e2f3d92011-04-04 17:22:28 -070064 * @sys_clk: system clock name/frequency, used for various timing calculations
Kevin Hilman0f015652011-07-14 11:12:32 -070065 * @scale: function used to scale the voltage of the voltagedomain
Kevin Hilman7590f602011-04-05 16:55:22 -070066 * @nominal_volt: current nominal voltage for this voltage domain
Kevin Hilmane3277882011-07-14 11:29:06 -070067 * @volt_data: voltage table having the distinct voltages supported
68 * by the domain and other associated per voltage data.
Thara Gopinath2f34ce82010-05-29 22:02:21 +053069 */
70struct voltagedomain {
71 char *name;
Kevin Hilman37efca72011-03-23 17:00:21 -070072 bool scalable;
Kevin Hilman81a60482011-03-16 14:25:45 -070073 struct list_head node;
Kevin Hilmane69c22b2011-03-16 16:13:15 -070074 struct list_head pwrdm_list;
Kevin Hilmand84adcf2011-03-22 16:14:57 -070075 struct omap_vc_channel *vc;
Kevin Hilman5892bb12011-03-29 14:36:04 -070076 const struct omap_vfsm_instance *vfsm;
Kevin Hilmanb7ea8032011-04-04 15:25:07 -070077 struct omap_vp_instance *vp;
Kevin Hilmance8ebe02011-03-30 11:01:10 -070078 struct omap_voltdm_pmic *pmic;
Tero Kristo8b5d8c02012-09-25 19:33:35 +030079 struct omap_vp_param *vp_param;
80 struct omap_vc_param *vc_param;
Kevin Hilmand84adcf2011-03-22 16:14:57 -070081
Kevin Hilman4bcc4752011-03-28 10:40:15 -070082 /* VC/VP register access functions: SoC specific */
83 u32 (*read) (u8 offset);
84 void (*write) (u32 val, u8 offset);
85 u32 (*rmw)(u32 mask, u32 bits, u8 offset);
86
Kevin Hilman0e2f3d92011-04-04 17:22:28 -070087 union {
88 const char *name;
89 u32 rate;
90 } sys_clk;
91
Kevin Hilman0f015652011-07-14 11:12:32 -070092 int (*scale) (struct voltagedomain *voltdm,
93 unsigned long target_volt);
94
Kevin Hilmane3277882011-07-14 11:29:06 -070095 u32 nominal_volt;
96 struct omap_volt_data *volt_data;
Thara Gopinath2f34ce82010-05-29 22:02:21 +053097};
98
Nishanth Menonf2a0dfe2012-09-25 19:33:33 +030099/* Min and max voltages from OMAP perspective */
100#define OMAP3430_VP1_VLIMITTO_VDDMIN 850000
101#define OMAP3430_VP1_VLIMITTO_VDDMAX 1425000
102#define OMAP3430_VP2_VLIMITTO_VDDMIN 900000
103#define OMAP3430_VP2_VLIMITTO_VDDMAX 1150000
104
105#define OMAP3630_VP1_VLIMITTO_VDDMIN 900000
106#define OMAP3630_VP1_VLIMITTO_VDDMAX 1350000
107#define OMAP3630_VP2_VLIMITTO_VDDMIN 900000
108#define OMAP3630_VP2_VLIMITTO_VDDMAX 1200000
109
110#define OMAP4_VP_MPU_VLIMITTO_VDDMIN 830000
111#define OMAP4_VP_MPU_VLIMITTO_VDDMAX 1410000
112#define OMAP4_VP_IVA_VLIMITTO_VDDMIN 830000
113#define OMAP4_VP_IVA_VLIMITTO_VDDMAX 1260000
114#define OMAP4_VP_CORE_VLIMITTO_VDDMIN 830000
115#define OMAP4_VP_CORE_VLIMITTO_VDDMAX 1200000
116
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530117/**
Kevin Hilmance8ebe02011-03-30 11:01:10 -0700118 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530119 * @slew_rate: PMIC slew rate (in uv/us)
120 * @step_size: PMIC voltage step size (in uv)
Kevin Hilmanba112a42011-03-29 14:02:36 -0700121 * @i2c_slave_addr: I2C slave address of PMIC
Kevin Hilmane74e4402011-03-22 14:12:37 -0700122 * @volt_reg_addr: voltage configuration register address
123 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
Kevin Hilmanf5395482011-03-30 16:36:30 -0700124 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
125 * @i2c_mcode: master code value for I2C high-speed preamble transmission
Kevin Hilmane4e021c2011-06-09 11:01:55 -0700126 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
127 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530128 */
Kevin Hilmance8ebe02011-03-30 11:01:10 -0700129struct omap_voltdm_pmic {
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530130 int slew_rate;
131 int step_size;
Kevin Hilmanba112a42011-03-29 14:02:36 -0700132 u16 i2c_slave_addr;
Kevin Hilmane4e021c2011-06-09 11:01:55 -0700133 u16 volt_reg_addr;
134 u16 cmd_reg_addr;
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530135 u8 vp_erroroffset;
136 u8 vp_vstepmin;
137 u8 vp_vstepmax;
Tero Kristob2540122012-09-25 19:33:34 +0300138 u32 vddmin;
139 u32 vddmax;
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530140 u8 vp_timeout_us;
Kevin Hilmanf5395482011-03-30 16:36:30 -0700141 bool i2c_high_speed;
Tero Kristo00bd2282012-09-25 19:33:48 +0300142 u32 i2c_pad_load;
Kevin Hilmanf5395482011-03-30 16:36:30 -0700143 u8 i2c_mcode;
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530144 unsigned long (*vsel_to_uv) (const u8 vsel);
145 u8 (*uv_to_vsel) (unsigned long uV);
146};
147
Tero Kristo8b5d8c02012-09-25 19:33:35 +0300148struct omap_vp_param {
149 u32 vddmax;
150 u32 vddmin;
151};
152
153struct omap_vc_param {
154 u32 on;
155 u32 onlp;
156 u32 ret;
157 u32 off;
158};
159
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530160void omap_voltage_get_volttable(struct voltagedomain *voltdm,
161 struct omap_volt_data **volt_data);
162struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
163 unsigned long volt);
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530164int omap_voltage_register_pmic(struct voltagedomain *voltdm,
Kevin Hilmance8ebe02011-03-30 11:01:10 -0700165 struct omap_voltdm_pmic *pmic);
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530166void omap_change_voltscale_method(struct voltagedomain *voltdm,
167 int voltscale_method);
168int omap_voltage_late_init(void);
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530169
Kevin Hilmanaae030f2011-03-23 16:09:41 -0700170extern void omap2xxx_voltagedomains_init(void);
Kevin Hilman81a60482011-03-16 14:25:45 -0700171extern void omap3xxx_voltagedomains_init(void);
Vaibhav Hiremathce3fc892012-06-18 00:47:26 -0600172extern void am33xx_voltagedomains_init(void);
Kevin Hilman81a60482011-03-16 14:25:45 -0700173extern void omap44xx_voltagedomains_init(void);
Santosh Shilimkar20d49e9cc2013-05-29 12:38:11 -0400174extern void omap54xx_voltagedomains_init(void);
Kevin Hilman81a60482011-03-16 14:25:45 -0700175
176struct voltagedomain *voltdm_lookup(const char *name);
177void voltdm_init(struct voltagedomain **voltdm_list);
Kevin Hilman048a7032011-03-16 15:52:47 -0700178int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
Kevin Hilmane69c22b2011-03-16 16:13:15 -0700179int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
180 void *user);
181int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
182 int (*fn)(struct voltagedomain *voltdm,
183 struct powerdomain *pwrdm));
Kevin Hilman5e5651b2011-04-05 16:27:21 -0700184int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
185void voltdm_reset(struct voltagedomain *voltdm);
Kevin Hilmand5c12822011-07-15 16:05:12 -0700186unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530187#endif