Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint/stand/altboot - some rework for PCI devic...



details:   https://anonhg.NetBSD.org/src/rev/a8d748896eab
branches:  trunk
changeset: 761903:a8d748896eab
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Thu Feb 10 13:38:08 2011 +0000

description:
- some rework for PCI device enumeration.
- allow dual IDE/SATA devices.
- fix a typo of D-Link #define.

diffstat:

 sys/arch/sandpoint/stand/altboot/brdsetup.c |  96 ++++++++++++++--------------
 sys/arch/sandpoint/stand/altboot/dsk.c      |  24 +++---
 sys/arch/sandpoint/stand/altboot/globals.h  |  17 +++-
 sys/arch/sandpoint/stand/altboot/main.c     |  79 +++++++++++++---------
 sys/arch/sandpoint/stand/altboot/nif.c      |  10 +-
 sys/arch/sandpoint/stand/altboot/pci.c      |  19 +++--
 6 files changed, 134 insertions(+), 111 deletions(-)

diffs (truncated from 584 to 300 lines):

diff -r 72236dde8c13 -r a8d748896eab sys/arch/sandpoint/stand/altboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/altboot/brdsetup.c       Thu Feb 10 13:31:55 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/brdsetup.c       Thu Feb 10 13:38:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.3 2011/02/08 00:33:05 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -101,8 +101,8 @@
        NULL, iomegabrdfix, iomegapcifix },
     {
        "dlink",
-       "D-Link GSM-G600",
-       BRD_DLINKGSM,
+       "D-Link DSM-G600",
+       BRD_DLINKDSM,
        0,
        "eumb", 0x4500, 9600,
        NULL, dlinkbrdfix, dlinkpcifix },
@@ -215,7 +215,7 @@
        }
        else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 16, 0), PCI_ID_REG)) ==
            0x1191) {                           /* PCI_VENDOR_ACARD */
-               brdtype = BRD_DLINKGSM;
+               brdtype = BRD_DLINKDSM;
        }
 
        brdprop = brd_lookup(brdtype);
