Ejemplo n.º 1
0
/* Returns the current state of the backlight (true=ON, false=OFF). */
bool _backlight_init(void)
{
    or_l(0x00020000, &GPIO1_ENABLE);
    or_l(0x00020000, &GPIO1_FUNCTION);
    
    return (GPIO1_OUT & 0x00020000) ? false : true;
}
Ejemplo n.º 2
0
void ata_device_init(void)
{
    /* ATA reset line config */
    or_l((1<<19), &GPIO_OUT);
    or_l((1<<19), &GPIO_ENABLE);
    or_l((1<<19), &GPIO_FUNCTION);
}
Ejemplo n.º 3
0
void pcm_play_dma_init(void)
{
    freq_ent = pcm_freq_parms[pcm_fsel];

    AUDIOGLOB = AUDIOGLOB_DEFPARM;
    DIVR0     = 54; /* DMA0 is mapped into vector 54 in system.c */
    and_l(0xffffff00, &DMAROUTE);
    or_l(DMA0_REQ_AUDIO_1, &DMAROUTE);
    DMACONFIG = 1;  /* DMA0Req = PDOR3, DMA1Req = PDIR2 */
    BCR0 = 0; /* No bytes waiting */
    ICR6 = (6 << 2); /* Enable interrupt at level 6, priority 0 */

    /* Setup Coldfire I2S before initializing hardware or changing
       other settings. */
    or_l(IIS_FIFO_RESET, &IIS_PLAY);
    IIS_PLAY = IIS_PLAY_DEFPARM | IIS_FIFO_RESET;
    audio_set_output_source(AUDIO_SRC_PLAYBACK);

    /* Initialize default register values. */
    audiohw_init();

    audio_input_mux(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);

    audiohw_set_frequency(pcm_fsel);
    coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM);

#if defined(HAVE_SPDIF_REC) || defined(HAVE_SPDIF_OUT)
    spdif_init();
