[Letux-kernel] [PATCH 00/20] A bunch of JZ4730 fixups for letux-kernel

Paul Boddie paul at boddie.org.uk
Mon Dec 21 00:18:11 CET 2020


On Sunday, 20 December 2020 23:13:17 CET H.  Nikolaus Schaller wrote:
> 
> Yes,
> I was just writing a longer mail with my findings but here is the important
> part.
> 
> [    0.047556] vcc: 3300 mV, enabled
> [    0.052047] reg-fixed-voltage regulator at 0: vcc supplying 3300000uV
> [    0.059335] ingenic_gpio_set: off=21, val=1
> [    0.046211] ingenic_gpio_set_value: offset=15, value=1

This is PA15 (related to the DMA controller) being set to high.

> [    0.051614] pinctrl-ingenic 10010000.pin-controller: set pin PA21 to
> output
> [    0.058831] ingenic_config_pin: pin=21, reg=20 set=0

This disables interrupts for PA21.

> [    0.046447] ingenic_config_pin: idx=15, offt=0

This is actually ingenic_set_output_level setting the level of PA15 to low.

> [    0.051098] ingenic_config_pin: regmap update roff=20, bits=00200000
> val=00000000

If I understand this correctly, this is clearing bit 21 in the interrupt 
register.

> [    0.058932] ingenic_config_pin: pin=21, reg=4 set=1

This is setting the direction for PA21 to output.

> [    0.064003] ingenic_config_pin: idx=15, offt=0

Again, PA15 set to low.

> [    0.051087] ingenic_config_pin: regmap update roff=4, bits=00200000
> val=00200000

And this looks like it is setting bit 21 in the direction register, making 
PA21 an output.

> [    0.058856] ingenic_config_pin_function: pin=21, reg=14:10 value=0

Finally, PA21 has its function set to 0 (GPIO).

> [    0.065394] vmmc: 3300 mV, disabled
> [    0.052437] reg-fixed-voltage regulator at 1: vmmc supplying 3300000uV
> 
> ingenic_config_pin is firstly setting the registers 0x20 and 0x04 and then
> setting the pin_function. If that one resets the direction we will not see
> it...

Since you have put trace statements in ingenic_config_pin, we would have seen 
any update to the direction, so I can only deduce that the above was actually 
initiated by ingenic_pinmux_gpio_set_direction which should be able to set the 
direction.

> But - there is something else:
> 
> I have also added (not yet in the snippet above) an ioremap and printk
> before and after updating in ingenic_pinmux_gpio_set_direction().
> 
> This is the initial value from U-Boot.
> 
> [    0.059224] reg: 10010004 28200200
> 
> It is not even changed by initializing the regulator.
> 
> But then it is suddenly reset:
> 
> [    0.435235] ingenic_gpio_get_value: offset=0
> [    0.439918] pinctrl-ingenic 10010000.pin-controller: set pin PA1 to input
> [    0.429403] reg: 10010004 28200200
> [    0.433025] ingenic_config_pin: pin=1, reg=20 set=0
> [    0.438105] ingenic_config_pin: idx=1, offt=0
> [    0.442667] ingenic_config_pin: regmap update roff=20, bits=00000002
> val=00000000
> [    0.432912] ingenic_config_pin: pin=1, reg=4 set=0
> [    0.437924] ingenic_config_pin: idx=1, offt=0
> [    0.442486] ingenic_config_pin: regmap update roff=4, bits=00000002
> val=00000000
> [    0.450202] ingenic_config_pin_function: pin=1, reg=14:10 value=0
> [    0.438978] reg: 10010004 28200200
> [    0.442621] ingenic_gpio_get_value: offset=1
> [    0.447325] pinctrl-ingenic 10010000.pin-controller: set pin PA2 to input
> [    0.454352] reg: 10010004 00000000

Yes, it has happened here.

> [    0.440416] ingenic_config_pin: pin=2, reg=20 set=0
> [    0.445517] ingenic_config_pin: idx=2, offt=0
> [    0.450079] ingenic_config_pin: regmap update roff=20, bits=00000004
> val=00000000
> [    0.457878] ingenic_config_pin: pin=2, reg=4 set=0
> [    0.445321] ingenic_config_pin: idx=2, offt=0
> [    0.449903] ingenic_config_pin: regmap update roff=4, bits=00000004
> val=00000000
> [    0.457623] ingenic_config_pin_function: pin=2, reg=14:10 value=0
> [    0.446383] reg: 10010004 00000000
> [    0.450025] ingenic_gpio_get_value: offset=2
> [    0.454760] pinctrl-ingenic 10010000.pin-controller: set pin PA3 to input
> [    0.461791] reg: 10010004 00000000
> 
> After a while it builds up again to
> 
> [    0.197738] reg: 10010004: 08000200

Right, so bit 21 is ultimately not set, and so PA21 is an input.

> Maybe the regmap is broken...
> Or some parallel process is writing to the wrong address.
> 
> If it is something else it should show itself by different timing.
> But that will really be hard to find without JTAG.
> 
> A first check makes it appear to be reproducible between PA1 and PA2.
> 
> I'll try to confirm in the next days.

One confusing thing is that the output is not written in order. If I sort it, 
we get this:

[    0.438978] reg: 10010004 28200200
[    0.439918] pinctrl-ingenic 10010000.pin-controller: set pin PA1 to input
[    0.440416] ingenic_config_pin: pin=2, reg=20 set=0
[    0.442486] ingenic_config_pin: regmap update roff=4, bits=00000002
               val=00000000
[    0.442621] ingenic_gpio_get_value: offset=1
[    0.442667] ingenic_config_pin: regmap update roff=20, bits=00000002
               val=00000000
[    0.445321] ingenic_config_pin: idx=2, offt=0
[    0.445517] ingenic_config_pin: idx=2, offt=0
[    0.446383] reg: 10010004 00000000

I can't immediately see anything that might reset the register amongst the 
operations performed here. The update bits operation, which is what must be 
used with the JZ4730, should definitely only update the bits, not overwrite 
the register, unless I am seeing right through my mistake.

Paul




More information about the Letux-kernel mailing list