diff options
author | Martin Michlmayr <tbm@cyrius.com> | 2006-11-26 16:45:53 +0000 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2006-11-26 16:45:53 +0000 |
commit | bc4889b141e57bd2ebb91a710fa0c8c6071e483f (patch) | |
tree | a0afc9575ada9c089b0292073e46fe5e948de6ba | |
parent | 0ae2081146eebf903aa70eb5dfc3c6861406da38 (diff) | |
download | kernel_replicant_linux-bc4889b141e57bd2ebb91a710fa0c8c6071e483f.tar.gz kernel_replicant_linux-bc4889b141e57bd2ebb91a710fa0c8c6071e483f.tar.bz2 kernel_replicant_linux-bc4889b141e57bd2ebb91a710fa0c8c6071e483f.zip |
rtc: Add patch from Riku Voipio to get RS5C372 going on the N2100.
svn path=/dists/sid/linux-2.6/; revision=7888
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | debian/patches/bugfix/rtc-rs5c372.patch | 224 | ||||
-rw-r--r-- | debian/patches/series/7 | 1 |
3 files changed, 226 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 168467eb60cd..ea27bd23dfb6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ linux-2.6 (2.6.18-7) UNRELEASED; urgency=low [ Martin Michlmayr ] * r8169: Add an option to ignore parity errors. * r8169: Ignore parity errors on the Thecus N2100. + * rtc: Add patch from Riku Voipio to get RS5C372 going on the N2100. * arm/iop32x: Build RS5C372 support into the kernel. -- Bastian Blank <waldi@debian.org> Sun, 26 Nov 2006 10:39:33 +0100 diff --git a/debian/patches/bugfix/rtc-rs5c372.patch b/debian/patches/bugfix/rtc-rs5c372.patch new file mode 100644 index 000000000000..0efdaa99c1f5 --- /dev/null +++ b/debian/patches/bugfix/rtc-rs5c372.patch @@ -0,0 +1,224 @@ +diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c +index 7553d79..f3bca40 100644 +--- a/drivers/rtc/rtc-rs5c372.c ++++ b/drivers/rtc/rtc-rs5c372.c +@@ -13,7 +13,7 @@ + #include <linux/rtc.h> + #include <linux/bcd.h> + +-#define DRV_VERSION "0.2" ++#define DRV_VERSION "0.3" + + /* Addresses to scan */ + static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END }; +@@ -39,6 +39,14 @@ static int rs5c372_attach(struct i2c_ada + static int rs5c372_detach(struct i2c_client *client); + static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind); + ++struct rs5c372 { ++ u8 reg_addr; ++ u8 regs[17]; ++ struct i2c_msg msg[1]; ++ struct i2c_client client; ++ struct rtc_device *rtc; ++}; ++ + static struct i2c_driver rs5c372_driver = { + .driver = { + .name = "rs5c372", +@@ -49,22 +57,19 @@ static struct i2c_driver rs5c372_driver + + static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) + { +- unsigned char buf[7] = { RS5C372_REG_BASE }; + +- /* this implements the 1st reading method, according +- * to the datasheet. buf[0] is initialized with +- * address ptr and transmission format register. ++ struct rs5c372 *rs5c372 = i2c_get_clientdata(client); ++ u8 *buf = &(rs5c372->regs[1]); ++ ++ /* this implements the 3rd reading method, according ++ * to the datasheet. rs5c372 defaults to internal ++ * address 0xF, so 0x0 is in regs[1] + */ +- struct i2c_msg msgs[] = { +- { client->addr, 0, 1, buf }, +- { client->addr, I2C_M_RD, 7, buf }, +- }; + +- if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { ++ if ((i2c_transfer(client->adapter, rs5c372->msg, 1)) != 1) { + dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + return -EIO; + } +- + tm->tm_sec = BCD2BIN(buf[RS5C372_REG_SECS] & 0x7f); + tm->tm_min = BCD2BIN(buf[RS5C372_REG_MINS] & 0x7f); + tm->tm_hour = BCD2BIN(buf[RS5C372_REG_HOURS] & 0x3f); +@@ -91,7 +96,7 @@ static int rs5c372_set_datetime(struct i + unsigned char buf[8] = { RS5C372_REG_BASE }; + + dev_dbg(&client->dev, +- "%s: secs=%d, mins=%d, hours=%d ", ++ "%s: secs=%d, mins=%d, hours=%d " + "mday=%d, mon=%d, year=%d, wday=%d\n", + __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour, + tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); +@@ -114,25 +119,16 @@ static int rs5c372_set_datetime(struct i + + static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim) + { +- unsigned char buf = RS5C372_REG_TRIM; +- +- struct i2c_msg msgs[] = { +- { client->addr, 0, 1, &buf }, +- { client->addr, I2C_M_RD, 1, &buf }, +- }; +- +- if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { +- dev_err(&client->dev, "%s: read error\n", __FUNCTION__); +- return -EIO; +- } ++ struct rs5c372 *rs5c372 = i2c_get_clientdata(client); ++ u8 tmp = rs5c372->regs[RS5C372_REG_TRIM + 1]; + +- dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, trim); ++ dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, tmp); + + if (osc) +- *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768; ++ *osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768; + + if (trim) +- *trim = buf & RS5C372_TRIM_MASK; ++ *trim = tmp & RS5C372_TRIM_MASK; + + return 0; + } +@@ -160,14 +156,14 @@ static int rs5c372_rtc_proc(struct devic + return 0; + } + +-static struct rtc_class_ops rs5c372_rtc_ops = { ++static const struct rtc_class_ops rs5c372_rtc_ops = { + .proc = rs5c372_rtc_proc, + .read_time = rs5c372_rtc_read_time, + .set_time = rs5c372_rtc_set_time, + }; + + static ssize_t rs5c372_sysfs_show_trim(struct device *dev, +- struct device_attribute *attr, char *buf) ++ struct device_attribute *attr, char *buf) + { + int err, trim; + +@@ -180,7 +176,7 @@ static ssize_t rs5c372_sysfs_show_trim(s + static DEVICE_ATTR(trim, S_IRUGO, rs5c372_sysfs_show_trim, NULL); + + static ssize_t rs5c372_sysfs_show_osc(struct device *dev, +- struct device_attribute *attr, char *buf) ++ struct device_attribute *attr, char *buf) + { + int err, osc; + +@@ -199,9 +195,9 @@ static int rs5c372_attach(struct i2c_ada + + static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind) + { ++ struct rs5c372 *rs5c372; + int err = 0; + struct i2c_client *client; +- struct rtc_device *rtc; + + dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); + +@@ -210,62 +206,68 @@ static int rs5c372_probe(struct i2c_adap + goto exit; + } + +- if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { ++ if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) { + err = -ENOMEM; + goto exit; + } ++ client = &rs5c372->client; + +- /* I2C client */ + client->addr = address; +- client->driver = &rs5c372_driver; + client->adapter = adapter; +- ++ client->driver = &rs5c372_driver; + strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE); + ++ i2c_set_clientdata(client, rs5c372); ++ ++ rs5c372->msg[0].addr = address; ++ rs5c372->msg[0].flags = I2C_M_RD; ++ rs5c372->msg[0].len = sizeof(rs5c372->regs); ++ rs5c372->msg[0].buf = rs5c372->regs; ++ + /* Inform the i2c layer */ + if ((err = i2c_attach_client(client))) + goto exit_kfree; + + dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); + +- rtc = rtc_device_register(rs5c372_driver.driver.name, &client->dev, ++ rs5c372->rtc = ++ rtc_device_register(rs5c372_driver.driver.name, &client->dev, + &rs5c372_rtc_ops, THIS_MODULE); + +- if (IS_ERR(rtc)) { +- err = PTR_ERR(rtc); ++ if (IS_ERR(rs5c372->rtc)) { ++ err = PTR_ERR(rs5c372->rtc); + goto exit_detach; + } + +- i2c_set_clientdata(client, rtc); +- +- device_create_file(&client->dev, &dev_attr_trim); +- device_create_file(&client->dev, &dev_attr_osc); ++ if ((err = device_create_file(&client->dev, &dev_attr_trim))) ++ goto exit_detach; ++ if ((err = device_create_file(&client->dev, &dev_attr_osc))) ++ goto exit_detach; + + return 0; + +-exit_detach: ++ exit_detach: + i2c_detach_client(client); + +-exit_kfree: +- kfree(client); ++ exit_kfree: ++ kfree(rs5c372); + +-exit: ++ exit: + return err; + } + + static int rs5c372_detach(struct i2c_client *client) + { + int err; +- struct rtc_device *rtc = i2c_get_clientdata(client); ++ struct rs5c372 *rs5c372 = i2c_get_clientdata(client); + +- if (rtc) +- rtc_device_unregister(rtc); ++ if (rs5c372->rtc) ++ rtc_device_unregister(rs5c372->rtc); + + if ((err = i2c_detach_client(client))) + return err; + +- kfree(client); +- ++ kfree(rs5c372); + return 0; + } + diff --git a/debian/patches/series/7 b/debian/patches/series/7 index e68f36e3bbb9..cd06b1d23591 100644 --- a/debian/patches/series/7 +++ b/debian/patches/series/7 @@ -1,2 +1,3 @@ + bugfix/r8169-ignore-parity.patch + bugfix/arm/r8169-ignore-parity-n2100.patch ++ bugfix/rtc-rs5c372.patch |