From owner-freebsd-current@FreeBSD.ORG Fri Dec 16 11:19:36 2005 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 59BF516A427 for ; Fri, 16 Dec 2005 11:19:36 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua (tigra.ip.net.ua [82.193.96.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17BD643D66 for ; Fri, 16 Dec 2005 11:19:31 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from localhost (rocky.ip.net.ua [82.193.96.2]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id jBGBJPX3066019; Fri, 16 Dec 2005 13:19:25 +0200 (EET) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua ([82.193.96.10]) by localhost (rocky.ipnet [82.193.96.2]) (amavisd-new, port 10024) with LMTP id 73929-02-4; Fri, 16 Dec 2005 13:19:21 +0200 (EET) Received: from heffalump.ip.net.ua (heffalump.ip.net.ua [82.193.96.213]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id jBGBI6Ih065907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Dec 2005 13:18:06 +0200 (EET) (envelope-from ru@ip.net.ua) Received: (from ru@localhost) by heffalump.ip.net.ua (8.13.4/8.13.4) id jBGBIEX6024459; Fri, 16 Dec 2005 13:18:14 +0200 (EET) (envelope-from ru) Date: Fri, 16 Dec 2005 13:18:13 +0200 From: Ruslan Ermilov To: Artemiev Igor Message-ID: <20051216111813.GE41326@ip.net.ua> References: <200512141749.jBEHnjRV081112@repoman.freebsd.org> <20051214183345.GE51686@ip.net.ua> <20051215093643.694e995b.ai@bmc.brk.ru> <200512151306.57961.jhb@freebsd.org> <20051216083657.GA41326@ip.net.ua> <20051216134225.09aa93a3.ai@bmc.brk.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="L2Brqb15TUChFOBK" Content-Disposition: inline In-Reply-To: <20051216134225.09aa93a3.ai@bmc.brk.ru> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at ip.net.ua Cc: freebsd-current@FreeBSD.org Subject: Re: cvs commit: src/sys/pci amdpm.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 11:19:36 -0000 --L2Brqb15TUChFOBK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 16, 2005 at 01:42:25PM +0300, Artemiev Igor wrote: > > OK, I looked some more, and I doubt the usefullness of the > > nForce-2/3/4 support in its current shape. Perhaps I'm mistaken and > > you can shed a light on this. :-) > > The amdpm(4) driver originally supported AMD-756's PMC SMBus 1.0. > > Later, AMD-8111 support was added. All of these AMDs seem to support > > both SMBus 2.0 and SMBus 1.0 interfaces, and the driver uses the SMBus > > 1.0 interface (offset 0xe0). The nForce seems to also support SMBus > > 1.0 interface (offset 0). At least, the following lm_sensors pages > > amd AMD-8111 datasheet confirm this: > >=20 > > http://www.lm-sensors.org/supported.html > > http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/busses/i2c-amd756 > > http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/busses/i2c-amd8111 > >=20 > > Now, the same supported.html page and googling says that nForce2/3/4 > > MCPs all use SMBus 2.0 interface similar to AMD-8111 SMBus 2amd86.0 > > interface. But we don't support SMBus 2.0 interface in amdpm(4)! > > (lm_sensors, OTOH, does implement SMBus 2.0.). > i2c-amd756.c, i2c-amd8111.c and i2c-nforce2.c looks very similar for me. > Differences between i2c-amd756 and i2c-nforce2.c/i2c-amd8111.c in > pair ioctl. >=20 i2c-amd8111.c and i2c-nforce2.c are indeed very similar, because they both use SMBus 2.0 API. :-) But i2c-amd756.c, which also handles AMD-8111 SMBus 1.0, and is similar to FreeBSD's amdpm.c, uses a different API (SMBus 1.0). Are you sure the following fragments look similar to you? http://www2.lm-sensors.nu/~lm78/cvs/browse.cgi/lm_sensors2/kernel/busses/i2= c-amd756.c http://www2.lm-sensors.nu/~lm78/cvs/browse.cgi/lm_sensors2/kernel/busses/i2= c-nforce2.c Let's consider I2C_SMBUS_QUICK+I2C_SMBUS_WRITE case, which is in FreeBSD's smb(4) spelling is: SMB_QUICK_WRITE The QuickWrite command just issues the device addre= ss with write intent to the bus, without transferring = any data. I've added offsets in `//' style comments... 203 static s32 amd756_access(struct i2c_adapter * adap, u16 addr, 204 unsigned short flags, char read_write, 205 u8 command, int size, union i2c_smbus_data * data) 206 { 207 int i, len; 208=09 209 /** TODO: Should I supporte the 10-bit transfers? */ 210 switch (size) { 211 /* TODO: proc call is supported, I'm just not sure what to do here.= =2E. */ 212 case I2C_SMBUS_QUICK: 213 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01), 214 SMB_HOST_ADDRESS); // (0x4 + amd756_ioport) 215 size =3D AMD756_QUICK; 216 break; [...] 264 /* How about enabling interrupts... */ 265 outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE); // (0x2 + amd75= 6_ioport) word 266=09 267 if (amd756_transaction()) /* Error in transaction */ 268 return -1; 269=09 270 if ((read_write =3D=3D I2C_SMBUS_WRITE) || (size =3D=3D AMD756_QUIC= K)) 271 return 0; 141 s32 nforce2_access(struct i2c_adapter * adap, u16 addr, unsigned sho= rt flags, 142 char read_write, u8 command, int size, 143 union i2c_smbus_data * data) 144 { 145 struct nforce2_smbus *smbus =3D adap->algo_data; 146 unsigned char protocol, pec, temp; 147 unsigned char len =3D 0; /* to keep the compiler quiet */ 148 int i; 149=09 150 protocol =3D (read_write =3D=3D I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_= READ : NVIDIA_SMB_PRTCL_WRITE; 151 pec =3D (flags & I2C_CLIENT_PEC) ? NVIDIA_SMB_PRTCL_PEC : 0; 152=09 153 switch (size) { 154=09 155 case I2C_SMBUS_QUICK: 156 protocol |=3D NVIDIA_SMB_PRTCL_QUICK; 157 read_write =3D I2C_SMBUS_WRITE; 158 break; [...] 214 } 215=09 216 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR); // smbus->base + 0x02= (byte) 217 outb_p(protocol, NVIDIA_SMB_PRTCL); // smbus->base + 0x00 (byte) 218=09 219 temp =3D inb_p(NVIDIA_SMB_STS); // smbus->base + 0x01 (byte) 220=09 221 if (~temp & NVIDIA_SMB_STS_DONE) { 222 udelay(500); 223 temp =3D inb_p(NVIDIA_SMB_STS); 224 } 225 if (~temp & NVIDIA_SMB_STS_DONE) { 226 i2c_delay(HZ/100); 227 temp =3D inb_p(NVIDIA_SMB_STS); 228 } 229=09 230 if ((~temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)= ) { 231 printk(KERN_DEBUG "i2c-nforce2.o: SMBus Timeout! (0x%02x)\n", 232 temp); 233 return -1; 234 } 235=09 236 if (read_write =3D=3D I2C_SMBUS_WRITE) 237 return 0; See how the offset 0x2 register means completely different things. Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --L2Brqb15TUChFOBK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDoqJ1qRfpzJluFF4RAgDYAKCGdajD3GfCD9OzsYTkb9Nph7YMnACfYG47 Xfr+95AmFva/CjM6YOdM9p0= =nrSp -----END PGP SIGNATURE----- --L2Brqb15TUChFOBK--