lubbock_pcic.c revision 1.1
11.1Sbsh/* $NetBSD: lubbock_pcic.c,v 1.1 2003/08/09 19:38:53 bsh Exp $ */ 21.1Sbsh 31.1Sbsh/*- 41.1Sbsh * Copyright (c) 2001 The NetBSD Foundation, Inc. 51.1Sbsh * All rights reserved. 61.1Sbsh * 71.1Sbsh * This code is derived from software contributed to The NetBSD Foundation 81.1Sbsh * by IWAMOTO Toshihiro. 91.1Sbsh * 101.1Sbsh * Redistribution and use in source and binary forms, with or without 111.1Sbsh * modification, are permitted provided that the following conditions 121.1Sbsh * are met: 131.1Sbsh * 1. Redistributions of source code must retain the above copyright 141.1Sbsh * notice, this list of conditions and the following disclaimer. 151.1Sbsh * 2. Redistributions in binary form must reproduce the above copyright 161.1Sbsh * notice, this list of conditions and the following disclaimer in the 171.1Sbsh * documentation and/or other materials provided with the distribution. 181.1Sbsh * 3. All advertising materials mentioning features or use of this software 191.1Sbsh * must display the following acknowledgement: 201.1Sbsh * This product includes software developed by the NetBSD 211.1Sbsh * Foundation, Inc. and its contributors. 221.1Sbsh * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sbsh * contributors may be used to endorse or promote products derived 241.1Sbsh * from this software without specific prior written permission. 251.1Sbsh * 261.1Sbsh * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sbsh * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sbsh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sbsh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sbsh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sbsh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sbsh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sbsh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sbsh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sbsh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sbsh * POSSIBILITY OF SUCH DAMAGE. 371.1Sbsh */ 381.1Sbsh 391.1Sbsh#include <sys/cdefs.h> 401.1Sbsh__KERNEL_RCSID(0, "$NetBSD: lubbock_pcic.c,v 1.1 2003/08/09 19:38:53 bsh Exp $"); 411.1Sbsh 421.1Sbsh#include <sys/param.h> 431.1Sbsh#include <sys/systm.h> 441.1Sbsh#include <sys/types.h> 451.1Sbsh#include <sys/conf.h> 461.1Sbsh#include <sys/file.h> 471.1Sbsh#include <sys/device.h> 481.1Sbsh#include <sys/kernel.h> 491.1Sbsh#include <sys/kthread.h> 501.1Sbsh#include <sys/malloc.h> 511.1Sbsh 521.1Sbsh#include <machine/bus.h> 531.1Sbsh 541.1Sbsh#include <dev/pcmcia/pcmciachip.h> 551.1Sbsh#include <dev/pcmcia/pcmciavar.h> 561.1Sbsh#include <arm/sa11x0/sa11x0_reg.h> 571.1Sbsh#include <arm/sa11x0/sa11x0_var.h> 581.1Sbsh#include <arm/sa11x0/sa1111_reg.h> 591.1Sbsh#include <arm/sa11x0/sa1111_var.h> 601.1Sbsh#include <arm/sa11x0/sa11x1_pcicreg.h> 611.1Sbsh#include <arm/sa11x0/sa11xx_pcicvar.h> 621.1Sbsh#include <arm/sa11x0/sa11x1_pcicvar.h> 631.1Sbsh 641.1Sbsh#include <evbarm/lubbock/lubbock_reg.h> 651.1Sbsh#include <evbarm/lubbock/lubbock_var.h> 661.1Sbsh 671.1Sbshstatic int sacpcic_match(struct device *, struct cfdata *, void *); 681.1Sbshstatic void sacpcic_attach(struct device *, struct device *, void *); 691.1Sbshstatic void lubbock_set_power(struct sapcic_socket *so, int arg); 701.1Sbshstatic void lubbock_socket_setup(struct sapcic_socket *sp); 711.1Sbsh 721.1Sbshstatic struct sapcic_tag lubbock_sacpcic_functions = { 731.1Sbsh sacpcic_read, 741.1Sbsh sacpcic_write, 751.1Sbsh lubbock_set_power, 761.1Sbsh sacpcic_clear_intr, 771.1Sbsh sacpcic_intr_establish, 781.1Sbsh sacpcic_intr_disestablish 791.1Sbsh}; 801.1Sbsh 811.1SbshCFATTACH_DECL(sacpcic, sizeof(struct sacpcic_softc), 821.1Sbsh sacpcic_match, sacpcic_attach, NULL, NULL); 831.1Sbsh 841.1Sbshstatic int 851.1Sbshsacpcic_match(struct device *parent, struct cfdata *cf, void *aux) 861.1Sbsh{ 871.1Sbsh return (1); 881.1Sbsh} 891.1Sbsh 901.1Sbshstatic void 911.1Sbshlubbock_socket_setup(struct sapcic_socket *sp) 921.1Sbsh{ 931.1Sbsh sp->power_capability = SAPCIC_POWER_5V | SAPCIC_POWER_3V; 941.1Sbsh sp->pcictag = &lubbock_sacpcic_functions; 951.1Sbsh} 961.1Sbsh 971.1Sbshstatic void 981.1Sbshsacpcic_attach(struct device *parent, struct device *self, void *aux) 991.1Sbsh{ 1001.1Sbsh sacpcic_attach_common((struct sacc_softc *)parent, 1011.1Sbsh (struct sacpcic_softc *)self, aux, lubbock_socket_setup); 1021.1Sbsh} 1031.1Sbsh 1041.1Sbsh 1051.1Sbshstatic void 1061.1Sbshlubbock_set_power(struct sapcic_socket *so, int arg) 1071.1Sbsh{ 1081.1Sbsh struct sacc_softc *sc = so->pcictag_cookie; 1091.1Sbsh struct obio_softc *bsc = (struct obio_softc *)sc->sc_dev.dv_parent; 1101.1Sbsh int s; 1111.1Sbsh uint16_t tmp; 1121.1Sbsh 1131.1Sbsh static const uint8_t vval_socket0[] = { 1141.1Sbsh /* for socket0 (pcmcia) */ 1151.1Sbsh 0x00, /* OFF */ 1161.1Sbsh 0x08, /* 3.3V */ 1171.1Sbsh 0x05, /* 5V */ 1181.1Sbsh }; 1191.1Sbsh static const uint16_t vval_socket1[] = { 1201.1Sbsh /* for socket1 (CF) */ 1211.1Sbsh 0x0000, /* OFF */ 1221.1Sbsh 0x8000, /* 3.3V */ 1231.1Sbsh 0x4000, /* 5V */ 1241.1Sbsh }; 1251.1Sbsh 1261.1Sbsh if( arg < 0 || SAPCIC_POWER_5V < arg ) 1271.1Sbsh panic("sacpcic_set_power: bogus arg\n"); 1281.1Sbsh 1291.1Sbsh switch( so->socket ){ 1301.1Sbsh case 0: 1311.1Sbsh bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCGPIOA_DVR, 1321.1Sbsh vval_socket0[arg]); 1331.1Sbsh break; 1341.1Sbsh case 1: 1351.1Sbsh s = splhigh(); 1361.1Sbsh tmp = bus_space_read_2(bsc->sc_iot, bsc->sc_obioreg_ioh, 1371.1Sbsh LUBBOCK_MISCWR); 1381.1Sbsh bus_space_write_2(bsc->sc_iot, bsc->sc_obioreg_ioh, 1391.1Sbsh LUBBOCK_MISCWR, (tmp & 0x3fff) | vval_socket1[arg] ); 1401.1Sbsh splx(s); 1411.1Sbsh break; 1421.1Sbsh default: 1431.1Sbsh printf("unknown socket number: %d\n", so->socket); 1441.1Sbsh } 1451.1Sbsh} 146