|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( K1 ]/ l. B3 Q5 c#include <linux/init.h>. q R5 r0 A1 @4 S6 L
#include <linux/module.h>
5 K; T" {- u: _5 w* r+ w#include <linux/kernel.h>
$ n5 a R1 U2 F- g* J! g1 q' b7 N( I9 t6 [#include <linux/types.h>
* U6 u7 ^: y! v- A3 p0 M#include <linux/gpio.h>" c; [* K7 k" q* I$ y$ g! ~
#include <linux/leds.h>) R) Z( a5 [' Y" o" A+ S
#include <linux/platform_device.h>
0 A1 X8 n" {, M/ ?
9 i8 B6 l! g1 j. a* a5 f$ Q) N( c#include <asm/mach-types.h>2 O h% v* S' u+ l8 {6 \7 f/ U+ m
#include <asm/mach/arch.h>
! O. L% u5 C; X: g3 e#include <mach/da8xx.h>9 l. U: H& M4 p, W
#include <mach/mux.h>
2 Z) i, a3 }/ x! f" c6 v! k* E, ^! ~# R7 I, z" C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- N9 e Y+ d7 B1 Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# Y. X2 T& [; W# ?/ R% @7 y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: A" I' t* ]9 B" Y& l; O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ s8 U, \6 o/ v0 f" X( o
) ]5 q! M1 r8 U% d- `/* assign the tl som board LED-GPIOs*/
: }& E3 P$ B' j2 estatic const short da850_evm_tl_user_led_pins[] = {
9 }1 \. s. H; G* n7 n) m /* These pins are definition at <mach/mux.h> file */& @& R0 _: L! s' Z0 h7 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 W* C3 A8 E# [# g) A -1! `$ p5 ^- l. k: ~1 _
};
- D) X7 s8 P8 b9 u: L* n# }
0 ]6 p; p" j6 v8 D7 G3 e6 r3 A3 Astatic struct gpio_led da850_evm_tl_leds[] = {4 h6 \/ q( n! @9 u/ u9 W4 B. D, x
{+ M1 Z; r" S6 K
.active_low = 0,) q- i b. T+ V
.gpio = DA850_USER_LED0,
0 Z2 b, Y! ~. @. L( U2 E; `9 U .name = "user_led0",* L4 B7 C+ [5 h V9 U
.default_trigger = "default-on",6 P: P2 B& h" u6 l* t
},
6 m% E* n6 n- M; j5 r* E' t v6 y {
3 f3 x5 D3 h( u/ d9 E. x5 y( B .active_low = 0,; ^0 U0 q2 }, I/ H1 _) j
.gpio = DA850_USER_LED1, h( ~ {! U5 L, U
.name = "user_led1",
6 g; p( D! i: r- F: Q1 r; N4 k .default_trigger = "default-on",2 x' N9 A6 {& A0 E8 }$ l
},* J+ r7 C; [$ C( R3 n
{
" _' Q7 o5 k/ i, j% F! [7 E .active_low = 0,2 {2 t4 r8 C2 T" L5 v- `4 M _
.gpio = DA850_USER_LED2,
, P. ]' a V1 y: A! f0 L) } .name = "user_led2",: E- T9 [8 U5 L$ T# k; d
.default_trigger = "default-on",
3 E4 ]) ? C7 S l+ S8 t! m },
2 ]8 F; Z! _0 c7 ]/ v; V% R; [' g9 V6 C) K {
- \+ Z& X& T. y .active_low = 0,
9 N6 h) z* I. [' a9 w .gpio = DA850_USER_LED3,
( ]+ J& {) ~/ w# _, m: D: ?+ K .name = "user_led3",. Z: F$ Q% e0 \! r3 W
.default_trigger = "default-on",
4 w H9 u( @4 O0 \7 k4 e% S },0 u |& _: d$ S/ A# m, `/ A: z
};4 m( G# e0 X+ U) ?
6 D5 D) P6 V4 o) K0 r1 n8 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- y% Q9 R6 j' {- N# i
.leds = da850_evm_tl_leds,
) s+ O* o7 I+ | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 J0 H/ s! u5 @% {/ H};
3 l+ w: Y9 y x% Z+ m H6 k" ~5 T. \8 ]1 Y# e; R$ k6 I
static void led_dev_release(struct device *dev)% P% ~- b. {2 h( [
{
( f/ s( O- u: `: O6 h* H+ S};* G4 c2 U% O" s; O* j T R
5 @" U' n W8 a8 ]static struct platform_device da850_evm_tl_leds_device = { Z5 ?3 ~/ A2 `/ p2 j
.name = "leds-gpio",9 Y5 E( q) ?# Y
.id = 1,8 _( @! s5 O% |' Z+ Y
.dev = {$ s1 q/ Y% F+ T% G
.platform_data = &da850_evm_tl_leds_pdata,; m( d+ x$ V0 ~5 i- h, D; b
.release = led_dev_release,
6 d7 k4 m3 d `1 Q* w }0 V1 n" O8 M+ W- y4 w! \6 {. P
};# E6 W- S3 W! b( p# a5 v
# d/ n9 T" p3 X9 ^
static int __init led_platform_init(void)
. C) q/ {2 p& H{( a1 E, w* y5 J- w2 B1 }3 i" P
int ret;
- l: F: Q4 {! I5 K7 N#if 0
: _7 v% ?3 v5 |+ c1 d- z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 Z4 w( y# W7 Z% P. t; a' ^
if (ret)9 E" F4 {2 z Q: k7 T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 m( h/ f, P$ Q1 p+ L0 k. j! f
"%d\n", ret);& L" ]% B9 x6 x7 _6 `+ j
#endif1 J4 K& l: J* Q8 b `+ A: R- Y
ret = platform_device_register(&da850_evm_tl_leds_device);
) _+ o8 }$ [* i& e Q$ o if (ret)
0 v" t4 U8 N! e% i% P" l( U6 q pr_warning("Could not register som GPIO expander LEDS");
' i" A9 Q' n7 f+ l else
6 x+ o5 U6 a: k8 x; I7 `: ?0 ^ printk(KERN_INFO "LED register sucessful!\n");
) I. s; o& N( G) U/ t. f3 ]7 k3 a- ]& m
return ret;; }: ?" U; {( I" ~
}
4 K7 P4 f1 |- k" J
9 H `4 E# W1 B- estatic void __exit led_platform_exit(void)
6 g x) y$ C9 i7 H+ J5 j# Y{
2 f$ }- E5 C% t' p' e platform_device_unregister(&da850_evm_tl_leds_device);
+ L) `# W# E5 j' V; T+ r; }$ p( n! v/ \; i$ l0 q' U' ? ?& [% ~4 a9 e
printk(KERN_INFO "LED unregister!\n");& v! m* _6 @$ L+ j1 v( r
}+ F1 l5 E5 R) l5 W
5 l2 w: @' Q5 C* w" H0 I g* r+ E
module_init(led_platform_init);7 x f' e. d! Z- x
module_exit(led_platform_exit);
6 i4 x, x v* h* `: }$ N3 |/ G! s
MODULE_DESCRIPTION("Led platform driver");
/ q6 W& Q' q& r' i1 UMODULE_AUTHOR("Tronlong");
E2 Y& C8 q7 q% eMODULE_LICENSE("GPL");
/ Q/ b/ q' ]- ~5 z: W/ \- s6 R/ S2 H) e
|
|