|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 M) E9 G' D7 A0 Z#include <linux/init.h>
" i8 S1 C6 J/ Z2 V" j J#include <linux/module.h>
! [) A# f, H2 n* A3 @: F#include <linux/kernel.h>% _8 Y2 R/ T+ @* t
#include <linux/types.h>
4 K. P1 P7 S4 J6 K' [0 E% r; Z#include <linux/gpio.h>
, Z6 h! ^) m! p; [#include <linux/leds.h>9 q. ^8 D1 }5 x% Y% W/ r
#include <linux/platform_device.h>
. K X4 L( O" G/ k t
; m: G7 {+ v _3 C" R& i#include <asm/mach-types.h>
: i5 ~+ g4 ^ {& l! [' H#include <asm/mach/arch.h>
# M* A) I0 e% j4 R! G#include <mach/da8xx.h>2 O6 h( U5 v3 O, [. @" d
#include <mach/mux.h>! j% J# r( i" ]1 {9 n( i
' f4 O6 c* m4 O7 ^# T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* A: S0 m: s& |% g/ Q$ o1 O( `2 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 t. j! n. @/ X4 s# @1 v* d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 L! w3 G1 s1 n3 K* J; T2 c) E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! W, |/ u, {+ f% Y) M- T, s/ B
9 S3 O: |" V. X T2 f% x* H/* assign the tl som board LED-GPIOs*/
( S& y+ e0 v, b0 R1 j/ j4 Pstatic const short da850_evm_tl_user_led_pins[] = {# H u+ ^1 M r! V# f9 l
/* These pins are definition at <mach/mux.h> file */9 ^$ j3 [% G' b1 G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ b9 l+ |+ W! h; ~: i4 {
-1
( _ o. ~/ t) B/ [};' @0 _* w0 S- ?: l
9 w( N* r/ i; X8 f; Z( Y5 L
static struct gpio_led da850_evm_tl_leds[] = {, h4 p' X# z6 B1 y" \
{. P7 J" S; o5 d% S. I4 v6 D
.active_low = 0,
+ V, ~9 w3 P7 d$ j( U5 \ .gpio = DA850_USER_LED0,
3 W% l G- o* i9 Z' w .name = "user_led0",
1 u& Y) y; V& @ .default_trigger = "default-on",9 M! `9 {. E2 V m/ B& v/ o: m
},, }4 C2 q5 Q$ K* a! u0 y/ `
{
9 l1 g8 J3 r# k$ V, @ .active_low = 0,
: z) h3 M7 N# g% [$ M- d& P .gpio = DA850_USER_LED1,
& I, `: K, ? q; `2 j% ^5 u .name = "user_led1",9 _% N5 g$ y& l; q8 _
.default_trigger = "default-on",$ d5 J9 V' _: B5 b4 A- x$ t
},+ P9 U# U: U6 r# A& f! g0 n. w
{
/ z$ V8 _! ]4 y7 x .active_low = 0,
8 D7 L$ D$ X, R' J- J+ ?" Y0 ~- W; N .gpio = DA850_USER_LED2,
4 L' s1 G+ J! z1 y .name = "user_led2",
" y/ x8 x x; _: d( X: p o .default_trigger = "default-on",: P% C: Q+ |# b5 s5 g
},4 N2 T: a* w# i
{/ e* H: X: D: {6 |
.active_low = 0,. w1 \& J x) w" x2 x
.gpio = DA850_USER_LED3,* \* a' u& G0 V8 x6 t$ l
.name = "user_led3",
( W) {$ O, W9 W# K- E/ ~" C .default_trigger = "default-on",
( y$ w* t& @" W$ q' A },& c3 D6 n# _: c* }
};
# I9 K5 J, O' S4 `. z3 n
: G( J# D: ~- ~% astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% D6 N! w H& ~% z; a3 r8 k
.leds = da850_evm_tl_leds,3 e" s# v8 I! e. L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) @" |* Y1 I# F};
5 k( z7 A2 r0 k' f0 R
8 I% B: @, t9 N- m. n3 |static void led_dev_release(struct device *dev)
! ]: Y4 l) V6 r{
0 H: M! j& |* d) S# p5 P9 f};
0 r* S4 g0 B7 {3 [! ]
1 A" U. F2 G1 J5 w, Cstatic struct platform_device da850_evm_tl_leds_device = {. Q2 ?+ x; x. U% f* C* H; l5 n
.name = "leds-gpio", d4 }% R% N) y) s+ q3 q1 y
.id = 1,
7 C7 N4 n" W' [0 [/ B .dev = {
! Z; m6 V. c p4 y- o8 h .platform_data = &da850_evm_tl_leds_pdata,
! U: X6 L6 L6 A. M! o& ?- ?/ \) ` .release = led_dev_release,
9 e7 O' L7 i) i5 R/ `# V1 C/ G5 Z }9 |5 G5 L' I" R% y7 ]2 u% J' W
};: S! i% t) \" [+ n6 Z# \. v
4 x- n) m/ r3 f0 l- I8 ]" e) i# h1 D
static int __init led_platform_init(void)
/ b3 a, G; P9 x$ t4 W{; j$ f" G6 v* y0 ?
int ret;* g; w& }( k/ ~5 V8 c
#if 0
2 ^' `' E& Z _/ B+ p8 E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 P% H7 v' H% E, T- _ if (ret)
6 q7 V& H6 |0 V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 x4 ^, d* `% G; D0 S( R# Z4 H
"%d\n", ret);
0 h( D0 Z0 L' C4 J" D' ]#endif5 z9 s$ r% T+ ?
ret = platform_device_register(&da850_evm_tl_leds_device);
d6 Q3 K( A% c' s# F" m if (ret)
+ ^# D- t L6 n& G; @$ r pr_warning("Could not register som GPIO expander LEDS");2 T+ J1 G2 Q" t- r9 m
else
6 T% P% _/ d9 K' e+ X printk(KERN_INFO "LED register sucessful!\n");
2 b3 T9 \! G9 ^# X. H2 j ?' m' y
return ret;
( f- u7 i; F+ ?1 `) n* {}
8 U% ?$ n6 _ \
( ~% G7 Q2 B. c* a5 @/ c zstatic void __exit led_platform_exit(void)- A5 `6 q! U! _. `/ p( W5 S
{, H4 V; p7 r0 \1 e
platform_device_unregister(&da850_evm_tl_leds_device);# |' q J9 h- J
! E( L$ e* E9 p: i& I: m printk(KERN_INFO "LED unregister!\n");
8 V% ^- q9 F! c}
7 }8 ?/ c( s K0 P: e9 n A. Q$ L/ y# s1 V
module_init(led_platform_init);) |3 r+ w( o4 _! p. P0 b/ S
module_exit(led_platform_exit);7 r! u' d: h+ o. R7 |* _; o
* c3 Q2 \& ^6 z) Q T
MODULE_DESCRIPTION("Led platform driver");/ A3 l0 i2 D7 b
MODULE_AUTHOR("Tronlong");8 b K. S2 ^- v2 R) F# f! A
MODULE_LICENSE("GPL"); e( ~ `/ ]* M) R C) N5 D
( d/ w/ s6 k6 s, ~# z |
|