|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) r! c/ H2 H3 B: ?& N7 t#include <linux/init.h> v7 Y7 Z$ h2 } c! O
#include <linux/module.h>* H( d& m1 A2 Q# ^# q2 A: _
#include <linux/kernel.h>
3 X1 U4 j3 k! H" i3 h- ^; m* O#include <linux/types.h>
1 B& ~6 f; C, b! Y#include <linux/gpio.h>
2 h2 F9 m5 m7 F#include <linux/leds.h>9 d0 B: ?( q5 Y1 J
#include <linux/platform_device.h>
0 U7 b; P D$ i7 O6 ?- H
}/ \4 }6 @2 K4 J) p F# }! i#include <asm/mach-types.h>) R* h/ b4 E, x9 |) c
#include <asm/mach/arch.h>2 W1 ~, [8 B) I/ d* n4 B
#include <mach/da8xx.h>
/ Y, v [, a0 E0 D4 u#include <mach/mux.h>
, F4 n; R) [2 m4 P8 J# p! H+ k' i. _7 H! o1 l8 |' X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 E5 K3 n O& F9 j: ~1 ~% |$ {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" E6 G8 `* U& R; X. q* ?! ~& Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): L: ?- J, Z3 w: ]' \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 r; U8 C4 n0 d3 X& Z% m m. c" B
) m1 x `4 U8 @- g
/* assign the tl som board LED-GPIOs*/" \3 K* C3 j, T7 K) c
static const short da850_evm_tl_user_led_pins[] = {# u( v- G1 P9 D* G* q
/* These pins are definition at <mach/mux.h> file */& |8 }2 E9 ]# U$ y1 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& j6 \# T9 P1 N h' Q) |% P1 n- v -1& l+ y+ B9 r9 j1 h
};
6 N, U) j f7 I0 ~- Z
; F4 L8 x! c0 r- B; X6 `: P2 |static struct gpio_led da850_evm_tl_leds[] = {
5 f3 B: W2 c0 _" D/ {$ X! M$ I {6 g; P o7 u( A- G3 G
.active_low = 0,! _2 p' r# c" V# k2 L8 F
.gpio = DA850_USER_LED0,8 `. {0 O1 i( k4 [$ D" r- d( } R
.name = "user_led0",
* A/ N0 `9 H) X .default_trigger = "default-on",6 {$ [5 Q# a; ]; o
},: b! V& h2 v- C# z
{
; s/ x! b' {3 a2 b! M .active_low = 0,0 m" j9 t6 o: ]: `3 E( d% l
.gpio = DA850_USER_LED1,
. h2 `7 u1 ?8 I6 e .name = "user_led1",
l O4 s& J$ O' S- |8 i .default_trigger = "default-on",
/ _$ h4 d- O" ~8 z. [! n: o },+ W: Y& W) g5 {; o
{
( D* O" J0 X' P0 k$ q6 T .active_low = 0,) M; l1 \- @0 s
.gpio = DA850_USER_LED2,
1 b! W; {" ]0 w7 _/ O .name = "user_led2",
; {* H" y \/ h3 b .default_trigger = "default-on",0 O% ~# x1 v: P( `8 F- K3 H4 m* ?
},
% j2 O( w6 B7 f' Y3 E8 a8 ] {
" C% p/ O3 g# T) H. N" ] .active_low = 0,
2 |5 P9 B. c. ?8 R* O" U ~% l .gpio = DA850_USER_LED3,
" ?% W$ d4 O# d6 _+ }7 V% D .name = "user_led3",9 |) |" c" M) n# w0 q# R# [
.default_trigger = "default-on",
1 W8 i- V! ~4 ` },) }/ a* E) q' P. W2 ~8 R7 |/ H
};
. Y1 w# o6 w% F- k6 r4 g: V# X7 m; Y" q8 r3 E$ R: T0 v a( h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 ?9 k$ f& q; f: c- B2 p
.leds = da850_evm_tl_leds,
# X+ ?6 {+ C' r2 D5 d1 @5 ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! H9 u3 ^' _1 i5 q% h! O, D0 }0 G: T};
- v3 i4 Z* K: ~, R# @7 _8 d* T. h% e; A2 \
static void led_dev_release(struct device *dev)* D u# R5 f8 u% H, z
{9 w) b; H. \2 p/ K% ~/ p8 q
};- l% r5 I( U6 U8 K- n
# ~. |. p8 t8 ~7 @/ M8 Q- N; V
static struct platform_device da850_evm_tl_leds_device = {
- @ u4 A, q9 C8 k) \. L) {6 O* W .name = "leds-gpio",; `" g( @. `9 @* t: `2 x; c l6 S+ @
.id = 1,, }; G$ B' ?( H8 h+ @* N d
.dev = {: L* |! r* \! U5 G
.platform_data = &da850_evm_tl_leds_pdata,
2 u3 y6 C* \" Y% { .release = led_dev_release,% |' S2 O% R$ M! z4 z# m+ v1 X
}! Y- z4 y6 [2 H z- w# ^ z! y
};
' y* n! P' w4 M" ?( ~
5 Y& s5 V5 x* Xstatic int __init led_platform_init(void)
: U4 ?9 b& F: @4 i' R+ G/ `# m{
" u. f; W8 `1 _+ @8 h int ret;
3 t7 z/ N( q" ]. ]( W6 {3 |( Z#if 0
) ?% L% q; Z" R0 k" C: ]' t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ n6 ^: e$ A* {$ G1 u0 {9 L
if (ret)1 m0 N0 Z; w5 J3 H" x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; J7 F' V' U8 ^4 z$ f- g
"%d\n", ret);' L$ o6 L$ {- D7 L% I
#endif
! z3 q+ S1 Z% t! \8 b ret = platform_device_register(&da850_evm_tl_leds_device);
! A5 ^% W" _: x& g7 x7 B if (ret). h5 h4 {; B7 W+ f
pr_warning("Could not register som GPIO expander LEDS");, k/ s9 O1 p) Y/ L/ ~
else. [. }* u: R7 @1 g; Z- y9 B
printk(KERN_INFO "LED register sucessful!\n");
4 T- B1 }6 u+ H1 e( ]0 k A1 u% R( [9 e* _
return ret;$ T+ `, M X0 Z- w) [7 _
}2 P! _3 X$ w6 s$ J
. e! X* j8 O/ G$ T
static void __exit led_platform_exit(void) b, ]7 d4 s) V3 v9 q" i
{
: O0 t8 V! x/ y6 p9 ^1 `$ ]& P platform_device_unregister(&da850_evm_tl_leds_device);+ Z' j+ `8 _1 R# s% ?3 G
+ w# d" F' N3 u5 v
printk(KERN_INFO "LED unregister!\n");
4 e% t& ?+ P; e1 H5 q2 W* w}
3 ^9 |: v# o; q* e, Q9 p8 f# J$ e+ Z) K/ e* H I+ H" _$ p
module_init(led_platform_init);4 G+ o4 u$ B1 m, r& a! e4 @
module_exit(led_platform_exit);0 n) t1 t% A3 `( I( c
5 ?" U4 G! N' r, {) z( [$ X. WMODULE_DESCRIPTION("Led platform driver");
& @& q$ d: h( P; d! o* O& p+ ]MODULE_AUTHOR("Tronlong");
b" n, U6 _/ aMODULE_LICENSE("GPL");) |3 e+ V" Y# n! b( G
& R- z: Q0 Z$ d# J/ o6 c. B4 h |
|