All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] ADT7460 I2C Monitor Chip Support
@ 2008-07-11  8:23 Ricardo Ribalda Delgado
  2008-07-11  8:23 ` [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support Ricardo Ribalda Delgado
  0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-11  8:23 UTC (permalink / raw)
  To: u-boot

This patch adds support to the ADT7640 I2C Monitor Chip

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  8:23 [U-Boot-Users] ADT7460 I2C Monitor Chip Support Ricardo Ribalda Delgado
@ 2008-07-11  8:23 ` Ricardo Ribalda Delgado
  2008-07-11  8:46   ` Stefan Roese
  2008-07-11  8:54   ` Michal Simek
  0 siblings, 2 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-11  8:23 UTC (permalink / raw)
  To: u-boot


Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/hwmon/adt7460.h |   49 ++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 4 files changed, 133 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c
 create mode 100644 drivers/hwmon/adt7460.h

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 065433a..e301eaa 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-y += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-y += lm75.o
 COBJS-y += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..3fbd6fa
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,81 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+
+#include <i2c.h>
+#include <dtt.h>
+#include "adt7460.h"
+
+#define ADT7460_ADDRESS 0x2c
+int dtt_read(int sensor, int reg)
+{
+	u8 dir=reg;
+	u8 data;
+
+	if (i2c_read(ADT7460_ADDRESS,dir,1,&data,1)==-1)
+		return -1;
+	
+	if (data==ADT7460_INVALID)
+		return -1;
+
+	return data;
+} 
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir=reg;
+	u8 data=val;
+	
+	if (i2c_write(ADT7460_ADDRESS,dir,1,&data,1)==-1)
+		return -1;
+
+	return 0;
+} 
+
+
+
+int dtt_init (void)
+{
+	printf("ADT7460 at I2C address 0x%2x\n",ADT7460_ADDRESS);
+	if (dtt_write(0,ADT7460_CONFIG,1)==-1){
+		printf("Error initialiting ADT7460\n");
+		return -1;
+	}
+	return 0;
+} 
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[]={ADT7460_REM1_TEMP,ADT7460_LOCAL_TEMP,ADT7460_REM2_TEMP};
+	if (sensor>2){
+		printf("DTT sensor does not exist\n");
+		return -1;
+	}
+	
+	aux=dtt_read(0,table[sensor]);
+
+	if (aux==-1){
+		printf("DTT temperature read failed\n");
+		return -1;
+
+	}
+	return aux;
+}
diff --git a/drivers/hwmon/adt7460.h b/drivers/hwmon/adt7460.h
new file mode 100644
index 0000000..d915d1b
--- /dev/null
+++ b/drivers/hwmon/adt7460.h
@@ -0,0 +1,49 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/    
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef ADT7460
+#define ADT7460
+
+
+#define ADT7460_INVALID 128
+
+#define ADT7460_2_5V		0x20
+#define ADT7460_VCCP		0x21
+#define ADT7460_VCC		0x22
+#define ADT7460_V5		0x23
+#define ADT7460_V12		0x24
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+#define ADT7460_TACH1L		0x28
+#define ADT7460_TACH1H		0x29
+#define ADT7460_TACH2L		0x2a
+#define ADT7460_TACH2H		0x2b
+#define ADT7460_TACH3L		0x2c
+#define ADT7460_TACH3H		0x2d
+#define ADT7460_TACH4L		0x2e
+#define ADT7460_TACH4H		0x2f
+#define ADT7460_TACH5L		0xa9
+#define ADT7460_TACH5H		0xaa
+#define ADT7460_TACH6L		0xab
+#define ADT7460_TACH6H		0xac
+#define ADT7460_REVISION	0x3f
+#define ADT7460_CONFIG		0x40
+
+
+#endif
diff --git a/include/dtt.h b/include/dtt.h
index 4e8aaad..db448ce 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73)|| \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  8:23 ` [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support Ricardo Ribalda Delgado
@ 2008-07-11  8:46   ` Stefan Roese
  2008-07-11  8:54   ` Michal Simek
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Roese @ 2008-07-11  8:46 UTC (permalink / raw)
  To: u-boot

On Friday 11 July 2008, Ricardo Ribalda Delgado wrote:
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>

Please find some comments below (mostly nitpicking).

>  drivers/hwmon/Makefile  |    1 +
>  drivers/hwmon/adt7460.c |   81
> +++++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/adt7460.h |  
> 49 ++++++++++++++++++++++++++++
>  include/dtt.h           |    3 +-
>  4 files changed, 133 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/hwmon/adt7460.c
>  create mode 100644 drivers/hwmon/adt7460.h
>
> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> index 065433a..e301eaa 100644
> --- a/drivers/hwmon/Makefile
> +++ b/drivers/hwmon/Makefile
> @@ -37,6 +37,7 @@ COBJS-y += ds1775.o
>  COBJS-$(CONFIG_DTT_LM73) += lm73.o
>  COBJS-y += lm75.o
>  COBJS-y += lm81.o
> +COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
>
>  COBJS	:= $(COBJS-y)
>  SRCS	:= $(COBJS:.o=.c)
> diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
> new file mode 100644
> index 0000000..3fbd6fa
> --- /dev/null
> +++ b/drivers/hwmon/adt7460.c
> @@ -0,0 +1,81 @@
> +/*
> +    (C) Copyright 2008
> +    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
> +    This work has been supported by: Q-Technology  http://qtec.com/
> +
> +    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, see <http://www.gnu.org/licenses/>.
> +*/
> +
> +#include <common.h>
> +
> +#include <i2c.h>
> +#include <dtt.h>
> +#include "adt7460.h"
> +
> +#define ADT7460_ADDRESS 0x2c
> +int dtt_read(int sensor, int reg)
> +{
> +	u8 dir=reg;

Codingstyle:

	u8 dir = reg;

> +	u8 data;
> +
> +	if (i2c_read(ADT7460_ADDRESS,dir,1,&data,1)==-1)

Spaces are sometimes nice too:

	if (i2c_read(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)

> +		return -1;
> +
> +	if (data==ADT7460_INVALID)

Again spaces missing:

	if (data == ADT7460_INVALID)

I'll stop here with it. Please fix all this codingstyle issues in this file.

<snip>

> diff --git a/drivers/hwmon/adt7460.h b/drivers/hwmon/adt7460.h
> new file mode 100644
> index 0000000..d915d1b
> --- /dev/null
> +++ b/drivers/hwmon/adt7460.h
> @@ -0,0 +1,49 @@
> +/*
> +    (C) Copyright 2008
> +    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
> +    This work has been supported by: Q-Technology  http://qtec.com/
> +
> +    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, see <http://www.gnu.org/licenses/>.
> +*/
> +#ifndef ADT7460
> +#define ADT7460
> +
> +
> +#define ADT7460_INVALID 128
> +
> +#define ADT7460_2_5V		0x20
> +#define ADT7460_VCCP		0x21
> +#define ADT7460_VCC		0x22
> +#define ADT7460_V5		0x23
> +#define ADT7460_V12		0x24
> +#define ADT7460_REM1_TEMP	0x25
> +#define ADT7460_LOCAL_TEMP	0x26
> +#define ADT7460_REM2_TEMP	0x27
> +#define ADT7460_TACH1L		0x28
> +#define ADT7460_TACH1H		0x29
> +#define ADT7460_TACH2L		0x2a
> +#define ADT7460_TACH2H		0x2b
> +#define ADT7460_TACH3L		0x2c
> +#define ADT7460_TACH3H		0x2d
> +#define ADT7460_TACH4L		0x2e
> +#define ADT7460_TACH4H		0x2f
> +#define ADT7460_TACH5L		0xa9
> +#define ADT7460_TACH5H		0xaa
> +#define ADT7460_TACH6L		0xab
> +#define ADT7460_TACH6H		0xac
> +#define ADT7460_REVISION	0x3f
> +#define ADT7460_CONFIG		0x40
> +
> +
> +#endif

Do you really think this header is necessary? I would prefer to move those 
defines into the C file instead and drop the header completely.

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] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  8:23 ` [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support Ricardo Ribalda Delgado
  2008-07-11  8:46   ` Stefan Roese
@ 2008-07-11  8:54   ` Michal Simek
  2008-07-11  9:36     ` Stefan Roese
  2008-07-13 13:21     ` Wolfgang Denk
  1 sibling, 2 replies; 14+ messages in thread
From: Michal Simek @ 2008-07-11  8:54 UTC (permalink / raw)
  To: u-boot

Still is there coding style issue.

and you have one extra header file which is uneeded. I recommend you 
move usefull values directly to driver. 

WD: I looked at include/dtt.h there are many driver specific values. IMHO these
value should be usefull move to driver c file. What do you think about?

Michal


Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/hwmon/adt7460.h |   49 ++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 4 files changed, 133 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c
 create mode 100644 drivers/hwmon/adt7460.h

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 065433a..e301eaa 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-y += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-y += lm75.o
 COBJS-y += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..3fbd6fa
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,81 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+
+#include <i2c.h>
+#include <dtt.h>
+#include "adt7460.h"
+
+#define ADT7460_ADDRESS 0x2c
+int dtt_read(int sensor, int reg)
+{
+	u8 dir=reg;
+	u8 data;
+
+	if (i2c_read(ADT7460_ADDRESS,dir,1,&data,1)==-1)
+		return -1;
+	
+	if (data==ADT7460_INVALID)
+		return -1;
+
+	return data;
+} 
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir=reg;
+	u8 data=val;
+	
+	if (i2c_write(ADT7460_ADDRESS,dir,1,&data,1)==-1)
+		return -1;
+
+	return 0;
+} 
+
+
+

