|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 Q' W, }; W* D* b#include <linux/init.h># D" t3 Q: L9 |1 a
#include <linux/module.h>& K0 x g7 m) h/ ~5 t8 H& F' u9 I
#include <linux/kernel.h>
8 g6 b0 `$ g h3 \! C#include <linux/types.h>* k/ @4 \/ b/ }2 d, c% _ z
#include <linux/gpio.h>
2 ~- V2 _- u0 U6 |; ?& G ~$ P y#include <linux/leds.h>! K% c( O6 k( O: f
#include <linux/platform_device.h>3 N) N$ [% y! ]
/ U$ U- z0 a& B3 S#include <asm/mach-types.h>2 L7 Z. H1 q# A
#include <asm/mach/arch.h>. x6 Q# l& d" `, F3 f
#include <mach/da8xx.h>! @/ s$ [4 J0 x) l; F1 _$ }2 L8 g
#include <mach/mux.h>
, ` F% {( Z3 c8 f1 p+ q8 S2 x2 J
8 Q' {4 J z& I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). g% P& ]) A. \3 j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 d' y1 M; K% `' U& o j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: L, M4 |3 B& k, d4 H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, w" Y$ o) c7 W7 v: G- t! V% q+ B8 P( p- _
/* assign the tl som board LED-GPIOs*/
5 R5 P4 u$ s+ {- s+ Ystatic const short da850_evm_tl_user_led_pins[] = {
; r+ y1 S1 ?& b1 b1 v' Y8 k) q& t /* These pins are definition at <mach/mux.h> file */
. x& N! t8 [4 ^7 |1 @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, x9 l! J# e' y9 [; j
-15 t! D9 e: t1 ]9 N$ |/ ]
};. t# f- @+ V* s# d h
5 e' |& S, |& V+ I. p+ h/ }8 ?
static struct gpio_led da850_evm_tl_leds[] = {
6 u- e& }4 }7 f, q' T1 w {3 Q& A- C* p; |6 L. S8 u
.active_low = 0,: N C. ~2 |- d- t! P. c- N+ v
.gpio = DA850_USER_LED0,$ W6 L: ` |3 R* i7 J+ @1 D2 M
.name = "user_led0",- x r9 A+ F6 Q/ A
.default_trigger = "default-on",
2 F2 Y d0 }/ Z) e1 T! w },
# @4 X4 S W' E% G, d9 v/ \. P5 c {6 e/ T% N: ]# }, ~( j7 o
.active_low = 0,
& o7 T. ]" @8 U& d .gpio = DA850_USER_LED1,
+ k! y& b$ z1 E0 ^6 u .name = "user_led1",$ w; \( o" ?% [1 R; V
.default_trigger = "default-on",
3 Q5 ]' |* z+ b+ Y( l$ U' G5 T },+ q2 Y7 ?4 Y: o0 q- w
{/ p" G4 H0 |; y& c
.active_low = 0,
6 @1 J+ e7 o' d .gpio = DA850_USER_LED2,
, V$ C! m$ _, m; a, `, n/ Y .name = "user_led2",' F( D ?$ z2 E$ z4 q) S0 f
.default_trigger = "default-on",
3 r! S. x. s) m6 x# V },, v4 Y% T: L6 \/ ^+ g3 @
{
' P4 a# |! \) v9 |# D6 h- x .active_low = 0,
7 l8 j/ ?, F5 O( g8 q7 z) _+ I .gpio = DA850_USER_LED3,* J+ r9 r0 Q: C, a: K. F, g
.name = "user_led3",
: W% n9 F/ k# f8 `0 Z A .default_trigger = "default-on",
1 T$ ^7 l! b1 {, k5 M },. o4 d) V2 j; Q+ ]
};
# t/ J3 b4 ?* _) Z$ `4 R& o6 ^) R; `- j- R5 I2 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 m. @! i7 V, I7 c5 D k1 R .leds = da850_evm_tl_leds,$ [1 |2 K; S, }' K! R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 V2 s, q% P$ M! [) ]/ d9 C
};
$ X6 b3 C6 `$ h& g* {+ _' m2 C2 {: b& }8 {
static void led_dev_release(struct device *dev)
" }5 {6 ^* G( d4 S& C{
" N' R/ X. u" e" w& w( ?* E};
6 W1 O+ a. |; ?5 j- g8 M/ [6 P: M" T. |
: `' B9 A- D$ k6 Istatic struct platform_device da850_evm_tl_leds_device = {. w( u g* @5 r3 |4 N2 h" i2 {
.name = "leds-gpio",$ V) M) g6 i7 k+ H i& Q% p9 l, S
.id = 1,$ [, M, e B3 _4 L% f; Z' f
.dev = {% |% v4 {! o `3 n, x
.platform_data = &da850_evm_tl_leds_pdata,
* s% F: Q& l0 u& D. h9 {, k# y7 Z5 L .release = led_dev_release,
( s W5 j1 f* i" K }
- y/ y7 g5 U& m) C$ R};0 x. i* ]4 W! P. }0 m/ S# q/ ]
1 y' s, y" t. g" u( h3 v
static int __init led_platform_init(void)7 y! v7 U$ E9 W- R) v- W* k
{
2 f# M- H* e$ A- j int ret;' I) Y' k+ {+ d* W: m! Z! X s
#if 0
0 G# W) j) q2 ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 ~, Y# d! D, w& o5 \) E+ `
if (ret)
# h: y+ H$ h$ g+ |- O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 T c# V4 W4 f8 ?% I
"%d\n", ret);) k5 U! d( Y5 L2 E
#endif
, Q% l: S6 n+ M) A/ \2 I ret = platform_device_register(&da850_evm_tl_leds_device);0 T; `4 q* O! @- f+ k
if (ret)
& P2 R- H' f0 P, g+ V4 k2 z pr_warning("Could not register som GPIO expander LEDS");- }$ z5 j, G D' n3 R3 G
else7 Q& W% T1 y n# X/ l0 C6 G
printk(KERN_INFO "LED register sucessful!\n");
9 v* w. t4 }2 _$ e4 U8 A5 m. ^: R6 `6 {2 j
return ret;# X: ~. H$ F \8 T$ D
}' |( [' I2 @. l6 ^
2 H4 G0 v2 k! h1 Dstatic void __exit led_platform_exit(void)
7 O; A+ t+ E0 J5 L0 c; H3 _{
/ q6 _9 I6 L$ z3 p platform_device_unregister(&da850_evm_tl_leds_device);
& L; m- \- R4 p4 x/ C8 Y5 r b! i( K
printk(KERN_INFO "LED unregister!\n");& b8 P# d8 M+ M9 P: k) I
}* R- q4 r6 q/ m( R8 {$ r
" H. C+ W# E z' b' |/ R' wmodule_init(led_platform_init);, |8 @& G9 C* r1 f3 Y
module_exit(led_platform_exit);
+ k; Q+ ^; |, l: [2 c; ]
% G9 t9 G8 A! V! {MODULE_DESCRIPTION("Led platform driver");$ R7 P2 X, r2 ^& O7 f* \; `7 t9 _, M
MODULE_AUTHOR("Tronlong");/ ]# [( N9 ]) u, O
MODULE_LICENSE("GPL");! L8 d9 J1 ]- N$ @
6 q7 m2 t6 k1 C/ q) F' P |
|