|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * rtc-ds13307.c - RTC driver for the DS1307 and DS13307 I2C chips.
|
|
|
|
|
|
+ * rtc-ds13307.c - RTC driver for the DS1307 and DS1337 I2C chips.
|
|
*
|
|
*
|
|
* Copyright (C) 2018 Helmut Pozimski
|
|
* Copyright (C) 2018 Helmut Pozimski
|
|
*
|
|
*
|
|
@@ -38,7 +38,7 @@ static struct i2c_driver ds13307_driver;
|
|
|
|
|
|
/* Reads a specified number of bytes via i2c, returns 0 on success */
|
|
/* Reads a specified number of bytes via i2c, returns 0 on success */
|
|
static int ds13307_read_bytes(struct i2c_client *client,
|
|
static int ds13307_read_bytes(struct i2c_client *client,
|
|
- unsigned char *addr, u8 *byte, int length) {
|
|
|
|
|
|
+ u8 *addr, u8 *bytes, int length) {
|
|
int r;
|
|
int r;
|
|
struct i2c_msg msgs[] = {
|
|
struct i2c_msg msgs[] = {
|
|
{
|
|
{
|
|
@@ -50,7 +50,7 @@ static int ds13307_read_bytes(struct i2c_client *client,
|
|
.addr = client->addr,
|
|
.addr = client->addr,
|
|
.flags = I2C_M_RD,
|
|
.flags = I2C_M_RD,
|
|
.len = length,
|
|
.len = length,
|
|
- .buf = byte
|
|
|
|
|
|
+ .buf = bytes
|
|
}
|
|
}
|
|
};
|
|
};
|
|
r = i2c_transfer(client->adapter, msgs, 2);
|
|
r = i2c_transfer(client->adapter, msgs, 2);
|
|
@@ -78,10 +78,8 @@ static int ds13307_write_single_byte(struct i2c_client *client, u8 *addr, u8 *by
|
|
* therefore this function checks its status and clears the stop bit.
|
|
* therefore this function checks its status and clears the stop bit.
|
|
*/
|
|
*/
|
|
static int ds13307_start_oscillator(struct i2c_client *client) {
|
|
static int ds13307_start_oscillator(struct i2c_client *client) {
|
|
- u8 data;
|
|
|
|
|
|
+ u8 data, addr, buf[2];
|
|
int r, v;
|
|
int r, v;
|
|
- unsigned char addr;
|
|
|
|
- char buf[2];
|
|
|
|
if (model_detected == DEVICE_DS1307) {
|
|
if (model_detected == DEVICE_DS1307) {
|
|
addr = COMMON_SEC;
|
|
addr = COMMON_SEC;
|
|
} else {
|
|
} else {
|
|
@@ -197,9 +195,8 @@ static const struct rtc_class_ops ds13307_rtc_ops = {
|
|
* -1 on failure
|
|
* -1 on failure
|
|
*/
|
|
*/
|
|
static int ds13307_detect_device(struct i2c_client *client) {
|
|
static int ds13307_detect_device(struct i2c_client *client) {
|
|
- u8 data;
|
|
|
|
|
|
+ u8 data, addr = DS1307_MAX_ADDR;
|
|
int result;
|
|
int result;
|
|
- unsigned char addr = DS1307_MAX_ADDR;
|
|
|
|
result = ds13307_read_bytes(client, &addr, &data, 1);
|
|
result = ds13307_read_bytes(client, &addr, &data, 1);
|
|
if (!result) {
|
|
if (!result) {
|
|
printk(KERN_INFO "%s: Detected device DS1307\n", M_NAME);
|
|
printk(KERN_INFO "%s: Detected device DS1307\n", M_NAME);
|
|
@@ -235,19 +232,21 @@ static int ds13307_probe(struct i2c_client *client,
|
|
}
|
|
}
|
|
|
|
|
|
static struct i2c_device_id ds13307_idtable[] = {
|
|
static struct i2c_device_id ds13307_idtable[] = {
|
|
- { "ds1307", 0 }, {}
|
|
|
|
|
|
+ { "ds1307", 0 },
|
|
|
|
+ { "ds1337", 0 }, {}
|
|
};
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, ds13307_idtable);
|
|
MODULE_DEVICE_TABLE(i2c, ds13307_idtable);
|
|
|
|
|
|
static struct of_device_id ds13307_of_match[] = {
|
|
static struct of_device_id ds13307_of_match[] = {
|
|
{ .compatible = "dallas,ds1307" },
|
|
{ .compatible = "dallas,ds1307" },
|
|
|
|
+ { .compatible = "dallas,ds1337" },
|
|
{}
|
|
{}
|
|
};
|
|
};
|
|
MODULE_DEVICE_TABLE(of, ds13307_of_match);
|
|
MODULE_DEVICE_TABLE(of, ds13307_of_match);
|
|
|
|
|
|
static struct i2c_driver ds13307_driver = {
|
|
static struct i2c_driver ds13307_driver = {
|
|
.driver = {
|
|
.driver = {
|
|
- .name = "rtc-ds13307",
|
|
|
|
|
|
+ .name = M_NAME,
|
|
.of_match_table = of_match_ptr(ds13307_of_match),
|
|
.of_match_table = of_match_ptr(ds13307_of_match),
|
|
.owner = THIS_MODULE
|
|
.owner = THIS_MODULE
|
|
},
|
|
},
|