Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * OMAP Voltage Management Routines
0004  *
0005  * Author: Thara Gopinath   <thara@ti.com>
0006  *
0007  * Copyright (C) 2009 Texas Instruments, Inc.
0008  * Thara Gopinath <thara@ti.com>
0009  */
0010 
0011 #ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
0012 #define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
0013 
0014 #include <linux/err.h>
0015 
0016 #include <linux/platform_data/voltage-omap.h>
0017 
0018 #include "vc.h"
0019 #include "vp.h"
0020 
0021 struct powerdomain;
0022 
0023 /*
0024  * OMAP3 GENERIC setup times. Revisit to see if these needs to be
0025  * passed from board or PMIC file
0026  */
0027 #define OMAP3_CLKSETUP      0xff
0028 #define OMAP3_VOLTOFFSET    0xff
0029 #define OMAP3_VOLTSETUP2    0xff
0030 
0031 /**
0032  * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
0033  * data
0034  * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
0035  * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
0036  * @voltsetup_off_reg: register offset of PRM_VOLTSETUP_OFF from PRM base
0037  *
0038  * XXX What about VOLTOFFSET/VOLTCTRL?
0039  */
0040 struct omap_vfsm_instance {
0041     u32 voltsetup_mask;
0042     u8 voltsetup_reg;
0043     u8 voltsetup_off_reg;
0044 };
0045 
0046 /**
0047  * struct voltagedomain - omap voltage domain global structure.
0048  * @name: Name of the voltage domain which can be used as a unique identifier.
0049  * @scalable: Whether or not this voltage domain is scalable
0050  * @node: list_head linking all voltage domains
0051  * @vc: pointer to VC channel associated with this voltagedomain
0052  * @vp: pointer to VP associated with this voltagedomain
0053  * @read: read a VC/VP register
0054  * @write: write a VC/VP register
0055  * @read: read-modify-write a VC/VP register
0056  * @sys_clk: system clock name/frequency, used for various timing calculations
0057  * @scale: function used to scale the voltage of the voltagedomain
0058  * @nominal_volt: current nominal voltage for this voltage domain
0059  * @volt_data: voltage table having the distinct voltages supported
0060  *             by the domain and other associated per voltage data.
0061  */
0062 struct voltagedomain {
0063     char *name;
0064     bool scalable;
0065     struct list_head node;
0066     struct omap_vc_channel *vc;
0067     const struct omap_vfsm_instance *vfsm;
0068     struct omap_vp_instance *vp;
0069     struct omap_voltdm_pmic *pmic;
0070     struct omap_vp_param *vp_param;
0071     struct omap_vc_param *vc_param;
0072 
0073     /* VC/VP register access functions: SoC specific */
0074     u32 (*read) (u8 offset);
0075     void (*write) (u32 val, u8 offset);
0076     u32 (*rmw)(u32 mask, u32 bits, u8 offset);
0077 
0078     union {
0079         const char *name;
0080         u32 rate;
0081     } sys_clk;
0082 
0083     int (*scale) (struct voltagedomain *voltdm,
0084               unsigned long target_volt);
0085 
0086     u32 nominal_volt;
0087     struct omap_volt_data *volt_data;
0088 };
0089 
0090 /* Min and max voltages from OMAP perspective */
0091 #define OMAP3430_VP1_VLIMITTO_VDDMIN    850000
0092 #define OMAP3430_VP1_VLIMITTO_VDDMAX    1425000
0093 #define OMAP3430_VP2_VLIMITTO_VDDMIN    900000
0094 #define OMAP3430_VP2_VLIMITTO_VDDMAX    1150000
0095 
0096 #define OMAP3630_VP1_VLIMITTO_VDDMIN    900000
0097 #define OMAP3630_VP1_VLIMITTO_VDDMAX    1350000
0098 #define OMAP3630_VP2_VLIMITTO_VDDMIN    900000
0099 #define OMAP3630_VP2_VLIMITTO_VDDMAX    1200000
0100 
0101 #define OMAP4_VP_MPU_VLIMITTO_VDDMIN    830000
0102 #define OMAP4_VP_MPU_VLIMITTO_VDDMAX    1410000
0103 #define OMAP4_VP_IVA_VLIMITTO_VDDMIN    830000
0104 #define OMAP4_VP_IVA_VLIMITTO_VDDMAX    1260000
0105 #define OMAP4_VP_CORE_VLIMITTO_VDDMIN   830000
0106 #define OMAP4_VP_CORE_VLIMITTO_VDDMAX   1200000
0107 
0108 /**
0109  * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
0110  * @slew_rate:  PMIC slew rate (in uv/us)
0111  * @step_size:  PMIC voltage step size (in uv)
0112  * @i2c_slave_addr: I2C slave address of PMIC
0113  * @volt_reg_addr: voltage configuration register address
0114  * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
0115  * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
0116  * @i2c_mcode: master code value for I2C high-speed preamble transmission
0117  * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
0118  * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
0119  */
0120 struct omap_voltdm_pmic {
0121     int slew_rate;
0122     int step_size;
0123     u16 i2c_slave_addr;
0124     u16 volt_reg_addr;
0125     u16 cmd_reg_addr;
0126     u8 vp_erroroffset;
0127     u8 vp_vstepmin;
0128     u8 vp_vstepmax;
0129     u32 vddmin;
0130     u32 vddmax;
0131     u8 vp_timeout_us;
0132     bool i2c_high_speed;
0133     u32 i2c_pad_load;
0134     u8 i2c_mcode;
0135     unsigned long (*vsel_to_uv) (const u8 vsel);
0136     u8 (*uv_to_vsel) (unsigned long uV);
0137 };
0138 
0139 struct omap_vp_param {
0140     u32 vddmax;
0141     u32 vddmin;
0142 };
0143 
0144 struct omap_vc_param {
0145     u32 on;
0146     u32 onlp;
0147     u32 ret;
0148     u32 off;
0149 };
0150 
0151 void omap_voltage_get_volttable(struct voltagedomain *voltdm,
0152         struct omap_volt_data **volt_data);
0153 struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
0154         unsigned long volt);
0155 int omap_voltage_register_pmic(struct voltagedomain *voltdm,
0156                    struct omap_voltdm_pmic *pmic);
0157 int omap_voltage_late_init(void);
0158 
0159 extern void omap2xxx_voltagedomains_init(void);
0160 extern void omap3xxx_voltagedomains_init(void);
0161 extern void omap44xx_voltagedomains_init(void);
0162 extern void omap54xx_voltagedomains_init(void);
0163 
0164 struct voltagedomain *voltdm_lookup(const char *name);
0165 void voltdm_init(struct voltagedomain **voltdm_list);
0166 int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
0167 int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
0168 void voltdm_reset(struct voltagedomain *voltdm);
0169 unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
0170 #endif