138776Snsouch/*-
238776Snsouch * Copyright (c) 1998 Nicolas Souchu
338776Snsouch * All rights reserved.
438776Snsouch *
538776Snsouch * Redistribution and use in source and binary forms, with or without
638776Snsouch * modification, are permitted provided that the following conditions
738776Snsouch * are met:
838776Snsouch * 1. Redistributions of source code must retain the above copyright
938776Snsouch *    notice, this list of conditions and the following disclaimer.
1038776Snsouch * 2. Redistributions in binary form must reproduce the above copyright
1138776Snsouch *    notice, this list of conditions and the following disclaimer in the
1238776Snsouch *    documentation and/or other materials provided with the distribution.
1338776Snsouch *
1438776Snsouch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1538776Snsouch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1638776Snsouch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1738776Snsouch * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1838776Snsouch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1938776Snsouch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2038776Snsouch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2138776Snsouch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2238776Snsouch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2338776Snsouch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2438776Snsouch * SUCH DAMAGE.
2538776Snsouch *
2650477Speter * $FreeBSD$
2738776Snsouch */
2838776Snsouch#ifndef __SMBONF_H
2938776Snsouch#define __SMBONF_H
3038776Snsouch
3138776Snsouch#include <sys/queue.h>
3238776Snsouch
3343294Sdillon#define SMBPRI (PZERO+8)		/* XXX sleep/wakeup queue priority */
3438776Snsouch
3538776Snsouch#define n(flags) (~(flags) & (flags))
3638776Snsouch
3738776Snsouch/*
3838776Snsouch * How tsleep() is called in smb_request_bus().
3938776Snsouch */
4038776Snsouch#define SMB_DONTWAIT	0
4138776Snsouch#define SMB_NOINTR	0
4238776Snsouch#define SMB_WAIT	0x1
4338776Snsouch#define SMB_INTR	0x2
4438776Snsouch
4538776Snsouch/*
4640785Snsouch * callback index
4740785Snsouch */
4840785Snsouch#define SMB_REQUEST_BUS	0x1
4940785Snsouch#define SMB_RELEASE_BUS	0x2
5040785Snsouch
5140785Snsouch/*
5238776Snsouch * SMB bus errors
5338776Snsouch */
5438776Snsouch#define SMB_ENOERR	0x0
5538776Snsouch#define SMB_EBUSERR	0x1
5640785Snsouch#define SMB_ENOTSUPP	0x2
5743975Snsouch#define SMB_ENOACK	0x4
5843975Snsouch#define SMB_ECOLLI	0x8
5943975Snsouch#define SMB_EABORT	0x10
6043975Snsouch#define SMB_ETIMEOUT	0x20
6143975Snsouch#define SMB_EBUSY	0x40
62162234Sjhb#define	SMB_EINVAL	0x100
6338776Snsouch
6438776Snsouch/*
6538776Snsouch * How Quick command is executed
6638776Snsouch */
6738776Snsouch#define SMB_QWRITE	0x0
6838776Snsouch#define SMB_QREAD	0x1
6938776Snsouch
7038776Snsouch/*
7138776Snsouch * ivars codes
7238776Snsouch */
73162234Sjhb#define SMBUS_IVAR_ADDR	0x1	/* slave address of the device */
7438776Snsouch
75162234Sjhbint	smbus_request_bus(device_t, device_t, int);
76162234Sjhbint	smbus_release_bus(device_t, device_t);
77162234Sjhbdevice_t smbus_alloc_bus(device_t);
78162234Sjhbint	smbus_error(int error);
7938776Snsouch
80162234Sjhbvoid	smbus_intr(device_t, u_char, char low, char high, int error);
8138776Snsouch
82162234Sjhbu_char	smbus_get_addr(device_t);
8338776Snsouch
84162234Sjhbextern driver_t smbus_driver;
85162234Sjhbextern devclass_t smbus_devclass;
86162234Sjhb
8738776Snsouch#define smbus_quick(bus,slave,how) \
8838776Snsouch	(SMBUS_QUICK(device_get_parent(bus), slave, how))
8938776Snsouch#define smbus_sendb(bus,slave,byte) \
9038776Snsouch	(SMBUS_SENDB(device_get_parent(bus), slave, byte))
9138776Snsouch#define smbus_recvb(bus,slave,byte) \
9238776Snsouch	(SMBUS_RECVB(device_get_parent(bus), slave, byte))
9338776Snsouch#define smbus_writeb(bus,slave,cmd,byte) \
9438776Snsouch	(SMBUS_WRITEB(device_get_parent(bus), slave, cmd, byte))
9538776Snsouch#define smbus_writew(bus,slave,cmd,word) \
9638776Snsouch	(SMBUS_WRITEW(device_get_parent(bus), slave, cmd, word))
9738776Snsouch#define smbus_readb(bus,slave,cmd,byte) \
9838776Snsouch	(SMBUS_READB(device_get_parent(bus), slave, cmd, byte))
9938776Snsouch#define smbus_readw(bus,slave,cmd,word) \
10038776Snsouch	(SMBUS_READW(device_get_parent(bus), slave, cmd, word))
10138776Snsouch#define smbus_pcall(bus,slave,cmd,sdata,rdata) \
10238776Snsouch	(SMBUS_PCALL(device_get_parent(bus), slave, cmd, sdata, rdata))
10338776Snsouch#define smbus_bwrite(bus,slave,cmd,count,buf) \
10438776Snsouch	(SMBUS_BWRITE(device_get_parent(bus), slave, cmd, count, buf))
10538776Snsouch#define smbus_bread(bus,slave,cmd,count,buf) \
10638776Snsouch	(SMBUS_BREAD(device_get_parent(bus), slave, cmd, count, buf))
10738776Snsouch
10893023Snsouch#define SMBUS_MODVER	1
10993023Snsouch#define SMBUS_MINVER	1
11093023Snsouch#define SMBUS_MAXVER	1
11193023Snsouch#define SMBUS_PREFVER	SMBUS_MODVER
11293023Snsouch
11338776Snsouch#endif
114