Fully configure-ized version of an SMC superio

This commit is contained in:
Ronald G. Minnich 2001-07-18 15:00:53 +00:00
commit adfa49add4
2 changed files with 37 additions and 37 deletions

View file

@ -461,15 +461,27 @@ struct com_ports {
unsigned int enable,baud, base, irq;
};
// lpt port description.
// Note that for many superios you only really need to define the
// enable.
struct lpt_ports {
unsigned int enable, // 1 if this port is enabled
mode, // pp mode
base, // IO base of the parallel port
irq; // irq
};
struct superio {
struct superio_control *super; // the ops for the device.
unsigned int port; // if non-zero, overrides the default port
// com ports. This is not done as an array (yet).
// We think it's easier to set up from python if it is not an array.
struct com_ports com1, com2, com3, com4;
// DMA, if it exists.
struct lpt_ports lpt1, lpt2;
/* flags for each device type. Unsigned int. */
// low order bit ALWAYS means enable. Next bit means to enable
// DMA, if it exists.
// LPT is in transition, so we leave this here for the moment.
unsigned int ide, floppy, lpt;
};

View file

@ -24,7 +24,7 @@
static int
smc_configuration_state(struct superio *s, int state)
{
unsigned char addr;
unsigned short addr;
addr = s->port;
if (state) {
outb(0x55, addr);
@ -41,7 +41,7 @@ smc_configuration_state(struct superio *s, int state)
static int smc_write(struct superio *s, unsigned char data,
unsigned char index)
{
unsigned char addr;
unsigned short addr;
addr = s->port;
outb(index, addr);
outb(data, addr+1);
@ -51,20 +51,19 @@ static int smc_write(struct superio *s, unsigned char data,
static int smc_read(struct superio *s,
unsigned char index, unsigned char *data)
{
unsigned char addr;
unsigned short addr;
addr = s->port;
if ((addr!=0x370) && (addr!=0x3f0)) return(-1);
outb(index, addr);
*data = inb(addr+1);
return(0);
}
static int smc_uart_setup(struct superio *s,
int addr1, int irq1,
int addr2, int irq2)
static int smc_uart_setup(struct superio *s)
{
unsigned char addr = s->port;
unsigned short addr = s->port;
unsigned short addr1 = s->com1.base;
unsigned short addr2 = s->com2.base;
int rv;
unsigned char int1, int2;
unsigned char data;
@ -76,7 +75,7 @@ static int smc_uart_setup(struct superio *s,
* A configuration mechanism is needed.
*/
switch (irq1) {
switch (s->com1.irq) {
case 3: int1 = 1; break;
case 4: int1 = 2; break;
case 5: int1 = 3; break;
@ -87,7 +86,7 @@ static int smc_uart_setup(struct superio *s,
default: int1 = 0;
}
switch (irq2) {
switch (s->com2.irq) {
case 3: int2 = 1; break;
case 4: int2 = 2; break;
case 5: int2 = 3; break;
@ -102,7 +101,6 @@ static int smc_uart_setup(struct superio *s,
int2 = 0x0f;
}
rv = smc_configuration_state(addr, 1); if (rv) return(rv);
rv = smc_write(addr, (addr1>>2) & 0xfe, 0x24); if (rv) return(rv);
rv = smc_write(addr, (addr2>>2) & 0xfe, 0x25); if (rv) return(rv);
rv = smc_write(addr, (int1<<4) | int2, 0x28); if (rv) return(rv);
@ -114,16 +112,16 @@ static int smc_uart_setup(struct superio *s,
rv = smc_write(addr, data | 0x84, 0x03); if (rv) return(rv);
}
rv = smc_configuration_state(addr, 0); return(rv);
}
static int smc_pp_setup(struct superio *s, int pp_addr, int mode)
static int smc_pp_setup(struct superio *s)
{
unsigned char addr = s->port;
unsigned short addr = s->port;
unsigned short pp_addr = s->lpt1.base;
unsigned char mode = s->lpt1.mode;
int rv;
unsigned char data;
rv = smc_configuration_state(addr, 1); if (rv) return(rv);
rv = smc_read(addr, 0x04, &data); if (rv) return(rv);
data = (data & (~0x03)) | (mode & 0x03);
@ -135,7 +133,6 @@ static int smc_pp_setup(struct superio *s, int pp_addr, int mode)
rv = smc_write(addr, (pp_addr>>2) & 0xff, 0x23); if (rv) return(rv);
rv = smc_configuration_state(addr, 0); return(rv);
}
static int smc_validbit(struct superio *s, int valid)
@ -144,9 +141,6 @@ static int smc_validbit(struct superio *s, int valid)
int rv;
unsigned char data;
if ((addr!=0x370) && (addr!=0x3f0)) return(-1);
rv = smc_configuration_state(addr, 1); if (rv) return(rv);
rv = smc_read(addr, 0x00, &data); if (rv) return(rv);
if (valid) {
@ -157,34 +151,28 @@ static int smc_validbit(struct superio *s, int valid)
}
rv = smc_write(addr, data, 0x00); if (rv) return(rv);
rv = smc_configuration_state(addr, 0); return(rv);
}
static void
finishup(struct superio *s)
{
#if 0
// fix me later
enter_pnp(s);
int rv = 0;
// don't fool with IDE just yet ...
// if (s->floppy)
// enable_floppy(s);
rv = smc_configuration_state(addr, 1); if (rv) return(rv);
// this really needs to be broken into two com setups, but for onw
// we leave it.
if (s->com1.enable)
enable_com(s, PNP_COM1_DEVICE);
if (s->com2.enable)
enable_com(s, PNP_COM2_DEVICE);
if (s->lpt)
enable_lpt(s);
rv |= smc_uart_setup(s);
if (s->lpt1.enable)
rv |= smc_pp_setup(s);
exit_pnp(s);
#endif
rv |= smc_configuration_state(addr, 0); return(rv);
if (rv)
printk("For %s rv in finishup is %d\n", s->name, rv);
}
struct superio_control superio_sis_950_control = {
struct superio_control superio_smc_fdc37b807_control = {
(void *)0, (void *)0, finishup, 0x370, "SMC fdc37b807"
};