Esempio n. 1
0
void adc_init(void) 
{
    int i;

    /* Turn on the ADC PCLK */
    bitset32(&CLKCON, 1<<15);

    /* Set channel 0, normal mode, disable "start by read" */
    ADCCON &= ~(0x3F);

    /* No start delay.  Use normal conversion mode. */
    ADCDLY = 0x1;

    /* Set and enable the prescaler */
    ADCCON = (ADCCON & ~(0xff<<6)) | (0x19<<6);
    ADCCON |= (1<<14);

    /* prefill the adc channels */
    for (i = 0; i < NUM_ADC_CHANNELS; i++)
    {
        adc_readings[i] = __adc_read(i);
    }

    /* start at zero so when the tick starts it is at zero */
    adc_readings[0] = __adc_read(0);

    /* attach the adc reading to the tick */
    tick_add_task(adc_tick);
}
void lcd_remote_init_device(void)
{
#ifdef IRIVER_H300_SERIES
    or_l(0x10010000, &GPIO_FUNCTION); /* GPIO16: RS
                                         GPIO28: CLK */

    or_l(0x00040006, &GPIO1_FUNCTION); /* GPO33:  Backlight
                                          GPIO34: CS
                                          GPIO50: Data */
    or_l(0x10010000, &GPIO_ENABLE);
    or_l(0x00040006, &GPIO1_ENABLE);
#else
    or_l(0x10010800, &GPIO_FUNCTION); /* GPIO11: Backlight
                                         GPIO16: RS
                                         GPIO28: CLK */

    or_l(0x00040004, &GPIO1_FUNCTION); /* GPIO34: CS
                                          GPIO50: Data */
    or_l(0x10010800, &GPIO_ENABLE);
    or_l(0x00040004, &GPIO1_ENABLE);
#endif

    lcd_remote_clear_display();
    if (remote_detect())
        lcd_remote_on();
#ifndef BOOTLOADER
    tick_add_task(remote_tick);
#endif
}
Esempio n. 3
0
void powermgmt_init_target(void)
{
    charge_state = DISCHARGING;
    /* stmp < 3780 does not have a 4.2 rail */
#if IMX233_SUBTARGET >= 3780
    tick_add_task(&ramp_up_4p2_rail);
#endif
}
Esempio n. 4
0
void lcd_remote_init_device(void)
{
    lcd_remote_clear_display();
    if (remote_detect())
        lcd_remote_on();

    lcd_remote_update();

    /* put the remote control in the tick task */
    tick_add_task(remote_tick);
}
void adc_init(void)
{
    MFDR2 = 0x1f;             /* I²C clock = SYSCLK / 3840 */
    MBCR2 = IEN;              /* Enable interface */
    MBSR2 = 0;                /* Clear flags */
    MBCR2 = (IEN|IIEN);       /* Enable interrupts */

    or_l(  0x04000000, &INTPRI8); /* INT62 - Priority 4 */

    tick_add_task(adc_tick);
    
    while (!data_ready)
        sleep(1);             /* Ensure valid readings when adc_init returns */
}
bool _backlight_init(void)
{
    unsigned char brightness = log_brightness[DEFAULT_BRIGHTNESS_SETTING];
    buttonlight_brightness = brightness;
    _backlight_brightness = brightness;

    buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
    backlight_control = BACKLIGHT_CONTROL_ON;

    /* Set the backlight up in a known state */
    sc606_init();
    sc606_write(SC606_REG_A , brightness);
    sc606_write(SC606_REG_B , 0);
    sc606_write(SC606_REG_C , 0);
    sc606_write(SC606_REG_CONF , 0x03);
#ifndef BOOTLOADER
    /* put the led control on the tick list */
    tick_add_task(led_control_service);
#endif
    return true;
}
Esempio n. 7
0
void adc_init(void)
{
    /* GPIO38 GPIO39 */
    and_l(~((1<<6)|(1<<7)), &GPIO1_FUNCTION);

    /* ADOUT_SEL = 01
     * SOURCE SELECT = 000
     * CLEAR INTERRUPT FLAG
     * ENABLE INTERRUPT = 0
     * ADOUT_DRIVE = 00
     * ADCLK_SEL = 011 (busclk/8)
     */

    ADCONFIG = (1<<10)|(1<<8)|(1<<7)|0x03;

    /* ADC interrupt level 4.0 */
    or_l((4<<28), &INTPRI8);

    /* create tick task which enables ADC interrupt */
    tick_add_task(adc_tick);
}
Esempio n. 8
0
int main(void)
{
    char buf[40];
    char str[32];
    int i=0;
    struct queue_event *ev;

    /* Clear it all! */
    SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);

    /* This enables the serial Rx interrupt, to be able to exit into the
       debugger when you hit CTRL-C */
    SCR1 |= 0x40;
    SCR1 &= ~0x80;
    IPRE |= 0xf000; /* Set to highest priority */

    debugf("OK. Let's go\n");

    kernel_init();

    enable_irq();

    tick_add_task(testfunc);
    
    debugf("sleeping 10s...\n");
    sleep(HZ*10);
    debugf("woke up\n");
    
    queue_init(&main_q);
    
    create_thread(t1, s1, 1024, 0);
    create_thread(t2, s2, 1024, 0);

    while(1)
    {
        ev = queue_wait(&main_q);
        debugf("Thread 0 got an event. ID: %d\n", ev->id);
    }
}
Esempio n. 9
0
void button_init(void)
{
    /* Init used objects first */
    queue_init(&button_queue, true);

#ifdef HAVE_BUTTON_DATA
    int temp;
#endif
    /* hardware inits */
    button_init_device();

#ifdef HAVE_BUTTON_DATA
    button_read(&temp);
    lastbtn = button_read(&temp);
#else
    button_read();
    lastbtn = button_read();
#endif
    
    reset_poweroff_timer();

#ifdef HAVE_LCD_BITMAP
    flipped = false;
#endif
#ifdef HAVE_BACKLIGHT
    filter_first_keypress = false;
#ifdef HAVE_REMOTE_LCD
    remote_filter_first_keypress = false;
#endif    
#endif
#ifdef HAVE_TOUCHSCREEN
    last_touchscreen_touch = 0xffff;
#endif    
    /* Start polling last */
    tick_add_task(button_tick);
}
Esempio n. 10
0
void usb_init(void)
{
    /* We assume that the USB cable is extracted */
    usb_state = USB_EXTRACTED;
#ifdef USB_DETECT_BY_DRV
    last_usb_status = USB_UNPOWERED;
#else
    last_usb_status = USB_EXTRACTED;
#endif
    usb_monitor_enabled = false;

#ifdef HAVE_USBSTACK
    exclusive_storage_access = false;
#endif

#ifdef USB_FIREWIRE_HANDLING
    firewire_countdown = -1;
    last_firewire_status = false;
#endif

    usb_init_device();
#ifdef USB_FULL_INIT
    usb_enable(false);

    queue_init(&usb_queue, true);

    usb_thread_entry = create_thread(usb_thread, usb_stack,
                       sizeof(usb_stack), 0, usb_thread_name
                       IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU));