#endif
} /* pcm_play_dma_init */
Ejemplo n.º 4
0
bool backlight_hw_init(void)
{
    and_l(~0x00000008, &GPIO1_OUT);
    or_l(0x00000008, &GPIO1_ENABLE);
    or_l(0x00000008, &GPIO1_FUNCTION);
    return true; /* Backlight always ON after boot. */
}
Ejemplo n.º 5
0
bool backlight_hw_init(void)
{
    or_l(0x00020000, &GPIO1_ENABLE);
    or_l(0x00020000, &GPIO1_FUNCTION);
    or_l(0x00020000, &GPIO1_OUT);  /* Start with the backlight ON */
    
    return true; /* Backlight always ON after boot. */
}
Ejemplo n.º 6
0
void usb_init_device(void)
{
    and_l(~0x10000000, &GPIO_OUT);   /* USB enable bit */
    or_l(0x10000000, &GPIO_ENABLE);
    or_l(0x10000000, &GPIO_FUNCTION);
    
    or_l(0x00000400, &GPIO1_FUNCTION);  /* USB detect */
}
Ejemplo n.º 7
0
void m5636_device_init(void)
{
    and_l(~0x00004000, &GPIO_INT_EN);  /* probably redundant: disable
                                          interrupt; just in case ... */
    and_l(~0x00000004, &GPIO1_OUT);    /* probably redundant: set GPIO34 low */
    or_l(  0x00000004, &GPIO1_ENABLE);   /* GPIO34 enable (see above) */
    or_l(  0x00000004, &GPIO1_FUNCTION); /* GPIO34 function (see above) */
}
Ejemplo n.º 8
0
void uda1380_reset(void)
{
    /* RESET signal */
    or_l(1<<29, &GPIO_OUT);
    or_l(1<<29, &GPIO_ENABLE);
    or_l(1<<29, &GPIO_FUNCTION);
    sleep(HZ/100);
    and_l(~(1<<29), &GPIO_OUT);
}
Ejemplo n.º 9
0
void adc_init(void)
{
    or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7:  CS
                                         GPIO21: Data In (to the ADC)
                                         GPIO22: CLK
                                         GPIO31: Data Out (from the ADC) */
    or_l(0x00600080, &GPIO_ENABLE);
    or_l(0x80, &GPIO_OUT);          /* CS high */
    and_l(~0x00400000, &GPIO_OUT);  /* CLK low */
}
Ejemplo n.º 10
0
void i2c_init(void)
{
#ifdef IRIVER_H100_SERIES
    /* The FM chip has no pullup for SCL, so we have to bit-bang the
       I2C for that one. */
    or_l(0x00800000, &GPIO1_OUT);
    or_l(0x00000008, &GPIO_OUT);
    or_l(0x00800000, &GPIO1_ENABLE);
    or_l(0x00000008, &GPIO_ENABLE);
    or_l(0x00800000, &GPIO1_FUNCTION);
    or_l(0x00000008, &GPIO_FUNCTION);
#elif defined(IRIVER_H300_SERIES)
    /* The FM chip has no pullup for SCL, so we have to bit-bang the
       I2C for that one. */
    or_l(0x03000000, &GPIO1_OUT);
    or_l(0x03000000, &GPIO1_ENABLE);
    or_l(0x03000000, &GPIO1_FUNCTION);
#endif
    
    /* I2C Clock divisor = 160 => 124.1556 MHz / 2 / 160 = 388.08 kHz */
    MFDR  = 0x0d;

#if defined(IAUDIO_M3)
    MBCR  = IEN;  /* Enable interface 1 */
    /* secondary channel is handled in the interrupt driven ADC driver */
#elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
    MBCR  = IEN;  /* Enable interface 1 */

    MFDR2 = 0x0d;
    MBCR2 = IEN;  /* Enable interface 2 */
#elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
    MBDR = 0;    /* iRiver firmware does this */
    MBCR = IEN;  /* Enable interface */
#endif
}
Ejemplo n.º 11
0
void ide_power_enable(bool on)
{
   (void)on;
   if (on)
        and_l(~(1<<31),&GPIO_OUT);
    else
        or_l((1<<31),&GPIO_OUT);

    or_l((1<<31),&GPIO_ENABLE);
    or_l((1<<31),&GPIO_FUNCTION);

}
Ejemplo n.º 12
0
void sw_i2c_init(void)
{
#ifndef MROBE_100
    or_l(0x00001000, &GPIO_FUNCTION);
    or_l(0x00002000, &GPIO1_FUNCTION);
#endif
  
    SDA_HI;
    SCL_HI;
    SDA_OUT_LO;
    SCL_OUT_LO;
}
Ejemplo n.º 13
0
void usb_init_device(void)
{
    /* GPIO42 is USB detect input
     * but it also serves as MCLK2 for DAC
     */
    and_l(~(1<<4), &GPIO1_OUT);           /* GPIO36 low */
    or_l((1<<4), &GPIO1_ENABLE);          /* GPIO36 */
    or_l((1<<4)|(1<<5), &GPIO1_FUNCTION); /* GPIO36 GPIO37 */

    /* GPIO22 GPIO30 high */
    or_l((1<<22)|(1<<30), &GPIO_OUT);
    or_l((1<<22)|(1<<30), &GPIO_ENABLE);
    or_l((1<<22)|(1<<30), &GPIO_FUNCTION);
}
Ejemplo n.º 14
0
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
}
Ejemplo n.º 15
0
void DMA0(void)
{
    unsigned long res = DSR0;
    void *start;
    size_t size;

    and_l(~(DMA_EEXT | DMA_INT), &DCR0); /* per request and int OFF */
    DSR0 = 1; /* Clear interrupt and errors */

    if (res & 0x70)
    {
        logf("DMA0 err: %02x", res);
#if 0
        logf("  SAR0: %08x", SAR0);
        logf("  DAR0: %08x", DAR0);
        logf("  BCR0: %08x", BCR0);
        logf("  DCR0: %08x", DCR0);
#endif
    }

    /* Force stop on error */
    pcm_play_get_more_callback((res & 0x70) ? NULL : &start, &size);

    if (size != 0)
    {
        SAR0 = (unsigned long)start;     /* Source address */
        BCR0 = size;                     /* Bytes to transfer */
        or_l(DMA_EEXT | DMA_INT, &DCR0); /* per request and int ON */

        /* Call buffer callback */
        pcm_play_dma_started_callback();
    }
    /* else inished playing */
} /* DMA0 */
Ejemplo n.º 16
0
/* This clears the reset bit to enable monitoring immediately if monitoring
   recording sources or always if playback is in progress - we might be 
   switching samplerates on the fly */
