Subject: review needed for PC card controller
To: None <tech-kern@netbsd.org>
From: TAKEMURA Shin <takemura@netbsd.org>
List: tech-kern
Date: 11/10/2002 21:08:07
This is a multi-part message in MIME format.

------=_NextPart_000_0099_01C288FD.447336E0
Content-Type: text/plain;
	charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit

Hi there,

RICOH PC card controller, RF5C[23]96 supports 3.3v PC card. And
ngc@ff.iij4u.or.jp
had made a patch to use the function. (attached)
You can use some cards which requires 3.3V with the patch.

BUT the change possibly breaks something. I don't know how many people are
using
RICOH RF5C[23]96. (You are safe unless your laptop have the chip in it.)

I'm going to commit this change next week if no one objects.

Any comments?

Takemura

------=_NextPart_000_0099_01C288FD.447336E0
Content-Type: application/octet-stream;
	name="pcic33v.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="pcic33v.patch"

Index: i82365.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvsroot/syssrc/sys/dev/ic/i82365.c,v=0A=
retrieving revision 1.68=0A=
diff -c -r1.68 i82365.c=0A=
*** i82365.c	2002/10/22 02:12:42	1.68=0A=
--- i82365.c	2002/11/10 11:29:01=0A=
***************=0A=
*** 119,124 ****=0A=
--- 119,125 ----=0A=
  	struct pcic_handle *h;=0A=
  {=0A=
  	int reg;=0A=
+ 	int vendor;=0A=
  =0A=
  	/*=0A=
  	 * the chip_id of the cirrus toggles between 11 and 00 after a write.=0A=
***************=0A=
*** 141,150 ****=0A=
  =0A=
  	reg =3D pcic_read(h, PCIC_IDENT);=0A=
  =0A=
! 	if ((reg & PCIC_IDENT_REV_MASK) =3D=3D PCIC_IDENT_REV_I82365SLR0)=0A=
! 		return (PCIC_VENDOR_I82365SLR0);=0A=
! 	else=0A=
! 		return (PCIC_VENDOR_I82365SLR1);=0A=
  }=0A=
  =0A=
  char *=0A=
--- 142,188 ----=0A=
  =0A=
  	reg =3D pcic_read(h, PCIC_IDENT);=0A=
  =0A=
! 	switch (reg) {=0A=
! 	case PCIC_IDENT_ID_INTEL0:=0A=
! 		vendor =3D PCIC_VENDOR_I82365SLR0;=0A=
! 		break;=0A=
! 	case PCIC_IDENT_ID_INTEL1:=0A=
! 		vendor =3D PCIC_VENDOR_I82365SLR1;=0A=
! 		break;=0A=
! 	case PCIC_IDENT_ID_INTEL2:=0A=
! 		vendor =3D PCIC_VENDOR_I82365SL_DF;=0A=
! 		break;=0A=
! 	case PCIC_IDENT_ID_IBM1:=0A=
! 	case PCIC_IDENT_ID_IBM2:=0A=
! 		vendor =3D PCIC_VENDOR_IBM;=0A=
! 		break;=0A=
! 	case PCIC_IDENT_ID_IBM3:=0A=
! 		vendor =3D PCIC_VENDOR_IBM_KING;=0A=
! 		break;=0A=
! 	default:=0A=
! 		vendor =3D PCIC_VENDOR_UNKNOWN;=0A=
! 		break;=0A=
! 	}=0A=
! =0A=
! 	if (vendor =3D=3D PCIC_VENDOR_I82365SLR0 ||=0A=
! 	    vendor =3D=3D PCIC_VENDOR_I82365SLR1) {=0A=
! 		/*=0A=
! 		 * check for Ricoh RF5C[23]96=0A=
! 		 */=0A=
! 		reg =3D pcic_read(h, PCIC_RICOH_REG_CHIP_ID);=0A=
! 		switch (reg) {=0A=
! 		case PCIC_RICOH_CHIP_ID_5C296:=0A=
! 			vendor =3D PCIC_VENDOR_RICOH_5C296;=0A=
! 			break;=0A=
! 		case PCIC_RICOH_CHIP_ID_5C396:=0A=
! 			vendor =3D PCIC_VENDOR_RICOH_5C396;=0A=
! 			break;=0A=
! 		default:=0A=
! 			break;=0A=
! 		}=0A=
! 	}=0A=
! =0A=
! 	return ( vendor );=0A=
  }=0A=
  =0A=
  char *=0A=
