Am using a platform driver to access the external memory interface (EIM). In this kernel driver I want to write to RGMII_RD1 pin to trigger RESET_OUT from Kernel space, but I don’t know how to access it.
According to GPIO access from kernel space I can use the API of
int gpio_request(unsigned int gpio, const char *label); void gpio_free(unsigned int gpio); int gpio_direction_input(unsigned int gpio); int gpio_direction_output(unsigned int gpio, int value); int gpio_get_value(unsigned int gpio); void gpio_set_value(unsigned int gpio, int value);
According to GPIO in the kernel: an introduction
In current kernels, every GPIO in the system is represented by a simple unsigned integer. There is no provision for somehow mapping a desired function (“the sensor power line for the first camera device,” say) onto a GPIO number; the code must come by that knowledge by other means. Often that is done through a long series of macro definitions; it is also possible to pass GPIO numbers through platform data or a device tree.
How can I find out the GPIO number using the device tree?
I know that I can get custom properties from the device tree using the API of
int of_property_read_u32_index(const struct device_node *np, const char *propname, u32 index, u32 *out_value)
I know that RGMII_RD1 is pin 27 on the gpio6 bank. But neither know how to read this information from the device tree, nor do I know how to convert this information into the “simple unsigned integer” representing this GPIO.