|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ `9 \' E% c: U: d7 P% |
#include <linux/init.h>) d: t/ A5 Y1 k8 G2 t$ |" W2 L
#include <linux/module.h>% ~# |" L) W4 ]" x
#include <linux/kernel.h>1 f) K0 x8 k$ M' _: [
#include <linux/types.h>* e& m% Y9 o* u$ y# j5 W: E6 x7 F7 g
#include <linux/gpio.h>" d- y& t2 D- u
#include <linux/leds.h>
8 w3 o Y( F+ l9 a1 H#include <linux/platform_device.h>$ A/ w) w9 o; U+ e( Z
$ o# q$ @& a% w# C" h% f
#include <asm/mach-types.h>, I9 R% D- R: `# i9 m) `
#include <asm/mach/arch.h>& Z; u! E V7 j* k
#include <mach/da8xx.h>4 E% F1 s$ v* h3 \% [) A- V1 B y
#include <mach/mux.h>
8 T; D; N, K9 I7 C8 a" {4 `. y K0 s. K# X& w' ^/ j. j& N. S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): m# b! _6 p. q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 d5 G5 a6 O. }9 [" y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% n, b9 ~9 q) a# I' I( ^+ ^ c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 r4 c/ q2 _7 N% P' d5 z$ i% Z
6 ]$ V4 \0 G8 l* m, }9 p1 N
/* assign the tl som board LED-GPIOs*/( ?! i J) h/ Y3 \7 A* \* g
static const short da850_evm_tl_user_led_pins[] = {$ l2 A( M' s5 w1 m& W
/* These pins are definition at <mach/mux.h> file */) g1 i* v% m! P& g/ _# \) C0 I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 A, [. Q+ R$ A( z& i+ q7 W
-1- \4 q" i/ @. }& s) [! X; M
};. L0 A* E6 f4 P3 a7 O/ s& C
+ }. U; A. i D" X4 i3 }
static struct gpio_led da850_evm_tl_leds[] = {
1 q" e: e& f5 {# Z {5 u; v+ { c% Q& ?0 Y5 B: z- f
.active_low = 0,
( u) E' ]0 X+ V# i& H3 J .gpio = DA850_USER_LED0,* T" {4 r) e! y2 r6 J( G6 q. W
.name = "user_led0", {7 s/ g1 ^9 u( t. C `2 H$ L
.default_trigger = "default-on",
1 ]2 f$ Y _# S$ f8 N# m$ @ },
, g: \+ K+ f& Z3 y( w: b" F {" w3 |% Z/ l0 ^: W3 O
.active_low = 0,5 v" f( m, U+ P/ i$ G
.gpio = DA850_USER_LED1," o6 {" R+ s+ N( i9 M$ o
.name = "user_led1",! \( d+ ^9 m Z5 g4 N0 x
.default_trigger = "default-on",
e9 c0 B0 l# C6 Z" s8 k. ?* u2 ` },# W7 k; t3 }- W8 M4 g# Y
{
# r* A" _ Q+ k; r .active_low = 0," v1 ?& {2 o; l, j
.gpio = DA850_USER_LED2,
/ I# G- U8 [' b0 v: c9 _' | .name = "user_led2",- D9 B, L' P% q+ Q$ p$ \# y) {2 a. p' `
.default_trigger = "default-on",' z$ P, W" Y3 ]4 v
},
- E2 `& b4 g& Y; p! X2 [2 ^7 V {
5 n i4 A7 s( I) d .active_low = 0,
6 p4 H5 i E$ x4 m' x6 [ .gpio = DA850_USER_LED3,
2 J2 P( c* U+ @- W- u( b; _$ W# B .name = "user_led3",* u% B: h. J+ \/ k
.default_trigger = "default-on",4 ^" D9 D- ?& f* @. Z
}, }+ l3 Y8 m/ Y4 a% F9 u
};
; B' I# g/ U" [3 Y p$ b, S( L* i# j; L( m/ x+ [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 K6 X/ D7 ?% o3 g6 s( R .leds = da850_evm_tl_leds,
' `& Y1 i* z- z, j s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' ]* a1 l# f5 V W$ `};
( j! |, U+ d8 K( w
4 l, |: v7 T4 _+ Q- Q- Lstatic void led_dev_release(struct device *dev)
& F" {2 V/ R3 F7 f{
- y1 w4 C+ K/ U, u9 P7 j/ T5 _};6 G$ Z1 V, E$ M8 D
6 `9 F6 _6 S! _. i' Y% Sstatic struct platform_device da850_evm_tl_leds_device = {
& h; K$ z$ j' s .name = "leds-gpio",, e6 i4 C6 K! o; V- a
.id = 1,
7 ^$ r. |6 |6 e .dev = {
d+ t- b9 m7 ?: Z% ^. k7 T* e .platform_data = &da850_evm_tl_leds_pdata,
& Z+ N% z% T! e5 H! M3 @) Q .release = led_dev_release,( {" I% w8 y4 Z, {: u9 A0 ]0 D
}
: u4 s4 p, |0 w! y& }) B};% I9 b3 R$ n/ a3 O1 h: e. o
& |' K: T0 _. q! U
static int __init led_platform_init(void)
3 a0 l" T2 p0 D# h% f{: N* g: _: K. m7 P& C7 |0 k4 o
int ret;
7 @' ~3 D6 Y- }" l2 q; J, k#if 0
' Y( H- m; o7 }- J" B. ^# x" r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 N; p, d. A* P" P7 _0 @# s7 _) V
if (ret)( L% {/ [4 g1 |+ t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 J2 g* H( O4 C. c "%d\n", ret);
: [9 K0 z! ?) ]) d/ `#endif9 B4 G" R6 c/ Y
ret = platform_device_register(&da850_evm_tl_leds_device);( l% w: _4 c4 d5 f( ^- o) I) Q% ?7 t
if (ret)
I, x7 S# C& T L pr_warning("Could not register som GPIO expander LEDS");+ V9 x1 B7 i' T3 o
else
, d/ f5 U$ F# Y6 x3 H% B/ b printk(KERN_INFO "LED register sucessful!\n");$ w2 [9 X) ~1 F/ f
. g9 P9 z" M3 {9 }6 X! z return ret;
. P! c- [4 J( d* A1 N; x}2 | T* U O: v
# {: N+ `8 R/ w6 D, m
static void __exit led_platform_exit(void)( e' |! M9 M0 f# W
{
/ B+ ~: M. W1 q9 P' L# M% c* c platform_device_unregister(&da850_evm_tl_leds_device);
9 k9 k4 E! z/ I9 P4 J/ v( A( q. V; M9 U7 N4 N2 G# k% p
printk(KERN_INFO "LED unregister!\n");
# w( v6 p/ X1 W; ?}
3 l# j7 g& A! i, c/ d! z& Z- ^& o7 }5 Y e; R1 j9 N; f
module_init(led_platform_init);
2 G) ~* I3 C) A& _0 g! ]' t8 v3 K) emodule_exit(led_platform_exit);! d3 h5 a! b% z
7 n3 S/ ^8 D: Z9 s. _
MODULE_DESCRIPTION("Led platform driver");9 q! T* ?; E0 ~
MODULE_AUTHOR("Tronlong");- x9 o9 q3 V/ d' b$ V
MODULE_LICENSE("GPL");4 h' b/ }+ g3 _$ K1 E# @8 f
3 K+ R5 V% c3 m v d6 a' z |
|