|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 d( J! C/ D9 L) Q#include <linux/init.h>+ K9 h* |8 M6 U4 A
#include <linux/module.h>
' y* q% {' `. L* u( A#include <linux/kernel.h>
1 F2 s2 m/ `9 K1 r& w#include <linux/types.h>( Z% ~ @5 ?8 t3 u
#include <linux/gpio.h># u" ?1 Y) P6 y* x. F: j+ {$ h- w$ T
#include <linux/leds.h>
% x) h [+ d$ m$ I" W; U3 e#include <linux/platform_device.h>
& `" h4 B6 R, h# i
3 J! E2 \" m4 \/ }# c. F#include <asm/mach-types.h>7 i: G7 Y" }0 w% V o& D" m. p7 h
#include <asm/mach/arch.h>
8 G; p4 y( Y1 D l: w#include <mach/da8xx.h>
0 D1 n9 n2 I$ a% ]- b8 n# ^#include <mach/mux.h># g( [# g* X* J1 k$ W
6 R4 W* `( X% z" d; Y1 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. c6 B8 H" k. I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ p2 U* V+ N) X, C v* x+ x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% @- @, e- j$ S) G4 l9 R. i- w! A$ u( h" Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- u8 B! B0 T6 |" l$ X
+ {: T8 }: S& u/ d; w& L ~' V$ J/* assign the tl som board LED-GPIOs*/
. g, g6 B; j4 q# K5 I3 w3 P+ {static const short da850_evm_tl_user_led_pins[] = {4 L' B; M: f- z* V
/* These pins are definition at <mach/mux.h> file */
$ n5 X8 G5 S9 z. G) X! @; k( P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( h2 ~6 l) [9 t M0 R
-12 H9 ~2 @, f/ [4 \4 S* `
};/ l/ F5 h" `3 {' R
( k7 I1 u6 \% W+ A
static struct gpio_led da850_evm_tl_leds[] = {. z3 z- k$ i8 Q/ }' V) b7 y
{ u" S$ G7 G" M2 ]6 y4 |. W9 J
.active_low = 0,9 ]! C: Z3 b/ V7 a: [' N
.gpio = DA850_USER_LED0,. H" m& ?* O5 ~ S1 f
.name = "user_led0",
9 l8 Q* j& [2 q .default_trigger = "default-on",, y; f: Y, e( { a2 ~& |
},6 c2 N+ I) n* k" {
{
. Y/ u- M( r) a8 b) R' ]$ K! _- _ .active_low = 0,+ h4 u3 |7 V5 W. E3 q% |
.gpio = DA850_USER_LED1,6 u* u9 a/ U i. ~( r0 L
.name = "user_led1",
7 Z, ]/ ~" P9 r# E" ~2 A' Y6 X& H0 K .default_trigger = "default-on",
4 D4 V' [ v2 {% Q },; S* z; e( @6 o; @% ~' ?; j
{
+ G5 P! P6 ^( p* y9 m8 c .active_low = 0,
" D# i# r* c# H- v6 j" f .gpio = DA850_USER_LED2,; m0 O5 Q) J! K( l) L
.name = "user_led2",
1 S" P" J* A; [/ p; d. O .default_trigger = "default-on",
0 u' R& j0 p% a6 |, m2 c5 o },
2 e6 r$ z% U& T6 T {
- \* j) {# `9 H: F; Q .active_low = 0,
" u& O9 N/ j, E .gpio = DA850_USER_LED3,$ b/ r% @$ g) r; l% i
.name = "user_led3",5 W. u9 z! G" \
.default_trigger = "default-on",- |, n( Z0 m" ?/ S) x0 z/ ]
},
. J$ Z8 F, f% `! `- n};
: N5 E- ~4 p) p F$ {* F! p
% A4 x" O' Y- j' x! E4 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ b# D* M- u, d: ]
.leds = da850_evm_tl_leds," M& t2 U( J: {6 E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 I" r, O; j1 r
};; F) r* D. w( H d) u, [* b
) k4 p5 f- s7 m* Sstatic void led_dev_release(struct device *dev)9 y1 i; s" N; ]6 T1 A, ?
{
1 \( S c/ l$ e( R! a};
6 [0 Y7 p/ V: m {) z9 R: q
$ Y" {: K! o* w! |* r4 M7 K Cstatic struct platform_device da850_evm_tl_leds_device = {) z: e8 Y4 c0 [+ T2 R8 R& [0 V2 |
.name = "leds-gpio",% Y2 d9 i7 E5 W
.id = 1,
9 M' {( h- y% w, O .dev = {. b/ W# Q" _ R" b q- R0 H
.platform_data = &da850_evm_tl_leds_pdata,
/ Y4 _5 w! K3 B0 A" n .release = led_dev_release,) B( Z+ Q1 c. g! |3 Z7 l2 z
}
k- s0 ?6 i2 w( N};1 g: I3 ~" N* _- u2 N7 |
$ Z2 q( s/ C1 t7 [3 v& A. rstatic int __init led_platform_init(void)
0 `: B! G$ E- g{
- d1 U9 y1 G+ y4 M; C int ret;
6 P. e* ~" e/ ?5 J* R#if 06 m6 }) z# y& b' i! I8 D: S" ^3 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ x0 w k+ J8 @! o. H: R5 f
if (ret)
4 B) U6 D, v Y [) z! c c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 I1 p8 ? \0 p D) y; } "%d\n", ret);* ?$ a4 L( V4 P2 @6 R8 I7 ?$ b0 u- }
#endif
3 v: o8 c3 T* c: h# V$ X ret = platform_device_register(&da850_evm_tl_leds_device);4 S4 M3 m8 y+ Y/ I- r+ ]
if (ret)* ] Q* G8 o5 _$ t: d5 y" k- h
pr_warning("Could not register som GPIO expander LEDS");
( V. O! Y1 I4 j& [+ r else5 v4 D* Q2 F0 @. K
printk(KERN_INFO "LED register sucessful!\n");
9 m Y, }, a g; p0 h
) i8 q9 t, v+ x B" r2 \# Q return ret;5 x8 f5 F! e& u/ v8 y
}
7 a( h: V- T! U. Z3 K- m0 G* H; F) [2 {
static void __exit led_platform_exit(void)
$ F- \. E2 _$ O$ H+ b! O$ x{* N n1 v& q5 b& s
platform_device_unregister(&da850_evm_tl_leds_device);4 w: R9 |3 _$ R' s* W
, g# y/ q2 F7 L
printk(KERN_INFO "LED unregister!\n");% L- }1 h! ]- |5 `, u
}' r% f H6 e& ~3 t5 Z- `' @
6 Q, s& l% V7 U5 \6 ?7 H
module_init(led_platform_init);
, @& u H0 e( X0 h' o& smodule_exit(led_platform_exit);
% y; t6 b/ V* L1 Z0 V
: n7 [4 z' l: P/ OMODULE_DESCRIPTION("Led platform driver");
. X2 q1 n; Q1 R& Z- @' {! PMODULE_AUTHOR("Tronlong");
. h( e6 N5 p+ oMODULE_LICENSE("GPL");, ? \& Z, k) i+ y/ _) d& s& ]- W
/ U" P5 j1 m% [! @' X* T
|
|