Deleted Added
full compact
fsl_sdhci.c (327638) fsl_sdhci.c (331501)
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>
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 $");
28__FBSDID("$FreeBSD: stable/11/sys/dev/sdhci/fsl_sdhci.c 331501 2018-03-24 22:39:38Z 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;
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 bool slot_init_done;
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
90};
91
92#define R1BFIX_NONE 0 /* No fix needed at next interrupt. */
93#define R1BFIX_NODATA 1 /* Synthesize DATA_END for R1B w/o data. */
94#define R1BFIX_AC12 2 /* Wait for busy after auto command 12. */
95
96#define HWTYPE_NONE 0 /* Hardware not recognized/supported. */
97#define HWTYPE_ESDHC 1 /* fsl5x and earlier. */

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

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

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

928 protctl &= ~SDHC_PROT_EMODE_MASK;
929 if (OF_hasprop(node, "little-endian"))
930 protctl |= SDHC_PROT_EMODE_LITTLE;
931 else
932 protctl |= SDHC_PROT_EMODE_BIG;
933 WR4(sc, SDHC_PROT_CTRL, protctl);
934#endif
935
931 callout_init(&sc->r1bfix_callout, 1);
932 sdhci_init_slot(dev, &sc->slot, 0);
936 sdhci_init_slot(dev, &sc->slot, 0);
937 sc->slot_init_done = true;
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 ---
938
939 bus_generic_probe(dev);
940 bus_generic_attach(dev);
941
942 sdhci_start_slot(&sc->slot);
943
944 return (0);
945

--- 68 unchanged lines hidden ---