blob: a82e87c1c5faf87dd781901f9c38016e37e47e1f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * IBM PowerPC Virtual I/O Infrastructure Support.
3 *
4 * Copyright (c) 2003 IBM Corp.
5 * Dave Engebretsen engebret@us.ibm.com
6 * Santiago Leon santil@us.ibm.com
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef _ASM_VIO_H
15#define _ASM_VIO_H
16
17#include <linux/config.h>
18#include <linux/init.h>
19#include <linux/errno.h>
20#include <linux/device.h>
21#include <linux/dma-mapping.h>
22#include <asm/hvcall.h>
23#include <asm/prom.h>
24#include <asm/scatterlist.h>
25/*
26 * Architecture-specific constants for drivers to
27 * extract attributes of the device using vio_get_attribute()
28*/
29#define VETH_MAC_ADDR "local-mac-address"
30#define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
31
32/* End architecture-specific constants */
33
34#define h_vio_signal(ua, mode) \
35 plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
36
37#define VIO_IRQ_DISABLE 0UL
38#define VIO_IRQ_ENABLE 1UL
39
40struct vio_dev;
41struct vio_driver;
42struct vio_device_id;
43struct iommu_table;
44
45int vio_register_driver(struct vio_driver *drv);
46void vio_unregister_driver(struct vio_driver *drv);
47
48#ifdef CONFIG_PPC_PSERIES
49struct vio_dev * __devinit vio_register_device_node(
50 struct device_node *node_vdev);
51#endif
52void __devinit vio_unregister_device(struct vio_dev *dev);
53struct vio_dev *vio_find_node(struct device_node *vnode);
54
55const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length);
56int vio_get_irq(struct vio_dev *dev);
57int vio_enable_interrupts(struct vio_dev *dev);
58int vio_disable_interrupts(struct vio_dev *dev);
Stephen Rothwell3e494c82005-07-12 17:40:17 +100059extern struct vio_dev * __devinit vio_register_device_common(
60 struct vio_dev *viodev, char *name, char *type,
61 uint32_t unit_address, struct iommu_table *iommu_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63extern struct dma_mapping_ops vio_dma_ops;
64
65extern struct bus_type vio_bus_type;
66
67struct vio_device_id {
68 char *type;
69 char *compat;
70};
71
72struct vio_driver {
73 struct list_head node;
74 char *name;
75 const struct vio_device_id *id_table; /* NULL if wants all devices */
76 int (*probe) (struct vio_dev *dev, const struct vio_device_id *id); /* New device inserted */
77 int (*remove) (struct vio_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
78 unsigned long driver_data;
79
80 struct device_driver driver;
81};
82
83static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
84{
85 return container_of(drv, struct vio_driver, driver);
86}
87
88/*
89 * The vio_dev structure is used to describe virtual I/O devices.
90 */
91struct vio_dev {
92 struct iommu_table *iommu_table; /* vio_map_* uses this */
93 char *name;
94 char *type;
95 uint32_t unit_address;
96 unsigned int irq;
97
98 struct device dev;
99};
100
Stephen Rothwell3e494c82005-07-12 17:40:17 +1000101extern struct vio_dev vio_bus_device;
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103static inline struct vio_dev *to_vio_dev(struct device *dev)
104{
105 return container_of(dev, struct vio_dev, dev);
106}
107
Stephen Rothwell63122362005-07-12 17:45:27 +1000108extern int vio_bus_init(int (*is_match)(const struct vio_device_id *id,
Stephen Rothwell19dbd0f2005-07-12 17:50:26 +1000109 const struct vio_dev *dev),
110 void (*)(struct vio_dev *),
111 void (*)(struct device *));
Stephen Rothwell3e494c82005-07-12 17:40:17 +1000112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#endif /* _ASM_VIO_H */