pccbb.c (277233) | pccbb.c (277234) |
---|---|
1/*- 2 * Copyright (c) 2002-2004 M. Warner Losh. 3 * Copyright (c) 2000-2001 Jonathan Chen. 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: --- 61 unchanged lines hidden (view full) --- 70 * The author would like to acknowledge: 71 * * HAYAKAWA Koichi: Author of the NetBSD code for the same thing 72 * * Warner Losh: Newbus/newcard guru and author of the pccard side of things 73 * * YAMAMOTO Shigeru: Author of another FreeBSD cardbus driver 74 * * David Cross: Author of the initial ugly hack for a specific cardbus card 75 */ 76 77#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2004 M. Warner Losh. 3 * Copyright (c) 2000-2001 Jonathan Chen. 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: --- 61 unchanged lines hidden (view full) --- 70 * The author would like to acknowledge: 71 * * HAYAKAWA Koichi: Author of the NetBSD code for the same thing 72 * * Warner Losh: Newbus/newcard guru and author of the pccard side of things 73 * * YAMAMOTO Shigeru: Author of another FreeBSD cardbus driver 74 * * David Cross: Author of the initial ugly hack for a specific cardbus card 75 */ 76 77#include <sys/cdefs.h> |
78__FBSDID("$FreeBSD: head/sys/dev/pccbb/pccbb.c 277233 2015-01-16 06:19:24Z imp $"); | 78__FBSDID("$FreeBSD: head/sys/dev/pccbb/pccbb.c 277234 2015-01-16 06:19:39Z imp $"); |
79 80#include <sys/param.h> 81#include <sys/bus.h> 82#include <sys/condvar.h> 83#include <sys/errno.h> 84#include <sys/kernel.h> 85#include <sys/module.h> 86#include <sys/kthread.h> --- 1471 unchanged lines hidden (view full) --- 1558 return (EINVAL); 1559 case PCIB_IVAR_BUS: 1560 return (EINVAL); 1561 } 1562 return (ENOENT); 1563} 1564 1565int | 79 80#include <sys/param.h> 81#include <sys/bus.h> 82#include <sys/condvar.h> 83#include <sys/errno.h> 84#include <sys/kernel.h> 85#include <sys/module.h> 86#include <sys/kthread.h> --- 1471 unchanged lines hidden (view full) --- 1558 return (EINVAL); 1559 case PCIB_IVAR_BUS: 1560 return (EINVAL); 1561 } 1562 return (ENOENT); 1563} 1564 1565int |
1566cbb_suspend(device_t brdev) 1567{ 1568 int error = 0; 1569 struct cbb_softc *sc = device_get_softc(brdev); 1570 1571 error = bus_generic_suspend(brdev); 1572 if (error != 0) 1573 return (error); 1574 cbb_set(sc, CBB_SOCKET_MASK, 0); /* Quiet hardware */ 1575 sc->cardok = 0; /* Card is bogus now */ 1576 return (0); 1577} 1578 1579int 1580cbb_resume(device_t brdev) 1581{ 1582 int error = 0; 1583 struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev); 1584 uint32_t tmp; 1585 1586 /* 1587 * In the APM and early ACPI era, BIOSes saved the PCI config 1588 * registers. As chips became more complicated, that functionality moved 1589 * into the ACPI code / tables. We must therefore, restore the settings 1590 * we made here to make sure the device come back. Transitions to Dx 1591 * from D0 and back to D0 cause the bridge to lose its config space, so 1592 * all the bus mappings and such are preserved. 1593 * 1594 * For most drivers, the PCI layer handles this saving. However, since 1595 * there's much black magic and arcane art hidden in these few lines of 1596 * code that would be difficult to transition into the PCI 1597 * layer. chipinit was several years of trial and error to write. 1598 */ 1599 pci_write_config(brdev, CBBR_SOCKBASE, rman_get_start(sc->base_res), 4); 1600 DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n", 1601 rman_get_start(sc->base_res))); 1602 1603 sc->chipinit(sc); 1604 1605 /* reset interrupt -- Do we really need to do this? */ 1606 tmp = cbb_get(sc, CBB_SOCKET_EVENT); 1607 cbb_set(sc, CBB_SOCKET_EVENT, tmp); 1608 1609 /* CSC Interrupt: Card detect interrupt on */ 1610 cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD); 1611 1612 /* Signal the thread to wakeup. */ 1613 wakeup(&sc->intrhand); 1614 1615 error = bus_generic_resume(brdev); 1616 1617 return (error); 1618} 1619 1620int | |
1621cbb_child_present(device_t parent, device_t child) 1622{ 1623 struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(parent); 1624 uint32_t sockstate; 1625 1626 sockstate = cbb_get(sc, CBB_SOCKET_STATE); 1627 return (CBB_CARD_PRESENT(sockstate) && sc->cardok); 1628} | 1566cbb_child_present(device_t parent, device_t child) 1567{ 1568 struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(parent); 1569 uint32_t sockstate; 1570 1571 sockstate = cbb_get(sc, CBB_SOCKET_STATE); 1572 return (CBB_CARD_PRESENT(sockstate) && sc->cardok); 1573} |