rtc-rs5c372.c (59458f40e25915a355d8b1d701425fe9f4f9ea23) rtc-rs5c372.c (11966adc33fa1504c2d9a78e6fc129e5c87bdee1)
1/*
2 * An I2C driver for the Ricoh RS5C372 RTC
3 *
4 * Copyright (C) 2005 Pavel Mironchik <pmironchik@optifacio.net>
5 * Copyright (C) 2006 Tower Technologies
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 77 unchanged lines hidden (view full) ---

86 return 0;
87}
88
89static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
90{
91 unsigned char buf[8] = { RS5C372_REG_BASE };
92
93 dev_dbg(&client->dev,
1/*
2 * An I2C driver for the Ricoh RS5C372 RTC
3 *
4 * Copyright (C) 2005 Pavel Mironchik <pmironchik@optifacio.net>
5 * Copyright (C) 2006 Tower Technologies
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 77 unchanged lines hidden (view full) ---

86 return 0;
87}
88
89static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
90{
91 unsigned char buf[8] = { RS5C372_REG_BASE };
92
93 dev_dbg(&client->dev,
94 "%s: secs=%d, mins=%d, hours=%d ",
94 "%s: secs=%d, mins=%d, hours=%d "
95 "mday=%d, mon=%d, year=%d, wday=%d\n",
96 __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour,
97 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
98
99 buf[1] = BIN2BCD(tm->tm_sec);
100 buf[2] = BIN2BCD(tm->tm_min);
101 buf[3] = BIN2BCD(tm->tm_hour);
102 buf[4] = BIN2BCD(tm->tm_wday);

--- 18 unchanged lines hidden (view full) ---

121 { client->addr, I2C_M_RD, 1, &buf },
122 };
123
124 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
125 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
126 return -EIO;
127 }
128
95 "mday=%d, mon=%d, year=%d, wday=%d\n",
96 __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour,
97 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
98
99 buf[1] = BIN2BCD(tm->tm_sec);
100 buf[2] = BIN2BCD(tm->tm_min);
101 buf[3] = BIN2BCD(tm->tm_hour);
102 buf[4] = BIN2BCD(tm->tm_wday);

--- 18 unchanged lines hidden (view full) ---

121 { client->addr, I2C_M_RD, 1, &buf },
122 };
123
124 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
125 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
126 return -EIO;
127 }
128
129 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, trim);
129 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
130
131 if (osc)
132 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
133
134 if (trim)
135 *trim = buf & RS5C372_TRIM_MASK;
136
137 return 0;

--- 153 unchanged lines hidden ---
130
131 if (osc)
132 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
133
134 if (trim)
135 *trim = buf & RS5C372_TRIM_MASK;
136
137 return 0;

--- 153 unchanged lines hidden ---