2 * IBM PowerPC Virtual I/O Infrastructure Support.
4 * Dave Engebretsen engebret@us.ibm.com
5 * Copyright (c) 2003 Dave Engebretsen
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <asm/hvcall.h>
20 #include <asm/scatterlist.h>
22 * Architecture-specific constants for drivers to
23 * extract attributes of the device using vio_get_attribute()
25 #define VETH_MAC_ADDR "local-mac-address"
26 #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
28 /* End architecture-specific constants */
30 #define h_vio_signal(ua, mode) \
31 plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
33 #define VIO_IRQ_DISABLE 0UL
34 #define VIO_IRQ_ENABLE 1UL
41 int vio_register_driver(struct vio_driver *drv);
42 int vio_unregister_driver(struct vio_driver *drv);
43 const struct vio_device_id * vio_match_device(const struct vio_device_id *ids,
44 const struct vio_dev *dev);
45 struct vio_dev * __devinit vio_register_device(struct device_node *node_vdev);
46 struct vio_driver * __devinit vio_find_driver(struct vio_dev* dev);
47 const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length);
48 int vio_get_irq(struct vio_dev *dev);
49 struct TceTable * vio_build_tce_table(struct vio_dev *dev);
50 int vio_enable_interrupts(struct vio_dev *dev);
51 int vio_disable_interrupts(struct vio_dev *dev);
53 dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
54 size_t size, int direction);
55 void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle,
56 size_t size, int direction);
57 int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist,
58 int nelems, int direction);
59 void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist,
60 int nelems, int direction);
61 void *vio_alloc_consistent(struct vio_dev *dev, size_t size,
62 dma_addr_t *dma_handle);
63 void vio_free_consistent(struct vio_dev *dev, size_t size, void *vaddr,
64 dma_addr_t dma_handle);
66 struct vio_device_id {
69 /* I don't think we need this
70 unsigned long driver_data; */ /* Data private to the driver */
74 struct list_head node;
76 const struct vio_device_id *id_table; /* NULL if wants all devices */
77 int (*probe) (struct vio_dev *dev, const struct vio_device_id *id); /* New device inserted */
78 void (*remove) (struct vio_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
79 unsigned long driver_data;
84 * The vio_dev structure is used to describe virtual I/O devices.
87 struct list_head devices_list; /* node in list of all vio devices */
88 struct device_node *archdata; /* Open Firmware node */
89 struct vio_bus *bus; /* bus this device is on */
90 struct vio_driver *driver; /* owning driver */
91 void *driver_data; /* data private to the driver */
92 unsigned long unit_address;
94 struct TceTable *tce_table; /* vio_map_* uses this */
96 struct proc_dir_entry *procent; /* device entry in /proc/bus/vio */
100 struct list_head devices; /* list of virtual devices */
104 static inline int vio_module_init(struct vio_driver *drv)
106 int rc = vio_register_driver (drv);
111 /* iff CONFIG_HOTPLUG and built into kernel, we should
112 * leave the driver around for future hotplug events.
113 * For the module case, a hotplug daemon of some sort
114 * should load a module in response to an insert event. */
115 #if defined(CONFIG_HOTPLUG) && !defined(MODULE)
123 /* if we get here, we need to clean up vio driver instance
124 * and return some sort of error */