diff options
Diffstat (limited to 'bus.c')
-rw-r--r-- | bus.c | 60 |
1 files changed, 37 insertions, 23 deletions
@@ -83,13 +83,13 @@ static void util_unmapmemoryblock(void* block, size_t len) } } -static void pinmux_configurepin(char* pin, int option, int mode) +static void pinmux_configurepin(char* pin, int options_and_mode) { char path[256]; snprintf(path, sizeof(path), "/sys/kernel/debug/omap_mux/%s", pin); FILE* node = fopen(path, "w"); if (node != NULL) { - fprintf(node, "0x%02x\n", (((option << 3) | mode) & 0xff)); + fprintf(node, "0x%02x\n", (options_and_mode & 0xff)); fclose(node); } else { printf("Failed to configure pin %s (%s)\n", pin, path); @@ -161,30 +161,44 @@ static void gpmc_printinfo() #define RDCYCLETIME 0 #define WRACCESSTIME 24 +#define BIDIR 0x20 +#define PULL_UP 0x10 +#define PULL_DOWN 0x00 +#define NO_PULL 0x80 +#define MODE_0 0x00 +#define MODE_1 0x01 +#define MODE_2 0x02 +#define MODE_3 0x03 +#define MODE_4 0x04 +#define MODE_5 0x05 +#define MODE_6 0x06 +#define MODE_7 0x07 + + static void gpmc_setup(int chipselect, int accesscycles, int size, bool enablecs, int baseaddress) { - pinmux_configurepin("gpmc_csn0", 0x0, 0x0); - pinmux_configurepin("gpmc_oen_ren", 0x0, 0x0); - pinmux_configurepin("gpmc_wen", 0x0, 0x0); - - pinmux_configurepin("gpmc_ad7", 0x6, 0x0); - pinmux_configurepin("gpmc_ad6", 0x6, 0x0); - pinmux_configurepin("gpmc_ad5", 0x6, 0x0); - pinmux_configurepin("gpmc_ad4", 0x6, 0x0); - pinmux_configurepin("gpmc_ad3", 0x6, 0x0); - pinmux_configurepin("gpmc_ad2", 0x6, 0x0); - pinmux_configurepin("gpmc_ad1", 0x6, 0x0); - pinmux_configurepin("gpmc_ad0", 0x6, 0x0); - - pinmux_configurepin("lcd_data0", 0x0, 0x1); - pinmux_configurepin("lcd_data1", 0x0, 0x1); - pinmux_configurepin("lcd_data2", 0x0, 0x1); - pinmux_configurepin("lcd_data3", 0x0, 0x1); - pinmux_configurepin("lcd_data4", 0x0, 0x1); - pinmux_configurepin("lcd_data5", 0x0, 0x1); - pinmux_configurepin("lcd_data6", 0x0, 0x1); - pinmux_configurepin("lcd_data7", 0x0, 0x1); + pinmux_configurepin("gpmc_csn0", PULL_UP | MODE_0); + pinmux_configurepin("gpmc_oen_ren", PULL_UP | MODE_0); + pinmux_configurepin("gpmc_wen", PULL_UP | MODE_0); + + pinmux_configurepin("gpmc_ad7", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad6", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad5", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad4", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad3", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad2", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad1", BIDIR | PULL_UP | MODE_0); + pinmux_configurepin("gpmc_ad0", BIDIR | PULL_UP | MODE_0); + + pinmux_configurepin("lcd_data0", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data1", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data2", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data3", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data4", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data5", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data6", PULL_UP | MODE_1); + pinmux_configurepin("lcd_data7", PULL_UP | MODE_1); int displacement = GPMC_CHIPSELECTCONFIGDISPLACEMENT * chipselect; |