minix/kernel/arch/earm/omap_padconf.c
Thomas Cort 4593804bf0 kernel: add padconf kernel call
On the AM335X, writes to the padconf registers must be done in privileged
mode. To allow userspace drivers to dynamically change the padconf at
runtime, a kernel call has been added.

Change-Id: I4b25d2879399b1785a360912faa0e90b5c258533
2013-08-28 12:53:05 -04:00

51 lines
1 KiB
C

/* Implements sys_padconf() for the AM335X and DM37XX. */
#include "kernel/kernel.h"
#include "arch_proto.h"
#include <sys/types.h>
#include <machine/cpu.h>
#include <minix/mmio.h>
#include <minix/padconf.h>
#include <assert.h>
#include <io.h>
#include <stdlib.h>
#include <stdio.h>
#include "omap_padconf.h"
struct omap_padconf
{
vir_bytes base;
vir_bytes offset;
vir_bytes size;
};
static struct omap_padconf omap_padconf = {
.base = PADCONF_REGISTERS_BASE,
.offset = PADCONF_REGISTERS_OFFSET,
.size = PADCONF_REGISTERS_SIZE
};
static kern_phys_map padconf_phys_map;
int
arch_padconf_set(u32_t padconf, u32_t mask, u32_t value)
{
/* check that the value will be inside the padconf memory range */
if (padconf >= (PADCONF_REGISTERS_SIZE - PADCONF_REGISTERS_OFFSET)) {
return EINVAL; /* outside of valid range */
}
set32(padconf + omap_padconf.base + omap_padconf.offset, mask, value);
return OK;
}
void
arch_padconf_init(void)
{
kern_phys_map_ptr(omap_padconf.base, omap_padconf.size,
&padconf_phys_map, &omap_padconf.base);
return;
}