Changeset 0883de8 in mainline
- Timestamp:
- 2012-04-01T19:32:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4b44de57
- Parents:
- 557b7b3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-rtc.c
r557b7b3 r0883de8 48 48 #define NAME "cmos-rtc" 49 49 50 #define REG_COUNT 2 51 50 52 typedef struct rtc { 51 53 /** DDF device node */ … … 57 59 /** The base I/O address of the device registers */ 58 60 uint32_t io_addr; 61 /** The I/O port used to access the CMOS registers */ 62 ioport8_t *port; 59 63 } rtc_t; 60 64 … … 71 75 static int 72 76 rtc_dev_initialize(rtc_t *rtc); 77 78 static bool 79 rtc_pio_enable(rtc_t *rtc); 73 80 74 81 … … 104 111 rtc_dev_ops.interfaces[CLOCK_DEV_IFACE] = &rtc_clock_dev_ops; 105 112 rtc_dev_ops.default_handler = NULL; /* XXX */ 113 } 114 115 /** Enable the I/O ports of the device 116 * 117 * @param rtc The real time clock device 118 * 119 * @return true in case of success, false otherwise 120 */ 121 static bool 122 rtc_pio_enable(rtc_t *rtc) 123 { 124 if (pio_enable((void *)(uintptr_t) rtc->io_addr, REG_COUNT, 125 (void **) &rtc->port)) { 126 127 ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32 128 " for device %s", rtc->io_addr, rtc->dev->name); 129 return false; 130 } 131 132 return true; 106 133 } 107 134 … … 203 230 { 204 231 rtc_t *rtc; 232 ddf_fun_t *fun; 205 233 int rc; 206 234 … … 219 247 return rc; 220 248 249 /* XXX Need cleanup */ 250 if (!rtc_pio_enable(rtc)) 251 return EADDRNOTAVAIL; 252 253 fun = ddf_fun_create(dev, fun_exposed, "a"); 254 if (!fun) { 255 ddf_msg(LVL_ERROR, "Failed creating function"); 256 return ENOENT; 257 } 258 259 fun->ops = &rtc_dev_ops; 260 rc = ddf_fun_bind(fun); 261 if (rc != EOK) { 262 ddf_msg(LVL_ERROR, "Failed binding function"); 263 return rc; 264 } 265 266 rtc->fun = fun; 267 268 ddf_fun_add_to_category(fun, "clock"); 269 270 ddf_msg(LVL_NOTE, "Device %s successfully initialized", 271 dev->name); 272 221 273 return rc; 222 274 }
Note:
See TracChangeset
for help on using the changeset viewer.