1*1f469a9fSEmmanuel Vadot /*- 2*1f469a9fSEmmanuel Vadot * Copyright 2016 Michal Meloun <mmel@FreeBSD.org> 3*1f469a9fSEmmanuel Vadot * All rights reserved. 4*1f469a9fSEmmanuel Vadot * 5*1f469a9fSEmmanuel Vadot * Redistribution and use in source and binary forms, with or without 6*1f469a9fSEmmanuel Vadot * modification, are permitted provided that the following conditions 7*1f469a9fSEmmanuel Vadot * are met: 8*1f469a9fSEmmanuel Vadot * 1. Redistributions of source code must retain the above copyright 9*1f469a9fSEmmanuel Vadot * notice, this list of conditions and the following disclaimer. 10*1f469a9fSEmmanuel Vadot * 2. Redistributions in binary form must reproduce the above copyright 11*1f469a9fSEmmanuel Vadot * notice, this list of conditions and the following disclaimer in the 12*1f469a9fSEmmanuel Vadot * documentation and/or other materials provided with the distribution. 13*1f469a9fSEmmanuel Vadot * 14*1f469a9fSEmmanuel Vadot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15*1f469a9fSEmmanuel Vadot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16*1f469a9fSEmmanuel Vadot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17*1f469a9fSEmmanuel Vadot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18*1f469a9fSEmmanuel Vadot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19*1f469a9fSEmmanuel Vadot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20*1f469a9fSEmmanuel Vadot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21*1f469a9fSEmmanuel Vadot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22*1f469a9fSEmmanuel Vadot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23*1f469a9fSEmmanuel Vadot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24*1f469a9fSEmmanuel Vadot */ 25*1f469a9fSEmmanuel Vadot 26*1f469a9fSEmmanuel Vadot #ifndef _DEV_HWRESET_HWRESET_H_ 27*1f469a9fSEmmanuel Vadot #define _DEV_HWRESET_HWRESET_H_ 28*1f469a9fSEmmanuel Vadot 29*1f469a9fSEmmanuel Vadot #include "opt_platform.h" 30*1f469a9fSEmmanuel Vadot #include <sys/types.h> 31*1f469a9fSEmmanuel Vadot #ifdef FDT 32*1f469a9fSEmmanuel Vadot #include <dev/ofw/ofw_bus.h> 33*1f469a9fSEmmanuel Vadot #endif 34*1f469a9fSEmmanuel Vadot 35*1f469a9fSEmmanuel Vadot typedef struct hwreset *hwreset_t; 36*1f469a9fSEmmanuel Vadot typedef struct hwreset_array *hwreset_array_t; 37*1f469a9fSEmmanuel Vadot 38*1f469a9fSEmmanuel Vadot /* 39*1f469a9fSEmmanuel Vadot * Provider interface 40*1f469a9fSEmmanuel Vadot */ 41*1f469a9fSEmmanuel Vadot #ifdef FDT 42*1f469a9fSEmmanuel Vadot void hwreset_register_ofw_provider(device_t provider_dev); 43*1f469a9fSEmmanuel Vadot void hwreset_unregister_ofw_provider(device_t provider_dev); 44*1f469a9fSEmmanuel Vadot #endif 45*1f469a9fSEmmanuel Vadot 46*1f469a9fSEmmanuel Vadot /* 47*1f469a9fSEmmanuel Vadot * Consumer interface 48*1f469a9fSEmmanuel Vadot */ 49*1f469a9fSEmmanuel Vadot int hwreset_get_by_id(device_t consumer_dev, device_t provider_dev, intptr_t id, 50*1f469a9fSEmmanuel Vadot hwreset_t *rst); 51*1f469a9fSEmmanuel Vadot void hwreset_release(hwreset_t rst); 52*1f469a9fSEmmanuel Vadot 53*1f469a9fSEmmanuel Vadot int hwreset_assert(hwreset_t rst); 54*1f469a9fSEmmanuel Vadot int hwreset_deassert(hwreset_t rst); 55*1f469a9fSEmmanuel Vadot int hwreset_is_asserted(hwreset_t rst, bool *value); 56*1f469a9fSEmmanuel Vadot 57*1f469a9fSEmmanuel Vadot #ifdef FDT 58*1f469a9fSEmmanuel Vadot int hwreset_get_by_ofw_name(device_t consumer_dev, phandle_t node, char *name, 59*1f469a9fSEmmanuel Vadot hwreset_t *rst); 60*1f469a9fSEmmanuel Vadot int hwreset_get_by_ofw_idx(device_t consumer_dev, phandle_t node, int idx, 61*1f469a9fSEmmanuel Vadot hwreset_t *rst); 62*1f469a9fSEmmanuel Vadot #endif 63*1f469a9fSEmmanuel Vadot 64*1f469a9fSEmmanuel Vadot void hwreset_array_release(hwreset_array_t rsts); 65*1f469a9fSEmmanuel Vadot int hwreset_array_assert(hwreset_array_t rsts); 66*1f469a9fSEmmanuel Vadot int hwreset_array_deassert(hwreset_array_t rsts); 67*1f469a9fSEmmanuel Vadot #ifdef FDT 68*1f469a9fSEmmanuel Vadot int hwreset_array_get_ofw(device_t consumer_dev, phandle_t cnode, 69*1f469a9fSEmmanuel Vadot hwreset_array_t *rsts); 70*1f469a9fSEmmanuel Vadot #endif 71*1f469a9fSEmmanuel Vadot 72*1f469a9fSEmmanuel Vadot 73*1f469a9fSEmmanuel Vadot #endif /* _DEV_HWRESET_HWRESET_H_ */ 74