Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0883de8 in mainline


Ignore:
Timestamp:
2012-04-01T19:32:06Z (8 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
master
Children:
4b44de57
Parents:
557b7b3
Message:

RTC: add the driver to the "clock" category; add a function to enable the I/O ports used by the driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    r557b7b3 r0883de8  
    4848#define NAME "cmos-rtc"
    4949
     50#define REG_COUNT 2
     51
    5052typedef struct rtc {
    5153        /** DDF device node */
     
    5759        /** The base I/O address of the device registers */
    5860        uint32_t io_addr;
     61        /** The I/O port used to access the CMOS registers */
     62        ioport8_t *port;
    5963} rtc_t;
    6064
     
    7175static int
    7276rtc_dev_initialize(rtc_t *rtc);
     77
     78static bool
     79rtc_pio_enable(rtc_t *rtc);
    7380
    7481
     
    104111        rtc_dev_ops.interfaces[CLOCK_DEV_IFACE] = &rtc_clock_dev_ops;
    105112        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 */
     121static bool
     122rtc_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;
    106133}
    107134
     
    203230{
    204231        rtc_t *rtc;
     232        ddf_fun_t *fun;
    205233        int rc;
    206234
     
    219247                return rc;
    220248
     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
    221273        return rc;
    222274}
Note: See TracChangeset for help on using the changeset viewer.