|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- q" ?8 e! A6 U1 I1 F#include <linux/init.h>2 N/ m4 G( Y+ p5 B# k5 u* ?
#include <linux/module.h>
0 A, F4 h: W- N+ i6 u( O/ w#include <linux/kernel.h>$ Q" y* [( Y4 E+ I& m. k
#include <linux/types.h>
: U1 I8 m i" v: }) Z7 j" y#include <linux/gpio.h>
4 ?' y8 M. b. g' D) Z: n#include <linux/leds.h>
/ ^3 G! y4 Y: P: M7 Y#include <linux/platform_device.h>
# O. N( _) \% u: I b( \; W
: J/ y& {9 R) \: A" \$ O5 ^3 J- O#include <asm/mach-types.h>
- q) |# q4 m' a4 d! E- k6 V#include <asm/mach/arch.h>7 ?, s; Q! n8 q( j' h* N
#include <mach/da8xx.h>
! P7 }4 |# e; j! X2 _. a#include <mach/mux.h>/ X% _4 t1 ^+ X4 E6 w+ E! t
$ L! g1 _: g5 W7 [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# |: q2 ]; ~ H4 ?. a2 g* z# X- \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 h$ q1 w2 z$ _+ f+ p. B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& C8 I! n2 Y! c2 v9 J6 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& q P* B2 q5 {4 d7 ?/ c; z9 K! ~! v* S) |. g- y5 D
/* assign the tl som board LED-GPIOs*/
1 U7 r" [, m& X0 k2 t. Astatic const short da850_evm_tl_user_led_pins[] = {3 @7 t. f( a* j* v$ d$ Z: }1 n' e
/* These pins are definition at <mach/mux.h> file */
4 j& z p, A% _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 x8 P, l8 M+ Y) |/ p5 f- N -1* h+ Z" O# l e. y
};3 c4 l- c$ ~) r% R& j, H5 e) G* y+ I
2 H* c3 t9 o+ j( u
static struct gpio_led da850_evm_tl_leds[] = {
6 i d* \' V- Q g {
9 T9 [9 {& P3 V* Q w- a1 ? .active_low = 0,- V( S+ u7 k/ K
.gpio = DA850_USER_LED0,
0 l$ b6 n' x$ R* s .name = "user_led0",
B9 b5 t4 I6 d! w9 ]8 g .default_trigger = "default-on",
+ L$ {6 t% {$ k; A% G: g },6 c8 V8 v) _ ]) M" }6 k
{
0 B; e! U/ x: M- G2 R2 u .active_low = 0,
* X- E6 `* r/ R8 H A .gpio = DA850_USER_LED1,
V) Q- C9 O7 d .name = "user_led1",8 V0 j& P7 j1 G- {" O' Y" m0 ^
.default_trigger = "default-on",5 o, D% p2 U4 N; N
},
% t* w" J$ h3 v1 O1 I A( Y. h9 Q {3 G7 p8 x* u5 _" M9 d# g* H) i+ B' |
.active_low = 0,; J, \2 Q Z4 ~
.gpio = DA850_USER_LED2, \5 z0 m! g7 K
.name = "user_led2",0 G5 Q; k$ p& ]! M- V H/ A7 A, ?
.default_trigger = "default-on",. S2 P3 ~1 m" I. [: l7 R% [
},
& @" O2 W; W6 X/ C" y: I: {* X+ y {
7 {* R4 X7 P0 D" K- Z, t7 B' x9 ]& \2 J .active_low = 0,
3 N+ \* q6 U/ z$ b1 t. { .gpio = DA850_USER_LED3,
$ v9 _" s+ b! _3 [% y+ J/ a/ Y: W .name = "user_led3",
7 \" r6 m' y* g .default_trigger = "default-on", H# J4 k: \6 q8 {+ M$ ]( @
},
" a K+ S! R/ Y6 X# ~" V};
( ^0 ]2 Q; i% I0 T( I2 U O7 w" j; @2 S. M7 g2 K# G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& @- p8 S) D5 u1 t, ]7 c6 b K7 h
.leds = da850_evm_tl_leds,
4 T. t3 \9 W. J9 k# n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 F( n; J- L8 S5 y& J, ^! F
};
7 f6 f- y" x9 `+ i: D+ X9 E3 S$ y! U" y
static void led_dev_release(struct device *dev)$ g, T" I$ T( Q- {( K- ?: E
{
2 |! W* C! o* |( O0 ~};/ @$ m/ n ^/ `% F( B) t; q
+ Y2 Q1 q) R2 \7 z" b2 ^! y/ O8 H' D
static struct platform_device da850_evm_tl_leds_device = {
5 a$ T8 B5 H; j .name = "leds-gpio",
& b3 q. c+ ?9 U5 N .id = 1,& d- h/ a" ^ ~9 |0 P z3 V
.dev = {
# v) a8 u, o: T% J* t" A8 V .platform_data = &da850_evm_tl_leds_pdata,
: r' k" R5 l3 ^* O \ .release = led_dev_release,% X) m: Z# E2 A" N
}
$ X1 N7 t8 j! o4 y0 \' \+ z};
; Q4 U; ~* ^8 ^ m. h2 W7 w6 E; U9 ~& u9 E- }6 k
static int __init led_platform_init(void)
8 t7 |8 o3 z- U% _{
4 A* L7 `9 ?: X% X# E9 R k int ret;$ f' F1 [& M( U2 H9 x0 G
#if 0
; J, J" h( T/ D* |& r9 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* r @# V; `& n' n S if (ret)9 V, z! i9 _0 H8 l+ ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 K: k& R8 G4 j# u: O8 k "%d\n", ret);
/ i o _# [1 L' O" q0 M# u#endif
+ y, G" Z/ _) A5 G1 ?% j0 Y" s ret = platform_device_register(&da850_evm_tl_leds_device);
( j5 L) y9 {5 ]* Q: A% H4 s if (ret)
6 \) |9 x6 V: H$ o( L pr_warning("Could not register som GPIO expander LEDS");
$ V: A/ | \( Z6 C( V y9 u/ s else, U$ t1 [2 R7 k: B* W
printk(KERN_INFO "LED register sucessful!\n");
}$ M2 p9 p# V/ W+ j; Z( P" P! T Q! }
return ret;* @3 Y0 y# w! G
}! ~: S& V1 t) b+ Y& C3 @8 {
' E; J9 x5 R5 c! b, Pstatic void __exit led_platform_exit(void)
5 t6 K% \7 \' X) C{
- N- @6 S3 K2 p4 X& \0 X platform_device_unregister(&da850_evm_tl_leds_device);7 Y4 ?; h% i& y* N2 S" j; P; `' G, g
! w0 M+ m) p$ V4 ?5 T. q, O/ } printk(KERN_INFO "LED unregister!\n");
* N( j# i. i* o1 `3 J# n}9 m7 w n$ i7 Z; u2 w
5 t; s- N" K& S# s( f L9 i2 _4 {module_init(led_platform_init);
4 [1 }; t7 X/ V, P5 a2 P N& vmodule_exit(led_platform_exit);8 z: E( h9 a' s! W
- O& r: X/ h8 n' c+ G l* ?MODULE_DESCRIPTION("Led platform driver");+ {; z# A. f$ {1 ~( k
MODULE_AUTHOR("Tronlong");. Y. V- f. E3 Z: Q% ~! L
MODULE_LICENSE("GPL");
4 W8 }$ ^! N; f, T: w! l# e$ c" ?; z% r9 o! U
|
|