|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! @0 }7 @7 b C0 _0 q* ], R) u# i#include <linux/init.h>. v3 B& A, J1 z8 L
#include <linux/module.h>
* s" W0 z" P7 g8 h* b#include <linux/kernel.h>( A# V1 V. h8 c/ ^. J
#include <linux/types.h>) e5 L& B) ?% D4 z
#include <linux/gpio.h>
& t1 J/ l; E$ T/ q! Y* f/ w#include <linux/leds.h>% Q7 s D# T3 H! J3 g H# j
#include <linux/platform_device.h>) Y6 o. _9 j' E& e. t6 z
3 r( m) z3 @$ |9 j# l W2 Z#include <asm/mach-types.h>% _" ]% Q( Z' p2 N4 l) z
#include <asm/mach/arch.h>& i* s% b; _* [/ A" @
#include <mach/da8xx.h>: J* Z, M0 i' W8 g: E1 w
#include <mach/mux.h>
4 j+ ^: j# z( v# F; w" s" d/ Z3 m
Q$ p- O7 X A: o+ G5 C; c2 x9 k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 A2 P. A5 k$ _% H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 u3 M# u- g7 [* _% F0 d& v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' Z* {. I6 f) M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 T3 e# m% c; |; x7 L' {
* \: l8 M, ^; o/* assign the tl som board LED-GPIOs*/
+ q \" V6 _* I! qstatic const short da850_evm_tl_user_led_pins[] = {
@( P; K& _6 l5 N /* These pins are definition at <mach/mux.h> file */' L: y; q0 \( v) S9 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, r* X3 c1 \; w/ D. v) B
-1$ g) o" l) U& s4 |# l
};
. i. n0 B7 q; n$ t& d
$ q* j4 n+ U5 f: e- r% ustatic struct gpio_led da850_evm_tl_leds[] = {+ k1 ~) e+ m2 h$ v
{0 J; w% U% J9 k& ~
.active_low = 0,
5 Z6 u- `) E' i# u% j6 ^ .gpio = DA850_USER_LED0,
/ S; m* N0 r0 E$ z6 n* \& @# }; z .name = "user_led0",
/ b4 O5 t c( z7 a. f .default_trigger = "default-on",
& i* }* a0 K0 B0 s' Q. ] },
9 P2 o4 l, |1 q {2 w9 ?& G. H0 I* L, x% ~
.active_low = 0,
" o) }$ S3 @8 F7 s; A6 W: Q .gpio = DA850_USER_LED1,. b1 ?( d8 k- y+ g& b/ o
.name = "user_led1",2 y0 b0 y+ y) Z6 T% B. i# A& x
.default_trigger = "default-on",
. l4 g* l7 _3 g2 }- Z },
- s- w9 W. F. U* C8 J" F {
( W0 K. Q# n$ X9 d4 g7 J/ u .active_low = 0,
5 g/ q3 [7 L" \' ^$ s' l. z .gpio = DA850_USER_LED2,2 i+ N* N. B- G: t) w, ^* u7 A) ^
.name = "user_led2",& d: Q! I7 o! p+ r
.default_trigger = "default-on",$ }9 l" f$ \ q+ L8 @! L1 I
},
* }* v: Y% z' y! p/ e) D# f# e {9 M* z, U! V# ~7 U9 z S8 _' ~8 }
.active_low = 0,
9 l3 g7 r- h. p .gpio = DA850_USER_LED3,* V* p- [5 J2 S/ C. x+ W
.name = "user_led3",
. v% q4 T" i2 ?3 j1 g .default_trigger = "default-on",
/ b2 N# }0 o8 a/ `: o5 A( a3 ^ },
4 v* x2 ~2 i- x6 Y1 w" b9 @% T};
9 P0 |& G0 {) S
* ]" C: v b- H% C6 i* u+ M$ `+ sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
j8 B8 y2 O8 J5 q) _5 U+ N .leds = da850_evm_tl_leds,
/ k/ F Z: K: Z7 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) } Z3 Z. l& y; o- V};9 K0 o5 n# P5 D+ M! }# W
' Z |) n9 B% K5 d2 g$ qstatic void led_dev_release(struct device *dev)
; @8 c% B$ r6 _/ Q{
2 S# N4 Z. F4 k+ _: ?& E* e};
$ t/ m- j1 u5 K8 d' \7 }. u( z- Z; R3 r: F7 K8 b
static struct platform_device da850_evm_tl_leds_device = {0 D# u0 |' `2 d
.name = "leds-gpio",; I& b+ [/ }, [2 H# W
.id = 1,4 Q1 J6 r( z! k' _0 c4 h U
.dev = {# s k4 C$ x# p+ A5 R/ A4 O, O2 E$ E
.platform_data = &da850_evm_tl_leds_pdata,, T& h: `' v. Y2 { D( x( g
.release = led_dev_release,0 u- t n9 V6 F7 U8 e
}5 _# ?) l4 I" u& c( r) V5 g
};
' Z* ]7 C j9 q! Y; V8 A1 K% y0 X! S# O9 e$ R$ k' q6 u3 \5 x& N3 w& Q
static int __init led_platform_init(void)
, f) u2 D2 X+ A$ H9 k k7 b9 m{
M8 {; b- Z) v" ?: X# {6 d7 \/ @: ~ int ret;
# c, k* C A* i# D) Z& u#if 01 k. X+ a5 Z3 U8 h, \" I" n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ O( L6 A& Q" ^
if (ret)% _/ e: T1 r( r! ^: ?' E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 Y6 ~# [. H- z; l0 h
"%d\n", ret);7 j$ ^7 Z1 \7 b3 @. y) ?4 \, h
#endif* z2 O& G2 @3 i- e! ?
ret = platform_device_register(&da850_evm_tl_leds_device);+ F# h5 H2 ?6 e0 H
if (ret)
) r" g( c( C) C pr_warning("Could not register som GPIO expander LEDS");
% o: P# A% G. c' Y+ K' A" E else
\3 F: P3 D5 A* |/ m! e- j: M printk(KERN_INFO "LED register sucessful!\n");
! [% {1 V1 `4 V8 g8 Q; g7 M+ a% j7 p8 E
return ret;
% f& B* L& p1 f+ N2 I7 |( R}, f" @% }* b; U5 ^" T0 i1 a
. E* e2 `8 s& q. \static void __exit led_platform_exit(void)
* E; m+ ]0 k7 L$ q3 C" |% J{
' w- E* n, G7 e( x1 N* l( ]0 V: H+ K platform_device_unregister(&da850_evm_tl_leds_device);
0 E- x7 q" L9 S0 f5 F. i3 y0 Z& D' M
printk(KERN_INFO "LED unregister!\n");$ g* h- o' e+ k% B. M. @, N
}) Y2 z; G; ?/ D! L- a
, d, f- v \3 Y( X8 ~9 Y
module_init(led_platform_init);
$ ], [7 R! r1 P& Jmodule_exit(led_platform_exit);
. q3 X" p& d: J, \+ _6 }! W+ q2 d; H0 x8 o; J
MODULE_DESCRIPTION("Led platform driver");+ Y8 Y2 [( l! B1 j
MODULE_AUTHOR("Tronlong");
3 w3 C7 h3 K9 ^8 _$ v6 MMODULE_LICENSE("GPL");
' ~( ^! P$ k3 z" h) ?: |' _
1 h1 ]; {" D/ v3 `) n4 D |
|