/* Apply power to the simcard (use nullpointer to ignore atr) */ int calypso_sim_powerup(uint8_t *atr) { /* Enable level shifters and voltage regulator */ #if 1 // 2.9V twl3025_reg_write(VRPCSIM, VRPCSIM_SIMLEN | VRPCSIM_RSIMEN | VRPCSIM_SIMSEL); #else // 1.8V twl3025_reg_write(VRPCSIM, VRPCSIM_SIMLEN | VRPCSIM_RSIMEN); #endif printd(" * Power enabled!\n"); delay_ms(SIM_OPERATION_DELAY); /* Enable clock */ writew(REG_SIM_CMD_MODULE_CLK_EN | REG_SIM_CMD_CMDSTART, REG_SIM_CMD); printd(" * Clock enabled!\n"); delay_ms(SIM_OPERATION_DELAY); /* Release reset */ writew(readw(REG_SIM_CONF1) | REG_SIM_CONF1_CONFBYPASS | REG_SIM_CONF1_CONFSRSTLEV | REG_SIM_CONF1_CONFSVCCLEV, REG_SIM_CONF1); printd(" * Reset released!\n"); /* Catch ATR */ if(atr != 0) { calypso_sim_receive(atr, 0); while (!rxDoneFlag) ; } return 0; }
/* Switch the register page of the TWL3025 */ static void twl3025_switch_page(uint8_t page) { if (page == 0) twl3025_reg_write(PAGEREG, 1 << 0); else twl3025_reg_write(PAGEREG, 1 << 1); twl3025_state.page = page; }
void twl3025_clk13m(int enable) { if (enable) { twl3025_reg_write(TOGBR2, TOGBR2_ACTS); twl3025_wait_ibic_access(); /* for whatever reason we need to do this twice */ twl3025_reg_write(TOGBR2, TOGBR2_ACTS); twl3025_wait_ibic_access(); } else { twl3025_reg_write(TOGBR2, TOGBR2_ACTR); twl3025_wait_ibic_access(); } }
/* Powerdown simcard */ void calypso_sim_powerdown(void) { writew(readw(REG_SIM_CONF1) & ~REG_SIM_CONF1_CONFBYPASS, REG_SIM_CONF1); #if (SIM_DEBUG == 1) puts(" * Reset pulled down!\n"); #endif delay_ms(SIM_OPERATION_DELAY); writew(REG_SIM_CMD_MODULE_CLK_EN | REG_SIM_CMD_CMDSTOP, REG_SIM_CMD); #if (SIM_DEBUG == 1) puts(" * Clock disabled!\n"); #endif delay_ms(SIM_OPERATION_DELAY); writew(0, REG_SIM_CMD); #if (SIM_DEBUG == 1) puts(" * Module disabled!\n"); #endif delay_ms(SIM_OPERATION_DELAY); /* Disable level shifters and voltage regulator */ twl3025_reg_write(VRPCSIM, 0); #if (SIM_DEBUG == 1) puts(" * Power disabled!\n"); #endif delay_ms(SIM_OPERATION_DELAY); return; }
/* Apply power to the simcard (use nullpointer to ignore atr) */ int calypso_sim_powerup(uint8_t *atr) { /* Enable level shifters and voltage regulator */ twl3025_reg_write(VRPCSIM, VRPCSIM_SIMLEN | VRPCSIM_RSIMEN | VRPCSIM_SIMSEL); #if (SIM_DEBUG == 1) puts(" * Power enabled!\n"); #endif delay_ms(SIM_OPERATION_DELAY); /* Enable clock */ writew(REG_SIM_CMD_MODULE_CLK_EN | REG_SIM_CMD_CMDSTART, REG_SIM_CMD); #if (SIM_DEBUG == 1) puts(" * Clock enabled!\n"); #endif delay_ms(SIM_OPERATION_DELAY); /* Release reset */ writew(readw(REG_SIM_CONF1) | REG_SIM_CONF1_CONFBYPASS | REG_SIM_CONF1_CONFSRSTLEV | REG_SIM_CONF1_CONFSVCCLEV, REG_SIM_CONF1); #if (SIM_DEBUG == 1) puts(" * Reset released!\n"); #endif /* Catch ATR */ if(atr != 0) return calypso_sim_receive(atr); else return 0; }
void twl3025_afc_set(int16_t val) { printf("twl3025_afc_set(%d)\n", val); if (val > 4095) val = 4095; else if (val <= -4096) val = -4096; /* FIXME: we currently write from the USP rather than BSP */ twl3025_reg_write(AUXAFC2, val >> 10); twl3025_reg_write(AUXAFC1, val & 0x3ff); }
void twl3025_init(void) { spi_init(); twl3025_switch_page(0); twl3025_clk13m(1); twl3025_reg_write(AFCCTLADD, 0x01); /* AFCCK(1:0) must not be zero! */ twl3025_unit_enable(TWL3025_UNIT_AFC, 1); irq_register_handler(IRQ_EXTERNAL, &twl3025_irq); irq_config(IRQ_EXTERNAL, 0, 0, 0); irq_enable(IRQ_EXTERNAL); irq_register_handler(IRQ_EXTERNAL_FIQ, &twl3025_irq); irq_config(IRQ_EXTERNAL_FIQ, 1, 0, 0); irq_enable(IRQ_EXTERNAL_FIQ); }
void twl3025_unit_enable(enum twl3025_unit unit, int on) { uint16_t togbr1 = 0; switch (unit) { case TWL3025_UNIT_AFC: if (on) togbr1 = (1 << 7); else togbr1 = (1 << 6); break; case TWL3025_UNIT_MAD: if (on) togbr1 = (1 << 9); else togbr1 = (1 << 8); break; case TWL3025_UNIT_ADA: if (on) togbr1 = (1 << 5); else togbr1 = (1 << 4); case TWL3025_UNIT_VDL: if (on) togbr1 = (1 << 3); else togbr1 = (1 << 2); break; case TWL3025_UNIT_VUL: if (on) togbr1 = (1 << 1); else togbr1 = (1 << 0); break; } twl3025_reg_write(TOGBR1, togbr1); }
void board_init(int with_irq) { /* Disable watchdog (compal loader leaves it enabled) */ wdog_enable(0); /* Configure memory interface */ calypso_mem_cfg(CALYPSO_nCS0, 3, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_nCS1, 3, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_nCS2, 5, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_nCS3, 5, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_CS4, 0, CALYPSO_MEM_8bit, 1); calypso_mem_cfg(CALYPSO_nCS6, 0, CALYPSO_MEM_32bit, 1); calypso_mem_cfg(CALYPSO_nCS7, 0, CALYPSO_MEM_32bit, 0); /* Set VTCXO_DIV2 = 1, configure PLL for 104 MHz and give ARM half of that */ calypso_clock_set(2, CALYPSO_PLL13_104_MHZ, ARM_MCLK_DIV_2); /* Configure the RHEA bridge with some sane default values */ calypso_rhea_cfg(0, 0, 0xff, 0, 1, 0, 0); /* Initialize board-specific GPIO */ board_io_init(); /* Enable bootrom mapping to route exception vectors to RAM */ calypso_bootrom(with_irq); calypso_exceptions_install(); /* Initialize interrupt controller */ if (with_irq) irq_init(); sercomm_bind_uart(UART_MODEM); cons_bind_uart(UART_IRDA); /* initialize MODEM UART to be used for sercomm */ uart_init(UART_MODEM, with_irq); uart_baudrate(UART_MODEM, UART_115200); /* initialize IRDA UART to be used for old-school console code. * note: IRDA uart only accessible on C115 and C117 PCB */ uart_init(UART_IRDA, with_irq); uart_baudrate(UART_IRDA, UART_115200); /* Initialize hardware timers */ hwtimer_init(); /* Initialize DMA controller */ dma_init(); /* Initialize real time clock */ rtc_init(); /* Initialize system timers (uses hwtimer 2) */ timer_init(); /* Initialize LCD driver (uses UWire) */ fb_init(); bl_mode_pwl(1); bl_level(0); /* Initialize keypad driver */ keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); /* enable LEDB driver of Iota for keypad backlight */ twl3025_reg_write(AUXLED, 0x02); }
void board_init(void) { /* Configure the memory interface */ calypso_mem_cfg(CALYPSO_nCS0, 3, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_nCS1, 3, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_nCS2, 5, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_nCS3, 5, CALYPSO_MEM_16bit, 1); calypso_mem_cfg(CALYPSO_CS4, 0, CALYPSO_MEM_8bit, 1); calypso_mem_cfg(CALYPSO_nCS6, 0, CALYPSO_MEM_32bit, 1); calypso_mem_cfg(CALYPSO_nCS7, 0, CALYPSO_MEM_32bit, 0); /* Set VTCXO_DIV2 = 1, configure PLL for 104 MHz and give ARM half of that */ calypso_clock_set(2, CALYPSO_PLL13_104_MHZ, ARM_MCLK_DIV_2); /* Configure the RHEA bridge with some sane default values */ calypso_rhea_cfg(0, 0, 0xff, 0, 1, 0, 0); /* Initialize board-specific GPIO */ board_io_init(); /* Enable bootrom mapping to route exception vectors to RAM */ calypso_bootrom(1); calypso_exceptions_install(); /* Initialize interrupt controller */ irq_init(); /* initialize MODEM UART to be used for sercomm*/ uart_init(SERCOMM_UART_NR, 1); uart_baudrate(SERCOMM_UART_NR, UART_115200); /* Initialize IRDA UART to be used for old-school console code. * note: IRDA uart only accessible on C115 and C117 PCB */ uart_init(CONS_UART_NR, 1); uart_baudrate(CONS_UART_NR, UART_115200); /* Initialize hardware timers */ hwtimer_init(); /* Initialize DMA controller */ dma_init(); /* Initialize real time clock */ rtc_init(); /* Initialize system timers (uses hwtimer 2) */ timer_init(); /* Initialize LCD driver (uses I2C) and backlight */ display = &st7558_display; display_init(); bl_mode_pwl(1); bl_level(0); /* Initialize keypad driver */ keypad_init(1); /* Initialize ABB driver (uses SPI) */ twl3025_init(); /* enable LEDB driver of Iota for keypad backlight */ twl3025_reg_write(AUXLED, 0x02); }
void twl3025_afcout_set(uint8_t val) { twl3025_reg_write(AFCCTLADD, 0x05); twl3025_reg_write(AFCOUT, val); }
void twl3025_power_off(void) { twl3025_reg_write(VRPCDEV, 0x01); }