|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' D9 `5 Y" n7 ~4 |& M& g# ?3 y' I#include <linux/init.h>' f0 S8 r6 U0 A, n" ?. X* X
#include <linux/module.h># X' j9 ~: |3 o9 x+ m
#include <linux/kernel.h>
# ]8 e \+ Y; y, l; B#include <linux/types.h>
5 q3 z! j5 {8 `- ]#include <linux/gpio.h>
6 @3 U6 J+ g5 M9 ?#include <linux/leds.h>) V( p0 E' G9 y" t
#include <linux/platform_device.h>
4 J4 D. `" D, p! s( [
# \- J- G( Y: j- m: O#include <asm/mach-types.h>
3 t& W+ d9 r+ V#include <asm/mach/arch.h>
`3 Z1 a8 o( j. \7 h#include <mach/da8xx.h>2 {- Y; S4 U; A7 h2 k
#include <mach/mux.h>
; e& n+ X5 x9 m) D% v8 e
7 g+ q" G- S, i( o7 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 d" K) n: ], }6 B. y/ w4 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ f, \7 ]" C" i3 |0 n t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- w6 k5 ^6 j r: W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 D Z* v( n9 K& G# [+ w
7 r! Q& p: C) |; _4 g5 m4 G! @# Q/* assign the tl som board LED-GPIOs*/
. t# v7 ~; n) y* Pstatic const short da850_evm_tl_user_led_pins[] = {# [, D; u, Z+ P1 v7 z3 y: p
/* These pins are definition at <mach/mux.h> file */
7 T6 c2 X. C9 J0 ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. M+ E: `! i/ s# G D) l n& Q -17 Q: H8 \ f& V5 |' r; X& `
};
; \+ O* W& J% p; ^8 G% K2 W4 e2 i; S4 B" {
static struct gpio_led da850_evm_tl_leds[] = {
/ Y: G; ~2 i/ r& m {
, x0 _& _3 Y( J& B) \ .active_low = 0,
! n& t! B s- G+ @4 h8 ?: I' w5 z .gpio = DA850_USER_LED0,
- B. A$ t. Y5 t/ }$ e .name = "user_led0",
6 {0 {: H# d4 K$ u! b .default_trigger = "default-on",$ l/ \5 E7 ?1 B/ s/ ]; i
},- A9 U+ t" ?# S1 Z
{
; k) P( U- ^5 t' r# ]7 ~ .active_low = 0, K* l* K$ ], n
.gpio = DA850_USER_LED1," l9 S" t0 f C6 ^6 S
.name = "user_led1",
0 m, l* P. j( `1 h .default_trigger = "default-on",
4 E- l7 i6 v' b) r3 j5 L a( m. M! {' J },: M0 { q: D0 x. B8 }3 o
{# `9 M. \. J! l( M3 j1 y7 V* ~4 s
.active_low = 0,
. l+ ]* W% h1 |/ ~ .gpio = DA850_USER_LED2,0 v7 _/ g9 v1 f: H
.name = "user_led2"," e3 }* O+ C4 y8 ^
.default_trigger = "default-on",
H7 K) j# ^" H },
; W* H3 }* B! @$ ^6 h+ K( L {+ x5 R: M7 u' Q0 B. s
.active_low = 0," T& f! g, N' Q H) a, k6 n
.gpio = DA850_USER_LED3,9 w0 Y7 ]/ R1 J, }- a3 |
.name = "user_led3",
: ]$ ?* v: I- C .default_trigger = "default-on", w' o# C' q3 i' k4 O
},, S: ^) z: H f0 i4 j/ Y; o
};+ [, G" W z+ _9 p
; u0 l& C5 b9 a4 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( q! ~; C7 N: [0 \0 N0 K( e+ v .leds = da850_evm_tl_leds,# r+ q W" l3 Z& w- L9 m, I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) z& r5 \" n# a/ h
};
3 b" V7 R# O5 ^' m6 C0 y' D% j% |* J
static void led_dev_release(struct device *dev)3 ?& ?( f# f7 ^) [& k: i- ?
{) b7 B- L& L- t5 T! N# m. A% T
};2 U4 k9 \$ d6 g( j% e
2 f$ j) u( C- B o4 Q8 Fstatic struct platform_device da850_evm_tl_leds_device = {+ U6 E0 t/ v5 D8 @ W
.name = "leds-gpio",! _# |* D+ {. |: T1 s
.id = 1,
% t& e% d4 w' A/ l# ^ .dev = {
& w+ R8 J2 R# c$ B6 m* V .platform_data = &da850_evm_tl_leds_pdata,
9 t' D7 \# a w! [: |# J( P .release = led_dev_release,- J3 A: H! u* ^, P
}
, W7 D& i7 j4 |# c2 r. V5 m+ ~};
0 L" A5 `7 S: R6 ^1 a ]
8 `3 y9 P& g3 a; @static int __init led_platform_init(void)
9 h/ b, k3 o; R6 d5 W5 `{+ m: T/ u* T$ J+ f) z
int ret;0 F" e7 y- h; `6 x$ |) W
#if 0
, [0 K7 Q- S, u% [6 C1 e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* t, d l6 } ^ K* X
if (ret)
; p {- U9 A. V) U0 |* f& I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ b8 g4 w+ a4 R3 C8 ~ "%d\n", ret);
9 Y! `; S1 j- f! E- u4 G. `#endif
3 @& S& `) k5 U- U7 A7 q ret = platform_device_register(&da850_evm_tl_leds_device);
+ O+ s7 E/ m/ I# n- U. O0 J) Q if (ret)
( H- G: h1 F1 N pr_warning("Could not register som GPIO expander LEDS");% R! F8 Y: r/ S! ^. W
else+ V; m* A5 e/ @) v. P" g
printk(KERN_INFO "LED register sucessful!\n");3 Q4 I: ^6 z0 G' ?8 V( V" q$ u
" _0 } d4 q3 U+ N; l+ r3 X' |
return ret;% W, M- L( O; Z: h1 z
}
' \4 _7 `/ Z, a1 h; Z u1 a. c$ I4 a. v
$ G6 I D" c3 [$ P( N5 T8 X9 M4 Bstatic void __exit led_platform_exit(void)
# t2 U3 M% L8 u$ m4 t. t0 N{# M W7 q! Z% V3 T1 G5 c7 k
platform_device_unregister(&da850_evm_tl_leds_device);; R& ?( T' i2 N9 j
$ r' _ i) P9 t- g2 w, C( P \ e printk(KERN_INFO "LED unregister!\n");: y+ ~; i5 m1 B ?) ?) F& A. ~2 T) t
}. }1 _2 s: v8 B) i6 G1 ]
: }1 |7 l, u, b% U: R( x* t
module_init(led_platform_init);
* P6 `. D( I% w- umodule_exit(led_platform_exit);
: Z+ z. y6 p8 u
5 u8 w$ d! h/ z4 b2 K8 CMODULE_DESCRIPTION("Led platform driver");
0 X W* l* [: I: S$ F% ~) jMODULE_AUTHOR("Tronlong");2 W/ _/ V7 k% u
MODULE_LICENSE("GPL");( X# F! y/ G6 j, g0 P- J" U. e
' _+ h1 @/ G0 x9 u2 ?4 ~ |
|