xref: /freebsd/sys/arm/ti/am335x/tps65217x.h (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
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  * $FreeBSD$
28  */
29 
30 #ifndef __TPS65217X_H__
31 #define __TPS65217X_H__
32 
33 /*
34  * TPS65217 PMIC is a companion chip for AM335x SoC sitting on I2C bus
35  */
36 
37 /* TPS65217 Registers */
38 #define	TPS65217_CHIPID_REG	0x00
39 struct tps65217_chipid_reg {
40 	unsigned int rev:4;
41 	unsigned int chip:4;
42 #define TPS65217A		0x7
43 #define TPS65217B		0xF
44 #define TPS65217C		0xE
45 #define TPS65217D		0x6
46 } __attribute__((__packed__));
47 
48 #define	TPS65217_INT_REG	0x02
49 struct tps65217_int_reg {
50 	unsigned int usbi:1;
51 	unsigned int aci:1;
52 	unsigned int pbi:1;
53 	unsigned int reserved3:1;
54 	unsigned int usbm:1;
55 	unsigned int acm:1;
56 	unsigned int pbm:1;
57 	unsigned int reserved7:1;
58 } __attribute__((__packed__));
59 
60 #define	TPS65217_STATUS_REG	0x0A
61 struct tps65217_status_reg {
62 	unsigned int pb:1;
63 	unsigned int reserved1:1;
64 	unsigned int usbpwr:1;
65 	unsigned int acpwr:1;
66 	unsigned int reserved4:3;
67 	unsigned int off:1;
68 } __attribute__((__packed__));
69 
70 #define	TPS65217_CHGCONFIG0_REG	0x03
71 struct tps65217_chgconfig0_reg {
72 	unsigned int battemp:1;
73 	unsigned int pchgtout:1;
74 	unsigned int chgtout:1;
75 	unsigned int active:1;
76 	unsigned int termi:1;
77 	unsigned int tsusp:1;
78 	unsigned int dppm:1;
79 	unsigned int treg:1;
80 } __attribute__((__packed__));
81 
82 #define	TPS65217_CHGCONFIG1_REG	0x04
83 struct tps65217_chgconfig1_reg {
84 	unsigned int chg_en:1;
85 	unsigned int susp:1;
86 	unsigned int term:1;
87 	unsigned int reset:1;
88 	unsigned int ntc_type:1;
89 	unsigned int tmr_en:1;
90 	unsigned int timer:2;
91 } __attribute__((__packed__));
92 
93 #define	TPS65217_CHGCONFIG2_REG	0x05
94 struct tps65217_chgconfig2_reg {
95 	unsigned int reserved:4;
96 	unsigned int voreg:2;
97 #define	TPS65217_VO_410V	0b00
98 #define	TPS65217_VO_415V	0b01
99 #define	TPS65217_VO_420V	0b10
100 #define	TPS65217_VO_425V	0b11
101 	unsigned int vprechg:1;
102 	unsigned int dyntmr:1;
103 } __attribute__((__packed__));
104 
105 #define	TPS65217_CHGCONFIG3_REG	0x06
106 struct tps65217_chgconfig3_reg {
107 	unsigned int trange:1;
108 	unsigned int termif:2;
109 	unsigned int pchrgt:1;
110 	unsigned int dppmth:2;
111 	unsigned int ichrg:2;
112 } __attribute__((__packed__));
113 
114 #endif /* __TPS65217X_H__ */
115