|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( y0 U o' r% S! h+ j#include <linux/init.h>3 P7 N/ ^( g0 f1 _
#include <linux/module.h>. V4 p$ u# `* O) H( [0 C
#include <linux/kernel.h>" W7 n: R( ^: _
#include <linux/types.h>
: V% e% p8 b; Y: U#include <linux/gpio.h>
7 a! r9 L" K' g: @* `#include <linux/leds.h>. F& e3 b @3 P' S3 k" ~
#include <linux/platform_device.h>
* J/ d3 R9 N* D2 ]* _( n4 b, \, n+ M3 j( O' q) F) U8 g0 s$ ]3 N
#include <asm/mach-types.h>$ Q6 b& ^/ k# K; n; B
#include <asm/mach/arch.h>
1 P. x& p+ |. [. g+ M: p2 m2 G3 F g# b#include <mach/da8xx.h>
. P& o% h' g- U#include <mach/mux.h>% L( S( A3 H' S% y
) ]9 r. ]. K% I- H; M) a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% H: j. v0 d: S- u& e! @5 w" ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 e4 w5 t8 F; Y+ \4 E d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 p7 |' O* Y$ _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& |- Z, K2 l; `, }: V
8 O, D& ?4 X% _/* assign the tl som board LED-GPIOs*/
7 u# A/ E/ u2 c* H4 c4 ~static const short da850_evm_tl_user_led_pins[] = {
# [8 `$ a) m& B1 y' f; d! I /* These pins are definition at <mach/mux.h> file */3 s# u! @ R/ V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& o1 G6 ^+ n; h* } -1 n t1 J) c& _) Z- G7 |1 t# x' l
};* w% {1 {5 G4 F
' u5 o% c! Y; B; ]& Fstatic struct gpio_led da850_evm_tl_leds[] = {
' n+ S1 w0 C3 Z; B( }1 Q {* e3 v" j. S5 U- V8 v
.active_low = 0,
0 c8 _ ~7 v" i6 U7 f .gpio = DA850_USER_LED0,! u) |" b7 Y' Y, i. I* k$ H
.name = "user_led0",$ ]; l2 @/ t5 G Y. L5 U
.default_trigger = "default-on",9 J8 s% Y, V, F+ q# I
},
$ e" e8 k: C5 k, ?$ u8 c6 c+ n# K {1 [; A* b! a" ~- \
.active_low = 0,7 ^5 X7 U4 N7 |. F+ C
.gpio = DA850_USER_LED1,# W) P W; }/ K r7 @ K' X1 l* k- E
.name = "user_led1",8 S+ C) \$ {5 m
.default_trigger = "default-on",, a# A/ ^4 N+ g2 b- l5 K
},) t7 c: b2 P4 }
{+ S U. Q4 G; V: q* l1 b
.active_low = 0,
+ c5 }( Z! H: d0 H+ E" T6 G .gpio = DA850_USER_LED2,7 L$ Q# Y' [1 ]9 v
.name = "user_led2",
& W2 u+ Z: h0 l! G- M$ u .default_trigger = "default-on",
' o0 X1 N' i: G/ c },+ V3 }% e/ w2 ^8 t, U
{ u B! H3 q6 J% R- W2 _
.active_low = 0,
! C. l! e: d$ f3 @ .gpio = DA850_USER_LED3,( l' \1 H1 J* B/ X9 x7 s" T
.name = "user_led3",
% _ v6 d! t4 A1 y. r, Y .default_trigger = "default-on",3 `7 j1 t; I5 x% P, c. @
},
# j+ q6 f. z$ I* k};
* ]0 [9 q% `- z! S# y. ^
' m; n8 y7 m, Z7 b+ g. w% }! vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 g# o' v5 Y6 D
.leds = da850_evm_tl_leds,. ~; K! Y+ v5 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ S4 { Z$ m3 {' _# U1 R
};
$ o( _" \+ }1 A$ O& ] [: O* r: {6 O% G: i
static void led_dev_release(struct device *dev)
. Y' ?# Q; O/ \2 \5 ?' Z+ y{
) m) Y/ x/ F! B};- q1 q4 Q& ~9 B, ^* `
' }1 e3 @9 i/ C( F9 F/ mstatic struct platform_device da850_evm_tl_leds_device = {
6 ` ]6 H# @3 E5 x4 z$ Y* `7 e .name = "leds-gpio",5 g& ]% d' l+ }: S, h
.id = 1,% }/ u3 f7 S6 V8 L5 C/ Y8 F
.dev = {
- p1 L. a3 \: ]. L5 z& X/ f: R r1 o1 K. c .platform_data = &da850_evm_tl_leds_pdata,7 ~7 {8 h1 T! R0 p
.release = led_dev_release,' g$ m& ~( o1 {- _$ F
}, b* I0 f$ L% j0 V0 ]. F
};
9 S4 M- C) ]1 d6 I! d4 q& W# m4 q
( `' ], U# j! P# j! estatic int __init led_platform_init(void)
, r/ w: v7 G0 h' }7 T" ?4 F{* M5 q1 K! _, p* X- g
int ret;& A& H9 a% s* A4 h$ Z: ~
#if 0
! Y7 B- h: k; r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; J7 N% i3 h: Y. j if (ret)5 a2 g' j5 c: _2 I v$ L7 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 x8 b# E$ |7 @2 @: b3 F; p; W "%d\n", ret);5 F% h7 k. r: Y: i* N8 s& O0 }
#endif
/ [3 {3 [2 m7 Y8 ^1 E ret = platform_device_register(&da850_evm_tl_leds_device);
4 H; U' J& ~7 @( J# i+ A6 z9 b* ` if (ret)/ h8 v7 f- j5 ]
pr_warning("Could not register som GPIO expander LEDS");
; e* p1 G, T$ u: l- p else
( U9 F2 V/ e) t9 a! B, t7 ] printk(KERN_INFO "LED register sucessful!\n");" ^/ r% b# f }& W) b; K! P" k
9 G I* N7 ]* w return ret;
0 k& ^9 S1 Y. S# Z7 k5 \}+ E* B: b8 t1 f
+ X) }+ m" A, Tstatic void __exit led_platform_exit(void); G( [* A. X4 {. ?4 x# [0 W7 _" P
{
. B1 j* e( \7 N; A3 { platform_device_unregister(&da850_evm_tl_leds_device);& v7 |5 C7 z3 O: m9 ~, ]2 Q3 \0 O
|% ]1 R0 m+ t$ c4 l; @+ ] printk(KERN_INFO "LED unregister!\n");
, n- ]9 B' f6 u8 \* ]9 @}
2 h4 \6 K& m; W" v: z
1 a* }# @( X" w/ A# qmodule_init(led_platform_init);0 S" I( @! L( C5 }1 c% [
module_exit(led_platform_exit);3 X3 `- b- u8 A
% m* I$ r0 b/ [( O H) @MODULE_DESCRIPTION("Led platform driver");
% ]8 J) @' n/ h g" V4 q1 XMODULE_AUTHOR("Tronlong");7 G4 B7 P$ B) `" I
MODULE_LICENSE("GPL"); w/ u1 O! n# g0 `6 b; |! E
" f) s5 Q) P! K( T. v3 { |
|