|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 w: R1 P6 n$ v# a6 [1 R# l! v/ X5 ?3 @#include <linux/init.h>
4 S K2 L; g$ N1 |/ U% N9 R#include <linux/module.h>$ Y" V! P! `$ ~" j5 r
#include <linux/kernel.h>
7 z3 O1 g7 o G& t1 w#include <linux/types.h>
, @$ }! h( _& G, H4 ~ h#include <linux/gpio.h>
+ f$ u: ?- j1 }' q5 L/ x' s# ~$ b#include <linux/leds.h>. w- S4 ^* e- W; Q
#include <linux/platform_device.h>6 D. |+ D) \6 d
* H' ^8 H- F; l% h6 e
#include <asm/mach-types.h> P0 o! h& E' x/ c: x, A
#include <asm/mach/arch.h>
4 I6 o3 j7 [: c' E! k#include <mach/da8xx.h>
. D) G* N( N+ r; \7 b4 p) _#include <mach/mux.h>
' N9 r9 \+ n. d. O
& m0 @6 o6 v, t; L% O+ a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 [6 a+ k, E" Y& ]- |4 k5 C- W& V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ v& F+ z) F' B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# l. y& h" s W4 K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) T; ^3 ]! \! H# K* `% k& M1 d
5 X, b# B6 d H3 q9 _1 i
/* assign the tl som board LED-GPIOs*/5 H( A* e/ a% b* T
static const short da850_evm_tl_user_led_pins[] = {# V3 i4 H% L# [6 m7 b+ ] C& x2 Q
/* These pins are definition at <mach/mux.h> file */
2 }" J# f/ q6 E8 @8 b6 |! Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ {: U/ K4 d& m/ e! D E- W
-1' J) J6 l' |. N! k0 L" L1 k
};' y( D7 N6 t7 c* Y% C8 g' }
- x: r, Q: [1 P# p: ]. {( @static struct gpio_led da850_evm_tl_leds[] = {9 F6 j$ y3 ?7 ~5 u) W; g
{
- c( r5 i' f+ V/ C4 F% r .active_low = 0,
4 S( q9 G# _+ [# f# b; ~, o .gpio = DA850_USER_LED0,5 c5 G/ w/ n! \0 C% [+ R! F
.name = "user_led0",' l6 u! [0 p# S+ g' b' l- r
.default_trigger = "default-on",
& A. d( C9 ^5 g( g% X2 ~ },3 ?5 z' g! _1 @$ Q' |; h. i, {; S. O& C
{) v4 x f& [* ?) Y9 I6 H
.active_low = 0,
# H: }5 m) X% ]3 z F .gpio = DA850_USER_LED1,
t, Y- B- Q3 F! ~ { .name = "user_led1",
' n+ R w8 E4 p .default_trigger = "default-on",
3 X: ~- r2 c* P( `1 ^& [" { },- l) S" I$ P0 g9 Y# ?2 F# J8 Y
{
, x6 A+ } v6 V; }) r .active_low = 0,/ R/ P. ? O$ t* C
.gpio = DA850_USER_LED2,2 X1 [2 G ` V/ |7 N" N
.name = "user_led2",+ X' I `0 V0 H6 ]3 l& g& L0 v
.default_trigger = "default-on",+ \$ f- k6 f) |( [$ h' x
},
* F ?3 h+ y$ s8 F9 w+ { {) d$ {; r' g, F6 P7 L* B
.active_low = 0,
! D0 o. G4 w% w5 u .gpio = DA850_USER_LED3,' u- a4 `/ U$ @/ W3 [
.name = "user_led3",, h$ r3 T' O, U7 Q* t
.default_trigger = "default-on",
9 F) j1 g0 W1 [7 A( \! x },& M5 i/ r* {; N% B7 u% X" i5 m
};
- u: W4 U0 j- T7 h" A, v! I" r$ @- I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ z. r" i9 b! t1 g7 j .leds = da850_evm_tl_leds,1 p0 z. L8 C! b9 f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ C* z3 P0 ]. X) E' d};6 N% n4 s1 o+ @- J7 G# f
6 K: D7 i9 F- ~( ~
static void led_dev_release(struct device *dev)6 b, ]/ X1 A' u! d6 L
{
1 q; T# j2 g a7 ^; s};( ]) o) W: b3 X9 i
: m! l( Y9 `/ `8 F1 V0 jstatic struct platform_device da850_evm_tl_leds_device = {
/ v4 u7 N" f- Z0 C3 h/ P8 [+ e4 E .name = "leds-gpio",
/ t2 B6 z( {) o: J s4 O% b1 l .id = 1,
6 [( B2 i* t# j( O1 t1 W$ v3 q .dev = {
$ t8 X$ t) D' F# v ] .platform_data = &da850_evm_tl_leds_pdata,$ K8 N* o! n6 M! u. R. J6 l
.release = led_dev_release,
8 m) h4 d4 x/ O8 c" G0 X }" u/ v5 F) w" p! N
};
* ~" L# @! X# U2 C0 m1 b. W8 h' B2 g* {. }7 p
static int __init led_platform_init(void)
' o$ p8 N: M6 N0 c{
0 b. w/ S: S) x; h, c, c int ret;
6 s7 {: r1 E8 v#if 0
) }1 N) ]; t0 z J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ C$ @; r" R& } if (ret)- t1 l5 ?8 f2 f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" Z* v* E$ s3 [9 ~2 H3 J9 o+ t3 e
"%d\n", ret);
* s! [" y2 C" R#endif
5 o- ?0 S, Z3 {# _9 o% u0 ?- E ret = platform_device_register(&da850_evm_tl_leds_device);5 z, L' b. A( a7 ]
if (ret)9 X) G* I& j: [0 k' e8 O! q
pr_warning("Could not register som GPIO expander LEDS");# q% Q+ O1 {2 m1 t; B
else8 d5 z. k1 q/ U. v% j* _
printk(KERN_INFO "LED register sucessful!\n");. s4 `9 f3 x: E
; E* z. `& T! Y- I: M' g
return ret;
" y# e1 e' h4 a3 B+ m7 W}
2 S/ ~$ q3 h+ d) x6 C
- Z7 @6 R6 B3 C' O1 s8 Z% J/ sstatic void __exit led_platform_exit(void)
$ B1 A/ V& \8 _% s' d& G: p{
; D0 ?6 b) v9 I platform_device_unregister(&da850_evm_tl_leds_device);
0 ?( y: f/ e! r9 R
, x8 L* i$ Q0 M' I printk(KERN_INFO "LED unregister!\n");. _& f5 r' J, j. r5 K1 W# [: m
}- ?& v1 b9 V# N3 Z/ b$ x
" a. ]2 @/ G- }% P. Z/ `module_init(led_platform_init);
; [( H: b* X% Cmodule_exit(led_platform_exit);' b$ y/ z d+ O* h6 g0 {/ Z# z
2 {# @" P( U0 G! j
MODULE_DESCRIPTION("Led platform driver");
b% [/ \- X6 Z1 aMODULE_AUTHOR("Tronlong");
# a- }; e2 d6 M) e0 E1 SMODULE_LICENSE("GPL");
3 Y5 e' k/ }- d$ r* v1 o' E" b6 u: U9 d
|
|