|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* \. E1 d& I! J1 }: T! C( Y% P3 o5 L
#include <linux/init.h>
6 u# n) g& e6 n" ^, m#include <linux/module.h>
5 n, W2 D8 b# f! f0 g#include <linux/kernel.h>
3 h+ f8 `7 K1 L# [& I, D# _#include <linux/types.h>* E" A- {: @2 q9 q1 d
#include <linux/gpio.h>" ]) e. J0 C0 K7 [
#include <linux/leds.h>3 ?3 X2 d, h3 N7 O+ f4 n
#include <linux/platform_device.h>
( N" S! y1 \7 C$ s" W7 K
8 S) A4 z6 e4 D#include <asm/mach-types.h>
$ Q1 I6 {) P+ k2 r5 ]4 K/ U#include <asm/mach/arch.h>2 ?- d* `/ y, |* h
#include <mach/da8xx.h>
$ T4 |4 \- f; k6 w" ]3 `1 h#include <mach/mux.h>( v0 K& }! }4 x2 W2 {' D! |: u
% `6 o) Q3 z5 Z/ h- h+ r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) @8 X# D# I. T. r' B8 i5 K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 {% A6 K$ r! I- g7 w( b/ [5 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 x- G# M4 J8 h! P( K: |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 f+ G3 {4 k* \- n
$ q- c& ^6 A; t/* assign the tl som board LED-GPIOs*/
6 Z+ Q- j* Z. d8 C; L( V; cstatic const short da850_evm_tl_user_led_pins[] = {
g! V8 q' f! r2 u /* These pins are definition at <mach/mux.h> file */
( i9 t4 _& i) K1 }- ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ l1 H7 Y0 k- Y. G& Z' U -1; }1 ~8 o. \1 ]( Z3 V( V1 h4 L
};1 ^5 F# Y8 L; Q
$ \$ q8 ]7 ?" W$ P/ h5 d1 I, I5 c' E: Lstatic struct gpio_led da850_evm_tl_leds[] = {, C B" r1 a8 d, F
{8 T* X2 z4 x0 u9 s$ ?8 n$ J2 b$ n
.active_low = 0, x, h$ I6 q! q9 w
.gpio = DA850_USER_LED0,
- S$ {: f0 u1 K6 H2 b .name = "user_led0",
: ~" R* Z% p1 ~ .default_trigger = "default-on",
( M6 S+ c# `2 N0 b },
9 z' b4 A$ ^! k {0 `, L% g4 T1 c% C% ?0 P
.active_low = 0,
/ _5 N# ^# q8 N- F .gpio = DA850_USER_LED1,
: @1 v9 H7 Q2 F .name = "user_led1",
8 ^8 F9 H$ m7 X2 B! G: D .default_trigger = "default-on",. j% Q: J+ X# |! ]' v E
},# g0 |7 ?7 Z# V( {6 }
{; L% f1 W1 N9 G B
.active_low = 0," J+ c7 I. \. _! n9 S' g! u
.gpio = DA850_USER_LED2,) r% l% F0 @ j5 P
.name = "user_led2",
; B$ T7 b! L" S8 c1 X, ~ .default_trigger = "default-on",4 u, n, x2 a" g% ^
},
Q4 r, p4 _; R+ }2 E {
) U! M. V+ E+ o- ]$ v .active_low = 0,
) n! ]6 B1 {+ h6 C( t .gpio = DA850_USER_LED3,7 i1 K. k( G: o6 @" b" e2 |
.name = "user_led3",
5 x0 D) U" _$ j% B1 ^+ a8 q .default_trigger = "default-on",
. A0 Y& U4 \: E% N },/ l; k; ~/ g$ h' D7 f' U1 m
};
3 f$ [7 t8 n' F- B% q8 |7 S# E" T$ T8 ~% z0 v( N; ~! A! P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' a) m& J' x5 z: Z8 F# G: ]# A
.leds = da850_evm_tl_leds,0 ]/ p! H" o( h, ?- ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% X; D. y9 Y, ^4 h};
) }; U$ o4 O' z
; e) z: B" z* K istatic void led_dev_release(struct device *dev)6 v& |+ u- i7 Y: |; Z, U% G. x
{" s: ~3 O" E6 I5 Y b# h |. T& C! H
};" t; k: |" k1 Z; U. v. u
& M* W5 O2 c% b2 ?' P$ _
static struct platform_device da850_evm_tl_leds_device = {/ q4 u. M) j' J7 |
.name = "leds-gpio",
( b! R5 S* L3 k7 ^& T .id = 1,
/ @) H. c7 G* B4 `% P% P& s .dev = {
5 [2 D+ i4 n) |0 m! z" U .platform_data = &da850_evm_tl_leds_pdata," H+ z# x- V. K5 r$ h
.release = led_dev_release,
; E7 n: V( i! a2 J: C+ l }
7 W' d6 F6 a! A; d1 B# y p};% ^1 l) r# x8 z6 c
& n+ n9 |8 ?$ m Pstatic int __init led_platform_init(void)' x T4 }! r/ ^# i! l7 Q, S
{
, h5 l4 {& w, h. H1 B$ E) M( O int ret;
; c6 ~ W4 g2 K$ |5 ~5 V#if 0
5 @* }1 z, f2 D& e- R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. a7 A* F: I5 v& l" E
if (ret)8 S5 T; A4 o2 a+ s0 H/ M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& Y+ V* t/ C7 O2 \' j8 T8 F" U; j "%d\n", ret);) [8 s8 l4 K O3 i
#endif5 a8 c* O) g) w: _' T+ O8 t* v }- w( Y
ret = platform_device_register(&da850_evm_tl_leds_device);9 [. ~# o! |0 [( m
if (ret)
, V8 N" {. {4 Z+ ^8 { pr_warning("Could not register som GPIO expander LEDS");" _3 p- `* P* v7 d
else% z m8 L9 j2 s- c- G& I7 Z
printk(KERN_INFO "LED register sucessful!\n");
- \ T2 [. A8 H/ Q5 h
! R: P) x. B& T3 V return ret;
0 O8 w; Y& r+ S/ Y7 Z- b3 O0 y}: B7 c0 V# n8 o4 G P) y5 A" q7 C
0 \6 }* \+ n3 ?% f
static void __exit led_platform_exit(void)
, _* O9 L5 s! o% e/ x* L7 A3 |) E) M) Y{( u) `/ p3 _- B
platform_device_unregister(&da850_evm_tl_leds_device);
* e' i* C) @' ~& w5 `% [, m% r4 [8 b Z
printk(KERN_INFO "LED unregister!\n");- k! a( r) M$ G4 G; U$ i6 c! u
}
, ^# G; p3 ?' n, D
( Q* U6 X' p; U5 K( x( B! o( amodule_init(led_platform_init);9 @. O+ R0 V0 U
module_exit(led_platform_exit);
& D. r/ K7 J$ R' f
/ C* f7 C8 c7 s1 f1 ]MODULE_DESCRIPTION("Led platform driver");
$ W3 V6 l8 H P V( i. dMODULE_AUTHOR("Tronlong");
" n6 ~$ C) F7 I, d: qMODULE_LICENSE("GPL");8 g! M% V+ z3 ?1 g: g
& Y/ Y; [% P- E8 i# D# i! n) C+ N |
|