blob: 025cf164da71ee016f74233e8a20aff95068ce16 [file] [log] [blame]
Paul Walmsleyc0718df2011-03-10 22:17:45 -07001/*
2 * OMAP3/4 Voltage Processor (VP) structure and macro definitions
3 *
4 * Copyright (C) 2007, 2010 Texas Instruments, Inc.
5 * Rajendra Nayak <rnayak@ti.com>
6 * Lesly A M <x0080970@ti.com>
7 * Thara Gopinath <thara@ti.com>
8 *
9 * Copyright (C) 2008, 2011 Nokia Corporation
10 * Kalle Jokiniemi
11 * Paul Walmsley
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License version
15 * 2 as published by the Free Software Foundation.
16 */
17#ifndef __ARCH_ARM_MACH_OMAP2_VP_H
18#define __ARCH_ARM_MACH_OMAP2_VP_H
19
20#include <linux/kernel.h>
21
Kevin Hilman01f48d32011-03-21 14:29:13 -070022struct voltagedomain;
23
Paul Walmsleyc0718df2011-03-10 22:17:45 -070024/* XXX document */
25#define VP_IDLE_TIMEOUT 200
26#define VP_TRANXDONE_TIMEOUT 300
27
28
29/**
30 * struct omap_vp_common_data - register data common to all VDDs
31 * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
32 * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
33 * @vpconfig_timeouten_mask: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
34 * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg
35 * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg
36 * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg
37 * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg
38 * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg
39 * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg
40 * @vpconfig_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
41 * @vpconfig_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
42 * @vpconfig_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
43 * @vpconfig_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
44 * @vpconfig_vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
45 * @vpconfig_vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
46 * @vpconfig_vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
Kevin Hilmana7460daf2011-03-16 13:35:22 -070047 * @prm_mod: PRM module id used for PRM register access
Paul Walmsleyc0718df2011-03-10 22:17:45 -070048 *
49 * XXX It it not necessary to have both a mask and a shift for the same
50 * bitfield - remove one
51 * XXX Many of these fields are wrongly named -- e.g., vpconfig_smps* -- fix!
52 */
53struct omap_vp_common_data {
54 u32 vpconfig_errorgain_mask;
55 u32 vpconfig_initvoltage_mask;
56 u32 vpconfig_timeouten;
57 u32 vpconfig_initvdd;
58 u32 vpconfig_forceupdate;
59 u32 vpconfig_vpenable;
Kevin Hilmana7460daf2011-03-16 13:35:22 -070060 s16 prm_mod;
Paul Walmsleyc0718df2011-03-10 22:17:45 -070061 u8 vpconfig_erroroffset_shift;
62 u8 vpconfig_errorgain_shift;
63 u8 vpconfig_initvoltage_shift;
64 u8 vstepmin_stepmin_shift;
65 u8 vstepmin_smpswaittimemin_shift;
66 u8 vstepmax_stepmax_shift;
67 u8 vstepmax_smpswaittimemax_shift;
68 u8 vlimitto_vddmin_shift;
69 u8 vlimitto_vddmax_shift;
70 u8 vlimitto_timeout_shift;
71};
72
73/**
74 * struct omap_vp_prm_irqst_data - PRM_IRQSTATUS_MPU.VP_TRANXDONE_ST data
Paul Walmsleyc0718df2011-03-10 22:17:45 -070075 * @tranxdone_status: VP_TRANXDONE_ST bitmask in PRM_IRQSTATUS_MPU reg
76 *
Paul Walmsleyc0718df2011-03-10 22:17:45 -070077 * XXX Note that on OMAP3, VP_TRANXDONE interrupt may not work due to a
78 * hardware bug
79 * XXX This structure is probably not needed
80 */
81struct omap_vp_prm_irqst_data {
Paul Walmsleyc0718df2011-03-10 22:17:45 -070082 u32 tranxdone_status;
83};
84
85/**
86 * struct omap_vp_instance_data - VP register offsets (per-VDD)
87 * @vp_common: pointer to struct omap_vp_common_data * for this SoC
88 * @prm_irqst_data: pointer to struct omap_vp_prm_irqst_data for this VDD
89 * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start
90 * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start
91 * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start
92 * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start
93 * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start
94 *
95 * XXX vp_common is probably not needed since it is per-SoC
96 */
97struct omap_vp_instance_data {
98 const struct omap_vp_common_data *vp_common;
99 const struct omap_vp_prm_irqst_data *prm_irqst_data;
100 u8 vpconfig;
101 u8 vstepmin;
102 u8 vstepmax;
103 u8 vlimitto;
104 u8 vstatus;
105 u8 voltage;
106};
107
108/**
109 * struct omap_vp_runtime_data - VP data populated at runtime by code
110 * @vpconfig_erroroffset: value of ERROROFFSET bitfield in PRM_VP*_CONFIG
111 * @vpconfig_errorgain: value of ERRORGAIN bitfield in PRM_VP*_CONFIG
112 * @vstepmin_smpswaittimemin: value of SMPSWAITTIMEMIN bitfield in PRM_VP*_VSTEPMIN
113 * @vstepmax_smpswaittimemax: value of SMPSWAITTIMEMAX bitfield in PRM_VP*_VSTEPMAX
114 * @vlimitto_timeout: value of TIMEOUT bitfield in PRM_VP*_VLIMITTO
115 * @vstepmin_stepmin: value of VSTEPMIN bitfield in PRM_VP*_VSTEPMIN
116 * @vstepmax_stepmax: value of VSTEPMAX bitfield in PRM_VP*_VSTEPMAX
117 * @vlimitto_vddmin: value of VDDMIN bitfield in PRM_VP*_VLIMITTO
118 * @vlimitto_vddmax: value of VDDMAX bitfield in PRM_VP*_VLIMITTO
119 *
120 * XXX Is this structure really needed? Why not just program the
121 * device directly? They are in PRM space, therefore in the WKUP
122 * powerdomain, so register contents should not be lost in off-mode.
123 * XXX Some of these fields are incorrectly named, e.g., vstep*
124 */
125struct omap_vp_runtime_data {
126 u32 vpconfig_erroroffset;
127 u16 vpconfig_errorgain;
128 u16 vstepmin_smpswaittimemin;
129 u16 vstepmax_smpswaittimemax;
130 u16 vlimitto_timeout;
131 u8 vstepmin_stepmin;
132 u8 vstepmax_stepmax;
133 u8 vlimitto_vddmin;
134 u8 vlimitto_vddmax;
135};
136
137extern struct omap_vp_instance_data omap3_vp1_data;
138extern struct omap_vp_instance_data omap3_vp2_data;
139
140extern struct omap_vp_instance_data omap4_vp_mpu_data;
141extern struct omap_vp_instance_data omap4_vp_iva_data;
142extern struct omap_vp_instance_data omap4_vp_core_data;
143
Kevin Hilman01f48d32011-03-21 14:29:13 -0700144void omap_vp_init(struct voltagedomain *voltdm);
145void omap_vp_enable(struct voltagedomain *voltdm);
146void omap_vp_disable(struct voltagedomain *voltdm);
147unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
148int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
149 unsigned long target_volt);
150
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700151#endif