static int gpio_sch_config(struct device *dev, int access_op, u32_t pin, int flags) { const struct gpio_sch_config *info = dev->config->config_info; /* Do some sanity check first */ if (flags & GPIO_INT) { if (!(flags & GPIO_INT_EDGE)) { /* controller does not support level trigger */ return -EINVAL; } } if (access_op == GPIO_ACCESS_BY_PIN) { if (pin >= info->bits) { return -EINVAL; } gpio_pin_config(dev, pin, flags); } else { gpio_port_config(dev, flags); } return 0; }
/* * usrmain() - start the monitor * * This function is called from from rom_entry. It initialises the * serial port (ASC0) and then starts the monitor program. * */ void usrmain(void) { #if (ASC0_PORT==0) gpio_port_config(0, 4, GPIO_MODE_OUT|GPIO_MODE_ALT2); gpio_port_config(0, 5, GPIO_MODE_IN); asc_init(ASC0, 1); #elif (ASC0_PORT==2) gpio_port_config(2, 4, GPIO_MODE_OUT|GPIO_MODE_ALT1); gpio_port_config(2, 5, GPIO_MODE_IN); asc_init(ASC0, 0); #endif ASC0->asc_tbuf = '\r'; /* kick out a character to start things rolling */ printf("qdf version 0.1, copyright 2001 David Haworth\n"); printf("qdf comes with ABSOLUTELY NO WARRANTY. It is free software,\n"); printf("and you are welcome to redistribute it under certain conditions.\n"); printf("Please read the file COPYING for details.\n"); for (;;) do_forth(&forth_env); }
/* * usrmain() - start the kernel * * This function is called from from rom_entry. It initialises the * serial port (ASC0) for kernel debug messages and then starts the * kernel program. * */ void usrmain(void) { #if (ASC0_PORT==0) gpio_port_config(0, 4, GPIO_MODE_OUT|GPIO_MODE_ALT2); gpio_port_config(0, 5, GPIO_MODE_IN); asc_init(ASC0, 1); #elif (ASC0_PORT==2) gpio_port_config(2, 4, GPIO_MODE_OUT|GPIO_MODE_ALT1); gpio_port_config(2, 5, GPIO_MODE_IN); asc_init(ASC0, 0); #endif ASC0->asc_tbuf = '\r'; /* kick out a character to start things rolling */ kprintf("davros version 0.1, copyright 2001 David Haworth\n"); kprintf("davros comes with ABSOLUTELY NO WARRANTY. It is free software,\n"); kprintf("and you are welcome to redistribute it under certain conditions.\n"); kprintf("Please read the file COPYING for details.\n"); __davros_init((memaddr_t)&__bss_end, (RAM_START+RAM_SIZE)); /* Never returns */ }
/* * __arch_init() - start the drivers, etc. * */ void __arch_init(void) { set_biv((uint32_t)interrupt_table); set_btv((uint32_t)exception_table); CPS->cps_src3 = ISR_CLRR; CPS->cps_src2 = ISR_CLRR; CPS->cps_src1 = ISR_CLRR; CPS->cps_src0 = ISR_CLRR; gptu_timer_stop(GPTU0, 0); gptu_timer_stop(GPTU0, 1); gptu_timer_stop(GPTU1, 0); gptu_timer_stop(GPTU1, 1); GPTU0->gptu_gtsrc7 = ISR_CLRR; GPTU0->gptu_gtsrc6 = ISR_CLRR; GPTU0->gptu_gtsrc5 = ISR_CLRR; GPTU0->gptu_gtsrc4 = ISR_CLRR; GPTU0->gptu_gtsrc3 = ISR_CLRR; GPTU0->gptu_gtsrc2 = ISR_CLRR; GPTU0->gptu_gtsrc1 = ISR_CLRR; GPTU0->gptu_gtsrc0 = ISR_CLRR; GPTU1->gptu_gtsrc7 = ISR_CLRR; GPTU1->gptu_gtsrc6 = ISR_CLRR; GPTU1->gptu_gtsrc5 = ISR_CLRR; GPTU1->gptu_gtsrc4 = ISR_CLRR; GPTU1->gptu_gtsrc3 = ISR_CLRR; GPTU1->gptu_gtsrc2 = ISR_CLRR; GPTU1->gptu_gtsrc1 = ISR_CLRR; GPTU1->gptu_gtsrc0 = ISR_CLRR; asc_polled_init(ASC0); asc_polled_init(ASC1); enable_interrupts(); if ( gptu_timer_start(GPTU0, 0, __DAVROS_INUM_TIMER, __DAVROS_HZ) != 0 ) { kprintf("gptu_timer_start() returned error.\n"); return; } if ( __davros_attach_interrupt(__DAVROS_INUM_TIMER, (__davros_intfunc_t)__davros_tick, NULL) != 0 ) { kprintf("__davros_attach_interrupt() returned error.\n"); return; } if ( gptu_timer_enable_int(GPTU0, 0) != 0 ) { kprintf("gptu_timer_enable_int() returned error.\n"); return; } #if (ASC1_PORT==0) gpio_port_config(0, 6, GPIO_MODE_OUT|GPIO_MODE_ALT2); gpio_port_config(0, 7, GPIO_MODE_IN); #elif (ASC1_PORT==2) gpio_port_config(2, 6, GPIO_MODE_OUT|GPIO_MODE_ALT1); gpio_port_config(2, 7, GPIO_MODE_IN); #endif asc_tty_create("tty/0", ASC0, __DAVROS_INUM_ASC0, (ASC0_PORT==0)); asc_tty_create("tty/1", ASC1, __DAVROS_INUM_ASC1, (ASC1_PORT==0)); }