Subject: kern/9463: no interrupt on card detect after resume
To: None <gnats-bugs@gnats.netbsd.org>
From: Atsushi Onoe <onoe@sm.sony.co.jp>
List: netbsd-bugs
Date: 02/21/2000 17:57:42
>Number:         9463
>Category:       kern
>Synopsis:       no interrupt on card detect after resume
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 21 17:57:00 2000
>Last-Modified:
>Originator:     Atsushi Onoe
>Organization:
	
>Release:        NetBSD-current source as of Feb 20, 2000
>Environment:
	
System: NetBSD duplo.sm.sony.co.jp 1.4T NetBSD 1.4T (DUPLO) #79: Tue Feb 22 08:53:27 JST 2000 onoe@duplo.sm.sony.co.jp:/usr/obj/DUPLO i386


>Description:
	With cardbus configuration, VAIO PCG-N505AS does not interrupt on
	card detect after resume.  It seems that APM BIOS does not preserve
	all states of RL5C475 correctly.
	In this state, the interrupts from the card are still delivered
	after reinitializing, e.g.  by "ifconfig down; ifconfig up"
>How-To-Repeat:
	insert/remove the card from slot after resume.
	with cardbus configuration on PCG-N505, PCG-C2 (ACPI VAIO notebooks)
>Fix:
	copy workaround from dev/ic/i82365.c

Index: pccbb.c
===================================================================
RCS file: /usr/cvsroot/netbsd/syssrc/sys/dev/pci/pccbb.c,v
retrieving revision 1.23
diff -c -r1.23 pccbb.c
*** pccbb.c	2000/02/06 08:14:13	1.23
--- pccbb.c	2000/02/22 00:13:22
***************
*** 167,172 ****
--- 167,173 ----
  static void pccbb_pcmcia_do_io_map __P((struct pcic_handle *, int));
  static void pccbb_pcmcia_wait_ready __P((struct pcic_handle *));
  static void pccbb_pcmcia_do_mem_map __P((struct pcic_handle *, int));
+ static void pccbb_powerhook __P((int, void *));
  
  /* bus-space allocation and disallocation functions */
  #if rbus
***************
*** 587,592 ****
--- 588,594 ----
  	}
  
  	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
+ 	powerhook_establish(pccbb_powerhook, sc);
  
  	{
  		u_int32_t sockstat =
***************
*** 3103,3105 ****
--- 3105,3139 ----
  }
  
  #endif /* rbus */
+ 
+ static void
+ pccbb_powerhook (why, arg)
+ 	int why;
+ 	void *arg;
+ {
+ 	struct pccbb_softc *sc = arg;
+ 	u_int32_t reg;
+ 	bus_space_tag_t base_memt = sc->sc_base_memt;	/* socket regs memory */
+ 	bus_space_handle_t base_memh = sc->sc_base_memh;
+ 
+ 	DPRINTF(("%s: power: why %d\n", sc->sc_dev.dv_xname, why));
+ 
+ 	if (why == PWR_RESUME) {
+ 		/* CSC Interrupt: Card detect interrupt on */
+ 		reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_MASK);
+ 		/* Card detect intr is turned on. */
+ 		reg |= CB_SOCKET_MASK_CD;
+ 		bus_space_write_4(base_memt, base_memh, CB_SOCKET_MASK, reg);
+ 		/* reset interrupt */
+ 		reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_EVENT);
+ 		bus_space_write_4(base_memt, base_memh, CB_SOCKET_EVENT, reg);
+ 
+ 		/*
+ 		 * check for card insertion or removal during suspend period.
+ 		 * XXX: the code can't cope with card swap (remove then insert).
+ 		 * how can we detect such situation?
+ 		 */
+ 		if (why == PWR_RESUME)
+ 			(void)pccbbintr(sc);
+ 	}
+ }
>Audit-Trail:
>Unformatted: