|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 P1 G4 I& Q: ?& l. T#include <linux/init.h>
. L+ q9 `5 R' j0 c8 W#include <linux/module.h>. t% U. a: I5 w u
#include <linux/kernel.h>* h+ Y; `7 Y1 D4 l
#include <linux/types.h>
$ e* K" `1 G" Q! \# a#include <linux/gpio.h>+ e3 X: `9 w9 m1 _! Z5 B6 F2 W9 K& G
#include <linux/leds.h>
: r+ o6 `$ b# Y# L# v" r' E) r#include <linux/platform_device.h>
9 ~1 @/ U6 r% u" R0 V' G" j3 J' [; Y6 U% P- Q
#include <asm/mach-types.h># L8 x3 s# Q$ a C3 Y2 O* ^
#include <asm/mach/arch.h>
+ D, R1 ~- ^" O4 D- E" [: i#include <mach/da8xx.h>
* t1 R( s; b) y) a2 K' K#include <mach/mux.h>& J; v m% I+ H1 o# N
) }0 f$ J, A* m$ f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. A0 Q% I2 E8 p& z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ l' T+ s ]; ]0 t, Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. u( j1 w. h+ F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 n* B C" L7 h# E# e
9 g7 j$ v) E# n0 U
/* assign the tl som board LED-GPIOs*/$ y. p: O! M- r( w: k
static const short da850_evm_tl_user_led_pins[] = {
# Y. w. q# g- W1 h- P /* These pins are definition at <mach/mux.h> file */
4 Z% J0 `: _; _5 a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 o: }/ e5 a* n -17 O+ f5 }% f+ J+ @5 c+ e9 y# e9 O
};
- Z; C( G* A. ^3 R. T' V+ S" c: n7 P* g$ r) A
static struct gpio_led da850_evm_tl_leds[] = {4 w! G8 e k1 |4 `3 a% f5 f, b6 f4 K
{
, j' |- D; X6 W; ^% t .active_low = 0,
' h! x3 C0 f6 ?/ }- b% W .gpio = DA850_USER_LED0,
+ d1 {8 A7 X! h! N; l .name = "user_led0",
6 s7 v% E4 s; G4 O6 \1 I .default_trigger = "default-on",8 X$ X& x1 M1 P7 L& P2 l
},
' @+ S5 B+ ], \% a1 d {
4 i% ^" |/ k1 A; w8 W: q .active_low = 0,) V, j1 Q) [. |* |- y
.gpio = DA850_USER_LED1,
5 ?/ G8 O$ _" _9 _) O1 u& E: P0 I .name = "user_led1",$ c2 ~2 d% t" i2 l
.default_trigger = "default-on",
, [2 y4 m- l: q# l, G2 [ },
7 M g: d) Y( E# l {
9 p5 B) [" }7 ~' H) c; i l .active_low = 0,
% U( h; n" ?1 G- s4 |9 [' D3 D .gpio = DA850_USER_LED2,( i) ]* j, p# y+ w/ S
.name = "user_led2",
+ h6 N8 Q, V- ~' m& { y .default_trigger = "default-on",: n6 d0 n* F! F! ^3 u9 p& Y$ O4 h
},6 Y7 K, N1 ^: F: G$ E& l
{7 z5 a/ ]& I3 b8 k8 S
.active_low = 0,
8 `- Q0 ?( S6 [2 X/ r! a% [ .gpio = DA850_USER_LED3,, W# T, ]! D" }9 T9 \% A/ D
.name = "user_led3",
% [) u* M* D, N4 S/ R b5 A7 G .default_trigger = "default-on", f; B- C2 {3 }( u8 m) O: r; ]
},
/ a1 b( H0 L' {3 h2 P, L$ k};3 {& U; ?& `4 b% X7 m
1 E; Z/ q" X1 o/ m6 {! S" sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" g7 p4 C9 ?9 a, E .leds = da850_evm_tl_leds,
+ W2 | }, V) n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* }# \# B: D1 W5 i* ]};
, j4 K9 I* v4 l! p& p `8 h5 O" a( [) F
static void led_dev_release(struct device *dev)) z( p/ m: V% p9 \7 ]
{
' N6 v1 Z- e& R5 D* `: t};( B5 Y. X* G: j v
& ~# r/ k* o& xstatic struct platform_device da850_evm_tl_leds_device = {
, a+ g/ q% z/ J .name = "leds-gpio",* @& x. ]9 R5 ? q, h8 U
.id = 1,
. v& n: T& T1 j: P( s .dev = {
, d) V( E& ^, c* i1 z8 d" t .platform_data = &da850_evm_tl_leds_pdata,4 W1 e& F% @# f5 F7 P0 t) B
.release = led_dev_release,
- [/ m5 L n2 V* M" l8 C) q }$ }% W4 w7 l, ]: P! p8 v/ E* T
};, A# g' G e( m: O
/ V$ S' c" ~$ [/ P, k+ }4 P
static int __init led_platform_init(void)* z1 u- ^: ?6 P Q
{# }! r- r. t: I) K X5 K3 \
int ret;; ?3 |. v! `- ~0 z
#if 0' h: i% b6 Y5 C$ a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 q& |/ l" ]0 W; R1 I if (ret)# k& y7 i9 L3 V9 i# Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 F# w4 y9 u3 W& M! ?' ]1 z
"%d\n", ret);; U2 c! w, C3 K/ r: q+ d) V
#endif
) S# I! K$ A+ \+ v& v6 r7 } ret = platform_device_register(&da850_evm_tl_leds_device);: F4 m2 K/ e% x1 L! D
if (ret), D% [# c0 |8 ?; I
pr_warning("Could not register som GPIO expander LEDS");" w0 g, {5 w% ]! O5 D1 j
else/ q- {% D( a- L4 w, J7 _; w" f2 j g3 ?
printk(KERN_INFO "LED register sucessful!\n");
) v& L+ B5 C% x' U) N1 r
. w/ m- [- ^, V$ U return ret;+ s; Z" T0 n/ H+ V5 e
}* t( d* P$ R; B6 W7 ?; W# i% h3 T: T
: @. `5 `5 n7 q2 C$ Zstatic void __exit led_platform_exit(void)' y' R& v" y) t, |2 o% B
{
9 d( c% J& k7 Q9 b) v platform_device_unregister(&da850_evm_tl_leds_device);
% ?; F D6 J O3 [7 S3 J3 H% t j/ \( f9 z: r2 F. v# q/ t7 Y
printk(KERN_INFO "LED unregister!\n");1 G% Z: l8 J; k5 {5 J6 O* z g2 |
}% D b2 Z/ o& t1 W' `9 {2 U
. d5 W9 K2 ] \- ]! n; k
module_init(led_platform_init);
* ~) ~3 b8 c# ~) v1 C4 i& }! wmodule_exit(led_platform_exit);
+ w Q0 r5 C: g& G
- L: _4 U7 _7 h- O) uMODULE_DESCRIPTION("Led platform driver");/ j7 }! o9 c n# v1 }/ u/ |
MODULE_AUTHOR("Tronlong");
5 t2 h9 K: q, e% uMODULE_LICENSE("GPL");
U p% V" @& ^) `: X9 e# o& r% \" _+ E) d& W$ z! [1 Q
|
|