|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' p, f% j7 l C, _5 y#include <linux/init.h>
5 D6 K" H3 l# j+ z( u4 ^#include <linux/module.h>3 \1 Z$ }6 \5 P. z: t( [1 e
#include <linux/kernel.h>$ c: m/ t5 h' C, f I1 p
#include <linux/types.h>+ M: j+ `1 w5 a2 P( h/ C3 L4 y% c* u
#include <linux/gpio.h>6 e4 |) k3 I1 g% ]& E2 @- a3 a
#include <linux/leds.h>
6 | u9 K% z0 Y#include <linux/platform_device.h>+ C, P5 H- V8 j+ R8 X. M: _
! v5 s/ d4 `! A9 S5 V1 }) z
#include <asm/mach-types.h> z2 V0 ?8 m6 o7 O6 X' S9 U
#include <asm/mach/arch.h>8 L) b/ _! P0 T3 k9 O- k7 F0 ` b6 n
#include <mach/da8xx.h>
# k' z; E& F9 v2 b! ^#include <mach/mux.h>
0 J; s% m) ^( G/ r- [ R
) J) Y, X1 a2 `0 V8 r6 m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 I" P! Q0 ^5 x7 ^% Q! A* ?, D( N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 L! u: k7 e9 b" B% B" y' v& K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 s+ z% Y- A% ?5 p2 F# b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). i. k; {: b! C9 Q: s9 ^
, L$ @4 K2 e/ G+ F6 z7 }/* assign the tl som board LED-GPIOs*/
. V) F1 F: z: N8 ostatic const short da850_evm_tl_user_led_pins[] = {
, ]4 y0 M7 F; T% n! W: a% T* N /* These pins are definition at <mach/mux.h> file */# W5 ?* s) R3 j# x" | P/ H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( z9 h, e/ w, ]0 L+ A4 C$ L( W
-13 K1 W% {+ g% ]( i3 b2 k. @& d
};( u7 W# _3 T+ J7 @2 Q! F
* g" W" E# Y) m+ T9 o
static struct gpio_led da850_evm_tl_leds[] = {& y2 ~: x7 J% _! T
{$ c. w- Q, Y* j& A! p4 f$ y
.active_low = 0, R# W! u$ k, @: C# o5 A- I# n& _
.gpio = DA850_USER_LED0,
2 w0 q7 u4 _) w .name = "user_led0",, ]/ g# P; r' T
.default_trigger = "default-on",3 R& X$ y: k `6 P% B: ^: r
},
# q0 P' A0 _8 T8 r5 {& T2 ?" ` {1 j3 ]* e, y: _$ q6 Q
.active_low = 0,8 c0 g" D/ D ~. B, y1 w
.gpio = DA850_USER_LED1,
; {1 K# F) n: r7 s: q, H, D. @ .name = "user_led1",
7 b. B1 Z/ ]9 f( B5 R" ]$ U .default_trigger = "default-on",
4 A) t" f' D' U/ K },0 b( B7 p* n5 n9 C
{8 F8 @" S1 l; _6 ?) x" `# A5 I
.active_low = 0,3 v4 Z2 h* q- W! L* ?3 C
.gpio = DA850_USER_LED2,8 r [( X# s5 H/ y- S& a
.name = "user_led2",& m* k4 |- ?" t# P9 P* s
.default_trigger = "default-on",+ t( [: ]' X1 Q+ B
},5 P4 h9 e( Q# Z* S1 v
{
% S( `# K* I, W2 A2 H8 t .active_low = 0,6 {+ E( {; F& p# Y; l/ P
.gpio = DA850_USER_LED3,
S( w+ D8 q' ]( H. R+ ^ .name = "user_led3",# g# C! Y. u& H5 r
.default_trigger = "default-on",
! q/ Z3 i# }" U0 ` },
' I* D* D. t$ z' j/ T; }% j};
j+ H7 A7 x+ S! d9 t" X: U1 r
" j5 e0 t5 w& H7 k+ pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- V: ?: s3 ~) N% g5 O
.leds = da850_evm_tl_leds,2 p; |) E" H) R& d; r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ {+ u, g2 z8 r) i3 J5 v
};8 t* T! N* l0 y# U
' P9 [8 d1 P, u( q! Z' @4 L2 }4 G
static void led_dev_release(struct device *dev)
7 Q1 `( B9 o' j& o/ ]" C{
/ o. _! D5 }: V% ^}; X# U5 E3 u$ S7 u( u9 H
, }6 f8 R( U. I, D- F
static struct platform_device da850_evm_tl_leds_device = {
* W/ x7 |3 C5 \1 f, ~ .name = "leds-gpio",
* c: E# n1 f4 X4 O$ f9 Y .id = 1,2 V( l) K2 i( C0 E
.dev = {
$ z8 `7 D8 A8 _& a4 z6 ^& ] .platform_data = &da850_evm_tl_leds_pdata,
5 u0 {* j4 Q6 W( I5 Q .release = led_dev_release,, ]4 t! z6 x5 b% q, F
}7 b% M. T% G! I( S& P
};
6 e2 Y# }7 g! Y8 ?2 n: Q( S; x3 E
. ~- A( u9 v% l* cstatic int __init led_platform_init(void)
& c, q6 N' v/ S6 S/ S0 d{
2 n+ u3 D% E# k; ]7 p; H" l1 Z4 t1 z int ret;+ a6 D5 N! B: l# Z1 x: K, T
#if 0
% N* X" d/ M9 Y9 g6 g- a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% Z% y' \3 y3 u8 ~ if (ret), l- a3 c3 f1 w: |" {2 |. _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- U. a# b& Q& P) `
"%d\n", ret);1 D6 b/ D# o* A; e1 U- ^
#endif2 ^" c: ?) V( G) Z+ U
ret = platform_device_register(&da850_evm_tl_leds_device);
/ P% A1 E3 ^; i if (ret)
8 M* y3 _8 x2 F pr_warning("Could not register som GPIO expander LEDS");
3 v1 }/ q+ G4 n8 L else
! a# j) y# j! a& W printk(KERN_INFO "LED register sucessful!\n");1 c6 Q0 Q- h4 c- D* x0 V7 c3 u
1 g0 f" U# Z& b, { return ret;( E P! a5 F6 L8 V" M. x* m! B
}
. }, J7 [/ ^! Z; s( A* G9 h/ G
1 t' z* N& K3 n; dstatic void __exit led_platform_exit(void): F9 |$ s- w: W8 l6 R) {6 I
{
* o& t x& Y5 ~; C/ B platform_device_unregister(&da850_evm_tl_leds_device);6 h0 \' B. F5 U# X$ L" j* j
5 m0 _9 n6 O8 _# R% r
printk(KERN_INFO "LED unregister!\n");4 E; u5 ^) } D1 }: f
}
0 P3 L5 z+ b3 Y$ X( `' ^" K C" X
module_init(led_platform_init);
; z* i& m% j! D7 S( p8 Rmodule_exit(led_platform_exit);
2 { H" f8 e9 p* Z
; k1 d/ e# p! D! x$ X! `MODULE_DESCRIPTION("Led platform driver");
; {0 M# n8 ~1 j3 DMODULE_AUTHOR("Tronlong");
9 @( f# ^7 C) h4 UMODULE_LICENSE("GPL");
. `. W) [$ u' N' r5 g
. d1 j# Y {# p |
|