Home | History | Annotate | Line # | Download | only in dev
scoop.c revision 1.4.20.1
      1  1.4.20.1    yamt /*	$NetBSD: scoop.c,v 1.4.20.1 2009/05/04 08:12:15 yamt Exp $	*/
      2       1.1    ober /*	$OpenBSD: zaurus_scoop.c,v 1.12 2005/11/17 05:26:31 uwe Exp $	*/
      3       1.1    ober 
      4       1.1    ober /*
      5       1.1    ober  * Copyright (c) 2005 Uwe Stuehler <uwe (at) bsdx.de>
      6       1.1    ober  *
      7       1.1    ober  * Permission to use, copy, modify, and distribute this software for any
      8       1.1    ober  * purpose with or without fee is hereby granted, provided that the above
      9       1.1    ober  * copyright notice and this permission notice appear in all copies.
     10       1.1    ober  *
     11       1.1    ober  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12       1.1    ober  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13       1.1    ober  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14       1.1    ober  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15       1.1    ober  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16       1.1    ober  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17       1.1    ober  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18       1.1    ober  */
     19       1.1    ober 
     20       1.1    ober #include <sys/cdefs.h>
     21  1.4.20.1    yamt __KERNEL_RCSID(0, "$NetBSD: scoop.c,v 1.4.20.1 2009/05/04 08:12:15 yamt Exp $");
     22       1.1    ober 
     23       1.1    ober #include <sys/param.h>
     24       1.1    ober #include <sys/systm.h>
     25       1.1    ober #include <sys/device.h>
     26       1.1    ober #include <sys/conf.h>
     27       1.1    ober #include <sys/gpio.h>
     28       1.1    ober 
     29       1.1    ober #include <machine/bus.h>
     30       1.1    ober 
     31       1.1    ober #include <arm/xscale/pxa2x0var.h>
     32       1.1    ober 
     33       1.1    ober #include <zaurus/zaurus/zaurus_reg.h>
     34       1.1    ober #include <zaurus/zaurus/zaurus_var.h>
     35       1.1    ober 
     36       1.1    ober #include <zaurus/dev/scoopreg.h>
     37       1.1    ober #include <zaurus/dev/scoopvar.h>
     38       1.1    ober 
     39       1.1    ober #include "ioconf.h"
     40       1.1    ober 
     41       1.1    ober struct scoop_softc {
     42  1.4.20.1    yamt 	device_t		sc_dev;
     43       1.2   peter 
     44       1.2   peter 	bus_space_tag_t		sc_iot;
     45       1.2   peter 	bus_space_handle_t	sc_ioh;
     46       1.2   peter 
     47       1.2   peter 	uint16_t		sc_gpwr;	/* GPIO state before suspend */
     48       1.1    ober };
     49       1.1    ober 
     50  1.4.20.1    yamt static int	scoopmatch(device_t, cfdata_t, void *);
     51  1.4.20.1    yamt static void	scoopattach(device_t, device_t, void *);
     52       1.1    ober 
     53  1.4.20.1    yamt CFATTACH_DECL_NEW(scoop, sizeof(struct scoop_softc),
     54  1.4.20.1    yamt     scoopmatch, scoopattach, NULL, NULL);
     55       1.1    ober 
     56       1.2   peter #if 0
     57  1.4.20.1    yamt static int	scoop_gpio_pin_read(struct scoop_softc *, int);
     58       1.2   peter #endif
     59  1.4.20.1    yamt static void	scoop_gpio_pin_write(struct scoop_softc *, int, int);
     60  1.4.20.1    yamt static void	scoop_gpio_pin_ctl(struct scoop_softc *, int, int);
     61       1.1    ober 
     62       1.3  nonaka enum scoop_card {
     63       1.3  nonaka 	SD_CARD,
     64       1.3  nonaka 	CF_CARD		/* socket 0 (external) */
     65       1.3  nonaka };
     66       1.3  nonaka 
     67       1.3  nonaka static void	scoop0_set_card_power(enum scoop_card card, int new_cpr);
     68       1.3  nonaka 
     69       1.1    ober static int
     70  1.4.20.1    yamt scoopmatch(device_t parent, cfdata_t cf, void *aux)
     71       1.1    ober {
     72       1.1    ober 
     73       1.1    ober 	/*
     74       1.1    ober 	 * Only C3000-like models are known to have two SCOOPs.
     75       1.1    ober 	 */
     76       1.1    ober         if (ZAURUS_ISC3000)
     77       1.1    ober 		return (cf->cf_unit < 2);
     78       1.1    ober 	return (cf->cf_unit == 0);
     79       1.1    ober }
     80       1.1    ober 
     81       1.1    ober static void
     82  1.4.20.1    yamt scoopattach(device_t parent, device_t self, void *aux)
     83       1.1    ober {
     84  1.4.20.1    yamt 	struct scoop_softc *sc = device_private(self);
     85       1.1    ober 	struct pxaip_attach_args *pxa = (struct pxaip_attach_args *)aux;
     86       1.1    ober 	bus_addr_t addr;
     87       1.1    ober 	bus_size_t size;
     88       1.1    ober 
     89  1.4.20.1    yamt 	sc->sc_dev = self;
     90       1.1    ober 	sc->sc_iot = pxa->pxa_iot;
     91       1.1    ober 
     92  1.4.20.1    yamt 	aprint_normal(": PCMCIA/GPIO controller\n");
     93  1.4.20.1    yamt 	aprint_naive("\n");
     94  1.4.20.1    yamt 
     95       1.1    ober 	if (pxa->pxa_addr != -1)
     96       1.1    ober 		addr = pxa->pxa_addr;
     97  1.4.20.1    yamt 	else if (sc->sc_dev->dv_unit == 0)
     98       1.1    ober 		addr = C3000_SCOOP0_BASE;
     99       1.1    ober 	else
    100       1.1    ober 		addr = C3000_SCOOP1_BASE;
    101       1.1    ober 
    102       1.1    ober 	size = pxa->pxa_size < SCOOP_SIZE ? SCOOP_SIZE : pxa->pxa_size;
    103       1.1    ober 
    104       1.1    ober 	if (bus_space_map(sc->sc_iot, addr, size, 0, &sc->sc_ioh) != 0) {
    105  1.4.20.1    yamt 		aprint_error_dev(sc->sc_dev, "couldn't map registers\n");
    106       1.1    ober 		return;
    107       1.1    ober 	}
    108       1.1    ober 
    109  1.4.20.1    yamt 	if (ZAURUS_ISC3000 && sc->sc_dev->dv_unit == 1) {
    110       1.1    ober 		scoop_gpio_pin_ctl(sc, SCOOP1_AKIN_PULLUP, GPIO_PIN_OUTPUT);
    111       1.1    ober 		scoop_gpio_pin_write(sc, SCOOP1_AKIN_PULLUP, GPIO_PIN_LOW);
    112       1.1    ober 	} else if (!ZAURUS_ISC3000) {
    113       1.1    ober 		scoop_gpio_pin_ctl(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_OUTPUT);
    114       1.1    ober 		scoop_gpio_pin_write(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_LOW);
    115       1.1    ober 	}
    116       1.1    ober 
    117       1.1    ober }
    118       1.1    ober 
    119       1.2   peter #if 0
    120       1.2   peter static int
    121       1.1    ober scoop_gpio_pin_read(struct scoop_softc *sc, int pin)
    122       1.1    ober {
    123       1.1    ober 	uint16_t bit = (1 << pin);
    124       1.1    ober 	uint16_t rv;
    125       1.1    ober 
    126       1.1    ober 	rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR);
    127       1.2   peter 	return (rv & bit) ? 1 : 0;
    128       1.1    ober }
    129       1.2   peter #endif
    130       1.1    ober 
    131       1.2   peter static void
    132       1.1    ober scoop_gpio_pin_write(struct scoop_softc *sc, int pin, int level)
    133       1.1    ober {
    134       1.1    ober 	uint16_t bit = (1 << pin);
    135       1.1    ober 	uint16_t rv;
    136       1.1    ober 
    137       1.1    ober 	rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR);
    138       1.1    ober 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR,
    139       1.2   peter 	    (level == GPIO_PIN_LOW) ? (rv & ~bit) : (rv | bit));
    140       1.1    ober }
    141       1.1    ober 
    142       1.2   peter static void
    143       1.1    ober scoop_gpio_pin_ctl(struct scoop_softc *sc, int pin, int flags)
    144       1.1    ober {
    145       1.1    ober 	uint16_t bit = (1 << pin);
    146       1.1    ober 	uint16_t rv;
    147       1.1    ober 
    148       1.1    ober 	rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPCR);
    149       1.1    ober 	switch (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
    150       1.1    ober 	case GPIO_PIN_INPUT:
    151       1.1    ober 		rv &= ~bit;
    152       1.1    ober 		break;
    153       1.1    ober 	case GPIO_PIN_OUTPUT:
    154       1.1    ober 		rv |= bit;
    155       1.1    ober 		break;
    156       1.1    ober 	}
    157       1.1    ober 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPCR, rv);
    158       1.1    ober }
    159       1.1    ober 
    160       1.1    ober /*
    161       1.1    ober  * Turn the LCD background light and contrast signal on or off.
    162       1.1    ober  */
    163       1.1    ober void
    164       1.1    ober scoop_set_backlight(int on, int cont)
    165       1.1    ober {
    166  1.4.20.1    yamt 	struct scoop_softc *sc;
    167  1.4.20.1    yamt #if 0
    168  1.4.20.1    yamt 	struct scoop_softc *sc0;
    169  1.4.20.1    yamt 
    170  1.4.20.1    yamt 	sc0 = device_lookup_private(&scoop_cd, 0);
    171  1.4.20.1    yamt #endif
    172       1.1    ober 
    173  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 1);
    174  1.4.20.1    yamt 	if (sc != NULL) {
    175       1.1    ober 		/* C3000 */
    176  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    177       1.1    ober 		    SCOOP1_BACKLIGHT_CONT, !cont);
    178  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    179       1.1    ober 		    SCOOP1_BACKLIGHT_ON, on);
    180       1.1    ober 	}
    181       1.1    ober #if 0
    182  1.4.20.1    yamt 	else if (sc0 != NULL) {
    183  1.4.20.1    yamt 		scoop_gpio_pin_write(sc0,
    184       1.1    ober 		    SCOOP0_BACKLIGHT_CONT, cont);
    185       1.1    ober 	}
    186       1.1    ober #endif
    187       1.1    ober }
    188       1.1    ober 
    189       1.1    ober /*
    190       1.1    ober  * Turn the infrared LED on or off (must be on while transmitting).
    191       1.1    ober  */
    192       1.1    ober void
    193       1.1    ober scoop_set_irled(int on)
    194       1.1    ober {
    195  1.4.20.1    yamt 	struct scoop_softc *sc;
    196       1.2   peter 
    197  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 1);
    198  1.4.20.1    yamt 	if (sc != NULL) {
    199       1.1    ober 		/* IR_ON is inverted */
    200  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    201       1.1    ober 		    SCOOP1_IR_ON, !on);
    202       1.2   peter 	}
    203       1.1    ober }
    204       1.1    ober 
    205       1.1    ober /*
    206       1.1    ober  * Turn the green and orange LEDs on or off.  If the orange LED is on,
    207       1.1    ober  * then it is wired to indicate if A/C is connected.  The green LED has
    208       1.1    ober  * no such predefined function.
    209       1.1    ober  */
    210       1.1    ober void
    211       1.1    ober scoop_led_set(int led, int on)
    212       1.1    ober {
    213  1.4.20.1    yamt 	struct scoop_softc *sc;
    214       1.1    ober 
    215  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 0);
    216  1.4.20.1    yamt 	if (sc != NULL) {
    217       1.1    ober 		if ((led & SCOOP_LED_GREEN) != 0) {
    218  1.4.20.1    yamt 			scoop_gpio_pin_write(sc,
    219       1.1    ober 			    SCOOP0_LED_GREEN, on);
    220       1.1    ober 		}
    221       1.1    ober 		if (scoop_cd.cd_ndevs > 1 && (led & SCOOP_LED_ORANGE) != 0) {
    222  1.4.20.1    yamt 			scoop_gpio_pin_write(sc,
    223       1.1    ober 			    SCOOP0_LED_ORANGE_C3000, on);
    224       1.1    ober 		}
    225       1.1    ober 	}
    226       1.1    ober }
    227       1.1    ober 
    228       1.1    ober /*
    229       1.1    ober  * Enable or disable the headphone output connection.
    230       1.1    ober  */
    231       1.1    ober void
    232       1.1    ober scoop_set_headphone(int on)
    233       1.1    ober {
    234  1.4.20.1    yamt 	struct scoop_softc *sc;
    235       1.1    ober 
    236  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 0);
    237  1.4.20.1    yamt 	if (sc == NULL)
    238       1.1    ober 		return;
    239       1.1    ober 
    240  1.4.20.1    yamt 	scoop_gpio_pin_ctl(sc, SCOOP0_MUTE_L,
    241       1.1    ober 	    GPIO_PIN_OUTPUT);
    242  1.4.20.1    yamt 	scoop_gpio_pin_ctl(sc, SCOOP0_MUTE_R,
    243       1.1    ober 	    GPIO_PIN_OUTPUT);
    244       1.1    ober 
    245       1.1    ober 	if (on) {
    246  1.4.20.1    yamt 		scoop_gpio_pin_write(sc, SCOOP0_MUTE_L,
    247       1.1    ober 		    GPIO_PIN_HIGH);
    248  1.4.20.1    yamt 		scoop_gpio_pin_write(sc, SCOOP0_MUTE_R,
    249       1.1    ober 		    GPIO_PIN_HIGH);
    250       1.1    ober 	} else {
    251  1.4.20.1    yamt 		scoop_gpio_pin_write(sc, SCOOP0_MUTE_L,
    252       1.1    ober 		    GPIO_PIN_LOW);
    253  1.4.20.1    yamt 		scoop_gpio_pin_write(sc, SCOOP0_MUTE_R,
    254       1.1    ober 		    GPIO_PIN_LOW);
    255       1.1    ober 	}
    256       1.1    ober }
    257       1.1    ober 
    258       1.1    ober /*
    259  1.4.20.1    yamt  * Enable or disable the mic bias
    260  1.4.20.1    yamt  */
    261  1.4.20.1    yamt void
    262  1.4.20.1    yamt scoop_set_mic_bias(int onoff)
    263  1.4.20.1    yamt {
    264  1.4.20.1    yamt 	struct scoop_softc *sc1;
    265  1.4.20.1    yamt 
    266  1.4.20.1    yamt 	sc1 = device_lookup_private(&scoop_cd, 1);
    267  1.4.20.1    yamt 	if (sc1 != NULL)
    268  1.4.20.1    yamt 		scoop_gpio_pin_write(sc1, SCOOP1_MIC_BIAS, onoff);
    269  1.4.20.1    yamt }
    270  1.4.20.1    yamt 
    271  1.4.20.1    yamt /*
    272       1.1    ober  * Turn on pullup resistor while not reading the remote control.
    273       1.1    ober  */
    274       1.1    ober void
    275       1.1    ober scoop_akin_pullup(int enable)
    276       1.1    ober {
    277  1.4.20.1    yamt 	struct scoop_softc *sc0;
    278  1.4.20.1    yamt 	struct scoop_softc *sc1;
    279       1.1    ober 
    280  1.4.20.1    yamt 	sc0 = device_lookup_private(&scoop_cd, 0);
    281  1.4.20.1    yamt 	sc1 = device_lookup_private(&scoop_cd, 1);
    282  1.4.20.1    yamt 
    283  1.4.20.1    yamt 	if (sc1 != NULL) {
    284  1.4.20.1    yamt 		scoop_gpio_pin_write(sc1,
    285       1.1    ober 		    SCOOP1_AKIN_PULLUP, enable);
    286  1.4.20.1    yamt 	} else if (sc0 != NULL) {
    287  1.4.20.1    yamt 		scoop_gpio_pin_write(sc0,
    288       1.1    ober 		    SCOOP0_AKIN_PULLUP, enable);
    289       1.1    ober 	}
    290       1.1    ober }
    291       1.1    ober 
    292       1.1    ober void
    293       1.1    ober scoop_battery_temp_adc(int enable)
    294       1.1    ober {
    295  1.4.20.1    yamt 	struct scoop_softc *sc;
    296  1.4.20.1    yamt 
    297  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 0);
    298       1.1    ober 
    299  1.4.20.1    yamt 	if (sc != NULL) {
    300  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    301       1.1    ober 		    SCOOP0_ADC_TEMP_ON_C3000, enable);
    302       1.1    ober 	}
    303       1.1    ober }
    304       1.1    ober 
    305       1.1    ober void
    306       1.1    ober scoop_charge_battery(int enable, int voltage_high)
    307       1.1    ober {
    308  1.4.20.1    yamt 	struct scoop_softc *sc;
    309  1.4.20.1    yamt 
    310  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 0);
    311       1.1    ober 
    312  1.4.20.1    yamt 	if (sc != NULL) {
    313  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    314       1.1    ober 		    SCOOP0_JK_B_C3000, voltage_high);
    315  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    316       1.1    ober 		    SCOOP0_CHARGE_OFF_C3000, !enable);
    317       1.1    ober 	}
    318       1.1    ober }
    319       1.1    ober 
    320       1.1    ober void
    321       1.1    ober scoop_discharge_battery(int enable)
    322       1.1    ober {
    323  1.4.20.1    yamt 	struct scoop_softc *sc;
    324       1.1    ober 
    325  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 0);
    326  1.4.20.1    yamt 
    327  1.4.20.1    yamt 	if (sc != NULL) {
    328  1.4.20.1    yamt 		scoop_gpio_pin_write(sc,
    329       1.1    ober 		    SCOOP0_JK_A_C3000, enable);
    330       1.1    ober 	}
    331       1.1    ober }
    332       1.1    ober 
    333       1.3  nonaka /*
    334       1.3  nonaka  * Enable or disable 3.3V power to the SD/MMC card slot.
    335       1.3  nonaka  */
    336       1.3  nonaka void
    337       1.3  nonaka scoop_set_sdmmc_power(int on)
    338       1.3  nonaka {
    339       1.3  nonaka 
    340       1.3  nonaka 	scoop0_set_card_power(SD_CARD, on ? SCP_CPR_SD_3V : SCP_CPR_OFF);
    341       1.3  nonaka }
    342       1.3  nonaka 
    343       1.3  nonaka /*
    344       1.3  nonaka  * The Card Power Register of the first SCOOP unit controls the power
    345       1.3  nonaka  * for the first CompactFlash slot and the SD/MMC card slot as well.
    346       1.3  nonaka  */
    347       1.2   peter void
    348       1.3  nonaka scoop0_set_card_power(enum scoop_card card, int new_cpr)
    349       1.2   peter {
    350       1.2   peter 	struct scoop_softc *sc;
    351       1.2   peter 	bus_space_tag_t iot;
    352       1.2   peter 	bus_space_handle_t ioh;
    353       1.3  nonaka 	uint16_t cpr;
    354       1.2   peter 
    355  1.4.20.1    yamt 	sc = device_lookup_private(&scoop_cd, 0);
    356  1.4.20.1    yamt 	if (sc == NULL)
    357       1.3  nonaka 		return;
    358       1.2   peter 
    359       1.3  nonaka 	iot = sc->sc_iot;
    360       1.3  nonaka 	ioh = sc->sc_ioh;
    361       1.3  nonaka 
    362       1.3  nonaka 	cpr = bus_space_read_2(iot, ioh, SCOOP_CPR);
    363       1.3  nonaka 	if (new_cpr & SCP_CPR_VOLTAGE_MSK) {
    364       1.3  nonaka 		if (card == CF_CARD)
    365       1.3  nonaka 			cpr |= SCP_CPR_5V;
    366       1.3  nonaka 		else if (card == SD_CARD)
    367       1.3  nonaka 			cpr |= SCP_CPR_SD_3V;
    368       1.3  nonaka 
    369       1.3  nonaka 		scoop_gpio_pin_write(sc, SCOOP0_CF_POWER_C3000, 1);
    370       1.3  nonaka 		if (!ISSET(cpr, SCP_CPR_5V) && !ISSET(cpr, SCP_CPR_SD_3V))
    371       1.3  nonaka 			delay(5000);
    372       1.3  nonaka 		bus_space_write_2(iot, ioh, SCOOP_CPR, cpr | new_cpr);
    373       1.3  nonaka 	} else {
    374       1.3  nonaka 		if (card == CF_CARD)
    375       1.3  nonaka 			cpr &= ~SCP_CPR_5V;
    376       1.3  nonaka 		else if (card == SD_CARD)
    377       1.3  nonaka 			cpr &= ~SCP_CPR_SD_3V;
    378       1.3  nonaka 
    379       1.3  nonaka 		if (!ISSET(cpr, SCP_CPR_5V) && !ISSET(cpr, SCP_CPR_SD_3V)) {
    380       1.3  nonaka 			bus_space_write_2(iot, ioh, SCOOP_CPR, SCP_CPR_OFF);
    381       1.3  nonaka 			delay(1000);
    382       1.3  nonaka 			scoop_gpio_pin_write(sc, SCOOP0_CF_POWER_C3000, 0);
    383       1.3  nonaka 		} else
    384       1.3  nonaka 			bus_space_write_2(iot, ioh, SCOOP_CPR, cpr | new_cpr);
    385       1.2   peter 	}
    386       1.2   peter }
    387       1.2   peter 
    388       1.1    ober void
    389       1.1    ober scoop_check_mcr(void)
    390       1.1    ober {
    391  1.4.20.1    yamt 	struct scoop_softc *sc0, *sc1, *sc;
    392       1.1    ober 	uint16_t v;
    393       1.1    ober 
    394  1.4.20.1    yamt 	sc0 = device_lookup_private(&scoop_cd, 0);
    395  1.4.20.1    yamt 	sc1 = device_lookup_private(&scoop_cd, 1);
    396  1.4.20.1    yamt 
    397       1.1    ober 	/* C3000 */
    398  1.4.20.1    yamt 	if (sc1 != NULL) {
    399  1.4.20.1    yamt 		sc = sc0;
    400       1.1    ober 		v = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR);
    401       1.1    ober 		if ((v & 0x100) == 0) {
    402       1.1    ober 			bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR,
    403       1.1    ober 			    0x0101);
    404       1.1    ober 		}
    405       1.1    ober 
    406  1.4.20.1    yamt 		sc = sc1;
    407       1.1    ober 		v = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR);
    408       1.1    ober 		if ((v & 0x100) == 0) {
    409       1.1    ober 			bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_MCR,
    410       1.1    ober 			    0x0101);
    411       1.1    ober 		}
    412       1.1    ober 	}
    413       1.1    ober }
    414       1.1    ober 
    415       1.1    ober void
    416       1.1    ober scoop_suspend(void)
    417       1.1    ober {
    418  1.4.20.1    yamt 	struct scoop_softc *sc, *sc0, *sc1;
    419       1.1    ober 	uint32_t rv;
    420       1.1    ober 
    421  1.4.20.1    yamt 	sc0 = device_lookup_private(&scoop_cd, 0);
    422  1.4.20.1    yamt 	sc1 = device_lookup_private(&scoop_cd, 1);
    423  1.4.20.1    yamt 
    424  1.4.20.1    yamt 	if (sc0 != NULL) {
    425  1.4.20.1    yamt 		sc = sc0;
    426       1.1    ober 		sc->sc_gpwr = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    427       1.1    ober 		    SCOOP_GPWR);
    428       1.1    ober 		/* C3000 */
    429       1.1    ober 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR,
    430       1.1    ober 		    sc->sc_gpwr & ~((1<<SCOOP0_MUTE_L) | (1<<SCOOP0_MUTE_R) |
    431       1.1    ober 		    (1<<SCOOP0_JK_A_C3000) | (1<<SCOOP0_ADC_TEMP_ON_C3000) |
    432       1.1    ober 		    (1<<SCOOP0_LED_GREEN)));
    433       1.1    ober 	}
    434       1.1    ober 
    435       1.1    ober 	/* C3000 */
    436  1.4.20.1    yamt 	if (sc1 != NULL) {
    437  1.4.20.1    yamt 		sc = sc1;
    438       1.1    ober 		sc->sc_gpwr = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    439       1.1    ober 		    SCOOP_GPWR);
    440       1.1    ober 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR,
    441       1.1    ober 		    sc->sc_gpwr & ~((1<<SCOOP1_RESERVED_4) |
    442       1.1    ober 		    (1<<SCOOP1_RESERVED_5) | (1<<SCOOP1_RESERVED_6) |
    443       1.1    ober 		    (1<<SCOOP1_BACKLIGHT_CONT) | (1<<SCOOP1_BACKLIGHT_ON) |
    444       1.1    ober 		    (1<<SCOOP1_MIC_BIAS)));
    445       1.1    ober 		rv = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR);
    446       1.1    ober 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR,
    447       1.1    ober 		    rv | ((1<<SCOOP1_IR_ON) | (1<<SCOOP1_RESERVED_3)));
    448       1.1    ober 	}
    449       1.1    ober }
    450       1.1    ober 
    451       1.1    ober void
    452       1.1    ober scoop_resume(void)
    453       1.1    ober {
    454  1.4.20.1    yamt 	struct scoop_softc *sc, *sc0, *sc1;
    455  1.4.20.1    yamt 
    456  1.4.20.1    yamt 	sc0 = device_lookup_private(&scoop_cd, 0);
    457  1.4.20.1    yamt 	sc1 = device_lookup_private(&scoop_cd, 1);
    458       1.1    ober 
    459  1.4.20.1    yamt 	if (sc0 != NULL) {
    460  1.4.20.1    yamt 		sc = sc0;
    461       1.1    ober 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR,
    462       1.1    ober 		    sc->sc_gpwr);
    463       1.1    ober 	}
    464       1.1    ober 
    465  1.4.20.1    yamt 	if (sc1 != NULL) {
    466  1.4.20.1    yamt 		sc = sc1;
    467       1.1    ober 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_GPWR,
    468       1.1    ober 		    sc->sc_gpwr);
    469       1.1    ober 	}
    470       1.1    ober }
    471