Hello,
one thing I've found to be really annoying is that while GPIOs can be addressed by "number", their pin muxing must pass through the davinci_cfg_reg that requires an index in a huge pinmux table.
Consider this example: on my board an external LED is driven by GPIO49. Before using the gpio, an entry must be inserted into the pinmux table found in mux_cfg.c:
const struct pin_config __initdata_or_module davinci_dm365_pinmux[] = {
...
MUX_CFG("GPIO49", 0, 23, 1, 0, 0)
...
The position of this entry in the table must correspond exactly to the position of an equal entry in an enum used to calculate (at compile time) the position index (file mux.h):
enum davinci_dm365_index {
...
DM365_GPIO49,
...
This enum value can then be used to enable the specific mux configuration at the same entry:
davinci_cfg_reg(DM365_GPIO49, PINMUX_RESV);
The problem is that DM365_GPIO49 is the index position in the table. This requires to update the enum every time the configuration table is modified, but also makes very difficult to write a driver where GPIO number is configurable at runtime. For example:
modprobe davinci_led.ko ledgpio=49
There is no way to know the index corresponding to GPIO 49 at runtime. So this is my proposal. Adding a function to platform-davinci/mux.c so that entries in the table can be searched using the "name". Something like this:
static int __init_or_module davinci_find_mux_cfg_index(const char *name)
{
int i;
for(i = 0; i < pin_table_sz; i++) {
if(!strcmp(name, pin_table[i].name))
return i;
}
return -1;
}
EXPORT_SYMBOL(find_mux_cfg_index);