Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Sep 2002 22:58:45 +0200
From:      Nicolas Souchu <nsouch@free.fr>
To:        Bruce M Simpson <bms@spc.org>
Cc:        hardware@FreeBSD.ORG, Dan Larsson <dl@tyfon.net>
Subject:   Re: Getting /dev/smb* to work.
Message-ID:  <20020921225845.B1519@armor.fastether>
In-Reply-To: <20020828100722.GH24795@spc.org>; from bms@spc.org on Wed, Aug 28, 2002 at 11:07:23AM %2B0100
References:  <20020827233627.S76730-100000@hq1.tyfon.net> <20020828100722.GH24795@spc.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Aug 28, 2002 at 11:07:23AM +0100, Bruce M Simpson wrote:
> On Wed, Aug 28, 2002 at 12:01:15AM +0200, Dan Larsson wrote:
> > While trying to get hardware monitoring to work on my computer I
> > found the below procedure to enable the smbus device.
> > It didn't get me any closer to actually monitoring the hardware with
> > xbmon, lmmon or healthd. But the device is there.
> 
> I'd like to add to this. uname is:
> FreeBSD triage.dollah.com 4.6-STABLE FreeBSD 4.6-STABLE #1: Sun Aug 25 11:23:33 BST 2002     root@triage.dollah.com:/usr/src/sys/compile/TRIAGE  i386
> 
> Box in question is a Sony Vaio PCG-Z600HEK.  dmesg looks like this:-
> 
> pcib0: <Intel 82443BX (440 BX) host to PCI bridge> on motherboard
> ...
> intpm0: <Intel 82371AB Power management controller> port 0x1040-0x104f irq 9 at device 7.3 on pci0
> intpm0: I/O mapped 1040
> intpm0: intr IRQ 9 enabled revision 0
> smbus0: <System Management Bus> on intsmb0
> smb0: <SMBus general purpose I/O> on smbus0
> intpm0: PM I/O mapped 8000 

Run the attached program to probe the smbus.

Nicholas

-- 
Nicholas Souchu - nsouch@free.fr - nsouch@FreeBSD.org

--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="detect.c"

/*-
 * Copyright (c) 1999 Nicolas Souchu
 * 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 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.
 *
 *	[id for your version control system, if any]
 */
#include <stdlib.h>
#include <fcntl.h>
#include <machine/smb.h>

int doioctl(int alias, int cmd, caddr_t param)
{
	int error = 1;
	int retry = 3;

	while (error && retry--) {
		usleep(100000);
		error = ioctl(alias, cmd, param);
	}
	
	return (error);
}

int main (int argc,char argv[])
{
	int alias, i;
	unsigned char byte=0;
	struct smbcmd cmd;

	bzero(&cmd, sizeof(cmd));
	cmd.data.byte_ptr = &byte;

	alias = open("/dev/smb0", O_RDWR);

	for (i=2; i<254; i+=2)
	{
	  if (i != 0xd2) {
		  cmd.slave=(u_char)i;
		  if(doioctl(alias, SMB_RECVB, (caddr_t)&cmd)!=-1){
			printf("%x found.\n",i);
		  } else {
			printf("%x failed.\n",i);
		  }
	  }
	}

	close(alias);
	return 0;
}


--YZ5djTAD1cGYuMQK--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hardware" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020921225845.B1519>