FAQ: [#6107] requesting spi0 pins overflows map arrays on bf51x(2010)

Document created by Aaronwu Employee on Sep 11, 2013
Version 1Show Document
  • View in full screen mode

[#6107] requesting spi0 pins overflows map arrays on bf51x

Submitted By: Mike Frysinger

Open Date

2010-07-11 19:49:25     Close Date

2010-08-07 01:19:19

Priority:

High     Assignee:

Michael Hennerich

Status:

Closed     Fixed In Release:

N/A

Found In Release:

2009R1.1-RC4     Release:

Category:

N/A     Board:

N/A

Processor:

BF518     Silicon Revision:

Is this bug repeatable?:

Yes     Resolution:

Fixed

Uboot version or rev.:

    Toolchain version or rev.:

trunk

App binary format:

N/A     

Summary: requesting spi0 pins overflows map arrays on bf51x

Details:

 

this bug seems to have been around for a while, and doesnt seem to be specific to the bf51x as it'll happen on any part that has a partial bank of peripherals.  it's just easiest to replicate with that.

 

booting up the BF518F-EZBRD_defconfig results in:

root:/> cat /proc/gpio

GPIO_1:         UNKNOWN                 GPIO INPUT

GPIO_2:         UNKNOWN                 GPIO INPUT

GPIO_3:         UNKNOWN                 GPIO INPUT

GPIO_8:         bfin_mac                Peripheral

GPIO_9:         bfin_mac                Peripheral

GPIO_10:        bfin_mac                Peripheral

GPIO_11:        bfin_mac                Peripheral

GPIO_12:        bfin_mac                Peripheral

GPIO_13:        bfin_mac                Peripheral

GPIO_14:        bfin_mac                Peripheral

GPIO_15:        bfin_mac                Peripheral

GPIO_16:        bfin_mac                Peripheral

GPIO_18:        bfin_mac                Peripheral

GPIO_25:        bfin-uart               Peripheral

GPIO_26:        bfin-uart               Peripheral

GPIO_27:        ParaFlash               Peripheral

GPIO_28:        bfin-spi                Peripheral

GPIO_29:        bfin-spi                Peripheral

GPIO_30:        bfin-spi                Peripheral

GPIO_33:        bfin-spi                Peripheral

GPIO_34:        bfin-spi                Peripheral

GPIO_35:        bfin-spi                Peripheral

 

those first three items are interesting because they shouldnt be there.  looking closer, it's because the peripheral map is declared with length gpio_bank(MAX_RESOURCES), but that does integer division.  so on the bf51x, we have:

gpio_bank(MAX_RESOURCES) -> (41 >> 4) -> 2

 

but that doesnt take into account the partial third bank which means requesting any of the PH pins results in indexing peri[2] (the 3rd entry) when the array is only 2 entries long.  and so we end up scribbling on top of the gpio_irq reserved map array.

 

we probably want the bfin_gpio.c code to read:

-DECLARE_RESERVED_MAP(peri, gpio_bank(MAX_RESOURCES));

+DECLARE_RESERVED_MAP(peri, DIV_ROUND_UP(MAX_RESOURCES, GPIO_BANKSIZE));

 

or if you want to declare a new define in portmux.h like the GPIO_BANK_NUM:

#define PERIPHERAL_BANK_NUM DIV_ROUND_UP(MAX_RESOURCES, GPIO_BANKSIZE)

 

either way, changing the array size fixed the /proc/gpio output for me

 

Follow-ups

 

--- Zhi Qiang Zhang                                          2010-07-12 21:50:51

The MAX_RESOURCES on bf518 is 40, not 41. And I found no DECLARE_RESERVED_MAP in

Version: 2009R1.1.

 

--- Michael Hennerich                                        2010-07-13 04:27:35

Fixed on: branch 2009R1 & trunk

 

 

 

 

    Files

    Changes

    Commits

    Dependencies

    Duplicates

    Associations

    Tags

 

File Name     File Type     File Size     Posted By

No Files Were Found

Attachments

    Outcomes