1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25 26 #ifndef _SDHCI_FDT_H_ 27 #define _SDHCI_FDT_H_ 28 29 #define SDHCI_FDT_MAX_SLOTS 6 30 31 struct sdhci_fdt_softc { 32 device_t dev; /* Controller device */ 33 u_int quirks; /* Chip specific quirks */ 34 u_int caps; /* If we override SDHCI_CAPABILITIES */ 35 uint32_t max_clk; /* Max possible freq */ 36 uint8_t sdma_boundary; /* If we override the SDMA boundary */ 37 struct resource *irq_res; /* IRQ resource */ 38 void *intrhand; /* Interrupt handle */ 39 40 int num_slots; /* Number of slots on this controller*/ 41 struct sdhci_slot slots[SDHCI_FDT_MAX_SLOTS]; 42 struct resource *mem_res[SDHCI_FDT_MAX_SLOTS]; /* Memory resource */ 43 44 bool wp_inverted; /* WP pin is inverted */ 45 bool wp_disabled; /* WP pin is not supported */ 46 bool no_18v; /* No 1.8V support */ 47 48 clk_t clk_xin; /* xin24m fixed clock */ 49 clk_t clk_ahb; /* ahb clock */ 50 clk_t clk_core; /* core clock */ 51 phy_t phy; /* phy to be used */ 52 53 struct syscon *syscon; /* Handle to the syscon */ 54 }; 55 56 int sdhci_fdt_attach(device_t dev); 57 int sdhci_fdt_detach(device_t dev); 58 int sdhci_get_syscon(struct sdhci_fdt_softc *sc); 59 int sdhci_init_phy(struct sdhci_fdt_softc *sc); 60 void sdhci_export_clocks(struct sdhci_fdt_softc *sc); 61 int sdhci_clock_ofw_map(struct clkdom *clkdom, uint32_t ncells, 62 phandle_t *cells, struct clknode **clk); 63 int sdhci_init_clocks(device_t dev); 64 int sdhci_fdt_set_clock(device_t dev, struct sdhci_slot *slot, 65 int clock); 66 #endif 67