xref: /freebsd/sys/dev/bhnd/bhnd_bus_if.m (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
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	int type;
943	int rid;
944	struct bhnd_resource *res;
945} DEFAULT bhnd_bus_generic_release_resource;
946
947/**
948 * Activate a bhnd resource.
949 *
950 * This method's semantics are functionally identical to the bus API of the same
951 * name; refer to BUS_ACTIVATE_RESOURCE for complete documentation.
952 */
953METHOD int activate_resource {
954	device_t dev;
955        device_t child;
956	int type;
957        int rid;
958        struct bhnd_resource *r;
959} DEFAULT bhnd_bus_generic_activate_resource;
960
961/**
962 * Deactivate a bhnd resource.
963 *
964 * This method's semantics are functionally identical to the bus API of the same
965 * name; refer to BUS_DEACTIVATE_RESOURCE for complete documentation.
966 */
967METHOD int deactivate_resource {
968        device_t dev;
969        device_t child;
970        int type;
971	int rid;
972        struct bhnd_resource *r;
973} DEFAULT bhnd_bus_generic_deactivate_resource;
974
975/**
976 * Return the interrupt domain.
977 *
978 * This globally unique value may be used as the interrupt controller 'xref'
979 * on targets that support INTRNG.
980 *
981 * @param dev The device whose child is being examined.
982 * @param child The child device.
983 * @param self If true, return @p child's interrupt domain, rather than the
984 * domain in which @p child resides.
985 *
986 * On Non-OFW targets, this should either return:
987 *   - The pointer address of a device that can uniquely identify @p child's
988 *     interrupt domain (e.g., the bhnd bus' device_t address), or
989 *   - 0 if unsupported by the bus.
990 *
991 * On OFW (including FDT) targets, this should return the @p child's iparent
992 * property's xref if @p self is false, the child's own node xref value if
993 * @p self is true, or 0 if no interrupt parent is found.
994 */
995METHOD uintptr_t get_intr_domain {
996	device_t dev;
997	device_t child;
998	bool self;
999} DEFAULT bhnd_bus_null_get_intr_domain;
1000
1001/**
1002 * Return the number of interrupt lines assigned to @p child.
1003 *
1004 * @param dev The bhnd device whose child is being examined.
1005 * @param child The child device.
1006 */
1007METHOD u_int get_intr_count {
1008	device_t dev;
1009	device_t child;
1010} DEFAULT bhnd_bus_null_get_intr_count;
1011
1012/**
1013 * Get the backplane interrupt vector of the @p intr line attached to @p child.
1014 *
1015 * @param dev The device whose child is being examined.
1016 * @param child The child device.
1017 * @param intr The index of the interrupt line being queried.
1018 * @param[out] ivec On success, the assigned hardware interrupt vector will be
1019 * written to this pointer.
1020 *
1021 * On bcma(4) devices, this returns the OOB bus line assigned to the
1022 * interrupt.
1023 *
1024 * On siba(4) devices, this returns the target OCP slave flag number assigned
1025 * to the interrupt.
1026 *
1027 * @retval 0		success
1028 * @retval ENXIO	If @p intr exceeds the number of interrupt lines
1029 *			assigned to @p child.
1030 */
1031METHOD int get_intr_ivec {
1032	device_t dev;
1033	device_t child;
1034	u_int intr;
1035	u_int *ivec;
1036} DEFAULT bhnd_bus_null_get_intr_ivec;
1037
1038/**
1039 * Map the given @p intr to an IRQ number; until unmapped, this IRQ may be used
1040 * to allocate a resource of type SYS_RES_IRQ.
1041 *
1042 * On success, the caller assumes ownership of the interrupt mapping, and
1043 * is responsible for releasing the mapping via BHND_BUS_UNMAP_INTR().
1044 *
1045 * @param dev The bhnd bus device.
1046 * @param child The requesting child device.
1047 * @param intr The interrupt being mapped.
1048 * @param[out] irq On success, the bus interrupt value mapped for @p intr.
1049 *
1050 * @retval 0		If an interrupt was assigned.
1051 * @retval non-zero	If mapping an interrupt otherwise fails, a regular
1052 *			unix error code will be returned.
1053 */
1054METHOD int map_intr {
1055	device_t dev;
1056	device_t child;
1057	u_int intr;
1058	rman_res_t *irq;
1059} DEFAULT bhnd_bus_null_map_intr;
1060
1061/**
1062 * Unmap an bus interrupt previously mapped via BHND_BUS_MAP_INTR().
1063 *
1064 * @param dev The bhnd bus device.
1065 * @param child The requesting child device.
1066 * @param intr The interrupt number being unmapped. This is equivalent to the
1067 * bus resource ID for the interrupt.
1068 */
1069METHOD void unmap_intr {
1070	device_t dev;
1071	device_t child;
1072	rman_res_t irq;
1073} DEFAULT bhnd_bus_null_unmap_intr;
1074
1075/**
1076 * Return true if @p region_num is a valid region on @p port_num of
1077 * @p type attached to @p child.
1078 *
1079 * @param dev The device whose child is being examined.
1080 * @param child The child device.
1081 * @param type The port type being queried.
1082 * @param port_num The port number being queried.
1083 * @param region_num The region number being queried.
1084 */
1085METHOD bool is_region_valid {
1086	device_t dev;
1087	device_t child;
1088	bhnd_port_type type;
1089	u_int port_num;
1090	u_int region_num;
1091};
1092
1093/**
1094 * Return the number of ports of type @p type attached to @p child.
1095 *
1096 * @param dev The device whose child is being examined.
1097 * @param child The child device.
1098 * @param type The port type being queried.
1099 */
1100METHOD u_int get_port_count {
1101	device_t dev;
1102	device_t child;
1103	bhnd_port_type type;
1104};
1105
1106/**
1107 * Return the number of memory regions mapped to @p child @p port of
1108 * type @p type.
1109 *
1110 * @param dev The device whose child is being examined.
1111 * @param child The child device.
1112 * @param port The port number being queried.
1113 * @param type The port type being queried.
1114 */
1115METHOD u_int get_region_count {
1116	device_t dev;
1117	device_t child;
1118	bhnd_port_type type;
1119	u_int port;
1120};
1121
1122/**
1123 * Return the SYS_RES_MEMORY resource-ID for a port/region pair attached to
1124 * @p child.
1125 *
1126 * @param dev The bus device.
1127 * @param child The bhnd child.
1128 * @param port_type The port type.
1129 * @param port_num The index of the child interconnect port.
1130 * @param region_num The index of the port-mapped address region.
1131 *
1132 * @retval -1 No such port/region found.
1133 */
1134METHOD int get_port_rid {
1135	device_t dev;
1136	device_t child;
1137	bhnd_port_type port_type;
1138	u_int port_num;
1139	u_int region_num;
1140} DEFAULT bhnd_bus_null_get_port_rid;
1141
1142
1143/**
1144 * Decode a port / region pair on @p child defined by @p type and @p rid.
1145 *
1146 * @param dev The bus device.
1147 * @param child The bhnd child.
1148 * @param type The resource type.
1149 * @param rid The resource ID.
1150 * @param[out] port_type The port's type.
1151 * @param[out] port The port identifier.
1152 * @param[out] region The identifier of the memory region on @p port.
1153 *
1154 * @retval 0 success
1155 * @retval non-zero No matching type/rid found.
1156 */
1157METHOD int decode_port_rid {
1158	device_t dev;
1159	device_t child;
1160	int type;
1161	int rid;
1162	bhnd_port_type *port_type;
1163	u_int *port;
1164	u_int *region;
1165} DEFAULT bhnd_bus_null_decode_port_rid;
1166
1167/**
1168 * Get the address and size of @p region on @p port.
1169 *
1170 * @param dev The bus device.
1171 * @param child The bhnd child.
1172 * @param port_type The port type.
1173 * @param port The port identifier.
1174 * @param region The identifier of the memory region on @p port.
1175 * @param[out] region_addr The region's base address.
1176 * @param[out] region_size The region's size.
1177 *
1178 * @retval 0 success
1179 * @retval non-zero No matching port/region found.
1180 */
1181METHOD int get_region_addr {
1182	device_t dev;
1183	device_t child;
1184	bhnd_port_type port_type;
1185	u_int port;
1186	u_int region;
1187	bhnd_addr_t *region_addr;
1188	bhnd_size_t *region_size;
1189} DEFAULT bhnd_bus_null_get_region_addr;
1190
1191/**
1192 * Read an NVRAM variable.
1193 *
1194 * It is the responsibility of the bus to delegate this request to
1195 * the appropriate NVRAM child device, or to a parent bus implementation.
1196 *
1197 * @param		dev	The bus device.
1198 * @param		child	The requesting device.
1199 * @param		name	The NVRAM variable name.
1200 * @param[out]		buf	On success, the requested value will be written
1201 *				to this buffer. This argment may be NULL if
1202 *				the value is not desired.
1203 * @param[in,out]	size	The capacity of @p buf. On success, will be set
1204 *				to the actual size of the requested value.
1205 * @param		type	The data type to be written to @p buf.
1206 *
1207 * @retval 0		success
1208 * @retval ENOENT	The requested variable was not found.
1209 * @retval ENOMEM	If @p buf is non-NULL and a buffer of @p size is too
1210 *			small to hold the requested value.
1211 * @retval ENODEV	No valid NVRAM source could be found.
1212 * @retval EFTYPE	If the @p name's data type cannot be coerced to @p type.
1213 * @retval ERANGE	If value coercion would overflow @p type.
1214 * @retval non-zero	If reading @p name otherwise fails, a regular unix
1215 *			error code will be returned.
1216 */
1217METHOD int get_nvram_var {
1218	device_t	 dev;
1219	device_t	 child;
1220	const char	*name;
1221	void		*buf;
1222	size_t		*size;
1223	bhnd_nvram_type	 type;
1224} DEFAULT bhnd_bus_null_get_nvram_var;
1225
1226
1227/** An implementation of bus_read_1() compatible with bhnd_resource */
1228METHOD uint8_t read_1 {
1229	device_t dev;
1230	device_t child;
1231	struct bhnd_resource *r;
1232	bus_size_t offset;
1233}
1234
1235/** An implementation of bus_read_2() compatible with bhnd_resource */
1236METHOD uint16_t read_2 {
1237	device_t dev;
1238	device_t child;
1239	struct bhnd_resource *r;
1240	bus_size_t offset;
1241}
1242
1243/** An implementation of bus_read_4() compatible with bhnd_resource */
1244METHOD uint32_t read_4 {
1245	device_t dev;
1246	device_t child;
1247	struct bhnd_resource *r;
1248	bus_size_t offset;
1249}
1250
1251/** An implementation of bus_write_1() compatible with bhnd_resource */
1252METHOD void write_1 {
1253	device_t dev;
1254	device_t child;
1255	struct bhnd_resource *r;
1256	bus_size_t offset;
1257	uint8_t value;
1258}
1259
1260/** An implementation of bus_write_2() compatible with bhnd_resource */
1261METHOD void write_2 {
1262	device_t dev;
1263	device_t child;
1264	struct bhnd_resource *r;
1265	bus_size_t offset;
1266	uint16_t value;
1267}
1268
1269/** An implementation of bus_write_4() compatible with bhnd_resource */
1270METHOD void write_4 {
1271	device_t dev;
1272	device_t child;
1273	struct bhnd_resource *r;
1274	bus_size_t offset;
1275	uint32_t value;
1276}
1277
1278/** An implementation of bus_read_stream_1() compatible with bhnd_resource */
1279METHOD uint8_t read_stream_1 {
1280	device_t dev;
1281	device_t child;
1282	struct bhnd_resource *r;
1283	bus_size_t offset;
1284}
1285
1286/** An implementation of bus_read_stream_2() compatible with bhnd_resource */
1287METHOD uint16_t read_stream_2 {
1288	device_t dev;
1289	device_t child;
1290	struct bhnd_resource *r;
1291	bus_size_t offset;
1292}
1293
1294/** An implementation of bus_read_stream_4() compatible with bhnd_resource */
1295METHOD uint32_t read_stream_4 {
1296	device_t dev;
1297	device_t child;
1298	struct bhnd_resource *r;
1299	bus_size_t offset;
1300}
1301
1302/** An implementation of bus_write_stream_1() compatible with bhnd_resource */
1303METHOD void write_stream_1 {
1304	device_t dev;
1305	device_t child;
1306	struct bhnd_resource *r;
1307	bus_size_t offset;
1308	uint8_t value;
1309}
1310
1311/** An implementation of bus_write_stream_2() compatible with bhnd_resource */
1312METHOD void write_stream_2 {
1313	device_t dev;
1314	device_t child;
1315	struct bhnd_resource *r;
1316	bus_size_t offset;
1317	uint16_t value;
1318}
1319
1320/** An implementation of bus_write_stream_4() compatible with bhnd_resource */
1321METHOD void write_stream_4 {
1322	device_t dev;
1323	device_t child;
1324	struct bhnd_resource *r;
1325	bus_size_t offset;
1326	uint32_t value;
1327}
1328
1329/** An implementation of bus_read_multi_1() compatible with bhnd_resource */
1330METHOD void read_multi_1 {
1331	device_t dev;
1332	device_t child;
1333	struct bhnd_resource *r;
1334	bus_size_t offset;
1335	uint8_t *datap;
1336	bus_size_t count;
1337}
1338
1339/** An implementation of bus_read_multi_2() compatible with bhnd_resource */
1340METHOD void read_multi_2 {
1341	device_t dev;
1342	device_t child;
1343	struct bhnd_resource *r;
1344	bus_size_t offset;
1345	uint16_t *datap;
1346	bus_size_t count;
1347}
1348
1349/** An implementation of bus_read_multi_4() compatible with bhnd_resource */
1350METHOD void read_multi_4 {
1351	device_t dev;
1352	device_t child;
1353	struct bhnd_resource *r;
1354	bus_size_t offset;
1355	uint32_t *datap;
1356	bus_size_t count;
1357}
1358
1359/** An implementation of bus_write_multi_1() compatible with bhnd_resource */
1360METHOD void write_multi_1 {
1361	device_t dev;
1362	device_t child;
1363	struct bhnd_resource *r;
1364	bus_size_t offset;
1365	uint8_t *datap;
1366	bus_size_t count;
1367}
1368
1369/** An implementation of bus_write_multi_2() compatible with bhnd_resource */
1370METHOD void write_multi_2 {
1371	device_t dev;
1372	device_t child;
1373	struct bhnd_resource *r;
1374	bus_size_t offset;
1375	uint16_t *datap;
1376	bus_size_t count;
1377}
1378
1379/** An implementation of bus_write_multi_4() compatible with bhnd_resource */
1380METHOD void write_multi_4 {
1381	device_t dev;
1382	device_t child;
1383	struct bhnd_resource *r;
1384	bus_size_t offset;
1385	uint32_t *datap;
1386	bus_size_t count;
1387}
1388
1389/** An implementation of bus_read_multi_stream_1() compatible
1390 *  bhnd_resource */
1391METHOD void read_multi_stream_1 {
1392	device_t dev;
1393	device_t child;
1394	struct bhnd_resource *r;
1395	bus_size_t offset;
1396	uint8_t *datap;
1397	bus_size_t count;
1398}
1399
1400/** An implementation of bus_read_multi_stream_2() compatible
1401 *  bhnd_resource */
1402METHOD void read_multi_stream_2 {
1403	device_t dev;
1404	device_t child;
1405	struct bhnd_resource *r;
1406	bus_size_t offset;
1407	uint16_t *datap;
1408	bus_size_t count;
1409}
1410
1411/** An implementation of bus_read_multi_stream_4() compatible
1412 *  bhnd_resource */
1413METHOD void read_multi_stream_4 {
1414	device_t dev;
1415	device_t child;
1416	struct bhnd_resource *r;
1417	bus_size_t offset;
1418	uint32_t *datap;
1419	bus_size_t count;
1420}
1421
1422/** An implementation of bus_write_multi_stream_1() compatible
1423 *  bhnd_resource */
1424METHOD void write_multi_stream_1 {
1425	device_t dev;
1426	device_t child;
1427	struct bhnd_resource *r;
1428	bus_size_t offset;
1429	uint8_t *datap;
1430	bus_size_t count;
1431}
1432
1433/** An implementation of bus_write_multi_stream_2() compatible with
1434 *  bhnd_resource */
1435METHOD void write_multi_stream_2 {
1436	device_t dev;
1437	device_t child;
1438	struct bhnd_resource *r;
1439	bus_size_t offset;
1440	uint16_t *datap;
1441	bus_size_t count;
1442}
1443
1444/** An implementation of bus_write_multi_stream_4() compatible with
1445 *  bhnd_resource */
1446METHOD void write_multi_stream_4 {
1447	device_t dev;
1448	device_t child;
1449	struct bhnd_resource *r;
1450	bus_size_t offset;
1451	uint32_t *datap;
1452	bus_size_t count;
1453}
1454
1455/** An implementation of bus_set_multi_1() compatible with bhnd_resource */
1456METHOD void set_multi_1 {
1457	device_t dev;
1458	device_t child;
1459	struct bhnd_resource *r;
1460	bus_size_t offset;
1461	uint8_t value;
1462	bus_size_t count;
1463}
1464
1465/** An implementation of bus_set_multi_2() compatible with bhnd_resource */
1466METHOD void set_multi_2 {
1467	device_t dev;
1468	device_t child;
1469	struct bhnd_resource *r;
1470	bus_size_t offset;
1471	uint16_t value;
1472	bus_size_t count;
1473}
1474
1475/** An implementation of bus_set_multi_4() compatible with bhnd_resource */
1476METHOD void set_multi_4 {
1477	device_t dev;
1478	device_t child;
1479	struct bhnd_resource *r;
1480	bus_size_t offset;
1481	uint32_t value;
1482	bus_size_t count;
1483}
1484
1485/** An implementation of bus_set_region_1() compatible with bhnd_resource */
1486METHOD void set_region_1 {
1487	device_t dev;
1488	device_t child;
1489	struct bhnd_resource *r;
1490	bus_size_t offset;
1491	uint8_t value;
1492	bus_size_t count;
1493}
1494
1495/** An implementation of bus_set_region_2() compatible with bhnd_resource */
1496METHOD void set_region_2 {
1497	device_t dev;
1498	device_t child;
1499	struct bhnd_resource *r;
1500	bus_size_t offset;
1501	uint16_t value;
1502	bus_size_t count;
1503}
1504
1505/** An implementation of bus_set_region_4() compatible with bhnd_resource */
1506METHOD void set_region_4 {
1507	device_t dev;
1508	device_t child;
1509	struct bhnd_resource *r;
1510	bus_size_t offset;
1511	uint32_t value;
1512	bus_size_t count;
1513}
1514
1515/** An implementation of bus_read_region_1() compatible with bhnd_resource */
1516METHOD void read_region_1 {
1517	device_t dev;
1518	device_t child;
1519	struct bhnd_resource *r;
1520	bus_size_t offset;
1521	uint8_t *datap;
1522	bus_size_t count;
1523}
1524
1525/** An implementation of bus_read_region_2() compatible with bhnd_resource */
1526METHOD void read_region_2 {
1527	device_t dev;
1528	device_t child;
1529	struct bhnd_resource *r;
1530	bus_size_t offset;
1531	uint16_t *datap;
1532	bus_size_t count;
1533}
1534
1535/** An implementation of bus_read_region_4() compatible with bhnd_resource */
1536METHOD void read_region_4 {
1537	device_t dev;
1538	device_t child;
1539	struct bhnd_resource *r;
1540	bus_size_t offset;
1541	uint32_t *datap;
1542	bus_size_t count;
1543}
1544
1545/** An implementation of bus_read_region_stream_1() compatible with
1546  * bhnd_resource */
1547METHOD void read_region_stream_1 {
1548	device_t dev;
1549	device_t child;
1550	struct bhnd_resource *r;
1551	bus_size_t offset;
1552	uint8_t *datap;
1553	bus_size_t count;
1554}
1555
1556/** An implementation of bus_read_region_stream_2() compatible with
1557  * bhnd_resource */
1558METHOD void read_region_stream_2 {
1559	device_t dev;
1560	device_t child;
1561	struct bhnd_resource *r;
1562	bus_size_t offset;
1563	uint16_t *datap;
1564	bus_size_t count;
1565}
1566
1567/** An implementation of bus_read_region_stream_4() compatible with
1568  * bhnd_resource */
1569METHOD void read_region_stream_4 {
1570	device_t dev;
1571	device_t child;
1572	struct bhnd_resource *r;
1573	bus_size_t offset;
1574	uint32_t *datap;
1575	bus_size_t count;
1576}
1577
1578/** An implementation of bus_write_region_1() compatible with bhnd_resource */
1579METHOD void write_region_1 {
1580	device_t dev;
1581	device_t child;
1582	struct bhnd_resource *r;
1583	bus_size_t offset;
1584	uint8_t *datap;
1585	bus_size_t count;
1586}
1587
1588/** An implementation of bus_write_region_2() compatible with bhnd_resource */
1589METHOD void write_region_2 {
1590	device_t dev;
1591	device_t child;
1592	struct bhnd_resource *r;
1593	bus_size_t offset;
1594	uint16_t *datap;
1595	bus_size_t count;
1596}
1597
1598/** An implementation of bus_write_region_4() compatible with bhnd_resource */
1599METHOD void write_region_4 {
1600	device_t dev;
1601	device_t child;
1602	struct bhnd_resource *r;
1603	bus_size_t offset;
1604	uint32_t *datap;
1605	bus_size_t count;
1606}
1607
1608/** An implementation of bus_write_region_stream_1() compatible with
1609  * bhnd_resource */
1610METHOD void write_region_stream_1 {
1611	device_t dev;
1612	device_t child;
1613	struct bhnd_resource *r;
1614	bus_size_t offset;
1615	uint8_t *datap;
1616	bus_size_t count;
1617}
1618
1619/** An implementation of bus_write_region_stream_2() compatible with
1620  * bhnd_resource */
1621METHOD void write_region_stream_2 {
1622	device_t dev;
1623	device_t child;
1624	struct bhnd_resource *r;
1625	bus_size_t offset;
1626	uint16_t *datap;
1627	bus_size_t count;
1628}
1629
1630/** An implementation of bus_write_region_stream_4() compatible with
1631  * bhnd_resource */
1632METHOD void write_region_stream_4 {
1633	device_t dev;
1634	device_t child;
1635	struct bhnd_resource *r;
1636	bus_size_t offset;
1637	uint32_t *datap;
1638	bus_size_t count;
1639}
1640
1641/** An implementation of bus_barrier() compatible with bhnd_resource */
1642METHOD void barrier {
1643	device_t dev;
1644	device_t child;
1645	struct bhnd_resource *r;
1646	bus_size_t offset;
1647	bus_size_t length;
1648	int flags;
1649}
1650