Lines Matching +full:hp +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2003-2005 IBM Corp.
29 type = dev->type; in vio_match_device()
30 compat = dev->compat; in vio_match_device()
31 len = dev->compat_len; in vio_match_device()
33 while (matches->type[0] || matches->compat[0]) { in vio_match_device()
35 if (matches->type[0]) in vio_match_device()
36 match &= !strcmp(matches->type, type); in vio_match_device()
38 if (matches->compat[0]) { in vio_match_device()
40 of_find_in_proplist(compat, matches->compat, len); in vio_match_device()
53 add_uevent_var(env, "MODALIAS=vio:T%sS%s", vio_dev->type, vio_dev->compat); in vio_hotplug()
61 const struct vio_device_id *matches = vio_drv->id_table; in vio_bus_match()
72 struct vio_driver *drv = to_vio_driver(dev->driver); in vio_device_probe()
75 if (!drv->probe) in vio_device_probe()
76 return -ENODEV; in vio_device_probe()
78 id = vio_match_device(drv->id_table, vdev); in vio_device_probe()
80 return -ENODEV; in vio_device_probe()
83 if (!drv->no_irq) { in vio_device_probe()
84 if (vdev->tx_irq == 0 && vdev->tx_ino != ~0UL) in vio_device_probe()
85 vdev->tx_irq = sun4v_build_virq(vdev->cdev_handle, in vio_device_probe()
86 vdev->tx_ino); in vio_device_probe()
88 if (vdev->rx_irq == 0 && vdev->rx_ino != ~0UL) in vio_device_probe()
89 vdev->rx_irq = sun4v_build_virq(vdev->cdev_handle, in vio_device_probe()
90 vdev->rx_ino); in vio_device_probe()
93 return drv->probe(vdev, id); in vio_device_probe()
99 struct vio_driver *drv = to_vio_driver(dev->driver); in vio_device_remove()
101 if (drv->remove) { in vio_device_remove()
104 * here - however, there are currently no support in vio_device_remove()
108 drv->remove(vdev); in vio_device_remove()
118 if (!strcmp(vdev->type, "vnet-port")) in devspec_show()
120 else if (!strcmp(vdev->type, "vdc-port")) in devspec_show()
131 return sprintf(buf, "%s\n", vdev->type); in type_show()
140 return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat); in modalias_show()
164 viodrv->driver.bus = &vio_bus_type; in __vio_register_driver()
165 viodrv->driver.name = viodrv->name; in __vio_register_driver()
166 viodrv->driver.owner = owner; in __vio_register_driver()
167 viodrv->driver.mod_name = mod_name; in __vio_register_driver()
169 return driver_register(&viodrv->driver); in __vio_register_driver()
175 driver_unregister(&viodrv->driver); in vio_unregister_driver()
192 dp = vdev->dp; in show_pciobppath_attr()
205 static const u64 *vio_cfg_handle(struct mdesc_handle *hp, u64 node) in vio_cfg_handle() argument
210 mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) { in vio_cfg_handle()
213 target = mdesc_arc_target(hp, a); in vio_cfg_handle()
214 cfg_handle = mdesc_get_property(hp, target, in vio_cfg_handle()
215 "cfg-handle", NULL); in vio_cfg_handle()
224 * vio_vdev_node() - Find VDEV node in MD
225 * @hp: Handle to the MD
236 u64 vio_vdev_node(struct mdesc_handle *hp, struct vio_dev *vdev) in vio_vdev_node() argument
243 node = mdesc_get_node(hp, (const char *)vdev->node_name, in vio_vdev_node()
244 &vdev->md_node_info); in vio_vdev_node()
250 static void vio_fill_channel_info(struct mdesc_handle *hp, u64 mp, in vio_fill_channel_info() argument
255 vdev->tx_ino = ~0UL; in vio_fill_channel_info()
256 vdev->rx_ino = ~0UL; in vio_fill_channel_info()
257 vdev->channel_id = ~0UL; in vio_fill_channel_info()
258 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) { in vio_fill_channel_info()
263 target = mdesc_arc_target(hp, a); in vio_fill_channel_info()
265 irq = mdesc_get_property(hp, target, "tx-ino", NULL); in vio_fill_channel_info()
267 vdev->tx_ino = *irq; in vio_fill_channel_info()
269 irq = mdesc_get_property(hp, target, "rx-ino", NULL); in vio_fill_channel_info()
271 vdev->rx_ino = *irq; in vio_fill_channel_info()
273 chan_id = mdesc_get_property(hp, target, "id", NULL); in vio_fill_channel_info()
275 vdev->channel_id = *chan_id; in vio_fill_channel_info()
278 vdev->cdev_handle = cdev_cfg_handle; in vio_fill_channel_info()
290 static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, in vio_create_one() argument
300 type = mdesc_get_property(hp, mp, "device-type", &tlen); in vio_create_one()
302 type = mdesc_get_property(hp, mp, "name", &tlen); in vio_create_one()
304 type = mdesc_node_name(hp, mp); in vio_create_one()
314 id = mdesc_get_property(hp, mp, "id", NULL); in vio_create_one()
316 cfg_handle = vio_cfg_handle(hp, mp); in vio_create_one()
318 compat = mdesc_get_property(hp, mp, "device-type", &clen); in vio_create_one()
333 vdev->mp = mp; in vio_create_one()
334 memcpy(vdev->type, type, tlen); in vio_create_one()
336 memcpy(vdev->compat, compat, clen); in vio_create_one()
338 memset(vdev->compat, 0, sizeof(vdev->compat)); in vio_create_one()
339 vdev->compat_len = clen; in vio_create_one()
341 vdev->port_id = ~0UL; in vio_create_one()
342 vdev->tx_irq = 0; in vio_create_one()
343 vdev->rx_irq = 0; in vio_create_one()
345 vio_fill_channel_info(hp, mp, vdev); in vio_create_one()
348 dev_set_name(&vdev->dev, "%s", type); in vio_create_one()
349 vdev->dev_no = ~(u64)0; in vio_create_one()
351 dev_set_name(&vdev->dev, "%s-%llu", type, *id); in vio_create_one()
352 vdev->dev_no = *id; in vio_create_one()
354 dev_set_name(&vdev->dev, "%s-%llu-%llu", type, in vio_create_one()
356 vdev->dev_no = *cfg_handle; in vio_create_one()
357 vdev->port_id = *id; in vio_create_one()
360 vdev->dev.parent = parent; in vio_create_one()
361 vdev->dev.bus = &vio_bus_type; in vio_create_one()
362 vdev->dev.release = vio_dev_release; in vio_create_one()
372 dp = to_vio_dev(parent)->dp; in vio_create_one()
374 vdev->dp = dp; in vio_create_one()
377 * node_name is NULL for the parent/channel-devices node and in vio_create_one()
381 (void) snprintf(vdev->node_name, VIO_MAX_NAME_LEN, "%s", in vio_create_one()
384 err = mdesc_get_node_info(hp, mp, node_name, in vio_create_one()
385 &vdev->md_node_info); in vio_create_one()
388 dev_name(&vdev->dev), err); in vio_create_one()
395 dev_name(&vdev->dev), vdev->tx_ino, vdev->rx_ino); in vio_create_one()
397 err = device_register(&vdev->dev); in vio_create_one()
400 dev_name(&vdev->dev), err); in vio_create_one()
401 put_device(&vdev->dev); in vio_create_one()
404 if (vdev->dp) in vio_create_one()
405 err = sysfs_create_file(&vdev->dev.kobj, in vio_create_one()
411 static void vio_add(struct mdesc_handle *hp, u64 node, in vio_add() argument
414 (void) vio_create_one(hp, node, node_name, &root_vdev->dev); in vio_add()
418 struct mdesc_handle *hp; member
430 node = vio_vdev_node(node_data->hp, vdev); in vio_md_node_match()
432 if (node == node_data->node) in vio_md_node_match()
438 static void vio_remove(struct mdesc_handle *hp, u64 node, const char *node_name) in vio_remove() argument
443 node_data.hp = hp; in vio_remove()
446 dev = device_find_child(&root_vdev->dev, (void *)&node_data, in vio_remove()
461 .node_name = "virtual-device-port",
465 * "domain-services" node. On control nodes there is another port
469 static void vio_add_ds(struct mdesc_handle *hp, u64 node, in vio_add_ds() argument
476 mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) { in vio_add_ds()
477 u64 target = mdesc_arc_target(hp, a); in vio_add_ds()
478 const char *name = mdesc_node_name(hp, target); in vio_add_ds()
480 if (!strcmp(name, "domain-services")) { in vio_add_ds()
487 (void) vio_create_one(hp, node, node_name, &root_vdev->dev); in vio_add_ds()
493 .node_name = "domain-services-port",
496 static const char *channel_devices_node = "channel-devices";
497 static const char *channel_devices_compat = "SUNW,sun4v-channel-devices";
498 static const char *cfg_handle_prop = "cfg-handle";
502 struct mdesc_handle *hp; in vio_init() local
515 hp = mdesc_grab(); in vio_init()
516 if (!hp) in vio_init()
519 root = mdesc_node_by_name(hp, MDESC_NODE_NULL, channel_devices_node); in vio_init()
521 printk(KERN_INFO "VIO: No channel-devices MDESC node.\n"); in vio_init()
522 mdesc_release(hp); in vio_init()
526 cdev_node = of_find_node_by_name(NULL, "channel-devices"); in vio_init()
527 err = -ENODEV; in vio_init()
529 printk(KERN_INFO "VIO: No channel-devices OBP node.\n"); in vio_init()
533 compat = mdesc_get_property(hp, root, "compatible", &len); in vio_init()
545 cfg_handle = mdesc_get_property(hp, root, cfg_handle_prop, NULL); in vio_init()
554 root_vdev = vio_create_one(hp, root, NULL, NULL); in vio_init()
555 err = -ENODEV; in vio_init()
564 mdesc_release(hp); in vio_init()
569 mdesc_release(hp); in vio_init()