j720pwr.c revision 1.1.14.3 1 1.1.14.3 yamt /* $NetBSD: j720pwr.c,v 1.1.14.3 2006/12/30 20:46:02 yamt Exp $ */
2 1.1.14.2 yamt
3 1.1.14.2 yamt /*-
4 1.1.14.2 yamt * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
5 1.1.14.2 yamt * All rights reserved.
6 1.1.14.2 yamt *
7 1.1.14.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.14.2 yamt * by Emmanuel Dreyfus and Peter Postma.
9 1.1.14.2 yamt *
10 1.1.14.2 yamt * Redistribution and use in source and binary forms, with or without
11 1.1.14.2 yamt * modification, are permitted provided that the following conditions
12 1.1.14.2 yamt * are met:
13 1.1.14.2 yamt * 1. Redistributions of source code must retain the above copyright
14 1.1.14.2 yamt * notice, this list of conditions and the following disclaimer.
15 1.1.14.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.14.2 yamt * notice, this list of conditions and the following disclaimer in the
17 1.1.14.2 yamt * documentation and/or other materials provided with the distribution.
18 1.1.14.2 yamt * 3. All advertising materials mentioning features or use of this software
19 1.1.14.2 yamt * must display the following acknowledgement:
20 1.1.14.2 yamt * This product includes software developed by the NetBSD
21 1.1.14.2 yamt * Foundation, Inc. and its contributors.
22 1.1.14.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.14.2 yamt * contributors may be used to endorse or promote products derived
24 1.1.14.2 yamt * from this software without specific prior written permission.
25 1.1.14.2 yamt *
26 1.1.14.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.14.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.14.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.14.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.14.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.14.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.14.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.14.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.14.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.14.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.14.2 yamt * POSSIBILITY OF SUCH DAMAGE.
37 1.1.14.2 yamt */
38 1.1.14.2 yamt
39 1.1.14.2 yamt /* Jornada 720 power management. */
40 1.1.14.2 yamt
41 1.1.14.2 yamt #include <sys/cdefs.h>
42 1.1.14.3 yamt __KERNEL_RCSID(0, "$NetBSD: j720pwr.c,v 1.1.14.3 2006/12/30 20:46:02 yamt Exp $");
43 1.1.14.2 yamt
44 1.1.14.2 yamt #include <sys/param.h>
45 1.1.14.2 yamt #include <sys/systm.h>
46 1.1.14.2 yamt #include <sys/kernel.h>
47 1.1.14.2 yamt #include <sys/proc.h>
48 1.1.14.2 yamt #include <sys/device.h>
49 1.1.14.2 yamt
50 1.1.14.2 yamt #include <dev/apm/apmbios.h>
51 1.1.14.2 yamt
52 1.1.14.2 yamt #include <machine/config_hook.h>
53 1.1.14.2 yamt #include <machine/platid.h>
54 1.1.14.2 yamt #include <machine/platid_mask.h>
55 1.1.14.2 yamt
56 1.1.14.2 yamt #include <arm/sa11x0/sa11x0_var.h>
57 1.1.14.2 yamt #include <arm/sa11x0/sa11x0_gpioreg.h>
58 1.1.14.2 yamt #include <arm/sa11x0/sa11x0_ppcreg.h>
59 1.1.14.2 yamt #include <arm/sa11x0/sa11x0_sspreg.h>
60 1.1.14.2 yamt
61 1.1.14.2 yamt #include <hpcarm/dev/j720sspvar.h>
62 1.1.14.2 yamt
63 1.1.14.2 yamt #ifdef DEBUG
64 1.1.14.2 yamt #define DPRINTF(arg) printf arg
65 1.1.14.2 yamt #else
66 1.1.14.2 yamt #define DPRINTF(arg) /* nothing */
67 1.1.14.2 yamt #endif
68 1.1.14.2 yamt
69 1.1.14.2 yamt #define arraysize(ary) (sizeof(ary) / sizeof(ary[0]))
70 1.1.14.2 yamt
71 1.1.14.2 yamt struct j720pwr_softc {
72 1.1.14.2 yamt struct device sc_dev;
73 1.1.14.2 yamt
74 1.1.14.2 yamt struct j720ssp_softc *sc_ssp;
75 1.1.14.3 yamt
76 1.1.14.3 yamt volatile int sc_state;
77 1.1.14.3 yamt #define J720PWR_POWEROFF 0x01
78 1.1.14.3 yamt #define J720PWR_SLEEPING 0x02
79 1.1.14.2 yamt };
80 1.1.14.2 yamt
81 1.1.14.2 yamt static int j720pwr_match(struct device *, struct cfdata *, void *);
82 1.1.14.2 yamt static void j720pwr_attach(struct device *, struct device *, void *);
83 1.1.14.2 yamt
84 1.1.14.3 yamt static void j720pwr_sleep(void *);
85 1.1.14.3 yamt static int j720pwr_suspend_hook(void *, int, long, void *);
86 1.1.14.3 yamt static int j720pwr_event_hook(void *, int, long, void *);
87 1.1.14.2 yamt static int j720pwr_apm_getpower_hook(void *, int, long, void *);
88 1.1.14.2 yamt static int j720pwr_get_battery(struct j720pwr_softc *);
89 1.1.14.2 yamt static int j720pwr_get_ac_status(struct j720pwr_softc *);
90 1.1.14.2 yamt static int j720pwr_get_charge_status(struct j720pwr_softc *);
91 1.1.14.2 yamt
92 1.1.14.2 yamt static const struct {
93 1.1.14.2 yamt int percent;
94 1.1.14.2 yamt int value;
95 1.1.14.2 yamt int state;
96 1.1.14.2 yamt } battery_table[] = {
97 1.1.14.2 yamt { 100, 670, APM_BATT_FLAG_HIGH },
98 1.1.14.2 yamt { 90, 660, APM_BATT_FLAG_HIGH },
99 1.1.14.2 yamt { 80, 650, APM_BATT_FLAG_HIGH },
100 1.1.14.2 yamt { 70, 640, APM_BATT_FLAG_HIGH },
101 1.1.14.2 yamt { 60, 630, APM_BATT_FLAG_HIGH },
102 1.1.14.2 yamt { 50, 620, APM_BATT_FLAG_HIGH },
103 1.1.14.2 yamt { 40, 605, APM_BATT_FLAG_LOW },
104 1.1.14.2 yamt { 30, 580, APM_BATT_FLAG_LOW },
105 1.1.14.2 yamt { 20, 545, APM_BATT_FLAG_LOW },
106 1.1.14.2 yamt { 10, 500, APM_BATT_FLAG_CRITICAL },
107 1.1.14.2 yamt { 0, 430, APM_BATT_FLAG_CRITICAL },
108 1.1.14.2 yamt };
109 1.1.14.2 yamt
110 1.1.14.2 yamt CFATTACH_DECL(j720pwr, sizeof(struct j720pwr_softc),
111 1.1.14.2 yamt j720pwr_match, j720pwr_attach, NULL, NULL);
112 1.1.14.2 yamt
113 1.1.14.2 yamt
114 1.1.14.2 yamt static int
115 1.1.14.2 yamt j720pwr_match(struct device *parent, struct cfdata *cf, void *aux)
116 1.1.14.2 yamt {
117 1.1.14.2 yamt
118 1.1.14.2 yamt if (!platid_match(&platid, &platid_mask_MACH_HP_JORNADA_7XX))
119 1.1.14.2 yamt return 0;
120 1.1.14.2 yamt if (strcmp(cf->cf_name, "j720pwr") != 0)
121 1.1.14.2 yamt return 0;
122 1.1.14.2 yamt
123 1.1.14.2 yamt return 1;
124 1.1.14.2 yamt }
125 1.1.14.2 yamt
126 1.1.14.2 yamt static void
127 1.1.14.2 yamt j720pwr_attach(struct device *parent, struct device *self, void *aux)
128 1.1.14.2 yamt {
129 1.1.14.2 yamt struct j720pwr_softc *sc = (struct j720pwr_softc *)self;
130 1.1.14.3 yamt extern void (*__sleep_func)(void *);
131 1.1.14.3 yamt extern void *__sleep_ctx;
132 1.1.14.2 yamt
133 1.1.14.2 yamt printf("\n");
134 1.1.14.2 yamt
135 1.1.14.2 yamt sc->sc_ssp = (struct j720ssp_softc *)parent;
136 1.1.14.3 yamt sc->sc_state = 0;
137 1.1.14.3 yamt
138 1.1.14.3 yamt /* Register apm sleep function. */
139 1.1.14.3 yamt __sleep_func = j720pwr_sleep;
140 1.1.14.3 yamt __sleep_ctx = sc;
141 1.1.14.2 yamt
142 1.1.14.2 yamt /* Battery status query hook. */
143 1.1.14.2 yamt config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_BATTERYVAL,
144 1.1.14.2 yamt CONFIG_HOOK_EXCLUSIVE, j720pwr_apm_getpower_hook, sc);
145 1.1.14.2 yamt
146 1.1.14.2 yamt /* Battery charge status query hook. */
147 1.1.14.2 yamt config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_CHARGE,
148 1.1.14.2 yamt CONFIG_HOOK_EXCLUSIVE, j720pwr_apm_getpower_hook, sc);
149 1.1.14.2 yamt
150 1.1.14.2 yamt /* AC status query hook. */
151 1.1.14.2 yamt config_hook(CONFIG_HOOK_GET, CONFIG_HOOK_ACADAPTER,
152 1.1.14.2 yamt CONFIG_HOOK_EXCLUSIVE, j720pwr_apm_getpower_hook, sc);
153 1.1.14.2 yamt
154 1.1.14.3 yamt /* Suspend/resume button hook. */
155 1.1.14.3 yamt config_hook(CONFIG_HOOK_BUTTONEVENT,
156 1.1.14.3 yamt CONFIG_HOOK_BUTTONEVENT_POWER,
157 1.1.14.3 yamt CONFIG_HOOK_SHARE, j720pwr_suspend_hook, sc);
158 1.1.14.3 yamt
159 1.1.14.3 yamt /* Receive suspend/resume events. */
160 1.1.14.3 yamt config_hook(CONFIG_HOOK_PMEVENT,
161 1.1.14.3 yamt CONFIG_HOOK_PMEVENT_HARDPOWER,
162 1.1.14.3 yamt CONFIG_HOOK_SHARE, j720pwr_event_hook, sc);
163 1.1.14.3 yamt
164 1.1.14.2 yamt /* Attach hpcapm. */
165 1.1.14.2 yamt config_found_ia(self, "hpcapmif", NULL, NULL);
166 1.1.14.2 yamt }
167 1.1.14.2 yamt
168 1.1.14.3 yamt static void
169 1.1.14.3 yamt j720pwr_sleep(void *ctx)
170 1.1.14.3 yamt {
171 1.1.14.3 yamt struct j720pwr_softc *sc = ctx;
172 1.1.14.3 yamt struct j720ssp_softc *ssp = sc->sc_ssp;
173 1.1.14.3 yamt uint32_t oldfer;
174 1.1.14.3 yamt
175 1.1.14.3 yamt /* Disable falling-edge detect on all GPIO ports, except keyboard. */
176 1.1.14.3 yamt oldfer = bus_space_read_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_FER);
177 1.1.14.3 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_FER, 1 << 0);
178 1.1.14.3 yamt
179 1.1.14.3 yamt while (sc->sc_state & J720PWR_POWEROFF) {
180 1.1.14.3 yamt /*
181 1.1.14.3 yamt * Just sleep here until the poweroff bit gets unset.
182 1.1.14.3 yamt * We need to wait here because when machine_sleep() returns
183 1.1.14.3 yamt * hpcapm(4) assumes that we are "resuming".
184 1.1.14.3 yamt */
185 1.1.14.3 yamt (void)tsleep(&sc->sc_state, PWAIT, "j720slp", 0);
186 1.1.14.3 yamt }
187 1.1.14.3 yamt
188 1.1.14.3 yamt /* Restore previous FER value. */
189 1.1.14.3 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_FER, oldfer);
190 1.1.14.3 yamt }
191 1.1.14.3 yamt
192 1.1.14.3 yamt static int
193 1.1.14.3 yamt j720pwr_suspend_hook(void *ctx, int type, long id, void *msg)
194 1.1.14.3 yamt {
195 1.1.14.3 yamt struct j720pwr_softc *sc = ctx;
196 1.1.14.3 yamt
197 1.1.14.3 yamt if (type != CONFIG_HOOK_BUTTONEVENT ||
198 1.1.14.3 yamt id != CONFIG_HOOK_BUTTONEVENT_POWER)
199 1.1.14.3 yamt return EINVAL;
200 1.1.14.3 yamt
201 1.1.14.3 yamt if ((sc->sc_state & (J720PWR_POWEROFF | J720PWR_SLEEPING)) == 0) {
202 1.1.14.3 yamt sc->sc_state |= J720PWR_POWEROFF;
203 1.1.14.3 yamt } else if ((sc->sc_state & (J720PWR_POWEROFF | J720PWR_SLEEPING)) ==
204 1.1.14.3 yamt (J720PWR_POWEROFF | J720PWR_SLEEPING)) {
205 1.1.14.3 yamt sc->sc_state &= ~J720PWR_POWEROFF;
206 1.1.14.3 yamt wakeup(&sc->sc_state);
207 1.1.14.3 yamt } else {
208 1.1.14.3 yamt DPRINTF(("j720pwr_suspend_hook: busy\n"));
209 1.1.14.3 yamt return EBUSY;
210 1.1.14.3 yamt }
211 1.1.14.3 yamt
212 1.1.14.3 yamt config_hook_call(CONFIG_HOOK_PMEVENT,
213 1.1.14.3 yamt CONFIG_HOOK_PMEVENT_SUSPENDREQ, NULL);
214 1.1.14.3 yamt
215 1.1.14.3 yamt return 0;
216 1.1.14.3 yamt }
217 1.1.14.3 yamt
218 1.1.14.3 yamt static int
219 1.1.14.3 yamt j720pwr_event_hook(void *ctx, int type, long id, void *msg)
220 1.1.14.3 yamt {
221 1.1.14.3 yamt struct j720pwr_softc *sc = ctx;
222 1.1.14.3 yamt int event = (int)msg;
223 1.1.14.3 yamt
224 1.1.14.3 yamt if (type != CONFIG_HOOK_PMEVENT ||
225 1.1.14.3 yamt id != CONFIG_HOOK_PMEVENT_HARDPOWER)
226 1.1.14.3 yamt return EINVAL;
227 1.1.14.3 yamt
228 1.1.14.3 yamt switch (event) {
229 1.1.14.3 yamt case PWR_SUSPEND:
230 1.1.14.3 yamt sc->sc_state |= (J720PWR_SLEEPING | J720PWR_POWEROFF);
231 1.1.14.3 yamt break;
232 1.1.14.3 yamt case PWR_RESUME:
233 1.1.14.3 yamt sc->sc_state &= ~(J720PWR_SLEEPING | J720PWR_POWEROFF);
234 1.1.14.3 yamt break;
235 1.1.14.3 yamt default:
236 1.1.14.3 yamt return EINVAL;
237 1.1.14.3 yamt }
238 1.1.14.3 yamt
239 1.1.14.3 yamt return 0;
240 1.1.14.3 yamt }
241 1.1.14.3 yamt
242 1.1.14.2 yamt static int
243 1.1.14.2 yamt j720pwr_apm_getpower_hook(void *ctx, int type, long id, void *msg)
244 1.1.14.2 yamt {
245 1.1.14.2 yamt int * const pval = msg;
246 1.1.14.2 yamt int val, tmp, i, state = 0;
247 1.1.14.2 yamt
248 1.1.14.2 yamt if (type != CONFIG_HOOK_GET)
249 1.1.14.2 yamt return EINVAL;
250 1.1.14.2 yamt
251 1.1.14.2 yamt switch (id) {
252 1.1.14.2 yamt case CONFIG_HOOK_BATTERYVAL:
253 1.1.14.2 yamt val = j720pwr_get_battery(ctx);
254 1.1.14.2 yamt
255 1.1.14.2 yamt if (val != -1) {
256 1.1.14.2 yamt for (i = 0; i < arraysize(battery_table); i++)
257 1.1.14.2 yamt if (val > battery_table[i].value)
258 1.1.14.2 yamt break;
259 1.1.14.2 yamt if (i == 0) {
260 1.1.14.2 yamt /* Battery charge status is at maximum. */
261 1.1.14.2 yamt *pval = 100;
262 1.1.14.2 yamt } else {
263 1.1.14.2 yamt /*
264 1.1.14.2 yamt * Use linear interpolation to calculate
265 1.1.14.2 yamt * the estimated charge status.
266 1.1.14.2 yamt */
267 1.1.14.2 yamt tmp = ((val - battery_table[i].value) * 100) /
268 1.1.14.2 yamt (battery_table[i - 1].value -
269 1.1.14.2 yamt battery_table[i].value);
270 1.1.14.2 yamt *pval = battery_table[i].percent +
271 1.1.14.2 yamt ((battery_table[i - 1].percent -
272 1.1.14.2 yamt battery_table[i].percent) * tmp) / 100;
273 1.1.14.2 yamt }
274 1.1.14.2 yamt } else {
275 1.1.14.2 yamt /* Battery is absent. */
276 1.1.14.2 yamt *pval = 0;
277 1.1.14.2 yamt }
278 1.1.14.2 yamt
279 1.1.14.2 yamt return 0;
280 1.1.14.2 yamt
281 1.1.14.2 yamt case CONFIG_HOOK_CHARGE:
282 1.1.14.2 yamt val = j720pwr_get_battery(ctx);
283 1.1.14.2 yamt
284 1.1.14.2 yamt if (val != -1) {
285 1.1.14.2 yamt for (i = 1; i < arraysize(battery_table); i++) {
286 1.1.14.2 yamt if (val > battery_table[i].value) {
287 1.1.14.2 yamt state = battery_table[i - 1].state;
288 1.1.14.2 yamt break;
289 1.1.14.2 yamt }
290 1.1.14.2 yamt }
291 1.1.14.2 yamt
292 1.1.14.2 yamt if (j720pwr_get_charge_status(ctx) == 0)
293 1.1.14.2 yamt state |= APM_BATT_FLAG_CHARGING;
294 1.1.14.2 yamt } else {
295 1.1.14.2 yamt state = APM_BATT_FLAG_NO_SYSTEM_BATTERY;
296 1.1.14.2 yamt }
297 1.1.14.2 yamt
298 1.1.14.2 yamt *pval = state;
299 1.1.14.2 yamt return 0;
300 1.1.14.2 yamt
301 1.1.14.2 yamt case CONFIG_HOOK_ACADAPTER:
302 1.1.14.2 yamt *pval = j720pwr_get_ac_status(ctx) ? APM_AC_OFF : APM_AC_ON;
303 1.1.14.2 yamt
304 1.1.14.2 yamt return 0;
305 1.1.14.2 yamt }
306 1.1.14.2 yamt
307 1.1.14.2 yamt return EINVAL;
308 1.1.14.2 yamt }
309 1.1.14.2 yamt
310 1.1.14.2 yamt static int
311 1.1.14.2 yamt j720pwr_get_battery(struct j720pwr_softc *sc)
312 1.1.14.2 yamt {
313 1.1.14.2 yamt struct j720ssp_softc *ssp = sc->sc_ssp;
314 1.1.14.2 yamt int data, i, pmdata[3];
315 1.1.14.2 yamt
316 1.1.14.2 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_PCR, 0x2000000);
317 1.1.14.2 yamt
318 1.1.14.3 yamt if (j720ssp_readwrite(ssp, 1, 0xc0, &data, 500) < 0 || data != 0x11) {
319 1.1.14.2 yamt DPRINTF(("j720pwr_get_battery: no dummy received\n"));
320 1.1.14.2 yamt goto out;
321 1.1.14.2 yamt }
322 1.1.14.2 yamt
323 1.1.14.2 yamt for (i = 0; i < 3; i++) {
324 1.1.14.3 yamt if (j720ssp_readwrite(ssp, 0, 0x11, &pmdata[i], 100) < 0)
325 1.1.14.2 yamt goto out;
326 1.1.14.2 yamt }
327 1.1.14.2 yamt
328 1.1.14.2 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_PSR, 0x2000000);
329 1.1.14.2 yamt
330 1.1.14.2 yamt pmdata[0] |= (pmdata[2] & 0x3) << 8; /* Main battery. */
331 1.1.14.2 yamt pmdata[1] |= (pmdata[2] & 0xc) << 6; /* Backup battery (unused). */
332 1.1.14.2 yamt
333 1.1.14.2 yamt DPRINTF(("j720pwr_get_battery: data[0]=%d data[1]=%d data[2]=%d\n",
334 1.1.14.2 yamt pmdata[0], pmdata[1], pmdata[2]));
335 1.1.14.2 yamt
336 1.1.14.2 yamt /* If bit 0 and 1 are both set, the main battery is absent. */
337 1.1.14.2 yamt if ((pmdata[2] & 3) == 3)
338 1.1.14.2 yamt return -1;
339 1.1.14.2 yamt
340 1.1.14.2 yamt return pmdata[0];
341 1.1.14.2 yamt
342 1.1.14.2 yamt out:
343 1.1.14.2 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_PSR, 0x2000000);
344 1.1.14.2 yamt
345 1.1.14.2 yamt /* reset SSP */
346 1.1.14.2 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_ssph, SASSP_CR0, 0x307);
347 1.1.14.2 yamt delay(100);
348 1.1.14.2 yamt bus_space_write_4(ssp->sc_iot, ssp->sc_ssph, SASSP_CR0, 0x387);
349 1.1.14.2 yamt
350 1.1.14.2 yamt DPRINTF(("j720pwr_get_battery: error %x\n", data));
351 1.1.14.2 yamt return 0;
352 1.1.14.2 yamt }
353 1.1.14.2 yamt
354 1.1.14.2 yamt static int
355 1.1.14.2 yamt j720pwr_get_ac_status(struct j720pwr_softc *sc)
356 1.1.14.2 yamt {
357 1.1.14.2 yamt struct j720ssp_softc *ssp = sc->sc_ssp;
358 1.1.14.2 yamt uint32_t status;
359 1.1.14.2 yamt
360 1.1.14.2 yamt status = bus_space_read_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_PLR);
361 1.1.14.2 yamt
362 1.1.14.2 yamt return status & (1 << 4);
363 1.1.14.2 yamt }
364 1.1.14.2 yamt
365 1.1.14.2 yamt static int
366 1.1.14.2 yamt j720pwr_get_charge_status(struct j720pwr_softc *sc)
367 1.1.14.2 yamt {
368 1.1.14.2 yamt struct j720ssp_softc *ssp = sc->sc_ssp;
369 1.1.14.2 yamt uint32_t status;
370 1.1.14.2 yamt
371 1.1.14.2 yamt status = bus_space_read_4(ssp->sc_iot, ssp->sc_gpioh, SAGPIO_PLR);
372 1.1.14.2 yamt
373 1.1.14.2 yamt return status & (1 << 26);
374 1.1.14.2 yamt }
375