Changeset 5828554 in mainline for kernel/genarch/src/drivers/grlib/irqmp.c
- Timestamp:
- 2014-01-19T14:37:22Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cf982ff
- Parents:
- 2f591127 (diff), 476f62c (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/grlib/irqmp.c
r2f591127 r5828554 1 1 /* 2 * Copyright (c) 201 2 Maurizio Lombardi2 * Copyright (c) 2013 Jakub Klama 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ 32 /** @file 32 /** 33 * @file 34 * @brief Gaisler GRLIB interrupt controller. 33 35 */ 34 36 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> 40 40 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) 41 void grlib_irqmp_init(grlib_irqmp_t *irqc, bootinfo_t *bootinfo) 50 42 { 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); 64 51 } 65 52 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) 53 int grlib_irqmp_inum_get(grlib_irqmp_t *irqc) 75 54 { 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 } 77 64 78 async_exch_t *exch = async_exchange_begin(sess); 65 void grlib_irqmp_clear(grlib_irqmp_t *irqc, unsigned int inum) 66 { 67 pio_write_32(&irqc->regs->clear, (1 << inum)); 68 } 79 69 80 int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE), 81 BATTERY_CHARGE_LEVEL_GET, &charge_level); 70 void 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 } 82 78 83 async_exchange_end(exch); 84 85 if (rc == EOK) 86 *level = (int) charge_level; 87 88 return rc; 79 void 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); 89 86 } 90 87 91 88 /** @} 92 89 */ 93
Note:
See TracChangeset
for help on using the changeset viewer.