linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Volkov <avolkov@varma-el.com>
To: "Mark A. Greer" <mgreer@mvista.com>, Jean Delvare <khali@linux-fr.org>
Cc: adi@hexapodia.org, lm-sensors@lm-sensors.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] i2c: Combined ST m41txx i2c rtc chip driver
Date: Wed, 11 Jan 2006 22:03:24 +0300	[thread overview]
Message-ID: <43C5567C.8070106@varma-el.com> (raw)
In-Reply-To: <20060111161954.GB6405@mag.az.mvista.com>

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

Hi Mark,

Mark A. Greer wrote:
> On Wed, Jan 11, 2006 at 12:40:05PM +0300, Andrey Volkov wrote:
> 
>>
>>Mark A. Greer wrote:
>>
>>>On Tue, Dec 20, 2005 at 01:05:34PM +0300, Andrey Volkov wrote:
>>>
>>>
>>>>Hello Mark
>>>>
>>>>Big Thanks, I check it on my board today-tomorrow.
>>>>But check some comments below.
>>>
>>>
>>>Did you have a chance to test it?
>>>
>>
>>I testing it now (holidays, sorry).
>>Aprrox 3-4 hours delay.
> 
> 
> No problem.  Just curious if it works for you.
> Please let me know.
> 
> Thanks,
> 
> Mark
> 
Attached patch fix some misspellings and, mainly,
_reset_ HT flag. If this flag is set, then STM418xx
doesn't run in spite of ST flag state.
With this patch my board work ok.

P.S. Jean, "i2c_master_send vs i2c_smbus_write_byte_data"
problem still open.
Could you made executive decision about it?

-- 
Regards
Andrey Volkov

