Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha/pci - Use the default implementations of atta...



details:   https://anonhg.NetBSD.org/src/rev/34e5e98c1129
branches:  trunk
changeset: 379886:34e5e98c1129
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Jun 25 03:49:47 2021 +0000

description:
- 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.

diffstat:

 sys/arch/alpha/pci/ttwoga_pci.c |  55 ++++++----------------------------------
 1 files changed, 9 insertions(+), 46 deletions(-)

diffs (111 lines):

diff -r cf94cad7c6fb -r 34e5e98c1129 sys/arch/alpha/pci/ttwoga_pci.c
--- a/sys/arch/alpha/pci/ttwoga_pci.c   Fri Jun 25 03:46:30 2021 +0000
+++ b/sys/arch/alpha/pci/ttwoga_pci.c   Fri Jun 25 03:49:47 2021 +0000
@@ -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 @@
 #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();
 



Home | Main Index | Thread Index | Old Index