summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-05-15 15:47:16 +0000
committerattilio <attilio@FreeBSD.org>2011-05-15 15:47:16 +0000
commitd7d74971f13d3dd8b23b648b471dd209deef841f (patch)
treeb8c92b94db6c0893eb3cc61ecd7bb49b265937a8 /sys
parente0bdfaa331e0646b286138c0a1ebde578634f499 (diff)
parent18b26669453903e860135019c9ef861b23c4df7b (diff)
downloadFreeBSD-src-d7d74971f13d3dd8b23b648b471dd209deef841f.zip
FreeBSD-src-d7d74971f13d3dd8b23b648b471dd209deef841f.tar.gz
MFC
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/dev/ath/ath_hal/ar5416/ar5416_cal.c2
-rw-r--r--sys/dev/cxgbe/t4_sge.c13
-rw-r--r--sys/dev/glxiic/glxiic.c1077
-rw-r--r--sys/dev/iwn/if_iwn.c10
-rw-r--r--sys/dev/mii/mii.c6
-rw-r--r--sys/dev/mk48txx/mk48txx.c4
-rw-r--r--sys/dev/mk48txx/mk48txxreg.h3
-rw-r--r--sys/dev/scc/scc_bfe_ebus.c3
-rw-r--r--sys/dev/uart/uart_cpu_sparc64.c3
-rw-r--r--sys/geom/eli/g_eli_key_cache.c1
-rw-r--r--sys/i386/conf/NOTES6
-rw-r--r--sys/modules/Makefile2
-rw-r--r--sys/modules/glxiic/Makefile10
-rw-r--r--sys/net/if_media.h25
-rw-r--r--sys/sparc64/sparc64/eeprom.c5
16 files changed, 1157 insertions, 14 deletions
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index f518bc9..4f0d0d0 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -171,6 +171,7 @@ dev/fdc/fdc_acpi.c optional fdc
dev/fdc/fdc_isa.c optional fdc isa
dev/fdc/fdc_pccard.c optional fdc pccard
dev/fe/if_fe_isa.c optional fe isa
+dev/glxiic/glxiic.c optional glxiic
dev/glxsb/glxsb.c optional glxsb
dev/glxsb/glxsb_hash.c optional glxsb
dev/hptmv/entry.c optional hptmv
diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c
index d8609bb..ee61c30 100644
--- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c
+++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c
@@ -501,7 +501,7 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,
* and update the history buffer.
*/
r = ar5416GetNf(ah, chan);
- if (r <= 0) {
+ if (r == 0 || r == -1) {
/* NF calibration result isn't valid */
HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: NF calibration"
" didn't finish; delaying CCA\n", __func__);
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 5440528..5f59db6 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -141,6 +141,7 @@ static int handle_sge_egr_update(struct adapter *,
const struct cpl_sge_egr_update *);
static int ctrl_tx(struct adapter *, struct sge_ctrlq *, struct mbuf *);
+static int sysctl_abs_id(SYSCTL_HANDLER_ARGS);
extern void filter_rpl(struct adapter *, const struct cpl_set_tcb_rpl *);
@@ -1363,6 +1364,9 @@ alloc_rxq(struct port_info *pi, struct sge_rxq *rxq, int intr_idx, int idx)
NULL, "rx queue");
children = SYSCTL_CHILDREN(oid);
+ SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "abs_id",
+ CTLTYPE_INT | CTLFLAG_RD, &rxq->iq.abs_id, 0, sysctl_abs_id, "I",
+ "absolute id of the queue");
#ifdef INET
SYSCTL_ADD_INT(&pi->ctx, children, OID_AUTO, "lro_queued", CTLFLAG_RD,
&rxq->lro.lro_queued, 0, NULL);
@@ -2733,3 +2737,12 @@ failed:
return (rc);
}
+
+static int
+sysctl_abs_id(SYSCTL_HANDLER_ARGS)
+{
+ uint16_t *id = arg1;
+ int i = *id;
+
+ return sysctl_handle_int(oidp, &i, 0, req);
+}
diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c
new file mode 100644
index 0000000..2040951
--- /dev/null
+++ b/sys/dev/glxiic/glxiic.c
@@ -0,0 +1,1077 @@
+/*-
+ * Copyright (c) 2011 Henrik Brix Andersen <brix@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+/*
+ * AMD Geode LX CS5536 System Management Bus controller.
+ *
+ * Although AMD refers to this device as an SMBus controller, it
+ * really is an I2C controller (It lacks SMBus ALERT# and Alert
+ * Response support).
+ *
+ * The driver is implemented as an interrupt-driven state machine,
+ * supporting both master and slave mode.
+ */
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/sysctl.h>
+#ifdef GLXIIC_DEBUG
+#include <sys/syslog.h>
+#endif
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+#include <machine/bus.h>
+#include <sys/rman.h>
+#include <machine/resource.h>
+
+#include <dev/iicbus/iiconf.h>
+#include <dev/iicbus/iicbus.h>
+
+#include "iicbus_if.h"
+
+/* CS5536 PCI-ISA ID. */
+#define GLXIIC_CS5536_DEV_ID 0x20901022
+
+/* MSRs. */
+#define GLXIIC_MSR_PIC_YSEL_HIGH 0x51400021
+
+/* Bus speeds. */
+#define GLXIIC_SLOW 0x0258 /* 10 kHz. */
+#define GLXIIC_FAST 0x0078 /* 50 kHz. */
+#define GLXIIC_FASTEST 0x003c /* 100 kHz. */
+
+/* Default bus activity timeout in milliseconds. */
+#define GLXIIC_DEFAULT_TIMEOUT 35
+
+/* GPIO register offsets. */
+#define GLXIIC_GPIOL_OUT_AUX1_SEL 0x10
+#define GLXIIC_GPIOL_IN_AUX1_SEL 0x34
+
+/* GPIO 14 (SMB_CLK) and 15 (SMB_DATA) bitmasks. */
+#define GLXIIC_GPIO_14_15_ENABLE 0x0000c000
+#define GLXIIC_GPIO_14_15_DISABLE 0xc0000000
+
+/* SMB register offsets. */
+#define GLXIIC_SMB_SDA 0x00
+#define GLXIIC_SMB_STS 0x01
+#define GLXIIC_SMB_STS_SLVSTP_BIT (1 << 7)
+#define GLXIIC_SMB_STS_SDAST_BIT (1 << 6)
+#define GLXIIC_SMB_STS_BER_BIT (1 << 5)
+#define GLXIIC_SMB_STS_NEGACK_BIT (1 << 4)
+#define GLXIIC_SMB_STS_STASTR_BIT (1 << 3)
+#define GLXIIC_SMB_STS_NMATCH_BIT (1 << 2)
+#define GLXIIC_SMB_STS_MASTER_BIT (1 << 1)
+#define GLXIIC_SMB_STS_XMIT_BIT (1 << 0)
+#define GLXIIC_SMB_CTRL_STS 0x02
+#define GLXIIC_SMB_CTRL_STS_TGSCL_BIT (1 << 5)
+#define GLXIIC_SMB_CTRL_STS_TSDA_BIT (1 << 4)
+#define GLXIIC_SMB_CTRL_STS_GCMTCH_BIT (1 << 3)
+#define GLXIIC_SMB_CTRL_STS_MATCH_BIT (1 << 2)
+#define GLXIIC_SMB_CTRL_STS_BB_BIT (1 << 1)
+#define GLXIIC_SMB_CTRL_STS_BUSY_BIT (1 << 0)
+#define GLXIIC_SMB_CTRL1 0x03
+#define GLXIIC_SMB_CTRL1_STASTRE_BIT (1 << 7)
+#define GLXIIC_SMB_CTRL1_NMINTE_BIT (1 << 6)
+#define GLXIIC_SMB_CTRL1_GCMEN_BIT (1 << 5)
+#define GLXIIC_SMB_CTRL1_ACK_BIT (1 << 4)
+#define GLXIIC_SMB_CTRL1_INTEN_BIT (1 << 2)
+#define GLXIIC_SMB_CTRL1_STOP_BIT (1 << 1)
+#define GLXIIC_SMB_CTRL1_START_BIT (1 << 0)
+#define GLXIIC_SMB_ADDR 0x04
+#define GLXIIC_SMB_ADDR_SAEN_BIT (1 << 7)
+#define GLXIIC_SMB_CTRL2 0x05
+#define GLXIIC_SMB_CTRL2_EN_BIT (1 << 0)
+#define GLXIIC_SMB_CTRL3 0x06
+
+typedef enum {
+ GLXIIC_STATE_IDLE,
+ GLXIIC_STATE_SLAVE_TX,
+ GLXIIC_STATE_SLAVE_RX,
+ GLXIIC_STATE_MASTER_ADDR,
+ GLXIIC_STATE_MASTER_TX,
+ GLXIIC_STATE_MASTER_RX,
+ GLXIIC_STATE_MASTER_STOP,
+ GLXIIC_STATE_MAX,
+} glxiic_state_t;
+
+struct glxiic_softc {
+ device_t dev; /* Myself. */
+ device_t iicbus; /* IIC bus. */
+ struct mtx mtx; /* Lock. */
+ glxiic_state_t state; /* Driver state. */
+ struct callout callout; /* Driver state timeout callout. */
+ int timeout; /* Driver state timeout (ms). */
+
+ int smb_rid; /* SMB controller resource ID. */
+ struct resource *smb_res; /* SMB controller resource. */
+ int gpio_rid; /* GPIO resource ID. */
+ struct resource *gpio_res; /* GPIO resource. */
+
+ int irq_rid; /* IRQ resource ID. */
+ struct resource *irq_res; /* IRQ resource. */
+ void *irq_handler; /* IRQ handler cookie. */
+ int old_irq; /* IRQ mapped by board firmware. */
+
+ struct iic_msg *msg; /* Current master mode message. */
+ uint32_t nmsgs; /* Number of messages remaining. */
+ uint8_t *data; /* Current master mode data byte. */
+ uint16_t ndata; /* Number of data bytes remaining. */
+ int error; /* Last master mode error. */
+
+ uint8_t addr; /* Own address. */
+ uint16_t sclfrq; /* Bus frequency. */
+};
+
+#ifdef GLXIIC_DEBUG
+#define DEBUG(fmt, args...) log(LOG_DEBUG, "%s: " fmt "\n" , __func__ , ## args)
+#else
+#define DEBUG(fmt, args...)
+#endif
+
+#define GLXIIC_SCLFRQ(n) ((n << 1))
+#define GLXIIC_SMBADDR(n) ((n >> 1))
+#define GLXIIC_SMB_IRQ_TO_MAP(n) ((n << 16))
+#define GLXIIC_MAP_TO_SMB_IRQ(n) ((n >> 16) & 0xf)
+
+#define GLXIIC_LOCK(_sc) mtx_lock(&_sc->mtx)
+#define GLXIIC_UNLOCK(_sc) mtx_unlock(&_sc->mtx)
+#define GLXIIC_LOCK_INIT(_sc) \
+ mtx_init(&_sc->mtx, device_get_nameunit(_sc->dev), "glxiic", MTX_DEF)
+#define GLXIIC_SLEEP(_sc) \
+ mtx_sleep(_sc, &_sc->mtx, IICPRI, "glxiic", 0)
+#define GLXIIC_WAKEUP(_sc) wakeup(_sc);
+#define GLXIIC_LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx);
+#define GLXIIC_ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED);
+
+typedef int (glxiic_state_callback_t)(struct glxiic_softc *sc,
+ uint8_t status);
+
+static glxiic_state_callback_t glxiic_state_idle_callback;
+static glxiic_state_callback_t glxiic_state_slave_tx_callback;
+static glxiic_state_callback_t glxiic_state_slave_rx_callback;
+static glxiic_state_callback_t glxiic_state_master_addr_callback;
+static glxiic_state_callback_t glxiic_state_master_tx_callback;
+static glxiic_state_callback_t glxiic_state_master_rx_callback;
+static glxiic_state_callback_t glxiic_state_master_stop_callback;
+
+struct glxiic_state_table_entry {
+ glxiic_state_callback_t *callback;
+ boolean_t master;
+};
+typedef struct glxiic_state_table_entry glxiic_state_table_entry_t;
+
+static glxiic_state_table_entry_t glxiic_state_table[GLXIIC_STATE_MAX] = {
+ [GLXIIC_STATE_IDLE] = {
+ .callback = &glxiic_state_idle_callback,
+ .master = FALSE,
+ },
+
+ [GLXIIC_STATE_SLAVE_TX] = {
+ .callback = &glxiic_state_slave_tx_callback,
+ .master = FALSE,
+ },
+
+ [GLXIIC_STATE_SLAVE_RX] = {
+ .callback = &glxiic_state_slave_rx_callback,
+ .master = FALSE,
+ },
+
+ [GLXIIC_STATE_MASTER_ADDR] = {
+ .callback = &glxiic_state_master_addr_callback,
+ .master = TRUE,
+ },
+
+ [GLXIIC_STATE_MASTER_TX] = {
+ .callback = &glxiic_state_master_tx_callback,
+ .master = TRUE,
+ },
+
+ [GLXIIC_STATE_MASTER_RX] = {
+ .callback = &glxiic_state_master_rx_callback,
+ .master = TRUE,
+ },
+
+ [GLXIIC_STATE_MASTER_STOP] = {
+ .callback = &glxiic_state_master_stop_callback,
+ .master = TRUE,
+ },
+};
+
+static void glxiic_identify(driver_t *driver, device_t parent);
+static int glxiic_probe(device_t dev);
+static int glxiic_attach(device_t dev);
+static int glxiic_detach(device_t dev);
+
+static uint8_t glxiic_read_status_locked(struct glxiic_softc *sc);
+static void glxiic_stop_locked(struct glxiic_softc *sc);
+static void glxiic_timeout(void *arg);
+static void glxiic_start_timeout_locked(struct glxiic_softc *sc);
+static void glxiic_set_state_locked(struct glxiic_softc *sc,
+ glxiic_state_t state);
+static int glxiic_handle_slave_match_locked(struct glxiic_softc *sc,
+ uint8_t status);
+static void glxiic_intr(void *arg);
+
+static int glxiic_reset(device_t dev, u_char speed, u_char addr,
+ u_char *oldaddr);
+static int glxiic_transfer(device_t dev, struct iic_msg *msgs,
+ uint32_t nmsgs);
+
+static void glxiic_smb_map_interrupt(int irq);
+static void glxiic_gpio_enable(struct glxiic_softc *sc);
+static void glxiic_gpio_disable(struct glxiic_softc *sc);
+static void glxiic_smb_enable(struct glxiic_softc *sc, uint8_t speed,
+ uint8_t addr);
+static void glxiic_smb_disable(struct glxiic_softc *sc);
+
+static device_method_t glxiic_methods[] = {
+ DEVMETHOD(device_identify, glxiic_identify),
+ DEVMETHOD(device_probe, glxiic_probe),
+ DEVMETHOD(device_attach, glxiic_attach),
+ DEVMETHOD(device_detach, glxiic_detach),
+
+ DEVMETHOD(iicbus_reset, glxiic_reset),
+ DEVMETHOD(iicbus_transfer, glxiic_transfer),
+ DEVMETHOD(iicbus_callback, iicbus_null_callback),
+
+ { 0, 0 }
+};
+
+static driver_t glxiic_driver = {
+ "glxiic",
+ glxiic_methods,
+ sizeof(struct glxiic_softc),
+};
+
+static devclass_t glxiic_devclass;
+
+DRIVER_MODULE(glxiic, isab, glxiic_driver, glxiic_devclass, 0, 0);
+DRIVER_MODULE(iicbus, glxiic, iicbus_driver, iicbus_devclass, 0, 0);
+MODULE_DEPEND(glxiic, iicbus, 1, 1, 1);
+
+static void
+glxiic_identify(driver_t *driver, device_t parent)
+{
+
+ /* Prevent child from being added more than once. */
+ if (device_find_child(parent, driver->name, -1) != NULL)
+ return;
+
+ if (pci_get_devid(parent) == GLXIIC_CS5536_DEV_ID) {
+ if (device_add_child(parent, driver->name, -1) == NULL)
+ device_printf(parent, "Could not add glxiic child\n");
+ }
+}
+
+static int
+glxiic_probe(device_t dev)
+{
+
+ if (resource_disabled("glxiic", device_get_unit(dev)))
+ return (ENXIO);
+
+ device_set_desc(dev, "AMD Geode CS5536 SMBus controller");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+glxiic_attach(device_t dev)
+{
+ struct glxiic_softc *sc;
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid *tree;
+ int error, irq, unit;
+ uint32_t irq_map;
+ char tn[32];
+
+ sc = device_get_softc(dev);
+ sc->dev = dev;
+ sc->state = GLXIIC_STATE_IDLE;
+ error = 0;
+
+ GLXIIC_LOCK_INIT(sc);
+ callout_init_mtx(&sc->callout, &sc->mtx, 0);
+
+ sc->smb_rid = PCIR_BAR(0);
+ sc->smb_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->smb_rid,
+ RF_ACTIVE);
+ if (sc->smb_res == NULL) {
+ device_printf(dev, "Could not allocate SMBus I/O port\n");
+ error = ENXIO;
+ goto out;
+ }
+
+ sc->gpio_rid = PCIR_BAR(1);
+ sc->gpio_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
+ &sc->gpio_rid, RF_SHAREABLE | RF_ACTIVE);
+ if (sc->gpio_res == NULL) {
+ device_printf(dev, "Could not allocate GPIO I/O port\n");
+ error = ENXIO;
+ goto out;
+ }
+
+ /* Ensure the controller is not enabled by firmware. */
+ glxiic_smb_disable(sc);
+
+ /* Read the existing IRQ map. */
+ irq_map = rdmsr(GLXIIC_MSR_PIC_YSEL_HIGH);
+ sc->old_irq = GLXIIC_MAP_TO_SMB_IRQ(irq_map);
+
+ unit = device_get_unit(dev);
+ if (resource_int_value("glxiic", unit, "irq", &irq) == 0) {
+ if (irq < 1 || irq > 15) {
+ device_printf(dev, "Bad value %d for glxiic.%d.irq\n",
+ irq, unit);
+ error = ENXIO;
+ goto out;
+ }
+
+ if (bootverbose)
+ device_printf(dev, "Using irq %d set by hint\n", irq);
+ } else if (sc->old_irq != 0) {
+ if (bootverbose)
+ device_printf(dev, "Using irq %d set by firmware\n",
+ irq);
+ irq = sc->old_irq;
+ } else {
+ device_printf(dev, "No irq mapped by firmware");
+ printf(" and no glxiic.%d.irq hint provided\n", unit);
+ error = ENXIO;
+ goto out;
+ }
+
+ /* Map the SMBus interrupt to the requested legacy IRQ. */
+ glxiic_smb_map_interrupt(irq);
+
+ sc->irq_rid = 0;
+ sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
+ irq, irq, 1, RF_SHAREABLE | RF_ACTIVE);
+ if (sc->irq_res == NULL) {
+ device_printf(dev, "Could not allocate IRQ %d\n", irq);
+ error = ENXIO;
+ goto out;
+ }
+
+ error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
+ NULL, glxiic_intr, sc, &(sc->irq_handler));
+ if (error != 0) {
+ device_printf(dev, "Could not setup IRQ handler\n");
+ error = ENXIO;
+ goto out;
+ }
+
+ if ((sc->iicbus = device_add_child(dev, "iicbus", -1)) == NULL) {
+ device_printf(dev, "Could not allocate iicbus instance\n");
+ error = ENXIO;
+ goto out;
+ }
+
+ ctx = device_get_sysctl_ctx(dev);
+ tree = device_get_sysctl_tree(dev);
+
+ sc->timeout = GLXIIC_DEFAULT_TIMEOUT;
+ snprintf(tn, sizeof(tn), "dev.glxiic.%d.timeout", unit);
+ TUNABLE_INT_FETCH(tn, &sc->timeout);
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+ "timeout", CTLFLAG_RW | CTLFLAG_TUN, &sc->timeout, 0,
+ "activity timeout in ms");
+
+ glxiic_gpio_enable(sc);
+ glxiic_smb_enable(sc, IIC_FASTEST, 0);
+
+ error = bus_generic_attach(dev);
+ if (error != 0) {
+ device_printf(dev, "Could not probe and attach children\n");
+ error = ENXIO;
+ }
+out:
+ if (error != 0) {
+ callout_drain(&sc->callout);
+
+ if (sc->iicbus != NULL)
+ device_delete_child(dev, sc->iicbus);
+ if (sc->smb_res != NULL) {
+ glxiic_smb_disable(sc);
+ bus_release_resource(dev, SYS_RES_IOPORT, sc->smb_rid,
+ sc->smb_res);
+ }
+ if (sc->gpio_res != NULL) {
+ glxiic_gpio_disable(sc);
+ bus_release_resource(dev, SYS_RES_IOPORT, sc->gpio_rid,
+ sc->gpio_res);
+ }
+ if (sc->irq_handler != NULL)
+ bus_teardown_intr(dev, sc->irq_res, sc->irq_handler);
+ if (sc->irq_res != NULL)
+ bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid,
+ sc->irq_res);
+
+ /* Restore the old SMBus interrupt mapping. */
+ glxiic_smb_map_interrupt(sc->old_irq);
+
+ GLXIIC_LOCK_DESTROY(sc);
+ }
+
+ return (error);
+}
+
+static int
+glxiic_detach(device_t dev)
+{
+ struct glxiic_softc *sc;
+ int error;
+
+ sc = device_get_softc(dev);
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ goto out;
+ if (sc->iicbus != NULL)
+ error = device_delete_child(dev, sc->iicbus);
+
+out:
+ callout_drain(&sc->callout);
+
+ if (sc->smb_res != NULL) {
+ glxiic_smb_disable(sc);
+ bus_release_resource(dev, SYS_RES_IOPORT, sc->smb_rid,
+ sc->smb_res);
+ }
+ if (sc->gpio_res != NULL) {
+ glxiic_gpio_disable(sc);
+ bus_release_resource(dev, SYS_RES_IOPORT, sc->gpio_rid,
+ sc->gpio_res);
+ }
+ if (sc->irq_handler != NULL)
+ bus_teardown_intr(dev, sc->irq_res, sc->irq_handler);
+ if (sc->irq_res != NULL)
+ bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid,
+ sc->irq_res);
+
+ /* Restore the old SMBus interrupt mapping. */
+ glxiic_smb_map_interrupt(sc->old_irq);
+
+ GLXIIC_LOCK_DESTROY(sc);
+
+ return (error);
+}
+
+static uint8_t
+glxiic_read_status_locked(struct glxiic_softc *sc)
+{
+ uint8_t status;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ status = bus_read_1(sc->smb_res, GLXIIC_SMB_STS);
+
+ /* Clear all status flags except SDAST and STASTR after reading. */
+ bus_write_1(sc->smb_res, GLXIIC_SMB_STS, (GLXIIC_SMB_STS_SLVSTP_BIT |
+ GLXIIC_SMB_STS_BER_BIT | GLXIIC_SMB_STS_NEGACK_BIT |
+ GLXIIC_SMB_STS_NMATCH_BIT));
+
+ return (status);
+}
+
+static void
+glxiic_stop_locked(struct glxiic_softc *sc)
+{
+ uint8_t status, ctrl1;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ status = glxiic_read_status_locked(sc);
+
+ ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
+ bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+ ctrl1 | GLXIIC_SMB_CTRL1_STOP_BIT);
+
+ /*
+ * Perform a dummy read of SDA in master receive mode to clear
+ * SDAST if set.
+ */
+ if ((status & GLXIIC_SMB_STS_XMIT_BIT) == 0 &&
+ (status & GLXIIC_SMB_STS_SDAST_BIT) != 0)
+ bus_read_1(sc->smb_res, GLXIIC_SMB_SDA);
+
+ /* Check stall after start bit and clear if needed */
+ if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) {
+ bus_write_1(sc->smb_res, GLXIIC_SMB_STS,
+ GLXIIC_SMB_STS_STASTR_BIT);
+ }
+}
+
+static void
+glxiic_timeout(void *arg)
+{
+ struct glxiic_softc *sc;
+ uint8_t error;
+
+ sc = (struct glxiic_softc *)arg;
+
+ DEBUG("timeout in state %d", sc->state);
+
+ if (glxiic_state_table[sc->state].master) {
+ sc->error = IIC_ETIMEOUT;
+ GLXIIC_WAKEUP(sc);
+ } else {
+ error = IIC_ETIMEOUT;
+ iicbus_intr(sc->iicbus, INTR_ERROR, &error);
+ }
+
+ glxiic_smb_disable(sc);
+ glxiic_smb_enable(sc, IIC_UNKNOWN, sc->addr);
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+}
+
+static void
+glxiic_start_timeout_locked(struct glxiic_softc *sc)
+{
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ callout_reset(&sc->callout, sc->timeout * 1000 / hz, glxiic_timeout,
+ sc);
+}
+
+static void
+glxiic_set_state_locked(struct glxiic_softc *sc, glxiic_state_t state)
+{
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if (state == GLXIIC_STATE_IDLE)
+ callout_stop(&sc->callout);
+ else if (sc->timeout > 0)
+ glxiic_start_timeout_locked(sc);
+
+ sc->state = state;
+}
+
+static int
+glxiic_handle_slave_match_locked(struct glxiic_softc *sc, uint8_t status)
+{
+ uint8_t ctrl_sts, addr;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ ctrl_sts = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL_STS);
+
+ if ((ctrl_sts & GLXIIC_SMB_CTRL_STS_MATCH_BIT) != 0) {
+ if ((status & GLXIIC_SMB_STS_XMIT_BIT) != 0) {
+ addr = sc->addr | LSB;
+ glxiic_set_state_locked(sc,
+ GLXIIC_STATE_SLAVE_TX);
+ } else {
+ addr = sc->addr & ~LSB;
+ glxiic_set_state_locked(sc,
+ GLXIIC_STATE_SLAVE_RX);
+ }
+ iicbus_intr(sc->iicbus, INTR_START, &addr);
+ } else if ((ctrl_sts & GLXIIC_SMB_CTRL_STS_GCMTCH_BIT) != 0) {
+ addr = 0;
+ glxiic_set_state_locked(sc, GLXIIC_STATE_SLAVE_RX);
+ iicbus_intr(sc->iicbus, INTR_GENERAL, &addr);
+ } else {
+ DEBUG("unknown slave match");
+ return (IIC_ESTATUS);
+ }
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_idle_callback(struct glxiic_softc *sc, uint8_t status)
+{
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error in idle");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NMATCH_BIT) != 0) {
+ return (glxiic_handle_slave_match_locked(sc, status));
+ }
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_slave_tx_callback(struct glxiic_softc *sc, uint8_t status)
+{
+ uint8_t data;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error in slave tx");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_SLVSTP_BIT) != 0) {
+ iicbus_intr(sc->iicbus, INTR_STOP, NULL);
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+ return (IIC_NOERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) {
+ iicbus_intr(sc->iicbus, INTR_NOACK, NULL);
+ return (IIC_NOERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NMATCH_BIT) != 0) {
+ /* Handle repeated start in slave mode. */
+ return (glxiic_handle_slave_match_locked(sc, status));
+ }
+
+ if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) {
+ DEBUG("not awaiting data in slave tx");
+ return (IIC_ESTATUS);
+ }
+
+ iicbus_intr(sc->iicbus, INTR_TRANSMIT, &data);
+ bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, data);
+
+ glxiic_start_timeout_locked(sc);
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_slave_rx_callback(struct glxiic_softc *sc, uint8_t status)
+{
+ uint8_t data;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error in slave rx");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_SLVSTP_BIT) != 0) {
+ iicbus_intr(sc->iicbus, INTR_STOP, NULL);
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+ return (IIC_NOERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NMATCH_BIT) != 0) {
+ /* Handle repeated start in slave mode. */
+ return (glxiic_handle_slave_match_locked(sc, status));
+ }
+
+ if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) {
+ DEBUG("no pending data in slave rx");
+ return (IIC_ESTATUS);
+ }
+
+ data = bus_read_1(sc->smb_res, GLXIIC_SMB_SDA);
+ iicbus_intr(sc->iicbus, INTR_RECEIVE, &data);
+
+ glxiic_start_timeout_locked(sc);
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_master_addr_callback(struct glxiic_softc *sc, uint8_t status)
+{
+ uint8_t slave;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error after master start");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) {
+ DEBUG("not bus master after master start");
+ return (IIC_ESTATUS);
+ }
+
+ if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) {
+ DEBUG("not awaiting address in master addr");
+ return (IIC_ESTATUS);
+ }
+
+ if ((sc->msg->flags & IIC_M_RD) != 0) {
+ slave = sc->msg->slave | LSB;
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_RX);
+ } else {
+ slave = sc->msg->slave & ~LSB;
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_TX);
+ }
+
+ sc->data = sc->msg->buf;
+ sc->ndata = sc->msg->len;
+
+ /* Handle address-only transfer. */
+ if (sc->ndata == 0)
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_STOP);
+
+ bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, slave);
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_master_tx_callback(struct glxiic_softc *sc, uint8_t status)
+{
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error in master tx");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) {
+ DEBUG("not bus master in master tx");
+ return (IIC_ESTATUS);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) {
+ DEBUG("slave nack in master tx");
+ return (IIC_ENOACK);
+ }
+
+ if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) {
+ bus_write_1(sc->smb_res, GLXIIC_SMB_STS,
+ GLXIIC_SMB_STS_STASTR_BIT);
+ }
+
+ if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) {
+ DEBUG("not awaiting data in master tx");
+ return (IIC_ESTATUS);
+ }
+
+ bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, *sc->data++);
+ if (--sc->ndata == 0)
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_STOP);
+ else
+ glxiic_start_timeout_locked(sc);
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_master_rx_callback(struct glxiic_softc *sc, uint8_t status)
+{
+ uint8_t ctrl1;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error in master rx");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) {
+ DEBUG("not bus master in master rx");
+ return (IIC_ESTATUS);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) {
+ DEBUG("slave nack in rx");
+ return (IIC_ENOACK);
+ }
+
+ if (sc->ndata == 1) {
+ /* Last byte from slave, set NACK. */
+ ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
+ bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+ ctrl1 | GLXIIC_SMB_CTRL1_ACK_BIT);
+ }
+
+ if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) {
+ /* Bus is stalled, clear and wait for data. */
+ bus_write_1(sc->smb_res, GLXIIC_SMB_STS,
+ GLXIIC_SMB_STS_STASTR_BIT);
+ return (IIC_NOERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) {
+ DEBUG("no pending data in master rx");
+ return (IIC_ESTATUS);
+ }
+
+ *sc->data++ = bus_read_1(sc->smb_res, GLXIIC_SMB_SDA);
+ if (--sc->ndata == 0) {
+ /* Proceed with stop on reading last byte. */
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_STOP);
+ return (glxiic_state_table[sc->state].callback(sc, status));
+ }
+
+ glxiic_start_timeout_locked(sc);
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_state_master_stop_callback(struct glxiic_softc *sc, uint8_t status)
+{
+ uint8_t ctrl1;
+
+ GLXIIC_ASSERT_LOCKED(sc);
+
+ if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) {
+ DEBUG("bus error in master stop");
+ return (IIC_EBUSERR);
+ }
+
+ if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) {
+ DEBUG("not bus master in master stop");
+ return (IIC_ESTATUS);
+ }
+
+ if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) {
+ DEBUG("slave nack in master stop");
+ return (IIC_ENOACK);
+ }
+
+ if (--sc->nmsgs > 0) {
+ /* Start transfer of next message. */
+ if ((sc->msg->flags & IIC_M_NOSTOP) == 0) {
+ glxiic_stop_locked(sc);
+ }
+
+ ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
+ bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+ ctrl1 | GLXIIC_SMB_CTRL1_START_BIT);
+
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_ADDR);
+ sc->msg++;
+ } else {
+ /* Last message. */
+ glxiic_stop_locked(sc);
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+ sc->error = IIC_NOERR;
+ GLXIIC_WAKEUP(sc);
+ }
+
+ return (IIC_NOERR);
+}
+
+static void
+glxiic_intr(void *arg)
+{
+ struct glxiic_softc *sc;
+ int error;
+ uint8_t status, data;
+
+ sc = (struct glxiic_softc *)arg;
+
+ GLXIIC_LOCK(sc);
+
+ status = glxiic_read_status_locked(sc);
+
+ /* Check if this interrupt originated from the SMBus. */
+ if ((status &
+ ~(GLXIIC_SMB_STS_MASTER_BIT | GLXIIC_SMB_STS_XMIT_BIT)) != 0) {
+
+ error = glxiic_state_table[sc->state].callback(sc, status);
+
+ if (error != IIC_NOERR) {
+ if (glxiic_state_table[sc->state].master) {
+ glxiic_stop_locked(sc);
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+ sc->error = error;
+ GLXIIC_WAKEUP(sc);
+ } else {
+ data = error & 0xff;
+ iicbus_intr(sc->iicbus, INTR_ERROR, &data);
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+ }
+ }
+ }
+
+ GLXIIC_UNLOCK(sc);
+}
+
+static int
+glxiic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr)
+{
+ struct glxiic_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ GLXIIC_LOCK(sc);
+
+ if (oldaddr != NULL)
+ *oldaddr = sc->addr;
+ sc->addr = addr;
+
+ /* A disable/enable cycle resets the controller. */
+ glxiic_smb_disable(sc);
+ glxiic_smb_enable(sc, speed, addr);
+
+ if (glxiic_state_table[sc->state].master) {
+ sc->error = IIC_ESTATUS;
+ GLXIIC_WAKEUP(sc);
+ }
+ glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE);
+
+ GLXIIC_UNLOCK(sc);
+
+ return (IIC_NOERR);
+}
+
+static int
+glxiic_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
+{
+ struct glxiic_softc *sc;
+ int error;
+ uint8_t ctrl1;
+
+ sc = device_get_softc(dev);
+
+ GLXIIC_LOCK(sc);
+
+ if (sc->state != GLXIIC_STATE_IDLE) {
+ error = IIC_EBUSBSY;
+ goto out;
+ }
+
+ sc->msg = msgs;
+ sc->nmsgs = nmsgs;
+ glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_ADDR);
+
+ /* Set start bit and let glxiic_intr() handle the transfer. */
+ ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1);
+ bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+ ctrl1 | GLXIIC_SMB_CTRL1_START_BIT);
+
+ GLXIIC_SLEEP(sc);
+ error = sc->error;
+out:
+ GLXIIC_UNLOCK(sc);
+
+ return (error);
+}
+
+static void
+glxiic_smb_map_interrupt(int irq)
+{
+ uint32_t irq_map;
+ int old_irq;
+
+ /* Protect the read-modify-write operation. */
+ critical_enter();
+
+ irq_map = rdmsr(GLXIIC_MSR_PIC_YSEL_HIGH);
+ old_irq = GLXIIC_MAP_TO_SMB_IRQ(irq_map);
+
+ if (irq != old_irq) {
+ irq_map &= ~GLXIIC_SMB_IRQ_TO_MAP(old_irq);
+ irq_map |= GLXIIC_SMB_IRQ_TO_MAP(irq);
+ wrmsr(GLXIIC_MSR_PIC_YSEL_HIGH, irq_map);
+ }
+
+ critical_exit();
+}
+
+static void
+glxiic_gpio_enable(struct glxiic_softc *sc)
+{
+
+ bus_write_4(sc->gpio_res, GLXIIC_GPIOL_IN_AUX1_SEL,
+ GLXIIC_GPIO_14_15_ENABLE);
+ bus_write_4(sc->gpio_res, GLXIIC_GPIOL_OUT_AUX1_SEL,
+ GLXIIC_GPIO_14_15_ENABLE);
+}
+
+static void
+glxiic_gpio_disable(struct glxiic_softc *sc)
+{
+
+ bus_write_4(sc->gpio_res, GLXIIC_GPIOL_OUT_AUX1_SEL,
+ GLXIIC_GPIO_14_15_DISABLE);
+ bus_write_4(sc->gpio_res, GLXIIC_GPIOL_IN_AUX1_SEL,
+ GLXIIC_GPIO_14_15_DISABLE);
+}
+
+static void
+glxiic_smb_enable(struct glxiic_softc *sc, uint8_t speed, uint8_t addr)
+{
+ uint8_t ctrl1;
+
+ ctrl1 = 0;
+
+ switch (speed) {
+ case IIC_SLOW:
+ sc->sclfrq = GLXIIC_SLOW;
+ break;
+ case IIC_FAST:
+ sc->sclfrq = GLXIIC_FAST;
+ break;
+ case IIC_FASTEST:
+ sc->sclfrq = GLXIIC_FASTEST;
+ break;
+ case IIC_UNKNOWN:
+ default:
+ /* Reuse last frequency. */
+ break;
+ }
+
+ /* Set bus speed and enable controller. */
+ bus_write_2(sc->smb_res, GLXIIC_SMB_CTRL2,
+ GLXIIC_SCLFRQ(sc->sclfrq) | GLXIIC_SMB_CTRL2_EN_BIT);
+
+ if (addr != 0) {
+ /* Enable new match and global call match interrupts. */
+ ctrl1 |= GLXIIC_SMB_CTRL1_NMINTE_BIT |
+ GLXIIC_SMB_CTRL1_GCMEN_BIT;
+ bus_write_1(sc->smb_res, GLXIIC_SMB_ADDR,
+ GLXIIC_SMB_ADDR_SAEN_BIT | GLXIIC_SMBADDR(addr));
+ } else {
+ bus_write_1(sc->smb_res, GLXIIC_SMB_ADDR, 0);
+ }
+
+ /* Enable stall after start and interrupt. */
+ bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1,
+ ctrl1 | GLXIIC_SMB_CTRL1_STASTRE_BIT | GLXIIC_SMB_CTRL1_INTEN_BIT);
+}
+
+static void
+glxiic_smb_disable(struct glxiic_softc *sc)
+{
+ uint16_t sclfrq;
+
+ sclfrq = bus_read_2(sc->smb_res, GLXIIC_SMB_CTRL2);
+ bus_write_2(sc->smb_res, GLXIIC_SMB_CTRL2,
+ sclfrq & ~GLXIIC_SMB_CTRL2_EN_BIT);
+}
diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index 11c5238..29e391f 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -3527,7 +3527,8 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
BUS_DMASYNC_PREWRITE);
/* Update TX scheduler. */
- ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
+ if (ring->qid >= sc->firstaggqueue)
+ ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
/* Kick TX ring. */
ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT;
@@ -3730,7 +3731,8 @@ iwn_tx_data_raw(struct iwn_softc *sc, struct mbuf *m,
BUS_DMASYNC_PREWRITE);
/* Update TX scheduler. */
- ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
+ if (ring->qid >= sc->firstaggqueue)
+ ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
/* Kick TX ring. */
ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT;
@@ -3894,7 +3896,6 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
static int
iwn_cmd(struct iwn_softc *sc, int code, const void *buf, int size, int async)
{
- struct iwn_ops *ops = &sc->ops;
struct iwn_tx_ring *ring = &sc->txq[4];
struct iwn_tx_desc *desc;
struct iwn_tx_data *data;
@@ -3954,9 +3955,6 @@ iwn_cmd(struct iwn_softc *sc, int code, const void *buf, int size, int async)
bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
BUS_DMASYNC_PREWRITE);
- /* Update TX scheduler. */
- ops->update_sched(sc, ring->qid, ring->cur, 0, 0);
-
/* Kick command ring. */
ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT;
IWN_WRITE(sc, IWN_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur);
diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c
index fbdd0ea..224f85d 100644
--- a/sys/dev/mii/mii.c
+++ b/sys/dev/mii/mii.c
@@ -552,7 +552,7 @@ mii_down(struct mii_data *mii)
static unsigned char
mii_bitreverse(unsigned char x)
{
- static unsigned char nibbletab[16] = {
+ unsigned const char const nibbletab[16] = {
0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
};
@@ -567,6 +567,6 @@ mii_oui(u_int id1, u_int id2)
h = (id1 << 6) | (id2 >> 10);
return ((mii_bitreverse(h >> 16) << 16) |
- (mii_bitreverse((h >> 8) & 0xff) << 8) |
- mii_bitreverse(h & 0xff));
+ (mii_bitreverse((h >> 8) & 0xff) << 8) |
+ mii_bitreverse(h & 0xff));
}
diff --git a/sys/dev/mk48txx/mk48txx.c b/sys/dev/mk48txx/mk48txx.c
index 9742e82..de116d0 100644
--- a/sys/dev/mk48txx/mk48txx.c
+++ b/sys/dev/mk48txx/mk48txx.c
@@ -33,7 +33,8 @@
__FBSDID("$FreeBSD$");
/*
- * Mostek MK48T02, MK48T08, MK48T18, MK48T59 time-of-day chip subroutines
+ * Mostek MK48T02, MK48T08, MK48T18, MK48T37 and MK48T59 time-of-day chip
+ * subroutines
*/
#include <sys/param.h>
@@ -67,6 +68,7 @@ static const struct {
{ "mk48t02", MK48T02_CLKSZ, MK48T02_CLKOFF, 0 },
{ "mk48t08", MK48T08_CLKSZ, MK48T08_CLKOFF, 0 },
{ "mk48t18", MK48T18_CLKSZ, MK48T18_CLKOFF, 0 },
+ { "mk48t37", MK48T37_CLKSZ, MK48T37_CLKOFF, MK48TXX_EXT_REGISTERS },
{ "mk48t59", MK48T59_CLKSZ, MK48T59_CLKOFF, MK48TXX_EXT_REGISTERS },
};
diff --git a/sys/dev/mk48txx/mk48txxreg.h b/sys/dev/mk48txx/mk48txxreg.h
index bae6ae5..ef55b87 100644
--- a/sys/dev/mk48txx/mk48txxreg.h
+++ b/sys/dev/mk48txx/mk48txxreg.h
@@ -152,5 +152,8 @@
#define MK48T18_CLKSZ 8192
#define MK48T18_CLKOFF 0x1ff0
+#define MK48T37_CLKSZ 32768
+#define MK48T37_CLKOFF 0x1ff0
+
#define MK48T59_CLKSZ 8192
#define MK48T59_CLKOFF 0x1ff0
diff --git a/sys/dev/scc/scc_bfe_ebus.c b/sys/dev/scc/scc_bfe_ebus.c
index 17386db..6c944f7 100644
--- a/sys/dev/scc/scc_bfe_ebus.c
+++ b/sys/dev/scc/scc_bfe_ebus.c
@@ -56,7 +56,8 @@ scc_ebus_probe(device_t dev)
cmpt = ofw_bus_get_compat(dev);
if (cmpt == NULL)
cmpt = "";
- if (!strcmp(nm, "se") || !strcmp(cmpt, "sab82532")) {
+ if (!strcmp(nm, "se") || !strcmp(nm, "FJSV,se") ||
+ !strcmp(cmpt, "sab82532")) {
device_set_desc(dev, "Siemens SAB 82532 dual channel SCC");
sc->sc_class = &scc_sab82532_class;
return (scc_bfe_probe(dev, EBUS_REGSHFT, EBUS_RCLK, 0));
diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c
index c89b39f..582e919 100644
--- a/sys/dev/uart/uart_cpu_sparc64.c
+++ b/sys/dev/uart/uart_cpu_sparc64.c
@@ -238,7 +238,8 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
di->bas.regshft = 0;
di->bas.rclk = 0;
class = NULL;
- if (!strcmp(buf, "se") || !strcmp(compat, "sab82532")) {
+ if (!strcmp(buf, "se") || !strcmp(buf, "FJSV,se") ||
+ !strcmp(compat, "sab82532")) {
class = &uart_sab82532_class;
/* SAB82532 are only known to be used for TTYs. */
if ((di->bas.chan = uart_cpu_channel(dev)) == 0)
diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c
index 0a5a9ca..de4989b 100644
--- a/sys/geom/eli/g_eli_key_cache.c
+++ b/sys/geom/eli/g_eli_key_cache.c
@@ -124,6 +124,7 @@ g_eli_key_allocate(struct g_eli_softc *sc, uint64_t keyno)
ekey = RB_FIND(g_eli_key_tree, &sc->sc_ekeys_tree, &keysearch);
if (ekey != NULL) {
bzero(key, sizeof(*key));
+ free(key, M_ELI);
key = ekey;
TAILQ_REMOVE(&sc->sc_ekeys_queue, key, gek_next);
} else {
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index a68037b..866e641 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -731,6 +731,12 @@ options SAFE_DEBUG # enable debugging support: hw.safe.debug
options SAFE_RNDTEST # enable rndtest support
#
+# glxiic is an I2C driver for the AMD Geode LX CS5536 System Management Bus
+# controller. Requires 'device iicbus'.
+#
+device glxiic # AMD Geode LX CS5536 System Management Bus
+
+#
# glxsb is a driver for the Security Block in AMD Geode LX processors.
# Requires 'device crypto'.
#
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index f3e67c9..a83d56f 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -102,6 +102,7 @@ SUBDIR= ${_3dfx} \
fxp \
gem \
geom \
+ ${_glxiic} \
${_glxsb} \
hatm \
hifn \
@@ -419,6 +420,7 @@ _et= et
_exca= exca
_ext2fs= ext2fs
_fe= fe
+_glxiic= glxiic
_glxsb= glxsb
_i2c= i2c
_ibcs2= ibcs2
diff --git a/sys/modules/glxiic/Makefile b/sys/modules/glxiic/Makefile
new file mode 100644
index 0000000..46b0c07
--- /dev/null
+++ b/sys/modules/glxiic/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+#CFLAGS+= -DGLXIIC_DEBUG
+
+.PATH: ${.CURDIR}/../../dev/glxiic
+KMOD= glxiic
+SRCS= glxiic.c
+SRCS+= device_if.h bus_if.h pci_if.h iicbus_if.h
+
+.include <bsd.kmod.mk>
diff --git a/sys/net/if_media.h b/sys/net/if_media.h
index 1eb26ea..b6fd316 100644
--- a/sys/net/if_media.h
+++ b/sys/net/if_media.h
@@ -370,6 +370,7 @@ struct ifmedia_description {
}
#define IFM_SUBTYPE_ETHERNET_ALIASES { \
+ { IFM_10_T, "10baseT" }, \
{ IFM_10_T, "UTP" }, \
{ IFM_10_T, "10UTP" }, \
{ IFM_10_2, "BNC" }, \
@@ -389,6 +390,23 @@ struct ifmedia_description {
{ IFM_1000_T, "1000TX" }, \
{ IFM_1000_T, "1000T" }, \
{ IFM_2500_SX, "2500SX" }, \
+ \
+ /* \
+ * Shorthands for common media+option combinations as announced \
+ * by miibus(4) \
+ */ \
+ { IFM_10_T | IFM_FDX, "10baseT-FDX" }, \
+ { IFM_10_T | IFM_FDX | IFM_FLOW, "10baseT-FDX-flow" }, \
+ { IFM_100_TX | IFM_FDX, "100baseTX-FDX" }, \
+ { IFM_100_TX | IFM_FDX | IFM_FLOW, "100baseTX-FDX-flow" }, \
+ { IFM_1000_T | IFM_FDX, "1000baseT-FDX" }, \
+ { IFM_1000_T | IFM_FDX | IFM_FLOW, "1000baseT-FDX-flow" }, \
+ { IFM_1000_T | IFM_FDX | IFM_FLOW | IFM_ETH_MASTER, \
+ "1000baseT-FDX-flow-master" }, \
+ { IFM_1000_T | IFM_FDX | IFM_ETH_MASTER, \
+ "1000baseT-FDX-master" }, \
+ { IFM_1000_T | IFM_ETH_MASTER, "1000baseT-master" }, \
+ \
{ 0, NULL }, \
}
@@ -584,6 +602,13 @@ struct ifmedia_description {
#define IFM_SUBTYPE_SHARED_ALIASES { \
{ IFM_AUTO, "auto" }, \
+ \
+ /* \
+ * Shorthands for common media+option combinations as announced \
+ * by miibus(4) \
+ */ \
+ { IFM_AUTO | IFM_FLOW, "auto-flow" }, \
+ \
{ 0, NULL }, \
}
diff --git a/sys/sparc64/sparc64/eeprom.c b/sys/sparc64/sparc64/eeprom.c
index da9909a..e90aecb 100644
--- a/sys/sparc64/sparc64/eeprom.c
+++ b/sys/sparc64/sparc64/eeprom.c
@@ -107,8 +107,11 @@ DRIVER_MODULE(eeprom, sbus, eeprom_driver, eeprom_devclass, 0, 0);
static int
eeprom_probe(device_t dev)
{
+ const char *name;
- if (strcmp("eeprom", ofw_bus_get_name(dev)) == 0) {
+ name = ofw_bus_get_name(dev);
+ if (strcmp(name, "eeprom") == 0 ||
+ strcmp(name, "FJSV,eeprom") == 0) {
device_set_desc(dev, "EEPROM/clock");
return (0);
}
OpenPOWER on IntegriCloud