|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
F: N* d5 R$ B/ w i3 n4 N#include <linux/init.h>* T4 [8 {6 Y# V# S
#include <linux/module.h>
6 S- I3 `2 ?5 i/ }: e2 H7 ^( a+ \#include <linux/kernel.h>* q4 \1 J8 [ z' W" _, o0 Q( P& c) d
#include <linux/types.h>
4 @. G S$ c7 a4 A7 C, x G#include <linux/gpio.h>
+ G+ H4 O- Q" A9 x3 o) Y% @2 T0 D#include <linux/leds.h>
! n& v9 S9 x I/ k#include <linux/platform_device.h>* V" u4 V5 l( x% x& l) j
. P9 m+ P( d0 U: E: M
#include <asm/mach-types.h>
" ^2 H# Y, J, Q2 p& H+ X#include <asm/mach/arch.h>
0 l6 J3 B/ O. D, A: a& {6 L#include <mach/da8xx.h>- u0 e$ o; S; L, D
#include <mach/mux.h>
- G- K* i7 t: X7 m! \) X' t, E! r/ d/ t0 M [; L: ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 ~! o; `* P: y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 ]" Z6 f4 `" b @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* y0 j" x8 `! z& L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* O! @: f- Z* q/ r, r: X0 m, E
/ q R; o7 f! o, y; N/* assign the tl som board LED-GPIOs*/
& w8 F( w5 f2 Y, c& L8 Gstatic const short da850_evm_tl_user_led_pins[] = {
& S+ z' `7 }7 ~! E4 Z) v /* These pins are definition at <mach/mux.h> file */
- G8 R$ D: v& L/ V! ]: p+ ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 g! N* H' O8 [ -1
W+ H, e. v- }2 X};
2 S7 [% x& ]4 B
1 C% Q$ |+ A) r+ D, ystatic struct gpio_led da850_evm_tl_leds[] = {
2 p' j: Q2 T, d7 d. v; t# a {
) @2 m, b" y( n! S$ d! Z .active_low = 0,
9 @* i: o3 G _+ E8 B .gpio = DA850_USER_LED0,
" b' T+ L/ z0 \( d2 [/ Q! d/ p- h .name = "user_led0",7 b3 L: a( h. Z
.default_trigger = "default-on",
3 t& s G4 J; Z% `( } o }," M; h! K1 c8 D. m( k
{
/ C4 N* T( }" {" F* f .active_low = 0,/ q% V: e; G5 D( }: F; Q
.gpio = DA850_USER_LED1,
& j+ Q2 Y8 g; s1 |5 U .name = "user_led1",2 P% k6 ~1 R# U4 c! @
.default_trigger = "default-on",
, b7 l, \" q( ~5 l" e6 T3 u7 } },
H& {6 a5 c9 ]- s {# E3 I2 @& ] k% i
.active_low = 0,0 c% \6 b8 M' Y& R/ ^
.gpio = DA850_USER_LED2,6 e+ D2 q z$ G) E
.name = "user_led2",7 [4 v, W* k' ~6 U
.default_trigger = "default-on",6 E) Z' z ^. B
},: p2 T1 J! F. F/ c
{
' E9 m1 P, e" `% T3 p .active_low = 0,/ v9 b' ?. Q2 ]3 q, g) c! D6 l0 i
.gpio = DA850_USER_LED3,
: h# c2 D' Y( o- d) r" g2 E .name = "user_led3",& r. k; Z* ~& X5 O; I! ^
.default_trigger = "default-on",
, W% H) _( L% i; K },; i2 R' v, j+ e ~3 y
};
; E! r2 c6 ^% A! q+ E
8 U/ q0 i9 o% tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, k# ?2 D% X( K, x* D' N" g9 R; F .leds = da850_evm_tl_leds,! X3 ~8 c& J( Z6 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. `- `# v# W% J% V% i$ T};& R; a5 P' w5 y* `
3 W, d m" O3 w. X4 _7 w1 O6 h- i/ G0 U
static void led_dev_release(struct device *dev)2 o, ~4 `, D5 r6 e: M
{
! Q) T* Z7 {1 k5 y( A2 u};
7 u" k8 w6 \5 [2 L
3 z% _9 F# y# Q9 P3 c1 r, b% estatic struct platform_device da850_evm_tl_leds_device = {
; S d6 _6 u, M" r" A, c; e/ z .name = "leds-gpio",
. }8 t6 _4 H1 r6 X* h .id = 1,
; j2 h- J# |) W i# r .dev = {
: {; t0 ]& J4 B! }4 L# \) y$ l) L .platform_data = &da850_evm_tl_leds_pdata,+ a5 t" G! o3 ~, _# V: i7 F8 Q
.release = led_dev_release,3 o) q* M! {; Q5 ]3 |
}! f( s# y) F% y- \
};
7 B6 \/ T3 A, |0 z; S* P4 k8 v- K$ A- {" s1 N
static int __init led_platform_init(void)
3 e; A- Y* L! w# e$ }, q{; w" T$ v- \% \/ j6 p. Y
int ret;
6 E2 Y h+ f8 ]3 O" \2 K#if 0' H/ s. X2 D, [: g e3 [3 J$ ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 ^& \# g d2 d# X3 P3 H' G
if (ret)& a3 c4 N7 E6 S" V) r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 w+ ^ _* D8 }0 ?
"%d\n", ret);
9 |& Q: T4 u% {3 U/ u' _" ]( U! @#endif6 \, G2 F8 a# b Y) s
ret = platform_device_register(&da850_evm_tl_leds_device);9 |1 J$ e# @# |( `
if (ret)9 q6 X. k6 c7 \- |+ h' i
pr_warning("Could not register som GPIO expander LEDS");
! `# v. G7 o9 n# r: t else* I8 c: q8 h0 _8 |) j
printk(KERN_INFO "LED register sucessful!\n");
' v T# u9 f& v) U3 {2 a3 M- \1 M; \0 |0 u' P
return ret;
( p" A, x* b& w& Q' ? |- q# s" S}9 ~4 v _: o5 @. I
# j! O* ~5 V3 s: X! i$ ~7 o% r
static void __exit led_platform_exit(void)6 z0 c; j! ~/ a/ x/ w
{! p3 D3 \9 W2 e( Q; g' `
platform_device_unregister(&da850_evm_tl_leds_device);
$ | H: c: @" E, l4 S5 z" i) L4 n7 n) m( K% R+ B
printk(KERN_INFO "LED unregister!\n");
1 V4 m; x" q. [" |8 G$ b}, H1 S& J/ i* W K* s9 K$ r
4 n |& q; K) k( K! a4 l6 l' n
module_init(led_platform_init);
?1 r' e* k$ B2 U$ r5 n% Dmodule_exit(led_platform_exit);
* z5 v2 C5 `7 ^- N! v9 w! Z+ e7 I/ }
MODULE_DESCRIPTION("Led platform driver");
8 n s* k$ k! x# {2 f" kMODULE_AUTHOR("Tronlong");* ]+ S, u- q* G8 F) g8 H% _ Y
MODULE_LICENSE("GPL");! x- x0 q$ O6 S8 h
' L( Y+ }% @9 w/ v& C3 O
|
|