Subject: port-powerpc/23624: evbppc (OPENBLOCKS266) cardbus patch
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <kiyohara@kk.iij4u.or.jp>
List: netbsd-bugs
Date: 12/02/2003 17:39:38
>Number:         23624
>Category:       port-powerpc
>Synopsis:       evbppc (OPENBLOCKS266) cardbus patch
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-powerpc-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 02 17:40:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     KIYOHARA Takashi
>Release:        NetBSD 1.6ZF
>Organization:
>Environment:
NetBSD evbppc.fool 1.6ZF NetBSD 1.6ZF (OPENBLOCKS266) #0: Sun Nov 23 18:27:43 JST 2003 lance@hierophant.fool:/usr/src/sys/arch/evbppc/compile/OPENBLOCKS266 evbppc

>Description:
I wrote patch at OpenBlocks266 option PCMCIA BOX (Cardbus).

>How-To-Repeat:

>Fix:
Index: arch/evbppc/conf/OPENBLOCKS266
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/conf/OPENBLOCKS266,v
retrieving revision 1.6
diff -c -r1.6 OPENBLOCKS266
*** arch/evbppc/conf/OPENBLOCKS266	2003/10/18 08:30:14	1.6
--- arch/evbppc/conf/OPENBLOCKS266	2003/11/23 12:15:04
***************
*** 169,186 ****
  lxtphy*	at mii? phy ?			# Level One LXT-970 PHYs
  ukphy*	at mii? phy ?			# generic unknown PHYs
  
! #cardslot* at cbb?
! #cardbus* at cardslot?
! #pcmcia*	at cardslot?
  
! #com*	at pcmcia? function ?		# Modems and serial cards
! #wdc*	at pcmcia? function ?		# PCMCIA IDE controllers
! #ep*	at pcmcia? function ?		# 3Com 3c589 and 3c562 Ethernet
! #mbe*	at pcmcia? function ?		# MB8696x based Ethernet
! #ne*	at pcmcia? function ?		# NE2000-compatible Ethernet
! #ex*	at cardbus? dev ? function ?	# 3Com 3C575TX
! #tlp*	at cardbus? dev ? function ?	# DECchip 21143
! #rtk*	at cardbus? dev ? function ?	# Realtek 8129/8139
  
  wd*	at atabus? drive ?
  
--- 158,176 ----
  lxtphy*	at mii? phy ?			# Level One LXT-970 PHYs
  ukphy*	at mii? phy ?			# generic unknown PHYs
  
! cbb*	at pci? dev ? function ?
! cardslot* at cbb?
! cardbus* at cardslot?
! pcmcia*	at cardslot?
  
! com*	at pcmcia? function ?		# Modems and serial cards
! wdc*	at pcmcia? function ?		# PCMCIA IDE controllers
! ep*	at pcmcia? function ?		# 3Com 3c589 and 3c562 Ethernet
! mbe*	at pcmcia? function ?		# MB8696x based Ethernet
! ne*	at pcmcia? function ?		# NE2000-compatible Ethernet
! ex*	at cardbus? dev ? function ?	# 3Com 3C575TX
! tlp*	at cardbus? dev ? function ?	# DECchip 21143
! rtk*	at cardbus? dev ? function ?	# Realtek 8129/8139
  
  wd*	at atabus? drive ?
  
Index: arch/evbppc/conf/files.obs405
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/conf/files.obs405,v
retrieving revision 1.4
diff -c -r1.4 files.obs405
*** arch/evbppc/conf/files.obs405	2003/11/19 14:27:24	1.4
--- arch/evbppc/conf/files.obs405	2003/11/23 12:15:04
***************
*** 34,37 ****
  include "dev/cardbus/files.cardbus"
  include "dev/pcmcia/files.pcmcia"
  
! file arch/macppc/macppc/rbus_machdep.c		cardbus
--- 34,37 ----
  include "dev/cardbus/files.cardbus"
  include "dev/pcmcia/files.pcmcia"
  
! file arch/evbppc/obs405/rbus_machdep.c		cardbus
Index: arch/powerpc/ibm4xx/pci/pchb.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/pci/pchb.c,v
retrieving revision 1.1
diff -c -r1.1 pchb.c
*** arch/powerpc/ibm4xx/pci/pchb.c	2003/09/23 15:30:22	1.1
--- arch/powerpc/ibm4xx/pci/pchb.c	2003/11/23 12:15:15
***************
*** 61,66 ****
--- 61,67 ----
  static int	pchbmatch(struct device *, struct cfdata *, void *);
  static void	pchbattach(struct device *, struct device *, void *);
  static int	pchbprint(void *, const char *);
+ static pci_chipset_tag_t	alloc_chipset_tag(int);
  
  CFATTACH_DECL(pchb, sizeof(struct device),
      pchbmatch, pchbattach, NULL, NULL);
