Move to pci/mvsata_pci.c (marvell/mvsata_mv.c) splitting mvsata_products[].
mvsata(4) uses these to match.
This commit is contained in:
parent
f6f8f19a87
commit
66dad59009
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mvsata.c,v 1.4 2010/03/28 20:46:18 snj Exp $ */
|
||||
/* $NetBSD: mvsata.c,v 1.5 2010/07/13 12:53:42 kiyohara Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 KIYOHARA Takashi
|
||||
* All rights reserved.
|
||||
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.4 2010/03/28 20:46:18 snj Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.5 2010/07/13 12:53:42 kiyohara Exp $");
|
||||
|
||||
#include "opt_mvsata.h"
|
||||
|
||||
@ -226,39 +226,9 @@ static const struct scsipi_bustype mvsata_atapi_bustype = {
|
||||
#endif /* NATAPIBUS */
|
||||
#endif
|
||||
|
||||
struct mvsata_product {
|
||||
int model;
|
||||
int hc;
|
||||
int port;
|
||||
int generation;
|
||||
int flags;
|
||||
} mvsata_products[] = {
|
||||
{ PCI_PRODUCT_MARVELL_88SX5040, 1, 4, gen1, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX5041, 1, 4, gen1, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX5080, 2, 4, gen1, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX5081, 2, 4, gen1, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX6040, 1, 4, gen2, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX6041, 1, 4, gen2, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX6042, 1, 4, gen2e, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88SX6080, 2, 4, gen2, MVSATA_FLAGS_PCIE },
|
||||
{ PCI_PRODUCT_MARVELL_88SX6081, 2, 4, gen2, MVSATA_FLAGS_PCIE },
|
||||
{ PCI_PRODUCT_ADP2_1420SA, 2, 4, gen2, MVSATA_FLAGS_PCIE },
|
||||
{ PCI_PRODUCT_MARVELL_88SX7042, 1, 4, gen2e, 0 },
|
||||
{ PCI_PRODUCT_ADP2_1430SA, 1, 4, gen2e, 0 },
|
||||
{ PCI_PRODUCT_TRIONES_ROCKETRAID_2310, 1, 4, gen2e, 0 },
|
||||
{ PCI_PRODUCT_MARVELL_88F5082, 1, 1, gen2e, 0 }, /* Orion */
|
||||
{ PCI_PRODUCT_MARVELL_88F5182, 1, 2, gen2e, 0 }, /* Orion */
|
||||
{ PCI_PRODUCT_MARVELL_88F6082, 1, 1, gen2e, 0 }, /* Orion */
|
||||
#if 0 /* Marvell MV64660 Disco5: Product is 0x6490 ?? */
|
||||
{ PCI_PRODUCT_MARVELL_88F6490, 1, 1, gen2e, 0 }, /* Discover?*/
|
||||
#endif
|
||||
|
||||
{ -1, 0, 0, gen_unknown, 0 }
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
mvsata_attach(struct mvsata_softc *sc,
|
||||
mvsata_attach(struct mvsata_softc *sc, struct mvsata_product *product,
|
||||
int (*mvsata_sreset)(struct mvsata_softc *),
|
||||
int (*mvsata_misc_reset)(struct mvsata_softc *),
|
||||
int read_pre_amps)
|
||||
@ -271,18 +241,8 @@ mvsata_attach(struct mvsata_softc *sc,
|
||||
void (*edma_setup_crqb)
|
||||
(struct mvsata_port *, int, int, struct ata_bio *) = NULL;
|
||||
#endif
|
||||
struct mvsata_product *product;
|
||||
int hc, port, channel, i;
|
||||
int hc, port, channel;
|
||||
|
||||
for (i = 0; mvsata_products[i].model != -1; i++)
|
||||
if (sc->sc_model == mvsata_products[i].model)
|
||||
break;
|
||||
if (mvsata_products[i].model == -1) {
|
||||
aprint_error_dev(MVSATA_DEV(sc), "unknown product 0x%04x\n",
|
||||
sc->sc_model);
|
||||
return EINVAL;
|
||||
}
|
||||
product = &mvsata_products[i];
|
||||
aprint_normal_dev(MVSATA_DEV(sc), "Gen%s, %dhc, %dport/hc\n",
|
||||
(product->generation == gen1) ? "I" :
|
||||
((product->generation == gen2) ? "II" : "IIe"),
|
||||
@ -317,10 +277,10 @@ mvsata_attach(struct mvsata_softc *sc,
|
||||
break;
|
||||
}
|
||||
|
||||
sc->sc_gen = mvsata_products[i].generation;
|
||||
sc->sc_hc = mvsata_products[i].hc;
|
||||
sc->sc_port = mvsata_products[i].port;
|
||||
sc->sc_flags = mvsata_products[i].flags;
|
||||
sc->sc_gen = product->generation;
|
||||
sc->sc_hc = product->hc;
|
||||
sc->sc_port = product->port;
|
||||
sc->sc_flags = product->flags;
|
||||
|
||||
#ifdef MVSATA_WITHOUTDMA
|
||||
sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mvsatavar.h,v 1.1 2009/07/27 12:34:14 kiyohara Exp $ */
|
||||
/* $NetBSD: mvsatavar.h,v 1.2 2010/07/13 12:53:42 kiyohara Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 KIYOHARA Takashi
|
||||
* All rights reserved.
|
||||
@ -28,6 +28,15 @@
|
||||
#ifndef _MVSATAVAR_H_
|
||||
#define _MVSATAVAR_H_
|
||||
|
||||
struct mvsata_product {
|
||||
int vendor;
|
||||
int model;
|
||||
int hc;
|
||||
int port;
|
||||
int generation;
|
||||
int flags;
|
||||
};
|
||||
|
||||
#define MVSATA_EDMAQ_LEN 32 /* keep compatibility to gen1 */
|
||||
#define MVSATA_EDMAQ_INC(i) ((i) = ((i) + 1) % MVSATA_EDMAQ_LEN)
|
||||
#define MVSATA_HC_MAX 2
|
||||
@ -128,7 +137,7 @@ struct mvsata_softc {
|
||||
void (*sc_enable_intr)(struct mvsata_port *, int);
|
||||
};
|
||||
|
||||
int mvsata_attach(struct mvsata_softc *,
|
||||
int mvsata_attach(struct mvsata_softc *, struct mvsata_product *,
|
||||
int (*mvsata_sreset)(struct mvsata_softc *),
|
||||
int (*mvsata_misc_reset)(struct mvsata_softc *), int);
|
||||
int mvsata_intr(struct mvsata_hc *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mvsata_pci.c,v 1.3 2010/02/24 22:38:01 dyoung Exp $ */
|
||||
/* $NetBSD: mvsata_pci.c,v 1.4 2010/07/13 12:53:43 kiyohara Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 KIYOHARA Takashi
|
||||
* All rights reserved.
|
||||
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mvsata_pci.c,v 1.3 2010/02/24 22:38:01 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mvsata_pci.c,v 1.4 2010/07/13 12:53:43 kiyohara Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bus.h>
|
||||
@ -108,6 +108,26 @@ static void mvsata_pci_enable_intr(struct mvsata_port *, int);
|
||||
CFATTACH_DECL_NEW(mvsata_pci, sizeof(struct mvsata_pci_softc),
|
||||
mvsata_pci_match, mvsata_pci_attach, mvsata_pci_detach, NULL);
|
||||
|
||||
struct mvsata_product mvsata_pci_products[] = {
|
||||
#define PCI_VP(v, p) PCI_VENDOR_ ## v, PCI_PRODUCT_ ## v ## _ ## p
|
||||
{ PCI_VP(MARVELL, 88SX5040), 1, 4, gen1, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX5041), 1, 4, gen1, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX5080), 2, 4, gen1, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX5081), 2, 4, gen1, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX6040), 1, 4, gen2, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX6041), 1, 4, gen2, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX6042), 1, 4, gen2e, 0 },
|
||||
{ PCI_VP(MARVELL, 88SX6080), 2, 4, gen2, MVSATA_FLAGS_PCIE },
|
||||
{ PCI_VP(MARVELL, 88SX6081), 2, 4, gen2, MVSATA_FLAGS_PCIE },
|
||||
{ PCI_VP(ADP2, 1420SA), 2, 4, gen2, MVSATA_FLAGS_PCIE },
|
||||
{ PCI_VP(MARVELL, 88SX7042), 1, 4, gen2e, 0 },
|
||||
{ PCI_VP(ADP2, 1430SA), 1, 4, gen2e, 0 },
|
||||
{ PCI_VP(TRIONES, ROCKETRAID_2310), 1, 4, gen2e, 0 },
|
||||
#undef PCI_VP
|
||||
|
||||
{ -1, -1, 0, 0, gen_unknown, 0 }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* mvsata_pci_match()
|
||||
@ -117,29 +137,11 @@ static int
|
||||
mvsata_pci_match(device_t parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
int i;
|
||||
|
||||
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_MARVELL)
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_MARVELL_88SX5040:
|
||||
case PCI_PRODUCT_MARVELL_88SX5041:
|
||||
case PCI_PRODUCT_MARVELL_88SX5080:
|
||||
case PCI_PRODUCT_MARVELL_88SX5081:
|
||||
case PCI_PRODUCT_MARVELL_88SX6040:
|
||||
case PCI_PRODUCT_MARVELL_88SX6041:
|
||||
case PCI_PRODUCT_MARVELL_88SX6042:
|
||||
case PCI_PRODUCT_MARVELL_88SX6080:
|
||||
case PCI_PRODUCT_MARVELL_88SX6081:
|
||||
case PCI_PRODUCT_MARVELL_88SX7042:
|
||||
return 2;
|
||||
}
|
||||
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ADP2)
|
||||
switch (PCI_PRODUCT(pa->pa_id)) {
|
||||
case PCI_PRODUCT_ADP2_1420SA:
|
||||
case PCI_PRODUCT_ADP2_1430SA:
|
||||
return 2;
|
||||
}
|
||||
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_TRIONES &&
|
||||
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_TRIONES_ROCKETRAID_2310)
|
||||
for (i = 0; i < __arraycount(mvsata_pci_products); i++)
|
||||
if (PCI_VENDOR(pa->pa_id) == mvsata_pci_products[i].vendor &&
|
||||
PCI_PRODUCT(pa->pa_id) == mvsata_pci_products[i].model)
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
@ -154,7 +156,7 @@ mvsata_pci_attach(device_t parent, device_t self, void *aux)
|
||||
pcireg_t csr;
|
||||
bus_size_t size;
|
||||
uint32_t reg, mask;
|
||||
int read_pre_amps, hc, port, rv;
|
||||
int read_pre_amps, hc, port, rv, i;
|
||||
char devinfo[256];
|
||||
const char *intrstr;
|
||||
|
||||
@ -214,8 +216,14 @@ mvsata_pci_attach(device_t parent, device_t self, void *aux)
|
||||
reg = bus_space_read_4(psc->psc_iot, psc->psc_ioh, MVSATA_PCI_RESETCFG);
|
||||
read_pre_amps = (reg & 0x00000001) ? 1 : 0;
|
||||
|
||||
rv = mvsata_attach(sc, mvsata_pci_sreset, mvsata_pci_misc_reset,
|
||||
read_pre_amps);
|
||||
for (i = 0; i < __arraycount(mvsata_pci_products); i++)
|
||||
if (PCI_VENDOR(pa->pa_id) == mvsata_pci_products[i].vendor &&
|
||||
PCI_PRODUCT(pa->pa_id) == mvsata_pci_products[i].model)
|
||||
break;
|
||||
KASSERT(i < __arraycount(mvsata_pci_products));
|
||||
|
||||
rv = mvsata_attach(sc, &mvsata_pci_products[i],
|
||||
mvsata_pci_sreset, mvsata_pci_misc_reset, read_pre_amps);
|
||||
if (rv != 0) {
|
||||
pci_intr_disestablish(psc->psc_pc, psc->psc_ih);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user