sdhci_fdt.c (261410) | sdhci_fdt.c (265208) |
---|---|
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: head/sys/dev/sdhci/sdhci_fdt.c 261410 2014-02-02 19:17:28Z ian $"); | 32__FBSDID("$FreeBSD: head/sys/dev/sdhci/sdhci_fdt.c 265208 2014-05-02 01:28:19Z ian $"); |
33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/bus.h> 37#include <sys/conf.h> 38#include <sys/kernel.h> 39#include <sys/lock.h> 40#include <sys/module.h> --- 20 unchanged lines hidden (view full) --- 61#include "sdhci_if.h" 62 63#define MAX_SLOTS 6 64 65struct sdhci_fdt_softc { 66 device_t dev; /* Controller device */ 67 u_int quirks; /* Chip specific quirks */ 68 u_int caps; /* If we override SDHCI_CAPABILITIES */ | 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/bus.h> 37#include <sys/conf.h> 38#include <sys/kernel.h> 39#include <sys/lock.h> 40#include <sys/module.h> --- 20 unchanged lines hidden (view full) --- 61#include "sdhci_if.h" 62 63#define MAX_SLOTS 6 64 65struct sdhci_fdt_softc { 66 device_t dev; /* Controller device */ 67 u_int quirks; /* Chip specific quirks */ 68 u_int caps; /* If we override SDHCI_CAPABILITIES */ |
69 uint32_t max_clk; /* Max possible freq */ |
|
69 struct resource *irq_res; /* IRQ resource */ 70 void *intrhand; /* Interrupt handle */ 71 72 int num_slots; /* Number of slots on this controller*/ 73 struct sdhci_slot slots[MAX_SLOTS]; 74 struct resource *mem_res[MAX_SLOTS]; /* Memory resource */ 75}; 76 --- 74 unchanged lines hidden (view full) --- 151sdhci_fdt_probe(device_t dev) 152{ 153 struct sdhci_fdt_softc *sc = device_get_softc(dev); 154 phandle_t node; 155 pcell_t cid; 156 157 sc->quirks = 0; 158 sc->num_slots = 1; | 70 struct resource *irq_res; /* IRQ resource */ 71 void *intrhand; /* Interrupt handle */ 72 73 int num_slots; /* Number of slots on this controller*/ 74 struct sdhci_slot slots[MAX_SLOTS]; 75 struct resource *mem_res[MAX_SLOTS]; /* Memory resource */ 76}; 77 --- 74 unchanged lines hidden (view full) --- 152sdhci_fdt_probe(device_t dev) 153{ 154 struct sdhci_fdt_softc *sc = device_get_softc(dev); 155 phandle_t node; 156 pcell_t cid; 157 158 sc->quirks = 0; 159 sc->num_slots = 1; |
160 sc->max_clk = 0; |
|
159 160 if (!ofw_bus_status_okay(dev)) 161 return (ENXIO); 162 163 if (ofw_bus_is_compatible(dev, "sdhci_generic")) { 164 device_set_desc(dev, "generic fdt SDHCI controller"); 165 } else if (ofw_bus_is_compatible(dev, "xlnx,zy7_sdhci")) { 166 sc->quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK; 167 device_set_desc(dev, "Zynq-7000 generic fdt SDHCI controller"); 168 } else 169 return (ENXIO); 170 171 node = ofw_bus_get_node(dev); 172 | 161 162 if (!ofw_bus_status_okay(dev)) 163 return (ENXIO); 164 165 if (ofw_bus_is_compatible(dev, "sdhci_generic")) { 166 device_set_desc(dev, "generic fdt SDHCI controller"); 167 } else if (ofw_bus_is_compatible(dev, "xlnx,zy7_sdhci")) { 168 sc->quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK; 169 device_set_desc(dev, "Zynq-7000 generic fdt SDHCI controller"); 170 } else 171 return (ENXIO); 172 173 node = ofw_bus_get_node(dev); 174 |
173 /* Allow dts to patch quirks and slots. */ 174 if ((OF_getprop(node, "quirks", &cid, sizeof(cid))) > 0) 175 sc->quirks = fdt32_to_cpu(cid); 176 if ((OF_getprop(node, "num-slots", &cid, sizeof(cid))) > 0) 177 sc->num_slots = fdt32_to_cpu(cid); | 175 /* Allow dts to patch quirks, slots, and max-frequency. */ 176 if ((OF_getencprop(node, "quirks", &cid, sizeof(cid))) > 0) 177 sc->quirks = cid; 178 if ((OF_getencprop(node, "num-slots", &cid, sizeof(cid))) > 0) 179 sc->num_slots = cid; 180 if ((OF_getencprop(node, "max-frequency", &cid, sizeof(cid))) > 0) 181 sc->max_clk = cid; 182 |
178 179 return (0); 180} 181 182static int 183sdhci_fdt_attach(device_t dev) 184{ 185 struct sdhci_fdt_softc *sc = device_get_softc(dev); --- 23 unchanged lines hidden (view full) --- 209 if (sc->mem_res[i] == NULL) { 210 device_printf(dev, "Can't allocate memory for " 211 "slot %d\n", i); 212 continue; 213 } 214 215 slot->quirks = sc->quirks; 216 slot->caps = sc->caps; | 183 184 return (0); 185} 186 187static int 188sdhci_fdt_attach(device_t dev) 189{ 190 struct sdhci_fdt_softc *sc = device_get_softc(dev); --- 23 unchanged lines hidden (view full) --- 214 if (sc->mem_res[i] == NULL) { 215 device_printf(dev, "Can't allocate memory for " 216 "slot %d\n", i); 217 continue; 218 } 219 220 slot->quirks = sc->quirks; 221 slot->caps = sc->caps; |
222 slot->max_clk = sc->max_clk; |
|
217 218 if (sdhci_init_slot(dev, slot, i) != 0) 219 continue; 220 221 sc->num_slots++; 222 } 223 device_printf(dev, "%d slot(s) allocated\n", sc->num_slots); 224 --- 79 unchanged lines hidden --- | 223 224 if (sdhci_init_slot(dev, slot, i) != 0) 225 continue; 226 227 sc->num_slots++; 228 } 229 device_printf(dev, "%d slot(s) allocated\n", sc->num_slots); 230 --- 79 unchanged lines hidden --- |