aboutsummaryrefslogtreecommitdiff
path: root/Documentation/blackfin/bfin-gpio-notes.txt
blob: d36b01f778b9e450a07a7b49dffab29553faec63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * File:         Documentation/blackfin/bfin-gpio-notes.txt
 * Based on:
 * Author:
 *
 * Created:      $Id: bfin-gpio-note.txt 2008-11-24 16:42 grafyang $
 * Description:  This file contains the notes in developing/using bfin-gpio.
 *
 *
 * Rev:
 *
 * Modified:
 *               Copyright 2004-2008 Analog Devices Inc.
 *
 * Bugs:         Enter bugs at http://blackfin.uclinux.org/
 *
 */


1. Blackfin GPIO introduction

    There are many GPIO pins on Blackfin. Most of these pins are muxed to
    multi-functions. They can be configured as peripheral, or just as GPIO,
    configured to input with interrupt enabled, or output.

    For detailed information, please see "arch/blackfin/kernel/bfin_gpio.c",
    or the relevant HRM.


2. Avoiding resource conflict

    Followed function groups are used to avoiding resource conflict,
    - Use the pin as peripheral,
	int peripheral_request(unsigned short per, const char *label);
	int peripheral_request_list(const unsigned short per[], const char *label);
	void peripheral_free(unsigned short per);
	void peripheral_free_list(const unsigned short per[]);
    - Use the pin as GPIO,
	int bfin_gpio_request(unsigned gpio, const char *label);
	void bfin_gpio_free(unsigned gpio);
    - Use the pin as GPIO interrupt,
	int bfin_gpio_irq_request(unsigned gpio, const char *label);
	void bfin_gpio_irq_free(unsigned gpio);

    The request functions will record the function state for a certain pin,
    the free functions will clear its function state.
    Once a pin is requested, it can't be requested again before it is freed by
    previous caller, otherwise kernel will dump stacks, and the request
    function fail.
    These functions are wrapped by other functions, most of the users need not
    care.


3. But there are some exceptions
    - Kernel permit the identical GPIO be requested both as GPIO and GPIO
    interrut.
    Some drivers, like gpio-keys, need this behavior. Kernel only print out
    warning messages like,
	bfin-gpio: GPIO 24 is already reserved by gpio-keys: BTN0, and you are
configuring it as IRQ!

        Note: Consider the case that, if there are two drivers need the
	identical GPIO, one of them use it as GPIO, the other use it as
	GPIO interrupt. This will really cause resource conflict. So if
	there is any abnormal driver behavior, please check the bfin-gpio
	warning messages.

    - Kernel permit the identical GPIO be requested from the same driver twice.