xref: /freebsd/sys/dev/mmc/mmc_fdt_helpers.h (revision 8a8166e5bcfb50e2b7280581b600d098fa6c9fc7)
1e63fbd7bSEmmanuel Vadot /*
2e63fbd7bSEmmanuel Vadot  * Copyright 2019 Emmanuel Vadot <manu@freebsd.org>
3e63fbd7bSEmmanuel Vadot  * Copyright (c) 2017 Ian Lepore <ian@freebsd.org> All rights reserved.
4e63fbd7bSEmmanuel Vadot  *
5e63fbd7bSEmmanuel Vadot  * Redistribution and use in source and binary forms, with or without
6e63fbd7bSEmmanuel Vadot  * modification, are permitted provided that the following conditions are
7e63fbd7bSEmmanuel Vadot  * met:
8e63fbd7bSEmmanuel Vadot  *
9e63fbd7bSEmmanuel Vadot  *  1. Redistributions of source code must retain the above copyright
10e63fbd7bSEmmanuel Vadot  *     notice, this list of conditions and the following disclaimer.
11e63fbd7bSEmmanuel Vadot  *  2. Redistributions in binary form must reproduce the above copyright
12e63fbd7bSEmmanuel Vadot  *     notice, this list of conditions and the following disclaimer in the
13e63fbd7bSEmmanuel Vadot  *     documentation and/or other materials provided with the distribution.
14e63fbd7bSEmmanuel Vadot  *
15e63fbd7bSEmmanuel Vadot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16e63fbd7bSEmmanuel Vadot  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17e63fbd7bSEmmanuel Vadot  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18e63fbd7bSEmmanuel Vadot  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
19e63fbd7bSEmmanuel Vadot  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20e63fbd7bSEmmanuel Vadot  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21e63fbd7bSEmmanuel Vadot  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22e63fbd7bSEmmanuel Vadot  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23e63fbd7bSEmmanuel Vadot  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24e63fbd7bSEmmanuel Vadot  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25e63fbd7bSEmmanuel Vadot  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26e63fbd7bSEmmanuel Vadot  *
27e63fbd7bSEmmanuel Vadot  * $FreeBSD$
28e63fbd7bSEmmanuel Vadot  */
29e63fbd7bSEmmanuel Vadot 
30e63fbd7bSEmmanuel Vadot #ifndef _MMC_FDT_HELPERS_H_
31e63fbd7bSEmmanuel Vadot #define	_MMC_FDT_HELPERS_H_
32e63fbd7bSEmmanuel Vadot 
33e63fbd7bSEmmanuel Vadot #include <dev/gpio/gpiobusvar.h>
34e63fbd7bSEmmanuel Vadot #include <dev/ofw/ofw_bus.h>
35e63fbd7bSEmmanuel Vadot 
36e63fbd7bSEmmanuel Vadot #ifdef EXT_RESOURCES
37e63fbd7bSEmmanuel Vadot #include <dev/extres/regulator/regulator.h>
38e63fbd7bSEmmanuel Vadot #endif
39e63fbd7bSEmmanuel Vadot 
40*8a8166e5SBartlomiej Grzesik #include <dev/mmc/mmc_helpers.h>
41e63fbd7bSEmmanuel Vadot 
42*8a8166e5SBartlomiej Grzesik #define mmc_fdt_helper mmc_helper /* For backwards compatibility */
43e63fbd7bSEmmanuel Vadot 
44e63fbd7bSEmmanuel Vadot typedef void (*mmc_fdt_cd_handler)(device_t dev, bool present);
45e63fbd7bSEmmanuel Vadot 
46*8a8166e5SBartlomiej Grzesik int mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_helper *helper, struct mmc_host *host);
47*8a8166e5SBartlomiej Grzesik int mmc_fdt_gpio_setup(device_t dev, phandle_t node, struct mmc_helper *helper, mmc_fdt_cd_handler handler);
48*8a8166e5SBartlomiej Grzesik void mmc_fdt_gpio_teardown(struct mmc_helper *helper);
49*8a8166e5SBartlomiej Grzesik bool mmc_fdt_gpio_get_present(struct mmc_helper *helper);
50*8a8166e5SBartlomiej Grzesik bool mmc_fdt_gpio_get_readonly(struct mmc_helper *helper);
51*8a8166e5SBartlomiej Grzesik void mmc_fdt_set_power(struct mmc_helper *helper, enum mmc_power_mode power_mode);
52e63fbd7bSEmmanuel Vadot 
53e63fbd7bSEmmanuel Vadot #endif
54