Lines Matching refs:dev
27 __FBSDID("$FreeBSD: releng/11.0/sys/dev/sdhci/sdhci_pci.c 299414 2016-05-11 07:50:35Z trasz $");
42 #include <dev/pci/pcireg.h>
43 #include <dev/pci/pcivar.h>
49 #include <dev/mmc/bridge.h>
50 #include <dev/mmc/mmcreg.h>
51 #include <dev/mmc/mmcbrvar.h>
131 sdhci_pci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off)
133 struct sdhci_pci_softc *sc = device_get_softc(dev);
141 sdhci_pci_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint8_t val)
143 struct sdhci_pci_softc *sc = device_get_softc(dev);
151 sdhci_pci_read_2(device_t dev, struct sdhci_slot *slot, bus_size_t off)
153 struct sdhci_pci_softc *sc = device_get_softc(dev);
161 sdhci_pci_write_2(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint16_t val)
163 struct sdhci_pci_softc *sc = device_get_softc(dev);
171 sdhci_pci_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off)
173 struct sdhci_pci_softc *sc = device_get_softc(dev);
181 sdhci_pci_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t val)
183 struct sdhci_pci_softc *sc = device_get_softc(dev);
191 sdhci_pci_read_multi_4(device_t dev, struct sdhci_slot *slot,
194 struct sdhci_pci_softc *sc = device_get_softc(dev);
200 sdhci_pci_write_multi_4(device_t dev, struct sdhci_slot *slot,
203 struct sdhci_pci_softc *sc = device_get_softc(dev);
211 sdhci_lower_frequency(device_t dev)
213 struct sdhci_pci_softc *sc = device_get_softc(dev);
219 pci_write_config(dev, SDHC_PCI_MODE_KEY, 0xfc, 1);
220 sc->cfg_mode = pci_read_config(dev, SDHC_PCI_MODE, 1);
221 pci_write_config(dev, SDHC_PCI_MODE, SDHC_PCI_MODE_SD20, 1);
222 pci_write_config(dev, SDHC_PCI_MODE_KEY, 0x00, 1);
228 pci_write_config(dev, SDHC_PCI_BASE_FREQ_KEY, 0x01, 1);
229 sc->cfg_freq = pci_read_config(dev, SDHC_PCI_BASE_FREQ, 1);
230 pci_write_config(dev, SDHC_PCI_BASE_FREQ, 50, 1);
231 pci_write_config(dev, SDHC_PCI_BASE_FREQ_KEY, 0x00, 1);
235 sdhci_restore_frequency(device_t dev)
237 struct sdhci_pci_softc *sc = device_get_softc(dev);
240 pci_write_config(dev, SDHC_PCI_MODE_KEY, 0xfc, 1);
241 pci_write_config(dev, SDHC_PCI_MODE, sc->cfg_mode, 1);
242 pci_write_config(dev, SDHC_PCI_MODE_KEY, 0x00, 1);
245 pci_write_config(dev, SDHC_PCI_BASE_FREQ_KEY, 0x01, 1);
246 pci_write_config(dev, SDHC_PCI_BASE_FREQ, sc->cfg_freq, 1);
247 pci_write_config(dev, SDHC_PCI_BASE_FREQ_KEY, 0x00, 1);
251 sdhci_pci_probe(device_t dev)
258 model = (uint32_t)pci_get_device(dev) << 16;
259 model |= (uint32_t)pci_get_vendor(dev) & 0x0000ffff;
260 subvendor = pci_get_subvendor(dev);
261 class = pci_get_class(dev);
262 subclass = pci_get_subclass(dev);
269 device_set_desc(dev, sdhci_devices[i].desc);
276 device_set_desc(dev, "Generic SD HCI");
284 sdhci_pci_attach(device_t dev)
286 struct sdhci_pci_softc *sc = device_get_softc(dev);
291 model = (uint32_t)pci_get_device(dev) << 16;
292 model |= (uint32_t)pci_get_vendor(dev) & 0x0000ffff;
293 subvendor = pci_get_subvendor(dev);
305 sdhci_lower_frequency(dev);
307 slots = pci_read_config(dev, PCI_SLOT_INFO, 1);
311 device_printf(dev, "Incorrect slots information (%d, %d).\n",
318 if (sdhci_enable_msi != 0 && pci_alloc_msi(dev, &i) == 0)
320 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
323 device_printf(dev, "Can't allocate IRQ\n");
324 pci_release_msi(dev);
333 sc->mem_res[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
336 device_printf(dev, "Can't allocate memory for slot %d\n", i);
342 if (sdhci_init_slot(dev, slot, i) != 0)
347 device_printf(dev, "%d slot(s) allocated\n", sc->num_slots);
349 err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
352 device_printf(dev, "Can't setup IRQ\n");
353 pci_enable_busmaster(dev);
365 sdhci_pci_detach(device_t dev)
367 struct sdhci_pci_softc *sc = device_get_softc(dev);
370 bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
371 bus_release_resource(dev, SYS_RES_IRQ,
373 pci_release_msi(dev);
379 bus_release_resource(dev, SYS_RES_MEMORY,
383 sdhci_restore_frequency(dev);
388 sdhci_pci_shutdown(device_t dev)
390 struct sdhci_pci_softc *sc = device_get_softc(dev);
393 sdhci_restore_frequency(dev);
398 sdhci_pci_suspend(device_t dev)
400 struct sdhci_pci_softc *sc = device_get_softc(dev);
403 err = bus_generic_suspend(dev);
412 sdhci_pci_resume(device_t dev)
414 struct sdhci_pci_softc *sc = device_get_softc(dev);
419 err = bus_generic_resume(dev);
423 sdhci_lower_frequency(dev);