/* * Configure all necessary GPIO pins */ static void gpio_init(void) { /* * Enable power on GPIO. This is not really necessary, because power * on GPIO is enabled on SoC reset. */ lpc178x_periph_enable(LPC178X_SCC_PCONP_PCGPIO_MSK, 1); /* * Configure GPIO pins using the `ea_lpc1788_gpio[]` table */ lpc178x_gpio_config_table(ea_lpc1788_gpio, ARRAY_SIZE(ea_lpc1788_gpio)); #ifdef CONFIG_NR_DRAM_BANKS /* * Configure GPIO pins used for the External Memory Controller (EMC) */ struct lpc178x_gpio_dsc dsc; /* Configure EMC data pins (DQ0..DQ31) */ dsc.port = 3; for (dsc.pin = 0; dsc.pin <= LPC178X_EMC_DATA_PINS; dsc.pin++) lpc178x_gpio_config(&dsc, LPC178X_GPIO_EMC_REGVAL); /* * Configure EMC row/column address pins (A0..A11) and * NOR FLash address pins. */ dsc.port = 4; for (dsc.pin = 0; dsc.pin <= LPC178X_EMC_ADDR_PINS; dsc.pin++) lpc178x_gpio_config(&dsc, LPC178X_GPIO_EMC_REGVAL); #endif }
/* * Configure a set of GPIO pins using the given configuration table. * Returns 0 on success. */ int lpc178x_gpio_config_table( const struct lpc178x_gpio_pin_config *table, unsigned int len) { unsigned int i; int rv; for (i = 0; i < len; i ++) { rv = lpc178x_gpio_config(&table[i].dsc, table[i].regval); if (rv != 0) goto out; } rv = 0; out: return rv; }