|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: ?; O, Z; B; D& ?7 ?7 M+ l. j' r#include <linux/init.h>2 v; c1 G( L9 ]0 e1 H4 Y
#include <linux/module.h>
* j6 f* p! P, i8 D2 q8 M) q#include <linux/kernel.h>) s) ?; X1 [- v- b, _ o; q; j
#include <linux/types.h>- @ Q/ n* z0 I, Q. w
#include <linux/gpio.h>+ F0 m" `) h3 I7 V2 r+ {% Y$ F
#include <linux/leds.h>, ^0 C3 R4 R8 V7 h1 V" a7 V. H' b
#include <linux/platform_device.h>$ U% V2 D4 Z) e1 ^
& `# D, J% }1 l- N5 r& l( C
#include <asm/mach-types.h>
4 H, H" l/ G! @. v# i, @#include <asm/mach/arch.h>
, n/ T X# _; w, J6 w2 A5 L( x#include <mach/da8xx.h>
2 F6 W/ g, L& T, L/ j5 U3 E/ N#include <mach/mux.h>
5 B/ k$ X% ~% s! D) I' M' A9 u, i: q" v0 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 P2 K% u: f* m# J& a# n5 b7 O# n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' U& d2 }3 {0 Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# l% y ^/ L; k9 _# N; \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% x: q9 h1 e7 X) m& V+ H) V& K
( B* F4 b# z1 r/* assign the tl som board LED-GPIOs*/
X. V8 q, I# B+ A' zstatic const short da850_evm_tl_user_led_pins[] = {+ e" Q! a1 J2 F, q3 ~
/* These pins are definition at <mach/mux.h> file */, r3 E! n: e+ x: K: P7 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. F( g( Y4 B* ]/ \4 J3 W
-1
& J+ n% W2 i% s9 u2 |};
2 {" l4 ]' b; _: W/ y0 D# O( V6 P3 c7 [. t8 K
static struct gpio_led da850_evm_tl_leds[] = {+ i# K2 K9 a3 U0 p
{
j. e: V) p3 w- R .active_low = 0,4 s) f3 g w! ?5 t; M& I
.gpio = DA850_USER_LED0,* z! [1 ?; Y3 t: W/ R; p
.name = "user_led0",2 o( x8 u, | y+ s! }2 B
.default_trigger = "default-on",
3 c" f: C* n# `, B6 r4 i+ x },# l V/ Q7 h; a9 `2 B3 U7 n8 k0 P
{
$ _$ |' [* F% r% @2 y% ]# x .active_low = 0,
1 Z6 T$ _- H7 p .gpio = DA850_USER_LED1,4 Q% k+ i- \; x
.name = "user_led1",) l" Q% A- ?* r! ^( S
.default_trigger = "default-on",9 x1 f: k7 g7 b- e3 M
},' p' n9 t W; I; u
{8 r6 A! H% V3 b- x5 o
.active_low = 0,
8 @* H( \; ^6 j3 A F3 C `' J .gpio = DA850_USER_LED2,7 r2 V V) ~7 z) {% _
.name = "user_led2",1 ^- a& m0 ^5 h- k7 K
.default_trigger = "default-on",
8 o0 C' R+ x+ X a) N, D! I( e },1 t; c: C7 h4 t3 @
{# o4 \" S9 T0 _. P- F; o, d4 q
.active_low = 0,' v$ m$ ?" S4 e8 B: u& ?7 m2 g! c( @; c
.gpio = DA850_USER_LED3,4 k; a8 x3 C8 u" [
.name = "user_led3",
9 f$ r2 U0 M$ r- ?! _ .default_trigger = "default-on",
- ^6 y: S0 \3 Z7 i },; E! f4 D* u) q8 a5 `. R( n, _& N0 W
};
4 ]3 ]; ]6 `( t/ q# O, }$ r: C7 |3 {1 p* a: P' x1 z- N1 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 h( G$ O" ]+ P ~% G
.leds = da850_evm_tl_leds,
. P' p, @( h' h: [: w- E. b$ @5 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ L4 F# w7 X. }8 R};
) a. J- @* B- s0 ~* v! ^9 V$ {! m3 \5 f
static void led_dev_release(struct device *dev)
3 l6 i$ a% _! n9 s* x. ^9 G0 e{* \7 d8 \ g6 I: ~! a7 \
};0 i: ~. u# ?. m+ u$ f- a) {7 s
/ N* o# ^& G) X* H. E) Bstatic struct platform_device da850_evm_tl_leds_device = {
$ L9 E1 u/ ~( g .name = "leds-gpio",; S5 Q$ h! L7 x
.id = 1,8 G6 H: R- @! w3 a2 L! }! w/ k
.dev = {
2 w" n% d0 M$ J. ?4 [+ V .platform_data = &da850_evm_tl_leds_pdata,
0 j$ `% {1 L: Z2 s2 Z .release = led_dev_release,
9 }2 N) [2 J5 `) \. y }1 C0 V3 i% E) y4 C- @, ~* @
};( X7 h! k1 ?2 K) u% g1 C, _
+ `, t/ T7 N( m0 \/ m
static int __init led_platform_init(void)
9 l9 a# K; f3 t$ Q{
) g- m/ H) P {) ^2 ~ int ret;
" m& ]0 y) O9 d' j$ P6 h0 J#if 0
# G5 j4 I0 {) g6 w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 Z! \ U" ^0 s c5 E) c$ ] if (ret)! ?! Y1 |2 i. {3 Y, o) m9 i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 d8 l: i0 F4 e8 g1 u; ^ "%d\n", ret);
( K( c" P# ?9 }9 X, }: D m#endif& X( ?- O0 Q! b9 M' ?* P% b1 }
ret = platform_device_register(&da850_evm_tl_leds_device);
, K% V$ R$ k) k E6 c' S9 ?( I q if (ret)2 U& j9 G* `5 v
pr_warning("Could not register som GPIO expander LEDS");" L3 }) i- C. \! n6 p9 V
else7 x: P/ U2 ?% z# d0 x% [
printk(KERN_INFO "LED register sucessful!\n");
* M& G( a# P! S
; p& g5 f% ] _0 x1 V return ret;* H6 o' s" K0 l9 Y7 e6 t
}7 H0 G+ w% w* R. h- U
9 m' _6 y Q" n# R& l4 ]1 J
static void __exit led_platform_exit(void)
4 G0 n4 i/ u6 S- N/ G5 @{
! T" F" i: f' r7 |- R platform_device_unregister(&da850_evm_tl_leds_device);
$ Y6 w C. T6 f- A8 v0 ^! l& L3 |. \" q! I
printk(KERN_INFO "LED unregister!\n");) X7 z3 V" }: {1 `7 ~) y! z1 a+ e
}& C/ x" o C0 G, X1 p8 q' ~
0 Q# n) F8 K E* T
module_init(led_platform_init);
0 w V! O+ F& i0 B9 kmodule_exit(led_platform_exit);" w( n. c/ N { W. V. O
7 L+ ~7 x. k. ?. F( d7 G! n
MODULE_DESCRIPTION("Led platform driver");* Z2 P5 O8 E0 d; S" u+ v" z
MODULE_AUTHOR("Tronlong");+ a0 u+ }2 y; W) I# ~6 I
MODULE_LICENSE("GPL");
! J3 h; v$ ]! X8 }6 V5 P) x" ~/ Q, w7 ^: y5 @
|
|