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