rtc-ds1672.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) | rtc-ds1672.c (2a4e2b8780c6df42b19c053243dada7fa4d311ee) |
---|---|
1/* 2 * An rtc/i2c driver for the Dallas DS1672 3 * Copyright 2005-06 Tower Technologies 4 * 5 * Author: Alessandro Zummo <a.zummo@towertech.it> 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 --- 36 unchanged lines hidden (view full) --- 45 46 struct i2c_msg msgs[] = { 47 { client->addr, 0, 1, &addr }, /* setup read ptr */ 48 { client->addr, I2C_M_RD, 4, buf }, /* read date */ 49 }; 50 51 /* read date registers */ 52 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | 1/* 2 * An rtc/i2c driver for the Dallas DS1672 3 * Copyright 2005-06 Tower Technologies 4 * 5 * Author: Alessandro Zummo <a.zummo@towertech.it> 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 --- 36 unchanged lines hidden (view full) --- 45 46 struct i2c_msg msgs[] = { 47 { client->addr, 0, 1, &addr }, /* setup read ptr */ 48 { client->addr, I2C_M_RD, 4, buf }, /* read date */ 49 }; 50 51 /* read date registers */ 52 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { |
53 dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | 53 dev_err(&client->dev, "%s: read error\n", __func__); |
54 return -EIO; 55 } 56 57 dev_dbg(&client->dev, 58 "%s: raw read data - counters=%02x,%02x,%02x,%02x\n", | 54 return -EIO; 55 } 56 57 dev_dbg(&client->dev, 58 "%s: raw read data - counters=%02x,%02x,%02x,%02x\n", |
59 __FUNCTION__, buf[0], buf[1], buf[2], buf[3]); | 59 __func__, buf[0], buf[1], buf[2], buf[3]); |
60 61 time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; 62 63 rtc_time_to_tm(time, tm); 64 65 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 66 "mday=%d, mon=%d, year=%d, wday=%d\n", | 60 61 time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; 62 63 rtc_time_to_tm(time, tm); 64 65 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 66 "mday=%d, mon=%d, year=%d, wday=%d\n", |
67 __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour, | 67 __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, |
68 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 69 70 return 0; 71} 72 73static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs) 74{ 75 int xfer; 76 unsigned char buf[6]; 77 78 buf[0] = DS1672_REG_CNT_BASE; 79 buf[1] = secs & 0x000000FF; 80 buf[2] = (secs & 0x0000FF00) >> 8; 81 buf[3] = (secs & 0x00FF0000) >> 16; 82 buf[4] = (secs & 0xFF000000) >> 24; 83 buf[5] = 0; /* set control reg to enable counting */ 84 85 xfer = i2c_master_send(client, buf, 6); 86 if (xfer != 6) { | 68 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 69 70 return 0; 71} 72 73static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs) 74{ 75 int xfer; 76 unsigned char buf[6]; 77 78 buf[0] = DS1672_REG_CNT_BASE; 79 buf[1] = secs & 0x000000FF; 80 buf[2] = (secs & 0x0000FF00) >> 8; 81 buf[3] = (secs & 0x00FF0000) >> 16; 82 buf[4] = (secs & 0xFF000000) >> 24; 83 buf[5] = 0; /* set control reg to enable counting */ 84 85 xfer = i2c_master_send(client, buf, 6); 86 if (xfer != 6) { |
87 dev_err(&client->dev, "%s: send: %d\n", __FUNCTION__, xfer); | 87 dev_err(&client->dev, "%s: send: %d\n", __func__, xfer); |
88 return -EIO; 89 } 90 91 return 0; 92} 93 94static int ds1672_set_datetime(struct i2c_client *client, struct rtc_time *tm) 95{ 96 unsigned long secs; 97 98 dev_dbg(&client->dev, 99 "%s: secs=%d, mins=%d, hours=%d, " 100 "mday=%d, mon=%d, year=%d, wday=%d\n", | 88 return -EIO; 89 } 90 91 return 0; 92} 93 94static int ds1672_set_datetime(struct i2c_client *client, struct rtc_time *tm) 95{ 96 unsigned long secs; 97 98 dev_dbg(&client->dev, 99 "%s: secs=%d, mins=%d, hours=%d, " 100 "mday=%d, mon=%d, year=%d, wday=%d\n", |
101 __FUNCTION__, | 101 __func__, |
102 tm->tm_sec, tm->tm_min, tm->tm_hour, 103 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 104 105 rtc_tm_to_time(tm, &secs); 106 107 return ds1672_set_mmss(client, secs); 108} 109 --- 18 unchanged lines hidden (view full) --- 128 129 struct i2c_msg msgs[] = { 130 { client->addr, 0, 1, &addr }, /* setup read ptr */ 131 { client->addr, I2C_M_RD, 1, status }, /* read control */ 132 }; 133 134 /* read control register */ 135 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | 102 tm->tm_sec, tm->tm_min, tm->tm_hour, 103 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 104 105 rtc_tm_to_time(tm, &secs); 106 107 return ds1672_set_mmss(client, secs); 108} 109 --- 18 unchanged lines hidden (view full) --- 128 129 struct i2c_msg msgs[] = { 130 { client->addr, 0, 1, &addr }, /* setup read ptr */ 131 { client->addr, I2C_M_RD, 1, status }, /* read control */ 132 }; 133 134 /* read control register */ 135 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { |
136 dev_err(&client->dev, "%s: read error\n", __FUNCTION__); | 136 dev_err(&client->dev, "%s: read error\n", __func__); |
137 return -EIO; 138 } 139 140 return 0; 141} 142 143/* following are the sysfs callback functions */ 144static ssize_t show_control(struct device *dev, struct device_attribute *attr, char *buf) --- 49 unchanged lines hidden (view full) --- 194 195static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind) 196{ 197 int err = 0; 198 u8 control; 199 struct i2c_client *client; 200 struct rtc_device *rtc; 201 | 137 return -EIO; 138 } 139 140 return 0; 141} 142 143/* following are the sysfs callback functions */ 144static ssize_t show_control(struct device *dev, struct device_attribute *attr, char *buf) --- 49 unchanged lines hidden (view full) --- 194 195static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind) 196{ 197 int err = 0; 198 u8 control; 199 struct i2c_client *client; 200 struct rtc_device *rtc; 201 |
202 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); | 202 dev_dbg(&adapter->dev, "%s\n", __func__); |
203 204 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { 205 err = -ENODEV; 206 goto exit; 207 } 208 209 if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { 210 err = -ENOMEM; --- 72 unchanged lines hidden --- | 203 204 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { 205 err = -ENODEV; 206 goto exit; 207 } 208 209 if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { 210 err = -ENOMEM; --- 72 unchanged lines hidden --- |