|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# r& Y' |5 ~9 Y0 J i5 M: s$ }#include <linux/init.h>
$ [" ~# g8 v+ K; g! z2 i+ L3 ]#include <linux/module.h>3 u) O7 b4 r+ |9 l9 b9 s* t) p
#include <linux/kernel.h>
9 a* M* r+ n0 B q" Q#include <linux/types.h>
+ D: Z0 c' T8 c! h#include <linux/gpio.h>3 k" Z9 Z s5 h: o# D+ {* I
#include <linux/leds.h>
% h3 Z( o9 W8 R- O* K; y, |#include <linux/platform_device.h>" E1 T8 d& U, h6 W4 |% `
: I y% l" O3 B' S6 x0 E6 x
#include <asm/mach-types.h>
* V) |% _+ ~; m0 P#include <asm/mach/arch.h>; _5 C/ k; g' U2 Q+ t7 T
#include <mach/da8xx.h>8 n2 K4 S7 ^: ^% B( [$ Q
#include <mach/mux.h>
$ R& B. p' j0 J& Y' s
8 w6 ^2 o/ u7 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* W, } k4 U. |" o4 I& B1 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 x; \! i4 d- ?9 L/ t$ I7 k2 y( A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* w7 y# T* h% D4 s1 H y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 b' v. X4 i( L4 c. B& I
9 B: h/ y, U( {* c6 r2 m. z' O/* assign the tl som board LED-GPIOs*/
) h& g% ~7 m, t# [static const short da850_evm_tl_user_led_pins[] = {' E7 I7 ^' D4 y6 n& _7 V1 X
/* These pins are definition at <mach/mux.h> file */
9 h: a& c& j, S( M4 D0 C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 T2 ^ t' s. g" B -1- i) z. \$ Z9 r! b$ l. l
};
, ]1 I Q( Y; d8 V8 Q; D+ R" G+ p& a. w+ z. ~4 p
static struct gpio_led da850_evm_tl_leds[] = {
4 h: |7 `# b1 h# S! V; h0 k {
1 _$ }( X0 J/ `+ D .active_low = 0,3 H8 p y. D# ?$ [' R$ M0 b, R7 e' [& @
.gpio = DA850_USER_LED0,
' o' |5 Y! R# y' ]6 d* ` .name = "user_led0",
2 K3 y1 W" }9 R5 g2 w# Z/ P .default_trigger = "default-on",
5 |; k" h9 k* k R1 l },+ L8 ~. r) V# ]$ t: P
{
$ P% R9 V! T/ M+ H) J .active_low = 0,
, d6 ?6 U0 y& g9 V, d .gpio = DA850_USER_LED1,
8 l+ z x7 O1 [' a .name = "user_led1",
8 S& N7 n1 I Z9 V- m2 H, V. _ .default_trigger = "default-on",; p! Y0 _ |6 c) M' Q8 o/ h% y) w
},
0 E2 S; a0 B7 ?9 B. T% F! E, d { ?" p& Q) `' |
.active_low = 0,0 w5 k" q3 [$ L% B/ B
.gpio = DA850_USER_LED2,- y+ |0 P4 B, ~3 p7 N1 |$ r& m
.name = "user_led2",
2 F4 r1 `. F# ^( R& P( Q" P! q .default_trigger = "default-on",6 w) o/ h9 p. U5 M0 r
},
/ F$ b* X Y9 o) I. m {
# `( E* I2 t S8 U4 o% k0 Q/ } .active_low = 0,# f3 ^- F/ u `, x+ X9 M6 K
.gpio = DA850_USER_LED3,
0 p% m* x; Z" s% ^0 J, N0 d .name = "user_led3",3 c2 s/ A. t& T
.default_trigger = "default-on",' C/ z5 C. w; T) Y3 ^9 k
},2 P7 H$ P9 |4 l; [% E" @, z
};: X: g4 v4 i; L& e! S1 |3 ^
4 j2 Y1 R% C$ R6 N' O: F$ h0 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# F" f& l: G6 Z O* C$ p
.leds = da850_evm_tl_leds,
( q7 h6 ]- }5 O2 m. T h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 K, ^. a7 Y$ W: n# ^# ^5 C! `" Y};8 y' f0 P2 H" O* C. z+ K4 L- ]% ^* m: F
6 k2 |- ?# O- C; y' M% j
static void led_dev_release(struct device *dev)
G" {4 f7 e; q% X% U{
: d% ~8 d1 _0 s3 R9 x/ V2 C, r( o};
) U' w' U' n. i% v0 X
4 i, j. x% }5 k2 u$ g* o5 bstatic struct platform_device da850_evm_tl_leds_device = {
% |- e2 l! _' Z+ n( F& q& ] .name = "leds-gpio",
! z* _) C4 i& j$ A7 N) V; K9 { .id = 1,( Y; j4 G$ ^/ B' Q
.dev = {
, [9 z- W1 o! }. b. x+ Q/ _0 K7 @6 j .platform_data = &da850_evm_tl_leds_pdata,8 S+ ?& k1 ^' i
.release = led_dev_release,4 Y& T* h6 D$ L5 L: F7 O
}
4 V# \+ A* K D};
9 D* G2 T9 _! ?& `# [* \; I$ J" e% z0 [9 O, V8 ~) E
static int __init led_platform_init(void)1 d0 G0 n* m' d, s6 d" }+ T5 C
{
: _* Y7 f& o0 z" _! n4 i) z1 s7 W5 v int ret;
9 \% J9 G8 I9 O( I0 K" M: @#if 0
6 F! }+ o) } o; l: v" Y# j0 P% e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 n) K I1 O& ~) G, ]
if (ret)
( D; o6 A3 \7 t( d% m; l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; g4 c+ t8 s. } O7 A# @
"%d\n", ret);
: @+ O$ Z" u7 R#endif
7 V) \6 h$ ]: }6 a r2 @) s# a ret = platform_device_register(&da850_evm_tl_leds_device);
2 P" @7 X$ X+ ?' f( x if (ret)( O0 ]# h' R5 ^
pr_warning("Could not register som GPIO expander LEDS");4 M2 K* ^7 c) L5 S' e
else7 e$ t' f& j: T |" U2 n
printk(KERN_INFO "LED register sucessful!\n");3 }6 z3 P$ l+ n1 e% \9 ^3 V6 R
" y; U- F: M4 y) m7 Z return ret;
( C' T# Y8 k5 W2 l( z! h) ~}
! n U$ O) @. L2 ]& k) H- h* }; W, ~
. o* ]3 v+ ~3 w. T5 c& \static void __exit led_platform_exit(void). T" u) G% V2 c& |7 q- B. y- O
{8 j. d6 \& [2 o8 R- t3 \" o% b) V/ o
platform_device_unregister(&da850_evm_tl_leds_device);
i V6 c* G3 b% n1 l' _, J5 D. v8 h; ]9 d
printk(KERN_INFO "LED unregister!\n");7 ?! _' }7 x, ^7 [) X
}
! {' e t3 [5 `- Y) N! S8 ]! f) k6 q# E3 i! e7 `( J
module_init(led_platform_init);/ J s1 N" r8 l- n3 g# S
module_exit(led_platform_exit);
4 Q3 D3 w5 s& ?! \3 a y
5 ^7 }1 _* k3 X, X( FMODULE_DESCRIPTION("Led platform driver");; |7 g; r4 G- s
MODULE_AUTHOR("Tronlong");' S7 k# `, ~/ l1 H# r. T" L
MODULE_LICENSE("GPL");9 w, s' C u$ p
4 d1 T, Q: e D9 ^
|
|