Linux Audio

Check our new training course

Loading...
v3.15
 
  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
 17#include <linux/err.h>
 18
 19#include <linux/platform_data/voltage-omap.h>
 20
 21#include "vc.h"
 22#include "vp.h"
 23
 24struct powerdomain;
 25
 26/* XXX document */
 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
 38/**
 39 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
 40 * data
 41 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
 42 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
 43 * @voltsetup_off_reg: register offset of PRM_VOLTSETUP_OFF from PRM base
 44 *
 45 * XXX What about VOLTOFFSET/VOLTCTRL?
 46 */
 47struct omap_vfsm_instance {
 48	u32 voltsetup_mask;
 49	u8 voltsetup_reg;
 50	u8 voltsetup_off_reg;
 51};
 52
 53/**
 54 * struct voltagedomain - omap voltage domain global structure.
 55 * @name: Name of the voltage domain which can be used as a unique identifier.
 56 * @scalable: Whether or not this voltage domain is scalable
 57 * @node: list_head linking all voltage domains
 58 * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
 59 * @vc: pointer to VC channel associated with this voltagedomain
 60 * @vp: pointer to VP associated with this voltagedomain
 61 * @read: read a VC/VP register
 62 * @write: write a VC/VP register
 63 * @read: read-modify-write a VC/VP register
 64 * @sys_clk: system clock name/frequency, used for various timing calculations
 65 * @scale: function used to scale the voltage of the voltagedomain
 66 * @nominal_volt: current nominal voltage for this voltage domain
 67 * @volt_data: voltage table having the distinct voltages supported
 68 *             by the domain and other associated per voltage data.
 69 */
 70struct voltagedomain {
 71	char *name;
 72	bool scalable;
 73	struct list_head node;
 74	struct list_head pwrdm_list;
 75	struct omap_vc_channel *vc;
 76	const struct omap_vfsm_instance *vfsm;
 77	struct omap_vp_instance *vp;
 78	struct omap_voltdm_pmic *pmic;
 79	struct omap_vp_param *vp_param;
 80	struct omap_vc_param *vc_param;
 81
 82	/* VC/VP register access functions: SoC specific */
 83	u32 (*read) (u8 offset);
 84	void (*write) (u32 val, u8 offset);
 85	u32 (*rmw)(u32 mask, u32 bits, u8 offset);
 86
 87	union {
 88		const char *name;
 89		u32 rate;
 90	} sys_clk;
 91
 92	int (*scale) (struct voltagedomain *voltdm,
 93		      unsigned long target_volt);
 94
 95	u32 nominal_volt;
 96	struct omap_volt_data *volt_data;
 97};
 98
 99/* Min and max voltages from OMAP perspective */
