2 #include <minix/syslib.h>
3 #include <minix/drvlib.h>
5 #include <minix/mmio.h>
22 /* used for logging */
23 static struct log log
= {
24 .name
= "omap_clkconf",
25 .log_level
= LEVEL_INFO
,
26 .log_func
= default_log
29 #define CM_BASE 0x48004000
30 static u32_t base
= 0;
31 static u32_t use_count
= 0;
39 /* when used in a library we can't guaranty we only call this
41 log_trace(&log
, "Called %d times\n", use_count
);
44 struct minix_mem_range mr
;
46 mr
.mr_limit
= CM_BASE
+ 0x1000;
48 if (sys_privctl(SELF
, SYS_PRIV_ADD_MEM
, &mr
) != 0) {
49 log_warn(&log
, "Unable to request permission to map memory\n");
53 base
= (uint32_t) vm_map_phys(SELF
, (void *) CM_BASE
, 0x1000);
55 if (base
== (uint32_t) MAP_FAILED
) {
56 log_warn(&log
, "Unable to map GPIO memory\n");
63 clkconf_set(u32_t clk
, u32_t mask
, u32_t value
)
65 set32(base
+ clk
, mask
, value
);
72 assert(use_count
> 0);
75 vm_unmap_phys(SELF
, (void *) base
, 0x1000);