blob: a79158b69712e37b8d37799752a482dcc88c0532 [file] [log] [blame]
David Hendricks6e877ec2013-04-09 16:58:02 -07001/*
David Hendricks765ff762013-04-09 17:20:07 -07002 * Copyright 2012, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials provided
14 * with the distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
David Hendricks6e877ec2013-04-09 16:58:02 -070030 *
31 * Alternatively, this software may be distributed under the terms of the
32 * GNU General Public License ("GPL") version 2 as published by the Free
33 * Software Foundation.
34 */
35
36#ifndef __TPS65090_H_
37#define __TPS65090_H_
38
39/* I2C device address for TPS65090 PMU */
40#define TPS65090_I2C_ADDR 0x48
41
David Hendricks765ff762013-04-09 17:20:07 -070042/* TPS65090 FET control registers */
43enum fet_id {
44 FET1_CTRL = 0x0f,
45 FET2_CTRL,
46 FET3_CTRL,
47 FET4_CTRL,
48 FET5_CTRL,
49 FET6_CTRL,
50 FET7_CTRL,
51};
52
David Hendricks6e877ec2013-04-09 16:58:02 -070053enum {
54 /* Status register fields */
55 TPS65090_ST1_OTC = 1 << 0,
56 TPS65090_ST1_OCC = 1 << 1,
57 TPS65090_ST1_STATE_SHIFT = 4,
58 TPS65090_ST1_STATE_MASK = 0xf << TPS65090_ST1_STATE_SHIFT,
59};
60
61/* FET errors */
62enum {
63 FET_ERR_COMMS = -1, /* FET comms error */
64 FET_ERR_NOT_READY = -2, /* FET is not yet ready - retry */
65};
66
67/**
68 * Enable FET
69 *
Martin Roth5f066b22015-01-04 16:47:39 -070070 * @param bus I2C bus number the TPS65090 is on
71 * @param fet_id FET ID, value between 1 and 7
David Hendricks765ff762013-04-09 17:20:07 -070072 * return 0 on success, non-0 on failure
David Hendricks6e877ec2013-04-09 16:58:02 -070073 */
David Hendricks765ff762013-04-09 17:20:07 -070074int tps65090_fet_enable(unsigned int bus, enum fet_id fet_id);
David Hendricks6e877ec2013-04-09 16:58:02 -070075
76/**
77 * Disable FET
78 *
Martin Roth5f066b22015-01-04 16:47:39 -070079 * @param bus I2C bus number the TPS65090 is on
80 * @param fet_id FET ID, value between 1 and 7
David Hendricks6e877ec2013-04-09 16:58:02 -070081 * @return 0 on success, non-0 on failure
82 */
David Hendricks765ff762013-04-09 17:20:07 -070083int tps65090_fet_disable(unsigned int bus, enum fet_id fet_id);
David Hendricks6e877ec2013-04-09 16:58:02 -070084
85/**
86 * Is FET enabled?
87 *
Martin Roth5f066b22015-01-04 16:47:39 -070088 * @param bus I2C bus number the TPS65090 is on
89 * @param fet_id FET ID, value between 1 and 7
David Hendricks6e877ec2013-04-09 16:58:02 -070090 * @return 1 enabled, 0 disabled, negative value on failure
91 */
David Hendricks765ff762013-04-09 17:20:07 -070092int tps65090_fet_is_enabled(unsigned int bus, enum fet_id fet_id);
David Hendricks6e877ec2013-04-09 16:58:02 -070093
94/**
95 * Enable / disable the battery charger
96 *
Martin Roth5f066b22015-01-04 16:47:39 -070097 * @param bus I2C bus number the TPS65090 is on
98 * @param enable 0 to disable charging, non-zero to enable
David Hendricks6e877ec2013-04-09 16:58:02 -070099 */
David Hendricks765ff762013-04-09 17:20:07 -0700100int tps65090_set_charge_enable(unsigned int bus, int enable);
David Hendricks6e877ec2013-04-09 16:58:02 -0700101
102/**
103 * Check whether we have enabled battery charging
104 *
Martin Roth5f066b22015-01-04 16:47:39 -0700105 * @param bus I2C bus number the TPS65090 is on
David Hendricks6e877ec2013-04-09 16:58:02 -0700106 * @return 1 if enabled, 0 if disabled
107 */
David Hendricks765ff762013-04-09 17:20:07 -0700108int tps65090_is_charging(unsigned int bus);
David Hendricks6e877ec2013-04-09 16:58:02 -0700109
110/**
111 * Return the value of the status register
112 *
Martin Roth5f066b22015-01-04 16:47:39 -0700113 * @param bus I2C bus number the TPS65090 is on
David Hendricks6e877ec2013-04-09 16:58:02 -0700114 * @return status register value, or -1 on error
115 */
David Hendricks765ff762013-04-09 17:20:07 -0700116int tps65090_get_status(unsigned int bus);
David Hendricks6e877ec2013-04-09 16:58:02 -0700117
118#endif /* __TPS65090_H_ */