Lines Matching +full:num +full:- +full:ids

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (c) 2001-2023 Helge Deller <deller@gmx.de>
9 * Copyright (c) 2004-2005 Thibaut VARENE <varenet@parisc-linux.org>
16 * - 715/Mirage device paths have a dummy device between Lasi and its children
17 * - The EISA adapter may show up as a sibling or child of Wax
18 * - Dino has an optionally functional serial port. If firmware enables it,
21 * - Dino has both parisc and pci devices as children
22 * - parisc devices are discovered in a random order, including children
33 #include <linux/dma-map-ops.h>
37 #include <asm/parisc-device.h>
40 /* See comments in include/asm-parisc/pci.h */
50 if (dev->bus == &parisc_bus_type) { in check_dev()
53 return pdev->id.hw_type != HPHW_FAULTY; in check_dev()
70 if (recurse_data->fn(dev, recurse_data->obj)) in descend_children()
77 * for_each_padev - Iterate over all devices in the tree
81 * This performs a depth-first traversal of the tree, calling the
96 * match_device - Report whether this driver can handle this device
97 * @driver: the PA-RISC driver to try
98 * @dev: the PA-RISC device to try
102 const struct parisc_device_id *ids; in match_device() local
104 for (ids = driver->id_table; ids->sversion; ids++) { in match_device()
105 if ((ids->sversion != SVERSION_ANY_ID) && in match_device()
106 (ids->sversion != dev->id.sversion)) in match_device()
109 if ((ids->hw_type != HWTYPE_ANY_ID) && in match_device()
110 (ids->hw_type != dev->id.hw_type)) in match_device()
113 if ((ids->hversion != HVERSION_ANY_ID) && in match_device()
114 (ids->hversion != dev->id.hversion)) in match_device()
126 struct parisc_driver *pa_drv = to_parisc_driver(dev->driver); in parisc_driver_probe()
128 rc = pa_drv->probe(pa_dev); in parisc_driver_probe()
131 pa_dev->driver = pa_drv; in parisc_driver_probe()
139 struct parisc_driver *pa_drv = to_parisc_driver(dev->driver); in parisc_driver_remove()
141 if (pa_drv->remove) in parisc_driver_remove()
142 pa_drv->remove(pa_dev); in parisc_driver_remove()
147 * register_parisc_driver - Register this driver if it can handle a device
148 * @driver: the PA-RISC driver to try
154 if (driver->drv.name) { in register_parisc_driver()
156 driver->name); in register_parisc_driver()
160 if (!driver->probe) { in register_parisc_driver()
161 pr_warn("BUG: driver %s has no probe routine\n", driver->name); in register_parisc_driver()
165 driver->drv.bus = &parisc_bus_type; in register_parisc_driver()
168 WARN_ON(driver->drv.probe != NULL); in register_parisc_driver()
169 WARN_ON(driver->drv.remove != NULL); in register_parisc_driver()
171 driver->drv.name = driver->name; in register_parisc_driver()
173 return driver_register(&driver->drv); in register_parisc_driver()
189 if (match_device(m->driver, pdev)) in match_and_count()
190 m->count++; in match_and_count()
196 * count_parisc_driver - count # of devices this driver would match
197 * @driver: the PA-RISC driver to try
217 * unregister_parisc_driver - Unregister this driver from the list of drivers
218 * @driver: the PA-RISC driver to unregister
222 driver_unregister(&driver->drv); in unregister_parisc_driver()
238 if (pdev->hpa.start == d->hpa) { in find_device()
239 d->dev = pdev; in find_device()
263 if (pdev->id.hw_type != HPHW_BCPORT) in is_IKE_device()
266 (pdev->id.hversion == REO_MERCED_PORT) || in is_IKE_device()
267 (pdev->id.hversion == REOG_MERCED_PORT)) { in is_IKE_device()
282 * find_pa_parent_type - Find a parent of a specific type
292 const struct device *dev = &padev->dev; in find_pa_parent_type()
295 if (candidate->id.hw_type == type) in find_pa_parent_type()
297 dev = dev->parent; in find_pa_parent_type()
313 memset(&path->bc, -1, 6); in get_node_path()
316 unsigned int devfn = to_pci_dev(dev)->devfn; in get_node_path()
317 path->mod = PCI_FUNC(devfn); in get_node_path()
318 path->bc[i--] = PCI_SLOT(devfn); in get_node_path()
319 dev = dev->parent; in get_node_path()
324 unsigned int devfn = to_pci_dev(dev)->devfn; in get_node_path()
325 path->bc[i--] = PCI_SLOT(devfn) | (PCI_FUNC(devfn)<< 5); in get_node_path()
326 } else if (dev->bus == &parisc_bus_type) { in get_node_path()
327 path->bc[i--] = to_parisc_device(dev)->hw_path; in get_node_path()
329 dev = dev->parent; in get_node_path()
337 if (path->bc[i] == -1) in print_hwpath()
339 output += sprintf(output, "%u/", (unsigned char) path->bc[i]); in print_hwpath()
341 output += sprintf(output, "%u", (unsigned char) path->mod); in print_hwpath()
346 * print_pa_hwpath - Returns hardware path for PA devices
348 * @output: Pointer to a previously-allocated array to place the path in.
350 * This function fills in the output array with a human-readable path
358 get_node_path(dev->dev.parent, &path); in print_pa_hwpath()
359 path.mod = dev->hw_path; in print_pa_hwpath()
366 * get_pci_node_path - Determines the hardware path for a PCI device
368 * @path: Pointer to a previously-allocated array to place the path in.
376 get_node_path(&pdev->dev, path); in get_pci_node_path()
381 * print_pci_hwpath - Returns hardware path for PCI devices
383 * @output: Pointer to a previously-allocated array to place the path in.
385 * This function fills in the output array with a human-readable path
407 get_node_path(padev->dev.parent, &path); in setup_bus_id()
410 if (path.bc[i] == -1) in setup_bus_id()
414 sprintf(output, "%u", (unsigned char) padev->hw_path); in setup_bus_id()
415 dev_set_name(&padev->dev, name); in setup_bus_id()
425 dev->hw_path = id; in create_tree_node()
426 dev->id.hw_type = HPHW_FAULTY; in create_tree_node()
428 dev->dev.parent = parent; in create_tree_node()
431 dev->dev.bus = &parisc_bus_type; in create_tree_node()
432 dev->dma_mask = 0xffffffffUL; /* PARISC devices are 32-bit */ in create_tree_node()
435 dev->dev.dma_mask = &dev->dma_mask; in create_tree_node()
436 dev->dev.coherent_dma_mask = dev->dma_mask; in create_tree_node()
437 if (device_register(&dev->dev)) { in create_tree_node()
455 if (pdev->hw_path == d->id) { in match_by_id()
456 d->dev = pdev; in match_by_id()
463 * alloc_tree_node - returns a device entry in the iotree
487 if (modpath->bc[i] == -1) in create_parisc_device()
489 parent = &alloc_tree_node(parent, modpath->bc[i])->dev; in create_parisc_device()
491 return alloc_tree_node(parent, modpath->mod); in create_parisc_device()
503 /* Check to make sure this device has not already been added - Ryan */ in alloc_pa_dev()
512 if (dev->id.hw_type != HPHW_FAULTY) { in alloc_pa_dev()
519 dev->id.hw_type = iodc_data[3] & 0x1f; in alloc_pa_dev()
520 dev->id.hversion = (iodc_data[0] << 4) | ((iodc_data[1] & 0xf0) >> 4); in alloc_pa_dev()
521 dev->id.hversion_rev = iodc_data[1] & 0x0f; in alloc_pa_dev()
522 dev->id.sversion = ((iodc_data[4] & 0x0f) << 16) | in alloc_pa_dev()
524 dev->hpa.start = hpa; in alloc_pa_dev()
530 dev->hpa.end = hpa + 0x03ffffff; in alloc_pa_dev()
532 dev->hpa.end = hpa + 0x01ffffff; in alloc_pa_dev()
534 dev->hpa.end = hpa + 0xfff; in alloc_pa_dev()
536 dev->hpa.flags = IORESOURCE_MEM; in alloc_pa_dev()
537 dev->hpa.name = dev->name; in alloc_pa_dev()
538 name = parisc_hardware_description(&dev->id) ? : "unknown"; in alloc_pa_dev()
539 snprintf(dev->name, sizeof(dev->name), "%s [%s]", in alloc_pa_dev()
545 if ((hpa & 0xfff) == 0 && insert_resource(&iomem_resource, &dev->hpa)) in alloc_pa_dev()
559 const struct parisc_device_id *id = &padev->id; in make_modalias()
562 (u8)id->hw_type, (u16)id->hversion, (u8)id->hversion_rev, in make_modalias()
563 (u32)id->sversion); in make_modalias()
572 return -ENODEV; in parisc_uevent()
576 return -ENODEV; in parisc_uevent()
578 if (add_uevent_var(env, "PARISC_NAME=%s", padev->name)) in parisc_uevent()
579 return -ENOMEM; in parisc_uevent()
583 return -ENOMEM; in parisc_uevent()
592 return sprintf(buf, format_string, padev->field); \
631 * register_parisc_device - Locate a driver to manage this device.
642 if (dev->driver) in register_parisc_device()
649 * match_pci_device - Matches a pci device against a given hardware path
664 unsigned int devfn = pdev->devfn; in match_pci_device()
665 return ((modpath->bc[5] == PCI_SLOT(devfn)) && in match_pci_device()
666 (modpath->mod == PCI_FUNC(devfn))); in match_pci_device()
673 id = PCI_SLOT(pdev->devfn) | (PCI_FUNC(pdev->devfn) << 5); in match_pci_device()
674 return (modpath->bc[index] == id); in match_pci_device()
678 * match_parisc_device - Matches a parisc device against a given hardware
689 char id = (index == 6) ? modpath->mod : modpath->bc[index]; in match_parisc_device()
691 return (curr->hw_path == id); in match_parisc_device()
705 if (dev->bus == &parisc_bus_type) { in check_parent()
706 if (match_parisc_device(dev, d->index, d->modpath)) in check_parent()
707 d->dev = dev; in check_parent()
709 if (match_pci_device(dev, d->index, d->modpath)) in check_parent()
710 d->dev = dev; in check_parent()
711 } else if (dev->bus == NULL) { in check_parent()
713 struct device *new = parse_tree_node(dev, d->index, d->modpath); in check_parent()
715 d->dev = new; in check_parent()
718 return d->dev != NULL; in check_parent()
722 * parse_tree_node - returns a device entry in the iotree
751 * hwpath_to_device - Finds the generic device corresponding to a given hardware path.
760 if (modpath->bc[i] == -1) in hwpath_to_device()
774 * device_to_hwpath - Populates the hwpath corresponding to the given device.
781 if (dev->bus == &parisc_bus_type) { in device_to_hwpath()
783 get_node_path(dev->parent, path); in device_to_hwpath()
784 path->mod = padev->hw_path; in device_to_hwpath()
795 ((dev->id.hw_type == HPHW_IOA) || (dev->id.hw_type == HPHW_BCPORT))
798 ((gsc_readl(dev->hpa.start + offsetof(struct bc_module, io_status)) \
807 #define READ_IO_IO_LOW(dev) (unsigned long)(signed int)gsc_readl(dev->hpa.start + IO_IO_LOW)
808 #define READ_IO_IO_HIGH(dev) (unsigned long)(signed int)gsc_readl(dev->hpa.start + IO_IO_HIGH)
820 if (dev->id.hw_type == HPHW_IOA) { in walk_lower_bus()
828 walk_native_bus(io_io_low, io_io_high, &dev->dev); in walk_lower_bus()
832 * walk_native_bus -- Probe a bus for devices
874 * walk_central_bus - Find devices attached to the central bus
891 ++count, dev->name, &(dev->hpa.start), dev->id.hw_type, in print_parisc_device()
892 dev->id.hversion, dev->id.sversion, dev->id.hversion_rev); in print_parisc_device()
894 if (dev->num_addrs) { in print_parisc_device()
897 for (k = 0; k < dev->num_addrs; k++) in print_parisc_device()
898 pr_cont("0x%lx ", dev->addr[k]); in print_parisc_device()
904 * init_parisc_bus - Some preparation to be done before inventory
909 panic("Could not register PA-RISC bus type\n"); in init_parisc_bus()
911 panic("Could not register PA-RISC root device\n"); in init_parisc_bus()
917 int num; in qemu_header() local
920 pr_info("--- cut here ---\n"); in qemu_header()
921 pr_info("/* AUTO-GENERATED HEADER FILE FOR SEABIOS FIRMWARE */\n"); in qemu_header()
945 (unsigned long)(PAGE0->mem_pdc_hi) << 32 | in qemu_header()
947 (unsigned long)PAGE0->mem_pdc); in qemu_header()
951 for (num = 0; num < sizeof(cache_info); num += sizeof(unsigned long)) { in qemu_header()
952 if (((num % 5) == 0)) { in qemu_header()
957 num?", ":"", *p++); in qemu_header()
965 unsigned long hpa = dev->hpa.start; in qemu_print_hpa()
982 pr_info("--- cut here ---\n"); in qemu_footer()
990 unsigned long hpa = dev->hpa.start; in qemu_print_iodc_data()
1011 hpa, parisc_hardware_description(&dev->id)); in qemu_print_iodc_data()
1068 pr_info("#define HPA_%08lx_num_addr %d\n", hpa, dev->num_addrs); in qemu_print_iodc_data()
1071 if (dev->num_addrs == 0) in qemu_print_iodc_data()
1073 while (count < dev->num_addrs) { in qemu_print_iodc_data()
1074 pr_cont("0x%08lx, ", dev->addr[count]); in qemu_print_iodc_data()
1094 * print_parisc_devices - Print out a list of devices found in this system