diff options
| author | Alessandro Zummo <alessandro.zummo@towertech.it> | 2005-10-17 17:04:42 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 17:02:12 -0400 |
| commit | 4d4e5ce8648561b964699afb2df5e7268a84599b (patch) | |
| tree | 95d88cfc63db1e14cba71074a6108ed9a4b16737 | |
| parent | ddec748f328af6b67e4d0ce0248a8e9f36751827 (diff) | |
[PATCH] i2c: New Xicor X1205 RTC driver
New driver for the Xicor X1205 RTC chip.
Signed-off-by: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | Documentation/i2c/chips/x1205 | 38 | ||||
| -rw-r--r-- | drivers/i2c/chips/Kconfig | 9 | ||||
| -rw-r--r-- | drivers/i2c/chips/Makefile | 1 | ||||
| -rw-r--r-- | drivers/i2c/chips/x1205.c | 698 | ||||
| -rw-r--r-- | include/linux/x1205.h | 31 |
5 files changed, 777 insertions, 0 deletions
diff --git a/Documentation/i2c/chips/x1205 b/Documentation/i2c/chips/x1205 new file mode 100644 index 000000000000..09407c991fe5 --- /dev/null +++ b/Documentation/i2c/chips/x1205 | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | Kernel driver x1205 | ||
| 2 | =================== | ||
| 3 | |||
| 4 | Supported chips: | ||
| 5 | * Xicor X1205 RTC | ||
| 6 | Prefix: 'x1205' | ||
| 7 | Addresses scanned: none | ||
| 8 | Datasheet: http://www.intersil.com/cda/deviceinfo/0,1477,X1205,00.html | ||
| 9 | |||
| 10 | Authors: | ||
| 11 | Karen Spearel <kas11@tampabay.rr.com>, | ||
| 12 | Alessandro Zummo <a.zummo@towertech.it> | ||
| 13 | |||
| 14 | Description | ||
| 15 | ----------- | ||
| 16 | |||
| 17 | This module aims to provide complete access to the Xicor X1205 RTC. | ||
| 18 | Recently Xicor has merged with Intersil, but the chip is | ||
| 19 | still sold under the Xicor brand. | ||
| 20 | |||
| 21 | This chip is located at address 0x6f and uses a 2-byte register addressing. | ||
| 22 | Two bytes need to be written to read a single register, while most | ||
| 23 | other chips just require one and take the second one as the data | ||
| 24 | to be written. To prevent corrupting unknown chips, the user must | ||
| 25 | explicitely set the probe parameter. | ||
| 26 | |||
| 27 | example: | ||
| 28 | |||
| 29 | modprobe x1205 probe=0,0x6f | ||
| 30 | |||
| 31 | The module supports one more option, hctosys, which is used to set the | ||
| 32 | software clock from the x1205. On systems where the x1205 is the | ||
| 33 | only hardware rtc, this parameter could be used to achieve a correct | ||
| 34 | date/time earlier in the system boot sequence. | ||
| 35 | |||
| 36 | example: | ||
| 37 | |||
| 38 | modprobe x1205 probe=0,0x6f hctosys=1 | ||
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 6bd44a44cd28..f9fae28f5612 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
| @@ -126,4 +126,13 @@ config SENSORS_MAX6875 | |||
| 126 | This driver can also be built as a module. If so, the module | 126 | This driver can also be built as a module. If so, the module |
| 127 | will be called max6875. | 127 | will be called max6875. |
| 128 | 128 | ||
| 129 | config RTC_X1205_I2C | ||
| 130 | tristate "Xicor X1205 RTC chip" | ||
| 131 | depends on I2C && EXPERIMENTAL | ||
| 132 | help | ||
| 133 | If you say yes here you get support for the Xicor X1205 RTC chip. | ||
| 134 | |||
| 135 | This driver can also be built as a module. If so, the module | ||
| 136 | will be called x1205. | ||
| 137 | |||
| 129 | endmenu | 138 | endmenu |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index a876dd42b860..46178b57b1f1 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
| @@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | |||
| 13 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o | 13 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o |
| 14 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 14 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
| 15 | obj-$(CONFIG_TPS65010) += tps65010.o | 15 | obj-$(CONFIG_TPS65010) += tps65010.o |
| 16 | obj-$(CONFIG_RTC_X1205_I2C) += x1205.o | ||
| 16 | 17 | ||
| 17 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 18 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
| 18 | EXTRA_CFLAGS += -DDEBUG | 19 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c new file mode 100644 index 000000000000..7da366cdc18c --- /dev/null +++ b/drivers/i2c/chips/x1205.c | |||
| @@ -0,0 +1,698 @@ | |||
| 1 | /* | ||
| 2 | * x1205.c - An i2c driver for the Xicor X1205 RTC | ||
| 3 | * Copyright 2004 Karen Spearel | ||
| 4 | * Copyright 2005 Alessandro Zummo | ||
| 5 | * | ||
| 6 | * please send all reports to: | ||
| 7 | * kas11 at tampabay dot rr dot com | ||
| 8 | * a dot zummo at towertech dot it | ||
| 9 | * | ||
| 10 | * based on the other drivers in this same directory. | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify | ||
| 13 | * it under the terms of the GNU General Public License as published by | ||
| 14 | * the Free Software Foundation; either version 2 of the License, or | ||
| 15 | * (at your option) any later version. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/module.h> | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/slab.h> | ||
| 21 | #include <linux/i2c.h> | ||
| 22 | #include <linux/string.h> | ||
| 23 | #include <linux/bcd.h> | ||
| 24 | #include <linux/rtc.h> | ||
| 25 | #include <linux/list.h> | ||
| 26 | |||
| 27 | #include <linux/x1205.h> | ||
| 28 | |||
| 29 | #define DRV_VERSION "0.9.9" | ||
| 30 | |||
| 31 | /* Addresses to scan: none. This chip is located at | ||
| 32 | * 0x6f and uses a two bytes register addressing. | ||
| 33 | * Two bytes need to be written to read a single register, | ||
| 34 | * while most other chips just require one and take the second | ||
| 35 | * one as the data to be written. To prevent corrupting | ||
| 36 | * unknown chips, the user must explicitely set the probe parameter. | ||
| 37 | */ | ||
| 38 | |||
| 39 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
| 40 | |||
| 41 | /* Insmod parameters */ | ||
| 42 | I2C_CLIENT_INSMOD; | ||
| 43 | I2C_CLIENT_MODULE_PARM(hctosys, | ||
| 44 | "Set the system time from the hardware clock upon initialization"); | ||
| 45 | |||
| 46 | /* offsets into CCR area */ | ||
| 47 | |||
| 48 | #define CCR_SEC 0 | ||
| 49 | #define CCR_MIN 1 | ||
| 50 | #define CCR_HOUR 2 | ||
| 51 | #define CCR_MDAY 3 | ||
| 52 | #define CCR_MONTH 4 | ||
| 53 | #define CCR_YEAR 5 | ||
| 54 | #define CCR_WDAY 6 | ||
| 55 | #define CCR_Y2K 7 | ||
| 56 | |||
| 57 | #define X1205_REG_SR 0x3F /* status register */ | ||
| 58 | #define X1205_REG_Y2K 0x37 | ||
| 59 | #define X1205_REG_DW 0x36 | ||
| 60 | #define X1205_REG_YR 0x35 | ||
| 61 | #define X1205_REG_MO 0x34 | ||
| 62 | #define X1205_REG_DT 0x33 | ||
| 63 | #define X1205_REG_HR 0x32 | ||
| 64 | #define X1205_REG_MN 0x31 | ||
| 65 | #define X1205_REG_SC 0x30 | ||
| 66 | #define X1205_REG_DTR 0x13 | ||
| 67 | #define X1205_REG_ATR 0x12 | ||
| 68 | #define X1205_REG_INT 0x11 | ||
| 69 | #define X1205_REG_0 0x10 | ||
| 70 | #define X1205_REG_Y2K1 0x0F | ||
| 71 | #define X1205_REG_DWA1 0x0E | ||
| 72 | #define X1205_REG_YRA1 0x0D | ||
| 73 | #define X1205_REG_MOA1 0x0C | ||
| 74 | #define X1205_REG_DTA1 0x0B | ||
| 75 | #define X1205_REG_HRA1 0x0A | ||
| 76 | #define X1205_REG_MNA1 0x09 | ||
| 77 | #define X1205_REG_SCA1 0x08 | ||
| 78 | #define X1205_REG_Y2K0 0x07 | ||
| 79 | #define X1205_REG_DWA0 0x06 | ||
| 80 | #define X1205_REG_YRA0 0x05 | ||
| 81 | #define X1205_REG_MOA0 0x04 | ||
| 82 | #define X1205_REG_DTA0 0x03 | ||
| 83 | #define X1205_REG_HRA0 0x02 | ||
| 84 | #define X1205_REG_MNA0 0x01 | ||
| 85 | #define X1205_REG_SCA0 0x00 | ||
| 86 | |||
| 87 | #define X1205_CCR_BASE 0x30 /* Base address of CCR */ | ||
| 88 | #define X1205_ALM0_BASE 0x00 /* Base address of ALARM0 */ | ||
| 89 | |||
| 90 | #define X1205_SR_RTCF 0x01 /* Clock failure */ | ||
| 91 | #define X1205_SR_WEL 0x02 /* Write Enable Latch */ | ||
| 92 | #define X1205_SR_RWEL 0x04 /* Register Write Enable */ | ||
| 93 | |||
| 94 | #define X1205_DTR_DTR0 0x01 | ||
| 95 | #define X1205_DTR_DTR1 0x02 | ||
| 96 | #define X1205_DTR_DTR2 0x04 | ||
| 97 | |||
| 98 | #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ | ||
| 99 | |||
| 100 | /* Prototypes */ | ||
| 101 | static int x1205_attach(struct i2c_adapter *adapter); | ||
| 102 | static int x1205_detach(struct i2c_client *client); | ||
| 103 | static int x1205_probe(struct i2c_adapter *adapter, int address, int kind); | ||
| 104 | static int x1205_command(struct i2c_client *client, unsigned int cmd, | ||
| 105 | void *arg); | ||
| 106 | |||
| 107 | static struct i2c_driver x1205_driver = { | ||
| 108 | .owner = THIS_MODULE, | ||
| 109 | .name = "x1205", | ||
| 110 | .flags = I2C_DF_NOTIFY, | ||
| 111 | .attach_adapter = &x1205_attach, | ||
| 112 | .detach_client = &x1205_detach, | ||
| 113 | }; | ||
| 114 | |||
| 115 | struct x1205_data { | ||
| 116 | struct i2c_client client; | ||
| 117 | struct list_head list; | ||
| 118 | unsigned int epoch; | ||
| 119 | }; | ||
| 120 | |||
| 121 | static const unsigned char days_in_mo[] = | ||
| 122 | { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||
