|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 t, n% M8 j+ R3 w0 ^* Q#include <linux/init.h>
! j. |4 n1 i8 P( u$ q$ Z+ ~- S' a {#include <linux/module.h>
5 t& E/ l4 X* E9 V7 B+ w, n6 {& G#include <linux/kernel.h>
# H5 C+ X: z8 W( i5 L K u#include <linux/types.h>
. A/ P8 b! P8 w2 ~* T#include <linux/gpio.h>
0 Z& x& l& ^( Z3 W& o#include <linux/leds.h>7 G* _/ H+ X2 h0 t
#include <linux/platform_device.h>
: T2 [0 ^; _; I7 _, N8 g$ R9 A& \
#include <asm/mach-types.h>
! m& U- A' ]8 S+ A0 a6 x#include <asm/mach/arch.h>
& l! `: t9 T) I r# C#include <mach/da8xx.h>* s! S8 E) C$ t# n
#include <mach/mux.h>. z1 G7 i5 k$ r5 a. W
) h1 D, P. k# A- s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% j& b4 X2 l; b2 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& h& P: R% f( F n7 V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" f; g6 g8 [; N- h& `% _7 O' E3 m: T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 _( _% G2 Y- G0 m6 T- u
2 N6 a4 R8 }, b# B' J& u" x. b* d/* assign the tl som board LED-GPIOs*/: p) n- v& a' r+ H: |, r, b& ^7 r7 l
static const short da850_evm_tl_user_led_pins[] = {5 I$ r3 ^6 |5 d' b4 y
/* These pins are definition at <mach/mux.h> file */
$ C& D; k4 a5 g' D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& u( j. B) q G* H
-1
& l4 U/ Y* u/ S' h; p8 J};* _, K- C. y6 K) \5 k9 f
8 Z/ f4 p4 b* V# E2 n! q5 hstatic struct gpio_led da850_evm_tl_leds[] = {* B4 `" y9 a1 y) g3 ^6 p$ k! P
{5 N) ]# G, i& j. y% e! M4 s8 l& h
.active_low = 0,$ `' n0 [5 O+ t& w% K2 r" q* q# l
.gpio = DA850_USER_LED0,) Q! U9 n* C, H/ |# g
.name = "user_led0",
) U( h- c; G1 e .default_trigger = "default-on",
" b) U6 u' ]& P# J8 T8 @7 { },
7 H# d( D7 ^+ s; j1 M {( y5 Y* L5 S* }* C) c
.active_low = 0,
8 _. ~7 e: W8 Y8 _: z' R7 E .gpio = DA850_USER_LED1,
" w3 Y: k$ Y3 o* y0 l$ i .name = "user_led1",
! \0 N l* x' X. {' s- i; f .default_trigger = "default-on",- x9 X) m! j# {1 C( ^1 r3 @% m! D9 x
},
" s) X) z4 M( Y E% E0 O' k: { {" f9 J; b; s0 R% r2 a
.active_low = 0,
- @: d4 P7 W, ` .gpio = DA850_USER_LED2,
- w8 p1 @& N9 e, m! c* j' { .name = "user_led2"," {6 `5 u. H/ d3 W
.default_trigger = "default-on",
. I. m% r- h: [. B" T. R8 Y },
4 @3 x, I( j) p# r2 R {
" e( ]. `8 p; R) b .active_low = 0,
; ? | g# W. e; r .gpio = DA850_USER_LED3,
5 K, r0 B; U% F3 u8 @5 O l .name = "user_led3",% K- p- D* M: j: H, z
.default_trigger = "default-on",
! U; @8 s0 B3 { },- J( C! S! }5 w/ H b
};) N# N) v* @" z1 {3 y
( U8 h) ]: ~9 q" W* b1 G4 j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 Q+ L( b( ?; ]! H( _/ `3 b) J" p$ N
.leds = da850_evm_tl_leds,
) Q. _% S; H2 T8 h4 h, o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 i4 @; E& q7 K! i};* m" r5 a% S2 o
8 ~: o6 Q2 c% ^ C5 u$ d8 [" Pstatic void led_dev_release(struct device *dev)! T# ^2 k: B; Y5 y! ^
{
4 n Z# D# t6 Q1 q};" n2 l7 Q K; J+ I: N0 g
$ m& N5 ?2 X; ^1 _/ B) Nstatic struct platform_device da850_evm_tl_leds_device = {
& q+ d$ t9 ~/ j ]8 D* z+ Q" f( ` .name = "leds-gpio",; m. l" \! ~, `& V9 S
.id = 1,# d# d Q" K8 d3 N( [' W: j
.dev = {8 l2 a# Q6 n' j8 a' U! a
.platform_data = &da850_evm_tl_leds_pdata, N! A( ]9 l9 N1 `8 `4 i1 I& U% b
.release = led_dev_release,5 h( l3 B+ ?7 k
}
9 D' |, S. Z* ` H" @5 u};
; I, A1 i/ e) d, _
* p2 v; r9 o5 f' Fstatic int __init led_platform_init(void)3 @' L3 e* U# v1 }, G+ I
{
/ R& M- w, l) \" `: ?$ O6 T, C/ A int ret;
) r5 U1 [; G- ?4 x9 _#if 08 n' s3 e5 B; Y4 m" v- f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 W2 j+ u# w5 e: X [2 m
if (ret)
7 N' T4 S x8 J$ P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 I: L# Y$ N$ g) c! M. f
"%d\n", ret);
7 S9 e5 G* ~$ P#endif
1 a. w! W9 n5 M# [ ret = platform_device_register(&da850_evm_tl_leds_device);( S6 `7 Q6 M; w% V2 u
if (ret) x! j/ U6 L9 i8 m# L# C2 a
pr_warning("Could not register som GPIO expander LEDS");
4 h- z; y% H7 {- F9 f; y& M( z else: m4 S: d% l: `- w
printk(KERN_INFO "LED register sucessful!\n");9 X" m; v9 J1 B6 E Z: _
! F) P" X$ C; b$ ] return ret;; D: }9 N+ ?/ U# J5 X {
}
y& d( a1 P' ]6 W. T3 `6 @+ `! u8 O) m s9 I5 W
static void __exit led_platform_exit(void)4 {: _; U0 c5 a: p' f7 \
{) e" J6 y/ Z) X+ W A; y
platform_device_unregister(&da850_evm_tl_leds_device);9 t2 W' m _: W7 }6 b9 m
/ e# x: _0 i% C2 e1 `7 q2 D printk(KERN_INFO "LED unregister!\n");) X, u5 \) f j
}
0 |+ K5 k* x7 ~
) | E! X9 B: f% o% ~' g) k+ Q+ r3 Emodule_init(led_platform_init);9 |; V8 a$ L& U' e9 r
module_exit(led_platform_exit);2 J& o. ?( M+ Z9 _% o' @9 k
" n6 C( _7 f( @& v
MODULE_DESCRIPTION("Led platform driver");' c/ Y/ S2 R" Y% G- I+ [0 ^
MODULE_AUTHOR("Tronlong");( Y" n+ z% I( U
MODULE_LICENSE("GPL");
# |7 O- Y" `( {4 [
, g/ K9 W$ `, P: {4 D |
|