Many blank lines.

+int dtt_init (void)
+{
+	printf("ADT7460 at I2C address 0x%2x\n",ADT7460_ADDRESS);
+	if (dtt_write(0,ADT7460_CONFIG,1)==-1){
+		printf("Error initialiting ADT7460\n");
+		return -1;
+	}
+	return 0;
+} 
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[]={ADT7460_REM1_TEMP,ADT7460_LOCAL_TEMP,ADT7460_REM2_TEMP};
+	if (sensor>2){
+		printf("DTT sensor does not exist\n");
+		return -1;
+	}
+	
+	aux=dtt_read(0,table[sensor]);
+
+	if (aux==-1){
+		printf("DTT temperature read failed\n");
+		return -1;
+
+	}
+	return aux;
+}

IMHO this header should be in c file and these values are not used anywhere.

+#define ADT7460_2_5V		0x20
+#define ADT7460_VCCP		0x21
+#define ADT7460_VCC		0x22
+#define ADT7460_V5		0x23
+#define ADT7460_V12		0x24
+#define ADT7460_TACH1L		0x28
+#define ADT7460_TACH1H		0x29
+#define ADT7460_TACH2L		0x2a
+#define ADT7460_TACH2H		0x2b
+#define ADT7460_TACH3L		0x2c
+#define ADT7460_TACH3H		0x2d
+#define ADT7460_TACH4L		0x2e
+#define ADT7460_TACH4H		0x2f
+#define ADT7460_TACH5L		0xa9
+#define ADT7460_TACH5H		0xaa
+#define ADT7460_TACH6L		0xab
+#define ADT7460_TACH6H		0xac
+#define ADT7460_REVISION	0x3f




