1 /* $NetBSD: hd64461_machdep.c,v 1.1 2002/03/03 14:34:02 uch 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/param.h> 40 #include <sys/systm.h> 41 42 #include <machine/bus.h> 43 #include <machine/platid.h> 44 #include <machine/platid_mask.h> 45 46 #include <hpcsh/dev/hd64461/hd64461var.h> 47 #include <hpcsh/dev/hd64461/hd64461pcmciavar.h> 48 #include <hpcsh/dev/hd64461/hd64461pcmciareg.h> 49 50 /* 51 * Platform dependent hooks. 52 */ 53 54 void 55 hd64461pcmcia_power(int ch, enum pcmcia_voltage vol, int on) 56 { 57 #define VCC0_ON() \ 58 do { \ 59 r = hd64461_reg_read_1(gcr); \ 60 r |= HD64461_PCCGCR_VCC0; \ 61 hd64461_reg_write_1(gcr, r); \ 62 } while (/*CONSTCOND*/0) 63 #define VCC0_OFF() \ 64 do { \ 65 r = hd64461_reg_read_1(gcr); \ 66 r &= ~HD64461_PCCGCR_VCC0; \ 67 hd64461_reg_write_1(gcr, r); \ 68 } while (/*CONSTCOND*/0) 69 #define VCC1_ON() \ 70 do { \ 71 r = hd64461_reg_read_1(scr); \ 72 r |= HD64461_PCCSCR_VCC1; \ 73 hd64461_reg_write_1(scr, r); \ 74 } while (/*CONSTCOND*/0) 75 #define VCC1_OFF() \ 76 do { \ 77 r = hd64461_reg_read_1(scr); \ 78 r &= ~HD64461_PCCSCR_VCC1; \ 79 hd64461_reg_write_1(scr, r); \ 80 } while (/*CONSTCOND*/0) 81 bus_addr_t isr, gcr, scr; 82 u_int8_t r; 83 84 isr = HD64461_PCCISR(ch); 85 gcr = HD64461_PCCGCR(ch); 86 scr = HD64461_PCCSCR(ch); 87 88 /* 3.3 V */ 89 if (vol == V_3_3) { 90 if (ch == 1) { 91 if (on) { 92 VCC0_OFF(); 93 VCC1_OFF(); 94 } else { 95 VCC0_ON(); 96 VCC1_ON(); 97 } 98 } else { 99 if (on) { 100 VCC0_ON(); 101 VCC1_OFF(); 102 } else { 103 VCC0_OFF(); 104 VCC1_ON(); 105 } 106 } 107 return; 108 } 109 110 /* 5 V */ 111 if (platid_match(&platid, &platid_mask_MACH_HP)) { 112 if (on) { 113 VCC0_OFF(); 114 VCC1_OFF(); 115 } else { 116 VCC0_ON(); 117 VCC1_ON(); 118 } 119 return; 120 } else if (platid_match(&platid, &platid_mask_MACH_HITACHI)) { 121 if (on) { 122 VCC0_OFF(); 123 VCC1_ON(); 124 } else { 125 VCC0_ON(); 126 VCC1_OFF(); 127 } 128 return; 129 } 130 131 /* x.x V, y.y V */ 132 printf("x.x/y.y V not supported.\n"); 133 #undef VCC0_ON 134 #undef VCC0_OFF 135 #undef VCC1_ON 136 #undef VCC1_OFF 137 } 138