2013-08-28 06:43:45 +02:00
|
|
|
/* Implements sys_padconf() for the AM335X and DM37XX. */
|
2013-07-15 16:28:58 +02:00
|
|
|
|
|
|
|
#include "kernel/kernel.h"
|
2013-08-28 06:43:45 +02:00
|
|
|
#include "arch_proto.h"
|
2013-07-15 16:28:58 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <minix/mmio.h>
|
2013-08-28 06:43:45 +02:00
|
|
|
#include <minix/padconf.h>
|
2013-12-13 14:12:50 +01:00
|
|
|
#include <minix/board.h>
|
2013-07-15 16:28:58 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <io.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2014-02-07 08:46:29 +01:00
|
|
|
#include "bsp_padconf.h"
|
2013-07-15 16:28:58 +02:00
|
|
|
|
2013-08-28 06:43:45 +02:00
|
|
|
struct omap_padconf
|
|
|
|
{
|
|
|
|
vir_bytes base;
|
|
|
|
vir_bytes offset;
|
|
|
|
vir_bytes size;
|
2013-12-13 14:12:50 +01:00
|
|
|
unsigned int board_filter_value;
|
|
|
|
unsigned int board_filter_mask;
|
2013-08-28 06:43:45 +02:00
|
|
|
};
|
|
|
|
|
2013-12-17 16:20:37 +01:00
|
|
|
static struct omap_padconf omap_padconfs[] = {
|
2014-02-24 09:40:30 +01:00
|
|
|
{
|
|
|
|
.base = PADCONF_DM37XX_REGISTERS_BASE,
|
|
|
|
.offset = PADCONF_DM37XX_REGISTERS_OFFSET,
|
|
|
|
.size = PADCONF_DM37XX_REGISTERS_SIZE,
|
|
|
|
.board_filter_value = BOARD_FILTER_BBXM_VALUE,
|
|
|
|
.board_filter_mask = BOARD_FILTER_BBXM_MASK,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.base = PADCONF_AM335X_REGISTERS_BASE,
|
|
|
|
.offset = PADCONF_AM335X_REGISTERS_OFFSET,
|
|
|
|
.size = PADCONF_AM335X_REGISTERS_SIZE,
|
|
|
|
.board_filter_value = BOARD_FILTER_BB_VALUE,
|
|
|
|
.board_filter_mask = BOARD_FILTER_BB_MASK,
|
|
|
|
},
|
2013-08-28 06:43:45 +02:00
|
|
|
};
|
2013-07-15 16:28:58 +02:00
|
|
|
|
2013-12-13 14:12:50 +01:00
|
|
|
/* initialized in init */
|
|
|
|
static struct omap_padconf *omap_padconf;
|
|
|
|
|
2013-08-28 06:43:45 +02:00
|
|
|
static kern_phys_map padconf_phys_map;
|
2013-07-15 16:28:58 +02:00
|
|
|
|
2013-08-28 06:43:45 +02:00
|
|
|
int
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value)
|
2013-07-15 16:28:58 +02:00
|
|
|
{
|
2013-08-28 06:43:45 +02:00
|
|
|
/* check that the value will be inside the padconf memory range */
|
2013-12-13 14:12:50 +01:00
|
|
|
if (padconf >= (omap_padconf->size - omap_padconf->offset)) {
|
2013-08-28 06:43:45 +02:00
|
|
|
return EINVAL; /* outside of valid range */
|
|
|
|
}
|
|
|
|
|
2014-02-24 09:40:30 +01:00
|
|
|
set32(padconf + omap_padconf->base + omap_padconf->offset, mask,
|
|
|
|
value);
|
2013-08-28 06:43:45 +02:00
|
|
|
|
2013-07-15 16:28:58 +02:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_padconf_init(void)
|
2013-07-15 16:28:58 +02:00
|
|
|
{
|
2013-12-13 14:12:50 +01:00
|
|
|
int x;
|
|
|
|
omap_padconf = NULL;
|
|
|
|
/* find the correct padconf */
|
2014-02-24 09:40:30 +01:00
|
|
|
for (x = 0; x < sizeof(omap_padconfs) / sizeof(omap_padconfs[0]); x++) {
|
|
|
|
if ((omap_padconfs[x].board_filter_mask & machine.board_id) ==
|
|
|
|
omap_padconfs[x].board_filter_value) {
|
2013-12-13 14:12:50 +01:00
|
|
|
omap_padconf = &omap_padconfs[x];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(omap_padconf);
|
2014-02-24 09:40:30 +01:00
|
|
|
|
2013-12-13 14:12:50 +01:00
|
|
|
kern_phys_map_ptr(omap_padconf->base, omap_padconf->size,
|
2014-02-24 09:40:30 +01:00
|
|
|
&padconf_phys_map, (vir_bytes) & omap_padconf->base);
|
2013-07-15 16:28:58 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|