|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 B* l m, |* M6 Q( V
#include <linux/init.h> ?& c# `8 O, E
#include <linux/module.h>
( ^$ K$ Q$ X& j& C#include <linux/kernel.h>
; N: l/ k, q: d2 Y' \! ~' l#include <linux/types.h>$ { {( q# c, V& |( o$ \
#include <linux/gpio.h>
! E1 \, N U# |5 |& F" j1 A- V#include <linux/leds.h>9 S, ]* f$ r T6 z1 I" T' p
#include <linux/platform_device.h>0 G5 |5 ^3 A. {7 f) S' k3 t4 Q. N
|5 W, g+ S' z. r0 D
#include <asm/mach-types.h>0 t6 e; f4 Q4 I; d+ n; X; @
#include <asm/mach/arch.h>
: s+ u: j8 [) ~; K1 r3 {#include <mach/da8xx.h>
. p# Y, Z3 ?6 ]#include <mach/mux.h>
! g) u9 i! g7 u! [. V: d8 j5 T1 z; r& o/ W% E' }8 |: g$ l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# g( g- s% s! B5 ~- s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 x$ ~* z% x1 |' [5 t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 ` ]% m4 Q1 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 h$ K0 z, @6 e5 L5 _0 T4 W
/ k/ w$ ]; u$ b& j. H/* assign the tl som board LED-GPIOs*/
1 k- i3 e+ n: N* J6 z5 C$ R' Zstatic const short da850_evm_tl_user_led_pins[] = {" E% H0 Q1 ~: \% b
/* These pins are definition at <mach/mux.h> file */
1 \" c) k3 ]9 r: R9 N2 ~1 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 U/ W6 Z8 F! x( d Z -1
# a1 J3 }5 r# ~& {" E- }};- _1 g0 x! L7 ?; D; Z+ \+ d
" q; h# |0 C6 g4 H2 ^$ mstatic struct gpio_led da850_evm_tl_leds[] = {: k m& c! `6 F6 N; q
{
1 h' F) E: `' [, y6 S .active_low = 0,
3 d$ [/ E/ o( J+ K$ S& ?! `; o .gpio = DA850_USER_LED0,
4 }- R0 b2 z! W' s .name = "user_led0",, U3 r; i& w' W \$ y3 T
.default_trigger = "default-on",2 \# o! M% V2 C7 Q& @" o
},/ o( h) Z P. y; B
{
2 t8 b% S1 r. ?3 V. u* n* T .active_low = 0,5 i3 K; j) U- y7 n" g6 Q" T3 {% p O
.gpio = DA850_USER_LED1,
! _$ F. Q4 J) U; X0 T; R2 p .name = "user_led1",$ O- M% j' G4 x
.default_trigger = "default-on",; E/ M' h% w# r2 x* J B( g
},
) B: ?8 v* `( o, |6 F {7 |' ]( {0 M" ?$ n/ I+ @- h
.active_low = 0,7 F: h, H( b3 h+ T
.gpio = DA850_USER_LED2,0 r" x" i, x( f2 d
.name = "user_led2",
! Z" W* x% c/ M, u7 y .default_trigger = "default-on",, ` r4 U; N! @; ~9 ]% a
},
4 V5 P7 D$ ?& H1 w8 K {1 d( A- j" m N# { q7 a9 {2 y" e
.active_low = 0,
( |/ Y$ f1 q' e6 `$ x .gpio = DA850_USER_LED3,
- `7 V/ J- n# O5 q6 B$ Y7 S- y .name = "user_led3",# B) o/ }1 }3 A1 I6 ?1 i
.default_trigger = "default-on",
# m, f! ]+ Q5 H$ L7 z: N },& I( z0 S' d; @; W+ i- n1 o% T
};
8 O, w# n) E+ b7 C$ }
/ d/ q9 Z, c. _2 x6 Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ S, Q# _0 N1 l1 @4 n. h! K) x4 M6 X
.leds = da850_evm_tl_leds,) a1 {5 s+ X* }9 S2 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 a4 x0 K4 X3 _};
- A, F" k+ l: g/ d3 r6 V
. g* f6 N1 y& C4 d7 }static void led_dev_release(struct device *dev)1 F# C6 c& X; H9 c5 Y @% w, b5 p
{, ~! K+ `' z3 p( |
};
! G$ m# { I" u# @* T( j" t3 E6 ?6 }7 W7 R
static struct platform_device da850_evm_tl_leds_device = {
" z; }0 I' e( `+ e" e' q .name = "leds-gpio",
) D+ A; Y2 o. ^ [1 v4 u. u$ E: N .id = 1,
. H0 U% z4 \: z# G' N# V( w .dev = {
4 Z( w' j! a7 }. X .platform_data = &da850_evm_tl_leds_pdata,5 V2 N' r5 o& y: G4 m
.release = led_dev_release,
: s7 |3 u- k5 ~ L% F: T- o1 H* ~9 x }$ t) g4 P7 _+ t J0 B
};9 j. ^8 x* H" a" I( M# m
" X# W$ L+ e: K H* J4 Cstatic int __init led_platform_init(void)2 }" z4 Q5 H* J+ I- n5 ]. p
{
5 l- S A# }' M( [ int ret;
C/ A$ a' W& K#if 0
4 A0 G+ A0 X* d, \* J! I4 ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& l' n5 U9 \; E3 f
if (ret)
/ x# t! E; E b+ f+ P5 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! k( y: `- G; Y
"%d\n", ret);
- }, ^+ ]* A& ]#endif2 `# c7 p8 |* V. E9 o/ v) K5 |
ret = platform_device_register(&da850_evm_tl_leds_device);; {4 M1 ^( n7 @6 s# B1 [' U
if (ret); _6 m6 O3 E+ ~: M
pr_warning("Could not register som GPIO expander LEDS");4 j x9 Q2 i" W3 Z1 {
else. }3 Z& O; D& F4 Z) u8 u
printk(KERN_INFO "LED register sucessful!\n");
, _; |7 }- N- U7 s
. q6 u- M E. m7 Q; F return ret;) F+ r3 g: h6 n+ R
}
3 C% l1 R+ t/ @% z* ?' ] h( g6 z0 P0 x0 j/ e6 ]5 ]- w
static void __exit led_platform_exit(void)) O0 l9 `- p& N0 {# j
{4 p7 ?0 r5 F2 Q& N; f7 V- x
platform_device_unregister(&da850_evm_tl_leds_device);- r2 X" G" E2 U+ v0 A
+ r4 i5 g/ N2 d. p; _/ y
printk(KERN_INFO "LED unregister!\n");
) ]/ L4 y& P9 C3 l1 F+ Z5 G}
+ o0 q% N5 {" v# k/ x
: S7 U9 R( |( T9 O" U# I' imodule_init(led_platform_init);$ R3 z; Q# s( i9 [2 ~0 ^$ W7 ?
module_exit(led_platform_exit);& n" n- J) t4 `/ J2 `7 _/ L
" W' X7 Y" h5 j% _3 b- pMODULE_DESCRIPTION("Led platform driver");
8 I1 T l- y! FMODULE_AUTHOR("Tronlong");
( ^; ?# Y9 p3 U- K6 t. jMODULE_LICENSE("GPL");
, q: u5 y6 r5 e
; S' ]# a) u+ Q) M+ S |
|