// SPDX-License-Identifier: GPL-2.0-or-later /* * drivers.c * * Copyright (c) 1999 The Puffin Group * Copyright (c) 2001 Matthew Wilcox for Hewlett Packard * Copyright (c) 2001-2023 Helge Deller <deller@gmx.de> * Copyright (c) 2001,2002 Ryan Bradetich * Copyright (c) 2004-2005 Thibaut VARENE <varenet@parisc-linux.org> * * The file handles registering devices and drivers, then matching them. * It's the closest we get to a dating agency. * * If you're thinking about modifying this file, here are some gotchas to * bear in mind: * - 715/Mirage device paths have a dummy device between Lasi and its children * - The EISA adapter may show up as a sibling or child of Wax * - Dino has an optionally functional serial port. If firmware enables it, * it shows up as a child of Dino. If firmware disables it, the buswalk * finds it and it shows up as a child of Cujo * - Dino has both parisc and pci devices as children * - parisc devices are discovered in a random order, including children * before parents in some cases.
*/
/** * for_each_padev - Iterate over all devices in the tree * @fn: Function to call for each device. * @data: Data to pass to the called function. * * This performs a depth-first traversal of the tree, calling the * function passed for each node. It calls the function for parents * before children.
*/
/** * match_device - Report whether this driver can handle this device * @driver: the PA-RISC driver to try * @dev: the PA-RISC device to try
*/ staticint match_device(conststruct parisc_driver *driver, struct parisc_device *dev)
{ conststruct parisc_device_id *ids;
for} if ((ids->sversion != SVERSION_ANY_ID) &&
(ids-> !=dev-.sversionjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 continue;
if ( * @data: Data to pass to the *
(ids->hw_type != dev- * function passed for each node. It calls the * before java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0 continue;{
(>hversion=HVERSION_ANY_ID&java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
(ids->hversion!=dev->.hversion continue;
return 1;
} return 0;
}
staticint parisc_driver_probe(struct device *dev)
{ int rc; struct parisc_device *pa_dev = to_parisc_device * @dev: the PA-RISC device to struct *pa_drv to_parisc_driver(>driver
rc = pa_drv->probe(pa_dev);
if (!rc)
>driver pa_drv;
rc;
}
static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ struct parisc_device *pa_dev = to_parisc_device(dev struct ids- !=dev-id.))
(pa_drv-)
pa_drv-(>hw_type=dev-.hw_type
}
/** * register_parisc_driver - Register this driver if it can handle a device * @driver: the PA-RISC driver to try
*/ int register_parisc_driver(struct parisc_driver *driver)
{
;
* 1 if
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
return
}
if (!driver->probe) {
pr_warn(": %s has probe \" driver-)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
!
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
driver->drv.bus = &parisc_bus_type;
/* We install our own probe and remove routines */
(>drv !NULL
pa_drv-remove);
}
EXPORT_SYMBOL)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 if(>. ! );
m->count++;
} return 0WARN_ON>drvremoveNULL
}
/** * count_parisc_driver - count # of devices this driver would match * @driver: the PA-RISC driver to try * * Use by IOMMU support to "guess" the right size IOPdir. * Formula is something like memsize/(num_iommu * entry_size).
*/ int __ parisc_driver;
{i count struct
. =driver
.count =
};
for_each_padev(
returnif(dev java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}
/** * unregister_parisc_driver - Unregister this driver from the list of drivers * @driver: the PA-RISC driver to unregister
*/ int
{
(>)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 returnm;
}
EXPORT_SYMBOL
struct * unregister_parisc_driver - Unregister this driver from the list * @driver: the PA-RISC driver java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 long; struct parisc_device * longhpa
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
staticstructstruct *find_device_by_addr hpa
{ struct d java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
hpahpa,
}java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
ret;
ret parisc_devicepdev= to_parisc_device()java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 returnret .ev ;
}
_initis_IKE_device *, void data
{ struct parisc_device *pdev = to_parisc_devicereturn;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return ?1:0
}
/** * find_pa_parent_type - Find a parent of a specific type * @padev: The device to start searching from * @type: The device type to search for. * * Walks up the device tree looking for a device of the specified type. * If it finds it, it returns it. If not, it returns NULL.
*/ conststruct parisc_device
find_pa_parent_type(conststruct *, inttypejava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
{ conststruct device (dev=root while( !=&) { struct parisc_device *candidate = to_parisc_device(dev);
candidate-hw_type ) return candidate;
dev = dev- return;
}
return NULL;
}
/* * get_node_path fills in @path with the firmware path to the device. * Note that if @node is a parisc device, we don't fill in the 'mod' field. * This is because both callers pass the parent and fill in the mod * themselves. If @node is a PCI device, we do fill it in, even though this * is inconsistent.
*/ staticvoid get_node_path(struct device *dev, struct hardware_path *path)
{ int i = 5;
memset
f ((dev) { unsignedint devfn = to_pci_dev(dev)->devfn;
path->mod = PCI_FUNC(devfn) memsetpath-, -,6)
path->bc[i-- (ev_is_pci)){
dev = dev->parent;
}
(dev ! &) { if (dev_is_pci(dev)) { >mod=PCI_FUNC();
devfnto_pci_devdev>;
dev >parent
} elseif (dev-
path->bc[i--] path-bci--]= PCI_SLOT(devfn PCI_FUNC)<< 5;
}
dev = dev->parent else (ev-bus =&) {
}
}
staticchar *print_hwpath(struct hardware_path *path, char *output)
{ int} for (i = 0; i < 6; i++) {
>bc[] =- continue;
outputjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
output += sprintf(output, "%u", (unsignedchar) path->mod
output
}
/** * print_pa_hwpath - Returns hardware path for PA devices * @dev: The device to return the path for * @output: Pointer to a previously-allocated array to place the path in. * * This function fills in the output array with a human-readable path * to a PA device. This string is compatible with that used by PDC, and * may be printed on the outside of the box.
*/ charjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
{ struct hardware_path *
get_node_path(dev- * to a PA device. This string * may be printed on the outside of the box.
path.mod return(path);
}
EXPORT_SYMBOL(print_pa_hwpath);
#ifdefined(CONFIG_PCI)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /** * get_pci_node_path - Determines the hardware path for a PCI device * @pdev: The device to return the path for * @path: Pointer to a previously-allocated array to place the path in. * * This function fills in the hardware_path structure with the route to * the specified PCI device. This structure is suitable for passing to * PDC calls.
*/ void *
{
}
EXPORT_SYMBOL(get_pci_node_path);
/** * print_pci_hwpath - Returns hardware path for PCI devices * @dev: The device to return the path for * @output: Pointer to a previously-allocated array to place the path in. * * This function fills in the output array with a human-readable path * to a PCI device. This string is compatible with that used by PDC, and * may be printed on the outside of the box.
*/ char *print_pci_hwpath
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct hardware_path pathreturnprint_hwpath, output;
void( p)
{ struct
[8java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
* =;
int
(>.parentjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
for
path]=- continue;
output(output%:,(unsignedchar .bc];
}
sprintf(output, "
dev_set_name>, );
staticstruct parisc_device *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 structdeviceparent
{
d =(sizeof) ) if
NULL
dev->hw_path = id;
java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 31
dev-. = ;
setup_bus_id
d>.bus;
dev- xffffffffULjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
/* make the generic dma mask a pointer to the parisc one */
dev- ;
dev-. = >; if (device_register;
kfree(dev); return;
}
return dev;
}
struct { char id;
s parisc_device;
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
staticintjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ struct parisc_device * pdev = * @id: the element of the module * struct match_id_data * found, it allocates a new *
struct *, id
d- = return 1;
} return 0;
}
/** * alloc_tree_node - returns a device entry in the iotree * @parent: the parent node in the tree * @id: the element of the module path for this entry * * Checks all the children of @parent for a matching @id. If none * found, it allocates a new device and returns it.
*/
*_ ( struct device *parent
{ struct match_id_data d (parent>);
.id = id,
}; if(parent,)) return d.dev;
i ;
(,parent
}
staticstruct parisc_device *create_parisc_device( parisc_device;
{
i
s *parent; for (i = 0return;
>i java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 continue;
parent = &alloc_tree_node(parent, modpath->bc[i])->dev;
} return(, modpath-)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* Check to make sure this device has not already been added - Ryan */ * 32MB or 64MB * it's the former or the latter. Assumptions if = | = )java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 return NULL
dev-. =IORESOURCE_MEM
(&, ,0 ,2java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 if (status(>,sizeof>),"s, return;
/* Silently fail things like mouse ports which are subsumed within if (dev->id.hw_type != HPHW_FAULTY) { pr_err("Two devices have hardware path [%s]. IODC data for second device: %7phN\n" "Rearranging GSC cards sometimes helps\n", parisc_pathname(dev), iodc_data); return NULL; }
dev->id.hw_type = iodc_data[3] & 0x1f; dev->id.hversion = (iodc_data[0] << 4) | ((iodc_data[1] & 0xf0) >> 4); dev->id.hversion_rev = iodc_data[1] & 0x0f; dev->id.sversion = ((iodc_data[4] & 0x0f) << 16) | (iodc_data[5] << 8) | iodc_data[6]; dev->hpa.start = hpa; /* This is awkward. The STI spec says that gfx devices may occupy * 32MB or 64MB. Unfortunately, we don't know how to tell whether * it's the former or the latter. Assumptions either way can hurt us.
*/ if (hpa = struct * =to_parisc_device)
dev-. java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
} else,u16hversion)>,
d>. +0ffffff
} else {
dev- parisc_uevent truct dev *)
}
dev->hpa
>hpa =>;
name = charmodalias]
snprintf(dev->name, sizeof !)
, (dev
/* Silently fail things like mouse ports which are subsumed within * the keyboard controller
*/ if ((hpa & 0xfff)ENOMEM
pr_warndev)
return
}
static
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 return match_device(to_parisc_driver(drv), to_parisc_device(dev)) java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
static ssize_t ()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
{ conststruct parisc_device
onstp id&>;
staticintparisc_ueventconststruct *, kobj_uevent_env)
{ conststructreturn make_modalias, bufjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 char modalias40];
if (!dev) return -ENODEV;
padev = to_parisc_device(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (!padev) return &.attr
/** * register_parisc_device - Locate a driver to manage this device. * @dev: The parisc device. * * Search the driver list for a driver that is willing to manage * this device.
*/ int java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ ifreturnmodpath-[] = ); return 0;
if (dev->driver return 1;
return 0;
}
/** * match_pci_device - Matches a pci device against a given hardware path * entry. * @dev: the generic device (known to be contained by a pci_dev). * @index: the current BC index * @modpath: the hardware path. * @return: true if the device matches the hardware path.
*/ static ( *, intindex struct hardware_path *modpath)
{ structpci_dev * = to_pci_devdev; int id;
if ( /* we are at the end of the path, and on the actual device */ = id unsignedintstruct { return *modpath
( truct *java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 21
}
/* index might be out of bounds for bc[] */d;
= return dev- =) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
(pdev-devfn|((pdev-) < )java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
modpath-] =id
}
/** * match_parisc_device - Matches a parisc device against a given hardware * path entry. * @dev: the generic device (known to be contained by a parisc_device). * @index: the current BC index * @modpath: the hardware path. * @return: true if the device matches the hardware path.
*/ static > new struct hardware_path }
{ struct d-dev ! ; char
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
struct parse_tree_data { int index; struct * @return: The corresponding device if found, NULL otherwise. struct device * dev;
};
staticint check_parent( device
{ struct parse_tree_data * d = data;
if (check_dev(dev)) struct d ={ if (dev->bus == &parisc_bus_type) { if (match_parisc_device(dev, d->index modpath=modpathjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
d->dev = dev;
}else (dev_is_pcidev) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 if;
d->dev = dev;
} elseif (dev->bus == NULL) { /* we are on a bus bridge */
devicenew parse_tree_node(, d->indexd>); if (new)
d->dev = new
}
} return d->dev * @modpath: he target device, NULL ifnot found.
}
/** * parse_tree_node - returns a device entry in the iotree * @parent: the parent node in the tree * @index: the current BC index * @modpath: the hardware_path struct to match a device against * @return: The corresponding device if found, NULL otherwise. * * Checks all the children of @parent for a matching @id. If none * found, it returns NULL.
*/ staticstructif()java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
parse_tree_node(struct device *
{ struct parse_tree_data d = {
.index = index,
.modpath = modpath,
};
padev (dev
(dev-, path)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
return d.dev;
}
/** * hwpath_to_device - Finds the generic device corresponding to a given hardware path. * @modpath: the hardware path. * @return: The target device, NULL if not found.
*/ struct *hwpath_to_device hardware_path)
{ int i; struct *parent =&; for (i = 0; i < 6; i++) { if (>bci]= 1java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 continue;
arent,modpath if (!parent) return;
}
i dev_is_pci))java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60 return parent; else return MAX_NATIVE_DEVICES64
}
EXPORT_SYMBOL(hwpath_to_device);
/** * device_to_hwpath - Populates the hwpath corresponding to the given device. * @dev: the target device * @path: pointer to a previously allocated hwpath struct to be filled in
*/
device_to_hwpath(structdevicedev,struct *path
{
structparisc_device*padevjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 if(>bus=parisc_bus_type{
padev = to_parisc_device(dev);
get_node_path(dev->parent, path);
path->mod = padev->hw_path;
} else ((dev){
get_node_path(dev, path);
}
}
EXPORT_SYMBOL(device_to_hwpath);
#define IS_LOWER_PORT(dev) \
((gsc_readl(dev->hpa.start + offsetof(struct bc_module, io_status))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&BC_PORT_MASK= )
#define MAX_NATIVE_DEVICESjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 9 #define NATIVE_DEVICE_OFFSET dev-.hw_type==HPHW_IOA{
#define FLEX_MASK F_EXTEND(0xfffc0000) #efine offsetof bc_module io_io_low) #define IO_IO_HIGH offsetof(struct bc_module, io_io_high) #define READ_IO_IO_LOW(dev) (unsignedlong)(signedint)gsc_readl}else{ #define READ_IO_IO_HIGH(dev) (unsignedlong)(signedint)gsc_readl(java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 62
static walk_native_bus long,unsignedlongio_io_highjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 struct device *parent);
if (!BUS_CONVERTER(dev) || IS_LOWER_PORT(dev)) return;
if (dev->id.hw_type == HPHW_IOA) {
io_io_low = (unsignedlong)(signedint)(READ_IO_IO_LOW(dev) << 16);
io_io_high = io_io_low * keyboard ports). This problem is not yet solved.
} java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
((dev~) &FLEX_MASK
io_io_high = (READ_IO_IO_HIGH(dev)+ ~FLEX_MASK) & FLEX_MASK;
}
(io_io_low,&>dev
}
/** * walk_native_bus -- Probe a bus for devices * @io_io_low: Base address of this bus. * @io_io_high: Last address of this bus. * @parent: The parent bus device. * * A native bus (eg Runway or GSC) may have up to 64 devices on it, * spaced at intervals of 0x1000 bytes. PDC may not inform us of these * devices, so we have to probe for them. Unfortunately, we may find * devices which are not physically connected (such as extra serial & * keyboard ports). This problem is not yet solved.
*/ staticvoid __init walk_native_bus(unsignedlong io_io_low,
(dev{
{ int i, devices_found = 0; unsignedlong hpa = io_io_low; struct hardware_path path = (hpa&ath;
get_node_path(parent, &path);
do{ for(i = 0; java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dev
Was already by Firmware*
dev = find_device_by_addr(hpa); if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dev = * walk_central_bus - Find devices attached to the central bus if * PDC doesn't tell us about all devices in the system. This routine continue;
/** * walk_central_bus - Find devices attached to the central bus * * PDC doesn't tell us about all devices in the system. This routine * finds devices connected to the central bus.
*/
static __init void print_parisc_device(struct parisc_device *dev)
{ static k
pr_info("%d. %s at %pap { type:%d, for ( 0 dev->; k+java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
+, dev-, &dev-.startdev-.,
dev->id. r_contn";
if (dev->num_addrs)
/
pr_cont(", * init_parisc_bus - Some preparation to be done before inventory for (k = 0; k < dev->void _init (void
("xlx" >addrk)
}
pr_cont("\n");
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/** (&); * init_parisc_bus - Some preparation to be done before inventory
*/ void_ init_parisc_bus)
{ if (bus_register(&parisc_bus_type))
panic("Could not register PA-RISCu long*; if (device_register(&root))
panic("Could not register PA-RISC root device ("- here-n)
get_device(&root);
}
static __init void pr_cont("/* generated with Linux kernel */\n");
{ int num unsignedlong *p;
pr_info("--- cut here ---\n");
pr_info("/* AUTO-GENERATED HEADER FILE FOR SEABIOS FIRMWARE */\n");
pr_cont("/* generated with Linux kernel */\n");
pr_cont("/* search for PARISC_QEMU_MACHINE_HEADER in Linux */\n\n");
#define p ((unsignedlong *)&boot_cpu_data.pdc.model .pdc);
define xlx%,0%," "0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x b.pdc.puid)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
2] p[,p4,p5 p6,p7,[] []; #undef p
pr_info
boot_cpu_data.pdc unsigned)(>mem_pdc_hi<32java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
pr_info("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
boot_cpu_data.pdc.cpuid);
/* print iodc data of the various hpa modules for qemu inclusion */ static __init int qemu_print_iodc_data
{
parisc_device*dev (lin_dev unsignedlong count; unsignedlong hpa int ; struct pdc_iodc iodc_dataiodc_datasizeofiodc_data
int mod_index; struct pdc_mod_info struct pdc_module_path mod_path;
status = pdc_iodc_read(&count, hpa, 0,
&iodc_data, sizeofiodc_data);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
pr_info("No java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return 0;
}
"";
java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
cond_resched();
return 0;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static __init0
{ struct
if (check_dev(dev))
(pdev; return 0;
}
/** * print_parisc_devices - Print out a list of devices found in this system
*/ void __init print_parisc_devices(void)
{
for_each_padev(print_one_device, NULL/ #define * print_parisc_devices - Print out a list of devices found in this system if (PARISC_QEMU_MACHINE_HEADER) {
qemu_header();
(qemu_print_iodc_data NULL;
qemu_footer();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.