exynos4210_rtc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * Samsung exynos4210 Real Time Clock
  3. *
  4. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  5. * Ogurtsov Oleg <o.ogurtsov@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. * for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. /* Description:
  22. * Register RTCCON:
  23. * CLKSEL Bit[1] not used
  24. * CLKOUTEN Bit[9] not used
  25. */
  26. #include "qemu/osdep.h"
  27. #include "qemu/log.h"
  28. #include "qemu/module.h"
  29. #include "hw/sysbus.h"
  30. #include "migration/vmstate.h"
  31. #include "qemu/timer.h"
  32. #include "qemu/bcd.h"
  33. #include "hw/ptimer.h"
  34. #include "hw/irq.h"
  35. #include "hw/arm/exynos4210.h"
  36. #include "qom/object.h"
  37. #include "system/rtc.h"
  38. #define DEBUG_RTC 0
  39. #if DEBUG_RTC
  40. #define DPRINTF(fmt, ...) \
  41. do { fprintf(stdout, "RTC: [%24s:%5d] " fmt, __func__, __LINE__, \
  42. ## __VA_ARGS__); } while (0)
  43. #else
  44. #define DPRINTF(fmt, ...) do {} while (0)
  45. #endif
  46. #define EXYNOS4210_RTC_REG_MEM_SIZE 0x0100
  47. #define INTP 0x0030
  48. #define RTCCON 0x0040
  49. #define TICCNT 0x0044
  50. #define RTCALM 0x0050
  51. #define ALMSEC 0x0054
  52. #define ALMMIN 0x0058
  53. #define ALMHOUR 0x005C
  54. #define ALMDAY 0x0060
  55. #define ALMMON 0x0064
  56. #define ALMYEAR 0x0068
  57. #define BCDSEC 0x0070
  58. #define BCDMIN 0x0074
  59. #define BCDHOUR 0x0078
  60. #define BCDDAY 0x007C
  61. #define BCDDAYWEEK 0x0080
  62. #define BCDMON 0x0084
  63. #define BCDYEAR 0x0088
  64. #define CURTICNT 0x0090
  65. #define TICK_TIMER_ENABLE 0x0100
  66. #define TICNT_THRESHOLD 2
  67. #define RTC_ENABLE 0x0001
  68. #define INTP_TICK_ENABLE 0x0001
  69. #define INTP_ALM_ENABLE 0x0002
  70. #define ALARM_INT_ENABLE 0x0040
  71. #define RTC_BASE_FREQ 32768
  72. #define TYPE_EXYNOS4210_RTC "exynos4210.rtc"
  73. OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210RTCState, EXYNOS4210_RTC)
  74. struct Exynos4210RTCState {
  75. SysBusDevice parent_obj;
  76. MemoryRegion iomem;
  77. /* registers */
  78. uint32_t reg_intp;
  79. uint32_t reg_rtccon;
  80. uint32_t reg_ticcnt;
  81. uint32_t reg_rtcalm;
  82. uint32_t reg_almsec;
  83. uint32_t reg_almmin;
  84. uint32_t reg_almhour;
  85. uint32_t reg_almday;
  86. uint32_t reg_almmon;
  87. uint32_t reg_almyear;
  88. uint32_t reg_curticcnt;
  89. ptimer_state *ptimer; /* tick timer */
  90. ptimer_state *ptimer_1Hz; /* clock timer */
  91. uint32_t freq;
  92. qemu_irq tick_irq; /* Time Tick Generator irq */
  93. qemu_irq alm_irq; /* alarm irq */
  94. struct tm current_tm; /* current time */
  95. };
  96. #define TICCKSEL(value) ((value & (0x0F << 4)) >> 4)
  97. /*** VMState ***/
  98. static const VMStateDescription vmstate_exynos4210_rtc_state = {
  99. .name = "exynos4210.rtc",
  100. .version_id = 1,
  101. .minimum_version_id = 1,
  102. .fields = (const VMStateField[]) {
  103. VMSTATE_UINT32(reg_intp, Exynos4210RTCState),
  104. VMSTATE_UINT32(reg_rtccon, Exynos4210RTCState),
  105. VMSTATE_UINT32(reg_ticcnt, Exynos4210RTCState),
  106. VMSTATE_UINT32(reg_rtcalm, Exynos4210RTCState),
  107. VMSTATE_UINT32(reg_almsec, Exynos4210RTCState),
  108. VMSTATE_UINT32(reg_almmin, Exynos4210RTCState),
  109. VMSTATE_UINT32(reg_almhour, Exynos4210RTCState),
  110. VMSTATE_UINT32(reg_almday, Exynos4210RTCState),
  111. VMSTATE_UINT32(reg_almmon, Exynos4210RTCState),
  112. VMSTATE_UINT32(reg_almyear, Exynos4210RTCState),
  113. VMSTATE_UINT32(reg_curticcnt, Exynos4210RTCState),
  114. VMSTATE_PTIMER(ptimer, Exynos4210RTCState),
  115. VMSTATE_PTIMER(ptimer_1Hz, Exynos4210RTCState),
  116. VMSTATE_UINT32(freq, Exynos4210RTCState),
  117. VMSTATE_INT32(current_tm.tm_sec, Exynos4210RTCState),
  118. VMSTATE_INT32(current_tm.tm_min, Exynos4210RTCState),
  119. VMSTATE_INT32(current_tm.tm_hour, Exynos4210RTCState),
  120. VMSTATE_INT32(current_tm.tm_wday, Exynos4210RTCState),
  121. VMSTATE_INT32(current_tm.tm_mday, Exynos4210RTCState),
  122. VMSTATE_INT32(current_tm.tm_mon, Exynos4210RTCState),
  123. VMSTATE_INT32(current_tm.tm_year, Exynos4210RTCState),
  124. VMSTATE_END_OF_LIST()
  125. }
  126. };
  127. #define BCD3DIGITS(x) \
  128. ((uint32_t)to_bcd((uint8_t)(x % 100)) + \
  129. ((uint32_t)to_bcd((uint8_t)((x % 1000) / 100)) << 8))
  130. static void check_alarm_raise(Exynos4210RTCState *s)
  131. {
  132. unsigned int alarm_raise = 0;
  133. struct tm stm = s->current_tm;
  134. if ((s->reg_rtcalm & 0x01) &&
  135. (to_bcd((uint8_t)stm.tm_sec) == (uint8_t)s->reg_almsec)) {
  136. alarm_raise = 1;
  137. }
  138. if ((s->reg_rtcalm & 0x02) &&
  139. (to_bcd((uint8_t)stm.tm_min) == (uint8_t)s->reg_almmin)) {
  140. alarm_raise = 1;
  141. }
  142. if ((s->reg_rtcalm & 0x04) &&
  143. (to_bcd((uint8_t)stm.tm_hour) == (uint8_t)s->reg_almhour)) {
  144. alarm_raise = 1;
  145. }
  146. if ((s->reg_rtcalm & 0x08) &&
  147. (to_bcd((uint8_t)stm.tm_mday) == (uint8_t)s->reg_almday)) {
  148. alarm_raise = 1;
  149. }
  150. if ((s->reg_rtcalm & 0x10) &&
  151. (to_bcd((uint8_t)stm.tm_mon) == (uint8_t)s->reg_almmon)) {
  152. alarm_raise = 1;
  153. }
  154. if ((s->reg_rtcalm & 0x20) &&
  155. (BCD3DIGITS(stm.tm_year) == s->reg_almyear)) {
  156. alarm_raise = 1;
  157. }
  158. if (alarm_raise) {
  159. DPRINTF("ALARM IRQ\n");
  160. /* set irq status */
  161. s->reg_intp |= INTP_ALM_ENABLE;
  162. qemu_irq_raise(s->alm_irq);
  163. }
  164. }
  165. /*
  166. * RTC update frequency
  167. * Parameters:
  168. * reg_value - current RTCCON register or his new value
  169. * Must be called within a ptimer_transaction_begin/commit block for s->ptimer.
  170. */
  171. static void exynos4210_rtc_update_freq(Exynos4210RTCState *s,
  172. uint32_t reg_value)
  173. {
  174. uint32_t freq;
  175. freq = s->freq;
  176. /* set frequency for time generator */
  177. s->freq = RTC_BASE_FREQ / (1 << TICCKSEL(reg_value));
  178. if (freq != s->freq) {
  179. ptimer_set_freq(s->ptimer, s->freq);
  180. DPRINTF("freq=%dHz\n", s->freq);
  181. }
  182. }
  183. /* month is between 0 and 11. */
  184. static int get_days_in_month(int month, int year)
  185. {
  186. static const int days_tab[12] = {
  187. 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  188. };
  189. int d;
  190. if ((unsigned)month >= 12) {
  191. return 31;
  192. }
  193. d = days_tab[month];
  194. if (month == 1) {
  195. if ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
  196. d++;
  197. }
  198. }
  199. return d;
  200. }
  201. /* update 'tm' to the next second */
  202. static void rtc_next_second(struct tm *tm)
  203. {
  204. int days_in_month;
  205. tm->tm_sec++;
  206. if ((unsigned)tm->tm_sec >= 60) {
  207. tm->tm_sec = 0;
  208. tm->tm_min++;
  209. if ((unsigned)tm->tm_min >= 60) {
  210. tm->tm_min = 0;
  211. tm->tm_hour++;
  212. if ((unsigned)tm->tm_hour >= 24) {
  213. tm->tm_hour = 0;
  214. /* next day */
  215. tm->tm_wday++;
  216. if ((unsigned)tm->tm_wday >= 7) {
  217. tm->tm_wday = 0;
  218. }
  219. days_in_month = get_days_in_month(tm->tm_mon,
  220. tm->tm_year + 1900);
  221. tm->tm_mday++;
  222. if (tm->tm_mday < 1) {
  223. tm->tm_mday = 1;
  224. } else if (tm->tm_mday > days_in_month) {
  225. tm->tm_mday = 1;
  226. tm->tm_mon++;
  227. if (tm->tm_mon >= 12) {
  228. tm->tm_mon = 0;
  229. tm->tm_year++;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. /*
  237. * tick handler
  238. */
  239. static void exynos4210_rtc_tick(void *opaque)
  240. {
  241. Exynos4210RTCState *s = (Exynos4210RTCState *)opaque;
  242. DPRINTF("TICK IRQ\n");
  243. /* set irq status */
  244. s->reg_intp |= INTP_TICK_ENABLE;
  245. /* raise IRQ */
  246. qemu_irq_raise(s->tick_irq);
  247. /* restart timer */
  248. ptimer_set_count(s->ptimer, s->reg_ticcnt);
  249. ptimer_run(s->ptimer, 1);
  250. }
  251. /*
  252. * 1Hz clock handler
  253. */
  254. static void exynos4210_rtc_1Hz_tick(void *opaque)
  255. {
  256. Exynos4210RTCState *s = (Exynos4210RTCState *)opaque;
  257. rtc_next_second(&s->current_tm);
  258. /* DPRINTF("1Hz tick\n"); */
  259. /* raise IRQ */
  260. if (s->reg_rtcalm & ALARM_INT_ENABLE) {
  261. check_alarm_raise(s);
  262. }
  263. ptimer_set_count(s->ptimer_1Hz, RTC_BASE_FREQ);
  264. ptimer_run(s->ptimer_1Hz, 1);
  265. }
  266. /*
  267. * RTC Read
  268. */
  269. static uint64_t exynos4210_rtc_read(void *opaque, hwaddr offset,
  270. unsigned size)
  271. {
  272. uint32_t value = 0;
  273. Exynos4210RTCState *s = (Exynos4210RTCState *)opaque;
  274. switch (offset) {
  275. case INTP:
  276. value = s->reg_intp;
  277. break;
  278. case RTCCON:
  279. value = s->reg_rtccon;
  280. break;
  281. case TICCNT:
  282. value = s->reg_ticcnt;
  283. break;
  284. case RTCALM:
  285. value = s->reg_rtcalm;
  286. break;
  287. case ALMSEC:
  288. value = s->reg_almsec;
  289. break;
  290. case ALMMIN:
  291. value = s->reg_almmin;
  292. break;
  293. case ALMHOUR:
  294. value = s->reg_almhour;
  295. break;
  296. case ALMDAY:
  297. value = s->reg_almday;
  298. break;
  299. case ALMMON:
  300. value = s->reg_almmon;
  301. break;
  302. case ALMYEAR:
  303. value = s->reg_almyear;
  304. break;
  305. case BCDSEC:
  306. value = (uint32_t)to_bcd((uint8_t)s->current_tm.tm_sec);
  307. break;
  308. case BCDMIN:
  309. value = (uint32_t)to_bcd((uint8_t)s->current_tm.tm_min);
  310. break;
  311. case BCDHOUR:
  312. value = (uint32_t)to_bcd((uint8_t)s->current_tm.tm_hour);
  313. break;
  314. case BCDDAYWEEK:
  315. value = (uint32_t)to_bcd((uint8_t)s->current_tm.tm_wday);
  316. break;
  317. case BCDDAY:
  318. value = (uint32_t)to_bcd((uint8_t)s->current_tm.tm_mday);
  319. break;
  320. case BCDMON:
  321. value = (uint32_t)to_bcd((uint8_t)s->current_tm.tm_mon + 1);
  322. break;
  323. case BCDYEAR:
  324. value = BCD3DIGITS(s->current_tm.tm_year);
  325. break;
  326. case CURTICNT:
  327. s->reg_curticcnt = ptimer_get_count(s->ptimer);
  328. value = s->reg_curticcnt;
  329. break;
  330. default:
  331. qemu_log_mask(LOG_GUEST_ERROR,
  332. "exynos4210.rtc: bad read offset " HWADDR_FMT_plx,
  333. offset);
  334. break;
  335. }
  336. return value;
  337. }
  338. /*
  339. * RTC Write
  340. */
  341. static void exynos4210_rtc_write(void *opaque, hwaddr offset,
  342. uint64_t value, unsigned size)
  343. {
  344. Exynos4210RTCState *s = (Exynos4210RTCState *)opaque;
  345. switch (offset) {
  346. case INTP:
  347. if (value & INTP_ALM_ENABLE) {
  348. qemu_irq_lower(s->alm_irq);
  349. s->reg_intp &= (~INTP_ALM_ENABLE);
  350. }
  351. if (value & INTP_TICK_ENABLE) {
  352. qemu_irq_lower(s->tick_irq);
  353. s->reg_intp &= (~INTP_TICK_ENABLE);
  354. }
  355. break;
  356. case RTCCON:
  357. ptimer_transaction_begin(s->ptimer_1Hz);
  358. ptimer_transaction_begin(s->ptimer);
  359. if (value & RTC_ENABLE) {
  360. exynos4210_rtc_update_freq(s, value);
  361. }
  362. if ((value & RTC_ENABLE) > (s->reg_rtccon & RTC_ENABLE)) {
  363. /* clock timer */
  364. ptimer_set_count(s->ptimer_1Hz, RTC_BASE_FREQ);
  365. ptimer_run(s->ptimer_1Hz, 1);
  366. DPRINTF("run clock timer\n");
  367. }
  368. if ((value & RTC_ENABLE) < (s->reg_rtccon & RTC_ENABLE)) {
  369. /* tick timer */
  370. ptimer_stop(s->ptimer);
  371. /* clock timer */
  372. ptimer_stop(s->ptimer_1Hz);
  373. DPRINTF("stop all timers\n");
  374. }
  375. if (value & RTC_ENABLE) {
  376. if ((value & TICK_TIMER_ENABLE) >
  377. (s->reg_rtccon & TICK_TIMER_ENABLE) &&
  378. (s->reg_ticcnt)) {
  379. ptimer_set_count(s->ptimer, s->reg_ticcnt);
  380. ptimer_run(s->ptimer, 1);
  381. DPRINTF("run tick timer\n");
  382. }
  383. if ((value & TICK_TIMER_ENABLE) <
  384. (s->reg_rtccon & TICK_TIMER_ENABLE)) {
  385. ptimer_stop(s->ptimer);
  386. }
  387. }
  388. ptimer_transaction_commit(s->ptimer_1Hz);
  389. ptimer_transaction_commit(s->ptimer);
  390. s->reg_rtccon = value;
  391. break;
  392. case TICCNT:
  393. if (value > TICNT_THRESHOLD) {
  394. s->reg_ticcnt = value;
  395. } else {
  396. qemu_log_mask(LOG_GUEST_ERROR,
  397. "exynos4210.rtc: bad TICNT value %u",
  398. (uint32_t)value);
  399. }
  400. break;
  401. case RTCALM:
  402. s->reg_rtcalm = value;
  403. break;
  404. case ALMSEC:
  405. s->reg_almsec = (value & 0x7f);
  406. break;
  407. case ALMMIN:
  408. s->reg_almmin = (value & 0x7f);
  409. break;
  410. case ALMHOUR:
  411. s->reg_almhour = (value & 0x3f);
  412. break;
  413. case ALMDAY:
  414. s->reg_almday = (value & 0x3f);
  415. break;
  416. case ALMMON:
  417. s->reg_almmon = (value & 0x1f);
  418. break;
  419. case ALMYEAR:
  420. s->reg_almyear = (value & 0x0fff);
  421. break;
  422. case BCDSEC:
  423. if (s->reg_rtccon & RTC_ENABLE) {
  424. s->current_tm.tm_sec = (int)from_bcd((uint8_t)value);
  425. }
  426. break;
  427. case BCDMIN:
  428. if (s->reg_rtccon & RTC_ENABLE) {
  429. s->current_tm.tm_min = (int)from_bcd((uint8_t)value);
  430. }
  431. break;
  432. case BCDHOUR:
  433. if (s->reg_rtccon & RTC_ENABLE) {
  434. s->current_tm.tm_hour = (int)from_bcd((uint8_t)value);
  435. }
  436. break;
  437. case BCDDAYWEEK:
  438. if (s->reg_rtccon & RTC_ENABLE) {
  439. s->current_tm.tm_wday = (int)from_bcd((uint8_t)value);
  440. }
  441. break;
  442. case BCDDAY:
  443. if (s->reg_rtccon & RTC_ENABLE) {
  444. s->current_tm.tm_mday = (int)from_bcd((uint8_t)value);
  445. }
  446. break;
  447. case BCDMON:
  448. if (s->reg_rtccon & RTC_ENABLE) {
  449. s->current_tm.tm_mon = (int)from_bcd((uint8_t)value) - 1;
  450. }
  451. break;
  452. case BCDYEAR:
  453. if (s->reg_rtccon & RTC_ENABLE) {
  454. /* 3 digits */
  455. s->current_tm.tm_year = (int)from_bcd((uint8_t)value) +
  456. (int)from_bcd((uint8_t)((value >> 8) & 0x0f)) * 100;
  457. }
  458. break;
  459. default:
  460. qemu_log_mask(LOG_GUEST_ERROR,
  461. "exynos4210.rtc: bad write offset " HWADDR_FMT_plx,
  462. offset);
  463. break;
  464. }
  465. }
  466. /*
  467. * Set default values to timer fields and registers
  468. */
  469. static void exynos4210_rtc_reset(DeviceState *d)
  470. {
  471. Exynos4210RTCState *s = EXYNOS4210_RTC(d);
  472. qemu_get_timedate(&s->current_tm, 0);
  473. DPRINTF("Get time from host: %d-%d-%d %2d:%02d:%02d\n",
  474. s->current_tm.tm_year, s->current_tm.tm_mon, s->current_tm.tm_mday,
  475. s->current_tm.tm_hour, s->current_tm.tm_min, s->current_tm.tm_sec);
  476. s->reg_intp = 0;
  477. s->reg_rtccon = 0;
  478. s->reg_ticcnt = 0;
  479. s->reg_rtcalm = 0;
  480. s->reg_almsec = 0;
  481. s->reg_almmin = 0;
  482. s->reg_almhour = 0;
  483. s->reg_almday = 0;
  484. s->reg_almmon = 0;
  485. s->reg_almyear = 0;
  486. s->reg_curticcnt = 0;
  487. ptimer_transaction_begin(s->ptimer);
  488. exynos4210_rtc_update_freq(s, s->reg_rtccon);
  489. ptimer_stop(s->ptimer);
  490. ptimer_transaction_commit(s->ptimer);
  491. ptimer_transaction_begin(s->ptimer_1Hz);
  492. ptimer_stop(s->ptimer_1Hz);
  493. ptimer_transaction_commit(s->ptimer_1Hz);
  494. }
  495. static const MemoryRegionOps exynos4210_rtc_ops = {
  496. .read = exynos4210_rtc_read,
  497. .write = exynos4210_rtc_write,
  498. .endianness = DEVICE_NATIVE_ENDIAN,
  499. };
  500. /*
  501. * RTC timer initialization
  502. */
  503. static void exynos4210_rtc_init(Object *obj)
  504. {
  505. Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
  506. SysBusDevice *dev = SYS_BUS_DEVICE(obj);
  507. s->ptimer = ptimer_init(exynos4210_rtc_tick, s, PTIMER_POLICY_LEGACY);
  508. ptimer_transaction_begin(s->ptimer);
  509. ptimer_set_freq(s->ptimer, RTC_BASE_FREQ);
  510. exynos4210_rtc_update_freq(s, 0);
  511. ptimer_transaction_commit(s->ptimer);
  512. s->ptimer_1Hz = ptimer_init(exynos4210_rtc_1Hz_tick,
  513. s, PTIMER_POLICY_LEGACY);
  514. ptimer_transaction_begin(s->ptimer_1Hz);
  515. ptimer_set_freq(s->ptimer_1Hz, RTC_BASE_FREQ);
  516. ptimer_transaction_commit(s->ptimer_1Hz);
  517. sysbus_init_irq(dev, &s->alm_irq);
  518. sysbus_init_irq(dev, &s->tick_irq);
  519. memory_region_init_io(&s->iomem, obj, &exynos4210_rtc_ops, s,
  520. "exynos4210-rtc", EXYNOS4210_RTC_REG_MEM_SIZE);
  521. sysbus_init_mmio(dev, &s->iomem);
  522. }
  523. static void exynos4210_rtc_finalize(Object *obj)
  524. {
  525. Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
  526. ptimer_free(s->ptimer);
  527. ptimer_free(s->ptimer_1Hz);
  528. }
  529. static void exynos4210_rtc_class_init(ObjectClass *klass, void *data)
  530. {
  531. DeviceClass *dc = DEVICE_CLASS(klass);
  532. device_class_set_legacy_reset(dc, exynos4210_rtc_reset);
  533. dc->vmsd = &vmstate_exynos4210_rtc_state;
  534. }
  535. static const TypeInfo exynos4210_rtc_info = {
  536. .name = TYPE_EXYNOS4210_RTC,
  537. .parent = TYPE_SYS_BUS_DEVICE,
  538. .instance_size = sizeof(Exynos4210RTCState),
  539. .instance_init = exynos4210_rtc_init,
  540. .instance_finalize = exynos4210_rtc_finalize,
  541. .class_init = exynos4210_rtc_class_init,
  542. };
  543. static void exynos4210_rtc_register_types(void)
  544. {
  545. type_register_static(&exynos4210_rtc_info);
  546. }
  547. type_init(exynos4210_rtc_register_types)