ADM1032 eval board
Quoted 3 lines
In the event that you ruin the board just let me know and I'll send you another.
I'll try not to need another one that soon ;)
Quoted 1 line
The SMBus/I2C signal is generated by bit bashing the parallel port.
OK, that's how I had understood it.
Quoted 4 lines
Quoted 2 lines
I guess it's a simple problem of writing the right things at the right time on the parallel port.
Yes.
So I took our i2c-pport driver, which is intended for parallel-port bit-bashing. I had to adapt it to match the schematic I found on the evaluation CD. It now writes SCL to pin 2 (DATA bit 0), SDA to pin 3 (DATA bit 1) and reads SDA from pin 13 (STAT bit 4). I also added code to set pins 6 to 9 (DATA bits 4 to 7) to high so that the board gets enough power. According to the schematic, I don't think there is anything else required.
I have somewhat good results, since:
1* The power led lights up.
2* The bit_test option of our i2c-algo-bit module (which I had to tweak a bit because the eval board doesn't let me read SCL back) suggests that SDA can be set and read back correctly.
3* When running some commands on the bus (using i2cdetect for example) I detect electrical activity on both SDA and SCL. I'm using a low-cost multimeter, unfortunatelly I don't have anything better to watch the signals. I'd love a good oscilloscope these days :/
Now the problem is: i2cdetect doesn't detect anything. Not a single chip. Running i2cdump on address 0x4c (where I know the adm1032 has to be) fails reporting a single valid byte too. It looks like the adm1032 doesn't want to answer, and I can't understand why.
I've attached the modified i2c-pport.c source (BTW this module would benefit a complete rewrite someday, it's full of tricks that are better avoided in kernel code IMHO) in case someone has an idea of what I might be doing wrong.
Sean, is there something I'm supposed to do that does not appear on the schematic? Some pin of the parallel port that must be forced to either high or low for proper operation? I'm kind of lost now. I was expecting everything to work OK once I'd have worked the bit-bashing driver out, and am diappointed that it still doesn't work. Your Windows tool being working on the same machine, I know that there is no hardware incompatibility, so that must be something I am doing wrong somewhere. I've even been trying various speeds, but it did not help.
Thanks.
Signature · 213 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
-------------- next part --------------
/* ------------------------------------------------------------------------- */
/* i2c-pport.c i2c-hw access for primitive i2c par. port adapter */
/* ------------------------------------------------------------------------- */
/* Copyright (C) 2001 Daniel Smolik
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* ------------------------------------------------------------------------- */
/*
See doc/i2c-pport for instructions on wiring to the
parallel port connector.
Cut & paste :-) based on Velleman K9000 driver by Simon G. Vogl
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include "i2c.h"
#include "i2c-algo-bit.h"
#include <asm/io.h>
#define DEFAULT_BASE 0x378
static int base=0;
static unsigned char PortData = 0;
/* ----- global defines ----------------------------------------------- */
#define DEB(x) x /* should be reasonable open, close &c. */
#define DEB2(x) /* low level debugging - very slow */
#define DEBE(x) x /* error messages */
#define DEBINIT(x) x /* detection status messages */
/* --- Convenience defines for the parallel port: */
#define BASE (unsigned int)(data)
#define DATA BASE /* Centronics data port */
#define STAT (BASE+1) /* Centronics status port */
#define CTRL (BASE+2) /* Centronics control port */
/* we will use SDA - Auto Linefeed(14) bit 1 POUT */
/* we will use SCL - Initialize printer(16) BUSY bit 2*/
#define SET_SCL | 0x01
#define CLR_SCL & 0xFE
#define SET_SDA | 0x02
#define CLR_SDA & 0xFD
/* ----- local functions ---------------------------------------------- */
static void bit_pport_setscl(void *data, int state)
{
PortData = inb(DATA);
if (state) {
//high
PortData = PortData SET_SCL;
} else {
//low
PortData = PortData CLR_SCL;
}
outb(PortData, DATA);
}
static void bit_pport_setsda(void *data, int state)
{
PortData = inb(DATA);
if (state) {
PortData = PortData SET_SDA;
} else {
PortData = PortData CLR_SDA;
}
outb(PortData, DATA);
}
/*static int bit_pport_getscl(void *data)
{
return ( 1 = ( (inb_p(DATA)) & 0x01 ) );
}*/
static int bit_pport_getsda(void *data)
{
return ( 0x10 = ( (inb_p(STAT)) & 0x10 ) );
}
static int bit_pport_init(void)
{
if (!request_region((base),1, "i2c (PPORT adapter)")) {
return -ENODEV;
} else {
/* test for PPORT adap. */
PortData=inb(base);
PortData= (PortData SET_SDA) SET_SCL;
outb(PortData,base);
if (!(inb(base) | 0x03)) { /* SDA and SCL will be high */
DEBINIT(printk("i2c-pport.o: SDA and SCL was low.\n"));
return -ENODEV;
} else {
/*SCL high and SDA low*/
PortData = (PortData SET_SCL) CLR_SDA;
outb(PortData,base);
schedule_timeout(400);
if ( !(inb(base) | 0x01) ) {
//outb(0x04,base);
DEBINIT(printk("i2c-port.o: SDA was high.\n"));
return -ENODEV;
}
}
/* power on */
outb(PortData|0xF0, base);
bit_pport_setsda((void*)base,1);
bit_pport_setscl((void*)base,1);
}
return 0;
}
/* ------------------------------------------------------------------------
* Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported.
*/
static struct i2c_algo_bit_data bit_pport_data = {
.setsda = bit_pport_setsda,
.setscl = bit_pport_setscl,
.getsda = bit_pport_getsda,
.getscl = NULL,
.udelay = 500,
.mdelay = 10,
.timeout = HZ
};
static struct i2c_adapter bit_pport_ops = {
.owner = THIS_MODULE,
.name = "Primitive Parallel port adaptor",
.id = I2C_HW_B_PPORT,
.algo_data = &bit_pport_data,
};
int __init i2c_bitpport_init(void)
{
printk("i2c-pport.o: i2c Primitive parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
if (base=0) {
/* probe some values */
base�FAULT_BASE;
bit_pport_data.data=(void*)DEFAULT_BASE;
if (bit_pport_init()=0) {
if(i2c_bit_add_bus(&bit_pport_ops) < 0) {
release_region((base),1);
return -ENODEV; }
} else {
return -ENODEV;
}
} else {
bit_pport_data.data=(void*)base;
if (bit_pport_init()=0) {
if(i2c_bit_add_bus(&bit_pport_ops) < 0)
return -ENODEV;
} else {
return -ENODEV;
}
}
printk("i2c-pport.o: found device at %#x.\n",base);
return 0;
}
static void __exit i2c_bitpport_exit(void)
{
i2c_bit_del_bus(&bit_pport_ops);
release_region((base),1);
}
EXPORT_NO_SYMBOLS;
MODULE_AUTHOR("Daniel Smolik <[email protected]>");
MODULE_DESCRIPTION("I2C-Bus adapter routines for Primitive parallel port adapter");
MODULE_LICENSE("GPL");
MODULE_PARM(base, "i");
module_init(i2c_bitpport_init);
module_exit(i2c_bitpport_exit);(Answering to myself.)
Quoted 13 lines
I have somewhat good results, since:
1* The power led lights up.
2* The
bit_testoption of our i2c-algo-bit module (which I had to tweak a bit because the eval board doesn't let me read SCL back) suggests that SDA can be set and read back correctly.3* When running some commands on the bus (using i2cdetect for example) I detect electrical activity on both SDA and SCL. I'm using a low-cost multimeter, unfortunatelly I don't have anything better to watch the signals. I'd love a good oscilloscope these days :/
Quoted 14 lines
Now the problem is: i2cdetect doesn't detect anything. Not a single chip. Running i2cdump on address
0x4c(where I know the adm1032 has to be) fails reporting a single valid byte too. It looks like the adm1032 doesn't want to answer, and I can't understand why.
(...)
Sean, is there something I'm supposed to do that does not appear on the schematic? Some pin of the parallel port that must be forced to either high or low for proper operation? I'm kind of lost now. I was expecting everything to work OK once I'd have worked the bit-bashing driver out, and am diappointed that it still doesn't work. Your Windows tool being working on the same machine, I know that there is no hardware incompatibility, so that must be something I am doing wrong somewhere. I've even been trying various speeds, but it did not help.
OK, I finally got it working! :)
After trying various modules and parameters, and even trying to link the eval board to one of my computer motherboard's SMBus, with absolutely no results for 3 days, I was about to give up. Then I read the schematic once again, to make sure I had not missed something, although after reading it ten times I was pretty sure I wouldn't discover anything new this time. And finally I understood what I had made wrong.
You'll probably find it ridiculous since it was so obvious. It was all plain written on the schematic. All inputs and outputs are inversed. I had to write *1* to SCL or SDA to pull it low, *not* 0, and all the rest works the same way. I can't blame anyone but me there. Would I have been able to read the nice schematic correctly at first, I would have it all working within an hour or so... I'm not a hardware guy, so it did not even imagine that I would have to write a 0 to set the line high, and so on.
So, sorry Sean for annoying you with my silly questions ;)
I'll now move on to the ADM1032 driver itself, and that should be rather fast since we already support a very similar and mostly compatible chip (LM90). I'll read the datasheet once again to make sure there's no hidden trap, and then will let you know when I got it working :)
Thanks again.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Hi Jean,
Without a scope, it ie easy to overlook these smaller details.
The only reason why we used the inverting buffers was that it was difficult to get non-inverting ones that were surface mount.
Good to see you are up and running.
Regards,
Se?n.
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: 02 November 2003 11:51
To: [email protected]
Cc: [email protected]
Subject: Re: ADM1032 eval board
(Answering to myself.)
Quoted 13 lines
I have somewhat good results, since:
1* The power led lights up.
2* The
bit_testoption of our i2c-algo-bit module (which I had to tweak a bit because the eval board doesn't let me read SCL back) suggests that SDA can be set and read back correctly.3* When running some commands on the bus (using i2cdetect for example) I detect electrical activity on both SDA and SCL. I'm using a low-cost multimeter, unfortunatelly I don't have anything better to watch the signals. I'd love a good oscilloscope these days :/
Quoted 14 lines
Now the problem is: i2cdetect doesn't detect anything. Not a single chip. Running i2cdump on address
0x4c(where I know the adm1032 has to be) fails reporting a single valid byte too. It looks like the adm1032 doesn't want to answer, and I can't understand why.
(...)
Sean, is there something I'm supposed to do that does not appear on the schematic? Some pin of the parallel port that must be forced to either high or low for proper operation? I'm kind of lost now. I was expecting everything to work OK once I'd have worked the bit-bashing driver out, and am diappointed that it still doesn't work. Your Windows tool being working on the same machine, I know that there is no hardware incompatibility, so that must be something I am doing wrong somewhere. I've even been trying various speeds, but it did not help.
OK, I finally got it working! :)
After trying various modules and parameters, and even trying to link the eval board to one of my computer motherboard's SMBus, with absolutely no results for 3 days, I was about to give up. Then I read the schematic once again, to make sure I had not missed something, although after reading it ten times I was pretty sure I wouldn't discover anything new this time. And finally I understood what I had made wrong.
You'll probably find it ridiculous since it was so obvious. It was all plain written on the schematic. All inputs and outputs are inversed. I had to write *1* to SCL or SDA to pull it low, *not* 0, and all the rest works the same way. I can't blame anyone but me there. Would I have been able to read the nice schematic correctly at first, I would have it all working within an hour or so... I'm not a hardware guy, so it did not even imagine that I would have to write a 0 to set the line high, and so on.
So, sorry Sean for annoying you with my silly questions ;)
I'll now move on to the ADM1032 driver itself, and that should be rather fast since we already support a very similar and mostly compatible chip (LM90). I'll read the datasheet once again to make sure there's no hidden trap, and then will let you know when I got it working :)
Thanks again.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/