From af6e9e0779ac113bec6fab4aa4808475c897a8fe Mon Sep 17 00:00:00 2001 From: Irene Zubarev Date: Mon, 9 Sep 2002 00:38:14 -0700 Subject: [PATCH] IBM PCI Hotplug driver update - fix polling logic - add ability to write [chassis/rxe]#slot# instead of just slot# --- drivers/hotplug/ibmphp_hpc.c | 200 +++++++++++++++++++++++++++---------------- 1 file changed, 125 insertions(+), 75 deletions(-) (limited to 'drivers/hotplug/ibmphp_hpc.c') diff --git a/drivers/hotplug/ibmphp_hpc.c b/drivers/hotplug/ibmphp_hpc.c index bf2e067aaad0..5b410df72b62 100644 --- a/drivers/hotplug/ibmphp_hpc.c +++ b/drivers/hotplug/ibmphp_hpc.c @@ -107,8 +107,8 @@ static struct semaphore sem_exit; // make sure polling thread goes away //---------------------------------------------------------------------------- // local function prototypes //---------------------------------------------------------------------------- -static u8 ctrl_read (struct controller *, void *, u8); -static u8 ctrl_write (struct controller *, void *, u8, u8); +static u8 i2c_ctrl_read (struct controller *, void *, u8); +static u8 i2c_ctrl_write (struct controller *, void *, u8, u8); static u8 hpc_writecmdtoindex (u8, u8); static u8 hpc_readcmdtoindex (u8, u8); static void get_hpc_access (void); @@ -142,12 +142,12 @@ void __init ibmphp_hpc_initvars (void) } /*---------------------------------------------------------------------- -* Name: ctrl_read +* Name: i2c_ctrl_read * * Action: read from HPC over I2C * *---------------------------------------------------------------------*/ -static u8 ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index) +static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index) { u8 status; int i; @@ -249,13 +249,13 @@ static u8 ctrl_read (struct controller *ctlr_ptr, void *WPGBbar, u8 index) } /*---------------------------------------------------------------------- -* Name: ctrl_write +* Name: i2c_ctrl_write * * Action: write to HPC over I2C * * Return 0 or error codes *---------------------------------------------------------------------*/ -static u8 ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index, u8 cmd) +static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index, u8 cmd) { u8 rc; void *wpg_addr; // base addr + offset @@ -351,6 +351,33 @@ static u8 ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index, u8 c return (rc); } +static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset) +{ + u8 rc; + switch (ctlr->ctlr_type) { + case 2: + case 4: + rc = i2c_ctrl_read (ctlr, base, offset); + break; + default: + return -ENODEV; + } + return rc; +} + +static u8 ctrl_write (struct controller *ctlr, void *base, u8 offset, u8 data) +{ + u8 rc = 0; + switch (ctlr->ctlr_type) { + case 2: + case 4: + rc = i2c_ctrl_write(ctlr, base, offset, data); + break; + default: + return -ENODEV; + } + return rc; +} /*---------------------------------------------------------------------- * Name: hpc_writecmdtoindex() * @@ -449,7 +476,7 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index) *---------------------------------------------------------------------*/ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus) { - void *wpg_bbar; + void *wpg_bbar = NULL; struct controller *ctlr_ptr; struct list_head *pslotlist; u8 index, status; @@ -491,7 +518,8 @@ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus) //-------------------------------------------------------------------- // map physical address to logical address //-------------------------------------------------------------------- - wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); + if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) + wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); //-------------------------------------------------------------------- // check controller status before reading @@ -569,7 +597,11 @@ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus) //-------------------------------------------------------------------- // cleanup //-------------------------------------------------------------------- - iounmap (wpg_bbar); // remove physical to logical address mapping + + // remove physical to logical address mapping + if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) + iounmap (wpg_bbar); + free_hpc_access (); debug_polling ("%s - Exit rc[%d]\n", __FUNCTION__, rc); @@ -583,7 +615,7 @@ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus) *---------------------------------------------------------------------*/ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) { - void *wpg_bbar; + void *wpg_bbar = NULL; struct controller *ctlr_ptr; u8 index, status; int busindex; @@ -626,12 +658,13 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) //-------------------------------------------------------------------- // map physical address to logical address //-------------------------------------------------------------------- - wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); + if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) { + wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); - debug ("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __FUNCTION__, + debug ("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __FUNCTION__, ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar, ctlr_ptr->u.wpeg_ctlr.i2c_addr); - + } //-------------------------------------------------------------------- // check controller status before writing //-------------------------------------------------------------------- @@ -668,7 +701,10 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd) ctlr_ptr->status = status; } // cleanup - iounmap (wpg_bbar); // remove physical to logical address mapping + + // remove physical to logical address mapping + if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) + iounmap (wpg_bbar); free_hpc_access (); debug_polling ("%s - Exit rc[%d]\n", __FUNCTION__, rc); @@ -701,6 +737,7 @@ void free_hpc_access (void) void ibmphp_lock_operations (void) { down (&semOperations); + to_debug = TRUE; } /*---------------------------------------------------------------------- @@ -710,6 +747,7 @@ void ibmphp_unlock_operations (void) { debug ("%s - Entry\n", __FUNCTION__); up (&semOperations); + to_debug = FALSE; debug ("%s - Exit\n", __FUNCTION__); } @@ -734,82 +772,86 @@ static void poll_hpc (void) debug ("%s - Entry\n", __FUNCTION__); while (!ibmphp_shutdown) { + if (ibmphp_shutdown) + break; + /* try to get the lock to do some kind of harware access */ down (&semOperations); switch (poll_state) { - case POLL_LATCH_REGISTER: - oldlatchlow = curlatchlow; - ctrl_count = 0x00; - list_for_each (pslotlist, &ibmphp_slot_head) { - if (ctrl_count >= ibmphp_get_total_controllers()) - break; - pslot = list_entry (pslotlist, struct slot, ibm_slot_list); - if (pslot->ctrl->ctlr_relative_id == ctrl_count) { - ctrl_count++; - if (READ_SLOT_LATCH (pslot->ctrl)) { - rc = ibmphp_hpc_readslot (pslot, - READ_SLOTLATCHLOWREG, - &curlatchlow); - if (oldlatchlow != curlatchlow) - process_changeinlatch (oldlatchlow, - curlatchlow, - pslot->ctrl); - } + case POLL_LATCH_REGISTER: + oldlatchlow = curlatchlow; + ctrl_count = 0x00; + list_for_each (pslotlist, &ibmphp_slot_head) { + if (ctrl_count >= ibmphp_get_total_controllers()) + break; + pslot = list_entry (pslotlist, struct slot, ibm_slot_list); + if (pslot->ctrl->ctlr_relative_id == ctrl_count) { + ctrl_count++; + if (READ_SLOT_LATCH (pslot->ctrl)) { + rc = ibmphp_hpc_readslot (pslot, + READ_SLOTLATCHLOWREG, + &curlatchlow); + if (oldlatchlow != curlatchlow) + process_changeinlatch (oldlatchlow, + curlatchlow, + pslot->ctrl); } } - poll_state = POLL_SLOTS; - break; - - case POLL_SLOTS: - list_for_each (pslotlist, &ibmphp_slot_head) { - pslot = list_entry (pslotlist, struct slot, ibm_slot_list); - // make a copy of the old status - memcpy ((void *) &myslot, (void *) pslot, - sizeof (struct slot)); - rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); - if ((myslot.status != pslot->status) - || (myslot.ext_status != pslot->ext_status)) - process_changeinstatus (pslot, &myslot); + } + ++poll_count; + poll_state = POLL_SLEEP; + break; + case POLL_SLOTS: + list_for_each (pslotlist, &ibmphp_slot_head) { + pslot = list_entry (pslotlist, struct slot, ibm_slot_list); + // make a copy of the old status + memcpy ((void *) &myslot, (void *) pslot, + sizeof (struct slot)); + rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); + if ((myslot.status != pslot->status) + || (myslot.ext_status != pslot->ext_status)) + process_changeinstatus (pslot, &myslot); + } + ctrl_count = 0x00; + list_for_each (pslotlist, &ibmphp_slot_head) { + if (ctrl_count >= ibmphp_get_total_controllers()) + break; + pslot = list_entry (pslotlist, struct slot, ibm_slot_list); + if (pslot->ctrl->ctlr_relative_id == ctrl_count) { + ctrl_count++; + if (READ_SLOT_LATCH (pslot->ctrl)) + rc = ibmphp_hpc_readslot (pslot, + READ_SLOTLATCHLOWREG, + &curlatchlow); } + } + ++poll_count; + poll_state = POLL_SLEEP; + break; + case POLL_SLEEP: + /* don't sleep with a lock on the hardware */ + up (&semOperations); + long_delay (POLL_INTERVAL_SEC * HZ); - ctrl_count = 0x00; - list_for_each (pslotlist, &ibmphp_slot_head) { - if (ctrl_count >= ibmphp_get_total_controllers()) - break; - pslot = list_entry (pslotlist, struct slot, ibm_slot_list); - if (pslot->ctrl->ctlr_relative_id == ctrl_count) { - ctrl_count++; - if (READ_SLOT_LATCH (pslot->ctrl)) - rc = ibmphp_hpc_readslot (pslot, - READ_SLOTLATCHLOWREG, - &curlatchlow); - } - } - ++poll_count; - if (poll_count >= POLL_LATCH_CNT) { - poll_count = 0; - poll_state = POLL_SLEEP; - } + if (ibmphp_shutdown) break; - - case POLL_SLEEP: - /* don't sleep with a lock on the hardware */ - up (&semOperations); - long_delay (POLL_INTERVAL_SEC * HZ); - down (&semOperations); + + down (&semOperations); + + if (poll_count >= POLL_LATCH_CNT) { + poll_count = 0; + poll_state = POLL_SLOTS; + } else poll_state = POLL_LATCH_REGISTER; - break; - } - + break; + } /* give up the harware semaphore */ up (&semOperations); - /* sleep for a short time just for good measure */ set_current_state (TASK_INTERRUPTIBLE); schedule_timeout (HZ/10); } - up (&sem_exit); debug ("%s - Exit\n", __FUNCTION__); } @@ -1070,15 +1112,23 @@ void __exit ibmphp_hpc_stop_poll_thread (void) debug ("%s - Entry\n", __FUNCTION__); ibmphp_shutdown = TRUE; + debug ("before locking operations \n"); ibmphp_lock_operations (); - + debug ("after locking operations \n"); + // wait for poll thread to exit + debug ("before sem_exit down \n"); down (&sem_exit); + debug ("after sem_exit down \n"); // cleanup + debug ("before free_hpc_access \n"); free_hpc_access (); + debug ("after free_hpc_access \n"); ibmphp_unlock_operations (); + debug ("after unlock operations \n"); up (&sem_exit); + debug ("after sem exit up\n"); debug ("%s - Exit\n", __FUNCTION__); } -- cgit v1.2.3 From 9adaeddf526a83c4ad09b33588f20679bec85e22 Mon Sep 17 00:00:00 2001 From: Irene Zubarev Date: Mon, 9 Sep 2002 00:39:59 -0700 Subject: [PATCH] IBM PCI Hotplug driver update for ISA based controllers --- drivers/hotplug/ibmphp_ebda.c | 13 ++++++++++--- drivers/hotplug/ibmphp_hpc.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) (limited to 'drivers/hotplug/ibmphp_hpc.c') diff --git a/drivers/hotplug/ibmphp_ebda.c b/drivers/hotplug/ibmphp_ebda.c index 4ef1b21cc76f..3fba419e7d07 100644 --- a/drivers/hotplug/ibmphp_ebda.c +++ b/drivers/hotplug/ibmphp_ebda.c @@ -815,6 +815,7 @@ static int __init ebda_rsrc_controller (void) struct ebda_hpc_slot *slot_ptr; struct bus_info *bus_info_ptr1, *bus_info_ptr2; int rc; + int retval; struct slot *slot_cur; struct list_head *list; @@ -933,6 +934,10 @@ static int __init ebda_rsrc_controller (void) case 0: hpc_ptr->u.isa_ctlr.io_start = readw (io_mem + addr); hpc_ptr->u.isa_ctlr.io_end = readw (io_mem + addr + 2); + retval = check_region (hpc_ptr->u.isa_ctlr.io_start, (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1)); + if (retval) + return -ENODEV; + request_region (hpc_ptr->u.isa_ctlr.io_start, (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1), "ibmphp"); hpc_ptr->irq = readb (io_mem + addr + 4); addr += 5; break; @@ -949,9 +954,9 @@ static int __init ebda_rsrc_controller (void) return -ENODEV; } - /* following 3 line: Now our driver only supports I2c ctlrType */ - if ((hpc_ptr->ctlr_type != 2) && (hpc_ptr->ctlr_type != 4)) { - err ("Please run this driver on ibm xseries440\n "); + /* following 3 line: Now our driver only supports I2c/ISA ctlrType */ + if ((hpc_ptr->ctlr_type != 2) && (hpc_ptr->ctlr_type != 4) && (hpc_ptr->ctlr_type != 0)) { + err ("Please run this driver on IBM xSeries440 or xSeries 235\n "); return -ENODEV; } @@ -1211,6 +1216,8 @@ void ibmphp_free_ebda_hpc_queue (void) list_for_each_safe (list, next, &ebda_hpc_head) { controller = list_entry (list, struct controller, ebda_hpc_list); + if (controller->ctlr_type == 0) + release_region (controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); free_ebda_hpc (controller); } } diff --git a/drivers/hotplug/ibmphp_hpc.c b/drivers/hotplug/ibmphp_hpc.c index 5b410df72b62..de70037b449a 100644 --- a/drivers/hotplug/ibmphp_hpc.c +++ b/drivers/hotplug/ibmphp_hpc.c @@ -351,10 +351,41 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void *WPGBbar, u8 index, return (rc); } +//------------------------------------------------------------ +// Read from ISA type HPC +//------------------------------------------------------------ +static u8 isa_ctrl_read (struct controller *ctlr_ptr, u8 offset) +{ + u16 start_address; + u16 end_address; + u8 data; + + start_address = ctlr_ptr->u.isa_ctlr.io_start; + end_address = ctlr_ptr->u.isa_ctlr.io_end; + data = inb (start_address + offset); + return data; +} + +//-------------------------------------------------------------- +// Write to ISA type HPC +//-------------------------------------------------------------- +static void isa_ctrl_write (struct controller *ctlr_ptr, u8 offset, u8 data) +{ + u16 start_address; + u16 port_address; + + start_address = ctlr_ptr->u.isa_ctlr.io_start; + port_address = start_address + (u16) offset; + outb (data, port_address); +} + static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset) { u8 rc; switch (ctlr->ctlr_type) { + case 0: + rc = isa_ctrl_read (ctlr, offset); + break; case 2: case 4: rc = i2c_ctrl_read (ctlr, base, offset); @@ -369,6 +400,9 @@ static u8 ctrl_write (struct controller *ctlr, void *base, u8 offset, u8 data) { u8 rc = 0; switch (ctlr->ctlr_type) { + case 0: + isa_ctrl_write(ctlr, offset, data); + break; case 2: case 4: rc = i2c_ctrl_write(ctlr, base, offset, data); -- cgit v1.2.3 From ef7f120ab49379a4745574dddf480c845ea2c7ab Mon Sep 17 00:00:00 2001 From: Irene Zubarev Date: Mon, 9 Sep 2002 00:40:30 -0700 Subject: [PATCH] IBM PCI Hotplug driver update for PCI based controllers --- drivers/hotplug/ibmphp.h | 1 + drivers/hotplug/ibmphp_core.c | 5 +++ drivers/hotplug/ibmphp_ebda.c | 71 +++++++++++++++++++++++++++++++++++++++---- drivers/hotplug/ibmphp_hpc.c | 26 ++++++++++++++++ 4 files changed, 97 insertions(+), 6 deletions(-) (limited to 'drivers/hotplug/ibmphp_hpc.c') diff --git a/drivers/hotplug/ibmphp.h b/drivers/hotplug/ibmphp.h index a45b1c7e821b..3828441ce748 100644 --- a/drivers/hotplug/ibmphp.h +++ b/drivers/hotplug/ibmphp.h @@ -737,6 +737,7 @@ struct slot { struct controller { struct ebda_hpc_slot *slots; struct ebda_hpc_bus *buses; + struct pci_dev *ctrl_dev; /* in case where controller is PCI */ u8 starting_slot_num; /* starting and ending slot #'s this ctrl controls*/ u8 ending_slot_num; u8 revision; diff --git a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c index 72907414443f..713943370a76 100644 --- a/drivers/hotplug/ibmphp_core.c +++ b/drivers/hotplug/ibmphp_core.c @@ -1636,6 +1636,11 @@ static int __init ibmphp_init (void) max_slots = get_max_slots (); + if ((rc = ibmphp_register_pci ())) { + ibmphp_unload (); + return rc; + } + if (init_ops ()) { ibmphp_unload (); return -ENODEV; diff --git a/drivers/hotplug/ibmphp_ebda.c b/drivers/hotplug/ibmphp_ebda.c index 3fba419e7d07..86a88433da5f 100644 --- a/drivers/hotplug/ibmphp_ebda.c +++ b/drivers/hotplug/ibmphp_ebda.c @@ -131,6 +131,7 @@ static void free_ebda_hpc (struct controller *controller) controller->slots = NULL; kfree (controller->buses); controller->buses = NULL; + controller->ctrl_dev = NULL; kfree (controller); } @@ -798,6 +799,8 @@ static char *create_file_name (struct slot * slot_cur) return NULL; } +static struct pci_driver ibmphp_driver; + /* * map info (ctlr-id, slot count, slot#.. bus count, bus#, ctlr type...) of * each hpc from physical address to a list of hot plug controllers based on @@ -929,6 +932,7 @@ static int __init ebda_rsrc_controller (void) hpc_ptr->u.pci_ctlr.dev_fun = readb (io_mem + addr + 1); hpc_ptr->irq = readb (io_mem + addr + 2); addr += 3; + debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n", hpc_ptr->u.pci_ctlr.bus, hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); break; case 0: @@ -954,12 +958,6 @@ static int __init ebda_rsrc_controller (void) return -ENODEV; } - /* following 3 line: Now our driver only supports I2c/ISA ctlrType */ - if ((hpc_ptr->ctlr_type != 2) && (hpc_ptr->ctlr_type != 4) && (hpc_ptr->ctlr_type != 0)) { - err ("Please run this driver on IBM xSeries440 or xSeries 235\n "); - return -ENODEV; - } - //reorganize chassis' linked list combine_wpg_for_chassis (); combine_wpg_for_expansion (); @@ -1213,11 +1211,16 @@ void ibmphp_free_ebda_hpc_queue (void) struct controller *controller = NULL; struct list_head *list; struct list_head *next; + int pci_flag = 0; list_for_each_safe (list, next, &ebda_hpc_head) { controller = list_entry (list, struct controller, ebda_hpc_list); if (controller->ctlr_type == 0) release_region (controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); + else if ((controller->ctlr_type == 1) && (!pci_flag)) { + ++pci_flag; + pci_unregister_driver (&ibmphp_driver); + } free_ebda_hpc (controller); } } @@ -1234,3 +1237,59 @@ void ibmphp_free_ebda_pci_rsrc_queue (void) resource = NULL; } } + +static struct pci_device_id id_table[] __devinitdata = { + { + vendor: PCI_VENDOR_ID_IBM, + device: HPC_DEVICE_ID, + subvendor: PCI_VENDOR_ID_IBM, + subdevice: HPC_SUBSYSTEM_ID, + class: ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00), + }, {} +}; + +MODULE_DEVICE_TABLE(pci, id_table); + +static int ibmphp_probe (struct pci_dev *, const struct pci_device_id *); +static struct pci_driver ibmphp_driver = { + name: "ibmphp", + id_table: id_table, + probe: ibmphp_probe, +}; + +int ibmphp_register_pci (void) +{ + struct controller *ctrl; + struct list_head *tmp; + int rc = 0; + + list_for_each (tmp, &ebda_hpc_head) { + ctrl = list_entry (tmp, struct controller, ebda_hpc_list); + if (ctrl->ctlr_type == 1) { + rc = pci_module_init (&ibmphp_driver); + break; + } + } + return rc; +} +static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids) +{ + struct controller *ctrl; + struct list_head *tmp; + + debug ("inside ibmphp_probe \n"); + + list_for_each (tmp, &ebda_hpc_head) { + ctrl = list_entry (tmp, struct controller, ebda_hpc_list); + if (ctrl->ctlr_type == 1) { + if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { + ctrl->ctrl_dev = dev; + debug ("found device!!! \n"); + debug ("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device); + return 0; + } + } + } + return -ENODEV; +} + diff --git a/drivers/hotplug/ibmphp_hpc.c b/drivers/hotplug/ibmphp_hpc.c index de70037b449a..ae959809e8a8 100644 --- a/drivers/hotplug/ibmphp_hpc.c +++ b/drivers/hotplug/ibmphp_hpc.c @@ -379,6 +379,26 @@ static void isa_ctrl_write (struct controller *ctlr_ptr, u8 offset, u8 data) outb (data, port_address); } +static u8 pci_ctrl_read (struct controller *ctrl, u8 offset) +{ + u8 data = 0x00; + debug ("inside pci_ctrl_read\n"); + if (ctrl->ctrl_dev) + pci_read_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); + return data; +} + +static u8 pci_ctrl_write (struct controller *ctrl, u8 offset, u8 data) +{ + u8 rc = -ENODEV; + debug ("inside pci_ctrl_write\n"); + if (ctrl->ctrl_dev) { + pci_write_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); + rc = 0; + } + return rc; +} + static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset) { u8 rc; @@ -386,6 +406,9 @@ static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset) case 0: rc = isa_ctrl_read (ctlr, offset); break; + case 1: + rc = pci_ctrl_read (ctlr, offset); + break; case 2: case 4: rc = i2c_ctrl_read (ctlr, base, offset); @@ -403,6 +426,9 @@ static u8 ctrl_write (struct controller *ctlr, void *base, u8 offset, u8 data) case 0: isa_ctrl_write(ctlr, offset, data); break; + case 1: + rc = pci_ctrl_write (ctlr, offset, data); + break; case 2: case 4: rc = i2c_ctrl_write(ctlr, base, offset, data); -- cgit v1.2.3