sdhci_fdt.c (331722) | sdhci_fdt.c (337858) |
---|---|
1/*- 2 * Copyright (c) 2012 Thomas Skibo 3 * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 15 unchanged lines hidden (view full) --- 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27/* Generic driver to attach sdhci controllers on simplebus. 28 * Derived mainly from sdhci_pci.c 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2012 Thomas Skibo 3 * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 15 unchanged lines hidden (view full) --- 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27/* Generic driver to attach sdhci controllers on simplebus. 28 * Derived mainly from sdhci_pci.c 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: stable/11/sys/dev/sdhci/sdhci_fdt.c 331722 2018-03-29 02:50:57Z eadler $"); | 32__FBSDID("$FreeBSD: stable/11/sys/dev/sdhci/sdhci_fdt.c 337858 2018-08-15 16:27:52Z loos $"); |
33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/module.h> 40#include <sys/mutex.h> --- 24 unchanged lines hidden (view full) --- 65 u_int caps; /* If we override SDHCI_CAPABILITIES */ 66 uint32_t max_clk; /* Max possible freq */ 67 struct resource *irq_res; /* IRQ resource */ 68 void *intrhand; /* Interrupt handle */ 69 70 int num_slots; /* Number of slots on this controller*/ 71 struct sdhci_slot slots[MAX_SLOTS]; 72 struct resource *mem_res[MAX_SLOTS]; /* Memory resource */ | 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/module.h> 40#include <sys/mutex.h> --- 24 unchanged lines hidden (view full) --- 65 u_int caps; /* If we override SDHCI_CAPABILITIES */ 66 uint32_t max_clk; /* Max possible freq */ 67 struct resource *irq_res; /* IRQ resource */ 68 void *intrhand; /* Interrupt handle */ 69 70 int num_slots; /* Number of slots on this controller*/ 71 struct sdhci_slot slots[MAX_SLOTS]; 72 struct resource *mem_res[MAX_SLOTS]; /* Memory resource */ |
73 74 bool wp_inverted; /* WP pin is inverted */ 75 bool no_18v; /* No 1.8V support */ |
|
73}; 74 75static uint8_t 76sdhci_fdt_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) 77{ 78 struct sdhci_fdt_softc *sc = device_get_softc(dev); 79 80 return (bus_read_1(sc->mem_res[slot->num], off)); --- 24 unchanged lines hidden (view full) --- 105 106 bus_write_2(sc->mem_res[slot->num], off, val); 107} 108 109static uint32_t 110sdhci_fdt_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) 111{ 112 struct sdhci_fdt_softc *sc = device_get_softc(dev); | 76}; 77 78static uint8_t 79sdhci_fdt_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) 80{ 81 struct sdhci_fdt_softc *sc = device_get_softc(dev); 82 83 return (bus_read_1(sc->mem_res[slot->num], off)); --- 24 unchanged lines hidden (view full) --- 108 109 bus_write_2(sc->mem_res[slot->num], off, val); 110} 111 112static uint32_t 113sdhci_fdt_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) 114{ 115 struct sdhci_fdt_softc *sc = device_get_softc(dev); |
116 uint32_t val32; |
|
113 | 117 |
114 return (bus_read_4(sc->mem_res[slot->num], off)); | 118 val32 = bus_read_4(sc->mem_res[slot->num], off); 119 if (off == SDHCI_CAPABILITIES && sc->no_18v) 120 val32 &= ~SDHCI_CAN_VDD_180; 121 122 return (val32); |
115} 116 117static void 118sdhci_fdt_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, 119 uint32_t val) 120{ 121 struct sdhci_fdt_softc *sc = device_get_softc(dev); 122 --- 24 unchanged lines hidden (view full) --- 147 struct sdhci_fdt_softc *sc = (struct sdhci_fdt_softc *)arg; 148 int i; 149 150 for (i = 0; i < sc->num_slots; i++) 151 sdhci_generic_intr(&sc->slots[i]); 152} 153 154static int | 123} 124 125static void 126sdhci_fdt_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, 127 uint32_t val) 128{ 129 struct sdhci_fdt_softc *sc = device_get_softc(dev); 130 --- 24 unchanged lines hidden (view full) --- 155 struct sdhci_fdt_softc *sc = (struct sdhci_fdt_softc *)arg; 156 int i; 157 158 for (i = 0; i < sc->num_slots; i++) 159 sdhci_generic_intr(&sc->slots[i]); 160} 161 162static int |
163sdhci_fdt_get_ro(device_t bus, device_t dev) 164{ 165 struct sdhci_fdt_softc *sc = device_get_softc(bus); 166 167 return (sdhci_generic_get_ro(bus, dev) ^ sc->wp_inverted); 168} 169 170static int |
|
155sdhci_fdt_probe(device_t dev) 156{ 157 struct sdhci_fdt_softc *sc = device_get_softc(dev); 158 phandle_t node; 159 pcell_t cid; 160 161 sc->quirks = 0; 162 sc->num_slots = 1; --- 14 unchanged lines hidden (view full) --- 177 178 /* Allow dts to patch quirks, slots, and max-frequency. */ 179 if ((OF_getencprop(node, "quirks", &cid, sizeof(cid))) > 0) 180 sc->quirks = cid; 181 if ((OF_getencprop(node, "num-slots", &cid, sizeof(cid))) > 0) 182 sc->num_slots = cid; 183 if ((OF_getencprop(node, "max-frequency", &cid, sizeof(cid))) > 0) 184 sc->max_clk = cid; | 171sdhci_fdt_probe(device_t dev) 172{ 173 struct sdhci_fdt_softc *sc = device_get_softc(dev); 174 phandle_t node; 175 pcell_t cid; 176 177 sc->quirks = 0; 178 sc->num_slots = 1; --- 14 unchanged lines hidden (view full) --- 193 194 /* Allow dts to patch quirks, slots, and max-frequency. */ 195 if ((OF_getencprop(node, "quirks", &cid, sizeof(cid))) > 0) 196 sc->quirks = cid; 197 if ((OF_getencprop(node, "num-slots", &cid, sizeof(cid))) > 0) 198 sc->num_slots = cid; 199 if ((OF_getencprop(node, "max-frequency", &cid, sizeof(cid))) > 0) 200 sc->max_clk = cid; |
201 if (OF_hasprop(node, "no-1-8-v")) 202 sc->no_18v = true; 203 if (OF_hasprop(node, "wp-inverted")) 204 sc->wp_inverted = true; |
|
185 186 return (0); 187} 188 189static int 190sdhci_fdt_attach(device_t dev) 191{ 192 struct sdhci_fdt_softc *sc = device_get_softc(dev); --- 81 unchanged lines hidden (view full) --- 274 275 /* Bus interface */ 276 DEVMETHOD(bus_read_ivar, sdhci_generic_read_ivar), 277 DEVMETHOD(bus_write_ivar, sdhci_generic_write_ivar), 278 279 /* mmcbr_if */ 280 DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), 281 DEVMETHOD(mmcbr_request, sdhci_generic_request), | 205 206 return (0); 207} 208 209static int 210sdhci_fdt_attach(device_t dev) 211{ 212 struct sdhci_fdt_softc *sc = device_get_softc(dev); --- 81 unchanged lines hidden (view full) --- 294 295 /* Bus interface */ 296 DEVMETHOD(bus_read_ivar, sdhci_generic_read_ivar), 297 DEVMETHOD(bus_write_ivar, sdhci_generic_write_ivar), 298 299 /* mmcbr_if */ 300 DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), 301 DEVMETHOD(mmcbr_request, sdhci_generic_request), |
282 DEVMETHOD(mmcbr_get_ro, sdhci_generic_get_ro), | 302 DEVMETHOD(mmcbr_get_ro, sdhci_fdt_get_ro), |
283 DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), 284 DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), 285 286 /* SDHCI registers accessors */ 287 DEVMETHOD(sdhci_read_1, sdhci_fdt_read_1), 288 DEVMETHOD(sdhci_read_2, sdhci_fdt_read_2), 289 DEVMETHOD(sdhci_read_4, sdhci_fdt_read_4), 290 DEVMETHOD(sdhci_read_multi_4, sdhci_fdt_read_multi_4), --- 19 unchanged lines hidden --- | 303 DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), 304 DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), 305 306 /* SDHCI registers accessors */ 307 DEVMETHOD(sdhci_read_1, sdhci_fdt_read_1), 308 DEVMETHOD(sdhci_read_2, sdhci_fdt_read_2), 309 DEVMETHOD(sdhci_read_4, sdhci_fdt_read_4), 310 DEVMETHOD(sdhci_read_multi_4, sdhci_fdt_read_multi_4), --- 19 unchanged lines hidden --- |