xref: /freebsd/sys/dev/hwreset/hwreset_if.m (revision 1f469a9fc498c3d406ef7c4e347232678f49da0a)
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 AND CONTRIBUTORS ``AS IS'' AND
15*1f469a9fSEmmanuel Vadot# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*1f469a9fSEmmanuel Vadot# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*1f469a9fSEmmanuel Vadot# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*1f469a9fSEmmanuel Vadot# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*1f469a9fSEmmanuel Vadot# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*1f469a9fSEmmanuel Vadot# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*1f469a9fSEmmanuel Vadot# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*1f469a9fSEmmanuel Vadot# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*1f469a9fSEmmanuel Vadot# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*1f469a9fSEmmanuel Vadot# SUCH DAMAGE.
25*1f469a9fSEmmanuel Vadot#
26*1f469a9fSEmmanuel Vadot#
27*1f469a9fSEmmanuel Vadot
28*1f469a9fSEmmanuel Vadot#include "opt_platform.h"
29*1f469a9fSEmmanuel Vadot
30*1f469a9fSEmmanuel Vadot#ifdef FDT
31*1f469a9fSEmmanuel Vadot#include <sys/types.h>
32*1f469a9fSEmmanuel Vadot#include <dev/ofw/ofw_bus.h>
33*1f469a9fSEmmanuel Vadot#endif
34*1f469a9fSEmmanuel Vadot
35*1f469a9fSEmmanuel VadotINTERFACE hwreset;
36*1f469a9fSEmmanuel Vadot
37*1f469a9fSEmmanuel Vadot#ifdef FDT
38*1f469a9fSEmmanuel VadotHEADER {
39*1f469a9fSEmmanuel Vadotint hwreset_default_ofw_map(device_t , phandle_t, int, pcell_t *, intptr_t *);
40*1f469a9fSEmmanuel Vadot}
41*1f469a9fSEmmanuel Vadot
42*1f469a9fSEmmanuel Vadot#
43*1f469a9fSEmmanuel Vadot# map fdt property cells to reset id
44*1f469a9fSEmmanuel Vadot# Returns 0 on success or a standard errno value.
45*1f469a9fSEmmanuel Vadot#
46*1f469a9fSEmmanuel VadotMETHOD int map {
47*1f469a9fSEmmanuel Vadot	device_t	provider_dev;
48*1f469a9fSEmmanuel Vadot	phandle_t	xref;
49*1f469a9fSEmmanuel Vadot	int		ncells;
50*1f469a9fSEmmanuel Vadot	pcell_t		*cells;
51*1f469a9fSEmmanuel Vadot	intptr_t	*id;
52*1f469a9fSEmmanuel Vadot} DEFAULT hwreset_default_ofw_map;
53*1f469a9fSEmmanuel Vadot#endif
54*1f469a9fSEmmanuel Vadot
55*1f469a9fSEmmanuel Vadot#
56*1f469a9fSEmmanuel Vadot# Assert/deassert given reset.
57*1f469a9fSEmmanuel Vadot# Returns 0 on success or a standard errno value.
58*1f469a9fSEmmanuel Vadot#
59*1f469a9fSEmmanuel VadotMETHOD int assert {
60*1f469a9fSEmmanuel Vadot	device_t	provider_dev;
61*1f469a9fSEmmanuel Vadot	intptr_t	id;
62*1f469a9fSEmmanuel Vadot	bool		value;
63*1f469a9fSEmmanuel Vadot};
64*1f469a9fSEmmanuel Vadot
65*1f469a9fSEmmanuel Vadot#
66*1f469a9fSEmmanuel Vadot# Get actual status of given reset.
67*1f469a9fSEmmanuel Vadot# Returns 0 on success or a standard errno value.
68*1f469a9fSEmmanuel Vadot#
69*1f469a9fSEmmanuel VadotMETHOD int is_asserted {
70*1f469a9fSEmmanuel Vadot	device_t	provider_dev;
71*1f469a9fSEmmanuel Vadot	intptr_t	id;
72*1f469a9fSEmmanuel Vadot	bool		*value;
73*1f469a9fSEmmanuel Vadot};
74