***************
*** 89,95 ****
  {
  	struct plb_attach_args *paa = aux;
  	/* XXX chipset tag unused by walnut, so just pass 0 */
! 	pci_chipset_tag_t pc = 0;
  	pcitag_t tag; 
  	int class, id;
  
--- 90,96 ----
  {
  	struct plb_attach_args *paa = aux;
  	/* XXX chipset tag unused by walnut, so just pass 0 */
! 	pci_chipset_tag_t pc = alloc_chipset_tag(0);
  	pcitag_t tag; 
  	int class, id;
  
***************
*** 134,140 ****
  	pci_conf_debug = 1;
  #endif
  #endif
! 	pci_chipset_tag_t pc = 0;
  	pcitag_t tag; 
  	int class, id;
  
--- 135,141 ----
  	pci_conf_debug = 1;
  #endif
  #endif
! 	pci_chipset_tag_t pc = alloc_chipset_tag(0);
  	pcitag_t tag; 
  	int class, id;
  
***************
*** 174,181 ****
  	ioext = extent_create("pciio", IBM405GP_PCI_PCI_IO_START,
  	    IBM405GP_PCI_PCI_IO_START + 0xffff, M_DEVBUF, NULL, 0, EX_NOWAIT);
  	pci_configure_bus(0, ioext, memext, NULL, 0, 32);
! 	extent_destroy(memext);
! 	extent_destroy(ioext);
  #endif /* PCI_NETBSD_CONFIGURE */
  
  #ifdef PCI_CONFIGURE_VERBOSE
--- 175,182 ----
  	ioext = extent_create("pciio", IBM405GP_PCI_PCI_IO_START,
  	    IBM405GP_PCI_PCI_IO_START + 0xffff, M_DEVBUF, NULL, 0, EX_NOWAIT);
  	pci_configure_bus(0, ioext, memext, NULL, 0, 32);
! 	pc->memext = memext;
! 	pc->ioext = ioext;
  #endif /* PCI_NETBSD_CONFIGURE */
  
  #ifdef PCI_CONFIGURE_VERBOSE
***************
*** 188,193 ****
--- 189,195 ----
  	pba.pba_memt = &pchb_mem_tag;
  	pba.pba_dmat = paa->plb_dmat;
  	pba.pba_dmat64 = NULL;
+ 	pba.pba_pc = pc;
  	pba.pba_bus = 0;
  	pba.pba_bridgetag = NULL;
  	pba.pba_flags = PCI_FLAGS_MEM_ENABLED | PCI_FLAGS_IO_ENABLED;
***************
*** 228,230 ****
--- 230,245 ----
  	}
  }
  #endif
+ 
+ static pci_chipset_tag_t
+ alloc_chipset_tag(int node)
+ {
+ 	pci_chipset_tag_t npc;
+ 
+ 	npc = malloc(sizeof *npc, M_DEVBUF, M_NOWAIT);
+ 	if (npc == NULL)
+ 		panic("could not allocate pci_chipset_tag_t");
+ 	npc->rootnode = node;
+ 
+ 	return (npc);
+ }
Index: arch/powerpc/include/ibm4xx/pci_machdep.h
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/include/ibm4xx/pci_machdep.h,v
retrieving revision 1.1
diff -c -r1.1 pci_machdep.h
*** arch/powerpc/include/ibm4xx/pci_machdep.h	2003/03/04 07:51:03	1.1
--- arch/powerpc/include/ibm4xx/pci_machdep.h	2003/11/23 12:15:16
***************
*** 54,62 ****
  /*
   * Types provided to machine-independent PCI code
   */
! typedef void *pci_chipset_tag_t;
  typedef int pcitag_t;
  typedef int pci_intr_handle_t;
  
  /*
   * Functions provided to machine-independent PCI code.
--- 54,68 ----
  /*
   * Types provided to machine-independent PCI code
   */
! typedef struct ibm4xx_pci_chipset *pci_chipset_tag_t;
  typedef int pcitag_t;
  typedef int pci_intr_handle_t;
