2010-12-10 10:21:05 -07:00
|
|
|
/**
|
2017-02-27 15:29:20 -07:00
|
|
|
* OMAP and TWL PMIC specific initializations.
|
2010-12-10 10:21:05 -07:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Texas Instruments Incorporated.
|
|
|
|
* Thara Gopinath
|
|
|
|
* Copyright (C) 2009 Texas Instruments Incorporated.
|
|
|
|
* Nishanth Menon
|
|
|
|
* Copyright (C) 2009 Nokia Corporation
|
|
|
|
* Paul Walmsley
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/kernel.h>
|
2010-12-10 10:45:16 -07:00
|
|
|
#include <linux/i2c/twl.h>
|
2010-12-10 10:21:05 -07:00
|
|
|
|
2012-10-05 14:25:59 -06:00
|
|
|
#include "soc.h"
|
2011-02-25 15:54:33 -07:00
|
|
|
#include "voltage.h"
|
2010-12-10 10:21:05 -07:00
|
|
|
|
2011-01-03 11:58:30 -07:00
|
|
|
#include "pm.h"
|
|
|
|
|
2010-12-10 10:21:05 -07:00
|
|
|
#define OMAP3_SRI2C_SLAVE_ADDR 0x12
|
|
|
|
#define OMAP3_VDD_MPU_SR_CONTROL_REG 0x00
|
|
|
|
#define OMAP3_VDD_CORE_SR_CONTROL_REG 0x01
|
|
|
|
#define OMAP3_VP_CONFIG_ERROROFFSET 0x00
|
|
|
|
#define OMAP3_VP_VSTEPMIN_VSTEPMIN 0x1
|
|
|
|
#define OMAP3_VP_VSTEPMAX_VSTEPMAX 0x04
|
|
|
|
#define OMAP3_VP_VLIMITTO_TIMEOUT_US 200
|
|
|
|
|
2010-12-10 10:45:16 -07:00
|
|
|
#define OMAP4_SRI2C_SLAVE_ADDR 0x12
|
|
|
|
#define OMAP4_VDD_MPU_SR_VOLT_REG 0x55
|
2011-05-17 23:17:34 -06:00
|
|
|
#define OMAP4_VDD_MPU_SR_CMD_REG 0x56
|
2010-12-10 10:45:16 -07:00
|
|
|
#define OMAP4_VDD_IVA_SR_VOLT_REG 0x5B
|
2011-05-17 23:17:34 -06:00
|
|
|
#define OMAP4_VDD_IVA_SR_CMD_REG 0x5C
|
2010-12-10 10:45:16 -07:00
|
|
|
#define OMAP4_VDD_CORE_SR_VOLT_REG 0x61
|
2011-05-17 23:17:34 -06:00
|
|
|
#define OMAP4_VDD_CORE_SR_CMD_REG 0x62
|
2010-12-10 10:45:16 -07:00
|
|
|
|
|
|
|
#define OMAP4_VP_CONFIG_ERROROFFSET 0x00
|
|
|
|
#define OMAP4_VP_VSTEPMIN_VSTEPMIN 0x01
|
|
|
|
#define OMAP4_VP_VSTEPMAX_VSTEPMAX 0x04
|
|
|
|
#define OMAP4_VP_VLIMITTO_TIMEOUT_US 200
|
|
|
|
|
|
|
|
static bool is_offset_valid;
|
|
|
|
static u8 smps_offset;
|
|
|
|
|
|
|
|
#define REG_SMPS_OFFSET 0xE0
|
|
|
|
|
2011-01-03 11:58:29 -07:00
|
|
|
static unsigned long twl4030_vsel_to_uv(const u8 vsel)
|
2010-12-10 10:21:05 -07:00
|
|
|
{
|
|
|
|
return (((vsel * 125) + 6000)) * 100;
|
|
|
|
}
|
|
|
|
|
2011-01-03 11:58:29 -07:00
|
|
|
static u8 twl4030_uv_to_vsel(unsigned long uv)
|
2010-12-10 10:21:05 -07:00
|
|
|
{
|
|
|
|
return DIV_ROUND_UP(uv - 600000, 12500);
|
|
|
|
}
|
|
|
|
|
2011-01-03 11:58:29 -07:00
|
|
|
static unsigned long twl6030_vsel_to_uv(const u8 vsel)
|
2010-12-10 10:45:16 -07:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* In TWL6030 depending on the value of SMPS_OFFSET
|
|
|
|
* efuse register the voltage range supported in
|
|
|
|
* standard mode can be either between 0.6V - 1.3V or
|
|
|
|
* 0.7V - 1.4V. In TWL6030 ES1.0 SMPS_OFFSET efuse
|
|
|
|
* is programmed to all 0's where as starting from
|
|
|
|
* TWL6030 ES1.1 the efuse is programmed to 1
|
|
|
|
*/
|
|
|
|
if (!is_offset_valid) {
|
|
|
|
twl_i2c_read_u8(TWL6030_MODULE_ID0, &smps_offset,
|
|
|
|
REG_SMPS_OFFSET);
|
|
|
|
is_offset_valid = true;
|
|
|
|
}
|
|
|
|
|
2011-05-17 23:17:32 -06:00
|
|
|
if (!vsel)
|
|
|
|
return 0;
|
2010-12-10 10:45:16 -07:00
|
|
|
/*
|
|
|
|
* There is no specific formula for voltage to vsel
|
|
|
|
* conversion above 1.3V. There are special hardcoded
|
|
|
|
* values for voltages above 1.3V. Currently we are
|
|
|
|
* hardcoding only for 1.35 V which is used for 1GH OPP for
|
|
|
|
* OMAP4430.
|
|
|
|
*/
|
|
|
|
if (vsel == 0x3A)
|
|
|
|
return 1350000;
|
|
|
|
|
|
|
|
if (smps_offset & 0x8)
|
2011-05-17 23:17:30 -06:00
|
|
|
return ((((vsel - 1) * 1266) + 70900)) * 10;
|
2010-12-10 10:45:16 -07:00
|
|
|
else
|
2011-05-17 23:17:30 -06:00
|
|
|
return ((((vsel - 1) * 1266) + 60770)) * 10;
|
2010-12-10 10:45:16 -07:00
|
|
|
}
|
|
|
|
|
2011-01-03 11:58:29 -07:00
|
|
|
static u8 twl6030_uv_to_vsel(unsigned long uv)
|
2010-12-10 10:45:16 -07:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* In TWL6030 depending on the value of SMPS_OFFSET
|
|
|
|
* efuse register the voltage range supported in
|
|
|
|
* standard mode can be either between 0.6V - 1.3V or
|
|
|
|
* 0.7V - 1.4V. In TWL6030 ES1.0 SMPS_OFFSET efuse
|
|
|
|
* is programmed to all 0's where as starting from
|
|
|
|
* TWL6030 ES1.1 the efuse is programmed to 1
|
|
|
|
*/
|
|
|
|
if (!is_offset_valid) {
|
|
|
|
twl_i2c_read_u8(TWL6030_MODULE_ID0, &smps_offset,
|
|
|
|
REG_SMPS_OFFSET);
|
|
|
|
is_offset_valid = true;
|
|
|
|
}
|
|
|
|
|
2011-05-17 23:17:32 -06:00
|
|
|
if (!uv)
|
|
|
|
return 0x00;
|
2010-12-10 10:45:16 -07:00
|
|
|
/*
|
|
|
|
* There is no specific formula for voltage to vsel
|
|
|
|
* conversion above 1.3V. There are special hardcoded
|
|
|
|
* values for voltages above 1.3V. Currently we are
|
|
|
|
* hardcoding only for 1.35 V which is used for 1GH OPP for
|
|
|
|
* OMAP4430.
|
|
|
|
*/
|
2011-05-17 23:17:31 -06:00
|
|
|
if (uv > twl6030_vsel_to_uv(0x39)) {
|
|
|
|
if (uv == 1350000)
|
|
|
|
return 0x3A;
|
|
|
|
pr_err("%s:OUT OF RANGE! non mapped vsel for %ld Vs max %ld\n",
|
|
|
|
__func__, uv, twl6030_vsel_to_uv(0x39));
|
2010-12-10 10:45:16 -07:00
|
|
|
return 0x3A;
|
2011-05-17 23:17:31 -06:00
|
|
|
}
|
2010-12-10 10:45:16 -07:00
|
|
|
|
|
|
|
if (smps_offset & 0x8)
|
2011-05-17 23:17:30 -06:00
|
|
|
return DIV_ROUND_UP(uv - 709000, 12660) + 1;
|
2010-12-10 10:45:16 -07:00
|
|
|
else
|
2011-05-17 23:17:30 -06:00
|
|
|
return DIV_ROUND_UP(uv - 607700, 12660) + 1;
|
2010-12-10 10:45:16 -07:00
|
|
|
}
|
|
|
|
|
2011-03-30 12:01:10 -06:00
|
|
|
static struct omap_voltdm_pmic omap3_mpu_pmic = {
|
2010-12-10 10:21:05 -07:00
|
|
|
.slew_rate = 4000,
|
|
|
|
.step_size = 12500,
|
|
|
|
.vp_erroroffset = OMAP3_VP_CONFIG_ERROROFFSET,
|
|
|
|
.vp_vstepmin = OMAP3_VP_VSTEPMIN_VSTEPMIN,
|
|
|
|
.vp_vstepmax = OMAP3_VP_VSTEPMAX_VSTEPMAX,
|
2012-09-25 10:33:42 -06:00
|
|
|
.vddmin = 600000,
|
|
|
|
.vddmax = 1450000,
|
2010-12-10 10:21:05 -07:00
|
|
|
.vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US,
|
|
|
|
.i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR,
|
2011-03-22 15:12:37 -06:00
|
|
|
.volt_reg_addr = OMAP3_VDD_MPU_SR_CONTROL_REG,
|
2011-03-30 17:36:30 -06:00
|
|
|
.i2c_high_speed = true,
|
2010-12-10 10:21:05 -07:00
|
|
|
.vsel_to_uv = twl4030_vsel_to_uv,
|
|
|
|
.uv_to_vsel = twl4030_uv_to_vsel,
|
|
|
|
};
|
|
|
|
|
2011-03-30 12:01:10 -06:00
|
|
|
static struct omap_voltdm_pmic omap3_core_pmic = {
|
2010-12-10 10:21:05 -07:00
|
|
|
.slew_rate = 4000,
|
|
|
|
.step_size = 12500,
|
|
|
|
.vp_erroroffset = OMAP3_VP_CONFIG_ERROROFFSET,
|
|
|
|
.vp_vstepmin = OMAP3_VP_VSTEPMIN_VSTEPMIN,
|
|
|
|
.vp_vstepmax = OMAP3_VP_VSTEPMAX_VSTEPMAX,
|
2012-09-25 10:33:42 -06:00
|
|
|
.vddmin = 600000,
|
|
|
|
.vddmax = 1450000,
|
2010-12-10 10:21:05 -07:00
|
|
|
.vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US,
|
|
|
|
.i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR,
|
2011-03-22 15:12:37 -06:00
|
|
|
.volt_reg_addr = OMAP3_VDD_CORE_SR_CONTROL_REG,
|
2011-03-30 17:36:30 -06:00
|
|
|
.i2c_high_speed = true,
|
2010-12-10 10:21:05 -07:00
|
|
|
.vsel_to_uv = twl4030_vsel_to_uv,
|
|
|
|
.uv_to_vsel = twl4030_uv_to_vsel,
|
|
|
|
};
|
|
|
|
|
2011-03-30 12:01:10 -06:00
|
|
|
static struct omap_voltdm_pmic omap4_mpu_pmic = {
|
2010-12-10 10:45:16 -07:00
|
|
|
.slew_rate = 4000,
|
2011-05-17 23:17:30 -06:00
|
|
|
.step_size = 12660,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vp_erroroffset = OMAP4_VP_CONFIG_ERROROFFSET,
|
|
|
|
.vp_vstepmin = OMAP4_VP_VSTEPMIN_VSTEPMIN,
|
|
|
|
.vp_vstepmax = OMAP4_VP_VSTEPMAX_VSTEPMAX,
|
2012-09-25 10:33:42 -06:00
|
|
|
.vddmin = 0,
|
|
|
|
.vddmax = 2100000,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US,
|
|
|
|
.i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR,
|
2011-03-22 15:12:37 -06:00
|
|
|
.volt_reg_addr = OMAP4_VDD_MPU_SR_VOLT_REG,
|
2011-05-17 23:17:34 -06:00
|
|
|
.cmd_reg_addr = OMAP4_VDD_MPU_SR_CMD_REG,
|
2011-03-30 17:36:30 -06:00
|
|
|
.i2c_high_speed = true,
|
2012-09-25 10:33:48 -06:00
|
|
|
.i2c_pad_load = 3,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vsel_to_uv = twl6030_vsel_to_uv,
|
|
|
|
.uv_to_vsel = twl6030_uv_to_vsel,
|
|
|
|
};
|
|
|
|
|
2011-03-30 12:01:10 -06:00
|
|
|
static struct omap_voltdm_pmic omap4_iva_pmic = {
|
2010-12-10 10:45:16 -07:00
|
|
|
.slew_rate = 4000,
|
2011-05-17 23:17:30 -06:00
|
|
|
.step_size = 12660,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vp_erroroffset = OMAP4_VP_CONFIG_ERROROFFSET,
|
|
|
|
.vp_vstepmin = OMAP4_VP_VSTEPMIN_VSTEPMIN,
|
|
|
|
.vp_vstepmax = OMAP4_VP_VSTEPMAX_VSTEPMAX,
|
2012-09-25 10:33:42 -06:00
|
|
|
.vddmin = 0,
|
|
|
|
.vddmax = 2100000,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US,
|
|
|
|
.i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR,
|
2011-03-22 15:12:37 -06:00
|
|
|
.volt_reg_addr = OMAP4_VDD_IVA_SR_VOLT_REG,
|
2011-05-17 23:17:34 -06:00
|
|
|
.cmd_reg_addr = OMAP4_VDD_IVA_SR_CMD_REG,
|
2011-03-30 17:36:30 -06:00
|
|
|
.i2c_high_speed = true,
|
2012-09-25 10:33:48 -06:00
|
|
|
.i2c_pad_load = 3,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vsel_to_uv = twl6030_vsel_to_uv,
|
|
|
|
.uv_to_vsel = twl6030_uv_to_vsel,
|
|
|
|
};
|
|
|
|
|
2011-03-30 12:01:10 -06:00
|
|
|
static struct omap_voltdm_pmic omap4_core_pmic = {
|
2010-12-10 10:45:16 -07:00
|
|
|
.slew_rate = 4000,
|
2011-05-17 23:17:30 -06:00
|
|
|
.step_size = 12660,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vp_erroroffset = OMAP4_VP_CONFIG_ERROROFFSET,
|
|
|
|
.vp_vstepmin = OMAP4_VP_VSTEPMIN_VSTEPMIN,
|
|
|
|
.vp_vstepmax = OMAP4_VP_VSTEPMAX_VSTEPMAX,
|
2012-09-25 10:33:42 -06:00
|
|
|
.vddmin = 0,
|
|
|
|
.vddmax = 2100000,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US,
|
|
|
|
.i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR,
|
2011-03-22 15:12:37 -06:00
|
|
|
.volt_reg_addr = OMAP4_VDD_CORE_SR_VOLT_REG,
|
2011-05-17 23:17:34 -06:00
|
|
|
.cmd_reg_addr = OMAP4_VDD_CORE_SR_CMD_REG,
|
2012-09-25 10:33:49 -06:00
|
|
|
.i2c_high_speed = true,
|
2012-09-25 10:33:48 -06:00
|
|
|
.i2c_pad_load = 3,
|
2010-12-10 10:45:16 -07:00
|
|
|
.vsel_to_uv = twl6030_vsel_to_uv,
|
|
|
|
.uv_to_vsel = twl6030_uv_to_vsel,
|
|
|
|
};
|
|
|
|
|
|
|
|
int __init omap4_twl_init(void)
|
|
|
|
{
|
|
|
|
struct voltagedomain *voltdm;
|
|
|
|
|
|
|
|
if (!cpu_is_omap44xx())
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
voltdm = voltdm_lookup("mpu");
|
2011-03-30 12:01:10 -06:00
|
|
|
omap_voltage_register_pmic(voltdm, &omap4_mpu_pmic);
|
2010-12-10 10:45:16 -07:00
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
voltdm = voltdm_lookup("iva");
|
2011-03-30 12:01:10 -06:00
|
|
|
omap_voltage_register_pmic(voltdm, &omap4_iva_pmic);
|
2010-12-10 10:45:16 -07:00
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
voltdm = voltdm_lookup("core");
|
2011-03-30 12:01:10 -06:00
|
|
|
omap_voltage_register_pmic(voltdm, &omap4_core_pmic);
|
2010-12-10 10:45:16 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-10 10:21:05 -07:00
|
|
|
int __init omap3_twl_init(void)
|
|
|
|
{
|
|
|
|
struct voltagedomain *voltdm;
|
|
|
|
|
|
|
|
if (!cpu_is_omap34xx())
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-03-23 12:18:08 -06:00
|
|
|
voltdm = voltdm_lookup("mpu_iva");
|
2011-03-30 12:01:10 -06:00
|
|
|
omap_voltage_register_pmic(voltdm, &omap3_mpu_pmic);
|
2010-12-10 10:21:05 -07:00
|
|
|
|
2011-03-16 15:25:45 -06:00
|
|
|
voltdm = voltdm_lookup("core");
|
2011-03-30 12:01:10 -06:00
|
|
|
omap_voltage_register_pmic(voltdm, &omap3_core_pmic);
|
2010-12-10 10:21:05 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|