* [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor
@ 2007-12-22 20:14 Larry Johnson
2007-12-23 10:40 ` Jean-Christophe PLAGNIOL-VILLARD
2007-12-27 12:11 ` Stefan Roese
0 siblings, 2 replies; 6+ messages in thread
From: Larry Johnson @ 2007-12-22 20:14 UTC (permalink / raw)
To: u-boot
This driver is based on the driver for the LM75.
Signed-off-by: Larry Johnson <lrj@acm.org>
---
drivers/hwmon/Makefile | 1 +
drivers/hwmon/lm73.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++
include/dtt.h | 12 +++-
3 files changed, 193 insertions(+), 1 deletions(-)
create mode 100644 drivers/hwmon/lm73.c
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index cebb2ba..32e3f44 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -34,6 +34,7 @@ COBJS-y += adm1021.o
COBJS-y += ds1621.o
COBJS-y += ds1722.o
COBJS-y += ds1775.o
+COBJS-y += lm73.o
COBJS-y += lm75.o
COBJS-y += lm81.o
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
new file mode 100644
index 0000000..f9ae012
--- /dev/null
+++ b/drivers/hwmon/lm73.c
@@ -0,0 +1,181 @@
+/*
+ * (C) Copyright 2007
+ * Larry Johnson, lrj at acm.org
+ *
+ * based on dtt/lm75.c which is ...
+ *
+ * (C) Copyright 2001
+ * Bill Hunter, Wave 7 Optics, williamhunter at mediaone.net
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * National Semiconductor LM73 Temperature Sensor
+ */
+
+#include <common.h>
+
+#ifdef CONFIG_DTT_LM73
+#if !defined(CFG_EEPROM_PAGE_WRITE_ENABLE) || \
+ (CFG_EEPROM_PAGE_WRITE_BITS < 1)
+# error "CFG_EEPROM_PAGE_WRITE_ENABLE must be defined and CFG_EEPROM_PAGE_WRITE_BITS must be greater than 1 to use
CONFIG_DTT_LM73"
+#endif
+
+#include <i2c.h>
+#include <dtt.h>
+
+/*
+ * Device code
+ */
+#define DTT_I2C_DEV_CODE 0x48 /* National Semi's LM73 device */
+
+int dtt_read(int sensor, int reg)
+{
+ int dlen;
+ uchar data[2];
+
+ /*
+ * Validate 'reg' param and get register size.
+ */
+ switch (reg) {
+ case DTT_CONFIG:
+ case DTT_CONTROL:
+ dlen = 1;
+ break;
+ case DTT_READ_TEMP:
+ case DTT_TEMP_HIGH:
+ case DTT_TEMP_LOW:
+ case DTT_ID:
+ dlen = 2;
+ break;
+ default:
+ return -1;
+ }
+ /*
+ * Calculate sensor address and register.
+ */
+ sensor = DTT_I2C_DEV_CODE + (sensor & 0x07); /* calculate LM73 addr */
+ /*
+ * Now try to read the register.
+ */
+ if (i2c_read(sensor, reg, 1, data, dlen) != 0)
+ return -1;
+ /*
+ * Handle 2 byte result.
+ */
+ if (2 == dlen)
+ return ((int)((short)data[1] + (((short)data[0]) << 8)));
+
+ return (int)data[0];
+} /* dtt_read() */
+
+int dtt_write(int sensor, int reg, int val)
+{
+ int dlen;
+ uchar data[2];
+
+ /*
+ * Validate 'reg' param and handle register size
+ */
+ switch (reg) {
+ case DTT_CONFIG:
+ case DTT_CONTROL:
+ dlen = 1;
+ data[0] = (char)(val & 0xff);
+ break;
+ case DTT_TEMP_HIGH:
+ case DTT_TEMP_LOW:
+ dlen = 2;
+ data[0] = (char)((val >> 8) & 0xff); /* MSB first */
+ data[1] = (char)(val & 0xff);
+ break;
+ default:
+ return -1;
+ }
+ /*
+ * Calculate sensor address and register.
+ */
+ sensor = DTT_I2C_DEV_CODE + (sensor & 0x07); /* calculate LM73 addr */
+ /*
+ * Write value to register.
+ */
+ return i2c_write(sensor, reg, 1, data, dlen) != 0;
+} /* dtt_write() */
+
+static int _dtt_init(int sensor)
+{
+ int val;
+
+ /*
+ * Validate the Identification register
+ */
+ if (0x0190 != dtt_read(sensor, DTT_ID))
+ return 1;
+ /*
+ * Setup THIGH (upper-limit) and TLOW (lower-limit) registers
+ */
+ val = CFG_DTT_MAX_TEMP << 7;
+ if (dtt_write(sensor, DTT_TEMP_HIGH, val))
+ return 1;
+
+ val = CFG_DTT_MIN_TEMP << 7;
+ if (dtt_write(sensor, DTT_TEMP_LOW, val))
+ return 1;
+ /*
+ * Setup configuraton register
+ */
+ /* config = alert active low, disabled, and reset */
+ val = 0x64;
+ if (dtt_write(sensor, DTT_CONFIG, val))
+ return 1;
+ /*
+ * Setup control/status register
+ */
+ /* control = temp resolution 0.25C */
+ val = 0x00;
+ if (dtt_write(sensor, DTT_CONTROL, val))
+ return 1;
+
+ dtt_read(sensor, DTT_CONTROL); /* clear temperature flags */
+ return 0;
+} /* _dtt_init() */
+
+int dtt_init(void)
+{
+ int i;
+ unsigned char sensors[] = CONFIG_DTT_SENSORS;
+ const char *const header = "DTT: ";
+
+ for (i = 0; i < sizeof(sensors); i++) {
+ if (_dtt_init(sensors[i]) != 0)
+ printf("%s%d FAILED INIT\n", header, i + 1);
+ else
+ printf("%s%d is %i C\n", header, i + 1,
+ dtt_get_temp(sensors[i]));
+ }
+ return 0;
+} /* dtt_init() */
+
+int dtt_get_temp(int sensor)
+{
+ return (dtt_read(sensor, DTT_READ_TEMP) + 0x0040) >> 7;
+} /* dtt_get_temp() */
+
+#endif /* CONFIG_DTT_LM73 */
diff --git a/include/dtt.h b/include/dtt.h
index 2e8c690..4e8aaad 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -31,7 +31,8 @@
defined(CONFIG_DTT_DS1621) || \
defined(CONFIG_DTT_DS1775) || \
defined(CONFIG_DTT_LM81) || \
- defined(CONFIG_DTT_ADM1021)
+ defined(CONFIG_DTT_ADM1021) || \
+ defined(CONFIG_DTT_LM73)
#define CONFIG_DTT /* We have a DTT */
@@ -119,4 +120,13 @@ extern int dtt_get_temp(int sensor);
#define DTT_ADM1021_DEVID 0x41
#endif
+#if defined(CONFIG_DTT_LM73)
+#define DTT_READ_TEMP 0x0
+#define DTT_CONFIG 0x1
+#define DTT_TEMP_HIGH 0x2
+#define DTT_TEMP_LOW 0x3
+#define DTT_CONTROL 0x4
+#define DTT_ID 0x7
+#endif
+
#endif /* _DTT_H_ */
--
1.5.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor
2007-12-22 20:14 [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor Larry Johnson
@ 2007-12-23 10:40 ` Jean-Christophe PLAGNIOL-VILLARD
2007-12-27 12:18 ` Stefan Roese
2007-12-27 12:11 ` Stefan Roese
1 sibling, 1 reply; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2007-12-23 10:40 UTC (permalink / raw)
To: u-boot
On 15:14 Sat 22 Dec , Larry Johnson wrote:
> This driver is based on the driver for the LM75.
>
> Signed-off-by: Larry Johnson <lrj@acm.org>
> ---
> drivers/hwmon/Makefile | 1 +
> drivers/hwmon/lm73.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++
> include/dtt.h | 12 +++-
> 3 files changed, 193 insertions(+), 1 deletions(-)
> create mode 100644 drivers/hwmon/lm73.c
>
> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> index cebb2ba..32e3f44 100644
> --- a/drivers/hwmon/Makefile
> +++ b/drivers/hwmon/Makefile
> @@ -34,6 +34,7 @@ COBJS-y += adm1021.o
> COBJS-y += ds1621.o
> COBJS-y += ds1722.o
> COBJS-y += ds1775.o
> +COBJS-y += lm73.o
> COBJS-y += lm75.o
> COBJS-y += lm81.o
>
I will send soon (today or tomorow) the Makefile with conditional compilation please rebase
your patch about drivers on it.
Best Regards,
J.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor
2007-12-22 20:14 [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor Larry Johnson
2007-12-23 10:40 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2007-12-27 12:11 ` Stefan Roese
2007-12-27 17:16 ` [U-Boot-Users] CFG_EEPROM_PAGE_WRITE_ENABLE [Was: Re: [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor] Larry Johnson
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Roese @ 2007-12-27 12:11 UTC (permalink / raw)
To: u-boot
Hi Larry,
On Saturday 22 December 2007, Larry Johnson wrote:
> This driver is based on the driver for the LM75.
Patch seems to be line wrapped. Please fix and resubmit.
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor
2007-12-23 10:40 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2007-12-27 12:18 ` Stefan Roese
2007-12-27 17:56 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Roese @ 2007-12-27 12:18 UTC (permalink / raw)
To: u-boot
On Sunday 23 December 2007, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> > index cebb2ba..32e3f44 100644
> > --- a/drivers/hwmon/Makefile
> > +++ b/drivers/hwmon/Makefile
> > @@ -34,6 +34,7 @@ COBJS-y += adm1021.o
> > COBJS-y += ds1621.o
> > COBJS-y += ds1722.o
> > COBJS-y += ds1775.o
> > +COBJS-y += lm73.o
> > COBJS-y += lm75.o
> > COBJS-y += lm81.o
>
> I will send soon (today or tomorow) the Makefile with conditional
> compilation please rebase your patch about drivers on it.
I would like to get those patches accepted and merged in this merge window. We
should not delay this by waiting on your conditional compilation rework
(which is good of course). So I suggest to get such patches merged right now
and fix possible problems with future additions later.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] CFG_EEPROM_PAGE_WRITE_ENABLE [Was: Re: [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor]
2007-12-27 12:11 ` Stefan Roese
@ 2007-12-27 17:16 ` Larry Johnson
0 siblings, 0 replies; 6+ messages in thread
From: Larry Johnson @ 2007-12-27 17:16 UTC (permalink / raw)
To: u-boot
Stefan Roese wrote:
> Hi Larry,
>
> On Saturday 22 December 2007, Larry Johnson wrote:
>> This driver is based on the driver for the LM75.
>
> Patch seems to be line wrapped. Please fix and resubmit.
> Thanks.
>
> Best regards,
> Stefan
>
> =====================================================================
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
> =====================================================================
I noticed that the offending line was part of a check to ensure that the
symbol "CFG_EEPROM_PAGE_WRITE_ENABLE" is defined. However, I don't see
this switch being used anywhere in the code, although several other HWMON
drivers also check that it is defined. Does anyone know of a reason to
keep defining it?
Best regards,
Larry
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor
2007-12-27 12:18 ` Stefan Roese
@ 2007-12-27 17:56 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2007-12-27 17:56 UTC (permalink / raw)
To: u-boot
On 13:18 Thu 27 Dec , Stefan Roese wrote:
> On Sunday 23 December 2007, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> > > index cebb2ba..32e3f44 100644
> > > --- a/drivers/hwmon/Makefile
> > > +++ b/drivers/hwmon/Makefile
> > > @@ -34,6 +34,7 @@ COBJS-y += adm1021.o
> > > COBJS-y += ds1621.o
> > > COBJS-y += ds1722.o
> > > COBJS-y += ds1775.o
> > > +COBJS-y += lm73.o
> > > COBJS-y += lm75.o
> > > COBJS-y += lm81.o
> >
> > I will send soon (today or tomorow) the Makefile with conditional
> > compilation please rebase your patch about drivers on it.
>
> I would like to get those patches accepted and merged in this merge window. We
> should not delay this by waiting on your conditional compilation rework
> (which is good of course). So I suggest to get such patches merged right now
> and fix possible problems with future additions later.
I understand you view but il will great if the new driver could be use
conditional Makefile.o
Could you do this modification pls
COBJS-$(CONFIG_DTT_LM73) += lm73.o
instead of
> +COBJS-y += lm73.o
and remove if ifdef CONFIG_DTT_LM73 from the lm73.c
Thanks by advance,
J.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-12-27 17:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-22 20:14 [U-Boot-Users] [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor Larry Johnson
2007-12-23 10:40 ` Jean-Christophe PLAGNIOL-VILLARD
2007-12-27 12:18 ` Stefan Roese
2007-12-27 17:56 ` Jean-Christophe PLAGNIOL-VILLARD
2007-12-27 12:11 ` Stefan Roese
2007-12-27 17:16 ` [U-Boot-Users] CFG_EEPROM_PAGE_WRITE_ENABLE [Was: Re: [PATCH 2/9] Add driver for National Semiconductor LM73 temperature sensor] Larry Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox