|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 y- V% N1 o' M9 }6 D5 b, }7 s#include <linux/init.h> l4 _ m9 I/ C3 V" \
#include <linux/module.h>
9 _+ `5 y) ?- U* C#include <linux/kernel.h>
, A0 H( V/ {- ^ A#include <linux/types.h>4 h# g3 B: u. o
#include <linux/gpio.h>
: F9 b1 ^8 E! I+ l' V#include <linux/leds.h>
- c, D2 ~ j! E7 U; D#include <linux/platform_device.h>' i. y1 C2 h5 e8 C
, X0 ]. i4 E+ c9 C( D8 ^#include <asm/mach-types.h>- J; N: a7 Y6 D7 ]
#include <asm/mach/arch.h>' n e6 X& B0 s; x
#include <mach/da8xx.h>
6 _3 k# g5 _5 L/ \#include <mach/mux.h>
; _8 m. f+ F9 l' T) Z5 W
# q) B- K% Y3 j; S; v# {- {4 s1 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* T, @3 y" V5 L7 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( D7 Q! P) s6 x( i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# g4 ]" {1 t# {$ D) X. k Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; c. |' }+ G6 S1 o4 f* O1 O7 P# S5 D8 l" |, F. }5 ^
/* assign the tl som board LED-GPIOs*/
! ]7 r0 K8 R0 b* T [0 l% b7 Zstatic const short da850_evm_tl_user_led_pins[] = {
8 {+ _8 C+ Z/ p2 G+ W% h9 E' U( N /* These pins are definition at <mach/mux.h> file */
2 V4 ^7 ^' e( t1 Z) V9 K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) f9 Q4 R) k# w. R5 @ -14 C% {7 i, t8 \- O- W, y* N. E
};& A. O. ]" \5 w0 k8 j( T
# `0 z D3 W8 G
static struct gpio_led da850_evm_tl_leds[] = {
3 \2 N: e A$ q/ e _ {* u3 H) A7 q$ g8 V L4 L4 e) j: I& k
.active_low = 0,
5 @: @, a* e& Q) Y6 k .gpio = DA850_USER_LED0, F9 \* p. L+ s4 ^9 W
.name = "user_led0",( V8 ^, h- H w' M) P9 l
.default_trigger = "default-on",
* {! p" C3 S: Y1 `( L# B5 [ ~ },; B4 ~- ^% |% N. |1 O
{
8 R) N- o7 c- \ w* [ .active_low = 0,
8 V. j: ]8 x- e: V% n .gpio = DA850_USER_LED1,/ ]9 q" s* X0 k# |: O8 F% T( c
.name = "user_led1",
6 F4 p( V+ b! T, Y .default_trigger = "default-on",
% \7 ?" y+ C% Y" f! c },8 [. |6 B1 T8 S% l5 I l m
{
" M% y/ ^- E5 k. Z9 K* \( k) Q1 a .active_low = 0,
" ]7 |. }( l% p/ ?. m- t6 A5 h .gpio = DA850_USER_LED2,
! l: {' f. v$ v0 |# M .name = "user_led2",
: ^0 B; K- k X' K8 M# u1 Y .default_trigger = "default-on",# ~; \4 C: C1 u' x! f
},
0 G I8 R6 {, X6 a) @ {
% L& h( Z7 t6 _9 P1 S" Q3 b: M& b .active_low = 0,' _7 z( ?3 e! U! d! k5 G" |
.gpio = DA850_USER_LED3,
: f+ J7 e' G. `: b( m8 x .name = "user_led3"," C- Z3 ]; h1 R) u
.default_trigger = "default-on",
( ] }; P- ~. m },
2 ^ r$ t: ]3 j+ `};# B$ I5 Y6 n8 p6 ]' J
3 k' `4 ?# F {8 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 C0 l d3 r" G7 l+ a .leds = da850_evm_tl_leds,
& d3 J/ I& A: p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. Q& s) p1 c* R& Z. w' L
};
' r* V, N2 i2 G8 O. }. [, e: N. m3 Y, \
static void led_dev_release(struct device *dev)
4 |& ^* h: m; ?1 Z! M8 E/ i, d/ \- D{. p% _+ ~0 ]1 F p
};
/ F# W5 q) v' e. \( T9 ^4 p7 ~+ @
static struct platform_device da850_evm_tl_leds_device = {. Q. f. h% G9 P c& u6 `
.name = "leds-gpio"," d: ?2 ]' j6 T" D1 Y9 \% ~
.id = 1,
5 k! i% K4 {5 ^/ j) }+ v .dev = {/ H1 u; A& W; n# ~+ w
.platform_data = &da850_evm_tl_leds_pdata,
- b% @! F- U; z1 s4 x4 k .release = led_dev_release,
+ k" w6 @. x( c0 f$ | }4 `. l. T: @3 a& ^5 d) c$ r" l, Q n
}; ?) x2 p& i( s6 ~
% L( e( D9 w/ P/ i" b
static int __init led_platform_init(void)! z6 q. T% I1 H7 `; t9 O: O
{ ~( i3 }( G$ W
int ret;
7 k9 F* o) D! B, K( d#if 0
6 c. u0 h x7 l9 A# C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ z6 w8 U* }* O }; ~
if (ret)
9 _2 J6 Z L# x5 j h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 L, g7 I r: S+ g# A "%d\n", ret);7 a' P' Q4 x u6 E* V
#endif
, }0 H5 {! y4 c' w# v3 C ret = platform_device_register(&da850_evm_tl_leds_device);; i3 O% r& I; c' X1 Y
if (ret)1 [# b" |# B! R/ T
pr_warning("Could not register som GPIO expander LEDS");9 Q; H5 V( _* N' Y3 r/ ^; b$ O: ]
else
9 F* q! S( b8 V printk(KERN_INFO "LED register sucessful!\n");" [% _4 h7 N: y4 G9 u* m
, J" R$ t2 }. D- z
return ret;
1 ]8 y" A( t% d" Z( B' C}+ M' r5 } p) B6 q1 l9 E0 \5 `
K5 o2 R) t1 q" D- h0 [. c' a
static void __exit led_platform_exit(void)
* M4 Q5 @) l5 W s& e) M{
}2 ]( Q" `! J( @* }+ m platform_device_unregister(&da850_evm_tl_leds_device);
) R' j% j8 Q* m+ _' {6 w3 j2 S2 n* D7 M
printk(KERN_INFO "LED unregister!\n");; n* `1 k1 _/ U9 \" I# q' w/ @
}
6 I P: b% ~6 w& R5 Y" a, ^4 n( o2 E
module_init(led_platform_init);; m2 i4 @7 j. r) ?7 V
module_exit(led_platform_exit);
8 x$ S; F# `' c2 v) Z
& {2 q5 r7 r- w+ {, I* {1 \MODULE_DESCRIPTION("Led platform driver");
! b+ u A/ _1 a0 t) f, U5 @MODULE_AUTHOR("Tronlong");- ]9 j: `1 b% ?; d' K
MODULE_LICENSE("GPL");
2 D: b5 j/ p3 R& g, F
. r1 B% K" I* O# y3 A |
|