void lcd_enable(void) { if (lcd_disabled) { lcd_ctrl_init(lcd_set_base); } gpio_pin_init(36, GPIO_OUTPUT, 1); // Wait one ms before sending down SPI init sequence udelay(1000); MUX_VAL(CP(McBSP1_CLKR), (OFF_IN_PD | IEN | PTD | DIS | M4)) /*McSPI4-CLK*/ \ MUX_VAL(CP(McBSP1_DX), (OFF_IN_PD | IDIS | PTD | DIS | M4)) /*McSPI4-SIMO*/ \ MUX_VAL(CP(McBSP1_DR), (OFF_IN_PD | IEN | PTD | DIS | M4)) /*McSPI4-SOMI*/\ MUX_VAL(CP(McBSP1_FSX), (OFF_IN_PD | IEN | PTU | DIS | M4)) /*McSPI4-CS0*/ gpio_pin_init(GPIO_SPI_CLK,GPIO_OUTPUT,1); gpio_pin_init(GPIO_SPI_SIMO,GPIO_OUTPUT,1); gpio_pin_init(GPIO_SPI_CS,GPIO_OUTPUT,1); gpio_pin_init(GPIO_SPI_SOMI,GPIO_INPUT,1); boxer_init_panel(); omap3_dss_enable(); enable_backlight(); lcd_disabled = 0; }
void spi_panel_chipsel(int cs) { if (cs) { gpio_pin_init(GPIO_SPI_CS,0,0); } else { SPI_DELAY; gpio_pin_init(GPIO_SPI_CS,0,1); } }
void enable_backlight(void) { DECLARE_GLOBAL_DATA_PTR; u32 l; sr32(CM_CLKSEL_PER, 6, 1, 0x0); /* CLKSEL = 32Khz */ sr32(CM_FCLKEN_PER, 9, 1, 0x1); /* FCLKEN GPT8 */ sr32(CM_ICLKEN_PER, 9, 1, 0x1); /* ICLKEN GPT8 */ udelay(200); /*start with a random brightness which consumes less than 500mA such that we will gain current into battery even when display is showing UI image*/ lcd_adjust_brightness(40); gpio_pin_init(GPIO_BACKLIGHT_EN_EVT2, GPIO_OUTPUT, 0); }
void pen_irq_status(void) { U32 pen; U32 old_pen = 0; U32 first = 1; U32 initTimeval; U32 finTimeval; U32 secondsElapsed = 0; volatile U32 *sync32khzClk; S32 ret_val; ret_val = touch_screen_init((U32) & ts_device_handle); gpio_pin_init(GPIO_PENIRQ, 1); sync32khzClk = CLK32K_COUNTER_REGISTER; initTimeval = *sync32khzClk; while (secondsElapsed <= TS_TIMEOUT) { finTimeval = *sync32khzClk; secondsElapsed = ((finTimeval - initTimeval) * 31 / 1000000); pen = get_gpio_input(GPIO_PENIRQ); if (first) { old_pen = pen; } if ((first == 0) && (old_pen == pen)) { continue; } else { old_pen = pen; if (pen) { printf("Up\t"); } else { printf("Down"); } } first = 0; } }
int gpio_Platform_VerProbe(void) { int ii; if(!gpio_Platform_rawbufflg) { gpio_Platform_rawbufflg = !gpio_Platform_rawbufflg; gpio_conf_t ProbeIO[] = { {1, 3, GPIO_DIR_IN, GPIO_PIN_HIGH}, {0, 7, GPIO_DIR_IN, GPIO_PIN_HIGH}, }; unsigned int tmpValue = 0; for(ii = 0; ii < ARRAY_SIZE(ProbeIO); ii ++) { gpio_pin_init(ProbeIO[ii]); } udelay(1000); //Delay to Wait Input Signal Level Stable; for(ii = 0; ii < ARRAY_SIZE(ProbeIO); ii ++) { tmpValue <<= 1; if(gpio_get_pin(ProbeIO[ii].grp, ProbeIO[ii].pin) == GPIO_PIN_HIGH) { tmpValue += 1; } } gpio_Platform_rawbufval = tmpValue; printk("\nGPIO_PROBE_VALUE : 0x%08X\n", gpio_Platform_rawbufval); } switch(gpio_Platform_rawbufval) { case 0x01: return GPIO_PROBE_VER0; case 0x00: return GPIO_PROBE_VER1; case 0x03: return GPIO_PROBE_VER2; } return GPIO_PROBE_VER0; }
void diag_ts_prod_test(void) { U32 ret_val; U32 initTimeval; U32 finTimeval; U32 secondsElapsed; volatile U32 *sync32khzClk; U16 prev_x_co_ord = 0; U16 prev_y_co_ord = 0; U8 sample_count = 0; U8 first_time = 1; static U8 pen_pos_buffer[4] = { 0, 0, 0, 0 }; U32 len; static U16 x = 0, y = 0; sync32khzClk = CLK32K_COUNTER_REGISTER; initTimeval = *sync32khzClk; /*Initialise ts and get the device handle */ ret_val = touch_screen_init((U32) & ts_device_handle); // init pen irq line as i/p gpio_pin_init(GPIO_PENIRQ, 1); fprintf(stdout, "\tTouchScreen Test:\n\r"); fprintf(stdout, "\tTouch at %d different positions:\n\r", TS_SAMPLES_TO_READ); /* Mark start time for timeout timer. */ finTimeval = *sync32khzClk; secondsElapsed = ((finTimeval - initTimeval) * 31 / 1000000); first_time = 1; sample_count = 0; /* Start waiting for Pen down and ADC value */ while (secondsElapsed <= TS_TIMEOUT) { udelay(ONE_MILLISEC); // wait till pen is down while (get_gpio_input(GPIO_PENIRQ)) ; udelay(HUNDRED_MILLISEC); if (ts_pen_pos((U32) & ts_device_handle, &len, &pen_pos_buffer[0]) == SUCCESS) { x = pen_pos_buffer[0] | (pen_pos_buffer[1] << 8); y = pen_pos_buffer[2] | (pen_pos_buffer[3] << 8); /* Bounds checking */ if ((x >= 240) || (y >= 320)) { fprintf(stdout, "Invalid Pen position\n"); continue; } else if (first_time) { prev_x_co_ord = x; prev_y_co_ord = y; } /* Is pen still at the same place ? */ else if ((prev_x_co_ord == x) && (prev_y_co_ord == y)) { continue; } fprintf(stdout, "Current Pen Position:[x y]=[%u %u]\n\r", x, y); first_time = 0; prev_x_co_ord = x; prev_y_co_ord = y; sample_count++; if (sample_count >= TS_SAMPLES_TO_READ) { fprintf(stdout, "TouchScreen Test is Passed\t\n"); return; } udelay(ONE_MILLISEC); // wait for pen go Up while (get_gpio_input(GPIO_PENIRQ) == 0) ; udelay(ONE_MILLISEC); } // upadate the time elapsed finTimeval = *sync32khzClk; secondsElapsed = ((finTimeval - initTimeval) * 31 / 1000000); } fprintf(stdout, "TouchScreen Test is Timed out\t\n"); fprintf(stdout, "Failed to get %d samples from Touchscreen\t\n", TS_SAMPLES_TO_READ); fprintf(stdout, "TouchScreen Test is Failed\t\n"); }
int misc_init_r(void) { DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_DRIVER_OMAP34XX_I2C unsigned char data; printf("Hardware arch: %s rev: %s\n", arch_string(gd->bd->bi_arch_number), rev_string(gd->bd->bi_board_revision)); extern int twl4030_init_battery_charging(void); i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE); (void) twl4030_usb_init(); twl4030_power_reset_init(); /* see if we need to activate the power button startup */ #if defined(CONFIG_3621EVT1A) /* turn on long pwr button press reset*/ data = 0x40; i2c_write(0x4b, 0x46, 1, &data, 1); printf("Power Button Active\n"); printf("Keep TP in reset \n"); gpio_pin_init(46, GPIO_OUTPUT, GPIO_HIGH); printf("Keep Audio codec under reset \n"); gpio_pin_init(37, GPIO_OUTPUT, GPIO_LOW); printf("Power on Audio codec\n"); gpio_pin_init(103, GPIO_OUTPUT, GPIO_HIGH); printf("Take TP out of reset \n"); gpio_pin_init(46, GPIO_OUTPUT, GPIO_LOW); #endif char *s = getenv("pbboot"); if (s) { /* figure out why we have booted */ i2c_read(0x4b, 0x3a, 1, &data, 1); /* if status is non-zero, we didn't transition * from WAIT_ON state */ if (data) { printf("Transitioning to Wait State (%x)\n", data); /* clear status */ data = 0; i2c_write(0x4b, 0x3a, 1, &data, 1); /* put PM into WAIT_ON state */ data = 0x01; i2c_write(0x4b, 0x46, 1, &data, 1); /* no return - wait for power shutdown */ while (1) {;} } printf("Transitioning to Active State (%x)\n", data); /* turn on long pwr button press reset*/ data = 0x40; i2c_write(0x4b, 0x46, 1, &data, 1); printf("Power Button Active\n"); } #endif tps65921_keypad_init(); dieid_num_r(); return (0); }