2 * File: Documentation/blackfin/bfin-gpio-notes.txt
6 * Created: $Id: bfin-gpio-note.txt 2008-11-24 16:42 grafyang $
7 * Description: This file contains the notes in developing/using bfin-gpio.
13 * Copyright 2004-2008 Analog Devices Inc.
15 * Bugs: Enter bugs at http://blackfin.uclinux.org/
20 1. Blackfin GPIO introduction
22 There are many GPIO pins on Blackfin. Most of these pins are muxed to
23 multi-functions. They can be configured as peripheral, or just as GPIO,
24 configured to input with interrupt enabled, or output.
26 For detailed information, please see "arch/blackfin/kernel/bfin_gpio.c",
30 2. Avoiding resource conflict
32 Followed function groups are used to avoiding resource conflict,
33 - Use the pin as peripheral,
34 int peripheral_request(unsigned short per, const char *label);
35 int peripheral_request_list(const unsigned short per[], const char *label);
36 void peripheral_free(unsigned short per);
37 void peripheral_free_list(const unsigned short per[]);
38 - Use the pin as GPIO,
39 int bfin_gpio_request(unsigned gpio, const char *label);
40 void bfin_gpio_free(unsigned gpio);
41 - Use the pin as GPIO interrupt,
42 int bfin_gpio_irq_request(unsigned gpio, const char *label);
43 void bfin_gpio_irq_free(unsigned gpio);
45 The request functions will record the function state for a certain pin,
46 the free functions will clear its function state.
47 Once a pin is requested, it can't be requested again before it is freed by
48 previous caller, otherwise kernel will dump stacks, and the request
50 These functions are wrapped by other functions, most of the users need not
54 3. But there are some exceptions
55 - Kernel permit the identical GPIO be requested both as GPIO and GPIO
57 Some drivers, like gpio-keys, need this behavior. Kernel only print out
58 warning messages like,
59 bfin-gpio: GPIO 24 is already reserved by gpio-keys: BTN0, and you are
60 configuring it as IRQ!
62 Note: Consider the case that, if there are two drivers need the
63 identical GPIO, one of them use it as GPIO, the other use it as
64 GPIO interrupt. This will really cause resource conflict. So if
65 there is any abnormal driver behavior, please check the bfin-gpio
68 - Kernel permit the identical GPIO be requested from the same driver twice.