14ad7e9b0SAdrian Chadd /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 36e778a7eSPedro F. Giffuni * 4f90f4b65SLandon J. Fuller * Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org> 58e35bf83SLandon J. Fuller * Copyright (c) 2017 The FreeBSD Foundation 64ad7e9b0SAdrian Chadd * All rights reserved. 74ad7e9b0SAdrian Chadd * 88e35bf83SLandon J. Fuller * Portions of this software were developed by Landon Fuller 98e35bf83SLandon J. Fuller * under sponsorship from the FreeBSD Foundation. 108e35bf83SLandon J. Fuller * 114ad7e9b0SAdrian Chadd * Redistribution and use in source and binary forms, with or without 124ad7e9b0SAdrian Chadd * modification, are permitted provided that the following conditions 134ad7e9b0SAdrian Chadd * are met: 144ad7e9b0SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 154ad7e9b0SAdrian Chadd * notice, this list of conditions and the following disclaimer, 164ad7e9b0SAdrian Chadd * without modification. 174ad7e9b0SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer 184ad7e9b0SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 194ad7e9b0SAdrian Chadd * redistribution must be conditioned upon including a substantially 204ad7e9b0SAdrian Chadd * similar Disclaimer requirement for further binary redistribution. 214ad7e9b0SAdrian Chadd * 224ad7e9b0SAdrian Chadd * NO WARRANTY 234ad7e9b0SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 244ad7e9b0SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 254ad7e9b0SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 264ad7e9b0SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 274ad7e9b0SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 284ad7e9b0SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 294ad7e9b0SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 304ad7e9b0SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 314ad7e9b0SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 324ad7e9b0SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 334ad7e9b0SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES. 344ad7e9b0SAdrian Chadd * 354ad7e9b0SAdrian Chadd */ 364ad7e9b0SAdrian Chadd 374ad7e9b0SAdrian Chadd #ifndef _BHND_BHNDVAR_H_ 384ad7e9b0SAdrian Chadd #define _BHND_BHNDVAR_H_ 394ad7e9b0SAdrian Chadd 404ad7e9b0SAdrian Chadd #include <sys/param.h> 414ad7e9b0SAdrian Chadd #include <sys/bus.h> 424ad7e9b0SAdrian Chadd #include <sys/malloc.h> 434ad7e9b0SAdrian Chadd 444ad7e9b0SAdrian Chadd #include "bhnd.h" 454ad7e9b0SAdrian Chadd 464ad7e9b0SAdrian Chadd /* 474ad7e9b0SAdrian Chadd * Definitions shared by bhnd(4) bus and bhndb(4) bridge driver implementations. 484ad7e9b0SAdrian Chadd */ 494ad7e9b0SAdrian Chadd 504ad7e9b0SAdrian Chadd MALLOC_DECLARE(M_BHND); 514ad7e9b0SAdrian Chadd DECLARE_CLASS(bhnd_driver); 524ad7e9b0SAdrian Chadd 534e96bf3aSLandon J. Fuller struct bhnd_core_clkctl; 544e96bf3aSLandon J. Fuller 554e96bf3aSLandon J. Fuller struct bhnd_core_clkctl *bhnd_alloc_core_clkctl(device_t dev, 564e96bf3aSLandon J. Fuller device_t pmu_dev, struct bhnd_resource *r, 574e96bf3aSLandon J. Fuller bus_size_t offset, u_int max_latency); 584e96bf3aSLandon J. Fuller void bhnd_free_core_clkctl( 594e96bf3aSLandon J. Fuller struct bhnd_core_clkctl *clkctl); 604e96bf3aSLandon J. Fuller int bhnd_core_clkctl_wait( 614e96bf3aSLandon J. Fuller struct bhnd_core_clkctl *clkctl, 624e96bf3aSLandon J. Fuller uint32_t value, uint32_t mask); 634e96bf3aSLandon J. Fuller 644ad7e9b0SAdrian Chadd int bhnd_generic_attach(device_t dev); 654ad7e9b0SAdrian Chadd int bhnd_generic_detach(device_t dev); 664ad7e9b0SAdrian Chadd int bhnd_generic_shutdown(device_t dev); 674ad7e9b0SAdrian Chadd int bhnd_generic_resume(device_t dev); 684ad7e9b0SAdrian Chadd int bhnd_generic_suspend(device_t dev); 694ad7e9b0SAdrian Chadd 704ad7e9b0SAdrian Chadd int bhnd_generic_get_probe_order(device_t dev, 714ad7e9b0SAdrian Chadd device_t child); 724ad7e9b0SAdrian Chadd 73f90f4b65SLandon J. Fuller int bhnd_generic_alloc_pmu(device_t dev, 74f90f4b65SLandon J. Fuller device_t child); 75f90f4b65SLandon J. Fuller int bhnd_generic_release_pmu(device_t dev, 76f90f4b65SLandon J. Fuller device_t child); 774e96bf3aSLandon J. Fuller int bhnd_generic_get_clock_latency(device_t dev, 784e96bf3aSLandon J. Fuller device_t child, bhnd_clock clock, 794e96bf3aSLandon J. Fuller u_int *latency); 804e96bf3aSLandon J. Fuller int bhnd_generic_get_clock_freq(device_t dev, 814e96bf3aSLandon J. Fuller device_t child, bhnd_clock clock, 824e96bf3aSLandon J. Fuller u_int *freq); 83f90f4b65SLandon J. Fuller int bhnd_generic_request_clock(device_t dev, 84f90f4b65SLandon J. Fuller device_t child, bhnd_clock clock); 85f90f4b65SLandon J. Fuller int bhnd_generic_enable_clocks(device_t dev, 86f90f4b65SLandon J. Fuller device_t child, uint32_t clocks); 87f90f4b65SLandon J. Fuller int bhnd_generic_request_ext_rsrc(device_t dev, 88f90f4b65SLandon J. Fuller device_t child, u_int rsrc); 89f90f4b65SLandon J. Fuller int bhnd_generic_release_ext_rsrc(device_t dev, 90f90f4b65SLandon J. Fuller device_t child, u_int rsrc); 91f90f4b65SLandon J. Fuller 924ad7e9b0SAdrian Chadd int bhnd_generic_print_child(device_t dev, 934ad7e9b0SAdrian Chadd device_t child); 944ad7e9b0SAdrian Chadd void bhnd_generic_probe_nomatch(device_t dev, 954ad7e9b0SAdrian Chadd device_t child); 964ad7e9b0SAdrian Chadd 97688fc8c0SLandon J. Fuller void bhnd_generic_child_deleted(device_t dev, 98688fc8c0SLandon J. Fuller device_t child); 994ad7e9b0SAdrian Chadd int bhnd_generic_suspend_child(device_t dev, 1004ad7e9b0SAdrian Chadd device_t child); 1014ad7e9b0SAdrian Chadd int bhnd_generic_resume_child(device_t dev, 1024ad7e9b0SAdrian Chadd device_t child); 1034ad7e9b0SAdrian Chadd 104caeff9a3SLandon J. Fuller int bhnd_generic_setup_intr(device_t dev, 105caeff9a3SLandon J. Fuller device_t child, struct resource *irq, 106caeff9a3SLandon J. Fuller int flags, driver_filter_t *filter, 107caeff9a3SLandon J. Fuller driver_intr_t *intr, void *arg, 108caeff9a3SLandon J. Fuller void **cookiep); 109caeff9a3SLandon J. Fuller 110fdedcd9fSLandon J. Fuller int bhnd_generic_get_nvram_var(device_t dev, 1118e35bf83SLandon J. Fuller device_t child, const char *name, 1128e35bf83SLandon J. Fuller void *buf, size_t *size, 1138e35bf83SLandon J. Fuller bhnd_nvram_type type); 114fdedcd9fSLandon J. Fuller 115f90f4b65SLandon J. Fuller /** 116f90f4b65SLandon J. Fuller * bhnd driver instance state. Must be first member of all subclass 117f90f4b65SLandon J. Fuller * softc structures. 118f90f4b65SLandon J. Fuller */ 119f90f4b65SLandon J. Fuller struct bhnd_softc { 120f90f4b65SLandon J. Fuller device_t dev; /**< bus device */ 121f90f4b65SLandon J. Fuller }; 122f90f4b65SLandon J. Fuller 1234ad7e9b0SAdrian Chadd #endif /* _BHND_BHNDVAR_H_ */ 124