int radio_setup_2g() { gpio_pin_output(RADIO_GPIO_BB_MUX_SEL, OFF); gpio_pulldown_configure(RADIO_BB_PULLDOWN, GPIOPDDown); gpio_pin_output(RADIO_GPIO_BB_ON, OFF); udelay(100000); gpio_pin_output(RADIO_GPIO_RADIO_ON, ON); udelay(100000); gpio_pin_output(RADIO_GPIO_BB_RESET, ON); udelay(100000); gpio_pin_output(RADIO_GPIO_BB_RESET, OFF); udelay(100000); gpio_pin_use_as_input(RADIO_GPIO_BB_DETECT); if(gpio_pin_state(RADIO_GPIO_BB_DETECT) != 0) { bufferPrintf("radio: comm board not present, powered on, or at+xdrv=10,2 had been issued.\r\n"); return -1; } bufferPrintf("radio: comm board detected.\r\n"); if(!radio_wait_for_ok(10)) { bufferPrintf("radio: no response from baseband!\r\n"); return -1; } bufferPrintf("radio: setting speed to 750000 baud.\r\n"); radio_write("at+ipr=750000\r\n"); // wait a millisecond for the command to totally clear uart // I wasn't able to detect this condition with uart registers (looking at FIFO count, transmitter empty) udelay(1000); uart_set_baud_rate(RADIO_UART, 750000); if(!radio_wait_for_ok(10)) { bufferPrintf("radio: no response from baseband!\r\n"); return -1; } RadioAvailable = TRUE; bufferPrintf("radio: ready.\r\n"); speaker_setup(); return 0; }
int gpio_setup() { uint8_t v[9]; if (!(GET_REG(POWERID) & 1)) { gpio_pin_use_as_input(0x107); gpio_pin_use_as_input(0x106); gpio_pin_use_as_input(0x105); gpio_pin_use_as_input(0x104); gpio_pin_use_as_input(0x103); gpio_pin_use_as_input(0x102); gpio_pin_use_as_input(0x101); gpio_pin_use_as_input(0x100); udelay(50); v[0] = CHIPID_GET_GPIO(chipid_get_gpio()); v[1] = gpio_pin_state(0x104); v[2] = gpio_pin_state(0x105); v[3] = gpio_pin_state(0x106); v[4] = gpio_pin_state(0x107); v[5] = gpio_pin_state(0x100); v[6] = gpio_pin_state(0x101); v[7] = gpio_pin_state(0x102); v[8] = gpio_pin_state(0x103); gpio_pin_reset(0x107); gpio_pin_reset(0x106); gpio_pin_reset(0x105); gpio_pin_reset(0x104); gpio_pin_reset(0x103); gpio_pin_reset(0x102); gpio_pin_reset(0x101); gpio_pin_reset(0x100); uint32_t new_status = ((v[0] << 3 | v[1] << 2 | v[2] << 1 | v[3]) << 16) | ((v[4] << 3 | v[5] << 2 | v[6] << 1 | v[7]) << 8) | 1; SET_REG(POWERID, (GET_REG(POWERID) & 0xFF000000) | (new_status & 0xFFFFFF)); } return 0; }
int radio_setup_3g() { gpio_pulldown_configure(RADIO_BB_PULLDOWN, GPIOPDDown); pmu_gpio(RADIO_GPIO_BB_ON, TRUE, OFF); udelay(100000); gpio_pin_output(RADIO_GPIO_RADIO_ON, ON); udelay(100000); gpio_pin_output(RADIO_GPIO_BB_RESET, ON); udelay(100000); gpio_pin_output(RADIO_GPIO_BB_RESET, OFF); udelay(100000); gpio_pin_use_as_input(RADIO_GPIO_RESET_DETECT); if(gpio_pin_state(RADIO_GPIO_RESET_DETECT) != 1) { bufferPrintf("radio: comm board not present, powered on, or at+xdrv=10,2 had been issued.\r\n"); return -1; } bufferPrintf("radio: comm board detected.\r\n"); if(!radio_wait_for_ok(10)) { bufferPrintf("radio: no response from baseband!\r\n"); return -1; } RadioAvailable = TRUE; bufferPrintf("radio: ready.\r\n"); speaker_setup(); return 0; }