Home | History | Annotate | Line # | Download | only in hd64461
hd64461_machdep.c revision 1.2
      1 /*	$NetBSD: hd64461_machdep.c,v 1.2 2003/07/15 02:29:37 lukem Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by UCHIYAMA Yasushi.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include <sys/cdefs.h>
     40 __KERNEL_RCSID(0, "$NetBSD: hd64461_machdep.c,v 1.2 2003/07/15 02:29:37 lukem Exp $");
     41 
     42 #include <sys/param.h>
     43 #include <sys/systm.h>
     44 
     45 #include <machine/bus.h>
     46 #include <machine/platid.h>
     47 #include <machine/platid_mask.h>
     48 
     49 #include <hpcsh/dev/hd64461/hd64461var.h>
     50 #include <hpcsh/dev/hd64461/hd64461pcmciavar.h>
     51 #include <hpcsh/dev/hd64461/hd64461pcmciareg.h>
     52 
     53 /*
     54  * Platform dependent hooks.
     55  */
     56 
     57 void
     58 hd64461pcmcia_power(int ch, enum pcmcia_voltage vol, int on)
     59 {
     60 #define VCC0_ON()							\
     61 do {									\
     62 	r = hd64461_reg_read_1(gcr);					\
     63 	r |= HD64461_PCCGCR_VCC0;					\
     64 	hd64461_reg_write_1(gcr, r);					\
     65 } while (/*CONSTCOND*/0)
     66 #define VCC0_OFF()							\
     67 do {									\
     68 	r = hd64461_reg_read_1(gcr);					\
     69 	r &= ~HD64461_PCCGCR_VCC0;					\
     70 	hd64461_reg_write_1(gcr, r);					\
     71 } while (/*CONSTCOND*/0)
     72 #define VCC1_ON()							\
     73 do {									\
     74 	r = hd64461_reg_read_1(scr);					\
     75 	r |= HD64461_PCCSCR_VCC1;					\
     76 	hd64461_reg_write_1(scr, r);					\
     77 } while (/*CONSTCOND*/0)
     78 #define VCC1_OFF()							\
     79 do {									\
     80 	r = hd64461_reg_read_1(scr);					\
     81 	r &= ~HD64461_PCCSCR_VCC1;					\
     82 	hd64461_reg_write_1(scr, r);					\
     83 } while (/*CONSTCOND*/0)
     84 	bus_addr_t isr, gcr, scr;
     85 	u_int8_t r;
     86 
     87 	isr = HD64461_PCCISR(ch);
     88 	gcr = HD64461_PCCGCR(ch);
     89 	scr = HD64461_PCCSCR(ch);
     90 
     91 	/* 3.3 V */
     92 	if (vol == V_3_3) {
     93 		if (ch == 1) {
     94 			if (on) {
     95 				VCC0_OFF();
     96 				VCC1_OFF();
     97 			} else {
     98 				VCC0_ON();
     99 				VCC1_ON();
    100 			}
    101 		} else {
    102 			if (on) {
    103 				VCC0_ON();
    104 				VCC1_OFF();
    105 			} else {
    106 				VCC0_OFF();
    107 				VCC1_ON();
    108 			}
    109 		}
    110 		return;
    111 	}
    112 
    113 	/* 5 V */
    114 	if (platid_match(&platid, &platid_mask_MACH_HP)) {
    115 		if (on) {
    116 			VCC0_OFF();
    117 			VCC1_OFF();
    118 		} else {
    119 			VCC0_ON();
    120 			VCC1_ON();
    121 		}
    122 		return;
    123 	} else if (platid_match(&platid, &platid_mask_MACH_HITACHI)) {
    124 		if (on) {
    125 			VCC0_OFF();
    126 			VCC1_ON();
    127 		} else {
    128 			VCC0_ON();
    129 			VCC1_OFF();
    130 		}
    131 		return;
    132 	}
    133 
    134 	/* x.x V, y.y V */
    135 	printf("x.x/y.y V not supported.\n");
    136 #undef VCC0_ON
    137 #undef VCC0_OFF
    138 #undef VCC1_ON
    139 #undef VCC1_OFF
    140 }
    141