|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- ?* a u- z y* U- l9 a$ T, a#include <linux/init.h>' Q( @; N1 v" h! P3 p
#include <linux/module.h>
: e" P: M( e z! q9 a1 w/ z#include <linux/kernel.h>
! Q& m( b# j. ]; p#include <linux/types.h>
4 J" T- s! M3 H0 w4 t- F#include <linux/gpio.h>6 I _, a9 F2 M% a6 w( h
#include <linux/leds.h>
/ V& M( u: L7 P% @/ Z. ~3 `#include <linux/platform_device.h>, ?- q; Q/ L& o$ U S0 v; p
3 a) Z% s: B1 C- `
#include <asm/mach-types.h>+ \9 q% `4 o. r8 }9 @ m
#include <asm/mach/arch.h>+ M. O, d( S, Y
#include <mach/da8xx.h>
& f8 o7 |* D- ], w7 K#include <mach/mux.h>
$ Z7 J$ ]$ a1 U* X! e4 \
/ O* e% {0 v! d' Q4 Q! I5 @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); f$ h4 Y9 k0 N4 g7 ?* U2 l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) O5 c6 G/ N( h0 n1 F* a: b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& C7 R" `' u7 k& O1 Y5 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ R! b' t6 N7 F. I7 X" [& s1 p8 b
" L7 M+ W% D* v( B+ m" @/* assign the tl som board LED-GPIOs*/
2 G% [. l, t, n. Wstatic const short da850_evm_tl_user_led_pins[] = {0 {. J" {& |# A5 d5 J
/* These pins are definition at <mach/mux.h> file */
' c8 R- }) j m( W. @8 h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& n1 D4 ?. v6 w* @
-1
* q3 E N# `: }* K) `};: {* L+ f0 m7 w( c8 m
' g1 J, n) W! h
static struct gpio_led da850_evm_tl_leds[] = {
$ Q' |2 r/ }& Y: W5 T {8 P9 Y$ c* h% n5 z5 T. i
.active_low = 0,
+ y; p! u" l2 W! h .gpio = DA850_USER_LED0,
3 O J. h( n+ X8 x' A .name = "user_led0",; n2 R( p! y: s: j
.default_trigger = "default-on",
3 O* g) [- O+ i! C& n },
' Q9 n! d: d/ E* y$ F3 F% E {1 T. j6 E8 D- v; j: f1 e% D9 ^
.active_low = 0,/ n% t4 O" J( K! c/ L$ Z
.gpio = DA850_USER_LED1,
, d v" n6 n; C1 S I .name = "user_led1",
6 j9 k, z7 V; z9 u1 ~ .default_trigger = "default-on",
3 x- { B/ V' d1 @* a },' i! a& a3 r& \+ t' q* g S
{4 _9 U5 z& p) x; ]
.active_low = 0,
4 q- L6 j6 E* r3 f+ N, d/ T8 s .gpio = DA850_USER_LED2,
, r. }2 q) t& U* K, ~7 k' i0 l; b .name = "user_led2",( Q3 V( A+ Q' X3 R' P% g
.default_trigger = "default-on",
2 K8 L% w# U, ^6 w8 k1 c& e/ z0 e0 v },6 x% L. ?6 N& s4 }
{
& x! b4 {8 `. ~) ~ x8 `2 G* h .active_low = 0,
; P s" R+ h1 [! N' Z .gpio = DA850_USER_LED3,1 _% |) Q1 [" @* \- }# E: E4 ~3 b
.name = "user_led3",+ ]8 }( g& @5 [- @" _8 o
.default_trigger = "default-on",
( e S* C) C J8 e' u/ V( w" q },2 V# @$ z4 g; T3 s9 V( r/ a1 S
};8 Y* a9 c0 C/ U, v {. K8 I
9 p* f9 O3 B ]2 i# O! y/ T- v, h; M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- P+ |" f; T, `7 U9 \ .leds = da850_evm_tl_leds,
( U- f! e) {' J" U2 F+ p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 v# U( b' c% `* D4 D. o# z" l};$ }. a- W" E+ E# ?
6 w: ~; X% j! y0 F$ I$ K, n
static void led_dev_release(struct device *dev), _* R1 B. U; y# x' w; T0 a
{
, ?. m2 e: n( f! ^/ }};
( K, V" W7 ~- ^: F; k# s* W" z3 B6 b0 U+ g1 Q ]! L
static struct platform_device da850_evm_tl_leds_device = {
# Q( }3 B- d$ e9 o% m .name = "leds-gpio", }* u- i. q [5 f
.id = 1,
* G4 S! i( H, t2 ^1 q5 r# q .dev = {
7 W) Z( j9 u% v8 f& b .platform_data = &da850_evm_tl_leds_pdata,
8 _7 O0 f9 J# f6 q/ y$ V K" I1 f .release = led_dev_release,% p* L! j* \% q3 e+ j3 V
}. A1 X% ~8 x- j! y7 Z J* k( y6 O
};
- w. h2 c! Q4 J$ {% t6 g
3 `, U9 \! K7 [7 H- @ {static int __init led_platform_init(void)
" N E& w% y* c7 [1 o2 B{, ]2 {" @6 ]7 {, f, N* b
int ret;
4 J, y/ F9 ^' ~) [- t* T- x#if 0
/ ~/ m8 J) M# q# G; n& F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
O- k2 H6 |7 O9 o' J" [ if (ret)
: |) [4 S6 v5 _2 R+ j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
s# ?3 L: }. _& u9 V7 _$ f6 O "%d\n", ret);$ C/ h4 K' c, H! J! E. w
#endif# R) K8 T [6 w
ret = platform_device_register(&da850_evm_tl_leds_device);9 @' C7 d2 F. e( u/ u( l/ x
if (ret)
" g' q7 u c5 X, R pr_warning("Could not register som GPIO expander LEDS");
/ S6 C& q& A! q! I3 S" ` else1 h/ a3 a$ @4 Q1 h X
printk(KERN_INFO "LED register sucessful!\n");' P; a4 ~: L$ k2 q& v
9 e' n# z4 U: v' B" P
return ret;
' I, Y6 ^* V- K3 `- ^- B6 {}+ B" F3 @$ i0 n. b
% o1 Y* j0 m- L& o4 N3 H( y( k
static void __exit led_platform_exit(void)/ B' Y) B+ {- I; i
{
# f: a% l, [& w9 Y, { platform_device_unregister(&da850_evm_tl_leds_device);
/ ]/ z' b, i* M" b$ ` b! U4 a1 C
printk(KERN_INFO "LED unregister!\n");
! F6 p" E/ l3 ^, I' W5 s( ~; B}/ D" e* o. P" F" o3 ]
) O4 m" O0 N# bmodule_init(led_platform_init);' _2 ]8 ~+ K. }. n' {$ L. q) p2 K
module_exit(led_platform_exit);# j6 ?0 f Y$ V
' O6 ~- k2 F/ P7 `MODULE_DESCRIPTION("Led platform driver");
. w6 ]# r* F8 v3 mMODULE_AUTHOR("Tronlong");) m5 I6 k# ^+ ^: ]3 I1 w* C
MODULE_LICENSE("GPL");
4 {( D% |0 h5 a3 R2 e. I" m; h/ [- T" [" p9 Y" |) H
|
|