Blame view

drivers/rtc/rtc-rs5c313.c 10.5 KB
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  /*
   * Ricoh RS5C313 RTC device/driver
   *  Copyright (C) 2007 Nobuhiro Iwamatsu
   *
   *  2005-09-19 modifed by kogiidena
   *
   * Based on the old drivers/char/rs5c313_rtc.c  by:
   *  Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
   *  Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
   *
   * Based on code written by Paul Gortmaker.
   *  Copyright (C) 1996 Paul Gortmaker
   *
   * This file is subject to the terms and conditions of the GNU General Public
   * License.  See the file "COPYING" in the main directory of this archive
   * for more details.
   *
   * Based on other minimal char device drivers, like Alan's
   * watchdog, Ted's random, etc. etc.
   *
   *	1.07	Paul Gortmaker.
   *	1.08	Miquel van Smoorenburg: disallow certain things on the
   *		DEC Alpha as the CMOS clock is also used for other things.
   *	1.09	Nikita Schmidt: epoch support and some Alpha cleanup.
   *	1.09a	Pete Zaitcev: Sun SPARC
   *	1.09b	Jeff Garzik: Modularize, init cleanup
   *	1.09c	Jeff Garzik: SMP cleanup
   *	1.10    Paul Barton-Davis: add support for async I/O
   *	1.10a	Andrea Arcangeli: Alpha updates
   *	1.10b	Andrew Morton: SMP lock fix
   *	1.10c	Cesar Barros: SMP locking fixes and cleanup
   *	1.10d	Paul Gortmaker: delete paranoia check in rtc_exit
   *	1.10e	Maciej W. Rozycki: Handle DECstation's year weirdness.
   *      1.11    Takashi Iwai: Kernel access functions
   *			      rtc_register/rtc_unregister/rtc_control
   *      1.11a   Daniele Bellucci: Audit create_proc_read_entry in rtc_init
   *	1.12	Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
   *		CONFIG_HPET_EMULATE_RTC
   *	1.13	Nobuhiro Iwamatsu: Updata driver.
   */
aa161902e   Jingoo Han   rtc: rtc-rs5c313:...
41
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
42
43
44
45
46
47
  #include <linux/module.h>
  #include <linux/err.h>
  #include <linux/rtc.h>
  #include <linux/platform_device.h>
  #include <linux/bcd.h>
  #include <linux/delay.h>
