|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* a! i: X! R! [; N4 z* r0 \% L/ |8 u#include <linux/init.h>6 g6 L3 H! G5 e0 S. D
#include <linux/module.h>* `- x3 r* e2 i- P2 m
#include <linux/kernel.h>
2 H" R3 f1 `% i5 S- x8 F( `3 j+ Z#include <linux/types.h>$ V8 U# u+ w) u" k$ ?, I8 c
#include <linux/gpio.h>
& B. K" p" n$ _9 N3 G6 n7 ]#include <linux/leds.h>
% @# K3 n( I( W9 A: {; ?, u2 o#include <linux/platform_device.h>
: }) R; e0 c9 W
2 {- ^% o/ n- f1 H8 H: ]( v#include <asm/mach-types.h>" J: x- w9 n% Z0 _+ M3 B
#include <asm/mach/arch.h>! R, N# v. a' Z. w1 @
#include <mach/da8xx.h>
! z& y# ?* v7 ]; K3 S( ]#include <mach/mux.h> r( l! \" Q* r% y n; |7 i
p7 M( l9 }; j) g/ a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# b7 ~, [ h' T, t4 E/ L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): h- x* }" k4 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, Q: c9 d, @* p1 l+ H% X5 z& H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 j: t2 K9 T/ F- C. _9 m) Q
0 ^; j& A0 ~# D7 ^$ Z7 L: n/* assign the tl som board LED-GPIOs*/
" n1 f; u ^' N/ ]( |static const short da850_evm_tl_user_led_pins[] = {# m9 F+ P2 E3 N l( W7 t4 a& B
/* These pins are definition at <mach/mux.h> file */" N% q& k c6 o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ K* y6 S# _( t" Z0 Y
-1
4 z+ Q' V! P) Q1 |. o" \8 z6 f+ g};
+ t, I! x) Z, w) L; D L' D) x# n! ] c
2 B* |; P, H. {7 R5 s) ~static struct gpio_led da850_evm_tl_leds[] = {/ w: t; A6 J9 M( o* ], J# o$ i
{$ n/ j$ \, u1 q7 m& r+ }0 g7 c; B
.active_low = 0,+ w, I# V/ j( t0 Y7 |
.gpio = DA850_USER_LED0,
- B% o5 N/ R. Z3 \8 f; W+ b! D+ @ .name = "user_led0",
5 m; u- u- M7 ]7 g3 i3 W3 Q F6 Q# L .default_trigger = "default-on",8 F4 F* Q: I2 a: E( X2 T
},. t: b. W3 g8 g9 p" c
{* c/ I2 j; q5 I% O
.active_low = 0,& H5 m9 J4 U/ y2 w3 t
.gpio = DA850_USER_LED1,
1 o8 h1 f% ^/ G' t: x* V) t .name = "user_led1",
/ O* k$ {9 S5 C2 N9 l .default_trigger = "default-on",3 o# H+ F7 [3 C s7 m
},( I- u/ k) C9 U* e6 D# s1 g/ P
{
, o/ \, U( {# `" d: l" y% ? .active_low = 0,
2 e; C7 S. o; j/ H3 M: C* C3 U .gpio = DA850_USER_LED2,% x8 o+ e8 f2 M& K
.name = "user_led2",% T- ]( H% R$ p! S, L$ T
.default_trigger = "default-on",! g$ u' U' O3 j9 ^5 ^
},
* |: D3 j) p' s& ?. H {
5 R" { r0 L' z# A: F .active_low = 0,# E0 N/ d; ~/ ?; _5 p, d8 b
.gpio = DA850_USER_LED3,
: I/ T# s2 a: k/ d% A .name = "user_led3",
. g3 V% g# d, _1 ~6 @. l .default_trigger = "default-on",
5 C& X7 G+ t+ p7 m( P },4 \; l- X$ h. S& W k
};
c, O0 L; S9 ^$ F- o3 l& F
: D& }# K6 R& X! Y! e5 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 a$ ]2 t w- s/ b8 x
.leds = da850_evm_tl_leds,
( K' c7 R' U, D( k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ _) T% V' G* d$ y. ], }
};
# Q2 S; Q# B$ t! [" ~ C
& H3 d. M& w% F) }, A4 P! C1 Estatic void led_dev_release(struct device *dev)
* j# n7 l D2 C7 n) \/ k2 r{/ J1 U$ [- i0 H w$ Z$ z3 \
};2 a& {: r8 T# l% `# i/ J
8 s4 p( L8 O* t) |! F& rstatic struct platform_device da850_evm_tl_leds_device = {0 ^$ ]: n# V+ Y; Y
.name = "leds-gpio",
6 l# R( N$ _- z+ t. [! T" h .id = 1,1 A: o5 Q/ ?! l- B2 Q
.dev = {: o% E$ T7 v0 e: X3 d/ y
.platform_data = &da850_evm_tl_leds_pdata,* z6 M1 |4 [6 _/ }1 u3 W4 w* A
.release = led_dev_release,
5 C- r5 ?, p0 E2 y }& C5 c6 c* r; E$ B8 F: \: ^
};6 f: z2 X' o* q/ T& e
! T5 K9 s/ c; S' t1 H4 I- Y% Dstatic int __init led_platform_init(void)
! @ W5 N. P: b+ N/ T2 `{
; }' x! U9 f* T2 b7 E H, y4 X int ret;
6 p2 @1 B$ U+ c4 n' @. M#if 0+ l; b6 s4 G3 X( V6 K9 F+ ]5 m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' a* t* R; c+ j% o/ { if (ret)9 e+ s# p2 k3 o/ j( H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ k+ X8 J7 t7 j& T i
"%d\n", ret);
% ]! Z0 e$ T$ l* H" h0 l1 `7 l#endif
2 T- ]/ @( u, d ret = platform_device_register(&da850_evm_tl_leds_device);
/ e& K& L4 v$ H if (ret)
3 S& S3 P+ n9 R( \; N pr_warning("Could not register som GPIO expander LEDS");, G( ?" A4 L6 ~' Q* F( n
else/ l S% u) ~) w
printk(KERN_INFO "LED register sucessful!\n");, |9 h+ Z( S" W* X
% v% B3 D" _$ @/ U9 t( ?
return ret;( X1 ?+ m. n* i. D; O, |
}
$ j' T$ N" k. A7 G" `6 u$ k7 \8 Q$ P+ Z& N
static void __exit led_platform_exit(void)( s! f4 n( K, p9 j+ ~# o/ P& [+ Z4 s
{1 M, g, N$ h5 p
platform_device_unregister(&da850_evm_tl_leds_device);
! _* A( @ N& h0 Q5 G* D
& B8 H! a" c. Y7 ~+ p3 R printk(KERN_INFO "LED unregister!\n");1 v% Y6 N3 V& H# q" N+ e4 c) H9 L; o, R( w
}0 ]7 c9 E% @6 S. P
$ V( Z. r7 f0 d) K# Y
module_init(led_platform_init);
' a$ I# h) k3 U$ m1 W( F3 q# Wmodule_exit(led_platform_exit); b- B0 w& V* C% P
# t3 u5 u9 Q4 e t q2 C: `& |
MODULE_DESCRIPTION("Led platform driver");4 t1 `. x3 W7 E2 P
MODULE_AUTHOR("Tronlong");
% L% g: S3 f# V# H) o- TMODULE_LICENSE("GPL");
) S2 U& ~( k: n5 O7 `9 F9 g
$ X5 {: Q6 u) n' n/ g; n! ]7 } |
|