|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% ]+ @& W; E; r9 _$ n
#include <linux/init.h>' S2 |6 o `( u( a7 i: m/ y
#include <linux/module.h>; i) t- J2 G" H0 n2 [; H/ t9 j9 b& |
#include <linux/kernel.h>2 D# S) O' t+ O0 ^; h
#include <linux/types.h>
" _ ?8 ~$ [2 V. s( N T: c#include <linux/gpio.h>5 T- M/ c" x+ t2 V0 }( |* ]
#include <linux/leds.h>
. E3 t3 Z( n$ T9 O8 R/ h! l* d#include <linux/platform_device.h>9 p3 V) p( r f" c4 T% |/ a
, F: w- F: B% i
#include <asm/mach-types.h>
3 V2 c$ e* V/ O% U& g! Z1 w; g$ G#include <asm/mach/arch.h>! S- p- e! K0 x
#include <mach/da8xx.h># ]$ Y; i$ ? G+ @8 `/ f* w
#include <mach/mux.h>3 h: Q$ N' v% O1 j# J: z! _
* ^; L* i* a/ `7 q! ~; |" g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. f7 `$ v6 W& X: Z5 D4 v* r8 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 H. \. ~' U u! G2 }: d6 h1 l- O6 R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; l+ y" [* w$ }0 Z% d7 D6 K% }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) @& ?0 v2 `3 k' l) Y' j* P5 w! ~1 E9 h" j2 w; M1 H5 @, f
/* assign the tl som board LED-GPIOs*/0 [: N6 n* S* a# F( _! {
static const short da850_evm_tl_user_led_pins[] = {7 b; y$ L% Q+ j
/* These pins are definition at <mach/mux.h> file */
# m+ p6 K5 Z) V) b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( ?2 E: l9 \/ ~1 J2 B" e -1+ v- U3 _+ e4 T$ n0 _7 B2 D: G
};# `* w7 {0 a; M4 h2 M, I3 i
8 K' ~9 t4 n0 ?7 Q* X
static struct gpio_led da850_evm_tl_leds[] = {4 q6 n2 W0 e/ f2 `. J
{* w- W, p) s8 Q4 H; o4 h7 [
.active_low = 0,
1 T: A' Q' k- ]; e% V .gpio = DA850_USER_LED0,
7 G" u9 t% y5 `+ K# I3 Q- `/ C7 a .name = "user_led0",
/ J: d G. M2 K6 D0 z8 O' y .default_trigger = "default-on",
@2 D0 v Y" G1 F },
6 q) {8 Y1 V' _' r8 M9 n {
1 U% k" G- X# f ]8 E* m .active_low = 0,
) J$ K3 z% p4 @* ]# R .gpio = DA850_USER_LED1,
( `1 T3 g2 `& i' X .name = "user_led1",) U& g' H, M2 C
.default_trigger = "default-on",+ G3 d2 d# w9 L
},
' X. Q* Q: b: |( g8 E, } {
4 G( k% W5 A1 ` .active_low = 0,1 [4 U- d6 A5 N# j2 \0 Y2 J
.gpio = DA850_USER_LED2,
3 r4 ~# }* K: V' s .name = "user_led2",0 Z# C; D2 a7 _ X
.default_trigger = "default-on"," I8 e5 V& c! D/ E
},, ^2 V q3 K; y' i
{( x8 R* Z q* ~/ a8 ]5 @, A5 u
.active_low = 0,
" Q- o; R5 X5 n" [2 Z .gpio = DA850_USER_LED3,
0 b% L3 O2 x' H1 G .name = "user_led3",
/ x6 Q" }& Z7 w* y' b8 k .default_trigger = "default-on",
, U( b$ @" I" j& ^" K S6 [ },8 E4 e- N4 m) i" A; y# K* r6 g, V
};
' L% `) `2 e% ~9 J! w9 M
. E5 N8 S5 t4 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ p6 n- O/ R! a2 E5 I8 o, [ .leds = da850_evm_tl_leds,! V! S6 Q3 K7 j) Q$ ?9 W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* L m, P+ Z+ ^2 _/ I+ e3 j};
+ ~: X8 ?4 O( v, N' C# p3 M
, _, D5 E3 ]9 m( }3 B, Ostatic void led_dev_release(struct device *dev). T6 X1 a; o, z# p0 z1 t
{
; \& l$ z( L5 P& h& Z6 O};5 e8 C2 n8 N( T$ i/ B- x+ {* x
& a$ n! A( U# ~( a
static struct platform_device da850_evm_tl_leds_device = {
; t- E, G! m2 T* ` .name = "leds-gpio",
/ T) R* M- S9 x1 \, v+ W6 l- i .id = 1,
7 {0 @" W0 z7 o6 Y7 `9 a .dev = {
" I* E% {2 H7 B1 k$ M1 A .platform_data = &da850_evm_tl_leds_pdata,
7 F/ Q- [0 B- u. K% N. f .release = led_dev_release,1 l% }! \- N& p3 B# _) V
}8 J/ t: g/ w* o
};
/ `) s6 ]- F) u# V; Y. O4 a7 U, | k6 r' E& H% Q# G: L
static int __init led_platform_init(void)% @, l+ u( Z2 b% j
{; d4 M t4 _' _) \& E9 S
int ret;6 \+ K3 f9 Z: ~5 o7 {; @# [
#if 0
/ ~; E* G* G1 u8 ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 \& y7 ?# ^) N* l- Q
if (ret)' K, c! \# p3 `: K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# M/ I7 M. }- c9 t( [ "%d\n", ret);, _9 s& a& G- B9 M: m k1 @
#endif
' w5 B4 I. u5 w9 z0 M3 H/ o# `) w ret = platform_device_register(&da850_evm_tl_leds_device);
. y- ?! S9 @% h7 k% V1 E& T# `7 O if (ret)( Q- z9 u7 L# A; }- M- N- J% t
pr_warning("Could not register som GPIO expander LEDS");
g0 j0 x% G8 b" Z else
/ D' _2 } b. t" v' R9 Q k printk(KERN_INFO "LED register sucessful!\n");7 H6 j6 j* G( z8 w+ B
/ A9 k3 [$ G! X7 I6 y
return ret;
4 |0 ]0 A" H3 B' L w}, c4 q: g0 p+ f4 T4 ]: i/ _
3 o5 N, w, W4 A3 @: P: Z+ rstatic void __exit led_platform_exit(void)
- h y7 g1 k+ J{7 S: s+ v9 H r' v" Z+ W, M
platform_device_unregister(&da850_evm_tl_leds_device);
. @( L6 n4 L/ @% p5 o5 E1 e4 n# }6 h5 ]; E8 ~& G- `
printk(KERN_INFO "LED unregister!\n");
) I1 M: @4 G/ U2 c1 ]2 a5 [}( N6 u+ }4 y& Q! P4 ]0 H1 ?# W
' a! n& d+ r: s$ s) ~* I5 umodule_init(led_platform_init);4 ~3 ~: W* a/ K- d% d
module_exit(led_platform_exit);
* O/ `3 S/ {" Z$ `) E* n& b1 r+ T! b: ~$ m% z$ H7 b
MODULE_DESCRIPTION("Led platform driver");& e' v. U: O5 g& t
MODULE_AUTHOR("Tronlong");& @# p6 k7 c) h0 r2 W4 Z* x% O, g
MODULE_LICENSE("GPL");+ C* e( i1 p3 V/ K8 @. u
9 o6 w+ l, J" {5 {
|
|