diff --git a/drivers/hwmon/adt7460.h b/drivers/hwmon/adt7460.h
new file mode 100644
index 0000000..d915d1b
--- /dev/null
+++ b/drivers/hwmon/adt7460.h
@@ -0,0 +1,49 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/    
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef ADT7460
+#define ADT7460
+
+
+#define ADT7460_INVALID 128
+
+#define ADT7460_2_5V		0x20
+#define ADT7460_VCCP		0x21
+#define ADT7460_VCC		0x22
+#define ADT7460_V5		0x23
+#define ADT7460_V12		0x24
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+#define ADT7460_TACH1L		0x28
+#define ADT7460_TACH1H		0x29
+#define ADT7460_TACH2L		0x2a
+#define ADT7460_TACH2H		0x2b
+#define ADT7460_TACH3L		0x2c
+#define ADT7460_TACH3H		0x2d
+#define ADT7460_TACH4L		0x2e
+#define ADT7460_TACH4H		0x2f
+#define ADT7460_TACH5L		0xa9
+#define ADT7460_TACH5H		0xaa
+#define ADT7460_TACH6L		0xab
+#define ADT7460_TACH6H		0xac
+#define ADT7460_REVISION	0x3f
+#define ADT7460_CONFIG		0x40
+
+
+#endif
diff --git a/include/dtt.h b/include/dtt.h
index 4e8aaad..db448ce 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73)|| \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  8:54   ` Michal Simek
@ 2008-07-11  9:36     ` Stefan Roese
  2008-07-13 13:21     ` Wolfgang Denk
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Roese @ 2008-07-11  9:36 UTC (permalink / raw)
  To: u-boot

On Friday 11 July 2008, Michal Simek wrote:
> Still is there coding style issue.
>
> and you have one extra header file which is uneeded. I recommend you
> move usefull values directly to driver.
>
> WD: I looked at include/dtt.h there are many driver specific values. IMHO
> these value should be usefull move to driver c file. What do you think
> about?

Full ACK. Patches welcome. :)

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] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  9:49 [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support (fixed) Ricardo Ribalda Delgado
@ 2008-07-11  9:49 ` Ricardo Ribalda Delgado
  2008-07-11  9:53   ` Michal Simek
  0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-11  9:49 UTC (permalink / raw)
  To: u-boot

From: Ricardo Ribalda Delgado <ricardo@aragorn.ii.uam.es>


Signed-off-by: Ricardo Ribalda Delgado <ricardo@aragorn.ii.uam.es>
---
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   90 +++++++++++++++++++++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 3 files changed, 93 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 065433a..e301eaa 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-y += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-y += lm75.o
 COBJS-y += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..cf54d40
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,90 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+
+#include <i2c.h>
+#include <dtt.h>
+
+#define ADT7460_ADDRESS 	0x2c
+#define ADT7460_INVALID 	128
+#define ADT7460_CONFIG		0x40
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+
+int dtt_read(int sensor, int reg)
+{
+	u8 dir=reg;
+	u8 data;
+
+	if ( i2c_read(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
+		return -1;
+	
+	if (data==ADT7460_INVALID)
+		return -1;
+
+	return data;
+} 
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir=reg;
+	u8 data=val;
+	
+	if ( i2c_write(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
+		return -1;
+
+	return 0;
+} 
+
+
+
+int dtt_init (void)
+{
+	printf("ADT7460 at I2C address 0x%2x\n",ADT7460_ADDRESS);
+
+	if ( dtt_write(0,ADT7460_CONFIG,1) ==-1 ){
+		printf("Error initialiting ADT7460\n");
+		return -1;
+	}
+
+	return 0;
+} 
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[]={ADT7460_REM1_TEMP,ADT7460_LOCAL_TEMP,ADT7460_REM2_TEMP};
+
+	if (sensor>2){
+		printf("DTT sensor does not exist\n");
+		return -1;
+	}
+	
+	aux=dtt_read(0,table[sensor]);
+
+	if (aux==-1){
+		printf("DTT temperature read failed\n");
+		return -1;
+
+	}
+	return aux;
+}
+
diff --git a/include/dtt.h b/include/dtt.h
index 4e8aaad..db448ce 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73)|| \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  9:49 ` [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support Ricardo Ribalda Delgado
@ 2008-07-11  9:53   ` Michal Simek
  0 siblings, 0 replies; 14+ messages in thread
From: Michal Simek @ 2008-07-11  9:53 UTC (permalink / raw)
  To: u-boot

Still you have 3 empty lines. Look at code.

!!!! Do not add more than 2 empty lines to source files 

M

From: Ricardo Ribalda Delgado <ricardo@aragorn.ii.uam.es>


Signed-off-by: Ricardo Ribalda Delgado <ricardo@aragorn.ii.uam.es>
---
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   90 +++++++++++++++++++++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 3 files changed, 93 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 065433a..e301eaa 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-y += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-y += lm75.o
 COBJS-y += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..cf54d40
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,90 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+
+#include <i2c.h>
+#include <dtt.h>
+
+#define ADT7460_ADDRESS 	0x2c
+#define ADT7460_INVALID 	128
+#define ADT7460_CONFIG		0x40
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+
+int dtt_read(int sensor, int reg)
+{
+	u8 dir=reg;
+	u8 data;
+
+	if ( i2c_read(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
+		return -1;
+	
+	if (data==ADT7460_INVALID)
+		return -1;
+
+	return data;
+} 
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir=reg;
+	u8 data=val;
+	
+	if ( i2c_write(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
+		return -1;
+
+	return 0;
+} 
+
+
+

here!!!!

+int dtt_init (void)
+{
+	printf("ADT7460 at I2C address 0x%2x\n",ADT7460_ADDRESS);
+
+	if ( dtt_write(0,ADT7460_CONFIG,1) ==-1 ){
+		printf("Error initialiting ADT7460\n");
+		return -1;
+	}
+
+	return 0;
+} 
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[]={ADT7460_REM1_TEMP,ADT7460_LOCAL_TEMP,ADT7460_REM2_TEMP};
+
+	if (sensor>2){
+		printf("DTT sensor does not exist\n");
+		return -1;
+	}
+	
+	aux=dtt_read(0,table[sensor]);
+
+	if (aux==-1){
+		printf("DTT temperature read failed\n");
+		return -1;
+
+	}
+	return aux;
+}
+
diff --git a/include/dtt.h b/include/dtt.h
index 4e8aaad..db448ce 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73)|| \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
@ 2008-07-11 10:15 Ricardo Ribalda Delgado
  2008-07-11 10:15 ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-11 10:15 UTC (permalink / raw)
  To: u-boot



Removed extra lines

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11 10:15 Ricardo Ribalda Delgado
@ 2008-07-11 10:15 ` Ricardo Ribalda Delgado
  2008-07-11 10:58   ` Stefan Roese
  0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-11 10:15 UTC (permalink / raw)
  To: u-boot


Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 3 files changed, 88 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 065433a..e301eaa 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-y += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-y += lm75.o
 COBJS-y += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..28b2eb7
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,85 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+#include <i2c.h>
+#include <dtt.h>
+
+#define ADT7460_ADDRESS 	0x2c
+#define ADT7460_INVALID 	128
+#define ADT7460_CONFIG		0x40
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+
+int dtt_read(int sensor, int reg)
+{
+	u8 dir=reg;
+	u8 data;
+
+	if ( i2c_read(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
+		return -1;
+	if (data==ADT7460_INVALID)
+		return -1;
+
+	return data;
+} 
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir=reg;
+	u8 data=val;
+	
+	if ( i2c_write(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
+		return -1;
+
+	return 0;
+} 
+
+int dtt_init (void)
+{
+	printf("ADT7460 at I2C address 0x%2x\n",ADT7460_ADDRESS);
+
+	if ( dtt_write(0,ADT7460_CONFIG,1) ==-1 ){
+		printf("Error initialiting ADT7460\n");
+		return -1;
+	}
+
+	return 0;
+} 
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[]={ADT7460_REM1_TEMP,ADT7460_LOCAL_TEMP,ADT7460_REM2_TEMP};
+
+	if (sensor>2){
+		printf("DTT sensor does not exist\n");
+		return -1;
+	}
+	
+	aux=dtt_read(0,table[sensor]);
+	if (aux==-1){
+		printf("DTT temperature read failed\n");
+		return -1;
+
+	}
+
+	return aux;
+}
diff --git a/include/dtt.h b/include/dtt.h
index 4e8aaad..5efe294 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73) || \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11 10:15 ` Ricardo Ribalda Delgado
@ 2008-07-11 10:58   ` Stefan Roese
  2008-07-11 11:12     ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Roese @ 2008-07-11 10:58 UTC (permalink / raw)
  To: u-boot

On Friday 11 July 2008, Ricardo Ribalda Delgado wrote:
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>

Ricardo, please address my (nitpicking) comments below in the next version. 
You could also run "Lindent" if you don't want to do this coding style 
cleanup manually.

> ---
>  drivers/hwmon/Makefile  |    1 +
>  drivers/hwmon/adt7460.c |   85
> +++++++++++++++++++++++++++++++++++++++++++++++ include/dtt.h           |  
>  3 +-
>  3 files changed, 88 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/hwmon/adt7460.c
>
> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> index 065433a..e301eaa 100644
> --- a/drivers/hwmon/Makefile
> +++ b/drivers/hwmon/Makefile
> @@ -37,6 +37,7 @@ COBJS-y += ds1775.o
>  COBJS-$(CONFIG_DTT_LM73) += lm73.o
>  COBJS-y += lm75.o
>  COBJS-y += lm81.o
> +COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
>
>  COBJS	:= $(COBJS-y)
>  SRCS	:= $(COBJS:.o=.c)
> diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
> new file mode 100644
> index 0000000..28b2eb7
> --- /dev/null
> +++ b/drivers/hwmon/adt7460.c
> @@ -0,0 +1,85 @@
> +/*
> +    (C) Copyright 2008
> +    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
> +    This work has been supported by: Q-Technology  http://qtec.com/
> +
> +    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, see <http://www.gnu.org/licenses/>.
> +*/
> +
> +#include <common.h>
> +#include <i2c.h>
> +#include <dtt.h>
> +
> +#define ADT7460_ADDRESS 	0x2c
> +#define ADT7460_INVALID 	128
> +#define ADT7460_CONFIG		0x40
> +#define ADT7460_REM1_TEMP	0x25
> +#define ADT7460_LOCAL_TEMP	0x26
> +#define ADT7460_REM2_TEMP	0x27
> +
> +int dtt_read(int sensor, int reg)
> +{
> +	u8 dir=reg;

Spaces missing:

	u8 dir = reg;

> +	u8 data;
> +
> +	if ( i2c_read(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )

This should be:

	if (i2c_read(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)

> +		return -1;
> +	if (data==ADT7460_INVALID)

Again spaces. And more below...

I suggest you run Lindent over this file.

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] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11 10:58   ` Stefan Roese
@ 2008-07-11 11:12     ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-11 11:12 UTC (permalink / raw)
  To: u-boot

OK,

 I will do it on this and the next patches

  Best Regards

On Fri, Jul 11, 2008 at 12:58 PM, Stefan Roese <sr@denx.de> wrote:
> On Friday 11 July 2008, Ricardo Ribalda Delgado wrote:
>> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
>
> Ricardo, please address my (nitpicking) comments below in the next version.
> You could also run "Lindent" if you don't want to do this coding style
> cleanup manually.
>
>> ---
>>  drivers/hwmon/Makefile  |    1 +
>>  drivers/hwmon/adt7460.c |   85
>> +++++++++++++++++++++++++++++++++++++++++++++++ include/dtt.h           |
>>  3 +-
>>  3 files changed, 88 insertions(+), 1 deletions(-)
>>  create mode 100644 drivers/hwmon/adt7460.c
>>
>> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
>> index 065433a..e301eaa 100644
>> --- a/drivers/hwmon/Makefile
>> +++ b/drivers/hwmon/Makefile
>> @@ -37,6 +37,7 @@ COBJS-y += ds1775.o
>>  COBJS-$(CONFIG_DTT_LM73) += lm73.o
>>  COBJS-y += lm75.o
>>  COBJS-y += lm81.o
>> +COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
>>
>>  COBJS        := $(COBJS-y)
>>  SRCS := $(COBJS:.o=.c)
>> diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
>> new file mode 100644
>> index 0000000..28b2eb7
>> --- /dev/null
>> +++ b/drivers/hwmon/adt7460.c
>> @@ -0,0 +1,85 @@
>> +/*
>> +    (C) Copyright 2008
>> +    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
>> +    This work has been supported by: Q-Technology  http://qtec.com/
>> +
>> +    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, see <http://www.gnu.org/licenses/>.
>> +*/
>> +
>> +#include <common.h>
>> +#include <i2c.h>
>> +#include <dtt.h>
>> +
>> +#define ADT7460_ADDRESS      0x2c
>> +#define ADT7460_INVALID      128
>> +#define ADT7460_CONFIG               0x40
>> +#define ADT7460_REM1_TEMP    0x25
>> +#define ADT7460_LOCAL_TEMP   0x26
>> +#define ADT7460_REM2_TEMP    0x27
>> +
>> +int dtt_read(int sensor, int reg)
>> +{
>> +     u8 dir=reg;
>
> Spaces missing:
>
>        u8 dir = reg;
>
>> +     u8 data;
>> +
>> +     if ( i2c_read(ADT7460_ADDRESS,dir,1,&data,1) ==-1 )
>
> This should be:
>
>        if (i2c_read(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
>
>> +             return -1;
>> +     if (data==ADT7460_INVALID)
>
> Again spaces. And more below...
>
> I suggest you run Lindent over this file.
>
> 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
> =====================================================================
>



-- 
Ricardo Ribalda
http://www.eps.uam.es/~rribalda/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-11  8:54   ` Michal Simek
  2008-07-11  9:36     ` Stefan Roese
@ 2008-07-13 13:21     ` Wolfgang Denk
  2008-07-14 10:32       ` [U-Boot-Users] [PATCH] " Ricardo Ribalda Delgado
  1 sibling, 1 reply; 14+ messages in thread
From: Wolfgang Denk @ 2008-07-13 13:21 UTC (permalink / raw)
  To: u-boot

In message <4618.7248-495-1777888767-1215766461@seznam.cz> you wrote:
> Still is there coding style issue.
> 
> and you have one extra header file which is uneeded. I recommend you 
> move usefull values directly to driver. 
> 
> WD: I looked at include/dtt.h there are many driver specific values. IMHO these
> value should be usefull move to driver c file. What do you think about?

Please feel free to send a patch to clean this up.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A good marriage would be between a blind wife and deaf husband.
                                               -- Michel de Montaigne

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] [PATCH] I2C Monitor Chip ADT7460 support
  2008-07-13 13:21     ` Wolfgang Denk
@ 2008-07-14 10:32       ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-14 10:32 UTC (permalink / raw)
  To: u-boot

From: Ricardo Ribalda Delgado <ricardo@aragorn.ii.uam.es>

Add support to the ADT7460 Monitor Chip by Analog
Devices.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 3 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index f09f145..7342b91 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-$(CONFIG_DTT_DS1775) += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-$(CONFIG_DTT_LM75) += lm75.o
 COBJS-$(CONFIG_DTT_LM81) += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..0239e82
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,86 @@
+/*   
+    (C) Copyright 2008
+    Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+    This work has been supported by: Q-Technology  http://qtec.com/
+
+    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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+#include <i2c.h>
+#include <dtt.h>
+
+#define ADT7460_ADDRESS 	0x2c
+#define ADT7460_INVALID 	128
+#define ADT7460_CONFIG		0x40
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+
+int dtt_read(int sensor, int reg)
+{
+	u8 dir = reg;
+	u8 data;
+
+	if (i2c_read(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
+		return -1;
+	if (data == ADT7460_INVALID)
+		return -1;
+
+	return data;
+}
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir = reg;
+	u8 data = val;
+
+	if (i2c_write(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
+		return -1;
+
+	return 0;
+}
+
+int dtt_init(void)
+{
+	puts("ADT7460 at I2C address 0x%2x\n", ADT7460_ADDRESS);
+
+	if (dtt_write(0, ADT7460_CONFIG, 1) == -1) {
+		puts("Error initialiting ADT7460\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[] =
+	    { ADT7460_REM1_TEMP, ADT7460_LOCAL_TEMP, ADT7460_REM2_TEMP };
+
+	if (sensor > 2) {
+		puts("DTT sensor does not exist\n");
+		return -1;
+	}
+
+	aux = dtt_read(0, table[sensor]);
+	if (aux == -1) {
+		puts("DTT temperature read failed\n");
+		return -1;
+
+	}
+
+	return aux;
+}
diff --git a/include/dtt.h b/include/dtt.h
index 34053d1..ce0fdfa 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73) || \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [U-Boot-Users] [PATCH] I2C Monitor chip ADT7460 support
  2008-07-14 17:30 [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support (new version) Ricardo Ribalda Delgado
@ 2008-07-16  1:05 ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2008-07-16  1:05 UTC (permalink / raw)
  To: u-boot

Minor changes to previous patch

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
-Remove whitespaces

 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/adt7460.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++
 include/dtt.h           |    3 +-
 3 files changed, 86 insertions(+), 1 deletions(-)
 create mode 100644 drivers/hwmon/adt7460.c

diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index f09f145..7342b91 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -37,6 +37,7 @@ COBJS-$(CONFIG_DTT_DS1775) += ds1775.o
 COBJS-$(CONFIG_DTT_LM73) += lm73.o
 COBJS-$(CONFIG_DTT_LM75) += lm75.o
 COBJS-$(CONFIG_DTT_LM81) += lm81.o
+COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/hwmon/adt7460.c b/drivers/hwmon/adt7460.c
new file mode 100644
index 0000000..caef70a
--- /dev/null
+++ b/drivers/hwmon/adt7460.c
@@ -0,0 +1,83 @@
+/*
+ * (C) Copyright 2008
+ * Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda at uam.es
+ * This work has been supported by: QTechnology  http://qtec.com/
+ * 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <common.h>
+#include <i2c.h>
+#include <dtt.h>
+
+#define ADT7460_ADDRESS		0x2c
+#define ADT7460_INVALID		128
+#define ADT7460_CONFIG		0x40
+#define ADT7460_REM1_TEMP	0x25
+#define ADT7460_LOCAL_TEMP	0x26
+#define ADT7460_REM2_TEMP	0x27
+
+int dtt_read(int sensor, int reg)
+{
+	u8 dir = reg;
+	u8 data;
+
+	if (i2c_read(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
+		return -1;
+	if (data == ADT7460_INVALID)
+		return -1;
+
+	return data;
+}
+
+int dtt_write(int sensor, int reg, int val)
+{
+	u8 dir = reg;
+	u8 data = val;
+
+	if (i2c_write(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
+		return -1;
+
+	return 0;
+}
+
+int dtt_init(void)
+{
+	printf("ADT7460 at I2C address 0x%2x\n", ADT7460_ADDRESS);
+
+	if (dtt_write(0, ADT7460_CONFIG, 1) == -1) {
+		puts("Error initialiting ADT7460\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+int dtt_get_temp(int sensor)
+{
+	int aux;
+	u8 table[] =
+	    { ADT7460_REM1_TEMP, ADT7460_LOCAL_TEMP, ADT7460_REM2_TEMP };
+
+	if (sensor > 2) {
+		puts("DTT sensor does not exist\n");
+		return -1;
+	}
+
+	aux = dtt_read(0, table[sensor]);
+	if (aux == -1) {
+		puts("DTT temperature read failed\n");
+		return -1;
+	}
+
+	return aux;
+}
diff --git a/include/dtt.h b/include/dtt.h
index 34053d1..ce0fdfa 100644
--- a/include/dtt.h
+++ b/include/dtt.h
@@ -32,7 +32,8 @@
     defined(CONFIG_DTT_DS1775) || \
     defined(CONFIG_DTT_LM81) || \
     defined(CONFIG_DTT_ADM1021) || \
-    defined(CONFIG_DTT_LM73)
+    defined(CONFIG_DTT_LM73) || \
+    defined(CONFIG_DTT_ADT7460)
 
 #define CONFIG_DTT				/* We have a DTT */
 
-- 
1.5.6.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-07-16  1:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-11  8:23 [U-Boot-Users] ADT7460 I2C Monitor Chip Support Ricardo Ribalda Delgado
2008-07-11  8:23 ` [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support Ricardo Ribalda Delgado
2008-07-11  8:46   ` Stefan Roese
2008-07-11  8:54   ` Michal Simek
2008-07-11  9:36     ` Stefan Roese
2008-07-13 13:21     ` Wolfgang Denk
2008-07-14 10:32       ` [U-Boot-Users] [PATCH] " Ricardo Ribalda Delgado
  -- strict thread matches above, loose matches on Subject: below --
2008-07-11  9:49 [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support (fixed) Ricardo Ribalda Delgado
2008-07-11  9:49 ` [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support Ricardo Ribalda Delgado
2008-07-11  9:53   ` Michal Simek
2008-07-11 10:15 Ricardo Ribalda Delgado
2008-07-11 10:15 ` Ricardo Ribalda Delgado
2008-07-11 10:58   ` Stefan Roese
2008-07-11 11:12     ` Ricardo Ribalda Delgado
2008-07-14 17:30 [U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support (new version) Ricardo Ribalda Delgado
2008-07-16  1:05 ` [U-Boot-Users] [PATCH] I2C Monitor chip ADT7460 support Ricardo Ribalda Delgado

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.