|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- N a7 K7 p& P( k8 Z#include <linux/init.h>
9 t( W# v5 n7 p U#include <linux/module.h>
+ C. N6 Y% R$ K7 q0 a#include <linux/kernel.h>7 h; y r2 Z: k2 N3 o; m- K. F
#include <linux/types.h>* ]' _6 A7 v' M
#include <linux/gpio.h>
# k% I* P7 u% W) Q" F6 F& i# o#include <linux/leds.h>
; Z3 _6 C3 Z6 [( {+ _( e#include <linux/platform_device.h>7 v. T% b% J9 F
0 E0 m2 h: Q; L#include <asm/mach-types.h>
7 ?4 ?1 m J* `# G! e# n: {- z8 Q#include <asm/mach/arch.h>& d9 s2 _+ d+ ?( y' s' r
#include <mach/da8xx.h>: F. S: Y2 F2 @- J+ q
#include <mach/mux.h>' U, {# r* H1 b# V, ^3 m
8 |+ Q/ c) L# W4 o! b. J Z8 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 c1 p6 l* ]+ g' p9 ~- |9 g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
\6 T$ x, Q, y G$ j! x) {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! y! ^2 E) j! r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 E( b1 p- u3 e
3 S. k9 N: L( ^( [/* assign the tl som board LED-GPIOs*/9 g' F* x* D. t3 _: U
static const short da850_evm_tl_user_led_pins[] = {8 v' g& X" h( f: t$ t0 U( X* v
/* These pins are definition at <mach/mux.h> file */
2 R) z" ^" v& p k/ v I$ w, L% Y3 d0 M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 e, |/ s Q3 C$ w$ h$ V -1
) \$ O: ~& R! a$ i/ \0 f6 @};
5 L( M, F2 X3 ]1 P( u i
# q, G# s0 G+ q! W7 h* Mstatic struct gpio_led da850_evm_tl_leds[] = {
4 d6 U* D% x8 f# C* I2 J% p {
1 _& Q( _3 R. R, H8 `& x .active_low = 0,, S6 Z2 E# J! h$ i! S/ B, F" q" a
.gpio = DA850_USER_LED0,
" h8 L& s3 d, I$ Z% \# i .name = "user_led0",! H4 c6 {7 [9 \/ H
.default_trigger = "default-on",4 Z# F$ R) Q* M. U( H
},. u B& M9 \4 F3 G& a
{, }" ~0 ?; y3 {* i+ p
.active_low = 0,
( H. v/ g/ w) x# Q: ~" |) C .gpio = DA850_USER_LED1,
9 j1 [ C6 p4 ]- c5 | .name = "user_led1",
/ X9 a! j o) L3 y' i .default_trigger = "default-on", E7 s5 ~6 P: I9 t0 e: P+ e
},
) o# _' Y; N9 P+ b {
& a6 ]2 P* [( b- { .active_low = 0,3 y) I& o+ S/ s, z$ q/ U! X
.gpio = DA850_USER_LED2,0 R G" x+ b( b) Q) h6 u V
.name = "user_led2",
4 T/ l+ S* A+ ~5 y+ ?% c .default_trigger = "default-on",2 F8 N! w$ C6 T
},
: t$ ]1 t: l& b' d+ m {
! N+ I7 e% N! ?5 s3 O+ u- [ .active_low = 0,# o: M3 s! x( f
.gpio = DA850_USER_LED3,
. n1 _/ K$ z* q( @" v4 ?2 W+ u .name = "user_led3",
5 S0 K( ?1 |. A0 A .default_trigger = "default-on",) Y3 q/ Z* j5 v( }3 N
},! I" W# N; j) Y( r7 L1 T# [3 I; k: q
};
; S- J, t( v( ^% d; h* L6 Z* u
! q" k. J& K* B* V2 ?' wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, W" o4 \' U. T3 I; e
.leds = da850_evm_tl_leds,/ N0 u" j/ E8 m* Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 N. Y; z$ ?. Z( P0 h
};3 d5 }& x3 R% h
) {( r4 }4 B* Q7 ^& Y6 r
static void led_dev_release(struct device *dev)
: m9 t% f- v9 r6 G P' s' {2 R{7 D& w! l* I$ g* n4 |6 v1 N
};! }, p" n* `" X% X# ]( p9 k% d
% Z% X! ^6 `) k2 N4 L8 w% l4 ]( }static struct platform_device da850_evm_tl_leds_device = {
0 K) ^7 ^. v0 | .name = "leds-gpio",5 l2 _4 W4 m: {$ g
.id = 1,
/ K, ?5 E1 |" P0 V5 y5 Q .dev = {5 U6 R) E, t& `- m) v
.platform_data = &da850_evm_tl_leds_pdata,7 q! V5 e* S" ? ^3 _" W9 U, e
.release = led_dev_release,1 a' e; I/ {7 Y# d, L' A/ z) a1 N
}7 k/ J# m2 M' |
};
+ p0 W* E9 _, x3 m
# f9 N5 \1 C9 S% {. L; bstatic int __init led_platform_init(void)6 Y+ y8 ]/ t6 G$ ~$ h, E2 h( O
{
% F/ c& p8 {, c* v# M' \4 }. I int ret;
- e/ i) H8 m( e" W+ o. Y4 H* g#if 0
# C( d: _, K$ N' v j0 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 a- A4 H6 R4 h5 v if (ret)& e$ L+ m, t1 m* t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" A3 t) [9 d( Q( {/ Y3 D
"%d\n", ret);
" N: ]3 j. c u- e, }#endif% D! C& b) s: B3 ?) O9 E7 G9 }
ret = platform_device_register(&da850_evm_tl_leds_device);. `- [9 s+ U; S5 w( U# A
if (ret)
3 x7 P" ?9 V+ `% p0 Q0 k9 T% }3 @ pr_warning("Could not register som GPIO expander LEDS");
; E: A. N$ ?! f, X& i5 J$ G6 ~ else" ^3 ?- v+ I, `7 |9 j& u
printk(KERN_INFO "LED register sucessful!\n");
) O! B% r7 ^3 Y" J
- L! X, g% T+ V/ g5 U7 ` return ret;6 _ r5 i$ P+ l* B
}
3 F* S9 Z U* H9 E x" R4 U% W/ w% i2 P% }! z/ g* U
static void __exit led_platform_exit(void)' v4 t& q3 T# F
{0 a9 t( d* R% Z' q+ Y
platform_device_unregister(&da850_evm_tl_leds_device);( E' r8 {( U& G9 X* i( \2 a7 H' N6 _" h
# _4 @2 z0 Y1 }9 V# \, X! X
printk(KERN_INFO "LED unregister!\n");
$ T- c8 M" k4 `5 {" m0 L" s}% }3 D* Q, v% A* T% d
& K9 E* A' I- G* u1 h
module_init(led_platform_init);
' B# \6 c/ J9 N$ |- T3 Amodule_exit(led_platform_exit);
* J/ ]5 n( }) B7 C ?* u# ?. S$ N$ P4 f
MODULE_DESCRIPTION("Led platform driver");7 K1 |" @- ?/ J, M8 ~1 @
MODULE_AUTHOR("Tronlong");
0 r" d- P- B+ bMODULE_LICENSE("GPL");
' L+ ^- t7 O8 v6 S% ?7 p7 K& G1 L& I; R4 j" v4 j3 @
|
|