[U-Boot-Users] [PATCH] I2C Monitor Chip ADT7460 support (new version)

-Add support to the ADT7460 Monitor Chip by Analog Devices. -Correct wrong previous coding style -Correct previous use of puts
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..197d86c --- /dev/null +++ b/drivers/hwmon/adt7460.c @@ -0,0 +1,86 @@ +/* + (C) Copyright 2008 + Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda@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) { + 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 */

On 17:26 Mon 14 Jul , Ricardo Ribalda Delgado wrote:
-Add support to the ADT7460 Monitor Chip by Analog Devices. -Correct wrong previous coding style -Correct previous use of puts
please add this comment after the ---
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..197d86c --- /dev/null +++ b/drivers/hwmon/adt7460.c @@ -0,0 +1,86 @@ +/*
^^^ please remove whitespace
- (C) Copyright 2008
- Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda@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/.
+*/
please use this style of comment /* * ..... */
+#include <common.h> +#include <i2c.h> +#include <dtt.h>
+#define ADT7460_ADDRESS 0x2c
^
+#define ADT7460_INVALID 128
^ please remove whitespace
+#define ADT7460_CONFIG 0x40 +#define ADT7460_REM1_TEMP 0x25 +#define ADT7460_LOCAL_TEMP 0x26 +#define ADT7460_REM2_TEMP 0x27
+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;
Why no remove this empty line?
- }
- 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)
Best Regards, J.

Signed-off-by: Ricardo Ribalda Delgado ricardo.ribalda@uam.es --- -Add support to the ADT7460 Monitor Chip by Analog Devices. -Correct wrong previous coding style -Correct previous use of puts -Correct comments and 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..68b593b --- /dev/null +++ b/drivers/hwmon/adt7460.c @@ -0,0 +1,83 @@ +/* + * (C) Copyright 2008 + * Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda@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) { + 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 */

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@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 */

Minor changes to previous patch
Signed-off-by: Ricardo Ribalda Delgado ricardo.ribalda@uam.es
--- Added to GNATS database as unassigned-patches/8
Responsible: patch-coord Message-Id: 1216170306-13202-1-git-send-email-ricardo.ribalda@uam.es In-Reply-To: 1216056637-19627-1-git-send-email-ricardo.ribalda@uam.es References: 1216056637-19627-1-git-send-email-ricardo.ribalda@uam.es Patch-Date: Wed Jul 16 03:05:06 +0200 2008
--- -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@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 */
participants (3)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Ricardo Ribalda Delgado
-
u-boot@bugs.denx.de