|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 z7 H$ i. |( `& Y# F" }7 f+ r#include <linux/init.h>
# r# }' {* Q: r% B o% Y7 p( S$ v#include <linux/module.h>& v: a3 k g" F
#include <linux/kernel.h>
1 s0 O; I5 b: e1 O$ n7 Y$ _" @#include <linux/types.h>/ r0 B& [& r7 {( i: s8 }9 \, i* P
#include <linux/gpio.h>
7 o8 M, i* x. M- ?' @#include <linux/leds.h>4 q5 h, Q2 j# F1 P8 u* N+ e7 r
#include <linux/platform_device.h>$ }" ]( x8 o' f1 l) o) N$ ]: P* M
6 b$ i1 T; {1 O! I z7 i
#include <asm/mach-types.h>0 @9 q/ @, w6 e8 w
#include <asm/mach/arch.h>; W% {( c/ `7 l, i
#include <mach/da8xx.h>
; g0 z9 j( D. O ?: R( N( _#include <mach/mux.h>" K( V2 {' m& \$ `* _% [
& e$ b7 _1 @0 j# q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 P& [# M+ \. C3 P8 S- a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 A9 Y7 _* [$ h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ @+ f1 a3 o; }2 v0 Y. y+ j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), j2 P, `' X5 F8 N& z
; ]/ X: X- x; B( U" h0 J, K+ M/* assign the tl som board LED-GPIOs*/
: U6 ?+ t8 @! Pstatic const short da850_evm_tl_user_led_pins[] = {& d$ K% ]+ T& f9 n% m& n. H6 j0 o) q
/* These pins are definition at <mach/mux.h> file */3 Z. y0 v2 t9 u' z5 ^( P8 L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: `% ?1 q4 p2 @: V v# a# v; x -1
& M6 O7 Z7 e |& R3 H3 X) p};
7 ?# o) M$ V5 G6 U8 L0 I' I2 c# D2 F- f9 w4 U) k
static struct gpio_led da850_evm_tl_leds[] = {7 |. {- u* m* A+ u
{
( g* a6 o4 O; {8 a( a* C$ K .active_low = 0,
3 E% N5 D) ]/ K6 F2 x- o3 r2 \ .gpio = DA850_USER_LED0,
7 O% W4 |) C) T .name = "user_led0",
* D$ e% r2 P' s% n+ \6 D8 d .default_trigger = "default-on",
% m! A+ ^- b0 i7 G7 `& k8 l },
: W! }) a, s5 a/ `$ a& x/ r {2 x d4 q1 K' Y# b* Q
.active_low = 0,
& B$ v, H' O) f8 g$ c- Z .gpio = DA850_USER_LED1,: \( p( h) e& G6 t7 W
.name = "user_led1",* a9 C4 s8 A' ~$ r
.default_trigger = "default-on",
$ P. E/ `& l. e* k9 Q x },$ l5 ^( w1 z$ p* E V0 T: d
{6 R1 x' {; @8 s" s" }# ]0 `
.active_low = 0,
: i" R# U& q: W! ]3 Q .gpio = DA850_USER_LED2,& x+ D( @4 X) N* m7 B
.name = "user_led2",
* M! i2 s5 r$ M- [" o( C6 s .default_trigger = "default-on",
3 |8 D2 \. \' M! [. S! y: f },( i) i# D( S, p H, I: |- u
{
' y- F# t2 E8 Z# _ .active_low = 0,+ r9 W2 {$ ]2 C; E
.gpio = DA850_USER_LED3, H% G5 ~' A$ d+ |1 Q8 k7 `
.name = "user_led3",
# p5 M0 x" l; A1 `8 m .default_trigger = "default-on",6 f& G: g2 N, a9 x5 x
},: }- [% Y: l8 _4 ^& [( g
};
5 G1 M8 j0 C% a; K/ E9 z/ H: d9 p: z4 k+ H3 q$ K: H/ A, L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' M, x: _( ]7 Z( k7 O9 U: U
.leds = da850_evm_tl_leds,' J% h6 H1 `% ]* k) Y5 M0 o4 d9 l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 Z& m) u% H4 a/ t}; ~' Q9 k, S2 F$ W) g9 e- m* {
5 s+ ?3 a3 n8 T" I( P+ e8 w
static void led_dev_release(struct device *dev): `0 T9 J) `/ b2 h9 v" p
{
6 O |' J8 \0 _. ^9 u6 R};
5 x. M; `9 x# O, ~6 m
# ]' Y5 p0 K$ N5 u" x- Z3 gstatic struct platform_device da850_evm_tl_leds_device = {
$ Q! `+ Z0 f1 W* b0 u1 E; S+ z. Z .name = "leds-gpio",
" l: c% l+ i5 E2 ^6 j .id = 1,
1 x5 s; ^# t4 J+ [1 q% K .dev = {
! p3 {1 z% [4 ?1 b+ h8 Q .platform_data = &da850_evm_tl_leds_pdata,
; U) G0 I$ g. ?' t+ e1 l+ P5 c; C$ x .release = led_dev_release,
$ R" a' K u3 @* ^7 \/ y }
- ~4 `0 s& X% {9 r! U9 n};
2 t# e$ W7 J" K0 S1 }0 Y+ n' ?- d- A2 Y7 O2 W0 U
static int __init led_platform_init(void)
3 j( Z' ]1 b/ Z) N, z{- X2 A9 a% `' k8 f, Q/ P6 k# Q
int ret;2 w0 o& N: v+ d) o2 R
#if 0; Z/ y# B2 g/ ~6 L5 d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
j. i$ C/ b; U if (ret)# ]9 \$ x5 E/ l& _, Q' i8 S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 d" R7 L, B; V8 Y5 [
"%d\n", ret);% `: c. T+ g( L
#endif
1 |# I0 j. f% ^1 g ret = platform_device_register(&da850_evm_tl_leds_device);- J( @/ i1 x: r. N' l+ e! S
if (ret)* {. Y' g2 ^' _# b5 u; ^5 |
pr_warning("Could not register som GPIO expander LEDS");- q; H" A: u/ i7 b0 G. [# ]& N5 X: p
else
/ d( O/ M" \! B9 C- r printk(KERN_INFO "LED register sucessful!\n");& p" |( v0 _( D& B' `
0 i$ K+ u! j; u* s. P1 R5 I return ret;7 R2 r) k. U7 F! ^5 t7 A* y' P
}' z( F+ s, I3 D) d1 { j
6 X9 K5 U8 L5 J
static void __exit led_platform_exit(void)
& u# V3 H* `- h5 I- E5 m{- a& _+ j) V; K6 ?3 c" @
platform_device_unregister(&da850_evm_tl_leds_device);
8 G/ e2 I V t3 b" b' c5 ]: Z6 c, I1 y
printk(KERN_INFO "LED unregister!\n");1 B; q' E, e$ |3 Y. V% V
}9 T4 \* Z' n& f/ d4 c+ \. @
! C8 _. a+ i; w( v" j
module_init(led_platform_init);
% k+ v. z+ R: i( V* B& ^: b2 \module_exit(led_platform_exit);
# S" r: Q% w( C$ K: C) W
( W1 Q* w- r( f/ g8 y* eMODULE_DESCRIPTION("Led platform driver");+ c! w# W( X! ?- A! A* c
MODULE_AUTHOR("Tronlong");
- u/ D6 g) r' M, h# IMODULE_LICENSE("GPL");
( _- y; Q8 o7 X' p/ G* c
`8 j+ `) x4 T) m |
|