public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrey Volkov <avolkov@varma-el.com>
To: "Mark A. Greer" <mgreer@mvista.com>
Cc: Jean Delvare <khali@linux-fr.org>,
	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: Tue, 20 Dec 2005 13:05:34 +0300	[thread overview]
Message-ID: <43A7D76E.5050008@varma-el.com> (raw)
In-Reply-To: <20051219210325.GA21696@mag.az.mvista.com>

Hello Mark

Big Thanks, I check it on my board today-tomorrow.
But check some comments below.

Mark A. Greer wrote:
> On Tue, Nov 15, 2005 at 07:57:14PM -0700, Mark A. Greer wrote:
> 
>>I think we can combine the two into an m41txx.c and pass the exact type
>>in via platform_data--that would be the correct mechanism, right?
>>The platform_data could also be used to seed the correct SQW freq and
>>eliminate all the Kconfig noise.
>>
>>Comments?
>>
>>As for Jean's and Andrew's comments about the driver, they seem valid
>>to me and should be addressed.  In Andrey's defense, many of them are my
>>fault.  Once there is a consensus on the merging m41t00 & m41t85
>>question, I'll try to get a fixed up patch within a couple weeks.
> 
> 
> I've made what I think should be close to an acceptable driver that
> supports the m41t00, m41t81, and m41t85 i2c rtc chips.  I only have hw
> to test the m41t00 on a ppc platform, though.
> 
> It was suggested to me a while back to add retries when reading &
> writing the rtc regs.  Personally, I think its overkill but I added the
> code anyway.  You will see in m41txx_get_rtc_time() that 3 tries are
> made to get a good read of all the regs then up to 10 tries are made to
> make sure that the time didn't change while we were doing the reads.
> Something similar is done in m41txx_set().
> 
> Andrey, would you please apply and test this patch on your 5200?
> 
> Andy, I apologize but I didn't take the time to look at the mips tree in
> depth.  I did do a quick scan and I think that you should be able to set
> 'rtc_get_time' to 'm41txx_get_rtc_time' and 'rtc_set_time' to
> 'm41txx_set_rtc_time', and it'll work.  You'll have to hook up the proper
> driver for your host i2c ctlr, though.
> 
> Jean, Andrew, I think I addressed your coding style, etc. issues with
> the driver.  If not, just point out the problems an I'll fix them.
> 
> The patch is against the 2.6.15-rc5-mm3 tree.  Comments welcome.
> 
> [I will send a second patch that contains the changes I made to the ppc
> katana platform that has the m41t00 that I tested with.]
> 
> Thanks,
> 
> Mark

> +	down(&m41txx_mutex);
> +	do {
> +		retries = M41TXX_MAX_RETRIES;
> +
> +		do {
> +			if (((sec = i2c_smbus_read_byte_data(save_client,
> +						m41txx_chip->sec)) >= 0)
> +				&& ((min = i2c_smbus_read_byte_data(save_client,
> +						m41txx_chip->min)) >= 0)
> +				&& ((hour= i2c_smbus_read_byte_data(save_client,
> +						m41txx_chip->hour)) >= 0)
> +				&& ((day = i2c_smbus_read_byte_data(save_client,
> +						m41txx_chip->day)) >= 0)
> +				&& ((mon = i2c_smbus_read_byte_data(save_client,
> +						m41txx_chip->mon)) >= 0)
> +				&& ((year= i2c_smbus_read_byte_data(save_client,
> +						m41txx_chip->year)) >= 0))
> +				break;
> +		} while (--retries > 0);
> +
> +		if ((retries == 0) || ((sec == sec1) && (min == min1)
> +				&& (hour == hour1) && (day == day1)
> +				&& (mon == mon1) && (year == year1)))
> +			break;

I think this code is overburdened (I forgot to point on it last time,
sorry) and may be wrong for m41t8x, since when you send i2c stop
condition (in read_byte_data), you release time registers of m41t8x,
and as a consequence, in the worst case, you must compare/read it an
undetermined number of times, but not 3 times (however, for m41t00 this
code is correct).

I think i2c_master_recv here and i2c_master_send above in m41txx_set
will be more appropriate, since for m41t00 it will have no meaning when
you send STOP (250ms stall), but for m41t8x you could drop this
while-loop completely.

Hint: quotation from m41st85w.pdf p13/34
"The system-to-user transfer of clock data will be
halted whenever the address being read is a clock
address (00h to 07h). The update will resume either
due to a Stop Condition or when the pointer
increments to a non-clock or RAM address."

Also, please, change _obsoleted_ BCD_TO_BIN to BCD2BIN
(see include/linux/bcd.h)


-- 
Regards
Andrey Volkov

  parent reply	other threads:[~2005-12-20 10:05 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       ` Andrey Volkov [this message]
2005-12-21 21:25         ` [RFC] i2c: Combined ST m41txx i2c rtc chip driver 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
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=43A7D76E.5050008@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