Skip to content

Conversation

@Galland
Copy link

@Galland Galland commented Oct 2, 2013

No description provided.

Bugfix's bugfix

sram_gpio_init is called from mach-rk30/board-pmu-tps65910.c with
PMU_POWER_SLEEP (RK30_PIN6_PB1) as first argument. The return is -EINVAL
even though it's a valid pin.

This is caused, in rk3066, by the bad way in which sram_gpio_init checks
against the gpio_base array, taking into account that for RK3066 this
array is missing one element (RK30_GPIO5_BASE, which is ok). This makes
it give wrong results for any pin on GPIO6_BASE, because of this
comparison:
       if(index/NUM_GROUP >= ARRAY_SIZE(gpio_base))

For example:
PMU_POWER_SLEEP = RK30_PIN6_PB1 = 361

Taking the previous line's index calc: index = gpio - PIN_BASE;
Knowing that:
- #define PIN_BASE         NR_GIC_IRQS
- #define NR_GIC_IRQS      (5 * 32)

index = gpio - PIN_BASE = 361 - 5*32 = 201

and then in the if we have:
-  index/NUM_GROUP = 201 / 32 = 6.2 ... = 6
-  ARRAY_SIZE(gpio_base) = 6

which is == to ARRAY_SIZE so RK30_PIN6_* fail here
due to using array_size without a RK30_GPIO5_BASE

Solution entails failing on pins in GPIO5_BASE, but allowing them in
GPIO6, and then pressing the right base into data->base by using index 5
for GPIO6, as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant