#include #include #define OMAP3_GPIO1_BASE 0x48310000 #define OMAP3_GPIO2_BASE 0x49050000 #define OMAP3_GPIO3_BASE 0x49052000 #define OMAP3_GPIO4_BASE 0x49054000 #define OMAP3_GPIO5_BASE 0x49056000 #define OMAP3_GPIO6_BASE 0x49058000 #define OMAP3_GPIO_OE 0x34 #define OMAP3_GPIO_DATOUT 0x3C #define OMAP3_GPIO_CLEARDATAOUT 0x90 #define OMAP3_GPIO_SETDATAOUT 0x94 #define LED0 149 #define LED1 150 u32 gpio_bank_addr[] = {OMAP3_GPIO1_BASE, OMAP3_GPIO2_BASE, OMAP3_GPIO3_BASE, OMAP3_GPIO4_BASE, OMAP3_GPIO5_BASE, OMAP3_GPIO6_BASE}; static void setmem32(u32 reg_addr, u32 val) { u32 *rp; rp = (u32 *)reg_addr; *rp = val; } static void setmem16(u32 reg_addr, u16 val) { u32 *rp; rp = (u32 *)reg_addr; *rp = *rp & 0xFFFF0000; *rp = *rp | val; } //This function use to set the flag static void setbit(u32 reg_addr, u32 bit_num) { u32 set_value = 0x00000001; set_value <<= bit_num; printf ("Set Value: %d\n", set_value); setmem32(reg_addr, set_value); } /* Not work struct pin_map get_gpio_bank(int pin_num) { struct pin_map gpio_temp; gpio_temp.gpio_bank = pin_num / 32; gpio_temp.gpio_pin = pin_num % 32; return gpio_temp; }*/ static void clear_pin(u32 pin_num) { printf ("Clear Pin %d \n", pin_num); /* Not work struct pin_map gpio_temp; u32 reg_addr, bit_num; gpio_temp = get_gpio_bank(pin_num); printf ("This pin is at bank: %d , at bit: %d \n",gpio_temp.gpio_bank,gpio_temp.gpio_pin); reg_addr = gpio_bank_addr[gpio_temp.gpio_bank]; reg_addr |= OMAP3_GPIO_CLEARDATAOUT; bit_num = gpio_temp.gpio_pin; setbit(reg_addr,bit_num); */ } int test_gpio(int argc, char *argv[]) { /* Print the ABI version */ app_startup(argv); printf ("Example expects ABI version %d\n", XF_VERSION); printf ("Actual U-Boot ABI version %d\n", (int)get_version()); printf ("Test GPIO\n"); clear_pin(LED0); clear_pin(LED1); printf ("Hit any key to exit ... "); while (!tstc()) ; /* consume input */ (void) getc(); printf ("\n\n"); return (0); }