Changeset 917797f in mainline


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

Location:
uspace
Files:
3 added
5 edited
1 moved

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 *
  • uspace/lib/c/Makefile

    r0d911ee r917797f  
    7272        generic/device/char_dev.c \
    7373        generic/device/clock_dev.c \
     74        generic/device/battery_dev.c \
    7475        generic/device/graph_dev.c \
    7576        generic/device/nic.c \
  • uspace/lib/c/include/ipc/dev_iface.h

    r0d911ee r917797f  
    5656        /** Interface provided by Real Time Clock devices */
    5757        CLOCK_DEV_IFACE,
     58        /** Interface provided by battery powered devices */
     59        BATTERY_DEV_IFACE,
    5860        /** Interface provided by AHCI devices. */
    5961        AHCI_DEV_IFACE,
  • uspace/lib/drv/Makefile

    r0d911ee r917797f  
    4747        generic/remote_usbhid.c \
    4848        generic/remote_clock_dev.c \
     49        generic/remote_battery_dev.c \
    4950        generic/remote_ahci.c
    5051
  • uspace/lib/drv/generic/remote_clock_dev.c

    r0d911ee r917797f  
    104104}
    105105
    106 /** Process the write request from the remote client
     106/** Process the time_set() request from the remote client
    107107 *
    108108 * @param fun   The function to which the data are written
  • uspace/lib/drv/include/remote_battery_dev.h

    r0d911ee r917797f  
    2727 */
    2828
    29 #ifndef LIBC_IPC_CLOCK_CTL_H_
    30 #define LIBC_IPC_CLOCK_CTL_H_
     29/** @addtogroup libdrv
     30 * @{
     31 */
     32/** @file
     33 */
    3134
    32 #include <ipc/dev_iface.h>
     35#ifndef LIBDRV_REMOTE_BATTERY_DEV_H_
     36#define LIBDRV_REMOTE_BATTERY_DEV_H_
    3337
    34 typedef enum {
    35         CLOCK_GET_BATTERY_STATUS = DEV_FIRST_CUSTOM_METHOD,
    36 } clock_ctl_t;
     38extern remote_iface_t remote_battery_dev_iface;
    3739
    3840#endif
    3941
     42/**
     43 * @}
     44 */
     45
Note: See TracChangeset for help on using the changeset viewer.