1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * OMAP Voltage Management Routines
5 * Author: Thara Gopinath <thara@ti.com>
7 * Copyright (C) 2009 Texas Instruments, Inc.
8 * Thara Gopinath <thara@ti.com>
11 #ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
12 #define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
14 #include <linux/err.h>
16 #include <linux/platform_data/voltage-omap.h>
24 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
25 * passed from board or PMIC file
27 #define OMAP3_CLKSETUP 0xff
28 #define OMAP3_VOLTOFFSET 0xff
29 #define OMAP3_VOLTSETUP2 0xff
32 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
34 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
35 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
36 * @voltsetup_off_reg: register offset of PRM_VOLTSETUP_OFF from PRM base
38 * XXX What about VOLTOFFSET/VOLTCTRL?
40 struct omap_vfsm_instance
{
47 * struct voltagedomain - omap voltage domain global structure.
48 * @name: Name of the voltage domain which can be used as a unique identifier.
49 * @scalable: Whether or not this voltage domain is scalable
50 * @node: list_head linking all voltage domains
51 * @vc: pointer to VC channel associated with this voltagedomain
52 * @vp: pointer to VP associated with this voltagedomain
53 * @read: read a VC/VP register
54 * @write: write a VC/VP register
55 * @read: read-modify-write a VC/VP register
56 * @sys_clk: system clock name/frequency, used for various timing calculations
57 * @scale: function used to scale the voltage of the voltagedomain
58 * @nominal_volt: current nominal voltage for this voltage domain
59 * @volt_data: voltage table having the distinct voltages supported
60 * by the domain and other associated per voltage data.
62 struct voltagedomain
{
65 struct list_head node
;
66 struct omap_vc_channel
*vc
;
67 const struct omap_vfsm_instance
*vfsm
;
68 struct omap_vp_instance
*vp
;
69 struct omap_voltdm_pmic
*pmic
;
70 struct omap_vp_param
*vp_param
;
71 struct omap_vc_param
*vc_param
;
73 /* VC/VP register access functions: SoC specific */
74 u32 (*read
) (u8 offset
);
75 void (*write
) (u32 val
, u8 offset
);
76 u32 (*rmw
)(u32 mask
, u32 bits
, u8 offset
);
83 int (*scale
) (struct voltagedomain
*voltdm
,
84 unsigned long target_volt
);
87 struct omap_volt_data
*volt_data
;
90 /* Min and max voltages from OMAP perspective */
91 #define OMAP3430_VP1_VLIMITTO_VDDMIN 850000
92 #define OMAP3430_VP1_VLIMITTO_VDDMAX 1425000
93 #define OMAP3430_VP2_VLIMITTO_VDDMIN 900000
94 #define OMAP3430_VP2_VLIMITTO_VDDMAX 1150000
96 #define OMAP3630_VP1_VLIMITTO_VDDMIN 900000
97 #define OMAP3630_VP1_VLIMITTO_VDDMAX 1350000
98 #define OMAP3630_VP2_VLIMITTO_VDDMIN 900000
99 #define OMAP3630_VP2_VLIMITTO_VDDMAX 1200000
101 #define OMAP4_VP_MPU_VLIMITTO_VDDMIN 830000
102 #define OMAP4_VP_MPU_VLIMITTO_VDDMAX 1410000
103 #define OMAP4_VP_IVA_VLIMITTO_VDDMIN 830000
104 #define OMAP4_VP_IVA_VLIMITTO_VDDMAX 1260000
105 #define OMAP4_VP_CORE_VLIMITTO_VDDMIN 830000
106 #define OMAP4_VP_CORE_VLIMITTO_VDDMAX 1200000
109 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
110 * @slew_rate: PMIC slew rate (in uv/us)
111 * @step_size: PMIC voltage step size (in uv)
112 * @i2c_slave_addr: I2C slave address of PMIC
113 * @volt_reg_addr: voltage configuration register address
114 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
115 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
116 * @i2c_mcode: master code value for I2C high-speed preamble transmission
117 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
118 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
120 struct omap_voltdm_pmic
{
135 unsigned long (*vsel_to_uv
) (const u8 vsel
);
136 u8 (*uv_to_vsel
) (unsigned long uV
);
139 struct omap_vp_param
{
144 struct omap_vc_param
{
151 void omap_voltage_get_volttable(struct voltagedomain
*voltdm
,
152 struct omap_volt_data
**volt_data
);
153 struct omap_volt_data
*omap_voltage_get_voltdata(struct voltagedomain
*voltdm
,
155 int omap_voltage_register_pmic(struct voltagedomain
*voltdm
,
156 struct omap_voltdm_pmic
*pmic
);
157 int omap_voltage_late_init(void);
159 extern void omap2xxx_voltagedomains_init(void);
160 extern void omap3xxx_voltagedomains_init(void);
161 extern void omap44xx_voltagedomains_init(void);
162 extern void omap54xx_voltagedomains_init(void);
164 struct voltagedomain
*voltdm_lookup(const char *name
);
165 void voltdm_init(struct voltagedomain
**voltdm_list
);
166 int voltdm_add_pwrdm(struct voltagedomain
*voltdm
, struct powerdomain
*pwrdm
);
167 int voltdm_scale(struct voltagedomain
*voltdm
, unsigned long target_volt
);
168 void voltdm_reset(struct voltagedomain
*voltdm
);
169 unsigned long voltdm_get_voltage(struct voltagedomain
*voltdm
);