|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: S- T6 E+ `$ h8 F
#include <linux/init.h> d1 X6 z3 W2 c$ W
#include <linux/module.h>+ X) U5 R- B) n+ f& s% d
#include <linux/kernel.h>
! r5 N/ _# J- m1 y' s* ^#include <linux/types.h>
8 n2 y7 Q% z K* }; \% i#include <linux/gpio.h>; }% ?& |2 V, N0 t) a
#include <linux/leds.h>/ u1 E" C! u+ I, A8 w6 x! H& r
#include <linux/platform_device.h>
" |( Y! U; P" q5 F3 _6 w+ Y' R, Z; B
& f6 b; t0 q5 O# g* A% k#include <asm/mach-types.h>+ v: M7 y' _9 K: d
#include <asm/mach/arch.h>
: L$ d9 `! v$ q" l( B* D& {#include <mach/da8xx.h>
& k" q/ g( ]) w#include <mach/mux.h>( C- ^6 V- W! [
+ h- o4 j# U* a; g$ s1 ]5 o- d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 i2 k9 J, B. v. }% m& M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 g0 r1 d z$ s0 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* \ l7 z: b7 v0 I* n; Y. w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 f# H, M/ p. u3 F* j& [% F
" g' _* M* ~0 v7 ^/* assign the tl som board LED-GPIOs*/
4 B c' Q6 Q, G7 k) ^static const short da850_evm_tl_user_led_pins[] = {# D9 G' N! v# Y
/* These pins are definition at <mach/mux.h> file */
* L0 f2 P2 s0 k2 h- P# p: \% V: l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! @ U8 U9 k# l5 f. v, X& K -1
# y. N; J2 k- M6 Z};2 Q5 f1 }' N+ O$ U7 v, F3 s
# |/ H7 }2 a4 E! B
static struct gpio_led da850_evm_tl_leds[] = {
$ I) U, T3 L" C {; B6 ]6 }. b* q: s! r
.active_low = 0,/ I( r- f1 f% m5 x- s
.gpio = DA850_USER_LED0," D+ Y F* m3 L: b5 O5 e0 m
.name = "user_led0",
0 k& [% W- Z e8 m5 O .default_trigger = "default-on",3 A# X; M& H2 y1 o q) w
},: M( l% i3 x1 ~( W
{$ h) X. J. K7 ^. }8 A! Q0 @$ E
.active_low = 0,9 H! L1 r* n' c$ Z* A; Z3 V
.gpio = DA850_USER_LED1,5 w$ L4 ~. [+ y8 N
.name = "user_led1",
6 f! a V6 L8 d. u/ V, E! Q .default_trigger = "default-on",
! z. P$ P: L; F+ d, Q1 q },1 O$ r8 T6 A; C5 R1 x
{8 `6 p3 U( F; r Z$ @" a$ }7 E2 n
.active_low = 0,6 |. a1 w x# g
.gpio = DA850_USER_LED2,9 p( V0 \5 u$ _/ J: {1 \
.name = "user_led2",. z" Y f# J- b3 A7 w9 A% n
.default_trigger = "default-on",
6 z! y7 L! q* x' a3 |/ }0 |/ s }, t0 G5 p6 O, p$ F: I
{! O) ~2 u* Q @# j/ h Q$ J
.active_low = 0,
2 K+ ~% i- `7 t g; p9 j& }& s .gpio = DA850_USER_LED3,) C( z- A3 L4 s. [
.name = "user_led3",2 V1 U5 ^0 i S* u3 l
.default_trigger = "default-on",- I" n; e& N$ x
},/ X* m& ~9 e" G8 s
};
7 x! U7 b- v A& w+ z, Y3 l3 _, n9 E; Q5 H$ q" g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 u" ^$ [3 `5 p! p. l& b* P
.leds = da850_evm_tl_leds,
' M8 H, S7 O; X$ a$ O8 s' l% h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- r5 ^4 p D0 X: z K: \};
5 P3 j& ]. q) b. o. }' a
$ e' j: b( P. c% \9 n7 n# Q' s* k- Rstatic void led_dev_release(struct device *dev)) o7 f7 [, V) I; R: [
{
$ }$ [: t% G; X};+ y* g+ |' c6 _$ p* } }# V
) B; B: _- p, R' P. S# u: T! f1 xstatic struct platform_device da850_evm_tl_leds_device = { H# d; H5 j" Y
.name = "leds-gpio",' ~- z; M6 N$ J N6 w0 X8 X' _
.id = 1,' C& A$ [/ r# {* X8 L" ~1 }8 k
.dev = {
3 x1 T) k C) B! @ .platform_data = &da850_evm_tl_leds_pdata,/ [( L( u/ T9 t% b0 h$ j
.release = led_dev_release,6 y$ ]( f+ F1 H& Q" P$ i# d
}7 r/ W8 w8 J6 m
};' w5 Q: |3 s. t
, T+ O: Y/ P6 F( H, b' `
static int __init led_platform_init(void)
8 P- b/ i& Z' R3 g{
0 I( J C l- z; B: V0 [, Q+ O int ret;
3 R+ Q; F v3 B3 {% T, o7 R2 a2 ~9 D#if 0
& `% e6 B+ F# H. @: d ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- R# b2 @, i/ S# Q5 h3 m$ t
if (ret)+ ~' N9 V% A7 U: }3 r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% q* {# M: b- x; j "%d\n", ret);
0 [% G( T, M" s* }% ^8 N#endif
' s8 V& H: Q4 C9 u0 a6 a ret = platform_device_register(&da850_evm_tl_leds_device);; d+ o I1 i/ X6 I+ G2 Q
if (ret)
0 D' p5 s( Q" w5 ^5 F# T* ]6 O* p2 ^ pr_warning("Could not register som GPIO expander LEDS");
" c$ s. P* T: c$ c else% s3 B# \% e z, u- X. b9 i
printk(KERN_INFO "LED register sucessful!\n");
1 Q, X; J r$ b$ |7 Z& [- n# c
( h, r2 o2 \6 m, o return ret;
" ~8 N3 v: S) a5 }+ H- B0 e* ~) C} f N# t" \& V) b( |) t; |# d6 R
9 r$ X+ }* \/ B0 G: r# Vstatic void __exit led_platform_exit(void)
% m6 e: B! n4 t' @% y& U% X{- V- N, j9 [) D4 Z! T. @) h
platform_device_unregister(&da850_evm_tl_leds_device);7 }6 W7 m# O0 H" H
, b7 E7 R6 x& K1 _ printk(KERN_INFO "LED unregister!\n");
& v) ~' U8 V. }2 v. V) G0 P! v}- f6 N: }3 [1 ]/ d7 x
' b d' B! q' u; [, L1 @* \module_init(led_platform_init);
5 L- Y. {2 O" D! m" s) d# r1 k* Xmodule_exit(led_platform_exit);
, \' X$ v- M; x6 b
& h, Q+ T. z. dMODULE_DESCRIPTION("Led platform driver");1 V: i& K( i0 O& V; D* k& l
MODULE_AUTHOR("Tronlong");4 S0 ]% p. V1 N: f% C
MODULE_LICENSE("GPL");
1 e/ @: C( I1 Q: p9 H- P3 x J- v, ~3 X& N% ?5 J4 S
|
|