|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, E! d; y4 X6 K5 _, b6 g
#include <linux/init.h>: ~4 a* f" G0 |6 f' K
#include <linux/module.h>
: e7 W6 ~& R E) Z2 X7 `#include <linux/kernel.h>0 u( j* K" ]$ B! Z
#include <linux/types.h>
. [2 h1 ]' A0 n& [! ]! }1 b# S8 j#include <linux/gpio.h>
: H1 r: W" |% O1 _#include <linux/leds.h> Z4 D( p5 b ^: }: ~
#include <linux/platform_device.h>
: p0 A M/ _0 z' G4 p* M. F3 h
/ A8 z0 W% Q; `: D6 h#include <asm/mach-types.h>
0 F7 |3 P6 U# k6 P/ T#include <asm/mach/arch.h>3 [4 ~; u* q8 q8 S
#include <mach/da8xx.h>
( z+ K' A9 B9 m4 ^+ V#include <mach/mux.h>0 s6 k# ^. c& m N
% J9 K6 w, k0 i5 f" E) M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 K& O0 U. {6 C- F- [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 O3 f- q5 l) J5 t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: Y+ Y. m' `7 K5 z4 S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) N: R+ z1 s3 _9 d9 i0 R4 O
$ h3 L7 h+ p1 P5 f) F/* assign the tl som board LED-GPIOs*/" t" r. M2 f+ O
static const short da850_evm_tl_user_led_pins[] = {! N( D4 j6 X& w& h; P
/* These pins are definition at <mach/mux.h> file */; n. {9 F! t9 u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, E5 n# _$ T& H# Y4 S, |% M -1
. o; c. P' K# B L; W# ^0 S R4 q};
, H C( |; ] z! z3 S
* L' Q- f+ [" r# C: I/ Z$ ^$ cstatic struct gpio_led da850_evm_tl_leds[] = {
; Y; ]; z! U9 A" V {, O, T1 b6 J8 O
.active_low = 0,/ D* U5 L X g) |- o% Q! M" p: c
.gpio = DA850_USER_LED0,5 D- B: G7 {* B0 u0 x, `+ D4 L
.name = "user_led0",2 b/ C4 U' O* f8 f
.default_trigger = "default-on",1 f- M* b; y8 B8 _5 W+ Q
},+ y% X! C) X" }. N; v
{
1 e: o- ^ C! B$ [2 k7 k- g .active_low = 0,
* {9 k8 D4 d4 ?1 J% F; K. V8 @+ u3 } .gpio = DA850_USER_LED1,. e. Y. a" o; |) ]# ~ H
.name = "user_led1",4 S/ d. M& M u7 r" G; ?
.default_trigger = "default-on",- p% g2 V( |/ V4 ]7 i/ p8 E
},
2 r5 x5 _3 V5 I6 w {
" n: J* U* C8 G$ r5 L1 i- f' z1 E .active_low = 0, r( p8 {5 s8 t b# ]9 d
.gpio = DA850_USER_LED2,( ]0 q, X/ _* |& `
.name = "user_led2",
; _0 [ J0 e/ U8 Y. B9 U .default_trigger = "default-on",
* b$ v# T; E# t8 Z8 i# j },; J" Q* P( T5 c$ ]% u
{
9 w/ Y/ k' \" D3 E+ |: D% E2 o .active_low = 0,: u" q9 }" F! s }3 {' y- H
.gpio = DA850_USER_LED3,1 w. u) f8 k* N8 X/ o, y
.name = "user_led3",9 t$ U: O% k% X: R/ f. E4 K
.default_trigger = "default-on",: X: l* p$ w" k6 z# n
},
5 o- V$ g! S0 s: V5 E}; t+ F% b, t1 C' B) M, A6 ?2 K8 u, y6 _6 b
! P% _& B# R4 Y& l5 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# {/ m. E* E" z) a' e& M# y# M: `
.leds = da850_evm_tl_leds,' h/ P1 c. n1 K3 `3 f# s; M
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 W1 Y- S9 S" ?' y% \
};' R# D3 Y. K3 o1 B
/ x& Z! A) R$ l2 `! A3 W* ustatic void led_dev_release(struct device *dev)
0 I4 Y/ M6 j5 j& \+ }, f{1 h1 y1 A" Q( b. P, T" A. ]
};1 Y' ~8 v# c6 {
! n1 F$ x; P# `! P: Gstatic struct platform_device da850_evm_tl_leds_device = {5 `! W' Y8 v. Z# n. d( S& o0 z
.name = "leds-gpio",
8 T' Z {( b- Q1 X .id = 1,& p* |; \3 @( b
.dev = {
' M; C. Q! m" A, M6 k .platform_data = &da850_evm_tl_leds_pdata,: F# ]. N4 s5 k( Y) k4 e. ~" ~3 Y
.release = led_dev_release,
/ x( k4 K, ?$ Z }
6 Y8 V$ A7 \& R9 T};6 h9 H. t) b1 d
; z1 E1 z E$ \0 x, ] tstatic int __init led_platform_init(void)4 h, C' z* y3 p9 [
{
( T: Q* o- I. F( U) o# c/ Y int ret;5 p0 Y. k! m" f. ~
#if 0( l$ X" D; b5 k" `* W5 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! | I. {5 ]" {1 t if (ret)& |* T. O4 L! B- f, @# Q2 w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 a; d6 o' M4 Q% ?) `
"%d\n", ret);9 N3 b( M. G; ~3 N
#endif. Q, @2 \, V' A u0 M/ J, Y7 y( G
ret = platform_device_register(&da850_evm_tl_leds_device);& S3 S" _0 x- O7 Y/ h' {% {
if (ret)
& b7 p( R$ a* l6 G pr_warning("Could not register som GPIO expander LEDS");2 z2 f1 ]% f& m8 w5 k
else" v$ `: N& m" z, X
printk(KERN_INFO "LED register sucessful!\n");9 D4 U8 y% N. W+ H6 D; \
7 z& a4 r5 `) e/ x
return ret;
6 H( `& A O$ A% ^) l}
( F6 \9 j# ^+ G- g+ a* \& W2 b# C9 J" A2 E! w- G5 M
static void __exit led_platform_exit(void)
7 b, J- r4 I( o" X, z{
5 T6 a- a8 ?; u( V5 ~ platform_device_unregister(&da850_evm_tl_leds_device);6 d9 X0 \; M7 h; a' Z
8 A5 ?( K& {" i! p
printk(KERN_INFO "LED unregister!\n");
$ `: `( q* G9 R; D}- W% @. R+ C9 u# n
: W+ a, V: R( \# n$ ]& T% g
module_init(led_platform_init);. w& A; w9 ^1 i" s7 z( D- d5 l
module_exit(led_platform_exit);
8 {* X+ Q/ P8 U( f& B
/ _. [& N) v7 | Y, u9 {MODULE_DESCRIPTION("Led platform driver");6 b) |6 }8 x7 @& m" M
MODULE_AUTHOR("Tronlong");4 w H% C! R0 x& i( c
MODULE_LICENSE("GPL");7 @# k: W! q0 d2 j
8 V0 X4 G: h% `' p+ F$ B
|
|