|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. b! m7 ]4 i5 w1 o2 s o' j#include <linux/init.h>' o+ M' y# |+ j" E. a9 l
#include <linux/module.h>
A2 A2 O/ ]/ L( N- `1 K% }3 S7 u#include <linux/kernel.h>
5 b) ?2 l) z% x#include <linux/types.h>
- G/ @% R: I# V# a#include <linux/gpio.h>7 p: V/ j# O" y' B2 ^* d2 A. T
#include <linux/leds.h>
) i i D3 @3 l#include <linux/platform_device.h>
3 |' ~& F3 C$ {! Y% |, e) Y% F
3 A" d3 X. h+ B% x8 }, o& a1 D1 Y#include <asm/mach-types.h>
2 A: R& `. Z8 a#include <asm/mach/arch.h>/ {4 R' L7 }7 }# m) }
#include <mach/da8xx.h>
9 B7 X8 N# n- r/ y% ~#include <mach/mux.h>
8 @ b7 G" Z2 v2 f5 ^0 I2 |
# Y' H3 X5 h1 V2 S8 p0 U+ l. |. D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! N9 N: c7 I8 I7 Y, T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 Q, r2 G9 m8 j# H( l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 B& D |$ e2 ?9 ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 M$ d( [# C. `. ~! n& G9 k: Q. @( ?8 R: d' x7 `4 n% f4 p
/* assign the tl som board LED-GPIOs*/$ i( o# P' r5 s- Y3 f0 h& b" d
static const short da850_evm_tl_user_led_pins[] = {* w" z r, Q5 R! B0 [2 u. _2 m) l+ C
/* These pins are definition at <mach/mux.h> file */8 A& S q/ b; ~ r; {# v% g9 N4 P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. t! M. y7 l, {" B- `6 g -1( O! H- c: P( b
};
; F* J4 g$ ]. ^
7 O8 f3 U8 y, Z% s8 H7 }static struct gpio_led da850_evm_tl_leds[] = {
# n/ }" b0 ^, T0 Z4 a) _ {) q1 J* V0 D( B
.active_low = 0,
! i/ O: @* m0 i .gpio = DA850_USER_LED0,$ H [* b& c. z* m1 ^( K
.name = "user_led0",
6 r1 q/ Z4 D- C2 h0 C .default_trigger = "default-on",
3 i9 d0 {0 B; H2 W4 n },
3 G- W& Z$ S8 H# n% w# Y0 I9 l {5 U- I8 n+ k* w* ?5 Y, b5 x
.active_low = 0,
; `2 {6 F- b6 J) ~$ H .gpio = DA850_USER_LED1,7 g- k( a9 E/ l. A' U3 Q1 e c
.name = "user_led1",! @; j5 K5 {7 s5 w
.default_trigger = "default-on",1 F A/ ?. r, x
},4 k! e4 z7 P" g3 V6 t+ r) U4 y+ P
{7 t& e2 X% q( O( _3 O
.active_low = 0,
5 l: v9 R+ m( U8 T: d: A* n .gpio = DA850_USER_LED2,: F" Q5 [3 O% V. D/ T8 G: M
.name = "user_led2",6 Q8 h4 M: N; Y* Q( f. C
.default_trigger = "default-on",
( a, o0 w) C8 p5 Y" }1 c },
9 h. {8 n4 g7 \9 t8 B# m* ] {
' H1 [( z5 N8 N2 O- } .active_low = 0,
! r8 e6 |- e4 Z% F# \! V* F5 E$ Q .gpio = DA850_USER_LED3,* {& B4 _; c- {' I
.name = "user_led3",
2 U7 Y+ J# G+ L, Q7 x .default_trigger = "default-on",
+ L* i z) }2 B/ a8 C },4 M m: l9 o7 y0 g( K" Z/ s" J- v
};
$ n! O7 x( _' R# V3 K; M9 U$ ]: X8 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% f t- g$ q2 B
.leds = da850_evm_tl_leds,
- V2 O, [( u/ L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 o' Y. `2 x8 r7 j
};
& k. S4 m* L) ~
3 c( S5 O! @/ T" z1 Kstatic void led_dev_release(struct device *dev)
. Y Z. T& `7 |2 L$ ~{
0 y5 x& S, q3 e/ A};
) o( c. @6 }6 Q5 r2 g9 } k2 h, j3 R; X/ Z
static struct platform_device da850_evm_tl_leds_device = {( I. ~, k& B4 ~/ p
.name = "leds-gpio",' W5 l9 F6 V8 k7 m" M D/ X4 g
.id = 1,+ W, F) ]* S2 D, \* v
.dev = {
% U) \0 H. t* Q8 Y .platform_data = &da850_evm_tl_leds_pdata,% N& E8 w, h$ n9 p: ] i5 W
.release = led_dev_release,
+ d, U8 [! J3 W4 j6 R7 {8 q% } }
R; F& I) C, | ~0 G$ z};* o( U: G$ {- \6 P6 k7 V3 d; }3 I& T
( ?" K9 Q, h* \8 l" H1 vstatic int __init led_platform_init(void)2 N; y, v, T+ {* n1 U
{
. [9 v+ A5 D5 p6 K/ N. a+ Y" e! k int ret;/ R5 Z! x$ y- a% A+ Q q
#if 0' V8 c; j+ ~3 G- A( o! U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 F! Z. [$ c/ w* t" \ if (ret)
9 g( p: n; L+ T1 D+ ~. T4 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( _; Q+ o7 B# ^: `! N# C' A' G( f" O
"%d\n", ret);2 a2 k/ n/ H7 O! H
#endif
8 x$ o. D- i, [* m5 i) y/ E/ n ret = platform_device_register(&da850_evm_tl_leds_device);
7 {8 A' ~3 z5 u0 r, T: T if (ret), d& t+ r/ {7 x2 m% f' p
pr_warning("Could not register som GPIO expander LEDS");: d- P4 `$ c. L) L5 T
else9 Z9 Q( b g" k5 `* K) P
printk(KERN_INFO "LED register sucessful!\n");
* S$ ]: Q. D0 N% u: L) }. a7 \6 T# A* c' l
return ret;
) g& o. a5 X) t# s( |}, i$ Y0 Q* U1 P d3 U
1 ?8 i& e* M( ]6 D, O3 t: o8 ~! A% K0 \4 ystatic void __exit led_platform_exit(void)' i" O( E' z% O/ U+ v+ W; A
{
7 u+ J4 d! f2 r- ? platform_device_unregister(&da850_evm_tl_leds_device);
: p; f4 ?9 N' [! \! |3 q' d0 T; ?! h( \9 W7 G8 {
printk(KERN_INFO "LED unregister!\n");9 w) E. A `8 B
}0 j6 |" B( a4 C) |2 \4 ?
* x! y) p* _9 |; o4 ^8 {
module_init(led_platform_init);4 ^ N0 G3 i0 M2 n* Z! d
module_exit(led_platform_exit);
7 Y* V: f/ N# n/ n& e
$ a( k: h5 R0 B9 ZMODULE_DESCRIPTION("Led platform driver");( i* [5 @& R4 b. I5 @, e
MODULE_AUTHOR("Tronlong");
) K& N" V0 |/ w" ]MODULE_LICENSE("GPL");
* X! k) ^+ C: |5 ?& R
' P4 g, s7 M3 p. {1 H* V! L, { |
|