void pcm_dma_apply_settings(void)
{
    int level = set_irq_level(DMA_IRQ_LEVEL);

    /* remember table entry */
    freq_ent = pcm_freq_parms[pcm_fsel];
 
    /* Reprogramming bits 15-12 requires FIFO to be in a reset
       condition - Users Manual 17-8, Note 11 */
    or_l(IIS_FIFO_RESET, &IIS_PLAY);
    /* Important for TLV320 - this must happen in the correct order
       or starting recording will sound absolutely awful once in
       awhile - audiohw_set_frequency then coldfire_set_pllcr_audio_bits
     */
    IIS_PLAY = IIS_PLAY_DEFPARM | IIS_FIFO_RESET;
    restore_irq(level);

    audiohw_set_frequency(pcm_fsel);
    coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM);

    level = set_irq_level(DMA_IRQ_LEVEL);

    IIS_PLAY = IIS_PLAY_DEFPARM;

    if ((DCR0 & DMA_EEXT) != 0 && is_playback_monitoring())
        PDOR3 = 0; /* Kick FIFO out of reset by writing to it */

    restore_irq(level);
} /* pcm_dma_apply_settings */
Ejemplo n.º 17
0
static inline void enable_mclk(bool enable)
{
    if(enable)
        and_l(~(1<<10), &GPIO1_FUNCTION);
    else
        or_l((1<<10), &GPIO1_FUNCTION);
}
void button_init_device(void)
{
    /* GPIO56 (main PLAY) general input
     * GPIO41 (remote PLAY) is shared with Audio Serial Data
     */
    or_l((1<<24),&GPIO1_FUNCTION);
    and_l(~(1<<24),&GPIO1_ENABLE);
}
Ejemplo n.º 19
0
void power_init(void)
{
    /* Charger detect */
    and_l(~0x01000000, &GPIO1_ENABLE);
    or_l(0x01000000, &GPIO1_FUNCTION);
    
    pcf50606_init();
}
Ejemplo n.º 20
0
void usb_enable(bool on)
{
    if(on) {
        or_l(0x10000000, &GPIO_OUT);
    } else {
        and_l(~0x10000000, &GPIO_OUT);
    }
}
Ejemplo n.º 21
0
void ata_reset(void)
{
    /* GPIO19 */
    and_l(~(1<<19), &GPIO_OUT);
    sleep(1); /* > 25us */

    or_l((1<<19), &GPIO_OUT);
    sleep(1); /* > 25us */
}
Ejemplo n.º 22
0
/* Reset and power up the WM8751 */
void audiohw_preinit(void)
{
#ifdef MROBE_100
    /* controls headphone ouput */
    GPIOL_ENABLE     |= 0x10;
    GPIOL_OUTPUT_EN  |= 0x10;
    GPIOL_OUTPUT_VAL |= 0x10; /* disable */
#endif

#ifdef MPIO_HD200
    /* control headphone output
     * disabled on startup
     */
    and_l(~(1<<25),&GPIO1_OUT);
    or_l((1<<25), &GPIO1_ENABLE);
    or_l((1<<25), &GPIO1_FUNCTION);
#endif

    /*
     * 1. Switch on power supplies.
     *    By default the WM8751 is in Standby Mode, the DAC is
     *    digitally muted and the Audio Interface, Line outputs
     *    and Headphone outputs are all OFF (DACMU = 1 Power
     *    Management registers 1 and 2 are all zeros).
     */

    wmcodec_write(RESET, RESET_RESET);    /*Reset*/

     /* 2. Enable Vmid and VREF. */
    wmcodec_set_bits(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_5K);

#ifdef CODEC_SLAVE
    wmcodec_set_bits(AINTFCE,AINTFCE_WL_16 | AINTFCE_FORMAT_I2S);
#else
    /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
    /* IWL=00(16 bit) FORMAT=10(I2S format) */
    wmcodec_set_bits(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 |
                  AINTFCE_FORMAT_I2S);
#endif
    /* Set default samplerate */

    audiohw_set_frequency(HW_FREQ_DEFAULT);
}
Ejemplo n.º 23
0
void pcm_rec_dma_stop(void)
{
    and_l(~(DMA_EEXT | DMA_INT), &DCR1); /* per request and int OFF */
    DSR1 = 1; /* Clear interrupt, errors, stop transfer */
    BCR1 = 0; /* No bytes received */

    or_l(PDIR2_FIFO_RESET, &DATAINCONTROL);

    iis_play_reset_if_playback(false);

    dma_rec_lock.state = (1 << 15);
} /* pcm_rec_dma_stop */
Ejemplo n.º 24
0
void pcm_rec_dma_init(void)
{
    DIVR1     = 55; /* DMA1 is mapped into vector 55 in system.c */
    DMACONFIG = 1;  /* DMA0Req = PDOR3, DMA1Req = PDIR2 */
    and_l(0xffff00ff, &DMAROUTE);
    or_l(DMA1_REQ_AUDIO_2, &DMAROUTE);

    pcm_rec_dma_stop();

    /* Enable interrupt at level 6, priority 1 */
    ICR7 = (6 << 2) | (1 << 0);
} /* pcm_init_recording */
Ejemplo n.º 25
0
void usb_enable(bool on)
{

    if(on)
    {
        and_l(~(1<<30),&GPIO_OUT);  /* GPIO30 low */
        and_l(~(1<<22),&GPIO_OUT);  /* GPIO22 low */

        or_l((1<<4),&GPIO1_OUT);    /* GPIO36 high */

    }
    else
    {
        or_l((1<<22),&GPIO_OUT);  /* GPIO22 high */
        or_l((1<<30),&GPIO_OUT);  /* GPIO30 high */

        and_l(~(1<<4),&GPIO1_OUT); /* GPIO36 low */

        while ( !(GPIO1_READ & (1<<5)) ) {}
        sleep(HZ);
    }
}
Ejemplo n.º 26
0
bool tuner_power(bool status)
{
    (void)status;
    if (status)
    {
        and_l(~(1<<17), &GPIO1_OUT);
    }
    else
    {
        or_l((1<<17), &GPIO1_OUT);
    }

    return status;
}
Ejemplo n.º 27
0
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 */
}
Ejemplo n.º 28
0
void ata_enable(bool on)
{
    static bool init = true;

    /* Ide power toggling is a nasty hack to allow USB bridge operation
     * in rockbox. For some reason GL811E bridge doesn't like the state
     * in which rockbox leaves drive (and vice versa). The only way
     * I found out to recover is to do disk power cycle (I tried toggling
     * reset line of the disk but it doesn't work).
     */

    /* GPO36  /reset line of GL811E */
    if (on)
    {
        and_l(~(1<<4), &GPIO1_OUT);
#ifndef BOOTLOADER
        if ( !init )
        {
            ide_power_enable(false);
            sleep(1);
            ide_power_enable(true);
        }
#endif
        init = false;
    }
    else
    {
#ifndef BOOTLOADER
        ide_power_enable(false);
        sleep(1);
        ide_power_enable(true);
#endif
        or_l((1<<4), &GPIO1_OUT);
    }
    or_l((1<<4), &GPIO1_ENABLE);
    or_l((1<<4), &GPIO1_FUNCTION);
}
Ejemplo n.º 29
0
void lcd_init_device(void)
{
    and_l(~0x00000800, &GPIO_FUNCTION); /* CS3 line */

    /* LCD Reset GPO34 */
    or_l(0x00000004, &GPIO1_ENABLE);    /* set as output */
    or_l(0x00000004, &GPIO1_FUNCTION);  /* switch to secondary function - GPIO */

    and_l(~0x00000004, &GPIO1_OUT);     /* RESET low */
    sleep(1);                           /* delay at least 1000 ns */
    or_l(0x00000004, &GPIO1_OUT);       /* RESET high */
    sleep(1);

    lcd_write_command(LCD_CNTL_ON_OFF | 1); /* LCD ON */
    lcd_write_command(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */
    lcd_write_command(LCD_CNTL_REVERSE | 0); /* Reverse OFF */
    lcd_write_command(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */
    lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 1); /* Reverse dir */
    lcd_write_command_ex(LCD_CNTL_DISPLAY_START_LINE, 0, -1);
    lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 0);   /* Normal */
    lcd_write_command_ex(LCD_CNTL_DISPLAY_MODE, 0, -1); /* Greyscale mode */
    lcd_write_command_ex(LCD_CNTL_GRAY_SCALE_PATTERN, 0x53, -1);
    lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1);
    lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, 24, -1); /* 0x18 */

    lcd_write_command(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */
    lcd_write_command(LCD_CNTL_POWER_SAVE | 0);
    lcd_write_command_ex(LCD_CNTL_VOLTAGE_SELECT, 3, -1);
    lcd_write_command_ex(LCD_CNTL_POWER_CONTROL, 0x17, -1);
    lcd_write_command_ex(LCD_CNTL_OSC_FREQUENCY, 3, -1);
    lcd_write_command(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */
    lcd_write_command_ex(LCD_CNTL_LINE_INVERT_DRIVE, 0x10, -1);
    lcd_write_command_ex(LCD_CNTL_TEMP_GRADIENT_SELECT, 0, -1);

    lcd_update();
}
Ejemplo n.º 30
0
void pcm_play_dma_pause(bool pause)
{
    if (pause)
    {
        /* pause playback on current buffer */
        and_l(~(DMA_EEXT | DMA_INT), &DCR0); /* per request and int OFF */
        DSR0 = 1;                            /* stop channel */
        iis_play_reset_if_playback(true);
        dma_play_lock.state = (1 << 14);
    }
    else
    {
        /* restart playback on current buffer */
        iis_play_reset_if_playback(true);
        or_l(DMA_INT | DMA_EEXT | DMA_START, &DCR0); /* everything ON */
        dma_play_lock.state = (0 << 14);
    }
} /* pcm_play_dma_pause */