Ignore:
Timestamp:
2014-03-15T19:21:53Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c773adc
Parents:
2034f98 (diff), 8cffdf5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/grlib/irqmp.c

    r2034f98 rb0b4592e  
    11/*
    2  * Copyright (c) 2012 Maurizio Lombardi
     2 * Copyright (c) 2013 Jakub Klama
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29  /** @addtogroup libc
     29/** @addtogroup genarch
    3030 * @{
    3131 */
    32 /** @file
     32/**
     33 * @file
     34 * @brief Gaisler GRLIB interrupt controller.
    3335 */
    3436
    35 #include <ipc/dev_iface.h>
    36 #include <device/battery_dev.h>
    37 #include <errno.h>
    38 #include <async.h>
    39 #include <time.h>
     37#include <genarch/drivers/grlib/irqmp.h>
     38#include <arch/asm.h>
     39#include <mm/km.h>
    4040
    41 /** Read the current battery status from the device
    42  *
    43  * @param sess     Session of the device
    44  * @param status   Current status of the battery
    45  *
    46  * @return         EOK on success or a negative error code
    47  */
    48 int
    49 battery_status_get(async_sess_t *sess, battery_status_t *batt_status)
     41void grlib_irqmp_init(grlib_irqmp_t *irqc, bootinfo_t *bootinfo)
    5042{
    51         sysarg_t status;
    52 
    53         async_exch_t *exch = async_exchange_begin(sess);
    54 
    55         int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
    56             BATTERY_STATUS_GET, &status);
    57 
    58         async_exchange_end(exch);
    59 
    60         if (rc == EOK)
    61                 *batt_status = (battery_status_t) status;
    62 
    63         return rc;
     43        irqc->regs = (void *) km_map(bootinfo->intc_base, PAGE_SIZE,
     44            PAGE_NOT_CACHEABLE);
     45       
     46        /* Clear all pending interrupts */
     47        pio_write_32(&irqc->regs->clear, 0xffffffff);
     48       
     49        /* Mask all interrupts */
     50        pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, 0);
    6451}
    6552
    66 /** Read the current battery charge level from the device
    67  *
    68  * @param sess     Session of the device
    69  * @param level    Battery charge level (0 - 100)
    70  *
    71  * @return         EOK on success or a negative error code
    72  */
    73 int
    74 battery_charge_level_get(async_sess_t *sess, int *level)
     53int grlib_irqmp_inum_get(grlib_irqmp_t *irqc)
    7554{
    76         sysarg_t charge_level;
     55        uint32_t pending = pio_read_32(&irqc->regs->pending);
     56       
     57        for (unsigned int i = 1; i < 16; i++) {
     58                if (pending & (1 << i))
     59                        return i;
     60        }
     61       
     62        return -1;
     63}
    7764
    78         async_exch_t *exch = async_exchange_begin(sess);
     65void grlib_irqmp_clear(grlib_irqmp_t *irqc, unsigned int inum)
     66{
     67        pio_write_32(&irqc->regs->clear, (1 << inum));
     68}
    7969
    80         int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
    81             BATTERY_CHARGE_LEVEL_GET, &charge_level);
     70void grlib_irqmp_mask(grlib_irqmp_t *irqc, unsigned int src)
     71{
     72        uint32_t mask = pio_read_32((void *) irqc->regs +
     73            GRLIB_IRQMP_MASK_OFFSET);
     74       
     75        mask &= ~(1 << src);
     76        pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, mask);
     77}
    8278
    83         async_exchange_end(exch);
    84 
    85         if (rc == EOK)
    86                 *level = (int) charge_level;
    87 
    88         return rc;
     79void grlib_irqmp_unmask(grlib_irqmp_t *irqc, unsigned int src)
     80{
     81        uint32_t mask = pio_read_32((void *) irqc->regs +
     82            GRLIB_IRQMP_MASK_OFFSET);
     83       
     84        mask |= (1 << src);
     85        pio_write_32((void *) irqc->regs + GRLIB_IRQMP_MASK_OFFSET, mask);
    8986}
    9087
    9188/** @}
    9289 */
    93 
Note: See TracChangeset for help on using the changeset viewer.