- use a hardwired value for ISA/PCI iospace until the right solution
to find. - use const [] construct for register location lookup.
This commit is contained in:
parent
8ec93217ac
commit
6d7713a9a1
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pciide.c,v 1.3 2008/04/07 13:25:31 nisimura Exp $ */
|
||||
/* $NetBSD: pciide.c,v 1.4 2008/04/09 01:08:39 nisimura Exp $ */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
@ -24,10 +24,21 @@
|
||||
void *pciide_init(unsigned, unsigned);
|
||||
|
||||
#define PCIIDE_INTERFACE_PCI(chan) (0x01 << (2 * (chan)))
|
||||
#define PCIIDE_REG_CMD_BASE(chan) (0x10 + (8 * (chan)))
|
||||
#define PCIIDE_REG_CTL_BASE(chan) (0x14 + (8 * (chan)))
|
||||
#define PCIIDE_COMPAT_CMD_BASE(ch) (((ch)==0) ? 0x1f0 : 0x170)
|
||||
#define PCIIDE_COMPAT_CTL_BASE(ch) (((ch)==0) ? 0x3f6 : 0x376)
|
||||
|
||||
/* native: PCI BAR0-3 */
|
||||
static const struct {
|
||||
int cmd, ctl;
|
||||
} pcibar[2] = {
|
||||
{ 0x10, 0x14 },
|
||||
{ 0x18, 0x1c },
|
||||
};
|
||||
/* legacy: ISA/PCI IO space */
|
||||
static const struct {
|
||||
int cmd, ctl;
|
||||
} compat[2] = {
|
||||
{ 0x1f0, 0x3f6 },
|
||||
{ 0x170, 0x376 },
|
||||
};
|
||||
|
||||
void *
|
||||
pciide_init(unsigned tag, unsigned data)
|
||||
@ -53,10 +64,10 @@ pciide_init(unsigned tag, unsigned data)
|
||||
for (ch = 0; ch < 2; ch += 1) {
|
||||
cp = &l->channel[ch];
|
||||
if (PCIIDE_INTERFACE_PCI(ch) & val) {
|
||||
cp->c_cmdbase = (void *)DEVTOV(pcicfgread(tag,
|
||||
PCIIDE_REG_CMD_BASE(ch)));
|
||||
cp->c_ctlbase = (void *)DEVTOV(pcicfgread(tag,
|
||||
PCIIDE_REG_CTL_BASE(ch)));
|
||||
cp->c_cmdbase =
|
||||
(void *)DEVTOV(pcicfgread(tag, pcibar[ch].cmd));
|
||||
cp->c_ctlbase =
|
||||
(void *)DEVTOV(pcicfgread(tag, pcibar[ch].ctl));
|
||||
cp->c_data = (u_int16_t *)(cp->c_cmdbase + wd_data);
|
||||
for (i = 0; i < 8; i++)
|
||||
cp->c_cmdreg[i] = cp->c_cmdbase + i;
|
||||
@ -64,11 +75,11 @@ pciide_init(unsigned tag, unsigned data)
|
||||
cp->c_cmdreg[wd_features] = cp->c_cmdreg[wd_precomp];
|
||||
}
|
||||
else {
|
||||
tag = 0; /* !!! */
|
||||
cp->c_cmdbase = (void *)DEVTOV(pcicfgread(tag, 0x10)
|
||||
+ PCIIDE_COMPAT_CMD_BASE(ch));
|
||||
cp->c_ctlbase = (void *)DEVTOV(pcicfgread(tag, 0x10)
|
||||
+ PCIIDE_COMPAT_CTL_BASE(ch));
|
||||
uint32_t pciiobase = 0xfe000000; /* !!! */
|
||||
cp->c_cmdbase =
|
||||
(void *)DEVTOV(pciiobase + compat[ch].cmd);
|
||||
cp->c_ctlbase =
|
||||
(void *)DEVTOV(pciiobase + compat[ch].ctl);
|
||||
cp->c_data = (u_int16_t *)(cp->c_cmdbase + wd_data);
|
||||
for (i = 0; i < 8; i++)
|
||||
cp->c_cmdreg[i] = cp->c_cmdbase + i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: siisata.c,v 1.4 2008/04/08 23:59:03 nisimura Exp $ */
|
||||
/* $NetBSD: siisata.c,v 1.5 2008/04/09 01:08:39 nisimura Exp $ */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
@ -16,9 +16,6 @@
|
||||
|
||||
void *siisata_init(unsigned, unsigned);
|
||||
|
||||
#define PCIIDE_REG_CMD_BASE(chan) (0x10 + (8 * (chan)))
|
||||
#define PCIIDE_REG_CTL_BASE(chan) (0x14 + (8 * (chan)))
|
||||
|
||||
static void map3112chan(unsigned, int, struct atac_channel *);
|
||||
static void map3114chan(unsigned, int, struct atac_channel *);
|
||||
|
||||
@ -59,13 +56,21 @@ siisata_init(unsigned tag, unsigned data)
|
||||
return l;
|
||||
}
|
||||
|
||||
/* BAR0-3 */
|
||||
static const struct {
|
||||
int cmd, ctl;
|
||||
} regstd[2] = {
|
||||
{ 0x10, 0x14 },
|
||||
{ 0x18, 0x1c },
|
||||
};
|
||||
|
||||
static void
|
||||
map3112chan(unsigned tag, int ch, struct atac_channel *cp)
|
||||
{
|
||||
int i;
|
||||
|
||||
cp->c_cmdbase = (void*)DEVTOV(pcicfgread(tag, PCIIDE_REG_CMD_BASE(ch)));
|
||||
cp->c_ctlbase = (void*)DEVTOV(pcicfgread(tag, PCIIDE_REG_CTL_BASE(ch)));
|
||||
cp->c_cmdbase = (void *)DEVTOV(pcicfgread(tag, regstd[ch].cmd));
|
||||
cp->c_ctlbase = (void *)DEVTOV(pcicfgread(tag, regstd[ch].ctl));
|
||||
cp->c_data = (u_int16_t *)(cp->c_cmdbase + wd_data);
|
||||
for (i = 0; i < 8; i++)
|
||||
cp->c_cmdreg[i] = cp->c_cmdbase + i;
|
||||
@ -73,9 +78,10 @@ map3112chan(unsigned tag, int ch, struct atac_channel *cp)
|
||||
cp->c_cmdreg[wd_features] = cp->c_cmdreg[wd_precomp];
|
||||
}
|
||||
|
||||
/* offset to BAR5 */
|
||||
static const struct {
|
||||
int IDE_TF0, IDE_TF8;
|
||||
} regmap[4] = {
|
||||
} reg3114[4] = {
|
||||
{ 0x080, 0x091 },
|
||||
{ 0x0c0, 0x0d1 },
|
||||
{ 0x280, 0x291 },
|
||||
@ -89,8 +95,8 @@ map3114chan(unsigned tag, int ch, struct atac_channel *cp)
|
||||
uint8_t *ba5;
|
||||
|
||||
ba5 = (uint8_t *)DEVTOV(pcicfgread(tag, 0x24)); /* PCI_BAR5 */
|
||||
cp->c_cmdbase = ba5 + regmap[ch].IDE_TF0;
|
||||
cp->c_ctlbase = ba5 + regmap[ch].IDE_TF8;
|
||||
cp->c_cmdbase = ba5 + reg3114[ch].IDE_TF0;
|
||||
cp->c_ctlbase = ba5 + reg3114[ch].IDE_TF8;
|
||||
cp->c_data = (u_int16_t *)(cp->c_cmdbase + wd_data);
|
||||
for (i = 0; i < 8; i++)
|
||||
cp->c_cmdreg[i] = cp->c_cmdbase + i;
|
||||
|
Loading…
Reference in New Issue
Block a user