2009-01-07 11:32:15     Cannot free SPORT peripheral pins on PORTH

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

2009-01-07 11:32:15     Cannot free SPORT peripheral pins on PORTH

Michael McTernan (UNITED KINGDOM)

Message: 67594   

 

Hi,

 

I think I've found a minor bug in blackfin/kernel/bfin_gpio.c.  The problem is that I request some SPORT lines on a BF537 with peripheral_request_list(), but then they don't get freed with peripheral_free_list().

 

The request is for these lines:

 

unsigned short bfin_char_pin_req_sport0wr[] =

    {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_DTSEC, 0};

...

 

 

if (peripheral_request_list(bfin_char_pin_req_sport0wr, "bf5xx-sportdev")) {

   ...

 

That all works fine and I can see they are taken in /proc/gpio.  After a later call to peripheral_free_list(bfin_char_pin_req_sport0wr), they are still listed in /proc/gpio, and can't be reserved by a different driver.

 

I think the problem is this check in peripheral_free():

 

void peripheral_free(unsigned short per)

{

    unsigned long flags;

    unsigned short ident = P_IDENT(per);

 

    if (per & P_DONTCARE)

        return;

 

    if (!(per & P_DEFINED))

        return;

 

    if (check_gpio(ident) < 0)         return;

 

    local_irq_save_hw(flags);

 

Relevant bits of P_SPORT0_TFS definition:

 

#define P_SPORT0_TFS    (P_DEFINED | P_IDENT(PORT_PJ10) | P_FUNCT(0))

#define PORT_PJ10    (GPIO_PH15 + 11)

#define GPIO_PH15          47

#define MAX_BLACKFIN_GPIOS 48

 

So PORT_PJ10 > MAX_BLACKFIN_GPIOS and peripheral_free() bails when check_gpio() fails, so it doesn't release the pin.

 

This is on the lovely 2008R1.5 branch, but I checked bfin_gpio.c on trunk and think it is still an issue there.

 

Is this a bug, or am I just using the peripheral interface incorrectly?

 

Regards,

 

Mike

QuoteReplyEditDelete

 

 

2009-01-07 15:16:45     Re: Cannot free SPORT peripheral pins on PORTH

Mike Frysinger (UNITED STATES)

Message: 67595   

 

i think you're right we should just drop the check_gpio() call ... will have to wait for Michael to double check though as he's on vacation still ...

QuoteReplyEditDelete

 

 

2009-01-09 08:03:35     Re: Cannot free SPORT peripheral pins on PORTH

Michael McTernan (UNITED KINGDOM)

Message: 67717   

 

Cool, thanks.

 

I've opened a bug so it can be tracked/checked when Michael gets back:

 

https://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=4793

 

Many Thanks, Mike

Attachments

    Outcomes