Module Name:    src
Committed By:   thorpej
Date:           Fri Jun 25 03:49:47 UTC 2021

Modified Files:
        src/sys/arch/alpha/pci: ttwoga_pci.c

Log Message:
- Use the default implementations of attach_hook(), make_tag(), and
  decompose_tag().
- In ttwoga_make_type0addr(), assert that we have an IDSEL in our range,
  and otherwise always succeed.
- In ttwoga_bus_maxdevs(), allow only devices 0-9 on bus #0.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/pci/ttwoga_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/ttwoga_pci.c
diff -u src/sys/arch/alpha/pci/ttwoga_pci.c:1.9 src/sys/arch/alpha/pci/ttwoga_pci.c:1.10
--- src/sys/arch/alpha/pci/ttwoga_pci.c:1.9	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/ttwoga_pci.c	Fri Jun 25 03:49:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ttwoga_pci.c,v 1.9 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: ttwoga_pci.c,v 1.10 2021/06/25 03:49:47 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c,v 1.9 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c,v 1.10 2021/06/25 03:49:47 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -44,12 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c
 #include <alpha/pci/ttwogareg.h>
 #include <alpha/pci/ttwogavar.h>
 
-static void	ttwoga_attach_hook(device_t, device_t,
-		    struct pcibus_attach_args *);
 static int	ttwoga_bus_maxdevs(void *, int);
-static pcitag_t	ttwoga_make_tag(void *, int, int, int);
-static void	ttwoga_decompose_tag(void *, pcitag_t, int *, int *,
-		    int *);
 static pcireg_t	ttwoga_conf_read(void *, pcitag_t, int);
 static void	ttwoga_conf_write(void *, pcitag_t, int, pcireg_t);
 
@@ -87,54 +82,26 @@ ttwoga_pci_init(pci_chipset_tag_t pc, vo
 	mutex_init(&ttwoga_conf_lock, MUTEX_DEFAULT, IPL_HIGH);
 
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = ttwoga_attach_hook;
 	pc->pc_bus_maxdevs = ttwoga_bus_maxdevs;
-	pc->pc_make_tag = ttwoga_make_tag;
-	pc->pc_decompose_tag = ttwoga_decompose_tag;
 	pc->pc_conf_read = ttwoga_conf_read;
 	pc->pc_conf_write = ttwoga_conf_write;
 }
 
-static void
-ttwoga_attach_hook(device_t parent, device_t self,
-    struct pcibus_attach_args *pba)
-{
-}
-
 static int
 ttwoga_bus_maxdevs(void *cpv, int busno)
 {
-
-	return 32;
-}
-
-static pcitag_t
-ttwoga_make_tag(void *cpv, int b, int d, int f)
-{
-
-	/* This is the format used for Type 1 configuration cycles. */
-	return (b << 16) | (d << 11) | (f << 8);
-}
-
-static void
-ttwoga_decompose_tag(void *cpv, pcitag_t tag, int *bp, int *dp, int *fp)
-{
-
-	if (bp != NULL)
-		*bp = (tag >> 16) & 0xff;
-	if (dp != NULL)
-		*dp = (tag >> 11) & 0x1f;
-	if (fp != NULL)
-		*fp = (tag >> 8) & 0x7;
+	/*
+	 * We have to drive the IDSEL directly on bus 0, so we are
+	 * limited to 9 devices there.
+	 */
+	return busno == 0 ? 9 : 32;
 }
 
 static paddr_t
 ttwoga_make_type0addr(int d, int f)
 {
-
-	if (d > 8)			/* XXX ??? */
-		return ((paddr_t) -1);
-	return ((0x0800UL << d) | (f << 8));
+	KASSERT(d < 9);
+	return PCI_CONF_TYPE0_IDSEL(d) | __SHIFTIN(f, PCI_CONF_TYPE1_FUNCTION);
 }
 
 static pcireg_t
@@ -152,8 +119,6 @@ ttwoga_conf_read(void *cpv, pcitag_t tag
 	pci_decompose_tag(&tcp->tc_pc, tag, &b, &d, &f);
 
 	addr = b ? tag : ttwoga_make_type0addr(d, f);
-	if (addr == (paddr_t)-1)
-		return ((pcireg_t) -1);
 
 	TTWOGA_CONF_LOCK();
 
@@ -207,8 +172,6 @@ ttwoga_conf_write(void *cpv, pcitag_t ta
 	pci_decompose_tag(&tcp->tc_pc, tag, &b, &d, &f);
 
 	addr = b ? tag : ttwoga_make_type0addr(d, f);
-	if (addr == (paddr_t)-1)
-		return;
 
 	TTWOGA_CONF_LOCK();
 

Reply via email to