Deleted Added
full compact
intpm.c (179622) intpm.c (189882)
1/*-
2 * Copyright (c) 1998, 1999 Takanori Watanabe
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) 1998, 1999 Takanori Watanabe
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: head/sys/pci/intpm.c 179622 2008-06-06 18:29:56Z jhb $");
28__FBSDID("$FreeBSD: head/sys/pci/intpm.c 189882 2009-03-16 16:15:14Z avg $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/lock.h>
35#include <sys/module.h>
36#include <sys/mutex.h>

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

162
163 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
164 NULL, intsmb_rawintr, sc, &sc->irq_hand);
165 if (error) {
166 device_printf(dev, "Failed to map intr\n");
167 goto fail;
168 }
169
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/lock.h>
35#include <sys/module.h>
36#include <sys/mutex.h>

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

162
163 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
164 NULL, intsmb_rawintr, sc, &sc->irq_hand);
165 if (error) {
166 device_printf(dev, "Failed to map intr\n");
167 goto fail;
168 }
169
170 value = pci_read_config(dev, PCI_BASE_ADDR_PM, 4);
171 device_printf(dev, "PM %s %x\n", (value & 1) ? "I/O mapped" : "Memory",
172 value & 0xfffe);
173
174 sc->isbusy = 0;
175 sc->smbus = device_add_child(dev, "smbus", -1);
176 if (sc->smbus == NULL) {
177 error = ENXIO;
178 goto fail;
179 }
180 error = device_probe_and_attach(sc->smbus);
181 if (error)

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

360
361 INTSMB_LOCK_ASSERT(sc);
362 tmp = bus_read_1(sc->io_res, PIIX4_SMBHSTCNT);
363 tmp &= 0xe0;
364 tmp |= cmd;
365 tmp |= PIIX4_SMBHSTCNT_START;
366
367 /* While not in autoconfiguration enable interrupts. */
170 sc->isbusy = 0;
171 sc->smbus = device_add_child(dev, "smbus", -1);
172 if (sc->smbus == NULL) {
173 error = ENXIO;
174 goto fail;
175 }
176 error = device_probe_and_attach(sc->smbus);
177 if (error)

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

356
357 INTSMB_LOCK_ASSERT(sc);
358 tmp = bus_read_1(sc->io_res, PIIX4_SMBHSTCNT);
359 tmp &= 0xe0;
360 tmp |= cmd;
361 tmp |= PIIX4_SMBHSTCNT_START;
362
363 /* While not in autoconfiguration enable interrupts. */
368 if (!cold || !nointr)
364 if (!cold && !nointr)
369 tmp |= PIIX4_SMBHSTCNT_INTREN;
370 bus_write_1(sc->io_res, PIIX4_SMBHSTCNT, tmp);
371}
372
373static int
365 tmp |= PIIX4_SMBHSTCNT_INTREN;
366 bus_write_1(sc->io_res, PIIX4_SMBHSTCNT, tmp);
367}
368
369static int
374intsmb_error(int status)
370intsmb_error(device_t dev, int status)
375{
376 int error = 0;
377
378 if (status & PIIX4_SMBHSTSTAT_ERR)
379 error |= SMB_EBUSERR;
380 if (status & PIIX4_SMBHSTSTAT_BUSC)
381 error |= SMB_ECOLLI;
382 if (status & PIIX4_SMBHSTSTAT_FAIL)
383 error |= SMB_ENOACK;
371{
372 int error = 0;
373
374 if (status & PIIX4_SMBHSTSTAT_ERR)
375 error |= SMB_EBUSERR;
376 if (status & PIIX4_SMBHSTSTAT_BUSC)
377 error |= SMB_ECOLLI;
378 if (status & PIIX4_SMBHSTSTAT_FAIL)
379 error |= SMB_ENOACK;
380
381 if (error != 0 && bootverbose)
382 device_printf(dev, "error = %d, status = %#x\n", error, status);
383
384 return (error);
385}
386
387/*
388 * Polling Code.
389 *
390 * Polling is not encouraged because it requires waiting for the
391 * device if it is busy.

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

405 PIIX4_SMBHSTSTAT_BUSY)
406 break;
407
408 /* Wait for busy to clear. */
409 for (i = 0; i < 0x7fff; i++) {
410 status = bus_read_1(sc->io_res, PIIX4_SMBHSTSTS);
411 if (!(status & PIIX4_SMBHSTSTAT_BUSY)) {
412 sc->isbusy = 0;
384 return (error);
385}
386
387/*
388 * Polling Code.
389 *
390 * Polling is not encouraged because it requires waiting for the
391 * device if it is busy.

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

405 PIIX4_SMBHSTSTAT_BUSY)
406 break;
407
408 /* Wait for busy to clear. */
409 for (i = 0; i < 0x7fff; i++) {
410 status = bus_read_1(sc->io_res, PIIX4_SMBHSTSTS);
411 if (!(status & PIIX4_SMBHSTSTAT_BUSY)) {
412 sc->isbusy = 0;
413 error = intsmb_error(status);
413 error = intsmb_error(sc->dev, status);
414 if (error == 0 && !(status & PIIX4_SMBHSTSTAT_INTR))
415 device_printf(sc->dev, "unknown cause why?\n");
416 return (error);
417 }
418 }
419
420 /* Timed out waiting for busy to clear. */
421 sc->isbusy = 0;

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

437 if (cold)
438 /* So that it can use device during device probe on SMBus. */
439 return (intsmb_stop_poll(sc));
440
441 error = msleep(sc, &sc->lock, PWAIT | PCATCH, "SMBWAI", hz / 8);
442 if (error == 0) {
443 status = bus_read_1(sc->io_res, PIIX4_SMBHSTSTS);
444 if (!(status & PIIX4_SMBHSTSTAT_BUSY)) {
414 if (error == 0 && !(status & PIIX4_SMBHSTSTAT_INTR))
415 device_printf(sc->dev, "unknown cause why?\n");
416 return (error);
417 }
418 }
419
420 /* Timed out waiting for busy to clear. */
421 sc->isbusy = 0;

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

437 if (cold)
438 /* So that it can use device during device probe on SMBus. */
439 return (intsmb_stop_poll(sc));
440
441 error = msleep(sc, &sc->lock, PWAIT | PCATCH, "SMBWAI", hz / 8);
442 if (error == 0) {
443 status = bus_read_1(sc->io_res, PIIX4_SMBHSTSTS);
444 if (!(status & PIIX4_SMBHSTSTAT_BUSY)) {
445 error = intsmb_error(status);
445 error = intsmb_error(sc->dev, status);
446 if (error == 0 && !(status & PIIX4_SMBHSTSTAT_INTR))
447 device_printf(sc->dev, "unknown cause why?\n");
448#ifdef ENABLE_ALART
449 bus_write_1(sc->io_res, PIIX4_SMBSLVCNT,
450 PIIX4_SMBSLVCNT_ALTEN);
451#endif
452 return (error);
453 }

--- 329 unchanged lines hidden ---
446 if (error == 0 && !(status & PIIX4_SMBHSTSTAT_INTR))
447 device_printf(sc->dev, "unknown cause why?\n");
448#ifdef ENABLE_ALART
449 bus_write_1(sc->io_res, PIIX4_SMBSLVCNT,
450 PIIX4_SMBSLVCNT_ALTEN);
451#endif
452 return (error);
453 }

--- 329 unchanged lines hidden ---