91b80e4c3   Sachin Kamat   drivers/rtc/rtc-r...
48
  #include <linux/io.h>
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
49
50
  
  #define DRV_NAME	"rs5c313"
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  
  #ifdef CONFIG_SH_LANDISK
  /*****************************************************/
  /* LANDISK dependence part of RS5C313                */
  /*****************************************************/
  
  #define SCSMR1		0xFFE00000
  #define SCSCR1		0xFFE00008
  #define SCSMR1_CA	0x80
  #define SCSCR1_CKE	0x03
  #define SCSPTR1		0xFFE0001C
  #define SCSPTR1_EIO	0x80
  #define SCSPTR1_SPB1IO	0x08
  #define SCSPTR1_SPB1DT	0x04
  #define SCSPTR1_SPB0IO	0x02
  #define SCSPTR1_SPB0DT	0x01
  
  #define SDA_OEN		SCSPTR1_SPB1IO
  #define SDA		SCSPTR1_SPB1DT
  #define SCL_OEN		SCSPTR1_SPB0IO
  #define SCL		SCSPTR1_SPB0DT
  
  /* RICOH RS5C313 CE port */
  #define RS5C313_CE	0xB0000003
  
  /* RICOH RS5C313 CE port bit */
  #define RS5C313_CE_RTCCE	0x02
  
  /* SCSPTR1 data */
  unsigned char scsptr1_data;
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
81
82
83
  #define RS5C313_CEENABLE    __raw_writeb(RS5C313_CE_RTCCE, RS5C313_CE);
  #define RS5C313_CEDISABLE   __raw_writeb(0x00, RS5C313_CE)
  #define RS5C313_MISCOP      __raw_writeb(0x02, 0xB0000008)
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
84
85
86
87
  
  static void rs5c313_init_port(void)
  {
  	/* Set SCK as I/O port and Initialize SCSPTR1 data & I/O port. */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
88
89
  	__raw_writeb(__raw_readb(SCSMR1) & ~SCSMR1_CA, SCSMR1);
  	__raw_writeb(__raw_readb(SCSCR1) & ~SCSCR1_CKE, SCSCR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
90
91
  
  	/* And Initialize SCL for RS5C313 clock */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
92
93
94
95
  	scsptr1_data = __raw_readb(SCSPTR1) | SCL;	/* SCL:H */
  	__raw_writeb(scsptr1_data, SCSPTR1);
  	scsptr1_data = __raw_readb(SCSPTR1) | SCL_OEN;	/* SCL output enable */
  	__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
96
97
98
99
100
101
102
103
104
105
106
  	RS5C313_CEDISABLE;	/* CE:L */
  }
  
  static void rs5c313_write_data(unsigned char data)
  {
  	int i;
  
  	for (i = 0; i < 8; i++) {
  		/* SDA:Write Data */
  		scsptr1_data = (scsptr1_data & ~SDA) |
  				((((0x80 >> i) & data) >> (7 - i)) << 2);
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
107
  		__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
108
109
  		if (i == 0) {
  			scsptr1_data |= SDA_OEN;	/* SDA:output enable */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
110
  			__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
111
112
113
  		}
  		ndelay(700);
  		scsptr1_data &= ~SCL;	/* SCL:L */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
114
  		__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
115
116
  		ndelay(700);
  		scsptr1_data |= SCL;	/* SCL:H */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
117
  		__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
118
119
120
  	}
  
  	scsptr1_data &= ~SDA_OEN;	/* SDA:output disable */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
121
  	__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
122
123
124
125
126
  }
  
  static unsigned char rs5c313_read_data(void)
  {
  	int i;
9a3f1d53d   kogiidena   rtc-rs5c313.c: er...
127
  	unsigned char data = 0;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
128
129
130
131
  
  	for (i = 0; i < 8; i++) {
  		ndelay(700);
  		/* SDA:Read Data */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
132
  		data |= ((__raw_readb(SCSPTR1) & SDA) >> 2) << (7 - i);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
133
  		scsptr1_data &= ~SCL;	/* SCL:L */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
134
  		__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
135
136
  		ndelay(700);
  		scsptr1_data |= SCL;	/* SCL:H */
071a1e33b   Paul Mundt   rtc: rtc-rs5c313:...
137
  		__raw_writeb(scsptr1_data, SCSPTR1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
  	}
  	return data & 0x0F;
  }
  
  #endif /* CONFIG_SH_LANDISK */
  
  /*****************************************************/
  /* machine independence part of RS5C313              */
  /*****************************************************/
  
  /* RICOH RS5C313 address */
  #define RS5C313_ADDR_SEC	0x00
  #define RS5C313_ADDR_SEC10	0x01
  #define RS5C313_ADDR_MIN	0x02
  #define RS5C313_ADDR_MIN10	0x03
  #define RS5C313_ADDR_HOUR	0x04
  #define RS5C313_ADDR_HOUR10	0x05
  #define RS5C313_ADDR_WEEK	0x06
  #define RS5C313_ADDR_INTINTVREG	0x07
  #define RS5C313_ADDR_DAY	0x08
  #define RS5C313_ADDR_DAY10	0x09
  #define RS5C313_ADDR_MON	0x0A
  #define RS5C313_ADDR_MON10	0x0B
  #define RS5C313_ADDR_YEAR	0x0C
  #define RS5C313_ADDR_YEAR10	0x0D
  #define RS5C313_ADDR_CNTREG	0x0E
  #define RS5C313_ADDR_TESTREG	0x0F
  
  /* RICOH RS5C313 control register */
  #define RS5C313_CNTREG_ADJ_BSY	0x01
  #define RS5C313_CNTREG_WTEN_XSTP	0x02
  #define RS5C313_CNTREG_12_24	0x04
  #define RS5C313_CNTREG_CTFG	0x08
  
  /* RICOH RS5C313 test register */
  #define RS5C313_TESTREG_TEST	0x01
  
  /* RICOH RS5C313 control bit */
  #define RS5C313_CNTBIT_READ	0x40
  #define RS5C313_CNTBIT_AD	0x20
  #define RS5C313_CNTBIT_DT	0x10
  
  static unsigned char rs5c313_read_reg(unsigned char addr)
  {
  
  	rs5c313_write_data(addr | RS5C313_CNTBIT_READ | RS5C313_CNTBIT_AD);
  	return rs5c313_read_data();
  }
  
  static void rs5c313_write_reg(unsigned char addr, unsigned char data)
  {
  	data &= 0x0f;
  	rs5c313_write_data(addr | RS5C313_CNTBIT_AD);
  	rs5c313_write_data(data | RS5C313_CNTBIT_DT);
  	return;
  }
9a3f1d53d   kogiidena   rtc-rs5c313.c: er...
194
  static inline unsigned char rs5c313_read_cntreg(void)
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
  {
  	return rs5c313_read_reg(RS5C313_ADDR_CNTREG);
  }
  
  static inline void rs5c313_write_cntreg(unsigned char data)
  {
  	rs5c313_write_reg(RS5C313_ADDR_CNTREG, data);
  }
  
  static inline void rs5c313_write_intintvreg(unsigned char data)
  {
  	rs5c313_write_reg(RS5C313_ADDR_INTINTVREG, data);
  }
  
  static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm)
  {
  	int data;
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
212
  	int cnt;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
213

4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
214
  	cnt = 0;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
215
216
217
218
219
220
221
222
223
224
225
  	while (1) {
  		RS5C313_CEENABLE;	/* CE:H */
  
  		/* Initialize control reg. 24 hour */
  		rs5c313_write_cntreg(0x04);
  
  		if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY))
  			break;
  
  		RS5C313_CEDISABLE;
  		ndelay(700);	/* CE:L */
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
226
  		if (cnt++ > 100) {
2a4e2b878   Harvey Harrison   rtc: replace rema...
227
228
  			dev_err(dev, "%s: timeout error
  ", __func__);
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
229
230
  			return -EIO;
  		}
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
231
232
233
234
  	}
  
  	data = rs5c313_read_reg(RS5C313_ADDR_SEC);
  	data |= (rs5c313_read_reg(RS5C313_ADDR_SEC10) << 4);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
235
  	tm->tm_sec = bcd2bin(data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
236
237
238
  
  	data = rs5c313_read_reg(RS5C313_ADDR_MIN);
  	data |= (rs5c313_read_reg(RS5C313_ADDR_MIN10) << 4);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
239
  	tm->tm_min = bcd2bin(data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
240
241
242
  
  	data = rs5c313_read_reg(RS5C313_ADDR_HOUR);
  	data |= (rs5c313_read_reg(RS5C313_ADDR_HOUR10) << 4);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
243
  	tm->tm_hour = bcd2bin(data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
244
245
246
  
  	data = rs5c313_read_reg(RS5C313_ADDR_DAY);
  	data |= (rs5c313_read_reg(RS5C313_ADDR_DAY10) << 4);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
247
  	tm->tm_mday = bcd2bin(data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
248
249
250
  
  	data = rs5c313_read_reg(RS5C313_ADDR_MON);
  	data |= (rs5c313_read_reg(RS5C313_ADDR_MON10) << 4);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
251
  	tm->tm_mon = bcd2bin(data) - 1;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
252
253
254
  
  	data = rs5c313_read_reg(RS5C313_ADDR_YEAR);
  	data |= (rs5c313_read_reg(RS5C313_ADDR_YEAR10) << 4);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
255
  	tm->tm_year = bcd2bin(data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
256
257
258
259
260
  
  	if (tm->tm_year < 70)
  		tm->tm_year += 100;
  
  	data = rs5c313_read_reg(RS5C313_ADDR_WEEK);
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
261
  	tm->tm_wday = bcd2bin(data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
262
263
264
265
266
267
268
269
270
271
  
  	RS5C313_CEDISABLE;
  	ndelay(700);		/* CE:L */
  
  	return 0;
  }
  
  static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm)
  {
  	int data;
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
272
  	int cnt;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
273

4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
274
  	cnt = 0;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
275
276
277
278
279
280
281
282
283
284
285
286
  	/* busy check. */
  	while (1) {
  		RS5C313_CEENABLE;	/* CE:H */
  
  		/* Initiatlize control reg. 24 hour */
  		rs5c313_write_cntreg(0x04);
  
  		if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY))
  			break;
  		RS5C313_MISCOP;
  		RS5C313_CEDISABLE;
  		ndelay(700);	/* CE:L */
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
287
288
  
  		if (cnt++ > 100) {
2a4e2b878   Harvey Harrison   rtc: replace rema...
289
290
  			dev_err(dev, "%s: timeout error
  ", __func__);
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
291
292
  			return -EIO;
  		}
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
293
  	}
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
294
  	data = bin2bcd(tm->tm_sec);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
295
296
  	rs5c313_write_reg(RS5C313_ADDR_SEC, data);
  	rs5c313_write_reg(RS5C313_ADDR_SEC10, (data >> 4));
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
297
  	data = bin2bcd(tm->tm_min);
675090fa8   Sachin Kamat   drivers/rtc/rtc-r...
298
  	rs5c313_write_reg(RS5C313_ADDR_MIN, data);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
299
  	rs5c313_write_reg(RS5C313_ADDR_MIN10, (data >> 4));
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
300
  	data = bin2bcd(tm->tm_hour);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
301
302
  	rs5c313_write_reg(RS5C313_ADDR_HOUR, data);
  	rs5c313_write_reg(RS5C313_ADDR_HOUR10, (data >> 4));
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
303
  	data = bin2bcd(tm->tm_mday);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
304
  	rs5c313_write_reg(RS5C313_ADDR_DAY, data);
675090fa8   Sachin Kamat   drivers/rtc/rtc-r...
305
  	rs5c313_write_reg(RS5C313_ADDR_DAY10, (data >> 4));
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
306

fe20ba70a   Adrian Bunk   drivers/rtc/: use...
307
  	data = bin2bcd(tm->tm_mon + 1);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
308
309
  	rs5c313_write_reg(RS5C313_ADDR_MON, data);
  	rs5c313_write_reg(RS5C313_ADDR_MON10, (data >> 4));
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
310
  	data = bin2bcd(tm->tm_year % 100);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
311
312
  	rs5c313_write_reg(RS5C313_ADDR_YEAR, data);
  	rs5c313_write_reg(RS5C313_ADDR_YEAR10, (data >> 4));
fe20ba70a   Adrian Bunk   drivers/rtc/: use...
313
  	data = bin2bcd(tm->tm_wday);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
314
315
316
317
318
319
320
321
322
323
324
  	rs5c313_write_reg(RS5C313_ADDR_WEEK, data);
  
  	RS5C313_CEDISABLE;	/* CE:H */
  	ndelay(700);
  
  	return 0;
  }
  
  static void rs5c313_check_xstp_bit(void)
  {
  	struct rtc_time tm;
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
325
  	int cnt;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
326
327
328
329
330
331
332
333
334
  
  	RS5C313_CEENABLE;	/* CE:H */
  	if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) {
  		/* INT interval reg. OFF */
  		rs5c313_write_intintvreg(0x00);
  		/* Initialize control reg. 24 hour & adjust */
  		rs5c313_write_cntreg(0x07);
  
  		/* busy check. */
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
335
336
337
  		for (cnt = 0; cnt < 100; cnt++) {
  			if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY))
  				break;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
338
  			RS5C313_MISCOP;
4ac24b3ba   kogiidena   rtc-rs5c313.c: ad...
339
  		}
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
340
341
  
  		memset(&tm, 0, sizeof(struct rtc_time));
675090fa8   Sachin Kamat   drivers/rtc/rtc-r...
342
343
344
  		tm.tm_mday	= 1;
  		tm.tm_mon	= 1 - 1;
  		tm.tm_year	= 2000 - 1900;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
345
346
  
  		rs5c313_rtc_set_time(NULL, &tm);
aa161902e   Jingoo Han   rtc: rtc-rs5c313:...
347
348
  		pr_err("invalid value, resetting to 1 Jan 2000
  ");
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
349
350
351
352
353
354
355
356
357
358
359
360
  	}
  	RS5C313_CEDISABLE;
  	ndelay(700);		/* CE:L */
  }
  
  static const struct rtc_class_ops rs5c313_rtc_ops = {
  	.read_time = rs5c313_rtc_read_time,
  	.set_time = rs5c313_rtc_set_time,
  };
  
  static int rs5c313_rtc_probe(struct platform_device *pdev)
  {
284e2fa1d   Jingoo Han   rtc: rtc-rs5c313:...
361
  	struct rtc_device *rtc = devm_rtc_device_register(&pdev->dev, "rs5c313",
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
362
363
364
365
366
367
  				&rs5c313_rtc_ops, THIS_MODULE);
  
  	if (IS_ERR(rtc))
  		return PTR_ERR(rtc);
  
  	platform_set_drvdata(pdev, rtc);
9a3f1d53d   kogiidena   rtc-rs5c313.c: er...
368
  	return 0;
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
369
  }
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
370
371
372
  static struct platform_driver rs5c313_rtc_platform_driver = {
  	.driver         = {
  		.name   = DRV_NAME,
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
373
  	},
675090fa8   Sachin Kamat   drivers/rtc/rtc-r...
374
  	.probe	= rs5c313_rtc_probe,
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
  };
  
  static int __init rs5c313_rtc_init(void)
  {
  	int err;
  
  	err = platform_driver_register(&rs5c313_rtc_platform_driver);
  	if (err)
  		return err;
  
  	rs5c313_init_port();
  	rs5c313_check_xstp_bit();
  
  	return 0;
  }
  
  static void __exit rs5c313_rtc_exit(void)
  {
675090fa8   Sachin Kamat   drivers/rtc/rtc-r...
393
  	platform_driver_unregister(&rs5c313_rtc_platform_driver);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
394
395
396
397
  }
  
  module_init(rs5c313_rtc_init);
  module_exit(rs5c313_rtc_exit);
e9f2bd819   Nobuhiro Iwamatsu   RTC: add rtc-rs5c...
398
399
400
  MODULE_AUTHOR("kogiidena , Nobuhiro Iwamatsu <iwamatsu@nigauri.org>");
  MODULE_DESCRIPTION("Ricoh RS5C313 RTC device driver");
  MODULE_LICENSE("GPL");
ad28a07bc   Kay Sievers   rtc: fix platform...
401
  MODULE_ALIAS("platform:" DRV_NAME);