+ 
+ struct ibm4xx_pci_chipset {
+ 	int rootnode;		/* PCI controller */
+ 	struct extent *ioext;	/* PCI I/O extent */
+ 	struct extent *memext;	/* PCI memory extent */
+ };
  
  /*
   * Functions provided to machine-independent PCI code.
Index: arch/powerpc/include/ibm4xx/ibm4xx_intr.h
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/include/ibm4xx/ibm4xx_intr.h,v
retrieving revision 1.4
diff -c -r1.4 ibm4xx_intr.h
*** arch/powerpc/include/ibm4xx/ibm4xx_intr.h	2003/09/03 21:33:35	1.4
--- arch/powerpc/include/ibm4xx/ibm4xx_intr.h	2003/11/23 12:41:20
***************
*** 185,190 ****
--- 185,191 ----
  #define spltty()	splraise(imask[IPL_TTY])
  #define splclock()	splraise(imask[IPL_CLOCK])
  #define splvm()		splraise(imask[IPL_VM])
+ #define	splaudio()	splraise(imask[IPL_AUDIO])
  #define	splserial()	splraise(imask[IPL_SERIAL])
  #define splstatclock()	splclock()
  #define	spllowersoftclock() spllower(imask[IPL_SOFTCLOCK])
*** /tmp/rbus_machdep.c	Wed Dec  3 02:31:58 2003
--- arch/evbppc/obs405/rbus_machdep.c	Sun Nov 23 20:55:47 2003
***************
*** 0 ****
--- 1,115 ----
+ /*	$NetBSD$	*/
+ 
+ /*
+  * Copyright (c) 2003
+  *     KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+ #include <sys/cdefs.h>
+ 
+ #include <sys/param.h>
+ #include <sys/device.h>
+ #include <sys/systm.h>
+ 
+ #include <sys/extent.h>
+ 
+ #include <uvm/uvm_extern.h>
+ 
+ #include <machine/bus.h>
+ 
+ #include <dev/pci/pcivar.h>
+ #include <dev/pci/pcidevs.h>
+ #include <dev/cardbus/rbus.h>
+ 
+ #include "opt_pci.h"
+ 
+ #ifndef PCI_NETBSD_CONFIGURE
+ #error requird macro PCI_NETBSD_CONFIGURE
+ #endif
+ 
+ #ifdef RBUS_DEBUG
+ # define DPRINTF printf
+ #else
+ # define DPRINTF while (0) printf
+ #endif
+ 
+ int
+ md_space_map(t, bpa, size, flags, bshp)
+ 	bus_space_tag_t t;
+ 	bus_addr_t bpa;
+ 	bus_size_t size;
+ 	int flags;
+ 	bus_space_handle_t *bshp;
+ {
+ 	DPRINTF("md_space_map: 0x%x, 0x%x, 0x%x\n", t->pbs_base, bpa, size);
+ 
+ 	return bus_space_map(t, bpa, size, flags, bshp);
+ }
+ 
+ void
+ md_space_unmap(t, bsh, size, adrp)
+ 	bus_space_tag_t t;
+ 	bus_space_handle_t bsh;
+ 	bus_size_t size;
+ 	bus_addr_t *adrp;
+ {
+ 	paddr_t pa;
+ 
+ 	DPRINTF("md_space_unmap: 0x%x 0x%x\n", t->pbs_base, bsh);
+ 
+ 	if (adrp != NULL) {
+         	pmap_extract(pmap_kernel(), bsh, &pa);
+ 		*adrp = pa - t->pbs_offset;
+ 	}
+ 	bus_space_unmap(t, bsh, size);
+ }
+ 
+ rbus_tag_t
+ rbus_pccbb_parent_mem(pa)
+ 	struct pci_attach_args *pa;
+ {
+ 	bus_addr_t start;
+ 	bus_size_t size;
+ 	pci_chipset_tag_t pc = pa->pa_pc;
+ 	struct extent *ex = pc->memext;
+ 
+ 	start = ex->ex_start;
+ 	size = ex->ex_end - start;
+ 
+ 	return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
+ }
+ 
+ rbus_tag_t
+ rbus_pccbb_parent_io(pa)
+ 	struct pci_attach_args *pa;
+ {
+ 	bus_addr_t start;
+ 	bus_size_t size;
+ 	pci_chipset_tag_t pc = pa->pa_pc;
+ 	struct extent *ex = pc->ioext;
+ 
+ 	start = ex->ex_start;
+ 	size = ex->ex_end - start;
+ 
+ 	return rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
+ }
*** /tmp/rbus_machdep.h	Wed Dec  3 02:31:58 2003
--- arch/evbppc/include/rbus_machdep.h	Sat Oct 11 03:53:30 2003
***************
*** 0 ****
--- 1,42 ----
+ /*	$NetBSD: rbus_machdep.h,v 1.3 2000/06/01 00:04:55 cgd Exp $	*/
+ 
+ /*
+  * Copyright (c) 1999
+  *     TSUBAI Masanari.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. The name of the author may not be used to endorse or promote products
+  *    derived from this software without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
+ 
+ #ifndef _MACHINE_RBUS_MACHDEP_H_
+ #define _MACHINE_RBUS_MACHDEP_H_
+ 
+ struct pci_attach_args;
+ rbus_tag_t rbus_pccbb_parent_io(struct pci_attach_args *);
+ rbus_tag_t rbus_pccbb_parent_mem(struct pci_attach_args *);
+ 
+ int md_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
+ 		      bus_space_handle_t *);
+ void md_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ 			 bus_addr_t *);
+ 
+ #endif /* _MACHINE_RBUS_MACHDEP_H_ */

>Release-Note:
>Audit-Trail:
>Unformatted: