|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 w6 F, {0 z4 p#include <linux/init.h>" R) g" M8 m/ E7 a8 d: c
#include <linux/module.h>
6 ^# Z% j4 l% A7 v7 N4 B#include <linux/kernel.h>. D, p1 o- T6 i+ n, {# W6 t! ?
#include <linux/types.h>: S1 N& A0 m& m9 u, j
#include <linux/gpio.h>. \8 ~; p7 N- c1 V9 c& U! R
#include <linux/leds.h>, t6 K' J2 X o" Z! {5 m
#include <linux/platform_device.h>2 N, H8 I3 i9 U& y% j# t
7 {( m0 k) r! R6 u#include <asm/mach-types.h>
: q% B& ?0 i2 Q6 V, P {#include <asm/mach/arch.h>: \: H+ \4 I3 m% n: e
#include <mach/da8xx.h>: i$ r* E& M7 w, z, k8 G/ x8 ^- ]
#include <mach/mux.h>8 ]8 x+ U0 l1 }& W. Q
: ?7 u, T3 ^) y A' `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 l& z# J4 L% q b b# T! V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* ]6 U7 p2 O7 {* a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 a0 E0 X0 d8 r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" g7 I" b) H- M8 m4 Y( y" ^1 H: z7 ?
/* assign the tl som board LED-GPIOs*/. I, m& W+ X, M* ^8 x3 E E
static const short da850_evm_tl_user_led_pins[] = {
( n) b: f3 @0 E; T/ J; \& l /* These pins are definition at <mach/mux.h> file */& w) a$ d8 z* t2 m7 o& V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 u1 x2 w; f4 y( `
-1: w) J( ~* G; M: t: B$ w% {
};$ n% _, ^) e6 S' R# y3 Q
, G* J- V* H9 Wstatic struct gpio_led da850_evm_tl_leds[] = {
& H: Z4 J; D; `& Q {
P) Q% Q& X$ `3 \- e% b v7 n7 C .active_low = 0,2 G, S, Q- j) b: q0 n; h1 `
.gpio = DA850_USER_LED0,/ l N" A8 ^6 i/ R* t
.name = "user_led0",# O! ^/ B/ `4 H0 {0 w, W3 |4 U
.default_trigger = "default-on", c, Y3 l# H0 F# t
},2 x+ S4 k* j% N. i q8 Y( ~0 g8 T
{5 N. A' P# N, ~* R8 }* T. Z- P
.active_low = 0,$ ^/ _' s9 k1 a
.gpio = DA850_USER_LED1,
* O; o1 V4 J0 C8 [# v: A! N r .name = "user_led1",
4 F- k3 X( d/ z1 V& Y .default_trigger = "default-on",% H3 F j2 H6 E: c- Z1 o. \5 l
},
: \) m2 ~4 [2 _) X( A& r6 s0 p {
6 l& q5 n# l! A* k- \ .active_low = 0,, n$ J6 t3 r' P
.gpio = DA850_USER_LED2, F/ q6 G2 D, L; v! @; }4 V
.name = "user_led2",! J4 Z! q% O( @4 r
.default_trigger = "default-on",
; b+ v( O7 V! i3 b' ]/ L },. Z) y* h2 h# S
{
# a6 ^' h6 ^0 J .active_low = 0,
- o0 I$ {* Z( Q5 N$ z! j' j0 p .gpio = DA850_USER_LED3,
: j$ p& S- j5 q. y5 r .name = "user_led3",# n+ {: z5 a1 J
.default_trigger = "default-on",- E+ {3 p7 s" S# z5 a. f w( T
},8 j( B y+ U: x2 C. v7 |
};( {7 U: H* e3 O* V0 w
3 w/ w# Q5 K- |2 M9 p4 U$ W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ \+ h: ^8 B" |$ z9 J$ e1 X* s- ~4 L) S
.leds = da850_evm_tl_leds,
+ M( N) ^& V# L& Y3 E+ R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 i: \# P* \. b0 \& s: c};" l M! {5 D, q9 Q3 A6 Z
6 G4 E# z- }/ \8 f% V$ N
static void led_dev_release(struct device *dev)% D* I; s% z1 b, [# h3 H% i
{
$ p! E1 Q0 i. B _& w};
0 s# y- |) `; C! I4 s3 r. Q+ n c8 u' `+ P! Y$ S8 L
static struct platform_device da850_evm_tl_leds_device = {$ ]3 |: R/ Y* s& Q( {; A4 b
.name = "leds-gpio",
6 x' A& Q: o" h2 `8 P; M .id = 1,- c9 k, Q3 N6 n5 M, p
.dev = {7 o ?: V: u$ W1 c$ Z- {. B {
.platform_data = &da850_evm_tl_leds_pdata,; {7 L& x" ?' x' k: L
.release = led_dev_release,5 y- a J! Z6 e. W; X1 q1 i& Z
}
9 Y8 @4 {9 S# s- i& k! m3 o7 G7 @};* k% M A! }; \/ p9 i, z+ O
0 A) v: A- d" V0 F, O3 Z4 ystatic int __init led_platform_init(void)
; N$ n4 Y. V- @{( ?& t# a' x5 W( O
int ret;' x6 n4 Q+ }( B
#if 0
& e& Y( _. j. d* J- `9 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' ?0 }6 P" L' v$ w0 Y. z$ i
if (ret)4 J j8 X- D! @0 h6 `/ s: K& W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 ^8 ~+ W/ \- ]( _. s
"%d\n", ret);! u2 |1 H) P/ x3 e9 h
#endif
% j! E w$ |3 ^, N$ c% O, I* b ret = platform_device_register(&da850_evm_tl_leds_device);: r: W: _* V8 Z, C6 k) F
if (ret)
# l% e3 o8 s5 B/ ?2 t pr_warning("Could not register som GPIO expander LEDS");! b8 G& p: o$ w4 m% {# g6 l2 Z* d
else
$ {$ `! O& R1 @$ N printk(KERN_INFO "LED register sucessful!\n");
2 {# h+ A1 c( b, q7 v. x; w S) N: b' l2 E! W0 d% Y R
return ret;# i X. n5 O6 b
}
: S( ~. C( K. M/ p
* m$ f# u7 p% J. D6 Qstatic void __exit led_platform_exit(void)
" w8 A! B3 f/ c{
2 l, s0 y( O& w! {& S platform_device_unregister(&da850_evm_tl_leds_device);! E' K6 l3 B( N/ e0 ^, K+ ~
4 f6 S! g3 r+ ~, U5 ^
printk(KERN_INFO "LED unregister!\n");3 j- @( O, F) B# h) s, u
}3 w& `8 b) x3 ]& d/ {( @" \
6 a n) n3 \5 v% s
module_init(led_platform_init);
$ G+ h3 T! x( Nmodule_exit(led_platform_exit);% p. M! Q9 l0 w7 z/ s
6 r# Y) Y. N7 W1 H' L7 {8 S% [MODULE_DESCRIPTION("Led platform driver");, s+ U4 \7 R& I4 u. R1 P
MODULE_AUTHOR("Tronlong");
" T0 x! u# e+ W: v `$ OMODULE_LICENSE("GPL");
8 {- }3 {, c) U) E7 T& w! ^# K! U/ D
|
|