xref: /freebsd/sys/dev/bhnd/bhnd_bus_if.m (revision ca942ab4b2b665e5375cc72afc4930d3b33b14f9)
1#-
2# Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
3# Copyright (c) 2017 The FreeBSD Foundation
4# All rights reserved.
5#
6# Portions of this software were developed by Landon Fuller
7# under sponsorship from the FreeBSD Foundation.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
30#include <sys/types.h>
31#include <sys/bus.h>
32#include <sys/rman.h>
33
34#include <dev/bhnd/bhnd_types.h>
35#include <dev/bhnd/bhnd_erom_types.h>
36
37INTERFACE bhnd_bus;
38
39#
40# bhnd(4) bus interface
41#
42
43HEADER {
44	/* forward declarations */
45	struct bhnd_board_info;
46	struct bhnd_core_info;
47	struct bhnd_chipid;
48	struct bhnd_dma_translation;
49	struct bhnd_devinfo;
50	struct bhnd_resource;
51}
52
53CODE {
54	#include <sys/systm.h>
55
56	#include <dev/bhnd/bhndvar.h>
57
58	static bhnd_erom_class_t *
59	bhnd_bus_null_get_erom_class(driver_t *driver)
60	{
61		return (NULL);
62	}
63
64	static struct bhnd_chipid *
65	bhnd_bus_null_get_chipid(device_t dev, device_t child)
66	{
67		panic("bhnd_bus_get_chipid unimplemented");
68	}
69
70	static int
71	bhnd_bus_null_read_ioctl(device_t dev, device_t child, uint16_t *ioctl)
72	{
73		panic("bhnd_bus_read_ioctl unimplemented");
74	}
75
76
77	static int
78	bhnd_bus_null_write_ioctl(device_t dev, device_t child, uint16_t value,
79	    uint16_t mask)
80	{
81		panic("bhnd_bus_write_ioctl unimplemented");
82	}
83
84
85	static int
86	bhnd_bus_null_read_iost(device_t dev, device_t child, uint16_t *iost)
87	{
88		panic("bhnd_bus_read_iost unimplemented");
89	}
90
91	static bool
92	bhnd_bus_null_is_hw_suspended(device_t dev, device_t child)
93	{
94		panic("bhnd_bus_is_hw_suspended unimplemented");
95	}
96
97	static int
98	bhnd_bus_null_reset_hw(device_t dev, device_t child, uint16_t ioctl,
99	    uint16_t reset_ioctl)
100	{
101		panic("bhnd_bus_reset_hw unimplemented");
102	}
103
104
105	static int
106	bhnd_bus_null_suspend_hw(device_t dev, device_t child)
107	{
108		panic("bhnd_bus_suspend_hw unimplemented");
109	}
110
111	static bhnd_attach_type
112	bhnd_bus_null_get_attach_type(device_t dev, device_t child)
113	{
114		panic("bhnd_bus_get_attach_type unimplemented");
115	}
116
117	static int
118	bhnd_bus_null_read_board_info(device_t dev, device_t child,
119	    struct bhnd_board_info *info)
120	{
121		panic("bhnd_bus_read_boardinfo unimplemented");
122	}
123
124	static void
125	bhnd_bus_null_child_added(device_t dev, device_t child)
126	{
127	}
128
129	static int
130	bhnd_bus_null_alloc_pmu(device_t dev, device_t child)
131	{
132		panic("bhnd_bus_alloc_pmu unimplemented");
133	}
134
135	static int
136	bhnd_bus_null_release_pmu(device_t dev, device_t child)
137	{
138		panic("bhnd_bus_release_pmu unimplemented");
139	}
140
141	static int
142	bhnd_bus_null_get_clock_latency(device_t dev, device_t child,
143	    bhnd_clock clock, u_int *latency)
144	{
145		panic("bhnd_pmu_get_clock_latency unimplemented");
146	}
147
148	static int
149	bhnd_bus_null_get_clock_freq(device_t dev, device_t child,
150	    bhnd_clock clock, u_int *freq)
151	{
152		panic("bhnd_pmu_get_clock_freq unimplemented");
153	}
154
155	static int
156	bhnd_bus_null_request_clock(device_t dev, device_t child,
157	    bhnd_clock clock)
158	{
159		panic("bhnd_bus_request_clock unimplemented");
160	}
161
162	static int
163	bhnd_bus_null_enable_clocks(device_t dev, device_t child,
164	    uint32_t clocks)
165	{
166		panic("bhnd_bus_enable_clocks unimplemented");
167	}
168
169	static int
170	bhnd_bus_null_request_ext_rsrc(device_t dev, device_t child,
171	    u_int rsrc)
172	{
173		panic("bhnd_bus_request_ext_rsrc unimplemented");
174	}
175
176	static int
177	bhnd_bus_null_release_ext_rsrc(device_t dev, device_t child,
178	    u_int rsrc)
179	{
180		panic("bhnd_bus_release_ext_rsrc unimplemented");
181	}
182
183	static int
184	bhnd_bus_null_read_config(device_t dev, device_t child,
185	    bus_size_t offset, void *value, u_int width)
186	{
187		panic("bhnd_bus_null_read_config unimplemented");
188	}
189
190	static void
191	bhnd_bus_null_write_config(device_t dev, device_t child,
192	    bus_size_t offset, void *value, u_int width)
193	{
194		panic("bhnd_bus_null_write_config unimplemented");
195	}
196
197	static device_t
198	bhnd_bus_null_find_hostb_device(device_t dev)
199	{
200		return (NULL);
201	}
202
203	static struct bhnd_service_registry *
204	bhnd_bus_null_get_service_registry(device_t dev)
205	{
206		panic("bhnd_bus_get_service_registry unimplemented");
207	}
208
209	static bool
210	bhnd_bus_null_is_hw_disabled(device_t dev, device_t child)
211	{
212		panic("bhnd_bus_is_hw_disabled unimplemented");
213	}
214
215	static int
216	bhnd_bus_null_get_probe_order(device_t dev, device_t child)
217	{
218		panic("bhnd_bus_get_probe_order unimplemented");
219	}
220
221	static uintptr_t
222	bhnd_bus_null_get_intr_domain(device_t dev, device_t child, bool self)
223	{
224		/* Unsupported */
225		return (0);
226	}
227
228	static u_int
229	bhnd_bus_null_get_intr_count(device_t dev, device_t child)
230	{
231		return (0);
232	}
233
234	static int
235	bhnd_bus_null_get_intr_ivec(device_t dev, device_t child, u_int intr,
236	    u_int *ivec)
237	{
238		panic("bhnd_bus_get_intr_ivec unimplemented");
239	}
240
241	static int
242	bhnd_bus_null_map_intr(device_t dev, device_t child, u_int intr,
243	    rman_res_t *irq)
244	{
245	    panic("bhnd_bus_map_intr unimplemented");
246	}
247
248	static int
249	bhnd_bus_null_unmap_intr(device_t dev, device_t child, rman_res_t irq)
250	{
251	    panic("bhnd_bus_unmap_intr unimplemented");
252	}
253
254	static int
255	bhnd_bus_null_get_port_rid(device_t dev, device_t child,
256	    bhnd_port_type port_type, u_int port, u_int region)
257	{
258		return (-1);
259	}
260
261	static int
262	bhnd_bus_null_decode_port_rid(device_t dev, device_t child, int type,
263	    int rid, bhnd_port_type *port_type, u_int *port, u_int *region)
264	{
265		return (ENOENT);
266	}
267
268	static int
269	bhnd_bus_null_get_region_addr(device_t dev, device_t child,
270	    bhnd_port_type type, u_int port, u_int region, bhnd_addr_t *addr,
271	    bhnd_size_t *size)
272	{
273		return (ENOENT);
274	}
275
276	static int
277	bhnd_bus_null_get_nvram_var(device_t dev, device_t child,
278	    const char *name, void *buf, size_t *size, bhnd_nvram_type type)
279	{
280		return (ENODEV);
281	}
282
283}
284
285/**
286 * Return the bhnd(4) bus driver's device enumeration parser class.
287 *
288 * @param driver	The bhnd bus driver instance.
289 */
290STATICMETHOD bhnd_erom_class_t * get_erom_class {
291	driver_t			*driver;
292} DEFAULT bhnd_bus_null_get_erom_class;
293
294/**
295 * Register a shared bus @p provider for a given @p service.
296 *
297 * @param dev		The parent of @p child.
298 * @param child		The requesting child device.
299 * @param provider	The service provider to register.
300 * @param service	The service for which @p provider will be registered.
301 *
302 * @retval 0		success
303 * @retval EEXIST	if an entry for @p service already exists.
304 * @retval non-zero	if registering @p provider otherwise fails, a regular
305 *			unix error code will be returned.
306 */
307METHOD int register_provider {
308	device_t dev;
309	device_t child;
310	device_t provider;
311	bhnd_service_t service;
312} DEFAULT bhnd_bus_generic_register_provider;
313
314 /**
315 * Attempt to remove the @p service provider registration for @p provider.
316 *
317 * @param dev		The parent of @p child.
318 * @param child		The requesting child device.
319 * @param provider	The service provider to be deregistered.
320 * @param service	The service for which @p provider will be deregistered,
321 *			or BHND_SERVICE_INVALID to remove all service
322 *			registrations for @p provider.
323 *
324 * @retval 0		success
325 * @retval EBUSY	if active references to @p provider exist; @see
326 *			BHND_BUS_RETAIN_PROVIDER() and
327 *			BHND_BUS_RELEASE_PROVIDER().
328 */
329METHOD int deregister_provider {
330	device_t dev;
331	device_t child;
332	device_t provider;
333	bhnd_service_t service;
334} DEFAULT bhnd_bus_generic_deregister_provider;
335
336/**
337 * Retain and return a reference to the registered @p service provider, if any.
338 *
339 * @param dev		The parent of @p child.
340 * @param child		The requesting child device.
341 * @param service	The service for which a provider should be returned.
342 *
343 * On success, the caller assumes ownership the returned provider, and
344 * is responsible for releasing this reference via
345 * BHND_BUS_RELEASE_PROVIDER().
346 *
347 * @retval device_t	success
348 * @retval NULL		if no provider is registered for @p service.
349 */
350METHOD device_t retain_provider {
351	device_t dev;
352	device_t child;
353	bhnd_service_t service;
354} DEFAULT bhnd_bus_generic_retain_provider;
355
356 /**
357 * Release a reference to a service provider previously returned by
358 * BHND_BUS_RETAIN_PROVIDER().
359 *
360 * @param dev		The parent of @p child.
361 * @param child		The requesting child device.
362 * @param provider	The provider to be released.
363 * @param service	The service for which @p provider was previously
364 *			retained.
365 */
366METHOD void release_provider {
367	device_t dev;
368	device_t child;
369	device_t provider;
370	bhnd_service_t service;
371} DEFAULT bhnd_bus_generic_release_provider;
372
373/**
374 * Return a struct bhnd_service_registry.
375 *
376 * Used by drivers which use bhnd_bus_generic_sr_register_provider() etc.
377 * to implement service provider registration. It should return a service
378 * registry that may be used to resolve provider requests from @p child.
379 *
380 * @param dev		The parent of @p child.
381 * @param child		The requesting child device.
382 */
383METHOD struct bhnd_service_registry * get_service_registry {
384	device_t dev;
385	device_t child;
386} DEFAULT bhnd_bus_null_get_service_registry;
387
388/**
389 * Return the active host bridge core for the bhnd bus, if any.
390 *
391 * @param dev The bhnd bus device.
392 *
393 * @retval device_t if a hostb device exists
394 * @retval NULL if no hostb device is found.
395 */
396METHOD device_t find_hostb_device {
397	device_t dev;
398} DEFAULT bhnd_bus_null_find_hostb_device;
399
400/**
401 * Return true if the hardware components required by @p child are unpopulated
402 * or otherwise unusable.
403 *
404 * In some cases, enumerated devices may have pins that are left floating, or
405 * the hardware may otherwise be non-functional; this method allows a parent
406 * device to explicitly specify if a successfully enumerated @p child should
407 * be disabled.
408 *
409 * @param dev The device whose child is being examined.
410 * @param child The child device.
411 */
412METHOD bool is_hw_disabled {
413	device_t dev;
414	device_t child;
415} DEFAULT bhnd_bus_null_is_hw_disabled;
416
417/**
418 * Return the probe (and attach) order for @p child.
419 *
420 * All devices on the bhnd(4) bus will be probed, attached, or resumed in
421 * ascending order; they will be suspended, shutdown, and detached in
422 * descending order.
423 *
424 * The following device methods will be dispatched in ascending probe order
425 * by the bus:
426 *
427 * - DEVICE_PROBE()
428 * - DEVICE_ATTACH()
429 * - DEVICE_RESUME()
430 *
431 * The following device methods will be dispatched in descending probe order
432 * by the bus:
433 *
434 * - DEVICE_SHUTDOWN()
435 * - DEVICE_DETACH()
436 * - DEVICE_SUSPEND()
437 *
438 * @param dev The device whose child is being examined.
439 * @param child The child device.
440 *
441 * Refer to BHND_PROBE_* and BHND_PROBE_ORDER_* for the standard set of
442 * priorities.
443 */
444METHOD int get_probe_order {
445	device_t dev;
446	device_t child;
447} DEFAULT bhnd_bus_null_get_probe_order;
448
449/**
450 * Return the BHND chip identification for the parent bus.
451 *
452 * @param dev The device whose child is being examined.
453 * @param child The child device.
454 */
455METHOD const struct bhnd_chipid * get_chipid {
456	device_t dev;
457	device_t child;
458} DEFAULT bhnd_bus_null_get_chipid;
459
460/**
461 * Return the BHND attachment type of the parent bus.
462 *
463 * @param dev The device whose child is being examined.
464 * @param child The child device.
465 *
466 * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter,
467 * such as a WiFi chipset.
468 * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock,
469 * CPU, etc) to a directly attached native host.
470 */
471METHOD bhnd_attach_type get_attach_type {
472	device_t dev;
473	device_t child;
474} DEFAULT bhnd_bus_null_get_attach_type;
475
476
477/**
478 * Find the best available DMA address translation capable of mapping a
479 * physical host address to a BHND DMA device address of @p width with
480 * @p flags.
481 *
482 * @param dev The parent of @p child.
483 * @param child The bhnd device requesting the DMA address translation.
484 * @param width The address width within which the translation window must
485 * reside (see BHND_DMA_ADDR_*).
486 * @param flags Required translation flags (see BHND_DMA_TRANSLATION_*).
487 * @param[out] dmat On success, will be populated with a DMA tag specifying the
488 * @p translation DMA address restrictions. This argment may be NULL if the DMA
489 * tag is not desired.
490 * the set of valid host DMA addresses reachable via @p translation.
491 * @param[out] translation On success, will be populated with a DMA address
492 * translation descriptor for @p child. This argment may be NULL if the
493 * descriptor is not desired.
494 *
495 * @retval 0 success
496 * @retval ENODEV If DMA is not supported.
497 * @retval ENOENT If no DMA translation matching @p width and @p flags is
498 * available.
499 * @retval non-zero If determining the DMA address translation for @p child
500 * otherwise fails, a regular unix error code will be returned.
501 */
502METHOD int get_dma_translation {
503	device_t dev;
504	device_t child;
505	u_int width;
506	uint32_t flags;
507	bus_dma_tag_t *dmat;
508	struct bhnd_dma_translation *translation;
509} DEFAULT bhnd_bus_generic_get_dma_translation;
510
511/**
512 * Attempt to read the BHND board identification from the parent bus.
513 *
514 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot
515 * be found, or is not yet attached.
516 *
517 * @param dev The parent of @p child.
518 * @param child The bhnd device requesting board info.
519 * @param[out] info On success, will be populated with the bhnd(4) device's
520 * board information.
521 *
522 * @retval 0 success
523 * @retval ENODEV	No valid NVRAM source could be found.
524 * @retval non-zero	If reading @p name otherwise fails, a regular unix
525 *			error code will be returned.
526 */
527METHOD int read_board_info {
528	device_t dev;
529	device_t child;
530	struct bhnd_board_info *info;
531} DEFAULT bhnd_bus_null_read_board_info;
532
533/**
534 * Notify a bhnd bus that a child was added.
535 *
536 * This method must be called by concrete bhnd(4) driver impementations
537 * after @p child's bus state is fully initialized.
538 *
539 * @param dev The bhnd bus whose child is being added.
540 * @param child The child added to @p dev.
541 */
542METHOD void child_added {
543	device_t dev;
544	device_t child;
545} DEFAULT bhnd_bus_null_child_added;
546
547/**
548 * Read the current value of @p child's I/O control register.
549 *
550 * @param dev The bhnd bus parent of @p child.
551 * @param child The bhnd device for which the I/O control register should be
552 * read.
553 * @param[out] ioctl On success, the I/O control register value.
554 *
555 * @retval 0 success
556 * @retval EINVAL If @p child is not a direct child of @p dev.
557 * @retval ENODEV If agent/config space for @p child is unavailable.
558 * @retval non-zero If reading the IOCTL register otherwise fails, a regular
559 * unix error code will be returned.
560 */
561METHOD int read_ioctl {
562	device_t dev;
563	device_t child;
564	uint16_t *ioctl;
565} DEFAULT bhnd_bus_null_read_ioctl;
566
567/**
568 * Write @p value with @p mask to @p child's I/O control register.
569 *
570 * @param dev The bhnd bus parent of @p child.
571 * @param child The bhnd device for which the I/O control register should
572 * be updated.
573 * @param value The value to be written (see also BHND_IOCTL_*).
574 * @param mask Only the bits defined by @p mask will be updated from @p value.
575 *
576 * @retval 0 success
577 * @retval EINVAL If @p child is not a direct child of @p dev.
578 * @retval ENODEV If agent/config space for @p child is unavailable.
579 * @retval non-zero If writing the IOCTL register otherwise fails, a regular
580 * unix error code will be returned.
581 */
582METHOD int write_ioctl {
583	device_t dev;
584	device_t child;
585	uint16_t value;
586	uint16_t mask;
587} DEFAULT bhnd_bus_null_write_ioctl;
588
589/**
590 * Read the current value of @p child's I/O status register.
591 *
592 * @param dev The bhnd bus parent of @p child.
593 * @param child The bhnd device for which the I/O status register should be
594 * read.
595 * @param[out] iost On success, the I/O status register value.
596 *
597 * @retval 0 success
598 * @retval EINVAL If @p child is not a direct child of @p dev.
599 * @retval ENODEV If agent/config space for @p child is unavailable.
600 * @retval non-zero If reading the IOST register otherwise fails, a regular
601 * unix error code will be returned.
602 */
603METHOD int read_iost {
604	device_t dev;
605	device_t child;
606	uint16_t *iost;
607} DEFAULT bhnd_bus_null_read_iost;
608
609
610/**
611 * Return true if the given bhnd device's hardware is currently held
612 * in a RESET state or otherwise not clocked (BHND_IOCTL_CLK_EN).
613 *
614 * @param dev The bhnd bus parent of @p child.
615 * @param child The device to query.
616 *
617 * @retval true If @p child is held in RESET or not clocked (BHND_IOCTL_CLK_EN),
618 * or an error occurred determining @p child's hardware state.
619 * @retval false If @p child is clocked and is not held in RESET.
620 */
621METHOD bool is_hw_suspended {
622	device_t dev;
623	device_t child;
624} DEFAULT bhnd_bus_null_is_hw_suspended;
625
626/**
627 * Place the bhnd(4) device's hardware into a low-power RESET state with
628 * the @p reset_ioctl I/O control flags set, and then bring the hardware out of
629 * RESET with the @p ioctl I/O control flags set.
630 *
631 * Any clock or resource PMU requests previously made by @p child will be
632 * invalidated.
633 *
634 * @param dev The bhnd bus parent of @p child.
635 * @param child The device to be reset.
636 * @param ioctl Device-specific I/O control flags to be set when bringing
637 * the core out of its RESET state (see BHND_IOCTL_*).
638 * @param reset_ioctl Device-specific I/O control flags to be set when placing
639 * the core into its RESET state.
640 *
641 * @retval 0 success
642 * @retval non-zero error
643 */
644METHOD int reset_hw {
645	device_t dev;
646	device_t child;
647	uint16_t ioctl;
648	uint16_t reset_ioctl;
649} DEFAULT bhnd_bus_null_reset_hw;
650
651/**
652 * Suspend @p child's hardware in a low-power RESET state.
653 *
654 * Any clock or resource PMU requests previously made by @p dev will be
655 * invalidated.
656 *
657 * The hardware may be brought out of RESET via bhnd_reset_hw().
658 *
659 * @param dev The bhnd bus parent of @p child.
660 * @param dev The device to be suspended.
661 * @param ioctl Device-specific I/O control flags to be set when placing
662 * the core into its RESET state (see BHND_IOCTL_*).
663 *
664 * @retval 0 success
665 * @retval non-zero error
666 */
667METHOD int suspend_hw {
668	device_t dev;
669	device_t child;
670	uint16_t ioctl;
671} DEFAULT bhnd_bus_null_suspend_hw;
672
673/**
674 * Allocate per-core PMU resources and enable PMU request handling for @p child.
675 *
676 * The region containing the core's PMU register block (if any) must be
677 * allocated via bus_alloc_resource(9) (or bhnd_alloc_resource) before
678 * calling BHND_BUS_ALLOC_PMU(), and must not be released until after
679 * calling BHND_BUS_RELEASE_PMU().
680 *
681 * @param dev The parent of @p child.
682 * @param child The requesting bhnd device.
683 *
684 * @retval 0		success
685 * @retval non-zero	if enabling per-core PMU request handling fails, a
686 *			regular unix error code will be returned.
687 */
688METHOD int alloc_pmu {
689	device_t dev;
690	device_t child;
691} DEFAULT bhnd_bus_null_alloc_pmu;
692
693/**
694 * Release per-core PMU resources allocated for @p child. Any
695 * outstanding PMU requests are discarded.
696 *
697 * @param dev The parent of @p child.
698 * @param child The requesting bhnd device.
699 */
700METHOD int release_pmu {
701	device_t dev;
702	device_t child;
703} DEFAULT bhnd_bus_null_release_pmu;
704
705/**
706 * Return the transition latency required for @p clock in microseconds, if
707 * known.
708 *
709 * The BHND_CLOCK_HT latency value is suitable for use as the D11 core's
710 * 'fastpwrup_dly' value.
711 *
712 * @note A driver must ask the bhnd bus to allocate PMU request state
713 * via BHND_BUS_ALLOC_PMU() before querying PMU clocks.
714 *
715 * @param dev The parent of @p child.
716 * @param child The requesting bhnd device.
717 * @param clock	The clock to be queried for transition latency.
718 * @param[out] latency On success, the transition latency of @p clock in
719 * microseconds.
720 *
721 * @retval 0		success
722 * @retval ENODEV	If the transition latency for @p clock is not available.
723 */
724METHOD int get_clock_latency {
725	device_t dev;
726	device_t child;
727	bhnd_clock clock;
728	u_int *latency;
729} DEFAULT bhnd_bus_null_get_clock_latency;
730
731/**
732 * Return the frequency for @p clock in Hz, if known.
733 *
734 * @param dev The parent of @p child.
735 * @param child The requesting bhnd device.
736 * @param clock The clock to be queried.
737 * @param[out] freq On success, the frequency of @p clock in Hz.
738 *
739 * @note A driver must ask the bhnd bus to allocate PMU request state
740 * via BHND_BUS_ALLOC_PMU() before querying PMU clocks.
741 *
742 * @retval 0		success
743 * @retval ENODEV	If the frequency for @p clock is not available.
744 */
745METHOD int get_clock_freq {
746	device_t dev;
747	device_t child;
748	bhnd_clock clock;
749	u_int *freq;
750} DEFAULT bhnd_bus_null_get_clock_freq;
751
752/**
753 * Request that @p clock (or faster) be routed to @p child.
754 *
755 * @note A driver must ask the bhnd bus to allocate PMU request state
756 * via BHND_BUS_ALLOC_PMU() before it can request clock resources.
757 *
758 * @note Any outstanding PMU clock requests will be discarded upon calling
759 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
760 *
761 * @param dev The parent of @p child.
762 * @param child The bhnd device requesting @p clock.
763 * @param clock The requested clock source.
764 *
765 * @retval 0		success
766 * @retval ENODEV	If an unsupported clock was requested.
767 * @retval ETIMEDOUT	If the clock request succeeds, but the clock is not
768 *			detected as ready within the PMU's maximum transition
769 *			delay. This should not occur in normal operation.
770 */
771METHOD int request_clock {
772	device_t dev;
773	device_t child;
774	bhnd_clock clock;
775} DEFAULT bhnd_bus_null_request_clock;
776
777/**
778 * Request that @p clocks be powered on behalf of @p child.
779 *
780 * This will power on clock sources (e.g. XTAL, PLL, etc) required for
781 * @p clocks and wait until they are ready, discarding any previous
782 * requests by @p child.
783 *
784 * @note A driver must ask the bhnd bus to allocate PMU request state
785 * via BHND_BUS_ALLOC_PMU() before it can request clock resources.
786 *
787 * @note Any outstanding PMU clock requests will be discarded upon calling
788 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
789 *
790 * @param dev The parent of @p child.
791 * @param child The bhnd device requesting @p clock.
792 * @param clock The requested clock source.
793 *
794 * @retval 0		success
795 * @retval ENODEV	If an unsupported clock was requested.
796 * @retval ETIMEDOUT	If the clock request succeeds, but the clock is not
797 *			detected as ready within the PMU's maximum transition
798 *			delay. This should not occur in normal operation.
799 */
800METHOD int enable_clocks {
801	device_t dev;
802	device_t child;
803	uint32_t clocks;
804} DEFAULT bhnd_bus_null_enable_clocks;
805
806/**
807 * Power up an external PMU-managed resource assigned to @p child.
808 *
809 * @note A driver must ask the bhnd bus to allocate PMU request state
810 * via BHND_BUS_ALLOC_PMU() before it can request PMU resources.
811 *
812 * @note Any outstanding PMU resource requests will be released upon calling
813 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
814 *
815 * @param dev The parent of @p child.
816 * @param child The bhnd device requesting @p rsrc.
817 * @param rsrc The core-specific external resource identifier.
818 *
819 * @retval 0		success
820 * @retval ENODEV	If the PMU does not support @p rsrc.
821 * @retval ETIMEDOUT	If the clock request succeeds, but the clock is not
822 *			detected as ready within the PMU's maximum transition
823 *			delay. This should not occur in normal operation.
824 */
825METHOD int request_ext_rsrc {
826	device_t dev;
827	device_t child;
828	u_int rsrc;
829} DEFAULT bhnd_bus_null_request_ext_rsrc;
830
831/**
832 * Power down an external PMU-managed resource assigned to @p child.
833 *
834 * @note A driver must ask the bhnd bus to allocate PMU request state
835 * via BHND_BUS_ALLOC_PMU() before it can request PMU resources.
836 *
837 * @param dev The parent of @p child.
838 * @param child The bhnd device requesting @p rsrc.
839 * @param rsrc The core-specific external resource number.
840 *
841 * @retval 0		success
842 * @retval ENODEV	If the PMU does not support @p rsrc.
843 * @retval ETIMEDOUT	If the clock request succeeds, but the clock is not
844 *			detected as ready within the PMU's maximum transition
845 *			delay. This should not occur in normal operation.
846 */
847METHOD int release_ext_rsrc {
848	device_t dev;
849	device_t child;
850	u_int rsrc;
851} DEFAULT bhnd_bus_null_release_ext_rsrc;
852
853/**
854 * Read @p width bytes at @p offset from the bus-specific agent/config
855 * space of @p child.
856 *
857 * @param dev The parent of @p child.
858 * @param child The bhnd device for which @p offset should be read.
859 * @param offset The offset to be read.
860 * @param[out] value On success, the bytes read at @p offset.
861 * @param width The size of the access. Must be 1, 2 or 4 bytes.
862 *
863 * The exact behavior of this method is bus-specific. On a bcma(4) bus, this
864 * method provides access to the first agent port of @p child; on a siba(4) bus,
865 * this method provides access to the core's CFG0 register block.
866 *
867 * @note Device drivers should only use this API for functionality
868 * that is not available via another bhnd(4) function.
869 *
870 * @retval 0 success
871 * @retval EINVAL If @p child is not a direct child of @p dev.
872 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes.
873 * @retval ENODEV If accessing agent/config space for @p child is unsupported.
874 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of
875 * the mapped agent/config space  for @p child.
876 */
877METHOD int read_config {
878	device_t dev;
879	device_t child;
880	bus_size_t offset;
881	void *value;
882	u_int width;
883} DEFAULT bhnd_bus_null_read_config;
884
885/**
886 * Read @p width bytes at @p offset from the bus-specific agent/config
887 * space of @p child.
888 *
889 * @param dev The parent of @p child.
890 * @param child The bhnd device for which @p offset should be read.
891 * @param offset The offset to be written.
892 * @param value A pointer to the value to be written.
893 * @param width The size of @p value. Must be 1, 2 or 4 bytes.
894 *
895 * The exact behavior of this method is bus-specific. In the case of
896 * bcma(4), this method provides access to the first agent port of @p child.
897 *
898 * @note Device drivers should only use this API for functionality
899 * that is not available via another bhnd(4) function.
900 *
901 * @retval 0 success
902 * @retval EINVAL If @p child is not a direct child of @p dev.
903 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes.
904 * @retval ENODEV If accessing agent/config space for @p child is unsupported.
905 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of
906 * the mapped agent/config space  for @p child.
907 */
908METHOD int write_config {
909	device_t dev;
910	device_t child;
911	bus_size_t offset;
912	const void *value;
913	u_int width;
914} DEFAULT bhnd_bus_null_write_config;
915
916/**
917 * Allocate a bhnd resource.
918 *
919 * This method's semantics are functionally identical to the bus API of the same
920 * name; refer to BUS_ALLOC_RESOURCE for complete documentation.
921 */
922METHOD struct bhnd_resource * alloc_resource {
923	device_t dev;
924	device_t child;
925	int type;
926	int rid;
927	rman_res_t start;
928	rman_res_t end;
929	rman_res_t count;
930	u_int flags;
931} DEFAULT bhnd_bus_generic_alloc_resource;
932
933/**
934 * Release a bhnd resource.
935 *
936 * This method's semantics are functionally identical to the bus API of the same
937 * name; refer to BUS_RELEASE_RESOURCE for complete documentation.
938 */
939METHOD int release_resource {
940	device_t dev;
941	device_t child;
942	struct bhnd_resource *res;
943} DEFAULT bhnd_bus_generic_release_resource;
944
945/**
946 * Activate a bhnd resource.
947 *
948 * This method's semantics are functionally identical to the bus API of the same
949 * name; refer to BUS_ACTIVATE_RESOURCE for complete documentation.
950 */
951METHOD int activate_resource {
952	device_t dev;
953        device_t child;
954        struct bhnd_resource *r;
955} DEFAULT bhnd_bus_generic_activate_resource;
956
957/**
958 * Deactivate a bhnd resource.
959 *
960 * This method's semantics are functionally identical to the bus API of the same
961 * name; refer to BUS_DEACTIVATE_RESOURCE for complete documentation.
962 */
963METHOD int deactivate_resource {
964        device_t dev;
965        device_t child;
966        struct bhnd_resource *r;
967} DEFAULT bhnd_bus_generic_deactivate_resource;
968
969/**
970 * Return the interrupt domain.
971 *
972 * This globally unique value may be used as the interrupt controller 'xref'
973 * on targets that support INTRNG.
974 *
975 * @param dev The device whose child is being examined.
976 * @param child The child device.
977 * @param self If true, return @p child's interrupt domain, rather than the
978 * domain in which @p child resides.
979 *
980 * On Non-OFW targets, this should either return:
981 *   - The pointer address of a device that can uniquely identify @p child's
982 *     interrupt domain (e.g., the bhnd bus' device_t address), or
983 *   - 0 if unsupported by the bus.
984 *
985 * On OFW (including FDT) targets, this should return the @p child's iparent
986 * property's xref if @p self is false, the child's own node xref value if
987 * @p self is true, or 0 if no interrupt parent is found.
988 */
989METHOD uintptr_t get_intr_domain {
990	device_t dev;
991	device_t child;
992	bool self;
993} DEFAULT bhnd_bus_null_get_intr_domain;
994
995/**
996 * Return the number of interrupt lines assigned to @p child.
997 *
998 * @param dev The bhnd device whose child is being examined.
999 * @param child The child device.
1000 */
1001METHOD u_int get_intr_count {
1002	device_t dev;
1003	device_t child;
1004} DEFAULT bhnd_bus_null_get_intr_count;
1005
1006/**
1007 * Get the backplane interrupt vector of the @p intr line attached to @p child.
1008 *
1009 * @param dev The device whose child is being examined.
1010 * @param child The child device.
1011 * @param intr The index of the interrupt line being queried.
1012 * @param[out] ivec On success, the assigned hardware interrupt vector will be
1013 * written to this pointer.
1014 *
1015 * On bcma(4) devices, this returns the OOB bus line assigned to the
1016 * interrupt.
1017 *
1018 * On siba(4) devices, this returns the target OCP slave flag number assigned
1019 * to the interrupt.
1020 *
1021 * @retval 0		success
1022 * @retval ENXIO	If @p intr exceeds the number of interrupt lines
1023 *			assigned to @p child.
1024 */
1025METHOD int get_intr_ivec {
1026	device_t dev;
1027	device_t child;
1028	u_int intr;
1029	u_int *ivec;
1030} DEFAULT bhnd_bus_null_get_intr_ivec;
1031
1032/**
1033 * Map the given @p intr to an IRQ number; until unmapped, this IRQ may be used
1034 * to allocate a resource of type SYS_RES_IRQ.
1035 *
1036 * On success, the caller assumes ownership of the interrupt mapping, and
1037 * is responsible for releasing the mapping via BHND_BUS_UNMAP_INTR().
1038 *
1039 * @param dev The bhnd bus device.
1040 * @param child The requesting child device.
1041 * @param intr The interrupt being mapped.
1042 * @param[out] irq On success, the bus interrupt value mapped for @p intr.
1043 *
1044 * @retval 0		If an interrupt was assigned.
1045 * @retval non-zero	If mapping an interrupt otherwise fails, a regular
1046 *			unix error code will be returned.
1047 */
1048METHOD int map_intr {
1049	device_t dev;
1050	device_t child;
1051	u_int intr;
1052	rman_res_t *irq;
1053} DEFAULT bhnd_bus_null_map_intr;
1054
1055/**
1056 * Unmap an bus interrupt previously mapped via BHND_BUS_MAP_INTR().
1057 *
1058 * @param dev The bhnd bus device.
1059 * @param child The requesting child device.
1060 * @param intr The interrupt number being unmapped. This is equivalent to the
1061 * bus resource ID for the interrupt.
1062 */
1063METHOD void unmap_intr {
1064	device_t dev;
1065	device_t child;
1066	rman_res_t irq;
1067} DEFAULT bhnd_bus_null_unmap_intr;
1068
1069/**
1070 * Return true if @p region_num is a valid region on @p port_num of
1071 * @p type attached to @p child.
1072 *
1073 * @param dev The device whose child is being examined.
1074 * @param child The child device.
1075 * @param type The port type being queried.
1076 * @param port_num The port number being queried.
1077 * @param region_num The region number being queried.
1078 */
1079METHOD bool is_region_valid {
1080	device_t dev;
1081	device_t child;
1082	bhnd_port_type type;
1083	u_int port_num;
1084	u_int region_num;
1085};
1086
1087/**
1088 * Return the number of ports of type @p type attached to @p child.
1089 *
1090 * @param dev The device whose child is being examined.
1091 * @param child The child device.
1092 * @param type The port type being queried.
1093 */
1094METHOD u_int get_port_count {
1095	device_t dev;
1096	device_t child;
1097	bhnd_port_type type;
1098};
1099
1100/**
1101 * Return the number of memory regions mapped to @p child @p port of
1102 * type @p type.
1103 *
1104 * @param dev The device whose child is being examined.
1105 * @param child The child device.
1106 * @param port The port number being queried.
1107 * @param type The port type being queried.
1108 */
1109METHOD u_int get_region_count {
1110	device_t dev;
1111	device_t child;
1112	bhnd_port_type type;
1113	u_int port;
1114};
1115
1116/**
1117 * Return the SYS_RES_MEMORY resource-ID for a port/region pair attached to
1118 * @p child.
1119 *
1120 * @param dev The bus device.
1121 * @param child The bhnd child.
1122 * @param port_type The port type.
1123 * @param port_num The index of the child interconnect port.
1124 * @param region_num The index of the port-mapped address region.
1125 *
1126 * @retval -1 No such port/region found.
1127 */
1128METHOD int get_port_rid {
1129	device_t dev;
1130	device_t child;
1131	bhnd_port_type port_type;
1132	u_int port_num;
1133	u_int region_num;
1134} DEFAULT bhnd_bus_null_get_port_rid;
1135
1136
1137/**
1138 * Decode a port / region pair on @p child defined by @p type and @p rid.
1139 *
1140 * @param dev The bus device.
1141 * @param child The bhnd child.
1142 * @param type The resource type.
1143 * @param rid The resource ID.
1144 * @param[out] port_type The port's type.
1145 * @param[out] port The port identifier.
1146 * @param[out] region The identifier of the memory region on @p port.
1147 *
1148 * @retval 0 success
1149 * @retval non-zero No matching type/rid found.
1150 */
1151METHOD int decode_port_rid {
1152	device_t dev;
1153	device_t child;
1154	int type;
1155	int rid;
1156	bhnd_port_type *port_type;
1157	u_int *port;
1158	u_int *region;
1159} DEFAULT bhnd_bus_null_decode_port_rid;
1160
1161/**
1162 * Get the address and size of @p region on @p port.
1163 *
1164 * @param dev The bus device.
1165 * @param child The bhnd child.
1166 * @param port_type The port type.
1167 * @param port The port identifier.
1168 * @param region The identifier of the memory region on @p port.
1169 * @param[out] region_addr The region's base address.
1170 * @param[out] region_size The region's size.
1171 *
1172 * @retval 0 success
1173 * @retval non-zero No matching port/region found.
1174 */
1175METHOD int get_region_addr {
1176	device_t dev;
1177	device_t child;
1178	bhnd_port_type port_type;
1179	u_int port;
1180	u_int region;
1181	bhnd_addr_t *region_addr;
1182	bhnd_size_t *region_size;
1183} DEFAULT bhnd_bus_null_get_region_addr;
1184
1185/**
1186 * Read an NVRAM variable.
1187 *
1188 * It is the responsibility of the bus to delegate this request to
1189 * the appropriate NVRAM child device, or to a parent bus implementation.
1190 *
1191 * @param		dev	The bus device.
1192 * @param		child	The requesting device.
1193 * @param		name	The NVRAM variable name.
1194 * @param[out]		buf	On success, the requested value will be written
1195 *				to this buffer. This argment may be NULL if
1196 *				the value is not desired.
1197 * @param[in,out]	size	The capacity of @p buf. On success, will be set
1198 *				to the actual size of the requested value.
1199 * @param		type	The data type to be written to @p buf.
1200 *
1201 * @retval 0		success
1202 * @retval ENOENT	The requested variable was not found.
1203 * @retval ENOMEM	If @p buf is non-NULL and a buffer of @p size is too
1204 *			small to hold the requested value.
1205 * @retval ENODEV	No valid NVRAM source could be found.
1206 * @retval EFTYPE	If the @p name's data type cannot be coerced to @p type.
1207 * @retval ERANGE	If value coercion would overflow @p type.
1208 * @retval non-zero	If reading @p name otherwise fails, a regular unix
1209 *			error code will be returned.
1210 */
1211METHOD int get_nvram_var {
1212	device_t	 dev;
1213	device_t	 child;
1214	const char	*name;
1215	void		*buf;
1216	size_t		*size;
1217	bhnd_nvram_type	 type;
1218} DEFAULT bhnd_bus_null_get_nvram_var;
1219
1220
1221/** An implementation of bus_read_1() compatible with bhnd_resource */
1222METHOD uint8_t read_1 {
1223	device_t dev;
1224	device_t child;
1225	struct bhnd_resource *r;
1226	bus_size_t offset;
1227}
1228
1229/** An implementation of bus_read_2() compatible with bhnd_resource */
1230METHOD uint16_t read_2 {
1231	device_t dev;
1232	device_t child;
1233	struct bhnd_resource *r;
1234	bus_size_t offset;
1235}
1236
1237/** An implementation of bus_read_4() compatible with bhnd_resource */
1238METHOD uint32_t read_4 {
1239	device_t dev;
1240	device_t child;
1241	struct bhnd_resource *r;
1242	bus_size_t offset;
1243}
1244
1245/** An implementation of bus_write_1() compatible with bhnd_resource */
1246METHOD void write_1 {
1247	device_t dev;
1248	device_t child;
1249	struct bhnd_resource *r;
1250	bus_size_t offset;
1251	uint8_t value;
1252}
1253
1254/** An implementation of bus_write_2() compatible with bhnd_resource */
1255METHOD void write_2 {
1256	device_t dev;
1257	device_t child;
1258	struct bhnd_resource *r;
1259	bus_size_t offset;
1260	uint16_t value;
1261}
1262
1263/** An implementation of bus_write_4() compatible with bhnd_resource */
1264METHOD void write_4 {
1265	device_t dev;
1266	device_t child;
1267	struct bhnd_resource *r;
1268	bus_size_t offset;
1269	uint32_t value;
1270}
1271
1272/** An implementation of bus_read_stream_1() compatible with bhnd_resource */
1273METHOD uint8_t read_stream_1 {
1274	device_t dev;
1275	device_t child;
1276	struct bhnd_resource *r;
1277	bus_size_t offset;
1278}
1279
1280/** An implementation of bus_read_stream_2() compatible with bhnd_resource */
1281METHOD uint16_t read_stream_2 {
1282	device_t dev;
1283	device_t child;
1284	struct bhnd_resource *r;
1285	bus_size_t offset;
1286}
1287
1288/** An implementation of bus_read_stream_4() compatible with bhnd_resource */
1289METHOD uint32_t read_stream_4 {
1290	device_t dev;
1291	device_t child;
1292	struct bhnd_resource *r;
1293	bus_size_t offset;
1294}
1295
1296/** An implementation of bus_write_stream_1() compatible with bhnd_resource */
1297METHOD void write_stream_1 {
1298	device_t dev;
1299	device_t child;
1300	struct bhnd_resource *r;
1301	bus_size_t offset;
1302	uint8_t value;
1303}
1304
1305/** An implementation of bus_write_stream_2() compatible with bhnd_resource */
1306METHOD void write_stream_2 {
1307	device_t dev;
1308	device_t child;
1309	struct bhnd_resource *r;
1310	bus_size_t offset;
1311	uint16_t value;
1312}
1313
1314/** An implementation of bus_write_stream_4() compatible with bhnd_resource */
1315METHOD void write_stream_4 {
1316	device_t dev;
1317	device_t child;
1318	struct bhnd_resource *r;
1319	bus_size_t offset;
1320	uint32_t value;
1321}
1322
1323/** An implementation of bus_read_multi_1() compatible with bhnd_resource */
1324METHOD void read_multi_1 {
1325	device_t dev;
1326	device_t child;
1327	struct bhnd_resource *r;
1328	bus_size_t offset;
1329	uint8_t *datap;
1330	bus_size_t count;
1331}
1332
1333/** An implementation of bus_read_multi_2() compatible with bhnd_resource */
1334METHOD void read_multi_2 {
1335	device_t dev;
1336	device_t child;
1337	struct bhnd_resource *r;
1338	bus_size_t offset;
1339	uint16_t *datap;
1340	bus_size_t count;
1341}
1342
1343/** An implementation of bus_read_multi_4() compatible with bhnd_resource */
1344METHOD void read_multi_4 {
1345	device_t dev;
1346	device_t child;
1347	struct bhnd_resource *r;
1348	bus_size_t offset;
1349	uint32_t *datap;
1350	bus_size_t count;
1351}
1352
1353/** An implementation of bus_write_multi_1() compatible with bhnd_resource */
1354METHOD void write_multi_1 {
1355	device_t dev;
1356	device_t child;
1357	struct bhnd_resource *r;
1358	bus_size_t offset;
1359	uint8_t *datap;
1360	bus_size_t count;
1361}
1362
1363/** An implementation of bus_write_multi_2() compatible with bhnd_resource */
1364METHOD void write_multi_2 {
1365	device_t dev;
1366	device_t child;
1367	struct bhnd_resource *r;
1368	bus_size_t offset;
1369	uint16_t *datap;
1370	bus_size_t count;
1371}
1372
1373/** An implementation of bus_write_multi_4() compatible with bhnd_resource */
1374METHOD void write_multi_4 {
1375	device_t dev;
1376	device_t child;
1377	struct bhnd_resource *r;
1378	bus_size_t offset;
1379	uint32_t *datap;
1380	bus_size_t count;
1381}
1382
1383/** An implementation of bus_read_multi_stream_1() compatible
1384 *  bhnd_resource */
1385METHOD void read_multi_stream_1 {
1386	device_t dev;
1387	device_t child;
1388	struct bhnd_resource *r;
1389	bus_size_t offset;
1390	uint8_t *datap;
1391	bus_size_t count;
1392}
1393
1394/** An implementation of bus_read_multi_stream_2() compatible
1395 *  bhnd_resource */
1396METHOD void read_multi_stream_2 {
1397	device_t dev;
1398	device_t child;
1399	struct bhnd_resource *r;
1400	bus_size_t offset;
1401	uint16_t *datap;
1402	bus_size_t count;
1403}
1404
1405/** An implementation of bus_read_multi_stream_4() compatible
1406 *  bhnd_resource */
1407METHOD void read_multi_stream_4 {
1408	device_t dev;
1409	device_t child;
1410	struct bhnd_resource *r;
1411	bus_size_t offset;
1412	uint32_t *datap;
1413	bus_size_t count;
1414}
1415
1416/** An implementation of bus_write_multi_stream_1() compatible
1417 *  bhnd_resource */
1418METHOD void write_multi_stream_1 {
1419	device_t dev;
1420	device_t child;
1421	struct bhnd_resource *r;
1422	bus_size_t offset;
1423	uint8_t *datap;
1424	bus_size_t count;
1425}
1426
1427/** An implementation of bus_write_multi_stream_2() compatible with
1428 *  bhnd_resource */
1429METHOD void write_multi_stream_2 {
1430	device_t dev;
1431	device_t child;
1432	struct bhnd_resource *r;
1433	bus_size_t offset;
1434	uint16_t *datap;
1435	bus_size_t count;
1436}
1437
1438/** An implementation of bus_write_multi_stream_4() compatible with
1439 *  bhnd_resource */
1440METHOD void write_multi_stream_4 {
1441	device_t dev;
1442	device_t child;
1443	struct bhnd_resource *r;
1444	bus_size_t offset;
1445	uint32_t *datap;
1446	bus_size_t count;
1447}
1448
1449/** An implementation of bus_set_multi_1() compatible with bhnd_resource */
1450METHOD void set_multi_1 {
1451	device_t dev;
1452	device_t child;
1453	struct bhnd_resource *r;
1454	bus_size_t offset;
1455	uint8_t value;
1456	bus_size_t count;
1457}
1458
1459/** An implementation of bus_set_multi_2() compatible with bhnd_resource */
1460METHOD void set_multi_2 {
1461	device_t dev;
1462	device_t child;
1463	struct bhnd_resource *r;
1464	bus_size_t offset;
1465	uint16_t value;
1466	bus_size_t count;
1467}
1468
1469/** An implementation of bus_set_multi_4() compatible with bhnd_resource */
1470METHOD void set_multi_4 {
1471	device_t dev;
1472	device_t child;
1473	struct bhnd_resource *r;
1474	bus_size_t offset;
1475	uint32_t value;
1476	bus_size_t count;
1477}
1478
1479/** An implementation of bus_set_region_1() compatible with bhnd_resource */
1480METHOD void set_region_1 {
1481	device_t dev;
1482	device_t child;
1483	struct bhnd_resource *r;
1484	bus_size_t offset;
1485	uint8_t value;
1486	bus_size_t count;
1487}
1488
1489/** An implementation of bus_set_region_2() compatible with bhnd_resource */
1490METHOD void set_region_2 {
1491	device_t dev;
1492	device_t child;
1493	struct bhnd_resource *r;
1494	bus_size_t offset;
1495	uint16_t value;
1496	bus_size_t count;
1497}
1498
1499/** An implementation of bus_set_region_4() compatible with bhnd_resource */
1500METHOD void set_region_4 {
1501	device_t dev;
1502	device_t child;
1503	struct bhnd_resource *r;
1504	bus_size_t offset;
1505	uint32_t value;
1506	bus_size_t count;
1507}
1508
1509/** An implementation of bus_read_region_1() compatible with bhnd_resource */
1510METHOD void read_region_1 {
1511	device_t dev;
1512	device_t child;
1513	struct bhnd_resource *r;
1514	bus_size_t offset;
1515	uint8_t *datap;
1516	bus_size_t count;
1517}
1518
1519/** An implementation of bus_read_region_2() compatible with bhnd_resource */
1520METHOD void read_region_2 {
1521	device_t dev;
1522	device_t child;
1523	struct bhnd_resource *r;
1524	bus_size_t offset;
1525	uint16_t *datap;
1526	bus_size_t count;
1527}
1528
1529/** An implementation of bus_read_region_4() compatible with bhnd_resource */
1530METHOD void read_region_4 {
1531	device_t dev;
1532	device_t child;
1533	struct bhnd_resource *r;
1534	bus_size_t offset;
1535	uint32_t *datap;
1536	bus_size_t count;
1537}
1538
1539/** An implementation of bus_read_region_stream_1() compatible with
1540  * bhnd_resource */
1541METHOD void read_region_stream_1 {
1542	device_t dev;
1543	device_t child;
1544	struct bhnd_resource *r;
1545	bus_size_t offset;
1546	uint8_t *datap;
1547	bus_size_t count;
1548}
1549
1550/** An implementation of bus_read_region_stream_2() compatible with
1551  * bhnd_resource */
1552METHOD void read_region_stream_2 {
1553	device_t dev;
1554	device_t child;
1555	struct bhnd_resource *r;
1556	bus_size_t offset;
1557	uint16_t *datap;
1558	bus_size_t count;
1559}
1560
1561/** An implementation of bus_read_region_stream_4() compatible with
1562  * bhnd_resource */
1563METHOD void read_region_stream_4 {
1564	device_t dev;
1565	device_t child;
1566	struct bhnd_resource *r;
1567	bus_size_t offset;
1568	uint32_t *datap;
1569	bus_size_t count;
1570}
1571
1572/** An implementation of bus_write_region_1() compatible with bhnd_resource */
1573METHOD void write_region_1 {
1574	device_t dev;
1575	device_t child;
1576	struct bhnd_resource *r;
1577	bus_size_t offset;
1578	uint8_t *datap;
1579	bus_size_t count;
1580}
1581
1582/** An implementation of bus_write_region_2() compatible with bhnd_resource */
1583METHOD void write_region_2 {
1584	device_t dev;
1585	device_t child;
1586	struct bhnd_resource *r;
1587	bus_size_t offset;
1588	uint16_t *datap;
1589	bus_size_t count;
1590}
1591
1592/** An implementation of bus_write_region_4() compatible with bhnd_resource */
1593METHOD void write_region_4 {
1594	device_t dev;
1595	device_t child;
1596	struct bhnd_resource *r;
1597	bus_size_t offset;
1598	uint32_t *datap;
1599	bus_size_t count;
1600}
1601
1602/** An implementation of bus_write_region_stream_1() compatible with
1603  * bhnd_resource */
1604METHOD void write_region_stream_1 {
1605	device_t dev;
1606	device_t child;
1607	struct bhnd_resource *r;
1608	bus_size_t offset;
1609	uint8_t *datap;
1610	bus_size_t count;
1611}
1612
1613/** An implementation of bus_write_region_stream_2() compatible with
1614  * bhnd_resource */
1615METHOD void write_region_stream_2 {
1616	device_t dev;
1617	device_t child;
1618	struct bhnd_resource *r;
1619	bus_size_t offset;
1620	uint16_t *datap;
1621	bus_size_t count;
1622}
1623
1624/** An implementation of bus_write_region_stream_4() compatible with
1625  * bhnd_resource */
1626METHOD void write_region_stream_4 {
1627	device_t dev;
1628	device_t child;
1629	struct bhnd_resource *r;
1630	bus_size_t offset;
1631	uint32_t *datap;
1632	bus_size_t count;
1633}
1634
1635/** An implementation of bus_barrier() compatible with bhnd_resource */
1636METHOD void barrier {
1637	device_t dev;
1638	device_t child;
1639	struct bhnd_resource *r;
1640	bus_size_t offset;
1641	bus_size_t length;
1642	int flags;
1643}
1644