static void spi_enable(bool en) { imx233_pinctrl_set_gpio(1, 9, en); imx233_pinctrl_set_gpio(1, 10, en); imx233_pinctrl_set_gpio(1, 11, en); imx233_pinctrl_enable_gpio(1, 9, en); imx233_pinctrl_enable_gpio(1, 10, en); imx233_pinctrl_enable_gpio(1, 11, en); mdelay(1); }
bool _backlight_init(void) { imx233_pinctrl_acquire(0, 10, "backlight_enable"); imx233_pinctrl_set_function(0, 10, PINCTRL_FUNCTION_GPIO); imx233_pinctrl_enable_gpio(0, 10, true); imx233_pinctrl_set_gpio(0, 10, true); _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING); return true; }
// enable/disable the speaker audio gate (typically using a GPIO) void __attribute__((weak)) imx233_audio_enable_spkr(bool en) { #ifdef IMX233_AUDIO_SPKR_GATE_BANK # ifdef IMX233_AUDIO_SPKR_GATE_INVERTED en = !en; # endif imx233_pinctrl_set_gpio(IMX233_AUDIO_SPKR_GATE_BANK, IMX233_AUDIO_SPKR_GATE_PIN, en); #else (void) en; #endif }
void imx233_system_prepare_shutdown(void) { /* wait a bit, useful for the user to stop touching anything */ sleep(HZ / 2); /* disable watchdog just in case since we will disable interrupts */ imx233_rtc_enable_watchdog(false); /* disable interrupts, it's probably better to avoid any action so close * to shutdown */ disable_interrupt(IRQ_FIQ_STATUS); #ifdef SANSA_FUZEPLUS /* This pin seems to be important to shutdown the hardware properly */ imx233_pinctrl_acquire(0, 9, "power off"); imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO); imx233_pinctrl_enable_gpio(0, 9, true); imx233_pinctrl_set_gpio(0, 9, true); #endif }
void _backlight_set_brightness(int level) { #if defined(CREATIVE_ZENXFISTYLE) imx233_pwm_setup_simple(4, 24000, level); imx233_pwm_enable(4, true); #elif defined(CREATIVE_ZENV) lcd_set_contrast(level); #else unsigned val = (level + 200) * level / 1000; if(level != 0) { for(unsigned mask = 0x10; mask; mask >>= 1) imx233_uartdbg_send((val & mask) ? 0xff : 0xf8); imx233_uartdbg_send(0); imx233_pinctrl_set_gpio(1, 12, true); } else
static void lcd_power(bool en) { imx233_pinctrl_set_gpio(1, 8, en); mdelay(10); }
void lcd_init_device(void) { // determine power type imx233_pinctrl_acquire(3, 16, "lcd power kind"); imx233_pinctrl_set_function(3, 16, PINCTRL_FUNCTION_GPIO); imx233_pinctrl_enable_gpio(3, 16, false); udelay(10); lcd_has_power = !imx233_pinctrl_get_gpio(3, 16); if(lcd_has_power) { imx233_pinctrl_acquire(0, 27, "lcd power"); imx233_pinctrl_set_function(0, 27, PINCTRL_FUNCTION_GPIO); imx233_pinctrl_enable_gpio(0, 27, true); imx233_pinctrl_set_gpio(0, 27, true); } // determine kind (don't acquire pin because it's a lcdif pin !) imx233_pinctrl_set_function(1, 0, PINCTRL_FUNCTION_GPIO); imx233_pinctrl_enable_gpio(1, 0, false); udelay(10); lcd_kind = imx233_pinctrl_get_gpio(1, 0); imx233_lcdif_init(); imx233_lcdif_reset_lcd(false); imx233_lcdif_reset_lcd(true); imx233_lcdif_setup_system_pins(16); imx233_lcdif_set_timings(2, 2, 2, 2); imx233_lcdif_set_word_length(8); // set mux ratio lcd_send(false, 0xca); lcd_send(true, 131); // set remap, color and depth lcd_send(false, 0xa0); lcd_send(true, 0x74); // set master contrast lcd_send(false, 0xc7); lcd_send(true, 0x8); // set V_COMH lcd_send(false, 0xbe); lcd_send(true, lcd_kind ? 0x1c : 0x18); // set color contrasts lcd_send(false, 0xc1); lcd_send(true, 0x7b); lcd_send(true, 0x69); lcd_send(true, lcd_kind ? 0xcf : 0x9f); // set timings lcd_send(false, 0xb1); lcd_send(true, 0x1f); lcd_send(false, 0xb3); lcd_send(true, 0x80); // set precharge voltages lcd_send(false, 0xbb); lcd_send(true, 0x00); lcd_send(true, 0x00); lcd_send(true, 0x00); // set master config lcd_send(false, 0xad); lcd_send(true, 0x8a); // set power saving mode lcd_send(false, 0xb0); lcd_send(true, 0x00); // set normal display (seem to be a SSD1338 only command, not present in SS1339 datasheet) lcd_send(false, 0xd1); lcd_send(true, 0x02); // set LUT lcd_send(false, 0xb8); static uint8_t lut[32] = { 0x01, 0x15, 0x19, 0x1D, 0x21, 0x25, 0x29, 0x2D, 0x31, 0x35, 0x39, 0x3D, 0x41, 0x45, 0x49, 0x4D, 0x51, 0x55, 0x59, 0x5D, 0x61, 0x65, 0x69, 0x6D, 0x71, 0x75, 0x79, 0x7D, 0x81, 0x85, 0x89, 0x8D }; for(int i = 0; i < 32; i++) lcd_send(true, lut[i]); // set display offset (this lcd is really wired strangely) lcd_send(false, 0xa2); lcd_send(true, 128); // normal display lcd_send(false, 0xa6); // sleep mode off lcd_send(false, 0xaf); // write ram lcd_send(false, 0x5c); imx233_lcdif_set_word_length(16); for(int y = 0; y < LCD_HEIGHT; y++) for(int x = 0; x < LCD_WIDTH; x++) { uint16_t v = 0; imx233_lcdif_pio_send(true, 1, &v); } #ifdef HAVE_LCD_ENABLE lcd_on = true; #endif }
static void i2c_sda_out(bool high) { imx233_pinctrl_set_gpio(1, 24, high); }