|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' \* ?3 r4 M8 F) x+ x3 u8 v( N, z#include <linux/init.h>7 i ?8 h" g# C, P, d
#include <linux/module.h>- w9 F* y2 I& s3 j" k
#include <linux/kernel.h>7 M. m, X. j8 C( O% F- E5 S9 u
#include <linux/types.h>/ b) [9 p ~2 I5 w
#include <linux/gpio.h>* }1 z ^* h; T h0 F5 X
#include <linux/leds.h>
/ e `% i1 S- f2 I#include <linux/platform_device.h>: c9 L/ O4 H( G. ]) u2 r% t* Z
8 e% ?) i- i/ i1 l q: K#include <asm/mach-types.h> v2 G( Q9 |( ]2 H
#include <asm/mach/arch.h>
. X. R8 z9 m( `4 d5 K# U7 i$ I# B#include <mach/da8xx.h>
' I4 P- o3 T; y: I. b( A; _' x- O) y#include <mach/mux.h>
. ]( m: V4 h' H0 s4 m5 T0 J, ?/ _2 b( @) ^5 M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 F3 f' z) ]5 f: t) ]4 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): u5 z: Y8 p( u/ u" W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 `# _ T7 n+ R2 h3 Q5 u) a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; K9 s4 }& ^9 j0 c& q( M5 e$ ?/ v; [! W5 t
/* assign the tl som board LED-GPIOs*/$ ~8 f m. A# L6 c; j1 A1 H
static const short da850_evm_tl_user_led_pins[] = {8 P7 D) H8 O5 _- N0 k- y
/* These pins are definition at <mach/mux.h> file */2 l( N* g2 R6 \" a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% u" y4 z5 q" o4 D3 Y( p* a
-1
* p/ N* J& \, K6 _; @& f};
7 T' C% S9 `: k$ O" C. e1 d- U1 ?4 d9 G
static struct gpio_led da850_evm_tl_leds[] = {
: c( x9 K# {6 K: l: i( d& E {
, o9 k/ n2 G3 Z& [$ {3 o( U .active_low = 0,
; s6 l% C) U; x% a: |7 F! [: h1 s1 { .gpio = DA850_USER_LED0,2 P# A! p6 k( O# j! D2 J
.name = "user_led0",2 n, a) W9 M1 h( S
.default_trigger = "default-on",2 ^5 \- K: S C7 C! r, h5 F
},3 u" F3 ^+ C: ?
{
3 L! ~. ~- _ g1 p3 e0 Y .active_low = 0,
o8 m* j: H6 O .gpio = DA850_USER_LED1,7 m8 e0 p" m' \8 }6 | q# j
.name = "user_led1",. a7 C7 [+ B! O. X) L0 J- l8 e# z8 m
.default_trigger = "default-on",( e& Z h u$ m- _1 m
},
3 \, i ]6 Z$ [# w& m0 K+ c {3 y" _' y+ b0 i8 ~* P: {
.active_low = 0,
. @, g9 Q5 {, f) y .gpio = DA850_USER_LED2,
- |/ m9 p5 t% K4 `4 R( x .name = "user_led2",
3 M: l5 d9 Z2 ^( r9 y' a2 r .default_trigger = "default-on",
3 p3 i( s* H% @. K },
( T9 l5 d3 G( M/ S8 [" ^ {
. l* q3 W+ R1 H+ J' x; B9 [" S .active_low = 0,
+ y& r {" k) s6 ]5 K" k8 R" k .gpio = DA850_USER_LED3,1 n7 s- ? |% z/ n3 B, z0 f4 A
.name = "user_led3",
3 u' n' e" Q+ X .default_trigger = "default-on",
" L7 x5 B* O2 q/ m },
+ C# b. B( }( {" d};
' ?5 [, J+ N) u6 d2 B$ r: |. q" [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 C+ W+ u2 |0 X9 [2 r7 n2 N5 P% J
.leds = da850_evm_tl_leds,' a6 Y! X$ f' ?3 i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 [) T! u3 [ \. k};
( ]( \6 W" U }- H1 Q5 k* X9 t( F6 ~% u! D- ]3 g. T
static void led_dev_release(struct device *dev)
4 N9 [9 U. L' A- w8 z; p+ W2 O{
0 f: Q( D7 Y7 T% U2 D; h};( E7 O; f5 W, F% S) e- O
( d% L7 N# J$ y( U. [" astatic struct platform_device da850_evm_tl_leds_device = {, A6 h* g4 j1 J$ ?
.name = "leds-gpio",
6 V: P0 q, z5 T! [8 g" T5 B .id = 1,& m6 Y# S T. |2 |, `" I
.dev = {
! ?7 a! b& V- P' J, i .platform_data = &da850_evm_tl_leds_pdata,
) V* P: n7 i8 s( n! a .release = led_dev_release,
4 M; C4 k! A; D: U' ^- ^ }* S& n; Z* L2 ?. v6 E
};
# h& k+ ^! h, |# W+ f- t! Z' ]/ w/ C# a K! I$ v4 G
static int __init led_platform_init(void)
# x. H, {$ S S. g$ K{4 \8 a' D3 v; {( `; b* y
int ret;/ E5 L& W0 Z# _' b
#if 0
" d. G `7 {2 Y6 x' W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 t: V R% v# p; S if (ret)
/ l- _' p. H# a1 [" M5 p+ b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ Z- f2 I! s5 \$ Y& a "%d\n", ret);1 N" G' r3 t* H3 v" w7 Z
#endif; s/ ]' l: C6 K# q
ret = platform_device_register(&da850_evm_tl_leds_device);
2 w+ _3 e7 z2 h c3 E if (ret)
* p4 ?4 q2 v3 ^. _/ U8 j pr_warning("Could not register som GPIO expander LEDS");
$ y7 _' D$ s0 d7 T0 z; P# s8 A. M else7 N0 d! r& c6 n
printk(KERN_INFO "LED register sucessful!\n");
8 r8 j% z3 T9 `1 Z* x8 D& C# N! F( m; b6 d
return ret;
+ U+ M, v' B# I}) I, B9 e9 l# q P# N
/ y8 Z/ @8 \' c- m- m
static void __exit led_platform_exit(void)
- M; o7 G6 Y9 C' L3 P$ }4 `( W3 Z1 S# |{4 A* s/ a( F: X: F' ]
platform_device_unregister(&da850_evm_tl_leds_device);
; ]6 T( g5 f) f1 G+ m8 J; l+ k& {" U/ W. i. J% I. A
printk(KERN_INFO "LED unregister!\n");
3 x2 U# w% a% h}
, L0 z% }) T _0 z+ v0 F1 P l/ u6 V6 {
module_init(led_platform_init);
7 W# ]7 G, \+ |, `+ emodule_exit(led_platform_exit);+ E+ T" i% I+ |# c
, O q1 t! X. {9 N
MODULE_DESCRIPTION("Led platform driver");: ?8 |* @) A0 r. U& n4 o
MODULE_AUTHOR("Tronlong");
' q2 M5 \& p" n' ~) B. `$ [/ VMODULE_LICENSE("GPL");
' b5 b5 @0 }& w1 D
' b" _( P6 j7 n, p+ Q1 j |
|