|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) r" U l% O9 F$ e8 P5 B. Z, S#include <linux/init.h>/ i+ W, m6 w) s7 V, t8 O4 }
#include <linux/module.h>3 a7 E# Q- c& u
#include <linux/kernel.h>, r$ j3 O) i7 n$ a& T. G3 ?
#include <linux/types.h>
* y+ s0 A. J" ?7 Y" j M#include <linux/gpio.h>& A2 V$ k; _0 }9 k# U, Z
#include <linux/leds.h>& R# I% `6 Q! d- w* {
#include <linux/platform_device.h>& x+ J# Q( M) ^ S; s- r
: ^5 H7 M9 L: n/ n6 ]
#include <asm/mach-types.h>/ o0 o! A* {1 F3 b; ]8 o
#include <asm/mach/arch.h>" e7 ?4 _6 Y, q2 I; _) ?5 v: Y
#include <mach/da8xx.h>
+ u7 ~8 O& r/ R, P2 x3 ]: g/ m$ g1 l#include <mach/mux.h>
- ]# u% y1 @ \$ |3 B' m2 `( O1 j2 |: m
, O1 z" @. z1 \! X8 q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 F: Y0 g: c0 D, D" w# u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! F( K, U; i+ M$ e/ \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 g* x4 t; X. ~$ h$ L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 m8 Y2 T& C: D/ D5 \
' K$ [% ^$ Z* q' I4 `
/* assign the tl som board LED-GPIOs*/
9 \- f" d- e2 ^, e- `2 Rstatic const short da850_evm_tl_user_led_pins[] = {: T4 V8 L8 A& V* [; y2 b8 D! Y5 q
/* These pins are definition at <mach/mux.h> file */$ ]& `! o$ Z( U! ]% r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 j O3 v7 [* b; c$ _
-1
( {( `3 a( J+ c" w" r( S; F};+ s4 p% r2 {# B+ k& t
h! P, a9 ^9 W+ r- r5 v; B& k4 y9 Z
static struct gpio_led da850_evm_tl_leds[] = {
& X7 c1 E+ e& u* q/ Y, Y4 ^5 a { a% Z% Q! r( _
.active_low = 0,1 x& [0 E& j# @0 w, w5 p; Z
.gpio = DA850_USER_LED0,
& J3 X1 P2 V2 e6 u( L; K .name = "user_led0",
3 E( y5 F* s+ k* h .default_trigger = "default-on",0 D! [& p5 x9 v' w* ?
},
2 a+ M7 b4 w4 c# P5 Z {; a0 I L$ j! D0 R" {6 a8 j
.active_low = 0,+ J$ N0 c' M" _9 x) v, b2 O
.gpio = DA850_USER_LED1,
4 \4 Z0 b: b8 n# a% a3 ^: U .name = "user_led1",- J- ]: [: u( e4 [/ y' S
.default_trigger = "default-on",
" m- i, O+ @5 g2 V: y) [5 v },
, K) w p" g) N6 B: D* |8 K {
8 f9 ?' h. k9 ~( \ .active_low = 0,
! T |1 Y/ J2 Y: A) l; ] .gpio = DA850_USER_LED2,
7 i2 v/ p7 M+ `. |1 N$ y9 Q% ?- N .name = "user_led2",) q) N8 v0 v+ }9 L2 q' c2 ]$ L* A. B
.default_trigger = "default-on",, v) S7 e! ^1 f& a9 R0 J
},
, e$ f" o0 X+ w {7 A6 E$ Y" B0 g' i6 k
.active_low = 0,
0 Q( k/ V% R+ S% L0 m- Q u m .gpio = DA850_USER_LED3,
r, Y5 Q0 M @( G _/ U .name = "user_led3",
o0 W6 O. e% |3 q; H( n0 ^ .default_trigger = "default-on",# p( D. N# a& c; C5 ?
},
4 F1 \# D9 l& w2 o};
4 k0 a' V" X: ~6 ]/ G) B( n9 G0 B' B
+ J' u) M7 Y4 R) Y% a0 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: j; F0 w9 k$ S) J4 M .leds = da850_evm_tl_leds, z |8 g. o3 L: L- L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), L& V T4 g* v1 E
};
! F4 @ T1 d) g: ]3 L& I/ Q" f, L6 g9 y& z) x! c
static void led_dev_release(struct device *dev)" ]( E& }# ]/ t e6 { R5 E9 L
{
% _8 b+ C1 _/ Y9 h+ k0 P};) a3 ~+ q ^ i! l
% C4 L3 H- V. U* tstatic struct platform_device da850_evm_tl_leds_device = {
5 I% `& A. l `7 b4 V .name = "leds-gpio",
( k# }4 T S: r: q, ^( E* r7 A .id = 1,4 V# j: N$ w# ^( \
.dev = {3 ?* ~ E& E% x5 k' h/ g& Y' A8 Q4 T
.platform_data = &da850_evm_tl_leds_pdata,
; U# J. s) x1 }; R( ] .release = led_dev_release,
" n. N. a/ S" R# {) N }$ F6 r% U1 w) z9 @& a3 T
};8 _& r2 O; M, H+ L
& C$ y. ^& b l% i8 `static int __init led_platform_init(void)
. V) e5 f( A) M- [- T$ A9 l% e{1 s6 j# p, W7 e+ |0 U. G3 j- C
int ret;: m7 m" r- L5 @7 y6 f) ]: u4 J
#if 03 I4 C0 J3 }0 A) D; E5 I( C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 a2 w, M$ U& Z. B+ A x
if (ret)/ f! n8 j! W9 E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": B R4 p! l8 s: [. [6 b& [
"%d\n", ret);0 s& h8 w( U# ^6 ]
#endif
" s9 ]. S4 O6 B1 U) N, g- L ret = platform_device_register(&da850_evm_tl_leds_device);2 I" T6 X# T6 v1 O
if (ret)
4 `2 K" R% m" z pr_warning("Could not register som GPIO expander LEDS");. k. E# h3 X; X; t+ k
else7 d" Z( s8 f6 y9 n% s( I
printk(KERN_INFO "LED register sucessful!\n");; E) R& N5 w0 h `
0 a/ W1 E( c, m& r
return ret;8 u6 i1 g( |- n3 F# U" K" u. J
}
3 V, `1 R$ O, S1 K, m" v/ j- T: e: W5 E% n( S2 h. q& |( O
static void __exit led_platform_exit(void)( \- \5 \ _1 K- ]& O! u. T9 m' O1 I
{
0 B% q- e9 ?: w platform_device_unregister(&da850_evm_tl_leds_device);
. l& u( a0 g* x' W: O5 \$ s) m5 H" }! |" W( m I1 d
printk(KERN_INFO "LED unregister!\n");: f+ r, }8 O( E9 E* K
}
0 U; m8 Y2 P- O
0 Y' K% ?5 F: a5 \" r/ wmodule_init(led_platform_init);1 \7 X: P- S( ?9 \& [" W2 S
module_exit(led_platform_exit);
% n' R6 I H# x( _# F) A. ]/ r) y+ Y, }1 ^9 g. a
MODULE_DESCRIPTION("Led platform driver");, q" D0 d1 D% a+ q2 v
MODULE_AUTHOR("Tronlong");
' N3 ] ^3 @; D6 YMODULE_LICENSE("GPL");; n0 i/ @) U# W( D# X7 c9 P& b
r/ Q' c9 _" x2 v9 a r8 J |
|