|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% S1 M/ U* E& ^3 x7 ^) r4 c: R4 k#include <linux/init.h>! C' P& A$ g5 w2 J0 W
#include <linux/module.h>
9 r6 B# L0 ~( S2 N( k6 [#include <linux/kernel.h>
& F% f: e# k" d. r7 N#include <linux/types.h>
( ?% D* E2 W+ v6 A8 w#include <linux/gpio.h>
7 `! W5 E1 U. Q5 P8 L2 | O; m#include <linux/leds.h>) U8 T( z5 ~& a P
#include <linux/platform_device.h>& X! x1 Y( q. s; n
# ~* u; s0 G7 `' M' |#include <asm/mach-types.h>5 [3 t t+ `% B+ I5 E2 j' ^& {5 g
#include <asm/mach/arch.h>) j7 T4 e3 [4 A5 x! e* c% E% @" g
#include <mach/da8xx.h>8 n" N% t+ L- c% S
#include <mach/mux.h>, i; x) `! R2 E5 `4 z% r7 g/ m
1 U$ o" m- F f/ {' z8 I) d" C4 g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); e/ d$ T z/ |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ B: {/ B8 n e0 j# ~, q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; J' P& M6 u1 H& X+ Y r: m7 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ d8 h5 [% n! T' Z
" n, }# X! k; v% t/* assign the tl som board LED-GPIOs*/9 x' w) g: }* u5 r8 _, B
static const short da850_evm_tl_user_led_pins[] = {2 ^8 L7 b% C( q# i' {( y+ w
/* These pins are definition at <mach/mux.h> file */+ q: B( {" y' `) q+ j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 L- H3 ^1 H2 {5 a -1; [1 c+ [3 l, A* `* w
};
/ Z+ _4 k5 z) W; o; |9 |( `. p2 T6 S
static struct gpio_led da850_evm_tl_leds[] = { t6 X1 n3 [* F$ M- {4 h, t) O8 Q5 N
{ b- I4 w0 l) Z7 e3 _: T2 i
.active_low = 0,( G9 h7 r- @% u1 Q: `
.gpio = DA850_USER_LED0,
. \# J! i4 y1 L: @: `! M .name = "user_led0",
# O, Z( l/ e+ \) C; c8 p5 H .default_trigger = "default-on",) a. l9 ~) o0 U% w4 g
},
' v3 a" |: U; h- J8 X {% e+ ^3 d' ?8 _( E/ {
.active_low = 0,$ I% \* ^" U$ D& K# t) L* k! k8 C6 F. V
.gpio = DA850_USER_LED1,0 _8 l8 j2 t8 X8 _
.name = "user_led1",
3 `% w" a- A G+ R .default_trigger = "default-on",( A. u5 r' H- w: L/ v- g. ^) k
},
2 m) X/ N4 ~! i0 M% e/ E; n1 w& X {
4 S3 ~9 G7 O: B, g9 { .active_low = 0,
! j$ q+ \: x/ J, C. X. t .gpio = DA850_USER_LED2,* s( c+ q* U: o9 R! |
.name = "user_led2",
" }7 h6 Q1 E7 F* K/ x7 {8 ~) P) i8 u .default_trigger = "default-on",
% M: ~3 Q% C2 [5 g e# D' x },) g4 L" J3 \- P, T. N
{
2 }; |3 n! f, t% L- N .active_low = 0,
b9 V8 X4 H" ]! v; ]6 O. R .gpio = DA850_USER_LED3,
, S( p) ]5 T: D- n# i) Z4 p2 [ .name = "user_led3",4 A) L% F; G) s! a9 R; M
.default_trigger = "default-on",
K! C2 V5 F3 o7 [9 |1 V/ I! h( L. c },
! R" q: ~# n0 f" S};
# D* F( h. ^0 @9 ~* A' i( ^' r7 Z5 A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 r+ `5 z& b# D, k; J .leds = da850_evm_tl_leds,2 j7 |, R1 G# b1 J* f5 v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! K% s5 E% O$ t( q4 e0 B. i( z- }9 g};' k+ V9 h" b, Q8 h( n: c- m
- V, x F3 y0 F/ A$ sstatic void led_dev_release(struct device *dev)
& G4 p' t. z* c( A5 W{
( X/ `1 m8 U1 Q};' _/ h0 I$ g6 T7 H7 g
! E, a" n% |) ~3 e3 b. g
static struct platform_device da850_evm_tl_leds_device = {# z" e1 @" ]. t) P5 V3 ^$ y
.name = "leds-gpio",
8 R+ ^6 F/ _& Z# x .id = 1,
- o& E, \2 N+ Z! |* Y- Z .dev = {6 t3 S; C% x n) `
.platform_data = &da850_evm_tl_leds_pdata,
1 j4 L; t" H( } .release = led_dev_release,
! p+ i8 E- Y" o2 Z. x' w }3 g7 w/ P h7 T1 `% p- F
};
. E' R1 ]5 t7 W9 j' T U$ U
: \& k4 s- W, Y @6 cstatic int __init led_platform_init(void); T3 H3 H0 Y7 H& ^) H& t6 r7 ]3 h
{
7 k5 W( s* g! B int ret;2 u% {( }+ ^3 ~9 p
#if 0& w7 |. O/ l, X0 J7 E* ]1 E+ k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 ]6 y5 K4 ~4 B7 p7 `. U- R8 I/ a if (ret)
8 r& X0 r9 Q+ a$ F0 \2 L pr_warning("da850_evm_tl_leds_init : User LED mux failed :", q0 G( j- s& z$ r: b7 V6 [, E
"%d\n", ret);
. `5 |- h, c8 t+ _3 _#endif7 t( ]; r1 V- S
ret = platform_device_register(&da850_evm_tl_leds_device);. c, H: @& B" I4 v6 M' z
if (ret)
) m( V6 O( [7 h+ k& i pr_warning("Could not register som GPIO expander LEDS");
6 x! Q8 h+ ?# M8 u% _3 e. I# R5 S else
4 N$ X% K7 y5 X! ~ printk(KERN_INFO "LED register sucessful!\n");
' d2 ]0 J* Q) J8 n' c
9 o0 Y8 [) s+ I. z! \ return ret;! K1 z/ a# {/ V f! `! O i& N
}' |* u1 d0 d, e3 i
$ [! V& N B9 _/ D: W* a
static void __exit led_platform_exit(void)
( S. y. o% J4 k# O: m2 r" b+ U{" z0 D3 Q; u2 L2 L
platform_device_unregister(&da850_evm_tl_leds_device);
9 m' d" i- s* J" q7 e- ]9 Y l) i& r5 J% @, c, C
printk(KERN_INFO "LED unregister!\n");% B( o3 j- [% f0 _' \
}. ^; i% t7 m& B; S
% O7 ~' A/ N9 ^0 f
module_init(led_platform_init);
& \) a, N" ?& S7 B; n& Fmodule_exit(led_platform_exit);0 D! V5 T* H2 z1 `& v* U
' D! c, A4 ? IMODULE_DESCRIPTION("Led platform driver");
" z0 R# W; M5 ~8 N3 S5 }MODULE_AUTHOR("Tronlong");8 Y2 ]$ }5 }, ?4 E6 F
MODULE_LICENSE("GPL");
6 d F7 \/ U% n& s" I0 g4 ]0 l9 J+ r/ S; ^" p: j' B
|
|