2 # Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 # IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/types.h>
31 #include <dev/bhnd/bhnd_types.h>
32 #include <dev/bhnd/bhnd_erom_types.h>
37 # bhnd(4) bus interface
41 /* forward declarations */
42 struct bhnd_board_info;
43 struct bhnd_core_info;
50 #include <sys/systm.h>
52 #include <dev/bhnd/bhndvar.h>
54 static bhnd_erom_class_t *
55 bhnd_bus_null_get_erom_class(driver_t *driver)
60 static struct bhnd_chipid *
61 bhnd_bus_null_get_chipid(device_t dev, device_t child)
63 panic("bhnd_bus_get_chipid unimplemented");
67 bhnd_bus_null_read_ioctl(device_t dev, device_t child, uint16_t *ioctl)
69 panic("bhnd_bus_read_ioctl unimplemented");
74 bhnd_bus_null_write_ioctl(device_t dev, device_t child, uint16_t value,
77 panic("bhnd_bus_write_ioctl unimplemented");
82 bhnd_bus_null_read_iost(device_t dev, device_t child, uint16_t *iost)
84 panic("bhnd_bus_read_iost unimplemented");
88 bhnd_bus_null_is_hw_suspended(device_t dev, device_t child)
90 panic("bhnd_bus_is_hw_suspended unimplemented");
94 bhnd_bus_null_reset_hw(device_t dev, device_t child, uint16_t ioctl)
96 panic("bhnd_bus_reset_hw unimplemented");
101 bhnd_bus_null_suspend_hw(device_t dev, device_t child)
103 panic("bhnd_bus_suspend_hw unimplemented");
106 static bhnd_attach_type
107 bhnd_bus_null_get_attach_type(device_t dev, device_t child)
109 panic("bhnd_bus_get_attach_type unimplemented");
113 bhnd_bus_null_pwrctl_get_clksrc(device_t dev, device_t child,
116 return (BHND_CLKSRC_UNKNOWN);
120 bhnd_bus_null_pwrctl_gate_clock(device_t dev, device_t child,
127 bhnd_bus_null_pwrctl_ungate_clock(device_t dev, device_t child,
134 bhnd_bus_null_read_board_info(device_t dev, device_t child,
135 struct bhnd_board_info *info)
137 panic("bhnd_bus_read_boardinfo unimplemented");
141 bhnd_bus_null_get_intr_count(device_t dev, device_t child)
143 panic("bhnd_bus_get_intr_count unimplemented");
147 bhnd_bus_null_assign_intr(device_t dev, device_t child, int rid)
149 panic("bhnd_bus_assign_intr unimplemented");
153 bhnd_bus_null_get_core_ivec(device_t dev, device_t child, u_int intr,
156 panic("bhnd_bus_get_core_ivec unimplemented");
160 bhnd_bus_null_child_added(device_t dev, device_t child)
165 bhnd_bus_null_alloc_pmu(device_t dev, device_t child)
167 panic("bhnd_bus_alloc_pmu unimplemented");
171 bhnd_bus_null_release_pmu(device_t dev, device_t child)
173 panic("bhnd_bus_release_pmu unimplemented");
177 bhnd_bus_null_request_clock(device_t dev, device_t child,
180 panic("bhnd_bus_request_clock unimplemented");
184 bhnd_bus_null_enable_clocks(device_t dev, device_t child,
187 panic("bhnd_bus_enable_clocks unimplemented");
191 bhnd_bus_null_request_ext_rsrc(device_t dev, device_t child,
194 panic("bhnd_bus_request_ext_rsrc unimplemented");
198 bhnd_bus_null_release_ext_rsrc(device_t dev, device_t child,
201 panic("bhnd_bus_release_ext_rsrc unimplemented");
205 bhnd_bus_null_read_config(device_t dev, device_t child,
206 bus_size_t offset, void *value, u_int width)
208 panic("bhnd_bus_null_read_config unimplemented");
212 bhnd_bus_null_write_config(device_t dev, device_t child,
213 bus_size_t offset, void *value, u_int width)
215 panic("bhnd_bus_null_write_config unimplemented");
219 bhnd_bus_null_find_hostb_device(device_t dev)
225 bhnd_bus_null_is_hw_disabled(device_t dev, device_t child)
227 panic("bhnd_bus_is_hw_disabled unimplemented");
231 bhnd_bus_null_get_probe_order(device_t dev, device_t child)
233 panic("bhnd_bus_get_probe_order unimplemented");
237 bhnd_bus_null_get_port_rid(device_t dev, device_t child,
238 bhnd_port_type port_type, u_int port, u_int region)
244 bhnd_bus_null_decode_port_rid(device_t dev, device_t child, int type,
245 int rid, bhnd_port_type *port_type, u_int *port, u_int *region)
251 bhnd_bus_null_get_region_addr(device_t dev, device_t child,
252 bhnd_port_type type, u_int port, u_int region, bhnd_addr_t *addr,
259 bhnd_bus_null_get_nvram_var(device_t dev, device_t child,
260 const char *name, void *buf, size_t *size, bhnd_nvram_type type)
268 * Return the bhnd(4) bus driver's device enumeration parser class.
270 * @param driver The bhnd bus driver instance.
272 STATICMETHOD bhnd_erom_class_t * get_erom_class {
274 } DEFAULT bhnd_bus_null_get_erom_class;
277 * Return the active host bridge core for the bhnd bus, if any.
279 * @param dev The bhnd bus device.
281 * @retval device_t if a hostb device exists
282 * @retval NULL if no hostb device is found.
284 METHOD device_t find_hostb_device {
286 } DEFAULT bhnd_bus_null_find_hostb_device;
289 * Return true if the hardware components required by @p child are unpopulated
290 * or otherwise unusable.
292 * In some cases, enumerated devices may have pins that are left floating, or
293 * the hardware may otherwise be non-functional; this method allows a parent
294 * device to explicitly specify if a successfully enumerated @p child should
297 * @param dev The device whose child is being examined.
298 * @param child The child device.
300 METHOD bool is_hw_disabled {
303 } DEFAULT bhnd_bus_null_is_hw_disabled;
306 * Return the probe (and attach) order for @p child.
308 * All devices on the bhnd(4) bus will be probed, attached, or resumed in
309 * ascending order; they will be suspended, shutdown, and detached in
312 * The following device methods will be dispatched in ascending probe order
319 * The following device methods will be dispatched in descending probe order
322 * - DEVICE_SHUTDOWN()
326 * @param dev The device whose child is being examined.
327 * @param child The child device.
329 * Refer to BHND_PROBE_* and BHND_PROBE_ORDER_* for the standard set of
332 METHOD int get_probe_order {
335 } DEFAULT bhnd_bus_null_get_probe_order;
338 * Return the BHND chip identification for the parent bus.
340 * @param dev The device whose child is being examined.
341 * @param child The child device.
343 METHOD const struct bhnd_chipid * get_chipid {
346 } DEFAULT bhnd_bus_null_get_chipid;
349 * Return the BHND attachment type of the parent bus.
351 * @param dev The device whose child is being examined.
352 * @param child The child device.
354 * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter,
355 * such as a WiFi chipset.
356 * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock,
357 * CPU, etc) to a directly attached native host.
359 METHOD bhnd_attach_type get_attach_type {
362 } DEFAULT bhnd_bus_null_get_attach_type;
365 * Attempt to read the BHND board identification from the parent bus.
367 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot
368 * be found, or is not yet attached.
370 * @param dev The parent of @p child.
371 * @param child The bhnd device requesting board info.
372 * @param[out] info On success, will be populated with the bhnd(4) device's
376 * @retval ENODEV No valid NVRAM source could be found.
377 * @retval non-zero If reading @p name otherwise fails, a regular unix
378 * error code will be returned.
380 METHOD int read_board_info {
383 struct bhnd_board_info *info;
384 } DEFAULT bhnd_bus_null_read_board_info;
387 * Return the number of interrupts to be assigned to @p child via
388 * BHND_BUS_ASSIGN_INTR().
390 * @param dev The bhnd bus parent of @p child.
391 * @param child The bhnd device for which a count should be returned.
393 * @retval 0 If no interrupts should be assigned.
394 * @retval non-zero The count of interrupt resource IDs to be
395 * assigned, starting at rid 0.
397 METHOD int get_intr_count {
400 } DEFAULT bhnd_bus_null_get_intr_count;
403 * Assign an interrupt to @p child via bus_set_resource().
405 * The default bus implementation of this method should assign backplane
406 * interrupt values to @p child.
408 * Bridge-attached bus implementations may instead override standard
409 * interconnect IRQ assignment, providing IRQs inherited from the parent bus.
411 * TODO: Once we can depend on INTRNG, investigate replacing this with a
412 * bridge-level interrupt controller.
414 * @param dev The bhnd bus parent of @p child.
415 * @param child The bhnd device to which an interrupt should be assigned.
416 * @param rid The interrupt resource ID to be assigned.
418 * @retval 0 If an interrupt was assigned.
419 * @retval non-zero If assigning an interrupt otherwise fails, a regular
420 * unix error code will be returned.
422 METHOD int assign_intr {
426 } DEFAULT bhnd_bus_null_assign_intr;
429 * Return the backplane interrupt vector corresponding to @p child's given
432 * @param dev The bhnd bus parent of @p child.
433 * @param child The bhnd device for which the assigned interrupt vector should
435 * @param intr The interrupt number being queried. This is equivalent to the
436 * bus resource ID for the interrupt.
437 * @param[out] ivec On success, the assigned hardware interrupt vector be
438 * written to this pointer.
440 * On bcma(4) devices, this returns the OOB bus line assigned to the
443 * On siba(4) devices, this returns the target OCP slave flag number assigned
447 * @retval ENXIO If @p intr exceeds the number of interrupts available
450 METHOD int get_core_ivec {
455 } DEFAULT bhnd_bus_null_get_core_ivec;
458 * Notify a bhnd bus that a child was added.
460 * This method must be called by concrete bhnd(4) driver impementations
461 * after @p child's bus state is fully initialized.
463 * @param dev The bhnd bus whose child is being added.
464 * @param child The child added to @p dev.
466 METHOD void child_added {
469 } DEFAULT bhnd_bus_null_child_added;
472 * Read the current value of @p child's I/O control register.
474 * @param dev The bhnd bus parent of @p child.
475 * @param child The bhnd device for which the I/O control register should be
477 * @param[out] ioctl On success, the I/O control register value.
480 * @retval EINVAL If @p child is not a direct child of @p dev.
481 * @retval ENODEV If agent/config space for @p child is unavailable.
482 * @retval non-zero If reading the IOCTL register otherwise fails, a regular
483 * unix error code will be returned.
485 METHOD int read_ioctl {
489 } DEFAULT bhnd_bus_null_read_ioctl;
492 * Write @p value with @p mask to @p child's I/O control register.
494 * @param dev The bhnd bus parent of @p child.
495 * @param child The bhnd device for which the I/O control register should
497 * @param value The value to be written (see also BHND_IOCTL_*).
498 * @param mask Only the bits defined by @p mask will be updated from @p value.
501 * @retval EINVAL If @p child is not a direct child of @p dev.
502 * @retval ENODEV If agent/config space for @p child is unavailable.
503 * @retval non-zero If writing the IOCTL register otherwise fails, a regular
504 * unix error code will be returned.
506 METHOD int write_ioctl {
511 } DEFAULT bhnd_bus_null_write_ioctl;
514 * Read the current value of @p child's I/O status register.
516 * @param dev The bhnd bus parent of @p child.
517 * @param child The bhnd device for which the I/O status register should be
519 * @param[out] iost On success, the I/O status register value.
522 * @retval EINVAL If @p child is not a direct child of @p dev.
523 * @retval ENODEV If agent/config space for @p child is unavailable.
524 * @retval non-zero If reading the IOST register otherwise fails, a regular
525 * unix error code will be returned.
527 METHOD int read_iost {
531 } DEFAULT bhnd_bus_null_read_iost;
535 * Return true if the given bhnd device's hardware is currently held
536 * in a RESET state or otherwise not clocked (BHND_IOCTL_CLK_EN).
538 * @param dev The bhnd bus parent of @p child.
539 * @param child The device to query.
541 * @retval true If @p child is held in RESET or not clocked (BHND_IOCTL_CLK_EN),
542 * or an error occured determining @p child's hardware state.
543 * @retval false If @p child is clocked and is not held in RESET.
545 METHOD bool is_hw_suspended {
548 } DEFAULT bhnd_bus_null_is_hw_suspended;
551 * Place the bhnd(4) device's hardware into a reset state, and then bring the
552 * hardware out of reset with BHND_IOCTL_CLK_EN and @p ioctl flags set.
554 * Any clock or resource PMU requests previously made by @p child will be
557 * @param dev The bhnd bus parent of @p child.
558 * @param child The device to be reset.
559 * @param ioctl Device-specific core ioctl flags to be supplied on reset
560 * (see BHND_IOCTL_*).
563 * @retval non-zero error
565 METHOD int reset_hw {
569 } DEFAULT bhnd_bus_null_reset_hw;
572 * Suspend @p child's hardware in a low-power reset state.
574 * Any clock or resource PMU requests previously made by @p dev will be
577 * The hardware may be brought out of reset via bhnd_reset_hw().
579 * @param dev The bhnd bus parent of @P child.
580 * @param dev The device to be suspended.
583 * @retval non-zero error
585 METHOD int suspend_hw {
588 } DEFAULT bhnd_bus_null_suspend_hw;
591 * If supported by the chipset, return the clock source for the given clock.
593 * This function is only supported on early PWRCTL-equipped chipsets
594 * that expose clock management via their host bridge interface. Currently,
595 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9.
597 * @param dev The parent of @p child.
598 * @param child The bhnd device requesting a clock source.
599 * @param clock The clock for which a clock source will be returned.
601 * @retval bhnd_clksrc The clock source for @p clock.
602 * @retval BHND_CLKSRC_UNKNOWN If @p clock is unsupported, or its
603 * clock source is not known to the bus.
605 METHOD bhnd_clksrc pwrctl_get_clksrc {
609 } DEFAULT bhnd_bus_null_pwrctl_get_clksrc;
612 * If supported by the chipset, gate the clock source for @p clock
614 * This function is only supported on early PWRCTL-equipped chipsets
615 * that expose clock management via their host bridge interface. Currently,
616 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9.
618 * @param dev The parent of @p child.
619 * @param child The bhnd device requesting clock gating.
620 * @param clock The clock to be disabled.
623 * @retval ENODEV If bus-level clock source management is not supported.
624 * @retval ENXIO If bus-level management of @p clock is not supported.
626 METHOD int pwrctl_gate_clock {
630 } DEFAULT bhnd_bus_null_pwrctl_gate_clock;
633 * If supported by the chipset, ungate the clock source for @p clock
635 * This function is only supported on early PWRCTL-equipped chipsets
636 * that expose clock management via their host bridge interface. Currently,
637 * this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9.
639 * @param dev The parent of @p child.
640 * @param child The bhnd device requesting clock gating.
641 * @param clock The clock to be enabled.
644 * @retval ENODEV If bus-level clock source management is not supported.
645 * @retval ENXIO If bus-level management of @p clock is not supported.
647 METHOD int pwrctl_ungate_clock {
651 } DEFAULT bhnd_bus_null_pwrctl_ungate_clock;
654 * Allocate and enable per-core PMU request handling for @p child.
656 * The region containing the core's PMU register block (if any) must be
657 * allocated via bus_alloc_resource(9) (or bhnd_alloc_resource) before
658 * calling BHND_BUS_ALLOC_PMU(), and must not be released until after
659 * calling BHND_BUS_RELEASE_PMU().
661 * @param dev The parent of @p child.
662 * @param child The requesting bhnd device.
664 METHOD int alloc_pmu {
667 } DEFAULT bhnd_bus_null_alloc_pmu;
670 * Release per-core PMU resources allocated for @p child. Any
671 * outstanding PMU requests are discarded.
673 * @param dev The parent of @p child.
674 * @param child The requesting bhnd device.
676 METHOD int release_pmu {
679 } DEFAULT bhnd_bus_null_release_pmu;
682 * Request that @p clock (or faster) be routed to @p child.
684 * @note A driver must ask the bhnd bus to allocate PMU request state
685 * via BHND_BUS_ALLOC_PMU() before it can request clock resources.
687 * @note Any outstanding PMU clock requests will be discarded upon calling
688 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
690 * @param dev The parent of @p child.
691 * @param child The bhnd device requesting @p clock.
692 * @param clock The requested clock source.
695 * @retval ENODEV If an unsupported clock was requested.
696 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
698 METHOD int request_clock {
702 } DEFAULT bhnd_bus_null_request_clock;
705 * Request that @p clocks be powered on behalf of @p child.
707 * This will power on clock sources (e.g. XTAL, PLL, etc) required for
708 * @p clocks and wait until they are ready, discarding any previous
709 * requests by @p child.
711 * @note A driver must ask the bhnd bus to allocate PMU request state
712 * via BHND_BUS_ALLOC_PMU() before it can request clock resources.
714 * @note Any outstanding PMU clock requests will be discarded upon calling
715 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
717 * @param dev The parent of @p child.
718 * @param child The bhnd device requesting @p clock.
719 * @param clock The requested clock source.
722 * @retval ENODEV If an unsupported clock was requested.
723 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
725 METHOD int enable_clocks {
729 } DEFAULT bhnd_bus_null_enable_clocks;
732 * Power up an external PMU-managed resource assigned to @p child.
734 * @note A driver must ask the bhnd bus to allocate PMU request state
735 * via BHND_BUS_ALLOC_PMU() before it can request PMU resources.
737 * @note Any outstanding PMU resource requests will be released upon calling
738 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
740 * @param dev The parent of @p child.
741 * @param child The bhnd device requesting @p rsrc.
742 * @param rsrc The core-specific external resource identifier.
745 * @retval ENODEV If the PMU does not support @p rsrc.
746 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
748 METHOD int request_ext_rsrc {
752 } DEFAULT bhnd_bus_null_request_ext_rsrc;
755 * Power down an external PMU-managed resource assigned to @p child.
757 * @note A driver must ask the bhnd bus to allocate PMU request state
758 * via BHND_BUS_ALLOC_PMU() before it can request PMU resources.
760 * @param dev The parent of @p child.
761 * @param child The bhnd device requesting @p rsrc.
762 * @param rsrc The core-specific external resource number.
765 * @retval ENODEV If the PMU does not support @p rsrc.
766 * @retval ENXIO If the PMU has not been initialized or is otherwise unvailable.
768 METHOD int release_ext_rsrc {
772 } DEFAULT bhnd_bus_null_release_ext_rsrc;
775 * Read @p width bytes at @p offset from the bus-specific agent/config
778 * @param dev The parent of @p child.
779 * @param child The bhnd device for which @p offset should be read.
780 * @param offset The offset to be read.
781 * @param[out] value On success, the bytes read at @p offset.
782 * @param width The size of the access. Must be 1, 2 or 4 bytes.
784 * The exact behavior of this method is bus-specific. On a bcma(4) bus, this
785 * method provides access to the first agent port of @p child; on a siba(4) bus,
786 * this method provides access to the core's CFG0 register block.
788 * @note Device drivers should only use this API for functionality
789 * that is not available via another bhnd(4) function.
792 * @retval EINVAL If @p child is not a direct child of @p dev.
793 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes.
794 * @retval ENODEV If accessing agent/config space for @p child is unsupported.
795 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of
796 * the mapped agent/config space for @p child.
798 METHOD int read_config {
804 } DEFAULT bhnd_bus_null_read_config;
807 * Read @p width bytes at @p offset from the bus-specific agent/config
810 * @param dev The parent of @p child.
811 * @param child The bhnd device for which @p offset should be read.
812 * @param offset The offset to be written.
813 * @param value A pointer to the value to be written.
814 * @param width The size of @p value. Must be 1, 2 or 4 bytes.
816 * The exact behavior of this method is bus-specific. In the case of
817 * bcma(4), this method provides access to the first agent port of @p child.
819 * @note Device drivers should only use this API for functionality
820 * that is not available via another bhnd(4) function.
823 * @retval EINVAL If @p child is not a direct child of @p dev.
824 * @retval EINVAL If @p width is not one of 1, 2, or 4 bytes.
825 * @retval ENODEV If accessing agent/config space for @p child is unsupported.
826 * @retval EFAULT If reading @p width at @p offset exceeds the bounds of
827 * the mapped agent/config space for @p child.
829 METHOD int write_config {
835 } DEFAULT bhnd_bus_null_write_config;
838 * Allocate a bhnd resource.
840 * This method's semantics are functionally identical to the bus API of the same
841 * name; refer to BUS_ALLOC_RESOURCE for complete documentation.
843 METHOD struct bhnd_resource * alloc_resource {
852 } DEFAULT bhnd_bus_generic_alloc_resource;
855 * Release a bhnd resource.
857 * This method's semantics are functionally identical to the bus API of the same
858 * name; refer to BUS_RELEASE_RESOURCE for complete documentation.
860 METHOD int release_resource {
865 struct bhnd_resource *res;
866 } DEFAULT bhnd_bus_generic_release_resource;
869 * Activate a bhnd resource.
871 * This method's semantics are functionally identical to the bus API of the same
872 * name; refer to BUS_ACTIVATE_RESOURCE for complete documentation.
874 METHOD int activate_resource {
879 struct bhnd_resource *r;
880 } DEFAULT bhnd_bus_generic_activate_resource;
883 * Deactivate a bhnd resource.
885 * This method's semantics are functionally identical to the bus API of the same
886 * name; refer to BUS_DEACTIVATE_RESOURCE for complete documentation.
888 METHOD int deactivate_resource {
893 struct bhnd_resource *r;
894 } DEFAULT bhnd_bus_generic_deactivate_resource;
897 * Return true if @p region_num is a valid region on @p port_num of
898 * @p type attached to @p child.
900 * @param dev The device whose child is being examined.
901 * @param child The child device.
902 * @param type The port type being queried.
903 * @param port_num The port number being queried.
904 * @param region_num The region number being queried.
906 METHOD bool is_region_valid {
915 * Return the number of ports of type @p type attached to @p child.
917 * @param dev The device whose child is being examined.
918 * @param child The child device.
919 * @param type The port type being queried.
921 METHOD u_int get_port_count {
928 * Return the number of memory regions mapped to @p child @p port of
931 * @param dev The device whose child is being examined.
932 * @param child The child device.
933 * @param port The port number being queried.
934 * @param type The port type being queried.
936 METHOD u_int get_region_count {
944 * Return the SYS_RES_MEMORY resource-ID for a port/region pair attached to
947 * @param dev The bus device.
948 * @param child The bhnd child.
949 * @param port_type The port type.
950 * @param port_num The index of the child interconnect port.
951 * @param region_num The index of the port-mapped address region.
953 * @retval -1 No such port/region found.
955 METHOD int get_port_rid {
958 bhnd_port_type port_type;
961 } DEFAULT bhnd_bus_null_get_port_rid;
965 * Decode a port / region pair on @p child defined by @p type and @p rid.
967 * @param dev The bus device.
968 * @param child The bhnd child.
969 * @param type The resource type.
970 * @param rid The resource ID.
971 * @param[out] port_type The port's type.
972 * @param[out] port The port identifier.
973 * @param[out] region The identifier of the memory region on @p port.
976 * @retval non-zero No matching type/rid found.
978 METHOD int decode_port_rid {
983 bhnd_port_type *port_type;
986 } DEFAULT bhnd_bus_null_decode_port_rid;
989 * Get the address and size of @p region on @p port.
991 * @param dev The bus device.
992 * @param child The bhnd child.
993 * @param port_type The port type.
994 * @param port The port identifier.
995 * @param region The identifier of the memory region on @p port.
996 * @param[out] region_addr The region's base address.
997 * @param[out] region_size The region's size.
1000 * @retval non-zero No matching port/region found.
1002 METHOD int get_region_addr {
1005 bhnd_port_type port_type;
1008 bhnd_addr_t *region_addr;
1009 bhnd_size_t *region_size;
1010 } DEFAULT bhnd_bus_null_get_region_addr;
1013 * Read an NVRAM variable.
1015 * It is the responsibility of the bus to delegate this request to
1016 * the appropriate NVRAM child device, or to a parent bus implementation.
1018 * @param dev The bus device.
1019 * @param child The requesting device.
1020 * @param name The NVRAM variable name.
1021 * @param[out] buf On success, the requested value will be written
1022 * to this buffer. This argment may be NULL if
1023 * the value is not desired.
1024 * @param[in,out] size The capacity of @p buf. On success, will be set
1025 * to the actual size of the requested value.
1026 * @param type The data type to be written to @p buf.
1029 * @retval ENOENT The requested variable was not found.
1030 * @retval ENOMEM If @p buf is non-NULL and a buffer of @p size is too
1031 * small to hold the requested value.
1032 * @retval ENODEV No valid NVRAM source could be found.
1033 * @retval EFTYPE If the @p name's data type cannot be coerced to @p type.
1034 * @retval ERANGE If value coercion would overflow @p type.
1035 * @retval non-zero If reading @p name otherwise fails, a regular unix
1036 * error code will be returned.
1038 METHOD int get_nvram_var {
1044 bhnd_nvram_type type;
1045 } DEFAULT bhnd_bus_null_get_nvram_var;
1048 /** An implementation of bus_read_1() compatible with bhnd_resource */
1049 METHOD uint8_t read_1 {
1052 struct bhnd_resource *r;
1056 /** An implementation of bus_read_2() compatible with bhnd_resource */
1057 METHOD uint16_t read_2 {
1060 struct bhnd_resource *r;
1064 /** An implementation of bus_read_4() compatible with bhnd_resource */
1065 METHOD uint32_t read_4 {
1068 struct bhnd_resource *r;
1072 /** An implementation of bus_write_1() compatible with bhnd_resource */
1073 METHOD void write_1 {
1076 struct bhnd_resource *r;
1081 /** An implementation of bus_write_2() compatible with bhnd_resource */
1082 METHOD void write_2 {
1085 struct bhnd_resource *r;
1090 /** An implementation of bus_write_4() compatible with bhnd_resource */
1091 METHOD void write_4 {
1094 struct bhnd_resource *r;
1099 /** An implementation of bus_read_stream_1() compatible with bhnd_resource */
1100 METHOD uint8_t read_stream_1 {
1103 struct bhnd_resource *r;
1107 /** An implementation of bus_read_stream_2() compatible with bhnd_resource */
1108 METHOD uint16_t read_stream_2 {
1111 struct bhnd_resource *r;
1115 /** An implementation of bus_read_stream_4() compatible with bhnd_resource */
1116 METHOD uint32_t read_stream_4 {
1119 struct bhnd_resource *r;
1123 /** An implementation of bus_write_stream_1() compatible with bhnd_resource */
1124 METHOD void write_stream_1 {
1127 struct bhnd_resource *r;
1132 /** An implementation of bus_write_stream_2() compatible with bhnd_resource */
1133 METHOD void write_stream_2 {
1136 struct bhnd_resource *r;
1141 /** An implementation of bus_write_stream_4() compatible with bhnd_resource */
1142 METHOD void write_stream_4 {
1145 struct bhnd_resource *r;
1150 /** An implementation of bus_read_multi_1() compatible with bhnd_resource */
1151 METHOD void read_multi_1 {
1154 struct bhnd_resource *r;
1160 /** An implementation of bus_read_multi_2() compatible with bhnd_resource */
1161 METHOD void read_multi_2 {
1164 struct bhnd_resource *r;
1170 /** An implementation of bus_read_multi_4() compatible with bhnd_resource */
1171 METHOD void read_multi_4 {
1174 struct bhnd_resource *r;
1180 /** An implementation of bus_write_multi_1() compatible with bhnd_resource */
1181 METHOD void write_multi_1 {
1184 struct bhnd_resource *r;
1190 /** An implementation of bus_write_multi_2() compatible with bhnd_resource */
1191 METHOD void write_multi_2 {
1194 struct bhnd_resource *r;
1200 /** An implementation of bus_write_multi_4() compatible with bhnd_resource */
1201 METHOD void write_multi_4 {
1204 struct bhnd_resource *r;
1210 /** An implementation of bus_read_multi_stream_1() compatible
1212 METHOD void read_multi_stream_1 {
1215 struct bhnd_resource *r;
1221 /** An implementation of bus_read_multi_stream_2() compatible
1223 METHOD void read_multi_stream_2 {
1226 struct bhnd_resource *r;
1232 /** An implementation of bus_read_multi_stream_4() compatible
1234 METHOD void read_multi_stream_4 {
1237 struct bhnd_resource *r;
1243 /** An implementation of bus_write_multi_stream_1() compatible
1245 METHOD void write_multi_stream_1 {
1248 struct bhnd_resource *r;
1254 /** An implementation of bus_write_multi_stream_2() compatible with
1256 METHOD void write_multi_stream_2 {
1259 struct bhnd_resource *r;
1265 /** An implementation of bus_write_multi_stream_4() compatible with
1267 METHOD void write_multi_stream_4 {
1270 struct bhnd_resource *r;
1276 /** An implementation of bus_set_multi_1() compatible with bhnd_resource */
1277 METHOD void set_multi_1 {
1280 struct bhnd_resource *r;
1286 /** An implementation of bus_set_multi_2() compatible with bhnd_resource */
1287 METHOD void set_multi_2 {
1290 struct bhnd_resource *r;
1296 /** An implementation of bus_set_multi_4() compatible with bhnd_resource */
1297 METHOD void set_multi_4 {
1300 struct bhnd_resource *r;
1306 /** An implementation of bus_set_region_1() compatible with bhnd_resource */
1307 METHOD void set_region_1 {
1310 struct bhnd_resource *r;
1316 /** An implementation of bus_set_region_2() compatible with bhnd_resource */
1317 METHOD void set_region_2 {
1320 struct bhnd_resource *r;
1326 /** An implementation of bus_set_region_4() compatible with bhnd_resource */
1327 METHOD void set_region_4 {
1330 struct bhnd_resource *r;
1336 /** An implementation of bus_read_region_1() compatible with bhnd_resource */
1337 METHOD void read_region_1 {
1340 struct bhnd_resource *r;
1346 /** An implementation of bus_read_region_2() compatible with bhnd_resource */
1347 METHOD void read_region_2 {
1350 struct bhnd_resource *r;
1356 /** An implementation of bus_read_region_4() compatible with bhnd_resource */
1357 METHOD void read_region_4 {
1360 struct bhnd_resource *r;
1366 /** An implementation of bus_read_region_stream_1() compatible with
1368 METHOD void read_region_stream_1 {
1371 struct bhnd_resource *r;
1377 /** An implementation of bus_read_region_stream_2() compatible with
1379 METHOD void read_region_stream_2 {
1382 struct bhnd_resource *r;
1388 /** An implementation of bus_read_region_stream_4() compatible with
1390 METHOD void read_region_stream_4 {
1393 struct bhnd_resource *r;
1399 /** An implementation of bus_write_region_1() compatible with bhnd_resource */
1400 METHOD void write_region_1 {
1403 struct bhnd_resource *r;
1409 /** An implementation of bus_write_region_2() compatible with bhnd_resource */
1410 METHOD void write_region_2 {
1413 struct bhnd_resource *r;
1419 /** An implementation of bus_write_region_4() compatible with bhnd_resource */
1420 METHOD void write_region_4 {
1423 struct bhnd_resource *r;
1429 /** An implementation of bus_write_region_stream_1() compatible with
1431 METHOD void write_region_stream_1 {
1434 struct bhnd_resource *r;
1440 /** An implementation of bus_write_region_stream_2() compatible with
1442 METHOD void write_region_stream_2 {
1445 struct bhnd_resource *r;
1451 /** An implementation of bus_write_region_stream_4() compatible with
1453 METHOD void write_region_stream_4 {
1456 struct bhnd_resource *r;
1462 /** An implementation of bus_barrier() compatible with bhnd_resource */
1463 METHOD void barrier {
1466 struct bhnd_resource *r;