Lines Matching +full:led +full:-
3 #include "qemu/host-utils.h"
5 #include "qemu/error-report.h"
7 #include "migration/qemu-file-types.h"
17 /* TODO: remove fully only on state DISABLED and LED off.
22 #define SHPC_SLOTS_33 0x04 /* 4 bytes. Also encodes PCI-X slots. */
112 #define SHPC_SIZEOF(d) SHPC_SLOT_REG((d)->shpc->nslots)
122 #define SHPC_LOGICAL_TO_IDX(target) ((target) - 1)
124 #define SHPC_PCI_TO_IDX(pci_slot) ((pci_slot) - 1)
145 return "power-only"; in shpc_slot_state_to_str()
157 uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot); in shpc_get_status()
167 uint8_t *status = shpc->config + SHPC_SLOT_STATUS(slot); in shpc_set_status()
174 SHPCDevice *shpc = d->shpc; in shpc_interrupt_update()
181 for (slot = 0; slot < shpc->nslots; ++slot) { in shpc_interrupt_update()
182 uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH(slot)]; in shpc_interrupt_update()
183 uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS(d, slot)]; in shpc_interrupt_update()
189 serr_int = pci_get_long(shpc->config + SHPC_SERR_INT); in shpc_interrupt_update()
193 pci_set_long(shpc->config + SHPC_INT_LOCATOR, int_locator); in shpc_interrupt_update()
195 if (msi_enabled(d) && shpc->msi_requested != level) in shpc_interrupt_update()
199 shpc->msi_requested = level; in shpc_interrupt_update()
206 shpc->config[SHPC_SEC_BUS] &= ~SHPC_SEC_BUS_MASK; in shpc_set_sec_bus_speed()
207 shpc->config[SHPC_SEC_BUS] |= speed; in shpc_set_sec_bus_speed()
210 pci_word_test_and_set_mask(shpc->config + SHPC_CMD_STATUS, in shpc_set_sec_bus_speed()
217 SHPCDevice *shpc = d->shpc; in shpc_reset()
218 int nslots = shpc->nslots; in shpc_reset()
220 memset(shpc->config, 0, SHPC_SIZEOF(d)); in shpc_reset()
221 pci_set_byte(shpc->config + SHPC_NSLOTS, nslots); in shpc_reset()
222 pci_set_long(shpc->config + SHPC_SLOTS_33, nslots); in shpc_reset()
223 pci_set_long(shpc->config + SHPC_SLOTS_66, 0); in shpc_reset()
224 pci_set_byte(shpc->config + SHPC_FIRST_DEV, SHPC_IDX_TO_PCI(0)); in shpc_reset()
225 pci_set_word(shpc->config + SHPC_PHYS_SLOT, in shpc_reset()
230 pci_set_long(shpc->config + SHPC_SERR_INT, SHPC_INT_DIS | in shpc_reset()
234 pci_set_byte(shpc->config + SHPC_PROG_IFC, SHPC_PROG_IFC_1_0); in shpc_reset()
235 pci_set_word(shpc->config + SHPC_SEC_BUS, SHPC_SEC_BUS_33); in shpc_reset()
236 for (i = 0; i < shpc->nslots; ++i) { in shpc_reset()
237 pci_set_byte(shpc->config + SHPC_SLOT_EVENT_SERR_INT_DIS(d, i), in shpc_reset()
245 if (shpc->sec_bus->devices[PCI_DEVFN(SHPC_IDX_TO_PCI(i), 0)]) { in shpc_reset()
262 shpc->msi_requested = 0; in shpc_reset()
268 pci_word_test_and_set_mask(shpc->config + SHPC_CMD_STATUS, in shpc_invalid_command()
278 devfn <= PCI_DEVFN(pci_slot, PCI_FUNC_MAX - 1); in shpc_free_devices_in_slot()
280 PCIDevice *affected_dev = shpc->sec_bus->devices[devfn]; in shpc_free_devices_in_slot()
298 SHPCDevice *shpc = d->shpc; in shpc_slot_command()
304 if (target < SHPC_CMD_TRGT_MIN || slot >= shpc->nslots) { in shpc_slot_command()
338 DEVICE(shpc->sec_bus->devices[PCI_DEVFN(pci_slot, 0)]); in shpc_slot_command()
341 parent->canonical_path, pci_slot, in shpc_slot_command()
342 child ? child->canonical_path : "no-child", in shpc_slot_command()
358 shpc->config[SHPC_SLOT_EVENT_LATCH(slot)] |= in shpc_slot_command()
366 SHPCDevice *shpc = d->shpc; in shpc_command()
367 uint8_t code = pci_get_byte(shpc->config + SHPC_CMD_CODE); in shpc_command()
376 pci_word_test_and_clear_mask(shpc->config + SHPC_CMD_STATUS, in shpc_command()
383 target = shpc->config[SHPC_CMD_TRGT] & SHPC_CMD_TRGT_MAX; in shpc_command()
396 for (i = 0; i < shpc->nslots; ++i) { in shpc_command()
403 for (i = 0; i < shpc->nslots; ++i) { in shpc_command()
416 * This doesn't make sense - why not? a spec bug? */ in shpc_command()
417 for (i = 0; i < shpc->nslots; ++i) { in shpc_command()
424 for (i = 0; i < shpc->nslots; ++i) { in shpc_command()
439 pci_long_test_and_set_mask(shpc->config + SHPC_SERR_INT, SHPC_CMD_DETECTED); in shpc_command()
444 SHPCDevice *shpc = d->shpc; in shpc_write()
449 l = MIN(l, SHPC_SIZEOF(d) - addr); in shpc_write()
454 uint8_t wmask = shpc->wmask[a]; in shpc_write()
455 uint8_t w1cmask = shpc->w1cmask[a]; in shpc_write()
457 shpc->config[a] = (shpc->config[a] & ~wmask) | (val & wmask); in shpc_write()
458 shpc->config[a] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */ in shpc_write()
472 l = MIN(l, SHPC_SIZEOF(d) - addr); in shpc_read()
473 memcpy(&val, d->shpc->config + addr, l); in shpc_read()
487 return pci_get_byte(d->config + d->shpc->cap + SHPC_CAP_DWORD_SELECT); in shpc_cap_dword()
495 pci_set_long(d->config + d->shpc->cap + SHPC_CAP_DWORD_DATA, data); in shpc_cap_update_dword()
509 config = d->config + config_offset; in shpc_cap_add_config()
514 d->shpc->cap = config_offset; in shpc_cap_add_config()
516 pci_set_byte(d->wmask + config_offset + SHPC_CAP_DWORD_SELECT, 0xff); in shpc_cap_add_config()
517 pci_set_long(d->wmask + config_offset + SHPC_CAP_DWORD_DATA, 0xffffffff); in shpc_cap_add_config()
549 int pci_slot = PCI_SLOT(affected_dev->devfn); in shpc_device_get_slot()
552 if (pci_slot < SHPC_IDX_TO_PCI(0) || *slot >= shpc->nslots) { in shpc_device_get_slot()
556 SHPC_IDX_TO_PCI(shpc->nslots) - 1); in shpc_device_get_slot()
567 SHPCDevice *shpc = pci_hotplug_dev->shpc; in shpc_device_plug_cb()
577 if (!dev->hotplugged) { in shpc_device_plug_cb()
590 shpc->config[SHPC_SLOT_EVENT_LATCH(slot)] |= in shpc_device_plug_cb()
596 shpc->config[SHPC_SLOT_EVENT_LATCH(slot)] |= in shpc_device_plug_cb()
613 SHPCDevice *shpc = pci_hotplug_dev->shpc; in shpc_device_unplug_request_cb()
615 uint8_t led; in shpc_device_unplug_request_cb() local
623 led = shpc_get_status(shpc, slot, SHPC_SLOT_PWR_LED_MASK); in shpc_device_unplug_request_cb()
625 if (led == SHPC_LED_BLINK) { in shpc_device_unplug_request_cb()
626 error_setg(errp, "Hot-unplug failed: " in shpc_device_unplug_request_cb()
631 if (state == SHPC_STATE_DISABLED && led == SHPC_LED_OFF) { in shpc_device_unplug_request_cb()
636 shpc->config[SHPC_SLOT_EVENT_LATCH(slot)] |= in shpc_device_unplug_request_cb()
640 shpc->config[SHPC_SLOT_EVENT_LATCH(slot)] |= SHPC_SLOT_EVENT_BUTTON; in shpc_device_unplug_request_cb()
652 SHPCDevice *shpc = d->shpc = g_malloc0(sizeof(*d->shpc)); in shpc_init()
653 shpc->sec_bus = sec_bus; in shpc_init()
656 g_free(d->shpc); in shpc_init()
665 return -EINVAL; in shpc_init()
667 shpc->nslots = nslots; in shpc_init()
668 shpc->config = g_malloc0(SHPC_SIZEOF(d)); in shpc_init()
669 shpc->cmask = g_malloc0(SHPC_SIZEOF(d)); in shpc_init()
670 shpc->wmask = g_malloc0(SHPC_SIZEOF(d)); in shpc_init()
671 shpc->w1cmask = g_malloc0(SHPC_SIZEOF(d)); in shpc_init()
675 pci_set_long(shpc->config + SHPC_BASE_OFFSET, offset); in shpc_init()
677 pci_set_byte(shpc->wmask + SHPC_CMD_CODE, 0xff); in shpc_init()
678 pci_set_byte(shpc->wmask + SHPC_CMD_TRGT, SHPC_CMD_TRGT_MAX); in shpc_init()
679 pci_set_byte(shpc->wmask + SHPC_CMD_TRGT, SHPC_CMD_TRGT_MAX); in shpc_init()
680 pci_set_long(shpc->wmask + SHPC_SERR_INT, in shpc_init()
685 pci_set_long(shpc->w1cmask + SHPC_SERR_INT, in shpc_init()
689 pci_set_byte(shpc->wmask + in shpc_init()
698 pci_set_byte(shpc->w1cmask + in shpc_init()
708 memory_region_init_io(&shpc->mmio, OBJECT(d), &shpc_mmio_ops, in shpc_init()
709 d, "shpc-mmio", SHPC_SIZEOF(d)); in shpc_init()
711 memory_region_add_subregion(bar, offset, &shpc->mmio); in shpc_init()
715 d->cap_present |= QEMU_PCI_CAP_SHPC; in shpc_init()
726 SHPCDevice *shpc = d->shpc; in shpc_cleanup()
727 d->cap_present &= ~QEMU_PCI_CAP_SHPC; in shpc_cleanup()
728 memory_region_del_subregion(bar, &shpc->mmio); in shpc_cleanup()
734 SHPCDevice *shpc = d->shpc; in shpc_free()
738 object_unparent(OBJECT(&shpc->mmio)); in shpc_free()
739 g_free(shpc->config); in shpc_free()
740 g_free(shpc->cmask); in shpc_free()
741 g_free(shpc->wmask); in shpc_free()
742 g_free(shpc->w1cmask); in shpc_free()
744 d->shpc = NULL; in shpc_free()
749 if (!ranges_overlap(addr, l, d->shpc->cap, SHPC_CAP_LENGTH)) { in shpc_cap_write_config()
752 if (ranges_overlap(addr, l, d->shpc->cap + SHPC_CAP_DWORD_DATA, 4)) { in shpc_cap_write_config()
754 dword_data = pci_get_long(d->shpc->config + d->shpc->cap in shpc_cap_write_config()
766 qemu_put_buffer(f, d->shpc->config, SHPC_SIZEOF(d)); in shpc_save()
775 int ret = qemu_get_buffer(f, d->shpc->config, SHPC_SIZEOF(d)); in shpc_load()
777 return -EINVAL; in shpc_load()
780 d->shpc->msi_requested = 0; in shpc_load()