#include <minix/mmio.h>
#include <minix/gpio.h>
#include <minix/padconf.h>
+#include <minix/type.h>
+#include <minix/board.h>
/* system headers */
#include <sys/stat.h>
log_warn(&log, "Failed to init gpio driver\n");
}
-#ifdef AM335X
+ struct machine machine ;
+ sys_getmachine(&machine);
- /* Export GPIO3_19 (P9-27 on BBB) output as LCD_EN */
+ if (BOARD_IS_BBXM(machine.board_id)){
+ add_gpio_inode("USR0", 149, GPIO_MODE_OUTPUT);
+ add_gpio_inode("USR1", 150, GPIO_MODE_OUTPUT);
+ add_gpio_inode("Button", 4, GPIO_MODE_INPUT);
- sys_padconf(CONTROL_CONF_MCASP0_FSR, 0xffffffff,
- (CONTROL_CONF_PUTYPESEL | CONTROL_CONF_MUXMODE(7)));
+ /* configure GPIO_144 to be exported */
+ sys_padconf(CONTROL_PADCONF_UART2_CTS, 0x0000ffff,
+ PADCONF_MUXMODE(4) | PADCONF_PULL_MODE_PD_EN |
+ PADCONF_INPUT_ENABLE(1));
+ sys_padconf(CONTROL_PADCONF_MMC2_DAT6, 0xffff0000,
+ (PADCONF_MUXMODE(4) | PADCONF_PULL_MODE_PD_EN |
+ PADCONF_INPUT_ENABLE(1)) << 16);
- add_gpio_inode("LCD_EN", (32 * 3) + 19, GPIO_MODE_OUTPUT);
+ /* Added for demo purposes */
+ add_gpio_inode("BigRedButton", 144, GPIO_MODE_INPUT);
+ add_gpio_inode("BigRedButtonLed", 139, GPIO_MODE_OUTPUT);
+ } else if ( BOARD_IS_BB(machine.board_id)){
- /* Export GPIO1_17 (P9-23 on BBB) input as RIGHT */
+ /* Export GPIO3_19 (P9-27 on BBB) output as LCD_EN */
- /* assumes external pull-up resistor (10K) */
- sys_padconf(CONTROL_CONF_SPI0_D0, 0xffffffff, (CONTROL_CONF_RXACTIVE |
- CONTROL_CONF_PUDEN | CONTROL_CONF_MUXMODE(7)));
-
- add_gpio_inode("RIGHT", (32 * 1) + 17, GPIO_MODE_INPUT);
+ sys_padconf(CONTROL_CONF_MCASP0_FSR, 0xffffffff,
+ (CONTROL_CONF_PUTYPESEL | CONTROL_CONF_MUXMODE(7)));
-#elif DM37XX
+ add_gpio_inode("LCD_EN", (32 * 3) + 19, GPIO_MODE_OUTPUT);
- add_gpio_inode("USR0", 149, GPIO_MODE_OUTPUT);
- add_gpio_inode("USR1", 150, GPIO_MODE_OUTPUT);
- add_gpio_inode("Button", 4, GPIO_MODE_INPUT);
+ /* Export GPIO1_17 (P9-23 on BBB) input as RIGHT */
- /* configure GPIO_144 to be exported */
- sys_padconf(CONTROL_PADCONF_UART2_CTS, 0x0000ffff,
- PADCONF_MUXMODE(4) | PADCONF_PULL_MODE_PD_EN |
- PADCONF_INPUT_ENABLE(1));
- sys_padconf(CONTROL_PADCONF_MMC2_DAT6, 0xffff0000,
- (PADCONF_MUXMODE(4) | PADCONF_PULL_MODE_PD_EN |
- PADCONF_INPUT_ENABLE(1)) << 16);
-
- /* Added for demo purposes */
- add_gpio_inode("BigRedButton", 144, GPIO_MODE_INPUT);
- add_gpio_inode("BigRedButtonLed", 139, GPIO_MODE_OUTPUT);
-
-#endif /* DM37XX */
+ /* assumes external pull-up resistor (10K) */
+ sys_padconf(CONTROL_CONF_SPI0_D0, 0xffffffff, (CONTROL_CONF_RXACTIVE |
+ CONTROL_CONF_PUDEN | CONTROL_CONF_MUXMODE(7)));
+
+ add_gpio_inode("RIGHT", (32 * 1) + 17, GPIO_MODE_INPUT);
+ }
}
static int
#include <minix/i2c.h>
#include <minix/log.h>
#include <minix/type.h>
+#include <minix/board.h>
/* system headers */
#include <sys/mman.h>
{
int r;
char regex[DS_MAX_KEYLEN];
+ struct machine machine;
+ sys_getmachine(&machine);
if (type != SEF_INIT_FRESH) {
/* Restore a prior state. */
lu_state_restore();
}
-#if defined(AM335X) || defined(DM37XX)
- /* Set callback and initialize the bus */
- r = omap_interface_setup(&process, i2c_bus_id);
- if (r != OK) {
- return r;
+
+ if (BOARD_IS_BBXM(machine.board_id) || BOARD_IS_BB(machine.board_id)){
+ /* Set callback and initialize the bus */
+ r = omap_interface_setup(&process, i2c_bus_id);
+ if (r != OK) {
+ return r;
+ }
+ } else {
+ return ENODEV;
}
-#else
-#error /* Unknown SoC or bad configuration */
-#endif
/* Announce we are up when necessary. */
if (type != SEF_INIT_LU) {
#include <minix/spin.h>
#include <minix/log.h>
#include <minix/mmio.h>
+#include <minix/type.h>
+#include <minix/board.h>
#include <sys/mman.h>
#include <sys/time.h>
{
/* Initialize the basic data structures host slots and cards */
int i;
+ mmchs = NULL;
-#ifdef AM335X
- mmchs = &bone_sdcard;
-#endif
-#ifdef DM37XX
- mmchs = &bbxm_sdcard;
-#endif
+ struct machine machine ;
+ sys_getmachine(&machine);
+
+ if (BOARD_IS_BBXM(machine.board_id)){
+ mmchs = &bbxm_sdcard;
+ } else if ( BOARD_IS_BB(machine.board_id)){
+ mmchs = &bone_sdcard;
+ }
+
+ assert(mmchs);
host->host_set_instance = mmchs_host_set_instance;
host->host_init = mmchs_host_init;
host->set_log_level = mmchs_set_log_level;
#include <minix/syslib.h>
#include <minix/drvlib.h>
#include <minix/sysutil.h>
+#include <minix/type.h>
+#include <minix/board.h>
#include <sys/mman.h>
#include <sys/types.h>
int
arch_setup(struct rtc *r)
{
-#ifdef AM335X
- r->init = omap_rtc_init;
- r->get_time = omap_rtc_get_time;
- r->set_time = omap_rtc_set_time;
- r->pwr_off = omap_rtc_pwr_off;
- r->exit = omap_rtc_exit;
- return OK;
-#elif DM37XX
- fwd_set_label("tps65950.1.48");
- r->init = fwd_init;
- r->get_time = fwd_get_time;
- r->set_time = fwd_set_time;
- r->pwr_off = fwd_pwr_off;
- r->exit = fwd_exit;
- return OK;
-#else
+ struct machine machine ;
+ sys_getmachine(&machine);
+
+ if (BOARD_IS_BBXM(machine.board_id)){
+ fwd_set_label("tps65950.1.48");
+ r->init = fwd_init;
+ r->get_time = fwd_get_time;
+ r->set_time = fwd_set_time;
+ r->pwr_off = fwd_pwr_off;
+ r->exit = fwd_exit;
+ return OK;
+ } else if ( BOARD_IS_BB(machine.board_id)){
+ r->init = omap_rtc_init;
+ r->get_time = omap_rtc_get_time;
+ r->set_time = omap_rtc_set_time;
+ r->pwr_off = omap_rtc_pwr_off;
+ r->exit = omap_rtc_exit;
+ return OK;
+ }
return ENOSYS;
-#endif
}
#include <minix/config.h>
#include <minix/drivers.h>
#include <minix/vm.h>
+#include <minix/type.h>
+#include <minix/board.h>
#include <sys/mman.h>
#include <assert.h>
#include <signal.h>
int irq;
} uart_port_t;
-#ifdef DM37XX
/* OMAP3 UART base addresses. */
-static uart_port_t omap3[] = {
+static uart_port_t dm37xx_ports[] = {
{ OMAP3_UART1_BASE, 72}, /* UART1 */
{ OMAP3_UART2_BASE, 73}, /* UART2 */
{ OMAP3_UART3_BASE, 74}, /* UART3 */
{ 0, 0 }
};
-#endif
-#ifdef AM335X
-static uart_port_t omap3[] = {
+static uart_port_t am335x_ports[] = {
{ 0x44E09000 , 72 }, /* UART0 */
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
};
-#endif
static int rs_write(tty_t *tp, int try);
uart_port_t this_omap3;
char l[10];
struct minix_mem_range mr;
+ struct machine machine;
/* Associate RS232 and TTY structures. */
line = tp - &tty_table[NR_CONS];
/* Set up input queue. */
rs->ihead = rs->itail = rs->ibuf;
- this_omap3 = omap3[line];
+ sys_getmachine(&machine);
+
+ if (BOARD_IS_BBXM(machine.board_id)){
+ this_omap3 = dm37xx_ports[line];
+ } else if (BOARD_IS_BB(machine.board_id)){
+ this_omap3 = am335x_ports[line];
+ } else {
+ return;
+ }
if (this_omap3.base_addr == 0) return;
/* Configure memory access */
#include <minix/log.h>
#include <minix/mmio.h>
#include <minix/clkconf.h>
+#include <minix/type.h>
+#include <minix/board.h>
/* system headers */
#include <sys/mman.h>
.log_func = default_log
};
-#ifdef DM37XX
-#define CM_BASE 0x48004000
-#elif AM335X
-#define CM_BASE 0x44E00000
-#endif
+#define DM37XX_CM_BASE 0x48004000
+#define AM335X_CM_BASE 0x44E00000
static u32_t base = 0;
static u32_t use_count = 0;
clkconf_init()
{
use_count++;
+ struct machine machine;
+ sys_getmachine(&machine);
+ u32_t cm_base = 0;
+
if (base != 0) {
/* when used in a library we can't guaranty we only call this
log_trace(&log, "Called %d times\n", use_count);
return OK;
}
+
+ if (BOARD_IS_BBXM(machine.board_id)){
+ cm_base = DM37XX_CM_BASE;
+ } else if (BOARD_IS_BB(machine.board_id)){
+ cm_base = AM335X_CM_BASE;
+ }
struct minix_mem_range mr;
- mr.mr_base = CM_BASE;
- mr.mr_limit = CM_BASE + 0x1000;
+ mr.mr_base = cm_base;
+ mr.mr_limit = cm_base + 0x1000;
if (sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr) != 0) {
log_warn(&log, "Unable to request permission to map memory\n");
return EPERM;
}
- base = (uint32_t) vm_map_phys(SELF, (void *) CM_BASE, 0x1000);
+ base = (uint32_t) vm_map_phys(SELF, (void *) cm_base, 0x1000);
if (base == (uint32_t) MAP_FAILED) {
log_warn(&log, "Unable to map GPIO memory\n");
#include <minix/gpio.h>
#include <minix/clkconf.h>
#include <minix/type.h>
+#include <minix/board.h>
/* system headers */
#include <sys/mman.h>
uint32_t inter_values; /* values when the interrupt was called */
};
-static struct omap_gpio_bank omap_gpio_banks[] = {
-#ifdef AM335X
+static struct omap_gpio_bank *omap_gpio_banks;
+
+static struct omap_gpio_bank am335x_gpio_banks[] = {
{
.name = "GPIO0",
.register_address = AM335X_GPIO0_BASE,
.irq_hook_id = AM335X_GPIO3A_IRQ_HOOK_ID,
},
-#elif DM37XX
+ {NULL, 0, 0, 0, 0, 0, 0, 0 }
+};
+
+static struct omap_gpio_bank dm37xx_gpio_banks[] = {
{
.name = "GPIO1",
.register_address = DM37XX_GPIO1_BASE,
.irq_id = DM37XX_GPIO6_IRQ_HOOK_ID,
.irq_hook_id = DM37XX_GPIO6_IRQ_HOOK_ID,
},
-#endif /* DM37XX */
{NULL, 0, 0, 0, 0, 0, 0, 0 }
};
-#define NBANKS ((int)((sizeof(omap_gpio_banks)/sizeof(omap_gpio_banks[0])) - 1))
+static int nbanks; /* number of banks */
/*
* Defines the set of registers. There is a lot of commonality between the
.SETDATAOUT = AM335X_GPIO_SETDATAOUT
};
-#ifdef AM335X
-static gpio_omap_regs_t *regs = &gpio_omap_am335x;
-#elif DM37XX
-static gpio_omap_regs_t *regs = &gpio_omap_dm37xx;
-#endif /* DM37XX */
+static gpio_omap_regs_t *regs;
+
static struct omap_gpio_bank *
omap_gpio_bank_get(int gpio_nr)
{
struct omap_gpio_bank *bank;
- assert(gpio_nr >= 0 && gpio_nr <= 32 * NBANKS);
+ assert(gpio_nr >= 0 && gpio_nr <= 32 * nbanks);
bank = &omap_gpio_banks[gpio_nr / 32];
return bank;
}
{
log_trace(&log, "%s s claiming %d\n", owner, nr);
- if (nr < 0 && nr >= 32 * NBANKS) {
+ if (nr < 0 && nr >= 32 * nbanks) {
log_warn(&log, "%s is claiming unknown GPIO number %d\n",
owner, nr);
return EINVAL;
{
struct omap_gpio_bank *bank;
assert(gpio != NULL);
- assert(gpio->nr >= 0 && gpio->nr <= 32 * NBANKS);
+ assert(gpio->nr >= 0 && gpio->nr <= 32 * nbanks);
bank = omap_gpio_bank_get(gpio->nr);
if (value == 1) {
{
struct omap_gpio_bank *bank;
assert(gpio != NULL);
- assert(gpio->nr >= 0 && gpio->nr <= 32 * NBANKS);
+ assert(gpio->nr >= 0 && gpio->nr <= 32 * nbanks);
bank = omap_gpio_bank_get(gpio->nr);
log_trace(&log, "mode=%d OU/IN 0x%08x 0x%08x\n", gpio->mode,
{
struct omap_gpio_bank *bank;
assert(gpio != NULL);
- assert(gpio->nr >= 0 && gpio->nr <= 32 * NBANKS);
+ assert(gpio->nr >= 0 && gpio->nr <= 32 * nbanks);
bank = omap_gpio_bank_get(gpio->nr);
/* TODO: check if interrupt where enabled?? */
int i;
struct minix_mem_range mr;
struct omap_gpio_bank *bank;
+ struct machine machine;
+ sys_getmachine(&machine);
+
+ nbanks =0;
+ omap_gpio_banks = NULL;
+ if (BOARD_IS_BBXM(machine.board_id)){
+ omap_gpio_banks = dm37xx_gpio_banks;
+ regs = &gpio_omap_dm37xx;
+ } else if (BOARD_IS_BB(machine.board_id)){
+ omap_gpio_banks = am335x_gpio_banks;
+ regs = &gpio_omap_am335x;
+ }
bank = &omap_gpio_banks[0];
for (i = 0; omap_gpio_banks[i].name != NULL; i++) {
+ nbanks++;
bank = &omap_gpio_banks[i];
mr.mr_base = bank->register_address;
mr.mr_limit = bank->register_address + 0x400;
revision = 0;
revision = read32(bank->base_address + regs->REVISION);
+ unsigned int expected_major = 0;
+ unsigned int expected_minor = 0;
+ if (BOARD_IS_BBXM(machine.board_id)){
+ expected_major = 2;
+ expected_minor = 5;
+ } else if (BOARD_IS_BB(machine.board_id)){
+ expected_major = 0;
+ expected_minor = 1;
+ }
/* test if we can access it */
if (
-#ifdef AM335X
- AM335X_GPIO_REVISION_MAJOR(revision) != 0
- || AM335X_GPIO_REVISION_MINOR(revision) != 1
-#elif DM37XX
- DM37XX_GPIO_REVISION_MAJOR(revision) != 2
- || DM37XX_GPIO_REVISION_MINOR(revision) != 5
-#endif /* DM37XX */
+ AM335X_GPIO_REVISION_MAJOR(revision) != expected_major
+ || AM335X_GPIO_REVISION_MINOR(revision) != expected_minor
) {
log_warn(&log,
"Failed to read the revision of GPIO bank %s.. disabling\n",
};
clkconf_init();
-#ifdef AM335X
- /* Nothing to enable for GPIO on AM335X */
-#elif DM37XX
- /* enable the interface and functional clock on GPIO bank 1 */
- clkconf_set(CM_FCLKEN_WKUP, BIT(3), 0xffffffff);
- clkconf_set(CM_ICLKEN_WKUP, BIT(3), 0xffffffff);
-#endif /* DM37XX */
+
+ if (BOARD_IS_BBXM(machine.board_id)){
+ /* enable the interface and functional clock on GPIO bank 1 , this only
+ applies to the Beagelboard XM */
+ clkconf_set(CM_FCLKEN_WKUP, BIT(3), 0xffffffff);
+ clkconf_set(CM_ICLKEN_WKUP, BIT(3), 0xffffffff);
+ }
clkconf_release();