18a8166e5SBartlomiej Grzesik /* 28a8166e5SBartlomiej Grzesik * Copyright 2019 Emmanuel Vadot <manu@freebsd.org> 38a8166e5SBartlomiej Grzesik * Copyright (c) 2017 Ian Lepore <ian@freebsd.org> All rights reserved. 48a8166e5SBartlomiej Grzesik * 58a8166e5SBartlomiej Grzesik * Redistribution and use in source and binary forms, with or without 68a8166e5SBartlomiej Grzesik * modification, are permitted provided that the following conditions are 78a8166e5SBartlomiej Grzesik * met: 88a8166e5SBartlomiej Grzesik * 98a8166e5SBartlomiej Grzesik * 1. Redistributions of source code must retain the above copyright 108a8166e5SBartlomiej Grzesik * notice, this list of conditions and the following disclaimer. 118a8166e5SBartlomiej Grzesik * 2. Redistributions in binary form must reproduce the above copyright 128a8166e5SBartlomiej Grzesik * notice, this list of conditions and the following disclaimer in the 138a8166e5SBartlomiej Grzesik * documentation and/or other materials provided with the distribution. 148a8166e5SBartlomiej Grzesik * 158a8166e5SBartlomiej Grzesik * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 168a8166e5SBartlomiej Grzesik * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 178a8166e5SBartlomiej Grzesik * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 188a8166e5SBartlomiej Grzesik * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE 198a8166e5SBartlomiej Grzesik * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 208a8166e5SBartlomiej Grzesik * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 218a8166e5SBartlomiej Grzesik * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 228a8166e5SBartlomiej Grzesik * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 238a8166e5SBartlomiej Grzesik * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 248a8166e5SBartlomiej Grzesik * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 258a8166e5SBartlomiej Grzesik * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 268a8166e5SBartlomiej Grzesik */ 278a8166e5SBartlomiej Grzesik 288a8166e5SBartlomiej Grzesik #ifndef _MMC_HELPERS_H_ 298a8166e5SBartlomiej Grzesik #define _MMC_HELPERS_H_ 308a8166e5SBartlomiej Grzesik 318a8166e5SBartlomiej Grzesik #include <dev/gpio/gpiobusvar.h> 328a8166e5SBartlomiej Grzesik 33*b2f0caf1SEmmanuel Vadot #include <dev/regulator/regulator.h> 348a8166e5SBartlomiej Grzesik 358a8166e5SBartlomiej Grzesik struct mmc_helper { 368a8166e5SBartlomiej Grzesik device_t dev; 378a8166e5SBartlomiej Grzesik gpio_pin_t wp_pin; 388a8166e5SBartlomiej Grzesik gpio_pin_t cd_pin; 398a8166e5SBartlomiej Grzesik void * cd_ihandler; 408a8166e5SBartlomiej Grzesik struct resource * cd_ires; 418a8166e5SBartlomiej Grzesik int cd_irid; 428a8166e5SBartlomiej Grzesik void (*cd_handler)(device_t, bool); 438a8166e5SBartlomiej Grzesik struct timeout_task cd_delayed_task; 448a8166e5SBartlomiej Grzesik bool cd_disabled; 458a8166e5SBartlomiej Grzesik bool wp_disabled; 468a8166e5SBartlomiej Grzesik bool cd_present; 478a8166e5SBartlomiej Grzesik uint32_t props; 488a8166e5SBartlomiej Grzesik #define MMC_PROP_BROKEN_CD (1 << 0) 498a8166e5SBartlomiej Grzesik #define MMC_PROP_NON_REMOVABLE (1 << 1) 508a8166e5SBartlomiej Grzesik #define MMC_PROP_WP_INVERTED (1 << 2) 518a8166e5SBartlomiej Grzesik #define MMC_PROP_CD_INVERTED (1 << 3) 528a8166e5SBartlomiej Grzesik #define MMC_PROP_DISABLE_WP (1 << 4) 538a8166e5SBartlomiej Grzesik #define MMC_PROP_NO_SDIO (1 << 5) 548a8166e5SBartlomiej Grzesik #define MMC_PROP_NO_SD (1 << 6) 558a8166e5SBartlomiej Grzesik #define MMC_PROP_NO_MMC (1 << 7) 568a8166e5SBartlomiej Grzesik 578a8166e5SBartlomiej Grzesik regulator_t vmmc_supply; 588a8166e5SBartlomiej Grzesik regulator_t vqmmc_supply; 598a8166e5SBartlomiej Grzesik 608a8166e5SBartlomiej Grzesik device_t mmc_pwrseq; 618a8166e5SBartlomiej Grzesik }; 628a8166e5SBartlomiej Grzesik 638a8166e5SBartlomiej Grzesik int mmc_parse(device_t dev, struct mmc_helper *helper, 648a8166e5SBartlomiej Grzesik struct mmc_host *host); 658a8166e5SBartlomiej Grzesik 668a8166e5SBartlomiej Grzesik #endif 67