|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 L$ r3 J/ z9 @# [) Y( Q
#include <linux/init.h>
/ e8 b4 |" k2 G( g#include <linux/module.h>- @' j% p& P1 e/ S; v( \
#include <linux/kernel.h>+ o- Z" P! z# B8 o/ u/ n6 T6 G5 Z
#include <linux/types.h>) b5 |, d+ K9 g' R% w
#include <linux/gpio.h>1 h0 ^- s/ o8 f6 `! ^1 ?
#include <linux/leds.h>
+ U( ~- u$ A' Z- o, h' ]4 D# W#include <linux/platform_device.h>+ K: p1 A, A8 s6 H, d4 B3 W
9 z. i) j- R4 x
#include <asm/mach-types.h>
. T- \1 |2 w; |, Q" N6 f#include <asm/mach/arch.h>( N! w2 z/ r) I
#include <mach/da8xx.h>& U4 q o' J) o8 f3 i: Z( ?- q
#include <mach/mux.h># Y" _; a. w. F! J1 F3 G
) d8 Y3 a2 p' D& I9 x2 u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! H$ l0 v7 H* g* K1 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 ~) I$ j k/ q+ X% p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 Z) B W+ B2 Q0 \& X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) s* n. s o# |- y: m! h6 {0 t/ d0 h9 E+ g# h
/* assign the tl som board LED-GPIOs*/
, v8 r9 c6 w: h; T5 {static const short da850_evm_tl_user_led_pins[] = {4 Z2 {( Z& F& k+ w
/* These pins are definition at <mach/mux.h> file */
* n1 c3 { l9 M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, |" y. ^% o' O5 _- E -1
6 H! H1 X, F1 k! K/ Y' P$ k};1 y4 }1 d3 H/ |
3 H* m4 ?- G3 n- jstatic struct gpio_led da850_evm_tl_leds[] = {
8 \1 I) Q6 C7 B- |" o& B Y {6 p4 R2 o& a2 G+ j! Q+ p
.active_low = 0,
+ Q1 u' x9 k' I% L0 _ .gpio = DA850_USER_LED0, R* s4 m* `( V0 n
.name = "user_led0",
6 A* G$ S @& N' B' F .default_trigger = "default-on",
% y; C1 I9 g& P- o; A( _+ { },, m: [7 ]+ h# |$ ]: G
{
& g& Q7 R/ k1 Z ~: C7 g, }$ I .active_low = 0,
J7 z1 y+ P8 X& G .gpio = DA850_USER_LED1,3 ^9 U% i( F! s/ g8 p2 S
.name = "user_led1",3 ]( z" w# W# h' g m: X$ N; M
.default_trigger = "default-on",
" H* t3 a8 e' L; n" ` },
' v9 e" l8 x' b0 ^, h+ p4 c {
* S4 K: ?* G$ g$ ~9 A$ A; s .active_low = 0,! F3 U3 V) k: D
.gpio = DA850_USER_LED2,
0 r& f$ D; u, f0 y! c" J: u .name = "user_led2",
$ q0 A: r: O0 Q, `$ Q" V* V7 q .default_trigger = "default-on",
: ^* R- v0 M" _! R* F: ] },
- _' M9 @9 }( f# M { Q; d. u; p' l5 a
.active_low = 0,0 e0 A1 S2 T- x6 ?4 L2 Q
.gpio = DA850_USER_LED3,
- M- A" F& u( f) u- y6 \7 e .name = "user_led3",8 i8 f- P2 F7 Z* S5 C6 ~$ W
.default_trigger = "default-on",
: j- Q6 ?, X! L },
* k8 ~. u1 _+ X- |2 g};
- M: E, g; G. A# G y+ K* r, O, a" x* W; Y5 T& {! P* \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 c E% n& r- I .leds = da850_evm_tl_leds,
8 {5 v' v7 K; `$ _6 F5 \& Z. d/ B2 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 I+ ~% b- Q9 F};
! N' q, l) s3 B/ T$ U
/ f1 H, d0 m* ]; Kstatic void led_dev_release(struct device *dev)$ X' A) Q; L+ b$ Y7 e
{
5 P; D, f5 V( q' Y/ ?};3 v1 r- y8 R. N7 ~# A
! _/ T% X5 H& d4 E# L$ |8 e8 T7 xstatic struct platform_device da850_evm_tl_leds_device = {. u1 n G6 A/ q. v, o0 b
.name = "leds-gpio"," W F( b D! @! k9 P: I3 q9 Z
.id = 1,- b4 W/ o6 Z7 Y- q
.dev = {9 _+ c# O& N( U( u
.platform_data = &da850_evm_tl_leds_pdata," U; V3 o4 f3 E; M
.release = led_dev_release,
& `1 w1 |- K [- ~7 ]- J1 D }1 _" ?$ d [4 `/ q
};
1 S% }/ S9 U; ]" y0 h' |" I3 M: B# J8 H3 C- E z
static int __init led_platform_init(void)
/ N3 E* x0 r8 A* H! o2 d$ V{$ ~5 [: w8 H) K; @8 }9 W( W* P
int ret;
% |: N+ t. F. `2 Z#if 0/ `% Z8 e0 I5 w/ y$ ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, I3 p4 B6 r# d+ V if (ret)
* F% B6 z; @& q$ C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ N, U. t" k( N1 F& F, A* z/ }7 w
"%d\n", ret);
- ^( n' H0 X' G* p4 O1 Q7 o#endif Z6 \! C! g$ f9 ]" e
ret = platform_device_register(&da850_evm_tl_leds_device);: Z" S3 o4 z& A- k/ I% n: g; T
if (ret)9 y7 e* ^. h: y9 [# _
pr_warning("Could not register som GPIO expander LEDS");
7 s5 Y+ m7 S+ e5 e. e \% S* Q( n, Y# l, N else j, W. i: k( k8 A9 a8 a4 R
printk(KERN_INFO "LED register sucessful!\n");
- a/ t F, s$ [( V# @
" j5 S6 }# K% y7 l" ?& P return ret;2 G/ K) p6 v: \0 H( B
}! W+ \2 c. B/ e+ U2 F- ~
9 S5 R. b; ?3 `) c+ b }; Nstatic void __exit led_platform_exit(void)2 n U" c6 [( ~; }
{
4 o+ i0 S! {) s( s# q) _+ b6 J. w platform_device_unregister(&da850_evm_tl_leds_device);
; `, @! r; f' {( S: z3 q9 O; F b& Q7 ~9 J; s' _
printk(KERN_INFO "LED unregister!\n");
4 d. D) M4 |+ ?' h, W}! I. y/ v2 |: X D0 w# o; g
- b0 z- n a! O
module_init(led_platform_init);4 b7 I" f7 r! M6 B5 M2 p6 D
module_exit(led_platform_exit);
7 z* p' ?+ F# ~& ~' E! K
* I1 n, m- g C* XMODULE_DESCRIPTION("Led platform driver");
+ Q' j3 w" \# O$ o( GMODULE_AUTHOR("Tronlong");
5 w, S8 J( v, z4 P( T# }MODULE_LICENSE("GPL");4 [9 ~8 {: e) y& s/ p6 k: P' c
' T( l* }6 k2 ~! Z+ E |
|