@@ -406,12 +406,12 @@
 void
 motpcifix(struct brdprop *brd)
 {
-       unsigned ide, nic, pcib, steer, val;
+       unsigned ide, net, pcib, steer, val;
        int line;
 
        pcib = pcimaketag(0, 11, 0);
        ide  = pcimaketag(0, 11, 1);
-       nic  = pcimaketag(0, 15, 0);
+       net  = pcimaketag(0, 15, 0);
 
        /*
         * //// WinBond PIRQ ////
@@ -492,21 +492,21 @@
         * //// fxp fixup ////
         * - use PCI pin A line 15 (fxp 0x3d/3c)
         */
-       val = pcicfgread(nic, 0x3c) & 0xffff0000;
-       pcidecomposetag(nic, NULL, &line, NULL);
+       val = pcicfgread(net, 0x3c) & 0xffff0000;
+       pcidecomposetag(net, NULL, &line, NULL);
        val |= (('A' - '@') << 8) | line;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 }
 
 void
 encpcifix(struct brdprop *brd)
 {
-       unsigned ide, irq, nic, pcib, steer, val;
+       unsigned ide, irq, net, pcib, steer, val;
 
 #define        STEER(v, b) (((v) & (b)) ? "edge" : "level")
        pcib = pcimaketag(0, 22, 0);
        ide  = pcimaketag(0, 22, 1);
-       nic  = pcimaketag(0, 25, 0);
+       net  = pcimaketag(0, 25, 0);
 
        /*
         * //// VIA PIRQ ////
@@ -603,9 +603,9 @@
         * - use PCI pin A line 25 (fxp 0x3d/3c)
         */
        /* 0x3d/3c - PCI pin/line */
-       val = pcicfgread(nic, 0x3c) & 0xffff0000;
+       val = pcicfgread(net, 0x3c) & 0xffff0000;
        val |= (('A' - '@') << 8) | 25;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -630,17 +630,17 @@
 void
 kuropcifix(struct brdprop *brd)
 {
-       unsigned ide, nic, usb, val;
+       unsigned dsk, net, usb, val;
 
-       nic = pcimaketag(0, 11, 0);
-       val = pcicfgread(nic, 0x3c) & 0xffffff00;
+       net = pcimaketag(0, 11, 0);
+       val = pcicfgread(net, 0x3c) & 0xffffff00;
        val |= 11;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 
-       ide = pcimaketag(0, 12, 0);
-       val = pcicfgread(ide, 0x3c) & 0xffffff00;
+       dsk = pcimaketag(0, 12, 0);
+       val = pcicfgread(dsk, 0x3c) & 0xffffff00;
        val |= 12;
-       pcicfgwrite(ide, 0x3c, val);
+       pcicfgwrite(dsk, 0x3c, val);
 
        usb = pcimaketag(0, 14, 0);
        val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -677,12 +677,12 @@
 void
 synopcifix(struct brdprop *brd)
 {
-       unsigned ide, nic, usb, val;
+       unsigned dsk, net, usb, val;
 
-       ide = pcimaketag(0, 13, 0);
-       val = pcicfgread(ide, 0x3c) & 0xffffff00;
+       dsk = pcimaketag(0, 13, 0);
+       val = pcicfgread(dsk, 0x3c) & 0xffffff00;
        val |= 13;
-       pcicfgwrite(ide, 0x3c, val);
+       pcicfgwrite(dsk, 0x3c, val);
 
        usb = pcimaketag(0, 14, 0);
        val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -699,10 +699,10 @@
        val |= 14;
        pcicfgwrite(usb, 0x3c, val);
 
-       nic = pcimaketag(0, 15, 0);
-       val = pcicfgread(nic, 0x3c) & 0xffffff00;
+       net = pcimaketag(0, 15, 0);
+       val = pcicfgread(net, 0x3c) & 0xffffff00;
        val |= 15;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -716,12 +716,12 @@
 void
 qnappcifix(struct brdprop *brd)
 {
-       unsigned ide, nic, usb, val;
+       unsigned dsk, net, usb, val;
 
-       ide = pcimaketag(0, 13, 0);
-       val = pcicfgread(ide, 0x3c) & 0xffffff00;
+       dsk = pcimaketag(0, 13, 0);
+       val = pcicfgread(dsk, 0x3c) & 0xffffff00;
        val |= 13;
-       pcicfgwrite(ide, 0x3c, val);
+       pcicfgwrite(dsk, 0x3c, val);
 
        usb = pcimaketag(0, 14, 0);
        val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -738,10 +738,10 @@
        val |= 14;
        pcicfgwrite(usb, 0x3c, val);
 
-       nic = pcimaketag(0, 15, 0);
-       val = pcicfgread(nic, 0x3c) & 0xffffff00;
+       net = pcimaketag(0, 15, 0);
+       val = pcicfgread(net, 0x3c) & 0xffffff00;
        val |= 15;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -754,12 +754,12 @@
 void
 iomegapcifix(struct brdprop *brd)
 {
-       unsigned ide, nic, usb, val;
+       unsigned dsk, net, usb, val;
 
-       ide = pcimaketag(0, 13, 0);
-       val = pcicfgread(ide, 0x3c) & 0xffffff00;
+       dsk = pcimaketag(0, 13, 0);
+       val = pcicfgread(dsk, 0x3c) & 0xffffff00;
        val |= 13;
-       pcicfgwrite(ide, 0x3c, val);
+       pcicfgwrite(dsk, 0x3c, val);
 
        usb = pcimaketag(0, 14, 0);
        val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -776,10 +776,10 @@
        val |= 14;
        pcicfgwrite(usb, 0x3c, val);
 
-       nic = pcimaketag(0, 15, 0);
-       val = pcicfgread(nic, 0x3c) & 0xffffff00;
+       net = pcimaketag(0, 15, 0);
+       val = pcicfgread(net, 0x3c) & 0xffffff00;
        val |= 15;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -792,7 +792,7 @@
 void
 dlinkpcifix(struct brdprop *brd)
 {
-       unsigned usb, nic, ide, val;
+       unsigned usb, net, dsk, val;
 
        usb = pcimaketag(0, 14, 0);
        val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -809,15 +809,15 @@
        val |= 14;
        pcicfgwrite(usb, 0x3c, val);
 
-       nic = pcimaketag(0, 15, 0);
-       val = pcicfgread(nic, 0x3c) & 0xffffff00;
+       net = pcimaketag(0, 15, 0);
+       val = pcicfgread(net, 0x3c) & 0xffffff00;
        val |= 15;
-       pcicfgwrite(nic, 0x3c, val);
+       pcicfgwrite(net, 0x3c, val);
 
-       ide = pcimaketag(0, 16, 0);
-       val = pcicfgread(ide, 0x3c) & 0xffffff00;
+       dsk = pcimaketag(0, 16, 0);
+       val = pcicfgread(dsk, 0x3c) & 0xffffff00;
        val |= 16;
-       pcicfgwrite(ide, 0x3c, val);
+       pcicfgwrite(dsk, 0x3c, val);
 }
 
 void
diff -r 72236dde8c13 -r a8d748896eab sys/arch/sandpoint/stand/altboot/dsk.c
--- a/sys/arch/sandpoint/stand/altboot/dsk.c    Thu Feb 10 13:31:55 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/dsk.c    Thu Feb 10 13:38:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.3 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -68,15 +68,15 @@
        char *name;
        int (*match)(unsigned, void *);
        void *(*init)(unsigned, void *);
-       void *priv;
 };
 
 static struct dskdv ldskdv[] = {
-       { "pciide", pciide_match, pciide_init, },
-       { "siisata", siisata_match, siisata_init, },
+       { "pciide", pciide_match, pciide_init },
+       { "siisata", siisata_match, siisata_init },
 };
 static int ndskdv = sizeof(ldskdv)/sizeof(ldskdv[0]);
 
+static int disk_scan(void *);
 static int probe_drive(struct dkdev_ata *, int);
 static void drive_ident(struct disk *, char *);
 static char *mkident(char *, int);
@@ -90,11 +90,14 @@
 static struct disk ldisk[4];
 
 int
-dskdv_init(unsigned tag, void **cookie)
+dskdv_init(void *self)
 {
+       struct pcidev *pci = self;
        struct dskdv *dv;
+       unsigned tag;
        int n;
 
+       tag = pci->bdf;
        for (n = 0; n < ndskdv; n++) {
                dv = &ldskdv[n];
                if ((*dv->match)(tag, NULL) > 0)
@@ -102,16 +105,15 @@
        }
        return 0;
   found:
-       dv->priv = (*dv->init)(tag, NULL);
-       *cookie = dv;
+       pci->drv = (*dv->init)(tag, NULL);
+       disk_scan(pci->drv);
        return 1;
 }
 
-int
-disk_scan(void *cookie)
+static int
+disk_scan(void *drv)
 {
-       struct dskdv *dv = cookie;
-       struct dkdev_ata *l = dv->priv;
+       struct dkdev_ata *l = drv;
        struct disk *d;
        int n, ndrive;
 
diff -r 72236dde8c13 -r a8d748896eab sys/arch/sandpoint/stand/altboot/globals.h
--- a/sys/arch/sandpoint/stand/altboot/globals.h        Thu Feb 10 13:31:55 2011 +0000



Home | Main Index | Thread Index | Old Index