Changeset 917797f in mainline for uspace/drv/time/cmos-rtc/cmos-rtc.c


Ignore:
Timestamp:
2012-09-15T14:58:48Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
69a13a4
Parents:
0d911ee
Message:

Add support to the battery interface, not tested yet

File:
1 edited

Legend:

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

    r0d911ee r917797f  
    4646#include <ddf/log.h>
    4747#include <ops/clock_dev.h>
     48#include <ops/battery_dev.h>
    4849#include <fibril_synch.h>
    4950#include <device/hw_res.h>
    5051#include <macros.h>
    51 #include <ipc/clock_ctl.h>
    5252#include <time.h>
    5353
     
    9494static unsigned bcd2bin(unsigned bcd);
    9595static unsigned bin2bcd(unsigned binary);
    96 static void rtc_default_handler(ddf_fun_t *fun,
    97     ipc_callid_t callid, ipc_call_t *call);
    9896static int rtc_dev_remove(ddf_dev_t *dev);
    9997static void rtc_register_write(rtc_t *rtc, int reg, int data);
     
    120118};
    121119
     120/** Battery powered device interface */
     121static battery_dev_ops_t rtc_battery_dev_ops = {
     122        .battery_status_get = NULL,
     123        .battery_charge_level_get = NULL,
     124};
     125
    122126/** Obtain soft state structure from device node */
    123127static rtc_t *
     
    144148
    145149        rtc_dev_ops.interfaces[CLOCK_DEV_IFACE] = &rtc_clock_dev_ops;
    146         rtc_dev_ops.default_handler = &rtc_default_handler;
     150        rtc_dev_ops.interfaces[BATTERY_DEV_IFACE] = &rtc_battery_dev_ops;
     151        rtc_dev_ops.default_handler = NULL;
    147152}
    148153
     
    597602}
    598603
    599 /** Default handler for client requests not handled
    600  *  by the standard interface
    601  */
    602 static void
    603 rtc_default_handler(ddf_fun_t *fun, ipc_callid_t callid, ipc_call_t *call)
    604 {
    605         sysarg_t method = IPC_GET_IMETHOD(*call);
    606         rtc_t *rtc = fun_rtc(fun);
    607         bool batt_ok;
    608 
    609         switch (method) {
    610         case CLOCK_GET_BATTERY_STATUS:
    611                 /* Get the RTC battery status */
    612                 batt_ok = rtc_register_read(rtc, RTC_STATUS_D) &
    613                     RTC_D_BATTERY_OK;
    614                 async_answer_1(callid, EOK, batt_ok);
    615                 break;
    616         default:
    617                 async_answer_0(callid, ENOTSUP);
    618         }
    619 }
    620 
    621604/** Open the device
    622605 *
Note: See TracChangeset for help on using the changeset viewer.