Deleted Added
sdiff udiff text old ( 327638 ) new ( 331501 )
full compact
1/*-
2 * Copyright (c) 2013 Ian Lepore <ian@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/11/sys/dev/sdhci/fsl_sdhci.c 327638 2018-01-06 21:19:52Z ian $");
29
30/*
31 * SDHCI driver glue for Freescale i.MX SoC and QorIQ families.
32 *
33 * This supports both eSDHC (earlier SoCs) and uSDHC (more recent SoCs).
34 */
35
36#include <sys/param.h>

--- 44 unchanged lines hidden (view full) ---

81 sbintime_t r1bfix_timeout_at;
82 struct sdhci_fdt_gpio * gpio;
83 uint32_t baseclk_hz;
84 uint32_t cmd_and_mode;
85 uint32_t r1bfix_intmask;
86 uint16_t sdclockreg_freq_bits;
87 uint8_t r1bfix_type;
88 uint8_t hwtype;
89};
90
91#define R1BFIX_NONE 0 /* No fix needed at next interrupt. */
92#define R1BFIX_NODATA 1 /* Synthesize DATA_END for R1B w/o data. */
93#define R1BFIX_AC12 2 /* Wait for busy after auto command 12. */
94
95#define HWTYPE_NONE 0 /* Hardware not recognized/supported. */
96#define HWTYPE_ESDHC 1 /* fsl5x and earlier. */

--- 712 unchanged lines hidden (view full) ---

809{
810 struct fsl_sdhci_softc *sc = device_get_softc(dev);
811
812 if (sc->gpio != NULL)
813 sdhci_fdt_gpio_teardown(sc->gpio);
814
815 callout_drain(&sc->r1bfix_callout);
816
817 if (sc->intr_cookie != NULL)
818 bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie);
819 if (sc->irq_res != NULL)
820 bus_release_resource(dev, SYS_RES_IRQ,
821 rman_get_rid(sc->irq_res), sc->irq_res);
822
823 if (sc->mem_res != NULL) {
824 sdhci_cleanup_slot(&sc->slot);
825 bus_release_resource(dev, SYS_RES_MEMORY,
826 rman_get_rid(sc->mem_res), sc->mem_res);
827 }
828
829 return (0);
830}
831
832static int
833fsl_sdhci_attach(device_t dev)
834{
835 struct fsl_sdhci_softc *sc = device_get_softc(dev);
836 int rid, err;
837#ifdef __powerpc__
838 phandle_t node;
839 uint32_t protctl;
840#endif
841
842 sc->dev = dev;
843
844 sc->hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
845 if (sc->hwtype == HWTYPE_NONE)
846 panic("Impossible: not compatible in fsl_sdhci_attach()");
847
848 rid = 0;
849 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
850 RF_ACTIVE);
851 if (!sc->mem_res) {

--- 71 unchanged lines hidden (view full) ---

923 protctl &= ~SDHC_PROT_EMODE_MASK;
924 if (OF_hasprop(node, "little-endian"))
925 protctl |= SDHC_PROT_EMODE_LITTLE;
926 else
927 protctl |= SDHC_PROT_EMODE_BIG;
928 WR4(sc, SDHC_PROT_CTRL, protctl);
929#endif
930
931 callout_init(&sc->r1bfix_callout, 1);
932 sdhci_init_slot(dev, &sc->slot, 0);
933
934 bus_generic_probe(dev);
935 bus_generic_attach(dev);
936
937 sdhci_start_slot(&sc->slot);
938
939 return (0);
940

--- 68 unchanged lines hidden ---