***************=0A=
*** 160,165 ****=0A=
--- 198,213 ----=0A=
  		return ("Cirrus PD6710");=0A=
  	case PCIC_VENDOR_CIRRUS_PD672X:=0A=
  		return ("Cirrus PD672X");=0A=
+ 	case PCIC_VENDOR_I82365SL_DF:=0A=
+ 		return ("Intel 82365SL-DF");=0A=
+ 	case PCIC_VENDOR_RICOH_5C296:=0A=
+ 		return ("Ricoh RF5C296");=0A=
+ 	case PCIC_VENDOR_RICOH_5C396:=0A=
+ 		return ("Ricoh RF5C396");=0A=
+ 	case PCIC_VENDOR_IBM:=0A=
+ 		return ("IBM PCIC");=0A=
+ 	case PCIC_VENDOR_IBM_KING:=0A=
+ 		return ("IBM KING");=0A=
  	}=0A=
  =0A=
  	return ("Unknown controller");=0A=
***************=0A=
*** 1361,1366 ****=0A=
--- 1409,1415 ----=0A=
  {=0A=
  	struct pcic_handle *h =3D (struct pcic_handle *) pch;=0A=
  	int cardtype, win, intr, pwr;=0A=
+ 	int vcc_3v, regtmp;=0A=
  #if defined(DIAGNOSTIC) || defined(PCICDEBUG)=0A=
  	int reg;=0A=
  #endif=0A=
***************=0A=
*** 1384,1389 ****=0A=
--- 1433,1468 ----=0A=
  	 * we are changing Vcc (Toff).=0A=
  	 */=0A=
  	pcic_delay(h, 300 + 100, "pccen0");=0A=
+ =0A=
+ 	/*=0A=
+ 	 * power hack for RICOH RF5C[23]96=0A=
+ 	 */=0A=
+ 	switch( h->vendor ) {=0A=
+ 	case PCIC_VENDOR_RICOH_5C296:=0A=
+ 	case PCIC_VENDOR_RICOH_5C396:=0A=
+ 		vcc_3v =3D 0;=0A=
+ 		regtmp =3D pcic_read(h, PCIC_CARD_DETECT);=0A=
+ 		if(regtmp & PCIC_CARD_DETECT_GPI_ENABLE) {=0A=
+ 			DPRINTF(("\nGPI is enabled. Can't sense VS1\n"));=0A=
+ 		} else {=0A=
+ 			regtmp =3D pcic_read(h, PCIC_IF_STATUS) ;=0A=
+ 			vcc_3v =3D (regtmp & PCIC_IF_STATUS_GPI) ? 1 : 0;=0A=
+ 			DPRINTF(("\n5VDET =3D %s\n",=0A=
+ 				 vcc_3v ? "1 (3.3V)" : "0 (5V)"));=0A=
+ 		}=0A=
+ =0A=
+ 		regtmp =3D pcic_read(h, PCIC_RICOH_REG_MCR2);=0A=
+ 		regtmp &=3D ~PCIC_RICOH_MCR2_VCC_SEL_MASK;=0A=
+ 		if(vcc_3v) {=0A=
+ 			regtmp |=3D PCIC_RICOH_MCR2_VCC_SEL_3V;=0A=
+ 		} else {=0A=
+ 			regtmp |=3D PCIC_RICOH_MCR2_VCC_SEL_5V;=0A=
+ 		}=0A=
+ 		pcic_write(h, PCIC_RICOH_REG_MCR2, regtmp);=0A=
+ 		break;=0A=
+ 	default:=0A=
+ 		break;=0A=
+ 	}=0A=
  =0A=
  #ifdef VADEM_POWER_HACK=0A=
  	bus_space_write_1(sc->iot, sc->ioh, PCIC_REG_INDEX, 0x0e);=0A=
Index: i82365reg.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvsroot/syssrc/sys/dev/ic/i82365reg.h,v=0A=
retrieving revision 1.6=0A=
diff -c -r1.6 i82365reg.h=0A=
*** i82365reg.h	2000/02/28 07:33:08	1.6=0A=
--- i82365reg.h	2002/11/10 11:29:02=0A=
***************=0A=
*** 63,68 ****=0A=
--- 63,75 ----=0A=
  #define	PCIC_IDENT_REV_I82365SLR0		0x02=0A=
  #define	PCIC_IDENT_REV_I82365SLR1		0x03=0A=
  =0A=
+ #define PCIC_IDENT_ID_INTEL0 0x82=0A=
+ #define PCIC_IDENT_ID_INTEL1 0x83=0A=
+ #define PCIC_IDENT_ID_INTEL2 0x84=0A=
+ #define PCIC_IDENT_ID_IBM1 0x88=0A=
+ #define PCIC_IDENT_ID_IBM2 0x89=0A=
+ #define PCIC_IDENT_ID_IBM3 0x8A=0A=
+ =0A=
  #define	PCIC_IF_STATUS				0x01	/* RO */=0A=
  #define	PCIC_IF_STATUS_GPI			0x80 /* General Purpose Input */=0A=
  #define	PCIC_IF_STATUS_POWERACTIVE		0x40=0A=
***************=0A=
*** 336,338 ****=0A=
--- 343,353 ----=0A=
  #define PCIC_CIRRUS_EXTENDED_DATA		0x2F=0A=
  #define PCIC_CIRRUS_EXT_CONTROL_1		0x03=0A=
  #define PCIC_CIRRUS_EXT_CONTROL_1_PCI_INTR_MASK	0x18=0A=
+ =0A=
+ #define PCIC_RICOH_REG_CHIP_ID 0x3A=0A=
+ #define PCIC_RICOH_CHIP_ID_5C296 0x32=0A=
+ #define PCIC_RICOH_CHIP_ID_5C396 0xB2=0A=
+ #define PCIC_RICOH_REG_MCR2 0x2F=0A=
+ #define PCIC_RICOH_MCR2_VCC_SEL_MASK 0x01=0A=
+ #define PCIC_RICOH_MCR2_VCC_SEL_3V 0x01=0A=
+ #define PCIC_RICOH_MCR2_VCC_SEL_5V 0x00=0A=
Index: i82365var.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvsroot/syssrc/sys/dev/ic/i82365var.h,v=0A=
retrieving revision 1.16=0A=
diff -c -r1.16 i82365var.h=0A=
*** i82365var.h	2001/12/15 13:23:21	1.16=0A=
--- i82365var.h	2002/11/10 11:29:03=0A=
***************=0A=
*** 100,105 ****=0A=
--- 100,110 ----=0A=
  #define	PCIC_VENDOR_I82365SLR1		2=0A=
  #define	PCIC_VENDOR_CIRRUS_PD6710	3=0A=
  #define	PCIC_VENDOR_CIRRUS_PD672X	4=0A=
+ #define PCIC_VENDOR_I82365SL_DF		5=0A=
+ #define PCIC_VENDOR_IBM			6=0A=
+ #define PCIC_VENDOR_IBM_KING		7=0A=
+ #define PCIC_VENDOR_RICOH_5C296		8=0A=
+ #define PCIC_VENDOR_RICOH_5C396		9=0A=
  =0A=
  /*=0A=
   * This is sort of arbitrary.  It merely needs to be "enough". It can =
be=0A=

------=_NextPart_000_0099_01C288FD.447336E0--