Skip to contentSkip to conversation

rtc: rtc-max6900: SMBus support.

PATCH In review Paul Mundt 3 participants 3 messages Jan 14, 2010 – Jan 15, 2010 Real time clock (RTC)

lore
Share & tools
lore

Paul Mundt

author
#0 lore raw

PATCH 1/1 rtc: rtc-max6900: SMBus support.

The current rtc-max6900 driver only supports getting and setting the time through bursting, which requires a controller capable of such. As bursting is merely an optimization, we can also opt for the non-burst fallback path that pokes at the date/time registers individually.

By opting for the fallback solution, it's possible to fully support the RTC on controllers that only implement I2C_FUNC_SMBUS_BYTE_DATA instead of requiring master transfers via I2C_FUNC_I2C.

This was tested with an I2C_FUNC_SMBUS_BYTE_DATA controller with a MAX6909 attached. Currently only a subset of the MAX6909 functionality is supported, patches to extend the current driver to be forthcoming.

There are no functional changes for I2C_FUNC_I2C controllers.

---

 drivers/rtc/Kconfig       |    4 +-
 drivers/rtc/rtc-max6900.c |   83 ++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 79 insertions(+), 8 deletions(-)
drivers/rtc/Kconfig +2 -2
index 8167e9e..1f74b46 100644
@@ -167,10 +167,10 @@ config RTC_DRV_DS1672
 	  will be called rtc-ds1672.
 
 config RTC_DRV_MAX6900
-	tristate "Maxim MAX6900"
+	tristate "Maxim MAX6900/MAX6909"
 	help
 	  If you say yes here you will get support for the
-	  Maxim MAX6900 I2C RTC chip.
+	  Maxim MAX6900 and MAX6909 I2C RTC chips.
 
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-max6900.
drivers/rtc/rtc-max6900.c +77 -6

126 lines not on this page · raw message

Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Paul Mundt

The current rtc-max6900 driver only supports getting and setting the time through bursting, which requires a controller capable of such. As bursting is merely an optimization, we can also opt for the non-burst fallback path that pokes at the date/time registers individually.

By opting for the fallback solution, it's possible to fully support the RTC on controllers that only implement I2C_FUNC_SMBUS_BYTE_DATA instead of requiring master transfers via I2C_FUNC_I2C.

Quoted 7 lines

This was tested with an I2C_FUNC_SMBUS_BYTE_DATA controller with a MAX6909 attached. Currently only a subset of the MAX6909 functionality is supported, patches to extend the current driver to be forthcoming.

There are no functional changes for I2C_FUNC_I2C controllers.

#2 lore raw
In reply to Paul Mundt
Quoted 4 lines · On Thu, 14 Jan 2010 20:32:35 +0900 Paul Mundt <[email protected]> wrote:

The current rtc-max6900 driver only supports getting and setting the time through bursting, which requires a controller capable of such. As bursting is merely an optimization, we can also opt for the non-burst fallback path that pokes at the date/time registers individually.

almost ok, review below.

drivers/rtc/rtc-max6900.c line 63

Quoted 2 lines
drivers/rtc/rtc-max6900.c +1 -1
-static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
+static unsigned int smbus_mode;	/* disabled by default, prefer bursting */

that one should be per-device.

drivers/rtc/rtc-max6900.c static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf) · line 156

Quoted 3 lines
drivers/rtc/rtc-max6900.c +3 -0
+static int max6900_i2c_smbus_read(struct i2c_client *client, u8 *buf)
+{
+	int rc = 0, i;

no need to init rc

drivers/rtc/rtc-max6900.c static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf) · line 177

Quoted 7 lines
drivers/rtc/rtc-max6900.c +7 -0
+static int max6900_i2c_smbus_write(struct i2c_client *client, u8 const *buf)
+{
+	int rc = 0, i;
+
+	for (i = 0; i < MAX6900_REG_LEN; i++)
+		rc |= i2c_smbus_write_byte_data(client,
+				MAX6900_REG_WRITE(i), buf[i]);

please check rc at each write.

you might want to check if you'll have troubles if you read/write when the minutes are changing.

you might also want to investigate block SMbus messages.

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it