rtc-ds1672.c (520d6516736e1c3f5b7178b2eba13c0b9e172f37) | rtc-ds1672.c (219219d9b89b4be4cb58c1503393cd715d48933a) |
---|---|
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 --- 70 unchanged lines hidden (view full) --- 79 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 80 "mday=%d, mon=%d, year=%d, wday=%d\n", 81 __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, 82 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 83 84 return 0; 85} 86 | 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 --- 70 unchanged lines hidden (view full) --- 79 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 80 "mday=%d, mon=%d, year=%d, wday=%d\n", 81 __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, 82 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 83 84 return 0; 85} 86 |
87static int ds1672_set_mmss(struct device *dev, unsigned long secs) | 87static int ds1672_set_time(struct device *dev, struct rtc_time *tm) |
88{ 89 struct i2c_client *client = to_i2c_client(dev); 90 int xfer; 91 unsigned char buf[6]; | 88{ 89 struct i2c_client *client = to_i2c_client(dev); 90 int xfer; 91 unsigned char buf[6]; |
92 unsigned long secs = rtc_tm_to_time64(tm); |
|
92 93 buf[0] = DS1672_REG_CNT_BASE; 94 buf[1] = secs & 0x000000FF; 95 buf[2] = (secs & 0x0000FF00) >> 8; 96 buf[3] = (secs & 0x00FF0000) >> 16; 97 buf[4] = (secs & 0xFF000000) >> 24; 98 buf[5] = 0; /* set control reg to enable counting */ 99 100 xfer = i2c_master_send(client, buf, 6); 101 if (xfer != 6) { 102 dev_err(&client->dev, "%s: send: %d\n", __func__, xfer); 103 return -EIO; 104 } 105 106 return 0; 107} 108 109static const struct rtc_class_ops ds1672_rtc_ops = { 110 .read_time = ds1672_read_time, | 93 94 buf[0] = DS1672_REG_CNT_BASE; 95 buf[1] = secs & 0x000000FF; 96 buf[2] = (secs & 0x0000FF00) >> 8; 97 buf[3] = (secs & 0x00FF0000) >> 16; 98 buf[4] = (secs & 0xFF000000) >> 24; 99 buf[5] = 0; /* set control reg to enable counting */ 100 101 xfer = i2c_master_send(client, buf, 6); 102 if (xfer != 6) { 103 dev_err(&client->dev, "%s: send: %d\n", __func__, xfer); 104 return -EIO; 105 } 106 107 return 0; 108} 109 110static const struct rtc_class_ops ds1672_rtc_ops = { 111 .read_time = ds1672_read_time, |
111 .set_mmss = ds1672_set_mmss, | 112 .set_time = ds1672_set_time, |
112}; 113 114static int ds1672_probe(struct i2c_client *client, 115 const struct i2c_device_id *id) 116{ 117 int err = 0; 118 struct rtc_device *rtc; 119 --- 50 unchanged lines hidden --- | 113}; 114 115static int ds1672_probe(struct i2c_client *client, 116 const struct i2c_device_id *id) 117{ 118 int err = 0; 119 struct rtc_device *rtc; 120 --- 50 unchanged lines hidden --- |