[U-Boot] [PATCH 0/3] dm: add dev_get_reg() for getting device node's reg

Stephen Warren
2015-12-16T18:53:50Z

On 12/15/2015 09:32 AM, Przemyslaw Marczak wrote:
> commit: dm: core: Enable optional use of fdt_translate_address()
>
> enables device's bus/child address translation method, depending
> on bus 'ranges' property and including child 'reg' property.
> This change makes impossible to decode the 'reg' for node with
> '#size-cells' equal to 0.
>
> Such case is possible by the specification and is also used in U-Boot,
> e.g. by I2C uclass or S5P GPIO - the last one is broken at present.

Can you please explain the problem you're seeing in more detail? Without
any context, my initial reaction is that this is simply a bug somewhere.
That bug should be fixed, rather than introducing new APIs to hide the
problem.

> For this purpose this patch set introduces new core function:
> fdt_addr_t dev_get_reg(struct udevice *dev)
> which returns the 'reg' value in the same way as previously dev_get_addr().
>
> This fixes s5p gpio driver and booting issue on few Exynos based boards:
> - Trats2
> - Odroid U3/X2

Looking at arch/arm/dts/exynos4412-trats2.dts, I see the following:

i2c at 138d0000 {
samsung,i2c-sda-delay = <100>;
samsung,i2c-slave-addr = <0x10>;
samsung,i2c-max-bus-freq = <100000>;
status = "okay";

max77686_pmic at 09 {
compatible = "maxim,max77686";
interrupts = <7 0>;
reg = <0x09 0 0>;

Is that the node you're having problems with? If so, I believe this may
simply be due to invalid DT content. In exynos4.dtsi, that i2c node is
defined as:

i2c at 138d0000 {
#address-cells = <1>;
#size-cells = <0>;

Thus, any reg property in a child of that node must only contain a
single cell (the sum of #address-cells and #size-cells in the parent).
Does fixing the DT so it's valid solve your issue at all?