|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( F! O. \ b T. r2 n% ~$ E
#include <linux/init.h>
7 {& C: o: q, a B#include <linux/module.h>+ a' V0 N8 Y' J
#include <linux/kernel.h>
# T! n9 ^ C* }3 p, G2 W#include <linux/types.h>9 B1 e$ v; j3 u5 X" u2 A
#include <linux/gpio.h>
) k- ^" n- T) [7 M#include <linux/leds.h>
# o& N, Y9 m; C1 @#include <linux/platform_device.h>
5 t1 R* m/ g: T# Y8 E$ a
. a4 j9 B# l+ u s2 W#include <asm/mach-types.h>
0 U' p: V4 B6 @2 N1 X; b4 V#include <asm/mach/arch.h>) a! W T7 y4 U6 V% p5 F2 u! S
#include <mach/da8xx.h>9 S \7 Z& H0 V/ z! e6 E
#include <mach/mux.h># z0 u% t: ^8 d+ z8 @
) F( V) y0 \/ T9 M; `! `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* J# j7 P0 _7 U% @) N4 [! p& o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ l5 e6 h Q; h8 ?$ @7 `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 F: e. `% m) ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' l, F' A( o8 h1 u' ~9 q# M4 r: f* T) m: N
/* assign the tl som board LED-GPIOs*/5 _ s$ o4 K2 V5 g' ^1 [4 x
static const short da850_evm_tl_user_led_pins[] = {5 F3 @0 [2 c; {( C. f
/* These pins are definition at <mach/mux.h> file */
6 h3 ?: G# v2 x( }. j: ]/ e& y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- {$ \6 f0 h6 e! n5 b' M8 T6 p
-1
6 k. I4 e" ]/ d3 j};6 c ~( Q2 y; r! \8 z3 M( \
" k) f" q1 @5 `0 f* Z0 o
static struct gpio_led da850_evm_tl_leds[] = {. A9 j. ], N- a* x
{
2 `8 h: y% D. ^- U1 ^ .active_low = 0,
2 e$ A, ~9 g" X7 ~7 L .gpio = DA850_USER_LED0,
/ U# a% k( B5 c4 M .name = "user_led0",- \8 b1 Y# t. D. r
.default_trigger = "default-on",
. b, Q& M" v* [* R },$ E3 V; F U7 s' e
{
; `* C Q' U! U; y& s# Y3 ? Z .active_low = 0,
* O; ]! f$ V. w E6 v. ]; p .gpio = DA850_USER_LED1,
& I+ e; R0 w; ?4 J. Q- [ .name = "user_led1",# N* X, A- `: Z/ S, v
.default_trigger = "default-on",
7 }9 ]* i5 f& a/ j. B },& b1 v) S$ o. t3 R" |5 C& B
{. v8 X- G8 r' t: S& u9 x
.active_low = 0,
2 D* L: Q' p4 H8 G' M# p .gpio = DA850_USER_LED2,( S6 m/ @) |# U- w' L* Y5 d
.name = "user_led2",
! r. ^ K) c$ s- ~2 L6 b% d! h .default_trigger = "default-on",; D+ Y5 \6 m- n5 E3 ~. u
},
: d$ {- B4 s6 p( _ {! [* G! p( c$ a' ^
.active_low = 0,
5 R5 _4 R2 ~) G4 J; ^7 R .gpio = DA850_USER_LED3,
6 j' s, m8 ?2 n .name = "user_led3",
; ?+ I/ u2 Q: ~* O. Y .default_trigger = "default-on",2 j+ H" U" ?7 e) {- d: i* y/ Z# @
},# g7 T# o3 t% {3 |5 r
};& k% j9 q9 g8 [7 f6 h
5 f5 `/ t! N; Y7 I. t+ {6 ~ ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' X5 A; L' @* T* A
.leds = da850_evm_tl_leds, e: Y- h: Z- r- c" R, Y5 \4 g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) q e+ Q# z/ N+ c& Y0 E
};" e6 g" r5 t% U; f' `/ G# ?8 {- G
$ X \* K! |( D! t" S" Ustatic void led_dev_release(struct device *dev)+ B4 |, K7 V2 }9 h3 j) y2 D1 Z
{
% G( X! B) N% ^) f) Y};
# q2 \) N m: a* M7 J) @; Y: J. h9 l
static struct platform_device da850_evm_tl_leds_device = {
9 E5 W- O3 x( C .name = "leds-gpio",
! S7 Z" j" h3 c* F6 a .id = 1,. b) h8 |# q( f4 }( ~
.dev = {
" W5 T5 L( N& @- E$ Q! Z" ? .platform_data = &da850_evm_tl_leds_pdata,
' I3 u# |( {- Z( ^ S. T# w .release = led_dev_release,7 b( |+ Y% }$ H) V3 z( R
}( v1 x7 {$ I, D! t
};
' D: j' S3 D* T {1 @, t2 W0 U4 A" W" U& d/ V z# ?: i2 Y9 {
static int __init led_platform_init(void)& [/ p* m, h( N* w* v
{3 Z; Q, s" H8 B2 M m1 _6 K
int ret;
8 i& p: v1 O& Y E9 v4 O& [" S#if 02 r3 [3 o; ~) j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' b0 Q; o) n3 J8 ]3 _6 x if (ret)+ ?- M% P6 P& K& [7 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# Z5 i# S6 r( A" g/ R5 f" y+ M
"%d\n", ret);" d, n8 J# _/ b% U8 j& k1 v
#endif3 L! X ^4 e$ R8 L) j
ret = platform_device_register(&da850_evm_tl_leds_device);
, h; z$ B7 D; |5 z if (ret)2 u$ U/ [7 \( X) k
pr_warning("Could not register som GPIO expander LEDS");' _$ {: Z9 M. _4 {3 t* b
else
% A5 y! b3 t6 x. l printk(KERN_INFO "LED register sucessful!\n");
& M) o7 B' G2 M$ r
7 z3 p2 ^% {6 n9 f) k+ \- {: R1 L. A' Q return ret;5 m" |- w' u7 N' s/ d9 w
}) W+ j8 H( R5 \3 l
! T2 h- n; D& j
static void __exit led_platform_exit(void)
3 [, S1 ?7 D9 {* L{
6 e1 H9 d0 F( ^; u9 R& s" v platform_device_unregister(&da850_evm_tl_leds_device);: C+ K' Y; O6 z6 U. T
1 K! p" w4 b4 @9 j. u printk(KERN_INFO "LED unregister!\n");
8 U' f8 y e% ?9 h( ~$ N5 c}" f, e S; ?/ G$ B
0 o/ C, Z/ M T3 o: I' o
module_init(led_platform_init);- W" q+ i- ^* g8 \* R% q7 |. w
module_exit(led_platform_exit);
7 \! d9 z0 t0 M0 K5 m9 r% v8 {; s O0 c H$ O
MODULE_DESCRIPTION("Led platform driver");& h; b. ^$ A, ^1 I
MODULE_AUTHOR("Tronlong");6 V% {5 n% q$ _2 P/ f8 p
MODULE_LICENSE("GPL");
6 B, \- X( z* R$ g' |
# q( Z% N+ I5 E; } |
|