From ac7ba92669a3e521924e21a3a6802ba2eb11371f Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Thu, 20 Jul 2000 09:28:07 +0000 Subject: [PATCH] Add support for the PC87303 chipset (found on Miata alphas) and add support for relocating the port address if the isa hints specify a different address from the address the chipset currently has. Submitted by: Andrew M. Miklic --- sys/dev/ppc/ppc.c | 52 +++++++++++++++++++++++++++++++++++++++----- sys/dev/ppc/ppcreg.h | 1 + sys/isa/ppc.c | 52 +++++++++++++++++++++++++++++++++++++++----- sys/isa/ppcreg.h | 1 + 4 files changed, 94 insertions(+), 12 deletions(-) diff --git a/sys/dev/ppc/ppc.c b/sys/dev/ppc/ppc.c index ab25faf9daf1..259eed2e2d3f 100644 --- a/sys/dev/ppc/ppc.c +++ b/sys/dev/ppc/ppc.c @@ -113,7 +113,7 @@ static driver_t ppc_driver = { static char *ppc_models[] = { "SMC-like", "SMC FDC37C665GT", "SMC FDC37C666GT", "PC87332", "PC87306", "82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334", - "SMC FDC37C935", 0 + "SMC FDC37C935", "PC87303", 0 }; /* list of available modes */ @@ -462,6 +462,7 @@ ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never for * 01010xxx PC87334 * 0001xxxx PC87332 * 01110xxx PC87306 + * 00110xxx PC87303 */ outb(idport, PC873_SID); val = inb(idport + 1); @@ -471,6 +472,10 @@ ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never for ppc->ppc_model = NS_PC87306; } else if ((val & 0xf8) == 0x50) { ppc->ppc_model = NS_PC87334; + } else if ((val & 0xf8) == 0x40) { /* Should be 0x30 by the + documentation, but probing + yielded 0x40... */ + ppc->ppc_model = NS_PC87303; } else { if (bootverbose && (val != 0xff)) printf("PC873xx probe at 0x%x got unknown ID 0x%x\n", idport, val); @@ -499,12 +504,47 @@ ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never for continue; } outb(idport, PC873_FAR); - val = inb(idport + 1) & 0x3; + val = inb(idport + 1); /* XXX we should create a driver instance for every port found */ - if (pc873xx_porttab[val] != ppc->ppc_base) { - if (bootverbose) - printf("PC873xx at 0x%x not for driver at port 0x%x\n", - pc873xx_porttab[val], ppc->ppc_base); + if (pc873xx_porttab[val & 0x3] != ppc->ppc_base) { + + /* First try to change the port address to that requested... */ + + switch(ppc->ppc_base) { + case 0x378: + val &= 0xfc; + break; + + case 0x3bc: + val &= 0xfd; + break; + + case 0x278: + val &= 0xfe; + break; + + default: + val &= 0xfd; + break; + } + + outb(idport, PC873_FAR); + outb(idport + 1, val); + outb(idport + 1, val); + + /* Check for success by reading back the value we supposedly + wrote and comparing...*/ + + outb(idport, PC873_FAR); + val = inb(idport + 1) & 0x3; + + /* If we fail, report the failure... */ + + if (pc873xx_porttab[val] != ppc->ppc_base) { + if (bootverbose) + printf("PC873xx at 0x%x not for driver at port 0x%x\n", + pc873xx_porttab[val], ppc->ppc_base); + } continue; } diff --git a/sys/dev/ppc/ppcreg.h b/sys/dev/ppc/ppcreg.h index 2d2266a868ab..8bd637c6d54b 100644 --- a/sys/dev/ppc/ppcreg.h +++ b/sys/dev/ppc/ppcreg.h @@ -44,6 +44,7 @@ #define WINB_UNKNOWN 9 #define NS_PC87334 10 #define SMC_37C935 11 +#define NS_PC87303 12 /* * Parallel Port Chipset Type. SMC versus GENERIC (others) diff --git a/sys/isa/ppc.c b/sys/isa/ppc.c index ab25faf9daf1..259eed2e2d3f 100644 --- a/sys/isa/ppc.c +++ b/sys/isa/ppc.c @@ -113,7 +113,7 @@ static driver_t ppc_driver = { static char *ppc_models[] = { "SMC-like", "SMC FDC37C665GT", "SMC FDC37C666GT", "PC87332", "PC87306", "82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334", - "SMC FDC37C935", 0 + "SMC FDC37C935", "PC87303", 0 }; /* list of available modes */ @@ -462,6 +462,7 @@ ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never for * 01010xxx PC87334 * 0001xxxx PC87332 * 01110xxx PC87306 + * 00110xxx PC87303 */ outb(idport, PC873_SID); val = inb(idport + 1); @@ -471,6 +472,10 @@ ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never for ppc->ppc_model = NS_PC87306; } else if ((val & 0xf8) == 0x50) { ppc->ppc_model = NS_PC87334; + } else if ((val & 0xf8) == 0x40) { /* Should be 0x30 by the + documentation, but probing + yielded 0x40... */ + ppc->ppc_model = NS_PC87303; } else { if (bootverbose && (val != 0xff)) printf("PC873xx probe at 0x%x got unknown ID 0x%x\n", idport, val); @@ -499,12 +504,47 @@ ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never for continue; } outb(idport, PC873_FAR); - val = inb(idport + 1) & 0x3; + val = inb(idport + 1); /* XXX we should create a driver instance for every port found */ - if (pc873xx_porttab[val] != ppc->ppc_base) { - if (bootverbose) - printf("PC873xx at 0x%x not for driver at port 0x%x\n", - pc873xx_porttab[val], ppc->ppc_base); + if (pc873xx_porttab[val & 0x3] != ppc->ppc_base) { + + /* First try to change the port address to that requested... */ + + switch(ppc->ppc_base) { + case 0x378: + val &= 0xfc; + break; + + case 0x3bc: + val &= 0xfd; + break; + + case 0x278: + val &= 0xfe; + break; + + default: + val &= 0xfd; + break; + } + + outb(idport, PC873_FAR); + outb(idport + 1, val); + outb(idport + 1, val); + + /* Check for success by reading back the value we supposedly + wrote and comparing...*/ + + outb(idport, PC873_FAR); + val = inb(idport + 1) & 0x3; + + /* If we fail, report the failure... */ + + if (pc873xx_porttab[val] != ppc->ppc_base) { + if (bootverbose) + printf("PC873xx at 0x%x not for driver at port 0x%x\n", + pc873xx_porttab[val], ppc->ppc_base); + } continue; } diff --git a/sys/isa/ppcreg.h b/sys/isa/ppcreg.h index 2d2266a868ab..8bd637c6d54b 100644 --- a/sys/isa/ppcreg.h +++ b/sys/isa/ppcreg.h @@ -44,6 +44,7 @@ #define WINB_UNKNOWN 9 #define NS_PC87334 10 #define SMC_37C935 11 +#define NS_PC87303 12 /* * Parallel Port Chipset Type. SMC versus GENERIC (others)