tools/llvm: Do not build with symbols
[minix3.git] / minix / kernel / arch / earm / bsp / ti / omap_padconf.c
blob318769beae28329d41aaae3d818012967a6a918a
1 /* Implements sys_padconf() for the AM335X and DM37XX. */
3 #include "kernel/kernel.h"
4 #include "arch_proto.h"
5 #include <sys/types.h>
6 #include <machine/cpu.h>
7 #include <minix/mmio.h>
8 #include <minix/padconf.h>
9 #include <minix/board.h>
10 #include <minix/com.h>
11 #include <assert.h>
12 #include <io.h>
13 #include <stdlib.h>
14 #include <stdio.h>
16 #include "bsp_padconf.h"
18 struct omap_padconf
20 vir_bytes base;
21 vir_bytes offset;
22 vir_bytes size;
23 unsigned int board_filter_value;
24 unsigned int board_filter_mask;
27 static struct omap_padconf omap_padconfs[] = {
29 .base = PADCONF_DM37XX_REGISTERS_BASE,
30 .offset = PADCONF_DM37XX_REGISTERS_OFFSET,
31 .size = PADCONF_DM37XX_REGISTERS_SIZE,
32 .board_filter_value = BOARD_FILTER_BBXM_VALUE,
33 .board_filter_mask = BOARD_FILTER_BBXM_MASK,
36 .base = PADCONF_AM335X_REGISTERS_BASE,
37 .offset = PADCONF_AM335X_REGISTERS_OFFSET,
38 .size = PADCONF_AM335X_REGISTERS_SIZE,
39 .board_filter_value = BOARD_FILTER_BB_VALUE,
40 .board_filter_mask = BOARD_FILTER_BB_MASK,
44 /* initialized in init */
45 static struct omap_padconf *omap_padconf;
47 static kern_phys_map padconf_phys_map;
49 int
50 bsp_padconf_set(u32_t padconf, u32_t mask, u32_t value)
52 /* check that the value will be inside the padconf memory range */
53 if (padconf >= (omap_padconf->size - omap_padconf->offset)) {
54 return EINVAL; /* outside of valid range */
57 set32(padconf + omap_padconf->base + omap_padconf->offset, mask,
58 value);
60 return OK;
63 void
64 bsp_padconf_init(void)
66 int x;
67 omap_padconf = NULL;
68 /* find the correct padconf */
69 for (x = 0; x < sizeof(omap_padconfs) / sizeof(omap_padconfs[0]); x++) {
70 if ((omap_padconfs[x].board_filter_mask & machine.board_id) ==
71 omap_padconfs[x].board_filter_value) {
72 omap_padconf = &omap_padconfs[x];
73 break;
76 assert(omap_padconf);
78 kern_phys_map_ptr(omap_padconf->base, omap_padconf->size,
79 VMMF_UNCACHED | VMMF_WRITE,
80 &padconf_phys_map, (vir_bytes) & omap_padconf->base);
82 return;