[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Jul 25 14:36:35 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/97fc4cc0d663
changeset: 517:97fc4cc0d663
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Wed Jul 25 17:32:49 2012 +0300
description:
Lazy update

diffstat:

 head/sys/dev/gpio/zwmux.c |  666 ----------------------------------------------
 1 files changed, 0 insertions(+), 666 deletions(-)

diffs (670 lines):

diff -r 8744504844bf -r 97fc4cc0d663 head/sys/dev/gpio/zwmux.c
--- a/head/sys/dev/gpio/zwmux.c	Wed Jul 25 17:30:44 2012 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,666 +0,0 @@
-/*-
- * Copyright (c) 2012, Aleksandr Rybalko <ray at dlink.ua>
- * 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 unmodified, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/rman.h>
-#include <sys/sx.h>
-//#include <sys/sysctl.h>
-#include <sys/uio.h>
-
-#include <sys/gpio.h>
-#include "gpiobus_if.h"
-
-#include <dev/spibus/spi.h>
-#include <dev/spibus/spibusvar.h>
-#include "spibus_if.h"
-
-#define ZWMUX_DEBUG
-#ifdef ZWMUX_DEBUG
-#define dprintf printf
-
-#ifndef	ZWMUX_VARIFY_WRITE
-#define	ZWMUX_VARIFY_WRITE
-#endif
-
-#else
-#define dprintf(x, arg...)
-#endif
-
-#define	PIN_SETFLAGS(_sc, _pin, _val) \
-    GPIOBUS_PIN_SETFLAGS((_sc)->sc_busdev, (_sc)->sc_dev, (_sc)->sc_ ## _pin, \
-	(_val))
-#define	PIN_SET(_sc, _pin, _val) \
-    GPIOBUS_PIN_SET((_sc)->sc_busdev, (_sc)->sc_dev, (_sc)->sc_ ## _pin, \
-	(_val))
-#define	PIN_GET(_sc, _pin, _val) \
-    GPIOBUS_PIN_GET((_sc)->sc_busdev, (_sc)->sc_dev, (_sc)->sc_ ## _pin, \
-	(_val))
-
-#define	ZWAVE_CMD_GET_FLASH_WORD_L8	0x20
-#define	ZWAVE_CMD_GET_FLASH_WORD_H8	0x28
-#define	ZWAVE_CMD_WRITE_RAM_WORD_L8	0x40
-#define	ZWAVE_CMD_WRITE_RAM_WORD_H8	0x48
-#define	ZWAVE_CMD_GET_SIG		0x30
-#define	ZWAVE_CMD_SYNC		0xac
-#define	ZWAVE_CMD_SYNC_PTRN		0x53
-#define	ZWAVE_CMD_COPY_FLASH_PAGE	0x4c
-#define	ZWAVE_CMD_ERASE_FLASH	0xac
-#define	ZWAVE_CMD_ERASE_TIMING		0x5d
-#define	ZWAVE_CMD_ERASE_FLASH_PAGE	0xc0
-#define	ZWAVE_CMD_ERASE_FLASH_FULL	0x80
-#define	ZWAVE_ERASE_FLASH_FULL		-1
-
-#define	MODULE_PAGE_SIZE		0x100
-#define	MODULE_FW_SIZE			0x8000
-
-struct zwmux_softc {
-	device_t	sc_dev;
-	device_t	sc_busdev;
-	struct cdev 	*sc_cdev;
-	uint8_t		sc_sclk;
-	uint8_t		sc_miso;
-	uint8_t		sc_mosi;
-	uint8_t		sc_cs;
-	uint8_t		sc_eept;
-	uint8_t		sc_zwrst;
-	int		sc_zw_synced;
-};
-
-static d_open_t		zwmux_open;
-static d_read_t		zwmux_read;
-static d_write_t	zwmux_write;
-static d_close_t	zwmux_close;
-
-static int zwmux_get_image(struct zwmux_softc *, uint16_t, uint8_t *, int);
-static int zwmux_write_mem(struct zwmux_softc *, uint16_t, uint8_t *, int);
-static int zwmux_copy_flash_page(struct zwmux_softc *, int);
-static int zwmux_erase_flash(struct zwmux_softc *, int);
-static int zwmux_set_erase_timing(struct zwmux_softc *, int);
-static int zwmux_get_sig_byte(struct zwmux_softc *, int);
-static int zwmux_check_sig(struct zwmux_softc *);
-
-static struct cdevsw zwmux_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_open =	zwmux_open,	/* Put module into Reset state */
-	.d_read =	zwmux_read,	/* Read FW image from module */
-	.d_write =	zwmux_write,	/* Write new FW image into device */
-	.d_close =	zwmux_close,	/* Release Reset pin */
-	.d_name =	"zwmux",
-};
-
-//SYSCTL_NODE(_hw, OID_AUTO, zwmux, CTLFLAG_RD, 0,
-//    "ZWMux module driver parameters");
-//
-static int sysctl_delay = 0;
-//SYSCTL_INT(_hw_zwmux, OID_AUTO, delay, CTLFLAG_RW, &sysctl_delay, 0,
-//    "delay - half clock time in uS");
-//TUNABLE_INT("hw.zwmux.delay", &sysctl_delay);
-
-static MALLOC_DEFINE(M_ZWMUX, "ZWMUX", "ZWave FW access module driver");
-
-static int
-zwmux_probe(device_t dev)
-{
-	device_set_desc(dev, "ZWMux driver");
-	return (0);
-}
-
-static int
-zwmux_attach(device_t dev)
-{
-	uint32_t value;
-	struct zwmux_softc *sc;
-
-	sc = device_get_softc(dev);
-	sc->sc_dev = dev;
-	sc->sc_busdev = device_get_parent(dev);
-
-#define	GET_HINTED(_name) \
-	if (resource_int_value(device_get_name(dev), \
-	    device_get_unit(dev), #_name, &value)) \
-		return (ENXIO); \
-	sc->sc_ ## _name = value & 0xff
-	/* Required variables */
-	GET_HINTED(sclk);
-	GET_HINTED(mosi);
-	GET_HINTED(miso);
-	GET_HINTED(cs);
-	GET_HINTED(eept);
-	GET_HINTED(zwrst);
-#undef	GET_HINTED
-
-	if (bootverbose)
-		printf("Use GPIO pins: sclk=%d, mosi=%d, miso=%d, "
-		    "cs=%d, eept=%d, zwrst=%d\n",
-		    sc->sc_sclk, sc->sc_mosi, sc->sc_miso,
-		    sc->sc_cs, sc->sc_eept, sc->sc_zwrst);
-
-	GPIOBUS_LOCK_BUS(sc->sc_busdev);
-	GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev);
-
-	/* Set directions */
-	PIN_SETFLAGS(sc, miso,	GPIO_PIN_INPUT |GPIO_PIN_PULLUP);
-	PIN_SETFLAGS(sc, sclk,	GPIO_PIN_OUTPUT|GPIO_PIN_PULLUP);
-	PIN_SETFLAGS(sc, mosi,	GPIO_PIN_OUTPUT|GPIO_PIN_PULLUP);
-	PIN_SETFLAGS(sc, cs,	GPIO_PIN_OUTPUT|GPIO_PIN_PULLUP);
-	PIN_SETFLAGS(sc, eept,	GPIO_PIN_OUTPUT|GPIO_PIN_PULLUP);
-	PIN_SETFLAGS(sc, zwrst,	GPIO_PIN_OUTPUT|GPIO_PIN_PULLUP);
-
-	GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
-	GPIOBUS_UNLOCK_BUS(sc->sc_busdev);
-
-	sc->sc_cdev = make_dev(&zwmux_cdevsw, device_get_unit(dev),
-	    UID_ROOT, GID_WHEEL, 0600, "zwflash");
-	sc->sc_cdev->si_drv1 = sc;
-
-	device_t spibus = device_add_child(dev, "spibus", -1);
-	device_printf(dev, "Attach spibus child %s\n", (spibus) ?
-	    device_get_nameunit(spibus) : "NULL");
-	return (bus_generic_attach(dev));
-}
-
-static int
-zwmux_detach(device_t dev)
-{
-	struct zwmux_softc *sc;
-
-	sc = device_get_softc(dev);
-	destroy_dev(sc->sc_cdev);
-	return (0);
-}
-
-static uint8_t
-zwmux_txrx(struct zwmux_softc *sc, int cs, int mode, uint8_t data)
-{
-	uint32_t mask, out = 0;
-	unsigned int bit;
-
-
-	/* called with locked gpiobus */
-
-	for (mask = 0x80; mask > 0; mask >>= 1) {
-		if ((mode == MODE_CPOL) || (mode == MODE_CPHA)) {
-			/* If mode 1 or 2 */
-
-			/* first step */
-			PIN_SET(sc, mosi, (data & mask)?1:0);
-			PIN_SET(sc, sclk, 0);
-			DELAY(sysctl_delay);
-			/* second step */
-			PIN_GET(sc, miso, &bit);
-			out |= bit?mask:0;
-			/* Data captured */
-			DELAY(sysctl_delay);
-			PIN_SET(sc, sclk, 1);
-		} else {
-			/* If mode 0 or 3 */
-
-			/* first step */
-			PIN_SET(sc, mosi, (data & mask)?1:0);
-			PIN_SET(sc, sclk, 1);
-			DELAY(sysctl_delay);
-			/* second step */
-			PIN_GET(sc, miso, &bit);
-			out |= bit?mask:0;
-			 /* Data captured */
-			DELAY(sysctl_delay);
-			PIN_SET(sc, sclk, 0);
-		}
-	}
-
-	return (out & 0xff);
-}
-
-static int
-zwmux_transfer(device_t dev, device_t child, struct spi_command *cmd)
-{
-	struct zwmux_softc *sc;
-	uint8_t *buf_in, *buf_out, byte;
-	struct spibus_ivar *devi = SPIBUS_IVAR(child);
-	int i;
-
-	sc = device_get_softc(dev);
-
-	GPIOBUS_LOCK_BUS(sc->sc_busdev);
-	GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev);
-
-	PIN_SET(sc, cs, 0);
-
-	/* Preset pins */
-	if ((devi->mode == MODE_CPOL) || (devi->mode == MODE_CPHA)) {
-		PIN_SET(sc, sclk, 1);
-	} else {
-		PIN_SET(sc, sclk, 0);
-	}
-
-	/*
-	 * Transfer command
-	 */
-	buf_out = (uint8_t *)cmd->tx_cmd;
-	buf_in = (uint8_t *)cmd->rx_cmd;
-
-	for (i = 0; i < MAX(cmd->tx_cmd_sz, cmd->rx_cmd_sz); i++) {
-		if (cmd->tx_cmd_sz > i)
-			byte = buf_out[i];
-		else
-			byte = 0;
-
-		byte = zwmux_txrx(sc, devi->cs, devi->mode, byte);
-
-		if (cmd->rx_cmd_sz > i)
-			buf_in[i] = byte;
-	}
-
-	/*
-	 * Receive/transmit data (depends on  command)
-	 */
-	buf_out = (uint8_t *)cmd->tx_data;
-	buf_in = (uint8_t *)cmd->rx_data;
-
-	for (i = 0; i < MAX(cmd->tx_data_sz, cmd->rx_data_sz); i++) {
-		if (cmd->tx_data_sz > i)
-			byte = buf_out[i];
-		else
-			byte = 0;
-
-		byte = zwmux_txrx(sc, devi->cs, devi->mode, byte);
-
-		if (cmd->rx_data_sz > i)
-			buf_in[i] = byte;
-	}
-
-
-	/* Return pins to mode default */
-	if ((devi->mode == MODE_CPOL) || (devi->mode == MODE_CPHA)) {
-		PIN_SET(sc, sclk, 1);
-	} else {
-		PIN_SET(sc, sclk, 0);
-	}
-
-	PIN_SET(sc, cs, 1);
-
-	GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
-	GPIOBUS_UNLOCK_BUS(sc->sc_busdev);
-
-	return (0);
-}
-
-static int
-zwmux_sync(struct zwmux_softc *sc)
-{
-	uint8_t	ptrn[2];
-	int i, error;
-
-	error = EIO;
-	for (i = 0; i < 32; i ++) {
-		zwmux_txrx(sc, 0, 0, ZWAVE_CMD_SYNC);
-		zwmux_txrx(sc, 0, 0, ZWAVE_CMD_SYNC_PTRN);
-		ptrn[0] = zwmux_txrx(sc, 0, 0, 0xff);
-		ptrn[1] = zwmux_txrx(sc, 0, 0, 0xff);
-		dprintf("%s: ptrn %02x %02x\n", __func__, ptrn[0], ptrn[1]);
-		if (ptrn[0] == ZWAVE_CMD_SYNC_PTRN) {
-			error = 0;
-			break;
-		}
-	}
-	if (error) {
-		dprintf("%s: no answer from module\n", __func__);
-		return (error);
-	}
-
-	error = zwmux_check_sig(sc);
-	if (error) {
-		dprintf("%s: wrong module signature\n", __func__);
-		return (error);
-	}
-
-	sc->sc_zw_synced = 1;
-	zwmux_set_erase_timing(sc, 11);
-
-	return (0);
-}
-
-static int
-zwmux_get_sig_byte(struct zwmux_softc *sc, int addr)
-{
-	uint8_t	sig;
-
-	zwmux_txrx(sc, 0, 0, ZWAVE_CMD_GET_SIG);
-	zwmux_txrx(sc, 0, 0, 0);
-	zwmux_txrx(sc, 0, 0, addr);
-	sig = zwmux_txrx(sc, 0, 0, 0xff);
-
-	return (sig);
-}
-
-static int
-zwmux_check_sig(struct zwmux_softc *sc)
-{
-	uint8_t	sig[8];
-	int i;
-
-	for (i = 0; i < 8; i ++)
-		sig[i] = zwmux_get_sig_byte(sc, i);
-
-	dprintf("Signature: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-	    sig[0], sig[1], sig[2], sig[3], sig[4], sig[5], sig[6], sig[7]);
-
-	if (sig[0] == 0x7f)
-		if (sig[1] == 0x7f)
-			if (sig[2] == 0x7f)
-				if (sig[3] == 0x7f)
-					if (sig[4] == 0x1f)
-						return (0);
-
-	return (EIO);
-}
-
-static int
-zwmux_get_image(struct zwmux_softc *sc, uint16_t off, uint8_t *buf, int len)
-{
-	int error, i;
-
-	if (off & 0x0001) {
-		dprintf("%s: wrong offset 0x%04x, must be aligned on 2\n",
-		    __func__, off);
-		return (EIO);
-	}
-	if ((off + len) > MODULE_FW_SIZE) {
-		dprintf("%s: offset+length exceed module flash size\n",
-		    __func__);
-		return (EIO);
-	}
-
-	if (!sc->sc_zw_synced) {
-		error = zwmux_sync(sc);
-		if (error)
-			return (error);
-	}
-
-	for (i = off; i < (off + len); i++, buf++) {
-		zwmux_txrx(sc, 0, 0, (i & 1) ? ZWAVE_CMD_GET_FLASH_WORD_H8 :
-		    ZWAVE_CMD_GET_FLASH_WORD_L8);
-		zwmux_txrx(sc, 0, 0, (i >> 8) & 0xff);
-		zwmux_txrx(sc, 0, 0, i & 0xfe);
-		*buf = (zwmux_txrx(sc, 0, 0, 0xff) & 0xff);
-	}
-
-	return (0);
-}
-
-static int
-zwmux_write_mem(struct zwmux_softc *sc, uint16_t off, uint8_t *buf, int len)
-{
-	int i;
-
-	if ((off + len) > MODULE_PAGE_SIZE)
-		return (1);
-
-	for (i = 0; i < len; i++) {
-		zwmux_txrx(sc, 0, 0, (i & 1) ? ZWAVE_CMD_WRITE_RAM_WORD_H8 :
-		    ZWAVE_CMD_WRITE_RAM_WORD_L8);
-		zwmux_txrx(sc, 0, 0, 0);
-		zwmux_txrx(sc, 0, 0, (off + i) & 0xff); /* Page */
-		zwmux_txrx(sc, 0, 0, buf[i]);
-	}
-
-	return (0);
-}
-
-/*
- * zwmux_copy_flash_page - copy 256 bytes from SRAM into Flash
- *
- */
-static int
-zwmux_copy_flash_page(struct zwmux_softc *sc, int page)
-{
-	zwmux_txrx(sc, 0, 0, ZWAVE_CMD_COPY_FLASH_PAGE);
-	zwmux_txrx(sc, 0, 0, page);
-	zwmux_txrx(sc, 0, 0, 0);
-	zwmux_txrx(sc, 0, 0, 0);
-
-	return (0);
-}
-
-static int
-zwmux_erase_flash(struct zwmux_softc *sc, int page)
-{
-	if ((page > 256) && (page != ZWAVE_ERASE_FLASH_FULL))
-		return (1);
-
-	zwmux_txrx(sc, 0, 0, ZWAVE_CMD_ERASE_FLASH);
-	if (page == ZWAVE_ERASE_FLASH_FULL) {
-		zwmux_txrx(sc, 0, 0, ZWAVE_CMD_ERASE_FLASH_FULL);
-		zwmux_txrx(sc, 0, 0, 0);
-	} else {
-		zwmux_txrx(sc, 0, 0, ZWAVE_CMD_ERASE_FLASH_PAGE);
-		zwmux_txrx(sc, 0, 0, page);
-	}
-	zwmux_txrx(sc, 0, 0, 0);
-
-	return (0);
-}
-
-static int
-zwmux_set_erase_timing(struct zwmux_softc *sc, int timing)
-{
-
-	zwmux_txrx(sc, 0, 0, ZWAVE_CMD_ERASE_FLASH);
-	zwmux_txrx(sc, 0, 0, ZWAVE_CMD_ERASE_TIMING);
-	zwmux_txrx(sc, 0, 0, 0);
-	zwmux_txrx(sc, 0, 0, timing);
-
-	return (0);
-}
-
-static int
-zwmux_open(struct cdev *cdev __unused, int flags, int fmt __unused,
-    struct thread *td)
-{
-	struct zwmux_softc *sc;
-
-	sc = cdev->si_drv1;
-	/* Put ZWave module into Reset state */
-	PIN_SET(sc, zwrst, 0);
-	/* Wait 1 sec to setup reset state */
-	pause("zwrst", hz);
-
-	return (0);
-}
-
-static int
-zwmux_read(struct cdev *dev, struct uio *uio, int flags)
-{
-	struct zwmux_softc *sc;
-	u_char *s;
-	int error;
-
-	error = 0;
-	sc = dev->si_drv1;
-
-	if ((uio->uio_offset + uio->uio_resid) > MODULE_FW_SIZE)
-		return (EINVAL);
-
-	s = malloc(uio->uio_resid, M_ZWMUX, M_WAITOK);
-
-	//mtx_lock(&led_mtx);
-	/* Hold EEPROM passthru in inactive possition */
-	PIN_SET(sc, eept, 1);
-	/* Get firmware */
-	zwmux_get_image(sc, 0, s, uio->uio_resid);
-	//mtx_unlock(&led_mtx);
-
-	error = uiomove(s, uio->uio_resid, uio);
-
-	free(s, M_ZWMUX);
-
-	return (error);
-}
-
-static int
-zwmux_write(struct cdev *dev, struct uio *uio, int ioflag)
-{
-	struct zwmux_softc *sc;
-	u_char *s, *tbuf;
-	int error, page, page_last, bsize, total, start;
-
-	error = 0;
-	sc = dev->si_drv1;
-
-	if ((uio->uio_offset + uio->uio_resid) > MODULE_FW_SIZE)
-		return (EINVAL);
-
-	if (uio->uio_offset % MODULE_PAGE_SIZE)
-		return (EINVAL);
-
-	if (!sc->sc_zw_synced) {
-		error = zwmux_sync(sc);
-		if (error)
-			return (error);
-	}
-
-	s = malloc(uio->uio_resid, M_ZWMUX, M_WAITOK);
-	if (!s)
-		return (ENOMEM);
-	tbuf = malloc(MODULE_PAGE_SIZE, M_ZWMUX, M_WAITOK);
-	if (!tbuf) {
-		error = ENOMEM;
-		goto malloc_fail;
-	}
-
-	total = uio->uio_resid;
-	start = uio->uio_offset / MODULE_PAGE_SIZE;
-	page_last = start + howmany(total, MODULE_PAGE_SIZE);
-	error = uiomove(s, uio->uio_resid, uio);
-	if (error)
-		goto fail;
-
-	//mtx_lock(&led_mtx);
-	/* Hold EEPROM passthru in inactive possition */
-	PIN_SET(sc, eept, 1);
-
-	for (page = start; page < page_last; page++) {
-		bsize = (page == page_last) ? (total % MODULE_PAGE_SIZE) :
-		    MODULE_PAGE_SIZE;
-
-		/* Erase one page */
-		error = zwmux_erase_flash(sc, page);
-		if (error)
-			goto fail;
-
-		pause("zwers", hz/50);
-
-		/* Write RAM */
-		error = zwmux_write_mem(sc, 0, s + (page * MODULE_PAGE_SIZE),
-		    bsize);
-		if (error)
-			goto fail;
-
-		/* Copy 256 bytes from SRAM to Flash page */
-		error = zwmux_copy_flash_page(sc, page);
-		if (error)
-			goto fail;
-
-		pause("zwprg", hz/50);
-
-#ifdef	ZWMUX_VARIFY_WRITE
-		/* Get last page */
-		error = zwmux_get_image(sc, (page << 8), tbuf, bsize);
-		if (error)
-			goto fail;
-
-		if (memcmp(s + (page * MODULE_PAGE_SIZE), tbuf, bsize)) {
-			printf("Writing block: bsize=%d\n", bsize);
-			hexdump(s + (page * MODULE_PAGE_SIZE), bsize, NULL, 0);
-			printf("Resulting block:\n");
-			hexdump(tbuf, bsize, NULL, 0);
-			error = EIO;
-			goto fail;
-		}
-#endif
-	}
-	/* TODO */
-	//mtx_unlock(&led_mtx);
-fail:
-	free(tbuf, M_ZWMUX);
-malloc_fail:
-	free(s, M_ZWMUX);
-
-	return (error);
-}
-
-static int
-zwmux_close(struct cdev *cdev, int flags __unused, int fmt __unused,
-    struct thread *td __unused)
-{
-	struct zwmux_softc *sc;
-
-	sc = cdev->si_drv1;
-	sc->sc_zw_synced = 0;
-	/* Release ZWave module */
-	PIN_SET(sc, zwrst, 1);
-
-	return (0);
-}
-
-static device_method_t zwmux_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		zwmux_probe),
-	DEVMETHOD(device_attach,	zwmux_attach),
-	DEVMETHOD(device_detach,	zwmux_detach),
-
-	DEVMETHOD(spibus_transfer,	zwmux_transfer),
-
-	{0, 0}
-};
-
-static driver_t zwmux_driver = {
-	"zwmux",
-	zwmux_methods,
-	sizeof(struct zwmux_softc),
-};
-
-static devclass_t zwmux_devclass;
-
-extern driver_t spibus_driver;
-extern devclass_t spibus_devclass;
-
-DRIVER_MODULE(zwmux, gpiobus, zwmux_driver, zwmux_devclass, 0, 0);
-DRIVER_MODULE(spibus, zwmux, spibus_driver, spibus_devclass, 0, 0);
-MODULE_DEPEND(zwmux, gpiobus, 1, 1, 1);
-MODULE_DEPEND(zwmux, spibus, 1, 1, 1);


More information about the Zrouter-src-freebsd mailing list