Re: [PATCH v2 4/4] ARM: dts: mt8135: Add pinctrl node for mt8135.
From: Sascha Hauer <hidden>
Date: 2014-10-06 07:19:18
Also in:
linux-arm-kernel, lkml
On Thu, Oct 02, 2014 at 04:02:58PM +0200, Linus Walleij wrote:
On Wed, Sep 24, 2014 at 2:40 PM, Sascha Hauer [off-list ref] wrote:quoted
On Wed, Sep 24, 2014 at 01:23:09PM +0200, Linus Walleij wrote:quoted
quoted
I haven't got to reviewing the driver, but this looks just wrong. Have the magic numbers in the driver. Use strings to describe functions, not integers.Interrupts, clocks, gpios, dma channels, nearly everything in the device tree is arbitrarily numbered. Instead of "irq-i2c0" we have <0 36 IRQ_TYPE_LEVEL_HIGH> in the device tree. These numbers can be resolved efficiently in the driver by shifting them to get a bitmask or by adding them as offset to a register base. Why do you want to make pinctrl different?Because pin control is about combining groups of pins with certain functions.quoted
Thanks to the recently introduced defines in the device trees these numbers are not magic at all anymore.Yeah that is good but not what I'm after here.quoted
quoted
We need to move toward standardized device tree bindings for this stuff, and that means using strings, not magic numbers.Agreed for standardized device tree bindings, but not for using strings.What is the alternative? Device Tree is very much about strings, as is shown by the pin config bindings.
The alternative is to use numbers. The majority of SoCs have a bit field per pad which is used for muxing the pad to different functions. The natural way to describe this is a pair of numbers: <pad-number> <function-number>. The pad number can normally be directly translated into a register offset and the function number to a value written to that register. This is true for most SoCs I know of and makes it very easy to generate code for and to prove for correctness of both the code and the device tree. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html