blob: d676617344cf122e34a52e30c16f9bf3e40c0f0c [file] [log] [blame]
SRICHARAN R21144292012-03-12 02:25:48 +00001/*
Nishanth Menoncb199102013-03-26 05:20:54 +00002 * (C) Copyright 2012-2013
SRICHARAN R21144292012-03-12 02:25:48 +00003 * Texas Instruments, <www.ti.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
SRICHARAN R21144292012-03-12 02:25:48 +00006 */
Nishanth Menonda2cc452013-03-26 05:20:58 +00007#ifndef PALMAS_H
8#define PALMAS_H
SRICHARAN R21144292012-03-12 02:25:48 +00009
10#include <common.h>
11#include <i2c.h>
12
Lubomir Popove9090fa2013-06-06 04:16:40 +000013/* I2C chip addresses, TW6035/37 */
14#define TWL603X_CHIP_P1 0x48 /* Page 1 */
15#define TWL603X_CHIP_P2 0x49 /* Page 2 */
16#define TWL603X_CHIP_P3 0x4a /* Page 3 */
SRICHARAN R21144292012-03-12 02:25:48 +000017
Lubomir Popove9090fa2013-06-06 04:16:40 +000018/* TPS659038/39 */
19#define TPS65903X_CHIP_P1 0x58 /* Page 1 */
20
21/* Page 1 registers (0x1XY translates to page 1, reg addr 0xXY): */
22
23/* LDO1 control/voltage */
24#define LDO1_CTRL 0x50
25#define LDO1_VOLTAGE 0x51
26
Lokesh Vutlab4b06002016-11-23 13:25:28 +053027/* LDO1 control/voltage for LP873x */
28#define LP873X_LDO1_ADDR 0x60
29#define LP873X_LDO1_CTRL 0x9
30#define LP873X_LDO1_VOLTAGE 0xa
31#define LP873X_LDO_VOLT_3V0 0x19
32#define LP873X_LDO_VOLT_1V8 0xa
33#define LP873X_LDO_CTRL_EN (0x1 << 0)
34#define LP873X_LDO_CTRL_EN_PINCTRL (0x1 << 1)
35#define LP873X_LDO_CTRL_RDIS_EN (0x1 << 2)
36
Dmitry Lifshitz35fe1cb2014-04-27 13:17:26 +030037/* LDO2 control/voltage */
38#define LDO2_CTRL 0x52
39#define LDO2_VOLTAGE 0x53
40
Lubomir Popove9090fa2013-06-06 04:16:40 +000041/* LDO9 control/voltage */
SRICHARAN R21144292012-03-12 02:25:48 +000042#define LDO9_CTRL 0x60
43#define LDO9_VOLTAGE 0x61
44
Lubomir Popove9090fa2013-06-06 04:16:40 +000045/* LDOUSB control/voltage */
46#define LDOUSB_CTRL 0x64
47#define LDOUSB_VOLTAGE 0x65
Dan Murphy1bd435b2013-08-26 08:54:49 -050048#define LDO_CTRL 0x6a
Lubomir Popove9090fa2013-06-06 04:16:40 +000049
50/* Control of 32 kHz audio clock */
51#define CLK32KGAUDIO_CTRL 0xd5
52
53/* SYSEN2_CTRL for VCC_3v3_AUX supply on the sEVM */
54#define SYSEN2_CTRL 0xd9
55
56/*
57 * Bit field definitions for LDOx_CTRL, SYSENx_CTRL
58 * and some other xxx_CTRL resources:
59 */
60#define LDO9_BYP_EN (1 << 6) /* LDO9 only! */
61#define RSC_STAT_ON (1 << 4) /* RO status bit! */
62#define RSC_MODE_SLEEP (1 << 2)
63#define RSC_MODE_ACTIVE (1 << 0)
64
65/* Some LDO voltage values */
66#define LDO_VOLT_OFF 0
67#define LDO_VOLT_1V8 0x13
68#define LDO_VOLT_3V0 0x2b
69#define LDO_VOLT_3V3 0x31
70/* Request bypass, LDO9 only */
71#define LDO9_BYPASS 0x3f
72
73/* SMPS7_CTRL */
74#define SMPS7_CTRL 0x30
75
76/* SMPS9_CTRL */
77#define SMPS9_CTRL 0x38
78#define SMPS9_VOLTAGE 0x3b
79
Dan Murphy1bd435b2013-08-26 08:54:49 -050080/* SMPS10_CTRL */
81#define SMPS10_CTRL 0x3c
82#define SMPS10_MODE_ACTIVE_D 0x0d
83
Lubomir Popove9090fa2013-06-06 04:16:40 +000084/* Bit field definitions for SMPSx_CTRL */
85#define SMPS_MODE_ACT_AUTO 1
86#define SMPS_MODE_ACT_ECO 2
87#define SMPS_MODE_ACT_FPWM 3
88#define SMPS_MODE_SLP_AUTO (1 << 2)
89#define SMPS_MODE_SLP_ECO (2 << 2)
90#define SMPS_MODE_SLP_FPWM (3 << 2)
91
92/*
93 * Some popular SMPS voltages, all with RANGE=1; note
94 * that RANGE cannot be changed on the fly
95 */
96#define SMPS_VOLT_OFF 0
97#define SMPS_VOLT_1V2 0x90
98#define SMPS_VOLT_1V8 0xae
99#define SMPS_VOLT_2V1 0xbd
100#define SMPS_VOLT_3V0 0xea
101#define SMPS_VOLT_3V3 0xf9
102
103/* Backup Battery & VRTC Control */
104#define BB_VRTC_CTRL 0xa8
105/* Bit definitions for BB_VRTC_CTRL */
106#define VRTC_EN_SLP (1 << 6)
107#define VRTC_EN_OFF (1 << 5)
108#define VRTC_PWEN (1 << 4)
109#define BB_LOW_ICHRG (1 << 3)
110#define BB_HIGH_ICHRG (0 << 3)
111#define BB_VSEL_3V0 (0 << 1)
112#define BB_VSEL_2V5 (1 << 1)
113#define BB_VSEL_3V15 (2 << 1)
114#define BB_VSEL_VBAT (3 << 1)
115#define BB_CHRG_EN (1 << 0)
SRICHARAN R21144292012-03-12 02:25:48 +0000116
Nishanth Menonff2d57e2013-03-26 05:20:57 +0000117/*
118 * Functions to read and write from TPS659038/TWL6035/TWL6037
119 * or other Palmas family of TI PMICs
120 */
121static inline int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
122{
123 return i2c_write(chip_no, reg, 1, &val, 1);
124}
125
126static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
127{
128 return i2c_read(chip_no, reg, 1, val, 1);
129}
130
Nishanth Menon12733882013-03-26 05:20:55 +0000131void palmas_init_settings(void);
Lokesh Vutlab4b06002016-11-23 13:25:28 +0530132int palmas_mmc1_poweron_ldo(uint voltage);
133int lp873x_mmc1_poweron_ldo(uint voltage);
Lubomir Popove9090fa2013-06-06 04:16:40 +0000134int twl603x_mmc1_set_ldo9(u8 vsel);
135int twl603x_audio_power(u8 on);
136int twl603x_enable_bb_charge(u8 bb_fields);
Dan Murphy1bd435b2013-08-26 08:54:49 -0500137int palmas_enable_ss_ldo(void);
Nishanth Menonda2cc452013-03-26 05:20:58 +0000138
139#endif /* PALMAS_H */