code reformat, fixed a bug in set/unset logical operation

git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1551 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Li-Ta Lo 2004-05-07 21:56:48 +00:00
parent 89666e4893
commit 75337f7500
1 changed files with 28 additions and 38 deletions

View File

@ -70,36 +70,30 @@ void pnp_read_resources(device_t dev)
static void pnp_set_resource(device_t dev, struct resource *resource) static void pnp_set_resource(device_t dev, struct resource *resource)
{ {
if (!(resource->flags & IORESOURCE_ASSIGNED)) { if (!(resource->flags & IORESOURCE_ASSIGNED)) {
#if 1
printk_err("ERROR: %s %02x not allocated\n", printk_err("ERROR: %s %02x not allocated\n",
dev_path(dev), resource->index); dev_path(dev), resource->index);
#endif
return; return;
} }
/* Now store the resource */ /* Now store the resource */
resource->flags |= IORESOURCE_STORED; resource->flags |= IORESOURCE_STORED;
if (resource->flags & IORESOURCE_IO) { if (resource->flags & IORESOURCE_IO) {
pnp_set_iobase(dev, resource->index, resource->base); pnp_set_iobase(dev, resource->index, resource->base);
} } else if (resource->flags & IORESOURCE_DRQ) {
else if (resource->flags & IORESOURCE_DRQ) {
pnp_set_drq(dev, resource->index, resource->base); pnp_set_drq(dev, resource->index, resource->base);
} } else if (resource->flags & IORESOURCE_IRQ) {
else if (resource->flags & IORESOURCE_IRQ) {
pnp_set_irq(dev, resource->index, resource->base); pnp_set_irq(dev, resource->index, resource->base);
} } else {
else {
/* Don't let me think I stored the resource */ /* Don't let me think I stored the resource */
resource->flags &= IORESOURCE_STORED; resource->flags &= ~IORESOURCE_STORED;
printk_err("ERROR: %s %02x unknown resource type\n", printk_err("ERROR: %s %02x unknown resource type\n",
dev_path(dev), resource->index); dev_path(dev), resource->index);
return; return;
} }
printk_debug( printk_debug("%s %02x <- [0x%08lx - 0x%08lx] %s\n", dev_path(dev),
"%s %02x <- [0x%08lx - 0x%08lx] %s\n", resource->index, resource->base,
dev_path(dev), resource->base + resource->size - 1,
resource->index,
resource->base, resource->base + resource->size - 1,
(resource->flags & IORESOURCE_IO)? "io": (resource->flags & IORESOURCE_IO)? "io":
(resource->flags & IORESOURCE_DRQ)? "drq": (resource->flags & IORESOURCE_DRQ)? "drq":
(resource->flags & IORESOURCE_IRQ)? "irq": (resource->flags & IORESOURCE_IRQ)? "irq":
@ -115,22 +109,19 @@ void pnp_set_resources(device_t dev)
pnp_set_logical_device(dev); pnp_set_logical_device(dev);
/* Paranoia says I should disable the device here... */ /* Paranoia says I should disable the device here... */
for(i = 0; i < dev->resources; i++) { for (i = 0; i < dev->resources; i++) {
pnp_set_resource(dev, &dev->resource[i]); pnp_set_resource(dev, &dev->resource[i]);
} }
} }
void pnp_enable_resources(device_t dev) void pnp_enable_resources(device_t dev)
{ {
pnp_set_logical_device(dev); pnp_set_logical_device(dev);
pnp_set_enable(dev, 1); pnp_set_enable(dev, 1);
} }
void pnp_enable(device_t dev) void pnp_enable(device_t dev)
{ {
if (!dev->enabled) { if (!dev->enabled) {
pnp_set_logical_device(dev); pnp_set_logical_device(dev);
pnp_set_enable(dev, 0); pnp_set_enable(dev, 0);
@ -146,10 +137,12 @@ struct device_operations pnp_ops = {
/* PNP chip opertations */ /* PNP chip opertations */
static void pnp_get_ioresource(device_t dev, unsigned index, struct io_info *info) static void pnp_get_ioresource(device_t dev, unsigned index,
struct io_info *info)
{ {
struct resource *resource; struct resource *resource;
uint32_t size; uint32_t size;
resource = get_resource(dev, index); resource = get_resource(dev, index);
/* Initilize the resource */ /* Initilize the resource */
@ -195,7 +188,6 @@ static void get_resources(device_t dev, struct pnp_info *info)
resource->size = 1; resource->size = 1;
resource->flags |= IORESOURCE_DRQ; resource->flags |= IORESOURCE_DRQ;
} }
} }
void pnp_enumerate(struct chip *chip, unsigned functions, void pnp_enumerate(struct chip *chip, unsigned functions,
@ -206,23 +198,21 @@ void pnp_enumerate(struct chip *chip, unsigned functions,
int i; int i;
chip_enumerate(chip); chip_enumerate(chip);
path.type = DEVICE_PATH_PNP; path.type = DEVICE_PATH_PNP;
path.u.pnp.port = chip->dev->path.u.pnp.port; path.u.pnp.port = chip->dev->path.u.pnp.port;
/* Setup the ops and resources on the newly allocated devices */ /* Setup the ops and resources on the newly allocated devices */
for(i = 0; i < functions; i++) { for (i = 0; i < functions; i++) {
path.u.pnp.device = info[i].function; path.u.pnp.device = info[i].function;
dev = alloc_find_dev(chip->bus, &path); dev = alloc_find_dev(chip->bus, &path);
if(info[i].ops == 0) { // BY LYH if (info[i].ops == 0) {
dev->ops = ops; dev->ops = ops;
} } else {
else { dev->ops = info[i].ops;
dev->ops = info[i].ops; // BY LYH
} }
get_resources(dev, &info[i]); get_resources(dev, &info[i]);
} }
} }