1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * IBM PowerPC Virtual I/O Infrastructure Support.
5 * Copyright (c) 2003 IBM Corp.
6 * Dave Engebretsen engebret@us.ibm.com
7 * Santiago Leon santil@us.ibm.com
10 #ifndef _ASM_POWERPC_VIO_H
11 #define _ASM_POWERPC_VIO_H
14 #include <linux/errno.h>
15 #include <linux/device.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/mod_devicetable.h>
18 #include <linux/scatterlist.h>
20 #include <asm/hvcall.h>
23 * Architecture-specific constants for drivers to
24 * extract attributes of the device using vio_get_attribute()
26 #define VETH_MAC_ADDR "local-mac-address"
27 #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
29 /* End architecture-specific constants */
31 #define h_vio_signal(ua, mode) \
32 plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
34 #define VIO_IRQ_DISABLE 0UL
35 #define VIO_IRQ_ENABLE 1UL
38 * VIO CMO minimum entitlement for all devices and spare entitlement
40 #define VIO_CMO_MIN_ENT 1562624
42 extern const struct bus_type vio_bus_type
;
47 * Platform Facilities Option (PFO)-specific data
50 /* Starting unit address for PFO devices on the VIO BUS */
51 #define VIO_BASE_PFO_UA 0x50000000
54 * vio_pfo_op - PFO operation parameters
56 * @flags: h_call subfunctions and modifiers
57 * @in: Input data block logical real address
58 * @inlen: If non-negative, the length of the input data block. If negative,
59 * the length of the input data descriptor list in bytes.
60 * @out: Output data block logical real address
61 * @outlen: If non-negative, the length of the input data block. If negative,
62 * the length of the input data descriptor list in bytes.
63 * @csbcpb: Logical real address of the 4k naturally-aligned storage block
64 * containing the CSB & optional FC field specific CPB
65 * @timeout: # of milliseconds to retry h_call, 0 for no timeout.
66 * @hcall_err: pointer to return the h_call return value, else NULL
81 /* End PFO specific data */
84 VDEVICE
, /* The OF node is a child of /vdevice */
85 PFO
, /* The OF node is a child of /ibm,platform-facilities */
89 * vio_dev - This structure is used to describe virtual I/O devices.
91 * @desired: set from return of driver's get_desired_dma() function
92 * @entitled: bytes of IO data that has been reserved for this device.
93 * @allocated: bytes of IO data currently in use by the device.
94 * @allocs_failed: number of DMA failures due to insufficient entitlement.
99 uint32_t unit_address
;
100 uint32_t resource_id
;
106 atomic_t allocs_failed
;
108 enum vio_dev_family family
;
114 const struct vio_device_id
*id_table
;
115 int (*probe
)(struct vio_dev
*dev
, const struct vio_device_id
*id
);
116 void (*remove
)(struct vio_dev
*dev
);
117 void (*shutdown
)(struct vio_dev
*dev
);
118 /* A driver must have a get_desired_dma() function to
119 * be loaded in a CMO environment if it uses DMA.
121 unsigned long (*get_desired_dma
)(struct vio_dev
*dev
);
122 const struct dev_pm_ops
*pm
;
123 struct device_driver driver
;
126 extern int __vio_register_driver(struct vio_driver
*drv
, struct module
*owner
,
127 const char *mod_name
);
129 * vio_register_driver must be a macro so that KBUILD_MODNAME can be expanded
131 #define vio_register_driver(driver) \
132 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
133 extern void vio_unregister_driver(struct vio_driver
*drv
);
135 extern int vio_cmo_entitlement_update(size_t);
136 extern void vio_cmo_set_dev_desired(struct vio_dev
*viodev
, size_t desired
);
138 extern void vio_unregister_device(struct vio_dev
*dev
);
140 extern int vio_h_cop_sync(struct vio_dev
*vdev
, struct vio_pfo_op
*op
);
144 extern struct vio_dev
*vio_register_device_node(
145 struct device_node
*node_vdev
);
146 extern const void *vio_get_attribute(struct vio_dev
*vdev
, char *which
,
148 #ifdef CONFIG_PPC_PSERIES
149 extern struct vio_dev
*vio_find_node(struct device_node
*vnode
);
150 extern int vio_enable_interrupts(struct vio_dev
*dev
);
151 extern int vio_disable_interrupts(struct vio_dev
*dev
);
153 static inline int vio_enable_interrupts(struct vio_dev
*dev
)
159 #define to_vio_driver(__drv) container_of_const(__drv, struct vio_driver, driver)
160 #define to_vio_dev(__dev) container_of_const(__dev, struct vio_dev, dev)
162 #endif /* __KERNEL__ */
163 #endif /* _ASM_POWERPC_VIO_H */