xref: /freebsd/sys/arm/ti/am335x/tps65217x.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1 /*-
2  * Copyright (c) 2012 Damjan Marion <dmarion@FreeBSD.org>
3  * Copyright (c) 2015 Maksym Sobolyev <sobomax@FreeBSD.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef __TPS65217X_H__
29 #define __TPS65217X_H__
30 
31 /*
32  * TPS65217 PMIC is a companion chip for AM335x SoC sitting on I2C bus
33  */
34 
35 /* TPS65217 Registers */
36 #define	TPS65217_CHIPID_REG	0x00
37 struct tps65217_chipid_reg {
38 	unsigned int rev:4;
39 	unsigned int chip:4;
40 #define TPS65217A		0x7
41 #define TPS65217B		0xF
42 #define TPS65217C		0xE
43 #define TPS65217D		0x6
44 } __attribute__((__packed__));
45 
46 #define	TPS65217_INT_REG	0x02
47 struct tps65217_int_reg {
48 	unsigned int usbi:1;
49 	unsigned int aci:1;
50 	unsigned int pbi:1;
51 	unsigned int reserved3:1;
52 	unsigned int usbm:1;
53 	unsigned int acm:1;
54 	unsigned int pbm:1;
55 	unsigned int reserved7:1;
56 } __attribute__((__packed__));
57 
58 #define	TPS65217_STATUS_REG	0x0A
59 struct tps65217_status_reg {
60 	unsigned int pb:1;
61 	unsigned int reserved1:1;
62 	unsigned int usbpwr:1;
63 	unsigned int acpwr:1;
64 	unsigned int reserved4:3;
65 	unsigned int off:1;
66 } __attribute__((__packed__));
67 
68 #define	TPS65217_CHGCONFIG0_REG	0x03
69 struct tps65217_chgconfig0_reg {
70 	unsigned int battemp:1;
71 	unsigned int pchgtout:1;
72 	unsigned int chgtout:1;
73 	unsigned int active:1;
74 	unsigned int termi:1;
75 	unsigned int tsusp:1;
76 	unsigned int dppm:1;
77 	unsigned int treg:1;
78 } __attribute__((__packed__));
79 
80 #define	TPS65217_CHGCONFIG1_REG	0x04
81 struct tps65217_chgconfig1_reg {
82 	unsigned int chg_en:1;
83 	unsigned int susp:1;
84 	unsigned int term:1;
85 	unsigned int reset:1;
86 	unsigned int ntc_type:1;
87 	unsigned int tmr_en:1;
88 	unsigned int timer:2;
89 } __attribute__((__packed__));
90 
91 #define	TPS65217_CHGCONFIG2_REG	0x05
92 struct tps65217_chgconfig2_reg {
93 	unsigned int reserved:4;
94 	unsigned int voreg:2;
95 #define	TPS65217_VO_410V	0b00
96 #define	TPS65217_VO_415V	0b01
97 #define	TPS65217_VO_420V	0b10
98 #define	TPS65217_VO_425V	0b11
99 	unsigned int vprechg:1;
100 	unsigned int dyntmr:1;
101 } __attribute__((__packed__));
102 
103 #define	TPS65217_CHGCONFIG3_REG	0x06
104 struct tps65217_chgconfig3_reg {
105 	unsigned int trange:1;
106 	unsigned int termif:2;
107 	unsigned int pchrgt:1;
108 	unsigned int dppmth:2;
109 	unsigned int ichrg:2;
110 } __attribute__((__packed__));
111 
112 #endif /* __TPS65217X_H__ */
113