|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 v& a, J) I3 l#include <linux/init.h>
, z& z$ w d% n#include <linux/module.h>; G+ z5 K( u' Z, N' ~
#include <linux/kernel.h>
. G) t& y' E. L+ k& d* T#include <linux/types.h>
" Z+ U. b1 ^' ^8 o& h1 g1 P#include <linux/gpio.h>4 k* T/ a. U# j0 R
#include <linux/leds.h>
0 X- z# F2 x: R1 `6 R2 |#include <linux/platform_device.h>* z1 N9 N- [! ]3 E
6 N# E0 q% r! D j2 i9 ?" C# Z7 \#include <asm/mach-types.h>% }# m% A& v9 d N0 \0 e* B
#include <asm/mach/arch.h>
- E/ a- z! C. o3 \#include <mach/da8xx.h>
0 ~. z5 p% ~' q0 W( `& {# g#include <mach/mux.h>
. J& C' W1 A% y% G: i* ^8 E, @+ X
0 h4 |% t0 u, e- Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 b2 c+ H `4 S: }& N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) S. S6 R" k7 W2 |/ ?. q$ Y0 ?- y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" E; Z$ Y4 t, B; o! g4 `+ p: g: z$ U3 B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
A' p3 \/ t0 o% Z/ x4 t" {+ V" }- u
, e) |. k' L+ d1 q+ c6 }/* assign the tl som board LED-GPIOs*/
/ G; L- L% s2 R N3 t1 Xstatic const short da850_evm_tl_user_led_pins[] = {
$ E" m% G! }1 k, x: H. V /* These pins are definition at <mach/mux.h> file */2 I; i8 f, w8 D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: d' A) s e1 } [" ]; A5 U
-1
/ k: ], t% Q& K# [1 {$ i/ e2 P" g};
0 s% i+ @3 {9 z- k3 }& R" H& v) j& G' N8 [ b5 I+ {
static struct gpio_led da850_evm_tl_leds[] = {# Q' {( @: j5 m/ }. Q! _% U
{
- O1 J, ]) c' {3 B# n0 D' N .active_low = 0,9 q5 I; s( @. ?8 r/ G. b
.gpio = DA850_USER_LED0,. i5 p* g; X3 p9 n) |* n
.name = "user_led0",
) v4 W- J/ m* X4 _- R' ^% \ .default_trigger = "default-on",
% ]: ?4 q" A9 V, E },4 K3 L3 d g. e e4 H) U: Y
{3 M5 F0 H( p$ [9 @+ t7 P
.active_low = 0,
* b& v% `- A" S# j6 m# ^; { h .gpio = DA850_USER_LED1," w- B( M5 ]* S: J4 ?
.name = "user_led1",# Q" t% H. J7 e4 a) ]( K
.default_trigger = "default-on",1 B3 d# E) K; S8 _ l- G' [
},( N: T4 ^5 i1 i2 l" ~$ |" T
{
9 x3 u# w0 t% b" z .active_low = 0,
* k$ s& R( s" o, c- q! c# Y .gpio = DA850_USER_LED2,+ H7 l* s7 S% F" h" K
.name = "user_led2",0 L& F! q! Z1 i" |
.default_trigger = "default-on",
/ [/ h y- B* b \% l# j },& k3 S- { ]- b2 L
{7 @7 H+ ?8 N) C7 I0 [6 j" K
.active_low = 0,4 Y/ J0 X- W: q; h3 v# p
.gpio = DA850_USER_LED3,* h; o* M; d- j k4 z
.name = "user_led3",' z/ u8 G7 W! `) i* N
.default_trigger = "default-on",( A; H2 u6 c' H f# }4 _# y
},5 C; d! A) F5 n; j1 v$ {
};/ Z5 d) p8 w- H
- I: |, c$ s6 x9 k/ {/ v. [8 p0 astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, R( o/ E' y3 e$ a, M- E7 _$ T .leds = da850_evm_tl_leds,
* d9 g Y( L1 _, o7 f5 C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 n6 b9 R8 w: R: n0 ]
};
6 e8 H1 p" t, }" Z- L" Q8 l0 k9 F" X ^$ }( X
static void led_dev_release(struct device *dev)
* |& U; F5 s3 y, m [# g; w3 s: N{
9 K4 {$ L" u6 v/ {1 o};/ f) B8 t8 z% K! v% N. ^- m3 [
) f% u. Q7 E3 estatic struct platform_device da850_evm_tl_leds_device = {, Q4 j0 u' j& O5 y+ W# F
.name = "leds-gpio",2 v5 g) S: C4 \7 d9 u
.id = 1, k. _9 N% i; V( ]
.dev = {
& Q, P- n' R, l) y, T4 A, F .platform_data = &da850_evm_tl_leds_pdata,
+ L; s; T: Y7 r .release = led_dev_release,
" A1 A1 ]5 ?% F# n }: n5 R; W3 w8 c5 ? _
};
" \ O+ k/ y( D, Z
8 h1 ]4 E/ B1 ^; H" _5 A! s* y. _static int __init led_platform_init(void)
# ~4 O# g: ?4 N{
" T2 y$ ^: N1 b _9 b# i& r0 q; ] int ret;
2 u9 `7 s0 t, D, ?# Z3 L# }: r#if 0
1 `7 j- d+ h( P/ \2 j0 g1 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: i( v7 P* C! n) [. a- F if (ret)3 v) b: n5 R) b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 h* E3 j- l6 J' G V9 {' A "%d\n", ret);' y9 G' J0 {7 g9 } W1 n# |; h
#endif
8 R: p" F2 B7 i' S7 l! W# o* H3 d ret = platform_device_register(&da850_evm_tl_leds_device);
" S! i3 U7 b0 V0 b0 ?! `. m if (ret)
@2 E& I, u1 a; Z! ^6 g) T! ? pr_warning("Could not register som GPIO expander LEDS");5 J* ], }) o: G' K2 P7 K9 }
else$ F0 w- {& H0 M
printk(KERN_INFO "LED register sucessful!\n");
; R: t# A* Y/ s" u0 B- f
( E" A- ?3 b5 A3 v; K- |6 s1 t; [ return ret;
0 c2 f) m2 n; h2 z% o6 q9 ^}
. [4 \) m. r+ A6 r" _' j" p/ m0 S$ U2 n% U3 f. C0 n- g
static void __exit led_platform_exit(void)
5 c/ H2 d5 e: ^2 ^{8 g5 r+ u5 @3 h8 m
platform_device_unregister(&da850_evm_tl_leds_device);- I! d5 p0 x2 j6 n4 T6 j+ t
- j* f9 Q: d: K/ q2 f f+ _" s
printk(KERN_INFO "LED unregister!\n");& b& G9 `/ W+ k0 j) l
}# W; d' q3 T4 `! _5 F4 B
0 h9 a2 C; x7 B& `/ Z, Z; vmodule_init(led_platform_init);$ j' h$ \+ }1 Z
module_exit(led_platform_exit);/ e/ `- ?) u1 f
9 \0 Y' O# [- e9 S) J: O g
MODULE_DESCRIPTION("Led platform driver");
; G" I6 { b" i1 E8 ^ v; V# jMODULE_AUTHOR("Tronlong");
* A& d4 G/ s5 T* C2 WMODULE_LICENSE("GPL"); x3 K. E5 V9 y/ w& ^; I! x6 k3 P1 k
( {4 H8 {6 T/ }5 S' `
|
|