|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: o8 Y% B9 R6 t+ e( ^+ D
#include <linux/init.h>" g# l1 C/ P, r) m ?5 {
#include <linux/module.h>- B% e# R( ?3 C$ p& N
#include <linux/kernel.h>
; |) h1 `6 \ T3 _0 `/ M+ c) U. O#include <linux/types.h>
3 Z" h8 D/ [1 Z' F$ f: j& o#include <linux/gpio.h>
( E) |' w. R' S: f& `2 r3 z, s#include <linux/leds.h>
1 C3 w7 o% ^# l; m) K6 h# C#include <linux/platform_device.h>
1 ~/ U4 E4 c! g! _
$ x' q' v3 L. P( W#include <asm/mach-types.h>8 p q# V/ {/ S0 t/ P8 A
#include <asm/mach/arch.h>
8 l- o/ A) X. ~+ z o#include <mach/da8xx.h>) c; z9 l/ T1 R1 h
#include <mach/mux.h>& |, `3 Q6 A! |7 v0 N
' M6 O- S4 y6 h2 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" N* [+ L$ M! S& Y# p# V1 `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" b/ y. w' G" @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 r/ L; Z5 `4 f: X* G$ C" x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); ]! f- P7 U- T! @& h3 P y) M( |
* m$ e$ v& U$ l0 O4 w; k w2 D
/* assign the tl som board LED-GPIOs*/
3 c6 }: c" |' h7 |+ k* v1 _* zstatic const short da850_evm_tl_user_led_pins[] = {
5 R: G+ X y7 j /* These pins are definition at <mach/mux.h> file */9 n: [& d0 r; G& C: B$ N2 x5 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: o. u0 i2 {/ Y0 H+ ~ -1
: r$ @: n' D& r5 h8 f1 u9 J};! n3 r) O( p1 X! e) i3 E. k
9 o/ ^' ^* _9 C) Rstatic struct gpio_led da850_evm_tl_leds[] = {
" z9 T% D8 f# |( W7 z5 } {0 H( y9 }. b. P; }
.active_low = 0,
z7 G% ~2 M, W. o! G1 V .gpio = DA850_USER_LED0,
* Y7 Y# h7 _2 Q; l .name = "user_led0",
% W/ b- |7 X, B .default_trigger = "default-on",
: r; f$ ]4 I& ^; I9 m },! v8 a, }8 A8 [, }5 T
{" p5 N I4 B) r
.active_low = 0,- A0 Y' H0 k+ {! U0 }
.gpio = DA850_USER_LED1,
- b$ b7 F# L, ~7 w& i/ s2 v. n" m0 Y .name = "user_led1",% n. W( a" j) I* ~. K
.default_trigger = "default-on",: d2 L- R# ^' T( S, W3 b, j* `
},
# V" p" ~6 Z( b3 H. I, e; b' V7 p1 E {9 `$ G0 K3 h! b! f8 k
.active_low = 0,3 I: @- v' Q9 z, I, S$ J
.gpio = DA850_USER_LED2,
: v: G- z9 W* a .name = "user_led2",5 q# z& d' ]# I* \8 j
.default_trigger = "default-on",! X+ C4 F5 f0 W
},% b" |' ~% Q9 n5 m2 I
{
* T- _6 a& y; M1 q& a9 [2 J6 i/ ? .active_low = 0,$ ~' T5 \( p3 P
.gpio = DA850_USER_LED3,1 ^ P) K4 \4 D
.name = "user_led3",$ A0 e( I+ l& G5 J7 o
.default_trigger = "default-on",' y% u5 E Z, i8 {; }
}, y% w4 n9 `4 P5 v% l7 N2 N
};
% C6 W- K4 y. x9 L# U! ^+ |6 J Z h" o* Y J5 N2 I E7 K# h h. d' h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 J; j2 g2 \6 a" t
.leds = da850_evm_tl_leds,
7 H$ j) Z: s$ ?9 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! f5 x% K" K, _' v6 n};
6 q1 t, r& ]0 u: j/ `% \; ~( @4 m8 l" t$ p" p( _
static void led_dev_release(struct device *dev)
& B% |0 q& `& s/ H' h: J{9 E2 H* J5 U F: D; W( g
};# I: I" s+ D3 w6 L# t/ p4 P
2 s0 U8 h+ [3 N: D9 q# kstatic struct platform_device da850_evm_tl_leds_device = {
* N9 ]; A+ }0 x$ j .name = "leds-gpio",
) G0 U0 J7 s: a$ Z .id = 1,
6 w+ ?' o' F& U. P; ~ .dev = {8 @: H" h8 f6 Z0 J
.platform_data = &da850_evm_tl_leds_pdata,- u$ D$ m( P' q, S0 k" a% w3 w
.release = led_dev_release,
7 G! G* m* }7 m) H4 i/ o$ J. ?( d }
" z; r- [$ N8 }! _9 K* U1 r7 K};+ N6 [: b! } W
; s& a1 }. h4 Q& L0 O: mstatic int __init led_platform_init(void)
) e0 {6 Z' h( C# [+ o, g. c{ j8 U/ J3 h8 ~7 G! ?) q7 F
int ret;
f$ V& @& A9 `/ V#if 02 a3 W4 S4 n+ f- l# D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 ^( v; D# y3 z7 p7 i! R2 s
if (ret)
3 s" V4 v. h1 i3 @2 ~9 Z p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* J% Z% C% |6 k) } "%d\n", ret);
+ _7 p9 G' a- a' U#endif7 M6 W. l, T; c' Q0 L3 j) I3 V& c
ret = platform_device_register(&da850_evm_tl_leds_device);. L* R, e: ~& l' o7 E7 o
if (ret)
" m P8 U: f9 I5 S pr_warning("Could not register som GPIO expander LEDS");
, A3 H3 @" y2 s# ] else
( y) ~- f& a. Q! p; H7 d* W$ ? printk(KERN_INFO "LED register sucessful!\n");
, j$ P: _$ E+ Q) D3 B$ y, i: N
0 v" M W/ S L9 p! g' _' u8 P return ret;
$ D ^8 R( G! N/ Y- d7 x4 t}
. y% q. G/ {9 p
" B" h! D, ^1 p. @static void __exit led_platform_exit(void)4 l# K% z( U( C( v9 ^/ k: n/ H
{2 t2 y0 _2 i& |, E7 {, G
platform_device_unregister(&da850_evm_tl_leds_device);3 e; h6 `8 w5 n ?, O: k
S% T P7 b) w* U0 S
printk(KERN_INFO "LED unregister!\n");0 Y4 C% w' g7 `1 E/ p& M& \' S+ V
}$ [! ~0 V1 s+ T/ i6 D# D- L
1 b5 i! N# t9 r5 e' `& Imodule_init(led_platform_init);; Z( `% j8 `' t: s0 g, I# W+ }
module_exit(led_platform_exit);! B; J0 T5 z9 N( y: L9 a9 M
2 @, e1 G/ }; i' ]8 @ ~; s
MODULE_DESCRIPTION("Led platform driver");
# p. M4 U6 N: D8 bMODULE_AUTHOR("Tronlong");( B9 t$ T5 T9 p/ G
MODULE_LICENSE("GPL");
# D, j B1 ]; Z8 M+ R7 K( ^ s
. l6 k% M! D2 ^1 ]1 \ |
|