Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 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 | |
Santosh Shilimkar | faacebc | 2011-01-05 16:27:04 +0530 | [diff] [blame] | 17 | #include <linux/err.h> |
| 18 | |
Arnd Bergmann | 2203747 | 2012-08-24 15:21:06 +0200 | [diff] [blame^] | 19 | #include <linux/platform_data/voltage-omap.h> |
J Keerthy | fa60be6 | 2012-04-25 11:14:31 +0530 | [diff] [blame] | 20 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 21 | #include "vc.h" |
| 22 | #include "vp.h" |
| 23 | |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 24 | struct powerdomain; |
| 25 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 26 | /* XXX document */ |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 27 | #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 Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 38 | /** |
Kevin Hilman | 5892bb1 | 2011-03-29 14:36:04 -0700 | [diff] [blame] | 39 | * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 40 | * data |
| 41 | * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register |
| 42 | * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 43 | * |
| 44 | * XXX What about VOLTOFFSET/VOLTCTRL? |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 45 | */ |
Kevin Hilman | 5892bb1 | 2011-03-29 14:36:04 -0700 | [diff] [blame] | 46 | struct omap_vfsm_instance { |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 47 | u32 voltsetup_mask; |
| 48 | u8 voltsetup_reg; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 49 | }; |
Thara Gopinath | bd38107 | 2010-12-10 23:15:23 +0530 | [diff] [blame] | 50 | |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 51 | /** |
| 52 | * struct voltagedomain - omap voltage domain global structure. |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 53 | * @name: Name of the voltage domain which can be used as a unique identifier. |
Kevin Hilman | 37efca7 | 2011-03-23 17:00:21 -0700 | [diff] [blame] | 54 | * @scalable: Whether or not this voltage domain is scalable |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 55 | * @node: list_head linking all voltage domains |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 56 | * @pwrdm_list: list_head linking all powerdomains in this voltagedomain |
Kevin Hilman | d84adcf | 2011-03-22 16:14:57 -0700 | [diff] [blame] | 57 | * @vc: pointer to VC channel associated with this voltagedomain |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame] | 58 | * @vp: pointer to VP associated with this voltagedomain |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 59 | * @read: read a VC/VP register |
| 60 | * @write: write a VC/VP register |
| 61 | * @read: read-modify-write a VC/VP register |
Kevin Hilman | 0e2f3d9 | 2011-04-04 17:22:28 -0700 | [diff] [blame] | 62 | * @sys_clk: system clock name/frequency, used for various timing calculations |
Kevin Hilman | 0f01565 | 2011-07-14 11:12:32 -0700 | [diff] [blame] | 63 | * @scale: function used to scale the voltage of the voltagedomain |
Kevin Hilman | 7590f60 | 2011-04-05 16:55:22 -0700 | [diff] [blame] | 64 | * @nominal_volt: current nominal voltage for this voltage domain |
Kevin Hilman | e327788 | 2011-07-14 11:29:06 -0700 | [diff] [blame] | 65 | * @volt_data: voltage table having the distinct voltages supported |
| 66 | * by the domain and other associated per voltage data. |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 67 | */ |
| 68 | struct voltagedomain { |
| 69 | char *name; |
Kevin Hilman | 37efca7 | 2011-03-23 17:00:21 -0700 | [diff] [blame] | 70 | bool scalable; |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 71 | struct list_head node; |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 72 | struct list_head pwrdm_list; |
Kevin Hilman | d84adcf | 2011-03-22 16:14:57 -0700 | [diff] [blame] | 73 | struct omap_vc_channel *vc; |
Kevin Hilman | 5892bb1 | 2011-03-29 14:36:04 -0700 | [diff] [blame] | 74 | const struct omap_vfsm_instance *vfsm; |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame] | 75 | struct omap_vp_instance *vp; |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 76 | struct omap_voltdm_pmic *pmic; |
Kevin Hilman | d84adcf | 2011-03-22 16:14:57 -0700 | [diff] [blame] | 77 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 78 | /* VC/VP register access functions: SoC specific */ |
| 79 | u32 (*read) (u8 offset); |
| 80 | void (*write) (u32 val, u8 offset); |
| 81 | u32 (*rmw)(u32 mask, u32 bits, u8 offset); |
| 82 | |
Kevin Hilman | 0e2f3d9 | 2011-04-04 17:22:28 -0700 | [diff] [blame] | 83 | union { |
| 84 | const char *name; |
| 85 | u32 rate; |
| 86 | } sys_clk; |
| 87 | |
Kevin Hilman | 0f01565 | 2011-07-14 11:12:32 -0700 | [diff] [blame] | 88 | int (*scale) (struct voltagedomain *voltdm, |
| 89 | unsigned long target_volt); |
| 90 | |
Kevin Hilman | e327788 | 2011-07-14 11:29:06 -0700 | [diff] [blame] | 91 | u32 nominal_volt; |
| 92 | struct omap_volt_data *volt_data; |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 93 | }; |
| 94 | |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 95 | /** |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 96 | * struct omap_voltdm_pmic - PMIC specific data required by voltage driver. |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 97 | * @slew_rate: PMIC slew rate (in uv/us) |
| 98 | * @step_size: PMIC voltage step size (in uv) |
Kevin Hilman | ba112a4 | 2011-03-29 14:02:36 -0700 | [diff] [blame] | 99 | * @i2c_slave_addr: I2C slave address of PMIC |
Kevin Hilman | e74e440 | 2011-03-22 14:12:37 -0700 | [diff] [blame] | 100 | * @volt_reg_addr: voltage configuration register address |
| 101 | * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address |
Kevin Hilman | f539548 | 2011-03-30 16:36:30 -0700 | [diff] [blame] | 102 | * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC |
| 103 | * @i2c_mcode: master code value for I2C high-speed preamble transmission |
Kevin Hilman | e4e021c | 2011-06-09 11:01:55 -0700 | [diff] [blame] | 104 | * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. |
| 105 | * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 106 | */ |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 107 | struct omap_voltdm_pmic { |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 108 | int slew_rate; |
| 109 | int step_size; |
| 110 | u32 on_volt; |
| 111 | u32 onlp_volt; |
| 112 | u32 ret_volt; |
| 113 | u32 off_volt; |
| 114 | u16 volt_setup_time; |
Kevin Hilman | ba112a4 | 2011-03-29 14:02:36 -0700 | [diff] [blame] | 115 | u16 i2c_slave_addr; |
Kevin Hilman | e4e021c | 2011-06-09 11:01:55 -0700 | [diff] [blame] | 116 | u16 volt_reg_addr; |
| 117 | u16 cmd_reg_addr; |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 118 | u8 vp_erroroffset; |
| 119 | u8 vp_vstepmin; |
| 120 | u8 vp_vstepmax; |
| 121 | u8 vp_vddmin; |
| 122 | u8 vp_vddmax; |
| 123 | u8 vp_timeout_us; |
Kevin Hilman | f539548 | 2011-03-30 16:36:30 -0700 | [diff] [blame] | 124 | bool i2c_high_speed; |
| 125 | u8 i2c_mcode; |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 126 | unsigned long (*vsel_to_uv) (const u8 vsel); |
| 127 | u8 (*uv_to_vsel) (unsigned long uV); |
| 128 | }; |
| 129 | |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 130 | void omap_voltage_get_volttable(struct voltagedomain *voltdm, |
| 131 | struct omap_volt_data **volt_data); |
| 132 | struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm, |
| 133 | unsigned long volt); |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 134 | int omap_voltage_register_pmic(struct voltagedomain *voltdm, |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 135 | struct omap_voltdm_pmic *pmic); |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 136 | void omap_change_voltscale_method(struct voltagedomain *voltdm, |
| 137 | int voltscale_method); |
| 138 | int omap_voltage_late_init(void); |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 139 | |
Kevin Hilman | aae030f | 2011-03-23 16:09:41 -0700 | [diff] [blame] | 140 | extern void omap2xxx_voltagedomains_init(void); |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 141 | extern void omap3xxx_voltagedomains_init(void); |
Vaibhav Hiremath | ce3fc89 | 2012-06-18 00:47:26 -0600 | [diff] [blame] | 142 | extern void am33xx_voltagedomains_init(void); |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 143 | extern void omap44xx_voltagedomains_init(void); |
| 144 | |
| 145 | struct voltagedomain *voltdm_lookup(const char *name); |
| 146 | void voltdm_init(struct voltagedomain **voltdm_list); |
Kevin Hilman | 048a703 | 2011-03-16 15:52:47 -0700 | [diff] [blame] | 147 | int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm); |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 148 | int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user), |
| 149 | void *user); |
| 150 | int voltdm_for_each_pwrdm(struct voltagedomain *voltdm, |
| 151 | int (*fn)(struct voltagedomain *voltdm, |
| 152 | struct powerdomain *pwrdm)); |
Kevin Hilman | 5e5651b | 2011-04-05 16:27:21 -0700 | [diff] [blame] | 153 | int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt); |
| 154 | void voltdm_reset(struct voltagedomain *voltdm); |
Kevin Hilman | d5c1282 | 2011-07-15 16:05:12 -0700 | [diff] [blame] | 155 | unsigned long voltdm_get_voltage(struct voltagedomain *voltdm); |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 156 | #endif |