devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* GPIO and Pinmux device tree support for Exynos.
@ 2011-08-11 18:08 Thomas Abraham
       [not found] ` <CAJuYYwRJ5UJ8OeTEDEh1Mk9yhJGVA7he1EzG8yM+pJYQVo6BXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Abraham @ 2011-08-11 18:08 UTC (permalink / raw)
  To: devicetree-discuss

Hi Grant,

I did some work on the gpio and pinmux device tree support for exynos.
I thought to discuss with you about what was done before proceeding
further.

In the dts file, the interrupt controller node is listed as

GPA: gpio-controller@11400000 {
		compatible = "samsung,exynos4-gpio-gpa0", "samsung,exynos4-gpio";
		#gpio-cells = <4>;
		gpio-controller;
};

The meaning of the 4 cells are as below. The values of all the cells
are set as per the exynos chip specification.

< [GPIO Pin Number]  [Pin-Mux Function Number] [Pull Up/Down Setting]
[Driver Strength Setting] >


Device nodes would include the gpio's that it would use (as in below example)

serial@13800000 {
		compatible = "samsung,s5pv310-uart";
		reg = <0x13800000 0x100>;
		interrupts = <116>;
		gpios = <&GPA  0  2  0  2   /* Tx */
				&GPA  1  2  0  2>;  /* Rx */
};


When the gpio_chip is registered, the corresponding node is searched
in the device tree and attached to the gpio_chip. Along with node
pointer, the of_gpio_n_cells is set to 4 and the of_xlate function is
set to point to the function listed below.

int exynos4_gpio_xlate(struct gpio_chip *gc, struct device_node *np,
			 const void *gpio_spec, u32 *flags)
{
	const __be32 *gpio = gpio_spec;
	const u32 n = be32_to_cpup(gpio);
	unsigned int pin = gc->base + be32_to_cpu(gpio[0]);

	if (gc->of_gpio_n_cells < 4) {
		WARN_ON(1);
		return -EINVAL;
	}

	if (n > gc->ngpio)
		return -EINVAL;

	/* Set PinMux */
	s3c_gpio_cfgpin(pin, be32_to_cpu(gpio[1]));
	/* Set pull up/down */
	s3c_gpio_setpull(pin, be32_to_cpu(gpio[2]));
	/* Set driver strength */
	s5p_gpio_set_drvstr(pin, be32_to_cpu(gpio[3]));

	return n;
}


The above function translates the gpio controller pin number to a
linux gpio number and sets the pinmux, pull up/down and driver
strength values. The device driver uses the of_get_gpio() function to
get the gpio pin number and then calls gpio_request on that gpio
number. The call to of_get_gpio() invokes the gpio translate function
which sets the pinmux, pull up/down and driver strength values.

This handles the gpio and pinmux requirements for exynos. Would this
approach be acceptable?

Thanks,
Thomas.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-08-15 15:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-11 18:08 GPIO and Pinmux device tree support for Exynos Thomas Abraham
     [not found] ` <CAJuYYwRJ5UJ8OeTEDEh1Mk9yhJGVA7he1EzG8yM+pJYQVo6BXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-11 20:06   ` Stephen Warren
     [not found]     ` <74CDBE0F657A3D45AFBB94109FB122FF04AEA24CD9-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-08-11 20:28       ` Mitch Bradley
2011-08-12  7:05       ` Thomas Abraham
     [not found]         ` <CAJuYYwSeq4Sjj4LLR49hwfvSGTyTDYLXCTp0ZB2yQt2F4rfHcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-12 20:07           ` Stephen Warren
     [not found]             ` <74CDBE0F657A3D45AFBB94109FB122FF04AEA24F1D-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-08-13 15:30               ` Shawn Guo
2011-08-13 14:00       ` Shawn Guo
     [not found]         ` <20110813140046.GD7244-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-08-15 15:54           ` Stephen Warren
2011-08-13 15:36   ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).