|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" z! x) y, U5 _4 N5 B+ U/ S. J! Z#include <linux/init.h>- y6 b5 h' @0 A
#include <linux/module.h>
* j: P; b) O6 x+ C#include <linux/kernel.h>0 c5 I/ F% H' s
#include <linux/types.h>
4 v4 b8 `8 w9 j7 s7 m8 V#include <linux/gpio.h>
, X. k' J* ?, Q2 g#include <linux/leds.h>+ _9 B; P4 E2 m9 }! B) c
#include <linux/platform_device.h>: l( Y( d% }8 d7 [' e4 e, b' n
/ P x; A! E9 f9 X. g#include <asm/mach-types.h>: Y: _$ K8 Z+ p e' f k
#include <asm/mach/arch.h>
- O2 f$ d& z) d3 r9 |#include <mach/da8xx.h>$ [7 Z3 H: q4 S8 d' G0 Q
#include <mach/mux.h>
) d) o% d' |: ^
! u1 a. g C( w2 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ \1 G y/ Y1 H* C; O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. H! C, B: n A6 ^! B; D0 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 F, g e. t+ J5 r& J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; {4 r5 u+ S5 d+ e" ^7 L% D2 U
: F+ {4 i: _1 O! h: `/* assign the tl som board LED-GPIOs*/+ V) N" v7 M) F- p+ _+ N! s+ ?) N K
static const short da850_evm_tl_user_led_pins[] = {
+ P4 C$ I9 M* H- N3 q/ _ /* These pins are definition at <mach/mux.h> file */
/ U& X; p9 C2 |) _% E( [0 K/ M; I) p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 E7 _. a( N5 j3 ^3 I' I' t
-19 p8 | K# C& M. y
};
: ~( v* g+ `! a1 c
+ n' }; S2 f; wstatic struct gpio_led da850_evm_tl_leds[] = {
- O+ [! v- D s* _: ]6 k! ~ {: B* a# E5 }2 N2 X3 t
.active_low = 0,
Y7 t( q P' { G$ S" t+ h .gpio = DA850_USER_LED0,; H }$ s' V0 m8 h% f
.name = "user_led0",# {$ q @, c1 I: ^+ @' Q0 Q1 M, f9 B
.default_trigger = "default-on",8 H F9 N; m; M Z g7 K# T
},
3 L) q7 ^ Y& e1 p! d {7 ?% H7 B- W& d# y4 I- L" T! p
.active_low = 0,
7 c" e q, |: n9 D' q! _; [ .gpio = DA850_USER_LED1,
/ E- s1 p* o9 p( n .name = "user_led1",, g- l( u4 z/ J: o1 ~" t7 |5 P* R$ d
.default_trigger = "default-on",
# D5 n7 D1 s* \8 }; G& f0 D& t },9 B9 ^! S" B, d) \* {( X! ?
{
. }3 [: K* N: A .active_low = 0,
/ n1 P2 n% M8 p .gpio = DA850_USER_LED2,+ |# ^+ k6 r( f9 K5 e+ m1 {
.name = "user_led2",% v5 a p5 I6 z5 f
.default_trigger = "default-on",
: q# Q5 Z* M0 A) k7 L4 O8 b p U },
& q- n. B- }! S3 x {) {$ `) E# h1 j8 h& b% n" h" N4 P
.active_low = 0,/ v) }9 B9 ^- K1 t2 E6 f @; K
.gpio = DA850_USER_LED3,
) U1 Q' v# P' P% e$ B) h$ W3 R# \" ? .name = "user_led3",
9 `- h: p3 f) F& w5 h .default_trigger = "default-on",
# }$ J# ]$ Y& W+ X },
6 B2 k! D) X' R$ H1 a& F$ O6 v};! F4 f3 J1 ]" o9 k" e
. m9 B- u" S3 |4 a& M+ H7 g" n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ V( L" ~) }: K# Y$ n( F# ^4 a
.leds = da850_evm_tl_leds,
* V0 ]7 r( z+ _2 O. V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 p Q1 `. S! H5 ~% i
};
+ K' L* p6 t: t7 p, U3 Q2 H; i1 k2 ?* V. r, J6 S; j
static void led_dev_release(struct device *dev)4 g9 V$ M9 h5 j: t. h& L# p
{. u- h/ i5 V4 v b7 ?/ q0 D
};
; e6 q6 L* Y8 ~1 r; b7 \1 ]6 F
: W3 G5 C3 R+ g0 B E- |2 `static struct platform_device da850_evm_tl_leds_device = {- Y$ ?- }/ F$ r/ K( T
.name = "leds-gpio",. y( ], R5 p3 ]$ b( \/ z
.id = 1,
# ^9 j) [- f4 m: x .dev = {( Y/ C5 I7 L& W, ]; w
.platform_data = &da850_evm_tl_leds_pdata,( @, l/ W9 e& C" q; V v
.release = led_dev_release,
6 b2 P, ^; I ~$ O Z5 f1 f }
, y& L0 }# m3 j7 s3 g+ W) t}; ~7 N; U m8 w% J7 u I( S; A
# F9 y; K }) A" ?) Y" Istatic int __init led_platform_init(void)
- @) K3 w7 q5 r& ~; ]; e0 ~0 d{. o/ B- w, \/ `1 U4 Q
int ret;
+ r& ^+ B/ w6 f2 @9 R#if 0
/ C6 h( R: S9 v3 T7 K. w8 D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 @# S. M" h' X4 P+ n if (ret)) l9 J7 \( H" v* {. n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 E9 t. j5 k4 Z3 Y
"%d\n", ret);$ r* @( X# n, s+ W, H1 U2 Y
#endif
% p+ i- @/ i9 g: D& B5 C ret = platform_device_register(&da850_evm_tl_leds_device);- F m( P, E8 z+ t% u S
if (ret)
r0 [% ]6 B- m( B pr_warning("Could not register som GPIO expander LEDS");
2 C. R5 o2 h+ m7 X) x else0 m$ w; @1 b. m. `" X
printk(KERN_INFO "LED register sucessful!\n");/ C v1 q" f2 Y1 _5 T& i
( |0 n4 I0 G1 J) u1 ~0 A
return ret;
M* Q( M( T/ }}
9 o% T. c+ c- C7 p6 U( y: Y- r2 M$ k" q# L: h! }; Y$ m1 P6 M9 }
static void __exit led_platform_exit(void)& ~4 V8 \. R( ?0 @
{
: I6 m, H6 v2 y: L: j platform_device_unregister(&da850_evm_tl_leds_device);
4 Z0 p. @) E( E6 f& I3 e& w! ~; K/ p* \0 i/ z- d) M+ j
printk(KERN_INFO "LED unregister!\n");+ j$ _9 p: U/ A1 ]
}
4 n3 `3 t; \( ]. |1 t. w3 ]6 x6 l9 T' y( a
module_init(led_platform_init);
( \5 y$ u- w) j* `! Kmodule_exit(led_platform_exit);
8 Q) X' `# Y$ t3 ^; y: p- Z
. i- K7 w- g' w! F4 NMODULE_DESCRIPTION("Led platform driver");
& {4 |- z7 l1 hMODULE_AUTHOR("Tronlong");% b) Z/ C, H( ]8 N1 D# l7 Z+ T, I8 [
MODULE_LICENSE("GPL");% _- s- e! g( T
) m$ L; h+ g, ~! _
|
|