0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _ASM_POWERPC_VIO_H
0011 #define _ASM_POWERPC_VIO_H
0012 #ifdef __KERNEL__
0013
0014 #include <linux/errno.h>
0015 #include <linux/device.h>
0016 #include <linux/dma-mapping.h>
0017 #include <linux/mod_devicetable.h>
0018 #include <linux/scatterlist.h>
0019
0020 #include <asm/hvcall.h>
0021
0022
0023
0024
0025
0026 #define VETH_MAC_ADDR "local-mac-address"
0027 #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
0028
0029
0030
0031 #define h_vio_signal(ua, mode) \
0032 plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
0033
0034 #define VIO_IRQ_DISABLE 0UL
0035 #define VIO_IRQ_ENABLE 1UL
0036
0037
0038
0039
0040 #define VIO_CMO_MIN_ENT 1562624
0041
0042 extern struct bus_type vio_bus_type;
0043
0044 struct iommu_table;
0045
0046
0047
0048
0049
0050
0051 #define VIO_BASE_PFO_UA 0x50000000
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 struct vio_pfo_op {
0069 u64 flags;
0070 s64 in;
0071 s64 inlen;
0072 s64 out;
0073 s64 outlen;
0074 u64 csbcpb;
0075 void *done;
0076 unsigned long handle;
0077 unsigned int timeout;
0078 long hcall_err;
0079 };
0080
0081
0082
0083 enum vio_dev_family {
0084 VDEVICE,
0085 PFO,
0086 };
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 struct vio_dev {
0097 const char *name;
0098 const char *type;
0099 uint32_t unit_address;
0100 uint32_t resource_id;
0101 unsigned int irq;
0102 struct {
0103 size_t desired;
0104 size_t entitled;
0105 size_t allocated;
0106 atomic_t allocs_failed;
0107 } cmo;
0108 enum vio_dev_family family;
0109 struct device dev;
0110 };
0111
0112 struct vio_driver {
0113 const char *name;
0114 const struct vio_device_id *id_table;
0115 int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
0116 void (*remove)(struct vio_dev *dev);
0117 void (*shutdown)(struct vio_dev *dev);
0118
0119
0120
0121 unsigned long (*get_desired_dma)(struct vio_dev *dev);
0122 const struct dev_pm_ops *pm;
0123 struct device_driver driver;
0124 };
0125
0126 extern int __vio_register_driver(struct vio_driver *drv, struct module *owner,
0127 const char *mod_name);
0128
0129
0130
0131 #define vio_register_driver(driver) \
0132 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
0133 extern void vio_unregister_driver(struct vio_driver *drv);
0134
0135 extern int vio_cmo_entitlement_update(size_t);
0136 extern void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired);
0137
0138 extern void vio_unregister_device(struct vio_dev *dev);
0139
0140 extern int vio_h_cop_sync(struct vio_dev *vdev, struct vio_pfo_op *op);
0141
0142 struct device_node;
0143
0144 extern struct vio_dev *vio_register_device_node(
0145 struct device_node *node_vdev);
0146 extern const void *vio_get_attribute(struct vio_dev *vdev, char *which,
0147 int *length);
0148 #ifdef CONFIG_PPC_PSERIES
0149 extern struct vio_dev *vio_find_node(struct device_node *vnode);
0150 extern int vio_enable_interrupts(struct vio_dev *dev);
0151 extern int vio_disable_interrupts(struct vio_dev *dev);
0152 #else
0153 static inline int vio_enable_interrupts(struct vio_dev *dev)
0154 {
0155 return 0;
0156 }
0157 #endif
0158
0159 static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
0160 {
0161 return container_of(drv, struct vio_driver, driver);
0162 }
0163
0164 static inline struct vio_dev *to_vio_dev(struct device *dev)
0165 {
0166 return container_of(dev, struct vio_dev, dev);
0167 }
0168
0169 #endif
0170 #endif