|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' b* J/ k/ T# H
#include <linux/init.h>$ R9 f8 i% ?. j
#include <linux/module.h>& m T; G$ A1 a! v$ g' z; _1 B- s, Z
#include <linux/kernel.h>0 t4 ]/ B( v+ c M/ T5 j
#include <linux/types.h>$ I1 o. P) ]/ J
#include <linux/gpio.h>" I9 ~' F7 n0 }4 b0 r: r
#include <linux/leds.h>; S3 a( R, s/ |
#include <linux/platform_device.h>6 V/ Q' S3 S) X& s7 {' ~
0 D/ x. q% l- }- `& O#include <asm/mach-types.h>
5 x% v% R; W' ^9 G' e1 i. m#include <asm/mach/arch.h>0 P5 I: ~, O( j! E& N/ l$ G# @
#include <mach/da8xx.h>
$ D! K7 h0 L' U6 [, U) k' A' U#include <mach/mux.h>5 {$ i8 u6 t) u) ]; d; m ]
. i0 H! E. ^; a5 Y1 Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' J! h* r: s9 ] r y/ W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), J8 Y* j, s0 b/ k5 X1 i& l: e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ {& M: v: I. h" [7 x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 l) l% R! a+ h+ v
/ p, t& S' j( M0 a C8 s/* assign the tl som board LED-GPIOs*/
c0 G, a! |* G, B$ e2 _. ?1 f Pstatic const short da850_evm_tl_user_led_pins[] = {2 m" D4 z* t8 C
/* These pins are definition at <mach/mux.h> file */
* Y+ T0 t7 u6 ~ L) ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 X. [( n4 N1 v7 E+ j& {/ R
-1
" Q8 d* Q2 ^0 b. K) u4 E};
) |- ]+ J3 U6 u. {1 N( m& y! a+ b l8 c. ~9 Y
static struct gpio_led da850_evm_tl_leds[] = {5 [( w/ W5 K3 _3 \# F I
{
: j* {! m1 X7 h; w" G .active_low = 0,
: T% Q/ J7 p2 l6 s0 o% w( o# y% ~ .gpio = DA850_USER_LED0,
: \4 o/ }0 f2 {2 Q6 q6 b' U .name = "user_led0",
/ K& O$ I$ z$ b& R* l% h .default_trigger = "default-on", B2 O$ T% t) D, U0 \
},& o3 G: x2 b) `; ?- ~5 A
{1 n6 C* P) d9 i9 m8 [# T
.active_low = 0,
# Z; {$ S; h. _ .gpio = DA850_USER_LED1,# A2 ~$ I: w' I& U
.name = "user_led1",8 {; q2 J; ^+ w5 x% y0 v
.default_trigger = "default-on",
" ~" K' R8 B; z, D* V },
% Y" x8 U+ H* n! q: ^/ { {5 B0 e" Z+ @; V% p
.active_low = 0,* W4 r+ e' o2 ^, g- B# P
.gpio = DA850_USER_LED2,
9 W& \+ S& T9 A- m .name = "user_led2",
7 a. q( X7 C8 a z& _9 v& A4 T .default_trigger = "default-on",1 f" n ?" i$ D7 J0 r
},
& |& k; ?+ r8 a' U9 ~, N4 L {
! m4 _ k8 J; E* L6 W .active_low = 0,
" |- W* p3 A* y- M8 H; O .gpio = DA850_USER_LED3,; X0 s' x0 N5 g) F, _
.name = "user_led3",
+ N6 b/ K/ p+ {' q/ k) x& m8 e" p .default_trigger = "default-on",
' p3 n& S4 D4 K7 [ },! L+ B4 C0 S% g
};, P6 Q' A; X4 B5 m
% @0 p* a) e# a6 y7 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& d; u' X0 N% u" g! O) m .leds = da850_evm_tl_leds,
* d3 l7 d) H `8 P( x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& V8 z6 N' v8 B; \. m$ T
};5 O/ }4 t7 e0 D& `- y6 t; q
8 V f; o: K' X% }/ R8 n, \ Cstatic void led_dev_release(struct device *dev)
8 \+ K9 c2 ?# |$ p3 J{
% e3 U5 H+ n" [- d# }$ {8 x};# F( k' {! q! z( B: J# p; A
/ p: n. f+ K; Q5 \' cstatic struct platform_device da850_evm_tl_leds_device = {+ a/ t. M- I1 ^& q W4 F/ l
.name = "leds-gpio",* D& U, F8 ~% N; B3 T E f
.id = 1,
; m! x0 d( j8 Z- H# n. u: M .dev = {
, S$ `8 |$ {1 d+ `5 d .platform_data = &da850_evm_tl_leds_pdata,
2 p# j7 T* ?# S$ ?* z .release = led_dev_release,2 D7 Q) L- c5 `; j+ ?9 D. K. M4 a
}
& |% n! |, f, X0 Y; {};9 \2 A! g* e6 ^/ o2 [' J1 \* U9 z- f
; O. ]; ~* `) ~& H6 Rstatic int __init led_platform_init(void)2 U5 O" g, i+ e M) E5 I
{# S0 v7 ^8 ^$ v9 E! h/ N
int ret;
2 _ d/ K- Y+ t) R2 V0 Q2 [4 g#if 0
/ f: T8 L% n$ _9 o5 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ `; s8 L4 v, o& t( b if (ret); ?) E* G$ S4 r! m& j' K9 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& k! X1 J- [) E
"%d\n", ret);: w" Q& P5 `" a1 k! X6 g3 H
#endif' H0 @! ]1 U" x: X' ~
ret = platform_device_register(&da850_evm_tl_leds_device);
: I" u5 v9 A( @ if (ret)# L# Y4 }+ `8 q+ D: J2 L& p
pr_warning("Could not register som GPIO expander LEDS");+ W+ ^7 q& |0 G
else/ \ S' s0 T2 }8 Z; M7 p+ M
printk(KERN_INFO "LED register sucessful!\n");
& P6 m+ ^: f0 m8 W& k3 D4 ?5 t' S0 d
3 }4 k4 P, r. U$ z" e5 I& H& k# x return ret;0 K+ Z/ e' O, `
}
, N& _+ q, g3 v. t
* B9 O" g6 q8 d+ b: E' Estatic void __exit led_platform_exit(void)6 \! L. }0 D7 h9 s2 P* |+ }( d) n0 `
{
* X! c* p; S7 r" h6 y; B( q platform_device_unregister(&da850_evm_tl_leds_device);: T% S2 g k6 I$ s& k
! x- A: N% v0 d* t9 O
printk(KERN_INFO "LED unregister!\n");
- O& Q2 ?9 \, D$ S2 w}
% e6 t* L3 `! c8 W! l7 i
a- g9 a* E) |1 p+ {: Dmodule_init(led_platform_init);1 k3 |9 c+ p1 I# v( C0 e3 K
module_exit(led_platform_exit);
# N' m: e+ u1 @' I. A5 p5 E# H) z) S
MODULE_DESCRIPTION("Led platform driver");
% d+ v0 [+ i7 j: g3 k, aMODULE_AUTHOR("Tronlong");
- _! K0 S; A% u! `/ R" T% LMODULE_LICENSE("GPL");# Z, V/ Q" a& A6 R/ r9 F
5 X/ x' x' |" F2 t4 I: C
|
|