|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& `8 U/ n% E/ @- C#include <linux/init.h>
: Y- U9 O# P2 v; S' P#include <linux/module.h>
* O* @1 ]/ ^" P6 o3 T#include <linux/kernel.h># v C' l& K; {4 u
#include <linux/types.h>
. e* T! [" ]! G% S2 e#include <linux/gpio.h>% e2 [% d& a# P& D8 \& s
#include <linux/leds.h>6 R; n7 w k4 e- Q3 e3 i
#include <linux/platform_device.h>- H" t. U1 C" n5 Y2 T" X
! Q3 V; m5 k9 `" ^9 E: \8 K
#include <asm/mach-types.h>9 c+ T& x0 Z( u4 D6 H3 W
#include <asm/mach/arch.h>; f& W4 j9 D4 F( v
#include <mach/da8xx.h>4 ]6 |! N$ q8 l
#include <mach/mux.h>
7 f- M6 k: ~& B, a& @8 _
# v; M2 L& P/ U+ z5 C: U) [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) s# A7 D- p% k+ u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); F g( M+ v; m5 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! s8 X' G& A+ r3 X, l, m2 p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% ~' { U7 `) K# L' k, E. }# \5 I' ^* c) m/ v) d
/* assign the tl som board LED-GPIOs*/
! n: l/ W+ Q, D& t$ W0 Ustatic const short da850_evm_tl_user_led_pins[] = {
1 l0 f# W4 Q6 Y+ @. F5 j4 ^ /* These pins are definition at <mach/mux.h> file */
v* K/ k. p) p9 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ o, j p: b. |& h -1
3 m8 W0 F' u3 `0 s/ i* K+ C};
5 E# t9 A _, n+ ^* Y* i4 H3 Z r9 K5 @- q2 X+ Q" T
static struct gpio_led da850_evm_tl_leds[] = {
0 D8 h) {$ w5 @( S {
. C4 d, I; W! [ .active_low = 0,0 N. d/ A: j+ H* W7 N& {% K
.gpio = DA850_USER_LED0,' v. v& T2 W8 V
.name = "user_led0"," c8 V1 y# m' n$ C+ t
.default_trigger = "default-on",/ D3 i3 g+ V$ r7 _& K
},/ m7 o* p$ c0 J
{ {6 s" C) Q) y
.active_low = 0,0 }7 J8 ?' |6 o8 ^% B
.gpio = DA850_USER_LED1,5 N. J# L$ f& t' h
.name = "user_led1",* @' l Q8 k2 p/ j$ t1 c& l4 z
.default_trigger = "default-on",* r6 _" z6 P) S
},( k, |4 ?2 _, e
{
2 w- B8 I l1 z$ m. j2 M* C .active_low = 0,4 z+ {6 b& h- e* b7 n" V6 y) W
.gpio = DA850_USER_LED2,
/ P: b; f% e% e+ e% {; T. a: g .name = "user_led2",
: s% p4 \ x. ^ .default_trigger = "default-on",5 H7 {( g; M1 `4 S9 n1 V
},
( D! E4 L: S* f% h2 ` {* f( [& C5 \: N0 i7 u+ `" a8 O
.active_low = 0,! T8 |0 R2 Z( s D" f' s. {4 ~
.gpio = DA850_USER_LED3,: ?, x" T L" }5 G6 _
.name = "user_led3",
, m e1 ]; P& q: w: D .default_trigger = "default-on",' W! E* F' r8 ?0 \3 f
},
% F$ z4 _2 }; `0 _! U! a& u& \# N};$ d; l. R( u+ S# l- I
4 i4 s. \: E) @( @6 v1 A% H! a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 [/ a }4 F! }/ a- G* P
.leds = da850_evm_tl_leds,/ l9 ^+ Y7 W% u* }, s5 s; r& @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ K( ~ H Y- o4 c0 F; T7 b/ L' r
};
' _1 w# ~5 ~4 U" B1 l( S2 D4 A' ^- y* B
static void led_dev_release(struct device *dev)
5 X& A& v0 T9 t6 t+ Z{
' ^/ u" y T! n u8 h9 _* l4 _; |* J};. W& b% C$ A8 ?6 E- K
1 l. u/ D) k" _* {9 X
static struct platform_device da850_evm_tl_leds_device = {
1 ?- h3 I' z/ B/ s7 w2 M/ Q* ^ .name = "leds-gpio",+ }9 `* A/ O0 _1 K' {2 i
.id = 1,% b) y( T( H( @+ Q
.dev = {
5 L: k9 {) f/ }" K3 T0 p .platform_data = &da850_evm_tl_leds_pdata,
: a9 o6 T) t9 h& } .release = led_dev_release,
. c5 }2 j7 C# R9 N8 a- U8 t }5 Q$ E# t Y3 n! q1 S
};4 k& R: g$ c6 E3 u0 ^* i6 R* T
8 a! r; e1 C; K* [4 v/ a' |static int __init led_platform_init(void)+ i: B" z; l: E1 o+ u1 g1 ]+ t
{
& B) [5 H4 g& R( T; V2 ^, j1 j int ret;
% B6 s7 \8 F1 k$ P#if 02 l, v6 D, ^* G8 }7 F k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# _6 ?6 \+ m7 T2 W/ y
if (ret)- M9 t* K5 o) ~: e j! n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' J# e0 p1 n. A2 g
"%d\n", ret);! N) W1 n5 K* b* n& }: \ z
#endif
+ X& ?' D" v7 ?9 t$ n ret = platform_device_register(&da850_evm_tl_leds_device);
' X6 U D. S' c if (ret)
# F, W! d4 ^( r1 w, W8 @) Q! { pr_warning("Could not register som GPIO expander LEDS");
) q/ b: \/ R$ x" ^: l- B# m else
9 x3 o% r$ b* [5 J printk(KERN_INFO "LED register sucessful!\n");/ r1 D% W1 {& |2 h- V
6 l- r2 N1 Q6 u$ v/ X
return ret;
z1 j9 g# k7 Y# y& C}
' y. Q5 m5 T# D6 }$ u: q$ h& t
. Y( M5 D2 I# Y; u2 T' T" J) istatic void __exit led_platform_exit(void)
4 `6 Y* M2 ]& c$ \% O1 O{+ F3 T* ~% b# E( C6 m+ j# ~6 X# k$ R
platform_device_unregister(&da850_evm_tl_leds_device);
6 ^4 t! a, z& U$ j1 A- ]( R- B0 {7 ]3 G& ^
printk(KERN_INFO "LED unregister!\n");
- w3 ^( K) S5 h5 l" D}
" F* b' u. F6 A" E2 x! q6 j+ a) ]. X. L, D1 t# \$ W
module_init(led_platform_init);
$ v8 p% ?1 q! u2 Pmodule_exit(led_platform_exit);/ _3 H# y+ b) n+ N' J
! o+ D/ T1 _; x8 m" v0 }
MODULE_DESCRIPTION("Led platform driver");6 `. G# e5 ]! T1 r6 {6 R
MODULE_AUTHOR("Tronlong");' ]! G4 v; e, o
MODULE_LICENSE("GPL");$ k9 k, [1 X! y6 v- J7 I) C
4 x' L; [ ]. o/ W |
|