#ifndef USB_STATUS_BY_EVENT
    countdown = -1;
    tick_add_task(usb_tick);
#endif
#endif /* USB_FULL_INIT */
}
Esempio n. 11
0
/* Adds a timeout callback - calling with an active timeout resets the
   interval - can be called from the ISR */
void timeout_register(struct timeout *tmo, timeout_cb_type callback,
                      int ticks, intptr_t data)
{
    int oldlevel;
    void **arr, **p;

    if(tmo == NULL)
        return;

    oldlevel = disable_irq_save();

    /* See if this one is already registered */
    arr = (void **)tmo_list;
    p = find_array_ptr(arr, tmo);

    if(p - arr < MAX_NUM_TIMEOUTS)
    {
        /* Vacancy */
        if(*p == NULL)
        {
            /* Not present */
            if(*tmo_list == NULL)
            {
                tick_add_task(timeout_tick); /* First one - add task */
            }

            *p = tmo;
        }

        tmo->callback = callback;
        tmo->data = data;
        tmo->expires = current_tick + ticks;
    }

    restore_irq(oldlevel);
}
Esempio n. 12
0
void button_init_sdl(void)
{
#ifdef HAVE_TOUCHSCREEN
    tick_add_task(mouse_tick_task);
#endif
}
void usb_drv_init(void)
{
    logf("usb_drv_init() !!!!\n");

    if (!initialized)
    {
        int i;
        for (i = 0; i < USB_NUM_EPS; i++)
        {
            semaphore_init(&endpoints[i][0].complete, 1, 0);
            semaphore_init(&endpoints[i][1].complete, 1, 0);
        }

        initialized = true;
    }

    usb_enable_pll();

    /* we have external power, so boost cpu */
    cpu_boost(1);

    /* length regulator: normal operation */
    ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) | 1<<2);

    /* AHB part */
    bitset32(&CGU_PERI, CGU_USB_CLOCK_ENABLE);

    /* reset AHB */
    CCU_SRC = CCU_SRC_USB_AHB_EN;
    CCU_SRL = CCU_SRL_MAGIC_NUMBER;
    mdelay(1);
    CCU_SRC = CCU_SRL = 0;

    USB_GPIO_CSR = USB_GPIO_TX_ENABLE_N
                 | USB_GPIO_TX_BIT_STUFF_EN
                 | USB_GPIO_XO_ON
                 | USB_GPIO_CLK_SEL10; /* 0x06180000; */

    /* bug workaround according to linux patch */
    USB_DEV_CFG = (USB_DEV_CFG & ~3) | 1; /* full speed */

    /* enable soft disconnect */
    USB_DEV_CTRL |= USB_DEV_CTRL_SOFT_DISCONN;

    usb_phy_on();
    usb_phy_suspend();
    USB_DEV_CTRL |= USB_DEV_CTRL_SOFT_DISCONN;

    /* We don't care about SVC or SOF events */
    /* Right now we don't handle suspend, so mask those too */
    USB_DEV_INTR_MASK = USB_DEV_INTR_SVC |
                        USB_DEV_INTR_SOF |
                        USB_DEV_INTR_USB_SUSPEND |
                        USB_DEV_INTR_EARLY_SUSPEND;

    USB_DEV_CFG = USB_DEV_CFG_STAT_ACK      |
                  USB_DEV_CFG_UNI_DIR       |
                  USB_DEV_CFG_PI_16BIT      |
                  USB_DEV_CFG_HS            |
                  USB_DEV_CFG_SELF_POWERED  |
                  USB_DEV_CFG_CSR_PRG       |
                  USB_DEV_CFG_PHY_ERR_DETECT;

    USB_DEV_CTRL = USB_DEV_CTRL_DESC_UPDATE  |
                   USB_DEV_CTRL_THRES_ENABLE |
                   USB_DEV_CTRL_BURST_ENABLE |
                   USB_DEV_CTRL_BLEN_8DWORDS |
                   USB_DEV_CTRL_TLEN_8THMAXSIZE;

    USB_DEV_EP_INTR_MASK &= ~((1<<0) | (1<<16));    /* ep 0 */

    reset_endpoints(1);

    /* clear pending interrupts */
    USB_DEV_EP_INTR = 0xffffffff;
    USB_DEV_INTR    = 0xffffffff;

    VIC_INT_ENABLE = INTERRUPT_USB;

    usb_phy_resume();
    USB_DEV_CTRL &= ~USB_DEV_CTRL_SOFT_DISCONN;

    USB_GPIO_CSR = USB_GPIO_TX_ENABLE_N
                 | USB_GPIO_TX_BIT_STUFF_EN
                 | USB_GPIO_XO_ON
                 | USB_GPIO_HS_INTR
                 | USB_GPIO_CLK_SEL10; /* 0x06180000; */

    tick_add_task(usb_tick);

    usb_enum_timeout = HZ; /* one second timeout for enumeration */
}