Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 1 | /* |
| 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 Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 22 | struct voltagedomain; |
| 23 | |
Kevin Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame^] | 24 | /* |
| 25 | * Voltage Processor (VP) identifiers |
| 26 | */ |
| 27 | #define OMAP3_VP_VDD_MPU_ID 0 |
| 28 | #define OMAP3_VP_VDD_CORE_ID 1 |
| 29 | #define OMAP4_VP_VDD_CORE_ID 0 |
| 30 | #define OMAP4_VP_VDD_IVA_ID 1 |
| 31 | #define OMAP4_VP_VDD_MPU_ID 2 |
| 32 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 33 | /* XXX document */ |
| 34 | #define VP_IDLE_TIMEOUT 200 |
| 35 | #define VP_TRANXDONE_TIMEOUT 300 |
| 36 | |
Kevin Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame^] | 37 | /** |
| 38 | * struct omap_vp_ops - per-VP operations |
| 39 | * @check_txdone: check for VP transaction done |
| 40 | * @clear_txdone: clear VP transaction done status |
| 41 | */ |
| 42 | struct omap_vp_ops { |
| 43 | u32 (*check_txdone)(u8 vp_id); |
| 44 | void (*clear_txdone)(u8 vp_id); |
| 45 | }; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * struct omap_vp_common_data - register data common to all VDDs |
| 49 | * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg |
| 50 | * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg |
| 51 | * @vpconfig_timeouten_mask: TIMEOUT bitmask in the PRM_VP*_CONFIG reg |
| 52 | * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg |
| 53 | * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg |
| 54 | * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg |
| 55 | * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg |
| 56 | * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg |
| 57 | * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg |
| 58 | * @vpconfig_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg |
| 59 | * @vpconfig_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg |
| 60 | * @vpconfig_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg |
| 61 | * @vpconfig_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg |
| 62 | * @vpconfig_vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg |
| 63 | * @vpconfig_vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg |
| 64 | * @vpconfig_vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg |
Kevin Hilman | a7460da | 2011-03-16 13:35:22 -0700 | [diff] [blame] | 65 | * @prm_mod: PRM module id used for PRM register access |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 66 | * |
| 67 | * XXX It it not necessary to have both a mask and a shift for the same |
| 68 | * bitfield - remove one |
| 69 | * XXX Many of these fields are wrongly named -- e.g., vpconfig_smps* -- fix! |
| 70 | */ |
| 71 | struct omap_vp_common_data { |
| 72 | u32 vpconfig_errorgain_mask; |
| 73 | u32 vpconfig_initvoltage_mask; |
| 74 | u32 vpconfig_timeouten; |
| 75 | u32 vpconfig_initvdd; |
| 76 | u32 vpconfig_forceupdate; |
| 77 | u32 vpconfig_vpenable; |
Kevin Hilman | a7460da | 2011-03-16 13:35:22 -0700 | [diff] [blame] | 78 | s16 prm_mod; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 79 | u8 vpconfig_erroroffset_shift; |
| 80 | u8 vpconfig_errorgain_shift; |
| 81 | u8 vpconfig_initvoltage_shift; |
| 82 | u8 vstepmin_stepmin_shift; |
| 83 | u8 vstepmin_smpswaittimemin_shift; |
| 84 | u8 vstepmax_stepmax_shift; |
| 85 | u8 vstepmax_smpswaittimemax_shift; |
| 86 | u8 vlimitto_vddmin_shift; |
| 87 | u8 vlimitto_vddmax_shift; |
| 88 | u8 vlimitto_timeout_shift; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 89 | |
Kevin Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame^] | 90 | const struct omap_vp_ops *ops; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | /** |
| 94 | * struct omap_vp_instance_data - VP register offsets (per-VDD) |
| 95 | * @vp_common: pointer to struct omap_vp_common_data * for this SoC |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 96 | * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start |
| 97 | * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start |
| 98 | * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start |
| 99 | * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start |
| 100 | * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start |
Kevin Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame^] | 101 | * @id: Unique identifier for VP instance. |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 102 | * |
| 103 | * XXX vp_common is probably not needed since it is per-SoC |
| 104 | */ |
| 105 | struct omap_vp_instance_data { |
| 106 | const struct omap_vp_common_data *vp_common; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 107 | u8 vpconfig; |
| 108 | u8 vstepmin; |
| 109 | u8 vstepmax; |
| 110 | u8 vlimitto; |
| 111 | u8 vstatus; |
| 112 | u8 voltage; |
Kevin Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame^] | 113 | u8 id; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | /** |
| 117 | * struct omap_vp_runtime_data - VP data populated at runtime by code |
| 118 | * @vpconfig_erroroffset: value of ERROROFFSET bitfield in PRM_VP*_CONFIG |
| 119 | * @vpconfig_errorgain: value of ERRORGAIN bitfield in PRM_VP*_CONFIG |
| 120 | * @vstepmin_smpswaittimemin: value of SMPSWAITTIMEMIN bitfield in PRM_VP*_VSTEPMIN |
| 121 | * @vstepmax_smpswaittimemax: value of SMPSWAITTIMEMAX bitfield in PRM_VP*_VSTEPMAX |
| 122 | * @vlimitto_timeout: value of TIMEOUT bitfield in PRM_VP*_VLIMITTO |
| 123 | * @vstepmin_stepmin: value of VSTEPMIN bitfield in PRM_VP*_VSTEPMIN |
| 124 | * @vstepmax_stepmax: value of VSTEPMAX bitfield in PRM_VP*_VSTEPMAX |
| 125 | * @vlimitto_vddmin: value of VDDMIN bitfield in PRM_VP*_VLIMITTO |
| 126 | * @vlimitto_vddmax: value of VDDMAX bitfield in PRM_VP*_VLIMITTO |
| 127 | * |
| 128 | * XXX Is this structure really needed? Why not just program the |
| 129 | * device directly? They are in PRM space, therefore in the WKUP |
| 130 | * powerdomain, so register contents should not be lost in off-mode. |
| 131 | * XXX Some of these fields are incorrectly named, e.g., vstep* |
| 132 | */ |
| 133 | struct omap_vp_runtime_data { |
| 134 | u32 vpconfig_erroroffset; |
| 135 | u16 vpconfig_errorgain; |
| 136 | u16 vstepmin_smpswaittimemin; |
| 137 | u16 vstepmax_smpswaittimemax; |
| 138 | u16 vlimitto_timeout; |
| 139 | u8 vstepmin_stepmin; |
| 140 | u8 vstepmax_stepmax; |
| 141 | u8 vlimitto_vddmin; |
| 142 | u8 vlimitto_vddmax; |
| 143 | }; |
| 144 | |
| 145 | extern struct omap_vp_instance_data omap3_vp1_data; |
| 146 | extern struct omap_vp_instance_data omap3_vp2_data; |
| 147 | |
| 148 | extern struct omap_vp_instance_data omap4_vp_mpu_data; |
| 149 | extern struct omap_vp_instance_data omap4_vp_iva_data; |
| 150 | extern struct omap_vp_instance_data omap4_vp_core_data; |
| 151 | |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 152 | void omap_vp_init(struct voltagedomain *voltdm); |
| 153 | void omap_vp_enable(struct voltagedomain *voltdm); |
| 154 | void omap_vp_disable(struct voltagedomain *voltdm); |
| 155 | unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm); |
| 156 | int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, |
| 157 | unsigned long target_volt); |
| 158 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 159 | #endif |