Lines Matching +full:rom +full:- +full:val

1 // SPDX-License-Identifier: GPL-2.0
3 * (C) Copyright 2002-2004 Greg Kroah-Hartman <[email protected]>
4 * (C) Copyright 2002-2004 IBM Corp.
6 * (C) Copyright 2003 Hewlett-Packard
49 return sysfs_emit(buf, format_string, pdev->field); \
69 * MSI-X, show the legacy INTx IRQ. in irq_show()
71 if (pdev->msi_enabled) in irq_show()
75 return sysfs_emit(buf, "%u\n", pdev->irq); in irq_show()
84 return sysfs_emit(buf, "%u\n", pdev->broken_parity_status); in broken_parity_status_show()
92 unsigned long val; in broken_parity_status_store() local
94 if (kstrtoul(buf, 0, &val) < 0) in broken_parity_status_store()
95 return -EINVAL; in broken_parity_status_store()
97 pdev->broken_parity_status = !!val; in broken_parity_status_store()
114 mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); in pci_dev_show_local_cpu()
159 return sysfs_emit(buf, "%s\n", pci_power_name(pdev->current_state)); in power_state_show()
173 if (pci_dev->subordinate) in resource_show()
179 struct resource *res = &pci_dev->resource[i]; in resource_show()
184 (unsigned long long)res->flags); in resource_show()
219 return -EINVAL; in current_link_speed_show()
236 return -EINVAL; in current_link_width_show()
252 return -EINVAL; in secondary_bus_number_show()
268 return -EINVAL; in subordinate_bus_number_show()
280 return sysfs_emit(buf, "%u\n", pci_ari_enabled(pci_dev->bus)); in ari_enabled_show()
290 pci_dev->vendor, pci_dev->device, in modalias_show()
291 pci_dev->subsystem_vendor, pci_dev->subsystem_device, in modalias_show()
292 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), in modalias_show()
293 (u8)(pci_dev->class)); in modalias_show()
301 unsigned long val; in enable_store() local
306 return -EPERM; in enable_store()
308 if (kstrtoul(buf, 0, &val) < 0) in enable_store()
309 return -EINVAL; in enable_store()
312 if (dev->driver) in enable_store()
313 result = -EBUSY; in enable_store()
314 else if (val) in enable_store()
319 result = -EIO; in enable_store()
331 return sysfs_emit(buf, "%u\n", atomic_read(&pdev->enable_cnt)); in enable_show()
344 return -EPERM; in numa_node_store()
347 return -EINVAL; in numa_node_store()
350 return -EINVAL; in numa_node_store()
353 return -EINVAL; in numa_node_store()
359 dev->numa_node = node; in numa_node_store()
366 return sysfs_emit(buf, "%d\n", dev->numa_node); in numa_node_show()
376 return sysfs_emit(buf, "%d\n", fls64(pdev->dma_mask)); in dma_mask_bits_show()
384 return sysfs_emit(buf, "%d\n", fls64(dev->coherent_dma_mask)); in consistent_dma_mask_bits_show()
392 struct pci_bus *subordinate = pdev->subordinate; in msi_bus_show()
395 !(subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI) in msi_bus_show()
396 : !pdev->no_msi); in msi_bus_show()
403 struct pci_bus *subordinate = pdev->subordinate; in msi_bus_store()
404 unsigned long val; in msi_bus_store() local
407 return -EPERM; in msi_bus_store()
409 if (kstrtoul(buf, 0, &val) < 0) in msi_bus_store()
410 return -EINVAL; in msi_bus_store()
414 * requests MSI or MSI-X. They don't affect any drivers that have in msi_bus_store()
415 * already requested MSI or MSI-X. in msi_bus_store()
418 pdev->no_msi = !val; in msi_bus_store()
419 pci_info(pdev, "MSI/MSI-X %s for future drivers\n", in msi_bus_store()
420 val ? "allowed" : "disallowed"); in msi_bus_store()
424 if (val) in msi_bus_store()
425 subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; in msi_bus_store()
427 subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; in msi_bus_store()
429 dev_info(&subordinate->dev, "MSI/MSI-X %s for future drivers of devices on this bus\n", in msi_bus_store()
430 val ? "allowed" : "disallowed"); in msi_bus_store()
437 unsigned long val; in rescan_store() local
440 if (kstrtoul(buf, 0, &val) < 0) in rescan_store()
441 return -EINVAL; in rescan_store()
443 if (val) { in rescan_store()
471 unsigned long val; in dev_rescan_store() local
474 if (kstrtoul(buf, 0, &val) < 0) in dev_rescan_store()
475 return -EINVAL; in dev_rescan_store()
477 if (val) { in dev_rescan_store()
479 pci_rescan_bus(pdev->bus); in dev_rescan_store()
490 unsigned long val; in remove_store() local
492 if (kstrtoul(buf, 0, &val) < 0) in remove_store()
493 return -EINVAL; in remove_store()
495 if (val && device_remove_file_self(dev, attr)) in remove_store()
506 unsigned long val; in bus_rescan_store() local
509 if (kstrtoul(buf, 0, &val) < 0) in bus_rescan_store()
510 return -EINVAL; in bus_rescan_store()
512 if (val) { in bus_rescan_store()
514 if (!pci_is_root_bus(bus) && list_empty(&bus->devices)) in bus_rescan_store()
515 pci_rescan_bus_bridge_resize(bus->self); in bus_rescan_store()
530 struct pci_bus *bus = pdev->subordinate; in reset_subordinate_store()
531 unsigned long val; in reset_subordinate_store() local
534 return -EPERM; in reset_subordinate_store()
536 if (kstrtoul(buf, 0, &val) < 0) in reset_subordinate_store()
537 return -EINVAL; in reset_subordinate_store()
539 if (val) { in reset_subordinate_store()
556 unsigned long val; in d3cold_allowed_store() local
558 if (kstrtoul(buf, 0, &val) < 0) in d3cold_allowed_store()
559 return -EINVAL; in d3cold_allowed_store()
561 pdev->d3cold_allowed = !!val; in d3cold_allowed_store()
573 return sysfs_emit(buf, "%u\n", pdev->d3cold_allowed); in d3cold_allowed_show()
599 ret = driver_set_override(dev, &pdev->driver_override, buf, count); in driver_override_store()
613 len = sysfs_emit(buf, "%s\n", pdev->driver_override); in driver_override_show()
692 !!(pdev->resource[PCI_ROM_RESOURCE].flags & in boot_vga_show()
708 size = dev->cfg_size; in pci_read_config()
709 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) in pci_read_config()
715 size -= off; in pci_read_config()
724 u8 val; in pci_read_config() local
725 pci_user_read_config_byte(dev, off, &val); in pci_read_config()
726 data[off - init_off] = val; in pci_read_config()
728 size--; in pci_read_config()
732 u16 val; in pci_read_config() local
733 pci_user_read_config_word(dev, off, &val); in pci_read_config()
734 data[off - init_off] = val & 0xff; in pci_read_config()
735 data[off - init_off + 1] = (val >> 8) & 0xff; in pci_read_config()
737 size -= 2; in pci_read_config()
741 u32 val; in pci_read_config() local
742 pci_user_read_config_dword(dev, off, &val); in pci_read_config()
743 data[off - init_off] = val & 0xff; in pci_read_config()
744 data[off - init_off + 1] = (val >> 8) & 0xff; in pci_read_config()
745 data[off - init_off + 2] = (val >> 16) & 0xff; in pci_read_config()
746 data[off - init_off + 3] = (val >> 24) & 0xff; in pci_read_config()
748 size -= 4; in pci_read_config()
753 u16 val; in pci_read_config() local
754 pci_user_read_config_word(dev, off, &val); in pci_read_config()
755 data[off - init_off] = val & 0xff; in pci_read_config()
756 data[off - init_off + 1] = (val >> 8) & 0xff; in pci_read_config()
758 size -= 2; in pci_read_config()
762 u8 val; in pci_read_config() local
763 pci_user_read_config_byte(dev, off, &val); in pci_read_config()
764 data[off - init_off] = val; in pci_read_config()
786 if (resource_is_exclusive(&dev->driver_exclusive_resource, off, in pci_write_config()
788 pci_warn_once(dev, "%s: Unexpected write to kernel-exclusive config offset %llx", in pci_write_config()
789 current->comm, off); in pci_write_config()
793 if (off > dev->cfg_size) in pci_write_config()
795 if (off + count > dev->cfg_size) { in pci_write_config()
796 size = dev->cfg_size - off; in pci_write_config()
803 pci_user_write_config_byte(dev, off, data[off - init_off]); in pci_write_config()
805 size--; in pci_write_config()
809 u16 val = data[off - init_off]; in pci_write_config() local
810 val |= (u16) data[off - init_off + 1] << 8; in pci_write_config()
811 pci_user_write_config_word(dev, off, val); in pci_write_config()
813 size -= 2; in pci_write_config()
817 u32 val = data[off - init_off]; in pci_write_config() local
818 val |= (u32) data[off - init_off + 1] << 8; in pci_write_config()
819 val |= (u32) data[off - init_off + 2] << 16; in pci_write_config()
820 val |= (u32) data[off - init_off + 3] << 24; in pci_write_config()
821 pci_user_write_config_dword(dev, off, val); in pci_write_config()
823 size -= 4; in pci_write_config()
827 u16 val = data[off - init_off]; in pci_write_config() local
828 val |= (u16) data[off - init_off + 1] << 8; in pci_write_config()
829 pci_user_write_config_word(dev, off, val); in pci_write_config()
831 size -= 2; in pci_write_config()
835 pci_user_write_config_byte(dev, off, data[off - init_off]); in pci_write_config()
854 if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) in pci_dev_config_attr_bin_size()
874 return fixed_size_llseek(filep, offset, whence, attr->size); in pci_llseek_resource()
879 * pci_read_legacy_io - read byte(s) from legacy I/O port space
898 return -EINVAL; in pci_read_legacy_io()
904 * pci_write_legacy_io - write byte(s) to legacy I/O port space
923 return -EINVAL; in pci_write_legacy_io()
929 * pci_mmap_legacy_mem - map legacy PCI memory into user memory space
949 * pci_mmap_legacy_io - map legacy PCI IO into user memory space
957 * memory space. Returns -ENOSYS if the operation isn't supported
969 * pci_adjust_legacy_attr - adjustment of legacy file attributes
981 * pci_create_legacy_files - create legacy I/O port and memory files
985 * a per-bus basis. This routine creates the files and ties them into
986 * their associated read, write and mmap files from pci-sysfs.c
998 b->legacy_io = kcalloc(2, sizeof(struct bin_attribute), in pci_create_legacy_files()
1000 if (!b->legacy_io) in pci_create_legacy_files()
1003 sysfs_bin_attr_init(b->legacy_io); in pci_create_legacy_files()
1004 b->legacy_io->attr.name = "legacy_io"; in pci_create_legacy_files()
1005 b->legacy_io->size = 0xffff; in pci_create_legacy_files()
1006 b->legacy_io->attr.mode = 0600; in pci_create_legacy_files()
1007 b->legacy_io->read_new = pci_read_legacy_io; in pci_create_legacy_files()
1008 b->legacy_io->write_new = pci_write_legacy_io; in pci_create_legacy_files()
1010 b->legacy_io->llseek = pci_llseek_resource; in pci_create_legacy_files()
1011 b->legacy_io->mmap = pci_mmap_legacy_io; in pci_create_legacy_files()
1012 b->legacy_io->f_mapping = iomem_get_mapping; in pci_create_legacy_files()
1014 error = device_create_bin_file(&b->dev, b->legacy_io); in pci_create_legacy_files()
1019 b->legacy_mem = b->legacy_io + 1; in pci_create_legacy_files()
1020 sysfs_bin_attr_init(b->legacy_mem); in pci_create_legacy_files()
1021 b->legacy_mem->attr.name = "legacy_mem"; in pci_create_legacy_files()
1022 b->legacy_mem->size = 1024*1024; in pci_create_legacy_files()
1023 b->legacy_mem->attr.mode = 0600; in pci_create_legacy_files()
1024 b->legacy_mem->mmap = pci_mmap_legacy_mem; in pci_create_legacy_files()
1026 b->legacy_mem->llseek = pci_llseek_resource; in pci_create_legacy_files()
1027 b->legacy_mem->f_mapping = iomem_get_mapping; in pci_create_legacy_files()
1029 error = device_create_bin_file(&b->dev, b->legacy_mem); in pci_create_legacy_files()
1036 device_remove_bin_file(&b->dev, b->legacy_io); in pci_create_legacy_files()
1038 kfree(b->legacy_io); in pci_create_legacy_files()
1039 b->legacy_io = NULL; in pci_create_legacy_files()
1041 dev_warn(&b->dev, "could not create legacy I/O port and ISA memory resources in sysfs\n"); in pci_create_legacy_files()
1046 if (b->legacy_io) { in pci_remove_legacy_files()
1047 device_remove_bin_file(&b->dev, b->legacy_io); in pci_remove_legacy_files()
1048 device_remove_bin_file(&b->dev, b->legacy_mem); in pci_remove_legacy_files()
1049 kfree(b->legacy_io); /* both are allocated here */ in pci_remove_legacy_files()
1056 * pci_mmap_resource - map a PCI resource into user memory space
1068 int bar = (unsigned long)attr->private; in pci_mmap_resource()
1070 struct resource *res = &pdev->resource[bar]; in pci_mmap_resource()
1077 if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) in pci_mmap_resource()
1078 return -EINVAL; in pci_mmap_resource()
1081 return -EINVAL; in pci_mmap_resource()
1083 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; in pci_mmap_resource()
1108 int bar = (unsigned long)attr->private; in pci_resource_io()
1116 if (port + count - 1 > pci_resource_end(pdev, bar)) in pci_resource_io()
1117 return -EINVAL; in pci_resource_io()
1139 return -EINVAL; in pci_resource_io()
1141 return -ENXIO; in pci_resource_io()
1166 * pci_remove_resource_files - cleanup resource files
1179 res_attr = pdev->res_attr[i]; in pci_remove_resource_files()
1181 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); in pci_remove_resource_files()
1185 res_attr = pdev->res_attr_wc[i]; in pci_remove_resource_files()
1187 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); in pci_remove_resource_files()
1203 return -ENOMEM; in pci_create_attr()
1210 res_attr->mmap = pci_mmap_resource_wc; in pci_create_attr()
1214 res_attr->read_new = pci_read_resource_io; in pci_create_attr()
1215 res_attr->write_new = pci_write_resource_io; in pci_create_attr()
1217 res_attr->mmap = pci_mmap_resource_uc; in pci_create_attr()
1219 res_attr->mmap = pci_mmap_resource_uc; in pci_create_attr()
1222 if (res_attr->mmap) { in pci_create_attr()
1223 res_attr->f_mapping = iomem_get_mapping; in pci_create_attr()
1225 * generic_file_llseek() consults f_mapping->host to determine in pci_create_attr()
1229 res_attr->llseek = pci_llseek_resource; in pci_create_attr()
1231 res_attr->attr.name = res_attr_name; in pci_create_attr()
1232 res_attr->attr.mode = 0600; in pci_create_attr()
1233 res_attr->size = pci_resource_len(pdev, num); in pci_create_attr()
1234 res_attr->private = (void *)(unsigned long)num; in pci_create_attr()
1235 retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); in pci_create_attr()
1242 pdev->res_attr_wc[num] = res_attr; in pci_create_attr()
1244 pdev->res_attr[num] = res_attr; in pci_create_attr()
1250 * pci_create_resource_files - create resource files in sysfs for @dev
1270 pdev->resource[i].flags & IORESOURCE_PREFETCH) in pci_create_resource_files()
1285 * pci_write_rom - used to enable access to the PCI ROM display
1302 pdev->rom_attr_enabled = 0; in pci_write_rom()
1304 pdev->rom_attr_enabled = 1; in pci_write_rom()
1310 * pci_read_rom - read a PCI ROM
1314 * @buf: where to put the data we read from the ROM
1318 * Put @count bytes starting at @off into @buf from the ROM in the PCI
1326 void __iomem *rom; in pci_read_rom() local
1329 if (!pdev->rom_attr_enabled) in pci_read_rom()
1330 return -EINVAL; in pci_read_rom()
1332 rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ in pci_read_rom()
1333 if (!rom || !size) in pci_read_rom()
1334 return -EIO; in pci_read_rom()
1340 count = size - off; in pci_read_rom()
1342 memcpy_fromio(buf, rom + off, count); in pci_read_rom()
1344 pci_unmap_rom(pdev, rom); in pci_read_rom()
1348 static const BIN_ATTR(rom, 0600, pci_read_rom, pci_write_rom, 0);
1360 /* If the device has a ROM, try to expose it in sysfs. */ in pci_dev_rom_attr_is_visible()
1364 return a->attr.mode; in pci_dev_rom_attr_is_visible()
1385 unsigned long val; in reset_store() local
1388 if (kstrtoul(buf, 0, &val) < 0) in reset_store()
1389 return -EINVAL; in reset_store()
1391 if (val != 1) in reset_store()
1392 return -EINVAL; in reset_store()
1417 return a->mode; in pci_dev_reset_attr_is_visible()
1433 m = pdev->reset_methods[i]; in reset_method_show()
1469 pdev->reset_methods[0] = 0; in reset_method_store()
1481 return -ENOMEM; in reset_method_store()
1495 return -EINVAL; in reset_method_store()
1500 return -EINVAL; in reset_method_store()
1503 if (n == PCI_NUM_RESET_METHODS - 1) { in reset_method_store()
1505 return -EINVAL; in reset_method_store()
1513 /* Warn if dev-specific supported but not highest priority */ in reset_method_store()
1516 pci_warn(pdev, "Device-specific reset disabled/de-prioritized by user"); in reset_method_store()
1517 memcpy(pdev->reset_methods, reset_methods, sizeof(pdev->reset_methods)); in reset_method_store()
1556 return -EINVAL; in __resource_resize_store()
1559 if (dev->driver || pci_num_vf(pdev)) { in __resource_resize_store()
1560 ret = -EBUSY; in __resource_resize_store()
1566 if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { in __resource_resize_store()
1589 pci_assign_unassigned_bus_resources(pdev->bus); in __resource_resize_store()
1640 return pci_rebar_get_current_size(pdev, n) < 0 ? 0 : a->mode; in resource_resize_is_visible()
1651 return -EACCES; in pci_create_sysfs_dev_files()
1657 * pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files
1704 return a->mode; in pci_dev_attrs_are_visible()
1721 if (pdev->is_virtfn) in pci_dev_hp_attrs_are_visible()
1724 return a->mode; in pci_dev_hp_attrs_are_visible()
1734 return a->mode; in pci_bridge_attrs_are_visible()
1746 return a->mode; in pcie_dev_attrs_are_visible()