[-- Attachment #2: 01-stm_combind_fixes.diff --]
[-- Type: text/plain, Size: 3928 bytes --]

	* Misc fixes of Mark A. Greers's stm_combined patch
---

 drivers/i2c/chips/Kconfig  |    2 +-
 drivers/i2c/chips/m41txx.c |   45 +++++++++++++++++++++++++-------------------
 include/linux/m41txx.h     |   34 +++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 4a26fb4..8fa3840 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -134,6 +134,6 @@ config RTC_M41TXX_I2C
 	  of I2C RTC chips.
 
 	  This driver can also be built as a module.  If so, the module
-	  will be called m41t00.
+	  will be called m41txx.
 
 endmenu
diff --git a/drivers/i2c/chips/m41txx.c b/drivers/i2c/chips/m41txx.c
index 82ada1f..97564a1 100644
--- a/drivers/i2c/chips/m41txx.c
+++ b/drivers/i2c/chips/m41txx.c
@@ -124,12 +124,12 @@ m41txx_get_rtc_time(void)
 	mon &= 0x1f;
 	year &= 0xff;
 
-	BCD_TO_BIN(sec);
-	BCD_TO_BIN(min);
-	BCD_TO_BIN(hour);
-	BCD_TO_BIN(day);
-	BCD_TO_BIN(mon);
-	BCD_TO_BIN(year);
+	sec = BCD2BIN(sec);
+	min = BCD2BIN(min);
+	hour = BCD2BIN(hour);
+	day = BCD2BIN(day);
+	mon = BCD2BIN(mon);
+	year = BCD2BIN(year);
 
 	year += 1900;
 	if (year < 1970)
@@ -148,12 +148,12 @@ m41txx_set(void *arg)
 	to_tm(nowtime, &tm);
 	tm.tm_year = (tm.tm_year - 1900) % 100;
 
-	BIN_TO_BCD(tm.tm_sec);
-	BIN_TO_BCD(tm.tm_min);
-	BIN_TO_BCD(tm.tm_hour);
-	BIN_TO_BCD(tm.tm_mday);
-	BIN_TO_BCD(tm.tm_mon);
-	BIN_TO_BCD(tm.tm_year);
+	tm.tm_sec = BIN2BCD(tm.tm_sec);
+	tm.tm_min = BIN2BCD(tm.tm_min);
+	tm.tm_hour = BIN2BCD(tm.tm_hour);
+	tm.tm_mday = BIN2BCD(tm.tm_mday);
+	tm.tm_mon = BIN2BCD(tm.tm_mon);
+	tm.tm_year = BIN2BCD(tm.tm_year);
 
 	down(&m41txx_mutex);
 
@@ -259,14 +259,21 @@ m41txx_probe(struct i2c_adapter *adap, i
 	if ((rc = i2c_attach_client(client)) != 0)
 		goto probe_err;
 
-	/* Sst SQW frequency & enable */
-	if ((m41txx_chip->type != M41TXX_TYPE_M41T00) && m41txx_chip->sqw_freq
-			&& ((rc = i2c_smbus_read_byte_data(client,
-				m41txx_chip->alarm_mon)) >= 0)
+	/* Set SQW frequency & enable */
+	if ((m41txx_chip->type != M41TXX_TYPE_M41T00)) {
+		if (m41txx_chip->sqw_freq  
+			&& ((rc = i2c_smbus_read_byte_data(client, 
+				 m41txx_chip->alarm_mon)) >= 0) 
 			&& !(rc & 0x40) && !(i2c_smbus_write_byte_data(
-				client,m41txx_chip->sqw,m41txx_chip->sqw_freq)))
-		i2c_smbus_write_byte_data(client, m41txx_chip->alarm_mon,
-			rc | 0x40);
+				client,m41txx_chip->sqw, m41txx_chip->sqw_freq)))
+			i2c_smbus_write_byte_data(client, m41txx_chip->alarm_mon,
+				rc | 0x40);
+	   /* Reset HT (Halt Update) flag, if it set */	
+		if ( ((rc = i2c_smbus_read_byte_data(client, 
+				 m41txx_chip->alarm_hour)) >= 0) && (rc & 0x40))
+			i2c_smbus_write_byte_data(client, m41txx_chip->alarm_hour,
+				rc & ~0x40);
+	} 
 
 	/* Make sure oscillator is running (i.e., clear 'ST' bit in sec reg) */
 	if (((rc = i2c_smbus_read_byte_data(client, m41txx_chip->sec)) < 0)
diff --git a/include/linux/m41txx.h b/include/linux/m41txx.h
index 31a40d2..8176721 100644
--- a/include/linux/m41txx.h
+++ b/include/linux/m41txx.h
@@ -25,4 +25,38 @@ struct m41txx_platform_data {
 	u32	sqw_freq;
 };
 
+/* SQW output disabled, this is default value by power on*/
+#define SQW_FREQ_DISABLE	(0)
+
+/* 32.768 KHz */
+#define SQW_FREQ_32KHZ	(1<<4)
+/* 8.192 KHz */
+#define SQW_FREQ_8KHZ	(2<<4)
+/* 4.096 KHz */
+#define SQW_FREQ_4KHZ	(3<<4)
+/* 2.048 KHz */
+#define SQW_FREQ_2KHZ	(4<<4)
+/* 1.024 KHz */
+#define SQW_FREQ_1KHZ	(5<<4)
+/* 512 Hz */
+#define SQW_FREQ_512HZ	(6<<4)
+/* 256 Hz */
+#define SQW_FREQ_256HZ	(7<<4)
+/* 128 Hz */
+#define SQW_FREQ_128HZ	(8<<4)
+/* 64 Hz */
+#define SQW_FREQ_64HZ	(9<<4)
+/* 32 Hz */
+#define SQW_FREQ_32HZ	(10<<4)
+/* 16 Hz */
+#define SQW_FREQ_16HZ	(11<<4)
+/* 8 Hz */
+#define SQW_FREQ_8HZ	(12<<4)
+/* 4 Hz */
+#define SQW_FREQ_4HZ	(13<<4)
+/* 2 Hz */
+#define SQW_FREQ_2HZ	(14<<4)
+/* 1 Hz */
+#define SQW_FREQ_1HZ	(15<<4)
+
 #endif /* _M41TXX_H */

  parent reply	other threads:[~2006-01-11 19:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-14 13:50 [PATCH 1/1] Added support of ST m41t85 rtc chip Andrey Volkov
2005-11-15  0:41 ` Andrew Morton
2005-11-15 21:24   ` Andrey Volkov
2005-11-15 20:52 ` Jean Delvare
2005-11-15 21:48   ` Andrey Volkov
2005-11-16  3:15     ` Mark A. Greer
2005-11-16 14:50       ` Andrey Volkov
2005-11-16 18:55       ` Andy Isaacson
2005-11-16 22:24         ` Mark A. Greer
2005-11-18 20:35           ` Mark A. Greer
2005-11-21 12:35             ` Andrey Volkov
2005-12-06 21:18               ` Mark A. Greer
2005-11-16  2:57   ` Mark A. Greer
2005-11-16 14:45     ` Andrey Volkov
2005-11-16 15:19       ` Jean Delvare
2005-11-16 16:43         ` Andrey Volkov
2005-11-16 21:36           ` Mark A. Greer
2005-11-17  9:20           ` Jean Delvare
2005-11-16 21:24         ` Mark A. Greer
2005-12-19 21:03     ` [RFC] i2c: Combined ST m41txx i2c rtc chip driver (was: [PATCH 1/1] Added support of ST m41t85 rtc chip) Mark A. Greer
2005-12-19 21:06       ` Mark A. Greer
2005-12-20 10:05       ` [RFC] i2c: Combined ST m41txx i2c rtc chip driver Andrey Volkov
2005-12-21 21:25         ` Mark A. Greer
     [not found]         ` <20060111000912.GA11471@mag.az.mvista.com>
     [not found]           ` <43C4D275.2070505@varma-el.com>
     [not found]             ` <20060111161954.GB6405@mag.az.mvista.com>
2006-01-11 19:03               ` Andrey Volkov [this message]
2006-01-18 22:06                 ` Mark A. Greer
2006-01-19  7:25                   ` Jean Delvare
2006-01-26  2:01                     ` Mark A. Greer
2006-01-26 20:50                       ` Mark A. Greer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43C5567C.8070106@varma-el.com \
    --to=avolkov@varma-el.com \
    --cc=adi@hexapodia.org \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=mgreer@mvista.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).