|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 T" g2 I) z% |8 c( e4 P2 P
#include <linux/init.h>
( n5 j+ R* x+ f6 l#include <linux/module.h>
& F- }, Y2 H2 ]0 T2 S% R#include <linux/kernel.h>
" x6 P( p5 Y! F: \6 w+ U#include <linux/types.h>
) ]; U C1 t! S/ i D$ m#include <linux/gpio.h>
* |0 D" k3 X" }4 G' v( Y& K; I! f#include <linux/leds.h>1 N) N: i4 _% e8 L) I
#include <linux/platform_device.h>
/ U; ?! ^' \! R4 Q
' s* d" C4 u& @#include <asm/mach-types.h>* O* p7 X1 @6 [6 C
#include <asm/mach/arch.h>0 w$ y+ l% X c: O! n
#include <mach/da8xx.h>9 ^& F( S* D; ?" i g m5 @
#include <mach/mux.h>
% z3 g6 T' x: q1 q! f( n9 x/ _
, `+ M/ Z$ f3 w/ e! ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ o @ h" O! M& H* n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 Y* ]7 ~+ C# [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) J! u( m. Y' H3 Q( i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- M9 N/ O0 P' S1 ~) [
% _' }4 Y4 }* {( F
/* assign the tl som board LED-GPIOs*/7 L' a% ]; }/ w% g/ M' }
static const short da850_evm_tl_user_led_pins[] = {, p$ W _* W& h
/* These pins are definition at <mach/mux.h> file */
# z4 C v: Z9 k3 V" c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 s" s) s# X, u: Z -1
6 \' _: {5 A+ f) x};8 Q; ?6 E4 n# Y0 A5 }2 E7 D; e
# L- U' J6 B- T! ]% istatic struct gpio_led da850_evm_tl_leds[] = {
) H' I$ ^4 y! ^" B* z# u {$ X" m9 r/ N# O$ R# K- A5 t
.active_low = 0,
+ Y9 w, D8 S# h" l% f' r .gpio = DA850_USER_LED0, ^# d v) x+ G: U% i
.name = "user_led0",! c) Q/ o, d) E0 ?, A$ j; a
.default_trigger = "default-on",
+ V& W8 O" r3 u9 N+ w- C$ t },+ W+ {3 G# v: d$ K' l8 E
{ K6 s2 k' }& d/ v) o9 M
.active_low = 0,0 Y2 P1 \( t) o: R& W1 c' B' H
.gpio = DA850_USER_LED1,
$ L( a* ?" x5 \2 F0 [( r% C .name = "user_led1",# M8 Z, g' H2 T: s
.default_trigger = "default-on",1 Q3 D1 J% E* U/ i
},% I4 F, d) G3 [8 l9 e/ ]# d3 c! f+ i
{& R+ S0 L1 k$ a$ P3 h
.active_low = 0,$ V$ B; l. C' f& l6 l
.gpio = DA850_USER_LED2,
/ o2 j8 p' S/ w& h5 x- q .name = "user_led2",
* O, f/ l Q* z& l& P U .default_trigger = "default-on",0 w8 i& x3 G( ~' z$ W4 {# P( N
},
' M2 m6 ^. n( U2 |" K {
' H4 k* v; ], L+ |8 \! ?6 ]/ @ .active_low = 0,
9 n( p' A! s2 Q% A/ L7 j .gpio = DA850_USER_LED3,
. J; w5 a4 v& x2 f- _0 x .name = "user_led3",) X4 ]* m+ l0 B* T6 e/ p* Z8 c
.default_trigger = "default-on",
+ ^( V T+ w( J' }: E },
- N9 C- U5 ]9 E2 v# Y8 P}; i* Q# M7 |1 A# x
0 y& b: |% T4 d0 F3 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# t* M6 _0 |/ t .leds = da850_evm_tl_leds,
" T& {' t: m# D0 w- J! t/ a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# H' Z- ~9 ~3 x2 s3 y: A
};
& K& g3 x' }7 H: F& R; I2 B) e' r1 j% U1 N& r% m4 Q
static void led_dev_release(struct device *dev)0 x: }1 w! e" e; {1 @
{
) X" ] O( b- G9 W( M" L};, R6 I* z- \- {/ o; ^, b3 d
! I/ r" V. ]8 u' U3 s# c* h) I
static struct platform_device da850_evm_tl_leds_device = {
4 z) O* W1 @1 v, a" [0 y6 u# P .name = "leds-gpio",
( i. |) Z/ O% K5 l/ Y .id = 1,( S* ]: [7 m; U6 l1 i6 Q, r6 I0 M
.dev = {
9 m# \0 ~: A& E% [! o .platform_data = &da850_evm_tl_leds_pdata,
3 B. z% x& c% F, G! g .release = led_dev_release,: m) B) Q- M" w0 y
}
, @) G T- l& k3 Q" G6 x( a/ a};
U& F: W1 W6 c" j+ r! k6 K5 ?; M1 T( ~2 b# o8 F! R
static int __init led_platform_init(void)% I1 {0 q; M5 Z3 l/ Y2 e! J- m
{
( N1 d" s( Q! P6 ? int ret; i. ^9 w& B+ G6 X8 f$ H8 G7 _
#if 0
% m6 R5 Z m, c4 B! {1 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) O, S; ^! E0 r* P8 g7 K- f if (ret)
8 _, Q- V4 j2 f( L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; A; U( J& s I2 |: Z
"%d\n", ret); h1 h" }% T' ^) \& s
#endif
- n/ b z% M2 l/ c2 e7 [ ret = platform_device_register(&da850_evm_tl_leds_device);
7 t$ X$ Z7 x. j if (ret)
! F2 Q7 e# M- i' Z6 g `6 A* O. U9 r pr_warning("Could not register som GPIO expander LEDS");
. \' E2 q3 t4 E# L! Z$ P# F2 f else, h9 E7 k% ?# d: W8 S! ?" ~
printk(KERN_INFO "LED register sucessful!\n");
! K( K4 a* r& W4 g( N! m; V8 [
) u0 g8 _2 E1 v4 p& p- x8 } return ret;8 ` ]3 i) J8 ~, h
}
/ z7 x0 q8 b8 x4 W' U
9 i" M' J' x$ S9 ?0 Lstatic void __exit led_platform_exit(void)% [" N3 C- }0 C% j: E2 C
{
" s+ o& C, U) s+ ]4 D2 _9 ^& L w: A9 W platform_device_unregister(&da850_evm_tl_leds_device);
% f+ P9 S8 N! m4 ^- y& A9 k6 Q. g& p/ e" d
printk(KERN_INFO "LED unregister!\n");& }" ?' J S0 \0 \0 ^
}. W' `. |" w$ j+ i# u
5 ]" H/ m3 R0 }7 H$ ^ omodule_init(led_platform_init);, ~) g* E2 w( l; ]) ` ?. ?
module_exit(led_platform_exit);
. X5 t; S& K& f5 J& Z, z C& W5 m3 Q* A3 V
MODULE_DESCRIPTION("Led platform driver");7 d# g6 w3 i7 H! @
MODULE_AUTHOR("Tronlong");
3 h$ m& _! f) P7 ~& X1 S8 t( oMODULE_LICENSE("GPL");9 ]$ \4 T* {) _; y' O; j
& p) x" p$ D ]& X |
|