100#define OMAP3430_VP1_VLIMITTO_VDDMIN	850000
101#define OMAP3430_VP1_VLIMITTO_VDDMAX	1425000
102#define OMAP3430_VP2_VLIMITTO_VDDMIN	900000
103#define OMAP3430_VP2_VLIMITTO_VDDMAX	1150000
104
105#define OMAP3630_VP1_VLIMITTO_VDDMIN	900000
106#define OMAP3630_VP1_VLIMITTO_VDDMAX	1350000
107#define OMAP3630_VP2_VLIMITTO_VDDMIN	900000
108#define OMAP3630_VP2_VLIMITTO_VDDMAX	1200000
109
110#define OMAP4_VP_MPU_VLIMITTO_VDDMIN	830000
111#define OMAP4_VP_MPU_VLIMITTO_VDDMAX	1410000
112#define OMAP4_VP_IVA_VLIMITTO_VDDMIN	830000
113#define OMAP4_VP_IVA_VLIMITTO_VDDMAX	1260000
114#define OMAP4_VP_CORE_VLIMITTO_VDDMIN	830000
115#define OMAP4_VP_CORE_VLIMITTO_VDDMAX	1200000
116
117/**
118 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
119 * @slew_rate:	PMIC slew rate (in uv/us)
120 * @step_size:	PMIC voltage step size (in uv)
121 * @i2c_slave_addr: I2C slave address of PMIC
122 * @volt_reg_addr: voltage configuration register address
123 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
124 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
125 * @i2c_mcode: master code value for I2C high-speed preamble transmission
126 * @vsel_to_uv:	PMIC API to convert vsel value to actual voltage in uV.
127 * @uv_to_vsel:	PMIC API to convert voltage in uV to vsel value.
128 */
129struct omap_voltdm_pmic {
130	int slew_rate;
131	int step_size;
132	u16 i2c_slave_addr;
133	u16 volt_reg_addr;
134	u16 cmd_reg_addr;
135	u8 vp_erroroffset;
136	u8 vp_vstepmin;
137	u8 vp_vstepmax;
138	u32 vddmin;
139	u32 vddmax;
140	u8 vp_timeout_us;
141	bool i2c_high_speed;
142	u32 i2c_pad_load;
143	u8 i2c_mcode;
144	unsigned long (*vsel_to_uv) (const u8 vsel);
145	u8 (*uv_to_vsel) (unsigned long uV);
146};
147
148struct omap_vp_param {
149	u32 vddmax;
150	u32 vddmin;
151};
152
153struct omap_vc_param {
154	u32 on;
155	u32 onlp;
156	u32 ret;
157	u32 off;
158};
159
160void omap_voltage_get_volttable(struct voltagedomain *voltdm,
161		struct omap_volt_data **volt_data);
162struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
163		unsigned long volt);
164int omap_voltage_register_pmic(struct voltagedomain *voltdm,
165			       struct omap_voltdm_pmic *pmic);
166void omap_change_voltscale_method(struct voltagedomain *voltdm,
167		int voltscale_method);
168int omap_voltage_late_init(void);
169
170extern void omap2xxx_voltagedomains_init(void);
171extern void omap3xxx_voltagedomains_init(void);
172extern void omap44xx_voltagedomains_init(void);
173extern void omap54xx_voltagedomains_init(void);
174
175struct voltagedomain *voltdm_lookup(const char *name);
176void voltdm_init(struct voltagedomain **voltdm_list);
177int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
178int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
179		    void *user);
180int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
181			  int (*fn)(struct voltagedomain *voltdm,
182				    struct powerdomain *pwrdm));
183int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
184void voltdm_reset(struct voltagedomain *voltdm);
185unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
186#endif
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * OMAP Voltage Management Routines
  4 *
  5 * Author: Thara Gopinath	<thara@ti.com>
  6 *
  7 * Copyright (C) 2009 Texas Instruments, Inc.
  8 * Thara Gopinath <thara@ti.com>
 
 
 
 
  9 */
 10
 11#ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
 12#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
 13
 14#include <linux/err.h>
 15
 16#include <linux/platform_data/voltage-omap.h>
 17
 18#include "vc.h"
 19#include "vp.h"
 20
 21struct powerdomain;
 22
 
 
 
 
 23/*
 24 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
 25 * passed from board or PMIC file
 26 */
 27#define OMAP3_CLKSETUP		0xff
 28#define OMAP3_VOLTOFFSET	0xff
 29#define OMAP3_VOLTSETUP2	0xff
 30
 31/**
 32 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
 33 * data
 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
 37 *
 38 * XXX What about VOLTOFFSET/VOLTCTRL?
 39 */
 40struct omap_vfsm_instance {
 41	u32 voltsetup_mask;
 42	u8 voltsetup_reg;
 43	u8 voltsetup_off_reg;
 44};
 45
 46/**
 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.
 61 */
 62struct voltagedomain {
 63	char *name;
 64	bool scalable;
 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;
 72
 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);
 77
 78	union {
 79		const char *name;
 80		u32 rate;
 81	} sys_clk;
 82
 83	int (*scale) (struct voltagedomain *voltdm,
 84		      unsigned long target_volt);
 85
 86	u32 nominal_volt;
 87	struct omap_volt_data *volt_data;
 88};
 89
 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
 95
 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
100
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
107
108/**
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.
119 */
120struct omap_voltdm_pmic {
121	int slew_rate;
122	int step_size;
123	u16 i2c_slave_addr;
124	u16 volt_reg_addr;
125	u16 cmd_reg_addr;
126	u8 vp_erroroffset;
127	u8 vp_vstepmin;
128	u8 vp_vstepmax;
129	u32 vddmin;
130	u32 vddmax;
131	u8 vp_timeout_us;
132	bool i2c_high_speed;
133	u32 i2c_pad_load;
134	u8 i2c_mcode;
135	unsigned long (*vsel_to_uv) (const u8 vsel);
136	u8 (*uv_to_vsel) (unsigned long uV);
137};
138
139struct omap_vp_param {
140	u32 vddmax;
141	u32 vddmin;
142};
143
144struct omap_vc_param {
145	u32 on;
146	u32 onlp;
147	u32 ret;
148	u32 off;
149};
150
151void omap_voltage_get_volttable(struct voltagedomain *voltdm,
152		struct omap_volt_data **volt_data);
153struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
154		unsigned long volt);
155int omap_voltage_register_pmic(struct voltagedomain *voltdm,
156			       struct omap_voltdm_pmic *pmic);
 
 
157int omap_voltage_late_init(void);
158
159extern void omap2xxx_voltagedomains_init(void);
160extern void omap3xxx_voltagedomains_init(void);
161extern void omap44xx_voltagedomains_init(void);
162extern void omap54xx_voltagedomains_init(void);
163
164struct voltagedomain *voltdm_lookup(const char *name);
165void voltdm_init(struct voltagedomain **voltdm_list);
166int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
 
 
 
 
 
167int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
168void voltdm_reset(struct voltagedomain *voltdm);
169unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
170#endif