stvii.c revision 1.7 1 1.7 thorpej /* $NetBSD: stvii.c,v 1.7 2023/12/20 14:12:25 thorpej Exp $ */
2 1.1 macallan
3 1.1 macallan /*-
4 1.2 macallan * Copyright (C) 2011 Michael Lorenz.
5 1.1 macallan *
6 1.1 macallan * Redistribution and use in source and binary forms, with or without
7 1.1 macallan * modification, are permitted provided that the following conditions
8 1.1 macallan * are met:
9 1.1 macallan * 1. Redistributions of source code must retain the above copyright
10 1.1 macallan * notice, this list of conditions and the following disclaimer.
11 1.1 macallan * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 macallan * notice, this list of conditions and the following disclaimer in the
13 1.1 macallan * documentation and/or other materials provided with the distribution.
14 1.1 macallan *
15 1.1 macallan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.1 macallan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 1.1 macallan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 1.1 macallan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 1.1 macallan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 1.1 macallan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 1.1 macallan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 1.1 macallan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 1.1 macallan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 1.1 macallan * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 1.1 macallan */
26 1.1 macallan
27 1.1 macallan /*
28 1.1 macallan * a driver for the ST7 microcontroller found in Gdium Liberty 1000 notebooks
29 1.1 macallan */
30 1.1 macallan
31 1.1 macallan
32 1.1 macallan #include <sys/cdefs.h>
33 1.7 thorpej __KERNEL_RCSID(0, "$NetBSD: stvii.c,v 1.7 2023/12/20 14:12:25 thorpej Exp $");
34 1.1 macallan
35 1.1 macallan #include <sys/param.h>
36 1.1 macallan #include <sys/systm.h>
37 1.1 macallan #include <sys/kernel.h>
38 1.1 macallan #include <sys/device.h>
39 1.1 macallan #include <sys/sysctl.h>
40 1.1 macallan #include <sys/kthread.h>
41 1.1 macallan #include <sys/proc.h>
42 1.1 macallan
43 1.1 macallan #include <dev/sysmon/sysmonvar.h>
44 1.1 macallan #include <dev/sysmon/sysmon_taskq.h>
45 1.1 macallan
46 1.1 macallan #include <dev/i2c/i2cvar.h>
47 1.1 macallan
48 1.1 macallan #include "opt_stvii.h"
49 1.1 macallan
50 1.1 macallan #ifdef STVII_DEBUG
51 1.1 macallan #define DPRINTF aprint_error
52 1.1 macallan #else
53 1.1 macallan #define DPRINTF while (0) printf
54 1.1 macallan #endif
55 1.1 macallan
56 1.1 macallan /* register definitions from OpenBSD */
57 1.1 macallan #define ST7_VERSION 0x00 /* only on later mobos */
58 1.1 macallan
59 1.1 macallan #define ST7_STATUS 0x01
60 1.1 macallan #define STS_LID_CLOSED 0x01
61 1.1 macallan #define STS_POWER_BTN_DOWN 0x02
62 1.1 macallan #define STS_BATTERY_PRESENT 0x04 /* not available on old mobo */
63 1.1 macallan #define STS_POWER_AVAILABLE 0x08
64 1.1 macallan #define STS_WAVELAN_BTN_DOWN 0x10 /* ``enable'' on old mobo */
65 1.1 macallan #define STS_AC_AVAILABLE 0x20
66 1.1 macallan #define ST7_CONTROL 0x02
67 1.1 macallan #define STC_DDR_CLOCK 0x01
68 1.1 macallan #define STC_CHARGE_LED_LIT 0x02
69 1.1 macallan #define STC_BEEP 0x04
70 1.1 macallan #define STC_DDR_POWER 0x08
71 1.1 macallan #define STC_TRICKLE 0x10 /* trickle charge rate */
72 1.1 macallan #define STC_RADIO_ENABLE 0x20 /* enable wavelan rf, later mobos */
73 1.1 macallan #define STC_MAIN_POWER 0x40
74 1.1 macallan #define STC_CHARGE_ENABLE 0x80
75 1.1 macallan #define ST7_BATTERY_L 0x03
76 1.1 macallan #define ST7_BATTERY_H 0x04
77 1.1 macallan #define ST7_SIGNATURE 0x05
78 1.1 macallan #define STSIG_EC_CONTROL 0x00
79 1.1 macallan #define STSIG_OS_CONTROL 0xae
80 1.1 macallan /* rough battery operating state limits */
81 1.1 macallan #define STSEC_BAT_MIN_VOLT 7000000 /* 7V */
82 1.1 macallan #define STSEC_BAT_MAX_VOLT 8000000 /* 8V */
83 1.1 macallan
84 1.1 macallan #define BAT_AC_PRESENT 0
85 1.1 macallan #define BAT_BATTERY_PRESENT 1
86 1.1 macallan #define BAT_CHARGING 2
87 1.1 macallan #define BAT_CHARGE 3
88 1.1 macallan #define BAT_MAX_CHARGE 4
89 1.1 macallan #define BAT_NSENSORS 5
90 1.1 macallan
91 1.1 macallan struct stvii_softc {
92 1.1 macallan device_t sc_dev;
93 1.1 macallan i2c_tag_t sc_i2c;
94 1.2 macallan int sc_address, sc_version;
95 1.1 macallan int sc_sleep;
96 1.4 macallan int sc_flags, sc_charge, sc_bat_level;
97 1.4 macallan uint8_t sc_control;
98 1.1 macallan struct sysmon_envsys *sc_sme;
99 1.1 macallan envsys_data_t sc_sensor[BAT_NSENSORS];
100 1.1 macallan struct sysmon_pswitch sc_sm_acpower;
101 1.1 macallan struct sysmon_pswitch sc_sm_lid;
102 1.2 macallan struct sysmon_pswitch sc_sm_powerbutton;
103 1.1 macallan };
104 1.1 macallan
105 1.1 macallan static void stvii_attach(device_t, device_t, void *);
106 1.1 macallan static int stvii_match(device_t, cfdata_t, void *);
107 1.1 macallan static void stvii_writereg(struct stvii_softc *, int, uint8_t);
108 1.2 macallan static int stvii_readreg(struct stvii_softc *, int);
109 1.1 macallan static void stvii_worker(void *);
110 1.3 macallan static void stvii_setup_envsys(struct stvii_softc *);
111 1.3 macallan static void stvii_refresh(struct sysmon_envsys *, envsys_data_t *);
112 1.4 macallan static int stvii_battery_level(struct stvii_softc *);
113 1.1 macallan
114 1.1 macallan CFATTACH_DECL_NEW(stvii, sizeof(struct stvii_softc),
115 1.1 macallan stvii_match, stvii_attach, NULL, NULL);
116 1.1 macallan
117 1.4 macallan void stvii_poweroff(void);
118 1.4 macallan static device_t stvii_dev = NULL;
119 1.4 macallan
120 1.4 macallan #define BAT_FULL 8000000
121 1.4 macallan #define BAT_LOW 7100000
122 1.4 macallan
123 1.1 macallan static int
124 1.1 macallan stvii_match(device_t parent, cfdata_t cf, void *aux)
125 1.1 macallan {
126 1.1 macallan struct i2c_attach_args *args = aux;
127 1.1 macallan int ret = -1;
128 1.1 macallan uint8_t out = ST7_VERSION, in = 0;
129 1.1 macallan
130 1.1 macallan /* see if we can talk to something at address 0x40 */
131 1.1 macallan if (args->ia_addr == 0x40) {
132 1.1 macallan iic_acquire_bus(args->ia_tag, 0);
133 1.1 macallan ret = iic_exec(args->ia_tag, I2C_OP_READ_WITH_STOP, args->ia_addr,
134 1.1 macallan &out, 1, &in, 1, 0);
135 1.1 macallan DPRINTF("%02x\n", in);
136 1.1 macallan iic_release_bus(args->ia_tag, 0);
137 1.1 macallan }
138 1.6 thorpej return (ret >= 0) ? I2C_MATCH_ADDRESS_AND_PROBE : 0;
139 1.1 macallan }
140 1.1 macallan
141 1.1 macallan static void
142 1.1 macallan stvii_attach(device_t parent, device_t self, void *aux)
143 1.1 macallan {
144 1.1 macallan struct stvii_softc *sc = device_private(self);
145 1.1 macallan struct i2c_attach_args *args = aux;
146 1.1 macallan uint8_t ver, reg;
147 1.1 macallan
148 1.1 macallan sc->sc_dev = self;
149 1.4 macallan stvii_dev = self;
150 1.1 macallan sc->sc_address = args->ia_addr;
151 1.1 macallan aprint_normal(": ST7 Microcontroller\n");
152 1.1 macallan sc->sc_i2c = args->ia_tag;
153 1.1 macallan ver = stvii_readreg(sc, ST7_VERSION);
154 1.2 macallan sc->sc_version = ver;
155 1.1 macallan aprint_normal_dev(sc->sc_dev, "firmware version %d.%d\n", (ver >> 4) & 0xf, ver & 0xf);
156 1.1 macallan #ifdef STVII_DEBUG
157 1.1 macallan {
158 1.1 macallan int i;
159 1.1 macallan
160 1.1 macallan for (i = 0; i < 6; i++) {
161 1.1 macallan printf("%02x ", stvii_readreg(sc, i));
162 1.1 macallan }
163 1.1 macallan printf("\n");
164 1.1 macallan }
165 1.1 macallan #endif
166 1.4 macallan stvii_writereg(sc, ST7_SIGNATURE, STSIG_OS_CONTROL);
167 1.1 macallan reg = stvii_readreg(sc, ST7_CONTROL);
168 1.1 macallan reg |= STC_RADIO_ENABLE;
169 1.1 macallan stvii_writereg(sc, ST7_CONTROL, reg);
170 1.4 macallan sc->sc_control = reg;
171 1.1 macallan reg = stvii_readreg(sc, ST7_CONTROL);
172 1.1 macallan
173 1.4 macallan sc->sc_bat_level = stvii_battery_level(sc);
174 1.4 macallan
175 1.1 macallan if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, stvii_worker, sc,
176 1.1 macallan NULL, "stvii") != 0) {
177 1.1 macallan aprint_error_dev(sc->sc_dev, "Failed to start kernel thread\n");
178 1.1 macallan }
179 1.1 macallan
180 1.1 macallan memset(&sc->sc_sm_acpower, 0, sizeof(struct sysmon_pswitch));
181 1.1 macallan sc->sc_sm_acpower.smpsw_name = "AC Power";
182 1.1 macallan sc->sc_sm_acpower.smpsw_type = PSWITCH_TYPE_ACADAPTER;
183 1.1 macallan if (sysmon_pswitch_register(&sc->sc_sm_acpower) != 0)
184 1.1 macallan printf("%s: unable to register AC power status with sysmon\n",
185 1.1 macallan device_xname(sc->sc_dev));
186 1.1 macallan memset(&sc->sc_sm_lid, 0, sizeof(struct sysmon_pswitch));
187 1.1 macallan sc->sc_sm_lid.smpsw_name = "Lid Switch";
188 1.1 macallan sc->sc_sm_lid.smpsw_type = PSWITCH_TYPE_LID;
189 1.1 macallan if (sysmon_pswitch_register(&sc->sc_sm_lid) != 0)
190 1.1 macallan printf("%s: unable to register lid switch with sysmon\n",
191 1.1 macallan device_xname(sc->sc_dev));
192 1.2 macallan memset(&sc->sc_sm_powerbutton, 0, sizeof(struct sysmon_pswitch));
193 1.2 macallan sc->sc_sm_powerbutton.smpsw_name = "Power Button";
194 1.2 macallan sc->sc_sm_powerbutton.smpsw_type = PSWITCH_TYPE_POWER;
195 1.2 macallan if (sysmon_pswitch_register(&sc->sc_sm_powerbutton) != 0)
196 1.2 macallan printf("%s: unable to register power button with sysmon\n",
197 1.2 macallan device_xname(sc->sc_dev));
198 1.3 macallan stvii_setup_envsys(sc);
199 1.1 macallan }
200 1.1 macallan
201 1.1 macallan static void
202 1.1 macallan stvii_writereg(struct stvii_softc *sc, int reg, uint8_t val)
203 1.1 macallan {
204 1.1 macallan uint8_t out[2] = {reg, val};
205 1.1 macallan
206 1.1 macallan if ((reg < 0) || (reg > 5))
207 1.1 macallan return;
208 1.1 macallan
209 1.1 macallan iic_acquire_bus(sc->sc_i2c, 0);
210 1.1 macallan iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_address, out, 2, NULL, 0, 0);
211 1.1 macallan iic_release_bus(sc->sc_i2c, 0);
212 1.1 macallan }
213 1.1 macallan
214 1.2 macallan static int
215 1.1 macallan stvii_readreg(struct stvii_softc *sc, int reg)
216 1.1 macallan {
217 1.1 macallan uint8_t inreg[1], outreg[1];
218 1.2 macallan int ret = 1, bail = 0;
219 1.1 macallan
220 1.1 macallan if ((reg < 0) || (reg > 5))
221 1.1 macallan return 0xff;
222 1.1 macallan inreg[0] = 0x77;
223 1.1 macallan outreg[0] = reg;
224 1.1 macallan iic_acquire_bus(sc->sc_i2c, 0);
225 1.2 macallan while ((ret != 0) && (bail < 10)) {
226 1.2 macallan ret = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
227 1.2 macallan sc->sc_address, outreg, 1, inreg, 1, 0);
228 1.2 macallan bail++;
229 1.2 macallan delay(10);
230 1.2 macallan }
231 1.1 macallan iic_release_bus(sc->sc_i2c, 0);
232 1.2 macallan if (ret != 0)
233 1.2 macallan return -1;
234 1.1 macallan return inreg[0];
235 1.1 macallan }
236 1.1 macallan
237 1.1 macallan static int
238 1.1 macallan stvii_battery_level(struct stvii_softc *sc)
239 1.1 macallan {
240 1.3 macallan int bl, bh, ret;
241 1.1 macallan
242 1.1 macallan bl = stvii_readreg(sc, ST7_BATTERY_L);
243 1.1 macallan bh = stvii_readreg(sc, ST7_BATTERY_H);
244 1.3 macallan ret = (bl & 3) | (bh << 2);
245 1.3 macallan ret = ((ret * 10000) / 1024) * 1000;
246 1.3 macallan return ret;
247 1.1 macallan }
248 1.1 macallan
249 1.1 macallan static void
250 1.1 macallan stvii_worker(void *cookie)
251 1.1 macallan {
252 1.1 macallan struct stvii_softc *sc = cookie;
253 1.4 macallan int status = 0, st, cnt = 4;
254 1.4 macallan int bl;
255 1.4 macallan int charging = 0;
256 1.1 macallan int ok = TRUE;
257 1.4 macallan uint8_t nctrl;
258 1.4 macallan
259 1.4 macallan /* if we were charging when we took over, keep charging */
260 1.4 macallan if (sc->sc_control & STC_CHARGE_ENABLE)
261 1.4 macallan charging = 1;
262 1.1 macallan
263 1.1 macallan while (ok) {
264 1.1 macallan st = stvii_readreg(sc, ST7_STATUS);
265 1.2 macallan /*
266 1.2 macallan * I get i2c timeouts when the power button is pressed.
267 1.2 macallan * According to the linux driver this happens on firmware
268 1.2 macallan * version 0x13 and newer, mine is 0x16.
269 1.2 macallan * So, when we see read errors on the right version we assume
270 1.2 macallan * it's the power button as long as the lid is open
271 1.2 macallan * ( the button is inside the lid )
272 1.2 macallan */
273 1.2 macallan if ((st == -1) && (sc->sc_version >= 0x13)) {
274 1.2 macallan if ((status & (STS_LID_CLOSED | STS_POWER_BTN_DOWN) )
275 1.2 macallan == 0) {
276 1.2 macallan st = status | STS_POWER_BTN_DOWN;
277 1.2 macallan }
278 1.2 macallan }
279 1.2 macallan if ((st != -1) && (st != status)) {
280 1.1 macallan if ((status ^ st) & STS_LID_CLOSED) {
281 1.1 macallan sysmon_pswitch_event(&sc->sc_sm_lid,
282 1.1 macallan ((st & STS_LID_CLOSED) ?
283 1.1 macallan PSWITCH_EVENT_PRESSED :
284 1.1 macallan PSWITCH_EVENT_RELEASED));
285 1.1 macallan }
286 1.1 macallan if ((status ^ st) & STS_AC_AVAILABLE) {
287 1.1 macallan sysmon_pswitch_event(&sc->sc_sm_acpower,
288 1.1 macallan ((st & STS_AC_AVAILABLE) ?
289 1.1 macallan PSWITCH_EVENT_PRESSED :
290 1.1 macallan PSWITCH_EVENT_RELEASED));
291 1.1 macallan }
292 1.2 macallan if ((status ^ st) & STS_POWER_BTN_DOWN) {
293 1.2 macallan sysmon_pswitch_event(&sc->sc_sm_powerbutton,
294 1.2 macallan ((st & STS_POWER_BTN_DOWN) ?
295 1.2 macallan PSWITCH_EVENT_PRESSED :
296 1.2 macallan PSWITCH_EVENT_RELEASED));
297 1.2 macallan }
298 1.1 macallan status = st;
299 1.1 macallan }
300 1.3 macallan sc->sc_flags = status;
301 1.4 macallan if (cnt >= 4) {
302 1.4 macallan nctrl = sc->sc_control & ~(STC_TRICKLE | STC_CHARGE_ENABLE);
303 1.1 macallan bl = stvii_battery_level(sc);
304 1.4 macallan sc->sc_bat_level = bl;
305 1.5 christos if (charging && (bl > BAT_FULL)) {
306 1.4 macallan /* stop charging, we're full */
307 1.4 macallan charging = 0;
308 1.5 christos } else if (!charging && (bl < BAT_LOW)) {
309 1.4 macallan charging = 1;
310 1.1 macallan }
311 1.4 macallan if (st & STS_AC_AVAILABLE) {
312 1.4 macallan if (charging) {
313 1.4 macallan nctrl |= STC_CHARGE_ENABLE;
314 1.4 macallan } else
315 1.4 macallan nctrl |= STC_TRICKLE;
316 1.4 macallan }
317 1.4 macallan if (nctrl != sc->sc_control) {
318 1.4 macallan sc->sc_control = nctrl;
319 1.4 macallan stvii_writereg(sc, ST7_CONTROL, sc->sc_control);
320 1.4 macallan }
321 1.4 macallan cnt = 0;
322 1.4 macallan } else
323 1.4 macallan cnt++;
324 1.1 macallan tsleep(&sc->sc_sleep, 0, "stvii", hz / 2);
325 1.1 macallan }
326 1.1 macallan }
327 1.3 macallan
328 1.3 macallan #define INITDATA(index, unit, string) \
329 1.3 macallan sc->sc_sensor[index].units = unit; \
330 1.3 macallan sc->sc_sensor[index].state = ENVSYS_SINVALID; \
331 1.3 macallan snprintf(sc->sc_sensor[index].desc, \
332 1.3 macallan sizeof(sc->sc_sensor[index].desc), "%s", string);
333 1.3 macallan
334 1.3 macallan static void
335 1.3 macallan stvii_setup_envsys(struct stvii_softc *sc)
336 1.3 macallan {
337 1.3 macallan int i;
338 1.3 macallan
339 1.3 macallan sc->sc_sme = sysmon_envsys_create();
340 1.3 macallan
341 1.3 macallan INITDATA(BAT_AC_PRESENT, ENVSYS_INDICATOR, "AC present");
342 1.3 macallan INITDATA(BAT_BATTERY_PRESENT, ENVSYS_INDICATOR, "Battery present");
343 1.3 macallan INITDATA(BAT_CHARGING, ENVSYS_BATTERY_CHARGE, "Battery charging");
344 1.3 macallan INITDATA(BAT_CHARGE, ENVSYS_SVOLTS_DC, "Battery voltage");
345 1.3 macallan INITDATA(BAT_MAX_CHARGE, ENVSYS_SVOLTS_DC, "Battery design cap");
346 1.3 macallan #undef INITDATA
347 1.3 macallan
348 1.3 macallan for (i = 0; i < BAT_NSENSORS; i++) {
349 1.3 macallan if (sysmon_envsys_sensor_attach(sc->sc_sme,
350 1.3 macallan &sc->sc_sensor[i])) {
351 1.3 macallan sysmon_envsys_destroy(sc->sc_sme);
352 1.3 macallan return;
353 1.3 macallan }
354 1.3 macallan }
355 1.3 macallan
356 1.3 macallan sc->sc_sme->sme_name = device_xname(sc->sc_dev);
357 1.3 macallan sc->sc_sme->sme_cookie = sc;
358 1.3 macallan sc->sc_sme->sme_refresh = stvii_refresh;
359 1.3 macallan
360 1.3 macallan if (sysmon_envsys_register(sc->sc_sme)) {
361 1.3 macallan aprint_error_dev(sc->sc_dev,
362 1.3 macallan "unable to register with sysmon\n");
363 1.3 macallan sysmon_envsys_destroy(sc->sc_sme);
364 1.3 macallan }
365 1.3 macallan }
366 1.3 macallan
367 1.3 macallan static void
368 1.3 macallan stvii_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
369 1.3 macallan {
370 1.3 macallan struct stvii_softc *sc = sme->sme_cookie;
371 1.4 macallan int which = edata->sensor;
372 1.3 macallan
373 1.3 macallan edata->state = ENVSYS_SINVALID;
374 1.3 macallan switch (which) {
375 1.3 macallan case BAT_AC_PRESENT:
376 1.3 macallan edata->value_cur = (sc->sc_flags & STS_AC_AVAILABLE);
377 1.3 macallan edata->state = ENVSYS_SVALID;
378 1.3 macallan break;
379 1.3 macallan case BAT_BATTERY_PRESENT:
380 1.3 macallan edata->value_cur = (sc->sc_flags & STS_BATTERY_PRESENT);
381 1.3 macallan edata->state = ENVSYS_SVALID;
382 1.3 macallan break;
383 1.3 macallan case BAT_CHARGE:
384 1.3 macallan if (sc->sc_flags & STS_BATTERY_PRESENT) {
385 1.4 macallan edata->value_cur = sc->sc_bat_level;
386 1.3 macallan edata->state = ENVSYS_SVALID;
387 1.3 macallan }
388 1.3 macallan break;
389 1.3 macallan case BAT_MAX_CHARGE:
390 1.3 macallan if (sc->sc_flags & STS_BATTERY_PRESENT) {
391 1.4 macallan edata->value_cur = 8000000;
392 1.3 macallan /*edata->state = ENVSYS_SVALID;*/
393 1.3 macallan }
394 1.3 macallan break;
395 1.3 macallan case BAT_CHARGING:
396 1.4 macallan edata->value_cur = sc->sc_control & STC_CHARGE_ENABLE;
397 1.3 macallan edata->state = ENVSYS_SVALID;
398 1.3 macallan break;
399 1.3 macallan }
400 1.3 macallan }
401 1.4 macallan
402 1.4 macallan void
403 1.4 macallan stvii_poweroff(void)
404 1.4 macallan {
405 1.4 macallan struct stvii_softc *sc = device_private(stvii_dev);
406 1.4 macallan int ctl;
407 1.4 macallan
408 1.4 macallan if (sc == NULL)
409 1.4 macallan return;
410 1.4 macallan ctl = stvii_readreg(sc, ST7_CONTROL);
411 1.4 macallan if (ctl == -1)
412 1.4 macallan return;
413 1.4 macallan stvii_writereg(sc, ST7_CONTROL, ctl & ~(STC_MAIN_POWER | STC_DDR_POWER));
414 1.4 macallan }
415