|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 P: P) i1 `2 S* h8 B. ]1 D( O$ R#include <linux/init.h>) V d1 \& F$ s& T& @" T B% \( J: y
#include <linux/module.h>" H$ c3 G2 b+ [9 Q8 k: B( ^
#include <linux/kernel.h>- \5 Q# L/ }* i" b
#include <linux/types.h>! T8 j7 u7 \, K t& R1 ^+ `) S) m
#include <linux/gpio.h>/ G R" Q7 j2 H6 {' z7 r
#include <linux/leds.h>
! [ s$ z! y3 n#include <linux/platform_device.h>
' `; O3 o/ L" Q% Q4 B, R8 T# D. i; n2 c* w7 Q# H
#include <asm/mach-types.h>
C: D% q+ F, T#include <asm/mach/arch.h>8 `. `" T3 N+ ]# E$ [7 _3 K* R5 @; ]
#include <mach/da8xx.h>
2 `0 Q" e" w9 i#include <mach/mux.h>: t. d- Z; w* z& Y& N4 b, c
6 D) D/ T0 a0 y" e$ o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" G! M5 ^1 r* X& U" i2 n7 u- p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* P; e7 t8 |2 Q1 c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 T7 _! q7 h& V4 E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, e% L2 ?6 @/ G/ O0 @1 c
; E! d+ p4 Q# k) O2 Y5 {/* assign the tl som board LED-GPIOs*/7 o; c4 }( U7 y u4 l$ o
static const short da850_evm_tl_user_led_pins[] = {
0 H; y! Y9 h) F# W2 _* { /* These pins are definition at <mach/mux.h> file */
$ M# b3 P* K4 p& p' k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 S4 ?! x' L, C& [% r2 m( J `
-1: F9 ~5 `- M e$ @ H" D
};
& C; L! {+ O. u5 b6 ^+ E. T8 P6 s8 {& t' v& C6 [
static struct gpio_led da850_evm_tl_leds[] = {
6 j C7 d# T( P* I {
. l$ d: r, ?: M$ | .active_low = 0,
* {; |1 c) C! @, R$ f0 m0 i/ z& { .gpio = DA850_USER_LED0,
: J( r: H9 E& Y .name = "user_led0",
4 P8 K2 e% a' z# D4 S .default_trigger = "default-on",6 q7 I {) }7 T9 K e
},
$ v+ x5 p& n' O+ \. u {9 C! v8 S5 _ W6 z/ @
.active_low = 0,
7 h0 C- E% v8 ?) J0 f, m' u .gpio = DA850_USER_LED1,
& Y% b# @3 I1 j3 }$ A5 b7 x4 B .name = "user_led1",, @ E3 ^ l% [7 b3 j8 [, \3 d& E
.default_trigger = "default-on"," V4 T8 v' x }+ \- {
},
; l n1 ]+ C- e; h6 q U { I& Y- w0 E- e* ~
.active_low = 0,! ^0 `& {# I$ Z0 F; n/ K
.gpio = DA850_USER_LED2,0 P. ^, V. {8 _( u# v2 I
.name = "user_led2",
2 r$ i1 T& ?9 V) X .default_trigger = "default-on",
# p4 F+ ]. X- r; I& e* W8 ]% B# G },
, `0 C+ [3 E7 {8 C" I7 T8 |" a) }/ ] {0 I8 C9 r! l7 y
.active_low = 0,3 H7 T' h9 b2 j) P( [. m
.gpio = DA850_USER_LED3,( u4 @" H# x5 d; R' Q8 `1 y$ j
.name = "user_led3",
% N1 ^6 k3 D$ I i4 f" u: ?: d5 p .default_trigger = "default-on",
4 n( \( N1 g; @/ t6 n# V- c* G, a% `5 d },9 a1 b. L0 E' s: S) ^6 m y% ]
};7 {3 _1 E. j7 s2 r
, [2 B: Q, R4 `7 f; \$ e7 u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ s% A% X$ L8 n$ v2 }! h) A, S. J .leds = da850_evm_tl_leds,$ B7 o2 b' h: Y% a9 j4 O" u9 B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), i4 R6 M- y1 k* Z
};! G/ N! e" x1 ~( L
: @: M- ~: N$ O" v: D+ y _static void led_dev_release(struct device *dev)+ u. ]: Q% f% r# _) D" T
{
/ C" L3 M: v4 W9 T};
- P% K1 m" o3 G2 @: Y5 J( R4 r; l5 V, ^/ W3 s4 ~
static struct platform_device da850_evm_tl_leds_device = {
; F4 e% \2 L& `% N, b. I .name = "leds-gpio",7 l# A! s6 |- f; ^! |. s! b
.id = 1,
' d9 P! f, k$ H, J .dev = {; m S% e" ~9 I( ?% t
.platform_data = &da850_evm_tl_leds_pdata,, T. H/ A7 b: i$ p b4 p4 x. }" B
.release = led_dev_release,, d4 |/ v$ F1 f: w2 D! D
}& P7 Z$ |6 X) f; X' U# u% }
};9 y/ b0 K9 c4 _. Z. I% F
: ^; h: W! j5 u: X' s3 Ustatic int __init led_platform_init(void)
3 ~. k' A; `( y( P; r( f4 A+ e6 X4 j{4 S: B7 J; F! u, G& u' x+ {
int ret;
2 [& {0 Z3 U c G3 g#if 0
7 t% M7 d% ]9 s0 V9 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 C+ J Y# \/ c if (ret)! @& G0 E9 f" l7 q' }) U& [2 S* E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 t6 X# n5 g! Q) w" \$ {$ J: |
"%d\n", ret);
3 i& W0 R* u# i& r% C#endif. [$ Z$ C+ }+ P3 [ [) x* Q
ret = platform_device_register(&da850_evm_tl_leds_device);
% M e/ X2 E: \) D/ u1 Z4 J if (ret)
. a) q5 V; H4 s6 ? P3 `$ ~ pr_warning("Could not register som GPIO expander LEDS");
9 u* z+ G& D# O# l/ t( w else
: B/ ?- r6 v6 m8 i8 ^ printk(KERN_INFO "LED register sucessful!\n");
4 G4 O0 |. n7 w
2 U0 m# ^5 I1 }/ M% C return ret;
; d! O1 _$ {6 {) f6 F( M. P: A* I}9 v0 D- q" F# _* `4 f
& ?. A& e: j/ Kstatic void __exit led_platform_exit(void)/ z+ B( ^9 J9 l3 x
{
2 O( q8 b c( n) S3 m! O7 p% b platform_device_unregister(&da850_evm_tl_leds_device);
s. c0 `4 o2 p8 E8 q$ H, E4 S4 g2 l) \/ G" ]( F' L
printk(KERN_INFO "LED unregister!\n");
5 D" j. O# R1 a/ h" h9 g; h}
; u: v1 B# X1 [$ Q0 v4 T8 e1 a9 U9 n) R5 g$ E9 d+ b
module_init(led_platform_init);) t/ f2 j. R7 J" G( I( P8 H
module_exit(led_platform_exit);! N. o% l) m+ ], l& X: P3 s5 }
8 w% S$ @& z. v+ k# \" a
MODULE_DESCRIPTION("Led platform driver");/ N# H% M# ?% p( w+ @$ J
MODULE_AUTHOR("Tronlong");
* w7 G+ `# S0 |" {7 P* j" ^4 tMODULE_LICENSE("GPL");9 W9 g% Q/ ^! ?- V; e6 Y3 r+ D
. t) Z [' q$ O# w9 @9 g" E3 W5 U |
|