blob: b8f08742a6f0f427d0ff7b782d21f65a2c2693c2 [file] [log] [blame]
Thara Gopinathfbc319f2010-12-10 22:51:05 +05301/**
2 * OMAP and TWL PMIC specific intializations.
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated.
5 * Thara Gopinath
6 * Copyright (C) 2009 Texas Instruments Incorporated.
7 * Nishanth Menon
8 * Copyright (C) 2009 Nokia Corporation
9 * Paul Walmsley
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/err.h>
17#include <linux/io.h>
18#include <linux/kernel.h>
19
20#include <plat/voltage.h>
21
22#define OMAP3_SRI2C_SLAVE_ADDR 0x12
23#define OMAP3_VDD_MPU_SR_CONTROL_REG 0x00
24#define OMAP3_VDD_CORE_SR_CONTROL_REG 0x01
25#define OMAP3_VP_CONFIG_ERROROFFSET 0x00
26#define OMAP3_VP_VSTEPMIN_VSTEPMIN 0x1
27#define OMAP3_VP_VSTEPMAX_VSTEPMAX 0x04
28#define OMAP3_VP_VLIMITTO_TIMEOUT_US 200
29
30#define OMAP3430_VP1_VLIMITTO_VDDMIN 0x14
31#define OMAP3430_VP1_VLIMITTO_VDDMAX 0x42
32#define OMAP3430_VP2_VLIMITTO_VDDMIN 0x18
33#define OMAP3430_VP2_VLIMITTO_VDDMAX 0x2c
34
35#define OMAP3630_VP1_VLIMITTO_VDDMIN 0x18
36#define OMAP3630_VP1_VLIMITTO_VDDMAX 0x3c
37#define OMAP3630_VP2_VLIMITTO_VDDMIN 0x18
38#define OMAP3630_VP2_VLIMITTO_VDDMAX 0x30
39
40unsigned long twl4030_vsel_to_uv(const u8 vsel)
41{
42 return (((vsel * 125) + 6000)) * 100;
43}
44
45u8 twl4030_uv_to_vsel(unsigned long uv)
46{
47 return DIV_ROUND_UP(uv - 600000, 12500);
48}
49
50static struct omap_volt_pmic_info omap3_mpu_volt_info = {
51 .slew_rate = 4000,
52 .step_size = 12500,
53 .on_volt = 1200000,
54 .onlp_volt = 1000000,
55 .ret_volt = 975000,
56 .off_volt = 600000,
57 .volt_setup_time = 0xfff,
58 .vp_erroroffset = OMAP3_VP_CONFIG_ERROROFFSET,
59 .vp_vstepmin = OMAP3_VP_VSTEPMIN_VSTEPMIN,
60 .vp_vstepmax = OMAP3_VP_VSTEPMAX_VSTEPMAX,
61 .vp_vddmin = OMAP3430_VP1_VLIMITTO_VDDMIN,
62 .vp_vddmax = OMAP3430_VP1_VLIMITTO_VDDMAX,
63 .vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US,
64 .i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR,
65 .pmic_reg = OMAP3_VDD_MPU_SR_CONTROL_REG,
66 .vsel_to_uv = twl4030_vsel_to_uv,
67 .uv_to_vsel = twl4030_uv_to_vsel,
68};
69
70static struct omap_volt_pmic_info omap3_core_volt_info = {
71 .slew_rate = 4000,
72 .step_size = 12500,
73 .on_volt = 1200000,
74 .onlp_volt = 1000000,
75 .ret_volt = 975000,
76 .off_volt = 600000,
77 .volt_setup_time = 0xfff,
78 .vp_erroroffset = OMAP3_VP_CONFIG_ERROROFFSET,
79 .vp_vstepmin = OMAP3_VP_VSTEPMIN_VSTEPMIN,
80 .vp_vstepmax = OMAP3_VP_VSTEPMAX_VSTEPMAX,
81 .vp_vddmin = OMAP3430_VP2_VLIMITTO_VDDMIN,
82 .vp_vddmax = OMAP3430_VP2_VLIMITTO_VDDMAX,
83 .vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US,
84 .i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR,
85 .pmic_reg = OMAP3_VDD_CORE_SR_CONTROL_REG,
86 .vsel_to_uv = twl4030_vsel_to_uv,
87 .uv_to_vsel = twl4030_uv_to_vsel,
88};
89
90int __init omap3_twl_init(void)
91{
92 struct voltagedomain *voltdm;
93
94 if (!cpu_is_omap34xx())
95 return -ENODEV;
96
97 if (cpu_is_omap3630()) {
98 omap3_mpu_volt_info.vp_vddmin = OMAP3630_VP1_VLIMITTO_VDDMIN;
99 omap3_mpu_volt_info.vp_vddmax = OMAP3630_VP1_VLIMITTO_VDDMAX;
100 omap3_core_volt_info.vp_vddmin = OMAP3630_VP2_VLIMITTO_VDDMIN;
101 omap3_core_volt_info.vp_vddmax = OMAP3630_VP2_VLIMITTO_VDDMAX;
102 }
103
104 voltdm = omap_voltage_domain_lookup("mpu");
105 omap_voltage_register_pmic(voltdm, &omap3_mpu_volt_info);
106
107 voltdm = omap_voltage_domain_lookup("core");
108 omap_voltage_register_pmic(voltdm, &omap3_core_volt_info);
109
110 return 0;
111}