2 # Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
3 # Copyright (c) 2017 The FreeBSD Foundation
6 # Portions of this software were developed by Landon Fuller
7 # under sponsorship from the FreeBSD Foundation.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
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.
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.
31 #include <sys/types.h>
35 #include <dev/bhnd/bhnd_types.h>
36 #include <dev/bhnd/bhnd_erom_types.h>
41 # bhnd(4) bus interface
45 /* forward declarations */
46 struct bhnd_board_info;
47 struct bhnd_core_info;
49 struct bhnd_dma_translation;
55 #include <sys/systm.h>
57 #include <dev/bhnd/bhndvar.h>
59 static bhnd_erom_class_t *
60 bhnd_bus_null_get_erom_class(driver_t *driver)
65 static struct bhnd_chipid *
66 bhnd_bus_null_get_chipid(device_t dev, device_t child)
68 panic("bhnd_bus_get_chipid unimplemented");
72 bhnd_bus_null_read_ioctl(device_t dev, device_t child, uint16_t *ioctl)
74 panic("bhnd_bus_read_ioctl unimplemented");
79 bhnd_bus_null_write_ioctl(device_t dev, device_t child, uint16_t value,
82 panic("bhnd_bus_write_ioctl unimplemented");
87 bhnd_bus_null_read_iost(device_t dev, device_t child, uint16_t *iost)
89 panic("bhnd_bus_read_iost unimplemented");
93 bhnd_bus_null_is_hw_suspended(device_t dev, device_t child)
95 panic("bhnd_bus_is_hw_suspended unimplemented");
99 bhnd_bus_null_reset_hw(device_t dev, device_t child, uint16_t ioctl,
100 uint16_t reset_ioctl)
102 panic("bhnd_bus_reset_hw unimplemented");
107 bhnd_bus_null_suspend_hw(device_t dev, device_t child)
109 panic("bhnd_bus_suspend_hw unimplemented");
112 static bhnd_attach_type
113 bhnd_bus_null_get_attach_type(device_t dev, device_t child)
115 panic("bhnd_bus_get_attach_type unimplemented");
119 bhnd_bus_null_read_board_info(device_t dev, device_t child,
120 struct bhnd_board_info *info)
122 panic("bhnd_bus_read_boardinfo unimplemented");
126 bhnd_bus_null_child_added(device_t dev, device_t child)
131 bhnd_bus_null_alloc_pmu(device_t dev, device_t child)
133 panic("bhnd_bus_alloc_pmu unimplemented");
137 bhnd_bus_null_release_pmu(device_t dev, device_t child)
139 panic("bhnd_bus_release_pmu unimplemented");
143 bhnd_bus_null_get_clock_latency(device_t dev, device_t child,
144 bhnd_clock clock, u_int *latency)
146 panic("bhnd_pmu_get_clock_latency unimplemented");
150 bhnd_bus_null_get_clock_freq(device_t dev, device_t child,
151 bhnd_clock clock, u_int *freq)
153 panic("bhnd_pmu_get_clock_freq unimplemented");
157 bhnd_bus_null_request_clock(device_t dev, device_t child,
160 panic("bhnd_bus_request_clock unimplemented");
164 bhnd_bus_null_enable_clocks(device_t dev, device_t child,
167 panic("bhnd_bus_enable_clocks unimplemented");
171 bhnd_bus_null_request_ext_rsrc(device_t dev, device_t child,
174 panic("bhnd_bus_request_ext_rsrc unimplemented");
178 bhnd_bus_null_release_ext_rsrc(device_t dev, device_t child,
181 panic("bhnd_bus_release_ext_rsrc unimplemented");
185 bhnd_bus_null_read_config(device_t dev, device_t child,
186 bus_size_t offset, void *value, u_int width)
188 panic("bhnd_bus_null_read_config unimplemented");
192 bhnd_bus_null_write_config(device_t dev, device_t child,
193 bus_size_t offset, void *value, u_int width)
195 panic("bhnd_bus_null_write_config unimplemented");
199 bhnd_bus_null_find_hostb_device(device_t dev)
204 static struct bhnd_service_registry *
205 bhnd_bus_null_get_service_registry(device_t dev)
207 panic("bhnd_bus_get_service_registry unimplemented");
211 bhnd_bus_null_is_hw_disabled(device_t dev, device_t child)
213 panic("bhnd_bus_is_hw_disabled unimplemented");
217 bhnd_bus_null_get_probe_order(device_t dev, device_t child)
219 panic("bhnd_bus_get_probe_order unimplemented");
223 bhnd_bus_null_get_intr_domain(device_t dev, device_t child, bool self)
230 bhnd_bus_null_get_intr_count(device_t dev, device_t child)
236 bhnd_bus_null_get_intr_ivec(device_t dev, device_t child, u_int intr,
239 panic("bhnd_bus_get_intr_ivec unimplemented");
243 bhnd_bus_null_map_intr(device_t dev, device_t child, u_int intr,
246 panic("bhnd_bus_map_intr unimplemented");
250 bhnd_bus_null_unmap_intr(device_t dev, device_t child, rman_res_t irq)
252 panic("bhnd_bus_unmap_intr unimplemented");
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)
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)
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,
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)
287 * Return the bhnd(4) bus driver's device enumeration parser class.
289 * @param driver The bhnd bus driver instance.
291 STATICMETHOD bhnd_erom_class_t * get_erom_class {
293 } DEFAULT bhnd_bus_null_get_erom_class;
296 * Register a shared bus @p provider for a given @p service.
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.
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.
308 METHOD int register_provider {
312 bhnd_service_t service;
313 } DEFAULT bhnd_bus_generic_register_provider;
316 * Attempt to remove the @p service provider registration for @p provider.
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.
326 * @retval EBUSY if active references to @p provider exist; @see
327 * BHND_BUS_RETAIN_PROVIDER() and
328 * BHND_BUS_RELEASE_PROVIDER().
330 METHOD int deregister_provider {
334 bhnd_service_t service;
335 } DEFAULT bhnd_bus_generic_deregister_provider;
338 * Retain and return a reference to the registered @p service provider, if any.
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.
344 * On success, the caller assumes ownership the returned provider, and
345 * is responsible for releasing this reference via
346 * BHND_BUS_RELEASE_PROVIDER().
348 * @retval device_t success
349 * @retval NULL if no provider is registered for @p service.
351 METHOD device_t retain_provider {
354 bhnd_service_t service;
355 } DEFAULT bhnd_bus_generic_retain_provider;
358 * Release a reference to a service provider previously returned by
359 * BHND_BUS_RETAIN_PROVIDER().
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
367 METHOD void release_provider {
371 bhnd_service_t service;
372 } DEFAULT bhnd_bus_generic_release_provider;
375 * Return a struct bhnd_service_registry.
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.
381 * @param dev The parent of @p child.
382 * @param child The requesting child device.
384 METHOD struct bhnd_service_registry * get_service_registry {
387 } DEFAULT bhnd_bus_null_get_service_registry;
390 * Return the active host bridge core for the bhnd bus, if any.
392 * @param dev The bhnd bus device.
394 * @retval device_t if a hostb device exists
395 * @retval NULL if no hostb device is found.
397 METHOD device_t find_hostb_device {
399 } DEFAULT bhnd_bus_null_find_hostb_device;
402 * Return true if the hardware components required by @p child are unpopulated
403 * or otherwise unusable.
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
410 * @param dev The device whose child is being examined.
411 * @param child The child device.
413 METHOD bool is_hw_disabled {
416 } DEFAULT bhnd_bus_null_is_hw_disabled;
419 * Return the probe (and attach) order for @p child.
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
425 * The following device methods will be dispatched in ascending probe order
432 * The following device methods will be dispatched in descending probe order
435 * - DEVICE_SHUTDOWN()
439 * @param dev The device whose child is being examined.
440 * @param child The child device.
442 * Refer to BHND_PROBE_* and BHND_PROBE_ORDER_* for the standard set of
445 METHOD int get_probe_order {
448 } DEFAULT bhnd_bus_null_get_probe_order;
451 * Return the BHND chip identification for the parent bus.
453 * @param dev The device whose child is being examined.
454 * @param child The child device.
456 METHOD const struct bhnd_chipid * get_chipid {
459 } DEFAULT bhnd_bus_null_get_chipid;
462 * Return the BHND attachment type of the parent bus.
464 * @param dev The device whose child is being examined.
465 * @param child The child device.
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.
472 METHOD bhnd_attach_type get_attach_type {
475 } DEFAULT bhnd_bus_null_get_attach_type;
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
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.
497 * @retval ENODEV If DMA is not supported.
498 * @retval ENOENT If no DMA translation matching @p width and @p flags is
500 * @retval non-zero If determining the DMA address translation for @p child
501 * otherwise fails, a regular unix error code will be returned.
503 METHOD int get_dma_translation {
509 struct bhnd_dma_translation *translation;
510 } DEFAULT bhnd_bus_generic_get_dma_translation;
513 * Attempt to read the BHND board identification from the parent bus.
515 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot
516 * be found, or is not yet attached.
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
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.
528 METHOD int read_board_info {
531 struct bhnd_board_info *info;
532 } DEFAULT bhnd_bus_null_read_board_info;
535 * Notify a bhnd bus that a child was added.
537 * This method must be called by concrete bhnd(4) driver impementations
538 * after @p child's bus state is fully initialized.
540 * @param dev The bhnd bus whose child is being added.
541 * @param child The child added to @p dev.
543 METHOD void child_added {
546 } DEFAULT bhnd_bus_null_child_added;
549 * Read the current value of @p child's I/O control register.
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
554 * @param[out] ioctl On success, the I/O control register value.
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.
562 METHOD int read_ioctl {
566 } DEFAULT bhnd_bus_null_read_ioctl;
569 * Write @p value with @p mask to @p child's I/O control register.
571 * @param dev The bhnd bus parent of @p child.
572 * @param child The bhnd device for which the I/O control register should
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.
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.
583 METHOD int write_ioctl {
588 } DEFAULT bhnd_bus_null_write_ioctl;
591 * Read the current value of @p child's I/O status register.
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
596 * @param[out] iost On success, the I/O status register value.
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.
604 METHOD int read_iost {
608 } DEFAULT bhnd_bus_null_read_iost;
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).
615 * @param dev The bhnd bus parent of @p child.
616 * @param child The device to query.
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.
622 METHOD bool is_hw_suspended {
625 } DEFAULT bhnd_bus_null_is_hw_suspended;
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.
632 * Any clock or resource PMU requests previously made by @p child will be
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.
643 * @retval non-zero error
645 METHOD int reset_hw {
649 uint16_t reset_ioctl;
650 } DEFAULT bhnd_bus_null_reset_hw;
653 * Suspend @p child's hardware in a low-power RESET state.
655 * Any clock or resource PMU requests previously made by @p dev will be
658 * The hardware may be brought out of RESET via bhnd_reset_hw().
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_*).
666 * @retval non-zero error
668 METHOD int suspend_hw {
672 } DEFAULT bhnd_bus_null_suspend_hw;
675 * Allocate per-core PMU resources and enable PMU request handling for @p child.
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().
682 * @param dev The parent of @p child.
683 * @param child The requesting bhnd device.
686 * @retval non-zero if enabling per-core PMU request handling fails, a
687 * regular unix error code will be returned.
689 METHOD int alloc_pmu {
692 } DEFAULT bhnd_bus_null_alloc_pmu;
695 * Release per-core PMU resources allocated for @p child. Any
696 * outstanding PMU requests are discarded.
698 * @param dev The parent of @p child.
699 * @param child The requesting bhnd device.
701 METHOD int release_pmu {
704 } DEFAULT bhnd_bus_null_release_pmu;
707 * Return the transition latency required for @p clock in microseconds, if
710 * The BHND_CLOCK_HT latency value is suitable for use as the D11 core's
711 * 'fastpwrup_dly' value.
713 * @note A driver must ask the bhnd bus to allocate PMU request state
714 * via BHND_BUS_ALLOC_PMU() before querying PMU clocks.
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
723 * @retval ENODEV If the transition latency for @p clock is not available.
725 METHOD int get_clock_latency {
730 } DEFAULT bhnd_bus_null_get_clock_latency;
733 * Return the frequency for @p clock in Hz, if known.
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.
740 * @note A driver must ask the bhnd bus to allocate PMU request state
741 * via BHND_BUS_ALLOC_PMU() before querying PMU clocks.
744 * @retval ENODEV If the frequency for @p clock is not available.
746 METHOD int get_clock_freq {
751 } DEFAULT bhnd_bus_null_get_clock_freq;
754 * Request that @p clock (or faster) be routed to @p child.
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.
759 * @note Any outstanding PMU clock requests will be discarded upon calling
760 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
762 * @param dev The parent of @p child.
763 * @param child The bhnd device requesting @p clock.
764 * @param clock The requested clock source.
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.
772 METHOD int request_clock {
776 } DEFAULT bhnd_bus_null_request_clock;
779 * Request that @p clocks be powered on behalf of @p child.
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.
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.
788 * @note Any outstanding PMU clock requests will be discarded upon calling
789 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
791 * @param dev The parent of @p child.
792 * @param child The bhnd device requesting @p clock.
793 * @param clock The requested clock source.
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.
801 METHOD int enable_clocks {
805 } DEFAULT bhnd_bus_null_enable_clocks;
808 * Power up an external PMU-managed resource assigned to @p child.
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.
813 * @note Any outstanding PMU resource requests will be released upon calling
814 * BHND_BUS_RESET_HW() or BHND_BUS_SUSPEND_HW().
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.
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.
826 METHOD int request_ext_rsrc {
830 } DEFAULT bhnd_bus_null_request_ext_rsrc;
833 * Power down an external PMU-managed resource assigned to @p child.
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.
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.
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.
848 METHOD int release_ext_rsrc {
852 } DEFAULT bhnd_bus_null_release_ext_rsrc;
855 * Read @p width bytes at @p offset from the bus-specific agent/config
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.
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.
868 * @note Device drivers should only use this API for functionality
869 * that is not available via another bhnd(4) function.
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.
878 METHOD int read_config {
884 } DEFAULT bhnd_bus_null_read_config;
887 * Read @p width bytes at @p offset from the bus-specific agent/config
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.
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.
899 * @note Device drivers should only use this API for functionality
900 * that is not available via another bhnd(4) function.
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.
909 METHOD int write_config {
915 } DEFAULT bhnd_bus_null_write_config;
918 * Allocate a bhnd resource.
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.
923 METHOD struct bhnd_resource * alloc_resource {
932 } DEFAULT bhnd_bus_generic_alloc_resource;
935 * Release a bhnd resource.
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.
940 METHOD int release_resource {
945 struct bhnd_resource *res;
946 } DEFAULT bhnd_bus_generic_release_resource;
949 * Activate a bhnd resource.
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.
954 METHOD int activate_resource {
959 struct bhnd_resource *r;
960 } DEFAULT bhnd_bus_generic_activate_resource;
963 * Deactivate a bhnd resource.
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.
968 METHOD int deactivate_resource {
973 struct bhnd_resource *r;
974 } DEFAULT bhnd_bus_generic_deactivate_resource;
977 * Return the interrupt domain.
979 * This globally unique value may be used as the interrupt controller 'xref'
980 * on targets that support INTRNG.
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.
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.
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.
996 METHOD uintptr_t get_intr_domain {
1000 } DEFAULT bhnd_bus_null_get_intr_domain;
1003 * Return the number of interrupt lines assigned to @p child.
1005 * @param dev The bhnd device whose child is being examined.
1006 * @param child The child device.
1008 METHOD u_int get_intr_count {
1011 } DEFAULT bhnd_bus_null_get_intr_count;
1014 * Get the backplane interrupt vector of the @p intr line attached to @p child.
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.
1022 * On bcma(4) devices, this returns the OOB bus line assigned to the
1025 * On siba(4) devices, this returns the target OCP slave flag number assigned
1029 * @retval ENXIO If @p intr exceeds the number of interrupt lines
1030 * assigned to @p child.
1032 METHOD int get_intr_ivec {
1037 } DEFAULT bhnd_bus_null_get_intr_ivec;
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.
1043 * On success, the caller assumes ownership of the interrupt mapping, and
1044 * is responsible for releasing the mapping via BHND_BUS_UNMAP_INTR().
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.
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.
1055 METHOD int map_intr {
1060 } DEFAULT bhnd_bus_null_map_intr;
1063 * Unmap an bus interrupt previously mapped via BHND_BUS_MAP_INTR().
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.
1070 METHOD void unmap_intr {
1074 } DEFAULT bhnd_bus_null_unmap_intr;
1077 * Return true if @p region_num is a valid region on @p port_num of
1078 * @p type attached to @p child.
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.
1086 METHOD bool is_region_valid {
1089 bhnd_port_type type;
1095 * Return the number of ports of type @p type attached to @p child.
1097 * @param dev The device whose child is being examined.
1098 * @param child The child device.
1099 * @param type The port type being queried.
1101 METHOD u_int get_port_count {
1104 bhnd_port_type type;
1108 * Return the number of memory regions mapped to @p child @p port of
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.
1116 METHOD u_int get_region_count {
1119 bhnd_port_type type;
1124 * Return the SYS_RES_MEMORY resource-ID for a port/region pair attached to
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.
1133 * @retval -1 No such port/region found.
1135 METHOD int get_port_rid {
1138 bhnd_port_type port_type;
1141 } DEFAULT bhnd_bus_null_get_port_rid;
1145 * Decode a port / region pair on @p child defined by @p type and @p rid.
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.
1156 * @retval non-zero No matching type/rid found.
1158 METHOD int decode_port_rid {
1163 bhnd_port_type *port_type;
1166 } DEFAULT bhnd_bus_null_decode_port_rid;
1169 * Get the address and size of @p region on @p port.
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.
1180 * @retval non-zero No matching port/region found.
1182 METHOD int get_region_addr {
1185 bhnd_port_type port_type;
1188 bhnd_addr_t *region_addr;
1189 bhnd_size_t *region_size;
1190 } DEFAULT bhnd_bus_null_get_region_addr;
1193 * Read an NVRAM variable.
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.
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.
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.
1218 METHOD int get_nvram_var {
1224 bhnd_nvram_type type;
1225 } DEFAULT bhnd_bus_null_get_nvram_var;
1228 /** An implementation of bus_read_1() compatible with bhnd_resource */
1229 METHOD uint8_t read_1 {
1232 struct bhnd_resource *r;
1236 /** An implementation of bus_read_2() compatible with bhnd_resource */
1237 METHOD uint16_t read_2 {
1240 struct bhnd_resource *r;
1244 /** An implementation of bus_read_4() compatible with bhnd_resource */
1245 METHOD uint32_t read_4 {
1248 struct bhnd_resource *r;
1252 /** An implementation of bus_write_1() compatible with bhnd_resource */
1253 METHOD void write_1 {
1256 struct bhnd_resource *r;
1261 /** An implementation of bus_write_2() compatible with bhnd_resource */
1262 METHOD void write_2 {
1265 struct bhnd_resource *r;
1270 /** An implementation of bus_write_4() compatible with bhnd_resource */
1271 METHOD void write_4 {
1274 struct bhnd_resource *r;
1279 /** An implementation of bus_read_stream_1() compatible with bhnd_resource */
1280 METHOD uint8_t read_stream_1 {
1283 struct bhnd_resource *r;
1287 /** An implementation of bus_read_stream_2() compatible with bhnd_resource */
1288 METHOD uint16_t read_stream_2 {
1291 struct bhnd_resource *r;
1295 /** An implementation of bus_read_stream_4() compatible with bhnd_resource */
1296 METHOD uint32_t read_stream_4 {
1299 struct bhnd_resource *r;
1303 /** An implementation of bus_write_stream_1() compatible with bhnd_resource */
1304 METHOD void write_stream_1 {
1307 struct bhnd_resource *r;
1312 /** An implementation of bus_write_stream_2() compatible with bhnd_resource */
1313 METHOD void write_stream_2 {
1316 struct bhnd_resource *r;
1321 /** An implementation of bus_write_stream_4() compatible with bhnd_resource */
1322 METHOD void write_stream_4 {
1325 struct bhnd_resource *r;
1330 /** An implementation of bus_read_multi_1() compatible with bhnd_resource */
1331 METHOD void read_multi_1 {
1334 struct bhnd_resource *r;
1340 /** An implementation of bus_read_multi_2() compatible with bhnd_resource */
1341 METHOD void read_multi_2 {
1344 struct bhnd_resource *r;
1350 /** An implementation of bus_read_multi_4() compatible with bhnd_resource */
1351 METHOD void read_multi_4 {
1354 struct bhnd_resource *r;
1360 /** An implementation of bus_write_multi_1() compatible with bhnd_resource */
1361 METHOD void write_multi_1 {
1364 struct bhnd_resource *r;
1370 /** An implementation of bus_write_multi_2() compatible with bhnd_resource */
1371 METHOD void write_multi_2 {
1374 struct bhnd_resource *r;
1380 /** An implementation of bus_write_multi_4() compatible with bhnd_resource */
1381 METHOD void write_multi_4 {
1384 struct bhnd_resource *r;
1390 /** An implementation of bus_read_multi_stream_1() compatible
1392 METHOD void read_multi_stream_1 {
1395 struct bhnd_resource *r;
1401 /** An implementation of bus_read_multi_stream_2() compatible
1403 METHOD void read_multi_stream_2 {
1406 struct bhnd_resource *r;
1412 /** An implementation of bus_read_multi_stream_4() compatible
1414 METHOD void read_multi_stream_4 {
1417 struct bhnd_resource *r;
1423 /** An implementation of bus_write_multi_stream_1() compatible
1425 METHOD void write_multi_stream_1 {
1428 struct bhnd_resource *r;
1434 /** An implementation of bus_write_multi_stream_2() compatible with
1436 METHOD void write_multi_stream_2 {
1439 struct bhnd_resource *r;
1445 /** An implementation of bus_write_multi_stream_4() compatible with
1447 METHOD void write_multi_stream_4 {
1450 struct bhnd_resource *r;
1456 /** An implementation of bus_set_multi_1() compatible with bhnd_resource */
1457 METHOD void set_multi_1 {
1460 struct bhnd_resource *r;
1466 /** An implementation of bus_set_multi_2() compatible with bhnd_resource */
1467 METHOD void set_multi_2 {
1470 struct bhnd_resource *r;
1476 /** An implementation of bus_set_multi_4() compatible with bhnd_resource */
1477 METHOD void set_multi_4 {
1480 struct bhnd_resource *r;
1486 /** An implementation of bus_set_region_1() compatible with bhnd_resource */
1487 METHOD void set_region_1 {
1490 struct bhnd_resource *r;
1496 /** An implementation of bus_set_region_2() compatible with bhnd_resource */
1497 METHOD void set_region_2 {
1500 struct bhnd_resource *r;
1506 /** An implementation of bus_set_region_4() compatible with bhnd_resource */
1507 METHOD void set_region_4 {
1510 struct bhnd_resource *r;
1516 /** An implementation of bus_read_region_1() compatible with bhnd_resource */
1517 METHOD void read_region_1 {
1520 struct bhnd_resource *r;
1526 /** An implementation of bus_read_region_2() compatible with bhnd_resource */
1527 METHOD void read_region_2 {
1530 struct bhnd_resource *r;
1536 /** An implementation of bus_read_region_4() compatible with bhnd_resource */
1537 METHOD void read_region_4 {
1540 struct bhnd_resource *r;
1546 /** An implementation of bus_read_region_stream_1() compatible with
1548 METHOD void read_region_stream_1 {
1551 struct bhnd_resource *r;
1557 /** An implementation of bus_read_region_stream_2() compatible with
1559 METHOD void read_region_stream_2 {
1562 struct bhnd_resource *r;
1568 /** An implementation of bus_read_region_stream_4() compatible with
1570 METHOD void read_region_stream_4 {
1573 struct bhnd_resource *r;
1579 /** An implementation of bus_write_region_1() compatible with bhnd_resource */
1580 METHOD void write_region_1 {
1583 struct bhnd_resource *r;
1589 /** An implementation of bus_write_region_2() compatible with bhnd_resource */
1590 METHOD void write_region_2 {
1593 struct bhnd_resource *r;
1599 /** An implementation of bus_write_region_4() compatible with bhnd_resource */
1600 METHOD void write_region_4 {
1603 struct bhnd_resource *r;
1609 /** An implementation of bus_write_region_stream_1() compatible with
1611 METHOD void write_region_stream_1 {
1614 struct bhnd_resource *r;
1620 /** An implementation of bus_write_region_stream_2() compatible with
1622 METHOD void write_region_stream_2 {
1625 struct bhnd_resource *r;
1631 /** An implementation of bus_write_region_stream_4() compatible with
1633 METHOD void write_region_stream_4 {
1636 struct bhnd_resource *r;
1642 /** An implementation of bus_barrier() compatible with bhnd_resource */
1643 METHOD void barrier {
1646 struct bhnd_resource *r;