|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ k' g# Q* q" Y#include <linux/init.h>/ Q3 @4 m1 B2 g' A+ b3 C
#include <linux/module.h>
5 [, }, p- Z3 y6 F# S& N#include <linux/kernel.h> d/ \6 O+ V* u/ ]0 X4 u
#include <linux/types.h>: R& N' j5 M# Z0 v+ h4 R& Q3 l
#include <linux/gpio.h>
4 g8 ]3 U5 a/ c% ?; Y' H#include <linux/leds.h>9 c( ]& g! P; I5 X2 m7 E% Q% S
#include <linux/platform_device.h>' l5 C/ g( P T) P
3 h2 D! i e( N( |6 ]2 z9 ~#include <asm/mach-types.h>2 y5 N) k! r- n' |& h9 i: l
#include <asm/mach/arch.h>
, y# ^2 {9 I i R# I+ Y#include <mach/da8xx.h>
( c( ]8 ~# o2 k! `- Y#include <mach/mux.h> Q, g+ T7 v1 S) H9 n
# w3 T& X1 l3 C2 s9 p8 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 f& r, f3 m" Z/ l1 j9 u8 }" o, u# x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), k( e/ j1 X7 U5 f6 C* D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' Q: C" M) I8 Q* V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ E2 v' h" m5 t+ k1 Y7 w5 a% s) a; {- r G
/* assign the tl som board LED-GPIOs*/
; j. }2 E# Y- `4 h9 o Q# i1 }5 ~static const short da850_evm_tl_user_led_pins[] = {
3 @3 x) }6 y7 K; Q$ ` /* These pins are definition at <mach/mux.h> file */* b/ ?; S% J+ h4 Z: c/ F% p8 D" R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 V. z$ ?5 ?0 f9 k9 r0 V! Z
-1
, ]! {1 C8 [: w( b( u};
; C& [7 A2 A+ k$ `( m
1 p s1 `3 \1 q5 W4 S7 vstatic struct gpio_led da850_evm_tl_leds[] = {
1 o+ L) c. w" O) u! V/ h {9 B L- M) X+ N5 T" e# z% U
.active_low = 0,
; B9 P( |" W) Y .gpio = DA850_USER_LED0,
- V# h7 n- s x l* }3 L .name = "user_led0",' H5 k2 d8 n: o1 z( m4 Q B
.default_trigger = "default-on",
0 s- k% M9 P8 X2 D! e },
1 }) v: ]0 k. _# E9 `7 i {3 N$ F5 A) T" a( y" s
.active_low = 0,$ H' S" F& A1 X3 }& R1 J
.gpio = DA850_USER_LED1,2 x j8 U4 @' c F% S
.name = "user_led1",4 f+ A; m8 X- s7 k% k
.default_trigger = "default-on",- ^, [" s2 b6 a8 W0 U2 Q
},/ d l0 t1 D, f+ g( y4 J
{
5 Q0 c& J" J+ B+ F .active_low = 0,
& k4 y0 K" K& ~0 H7 o u .gpio = DA850_USER_LED2,
+ ~7 R2 k P/ `- S% |4 [ .name = "user_led2",
9 q# F& b( U$ t: E4 H+ s8 j .default_trigger = "default-on",& @0 q+ `1 L) ]/ I& C, L) M$ j% O" Z
},
( i1 R0 h: ~: ?! L {
* n4 h" U- o6 i7 y* Q, k! G( g .active_low = 0, {0 J! J2 S/ g+ Y5 A
.gpio = DA850_USER_LED3,
2 m8 t7 _: _; b5 C9 L .name = "user_led3",
\# S/ N+ W" a( Q) e: G .default_trigger = "default-on",
7 b5 Y4 D7 m* u; [: L1 {) e },* y7 f, d$ ?4 R, O
};
! l3 ^+ { @; B2 T+ |4 Q/ l
2 T+ j4 r( b3 U/ e# F/ Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ y3 A2 h- `+ Y1 |$ [' H
.leds = da850_evm_tl_leds,; v1 X0 U1 U, F& ~4 s' G( m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. P5 J. x- ~" b: [& N7 m
};
. q$ z: l0 `! g( p1 M- g4 ^1 c% ?) e. e5 v8 x4 ]9 r
static void led_dev_release(struct device *dev)) s5 O1 }! Q7 N7 s( l( [
{
. c' |5 N. c$ @4 R: ~};& m' U8 v+ R2 I8 ?& ^6 x' e, A
2 A% A9 c8 C% ?) a, Kstatic struct platform_device da850_evm_tl_leds_device = {
) C2 H. F# B. b# @ .name = "leds-gpio", n$ M( b+ j% D) A1 f
.id = 1,
- e5 p# c" [4 k- ]5 \ .dev = {9 @* X$ `1 O6 D8 y% H/ X; m' C" Q
.platform_data = &da850_evm_tl_leds_pdata,
! q2 y" Z9 r3 f/ |* W- t .release = led_dev_release,; r' k) Y2 H! l1 L, m' F( y1 I% @! L6 o
}: u0 O6 V. k: x
};
3 d: C' E( e; ^( r) X1 |& U! b9 t1 s
static int __init led_platform_init(void)
' Z) i Q! `. O* e/ }{/ E4 Y( K0 Z9 X4 U
int ret;9 Y8 x3 g) S3 s3 U. j6 G$ _
#if 0
2 F. ~* d2 B! | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
l4 V$ Q8 z3 o if (ret)
) P, K! l, v0 c" p4 o pr_warning("da850_evm_tl_leds_init : User LED mux failed :") [) p. |+ x0 y9 r. ~1 h
"%d\n", ret);+ V0 H9 X) L7 Y
#endif
$ \0 E* b6 {3 H$ Q! z) f ret = platform_device_register(&da850_evm_tl_leds_device);
1 b }+ Z) q& c( G$ x/ L if (ret)
! y3 @' T) O' ]8 ]4 G8 A pr_warning("Could not register som GPIO expander LEDS");( H# F: q4 B) d+ H5 F8 K
else
* e5 p0 ?5 w# a$ f printk(KERN_INFO "LED register sucessful!\n");# t3 q) W4 z0 E, ^! ]$ N
) |& @5 R2 H( {" S% h, @
return ret; B0 B! I. L5 Y# l5 Q
}! A" ?5 s$ @( d+ v$ P
2 X* N$ ]% A* e f' Y2 {7 M( ^static void __exit led_platform_exit(void)% i ~4 D4 [& E! b M
{
3 k7 j: n- B) [* D platform_device_unregister(&da850_evm_tl_leds_device);( x" E0 B1 f E1 A" F- c4 m
' a' d1 `% Q3 A/ ~ printk(KERN_INFO "LED unregister!\n");5 B/ T" H1 a( @9 `; V8 b
}
4 U$ j" Z& R7 K- q( s0 Z. A. a6 Z/ G% @
module_init(led_platform_init);0 t7 ?. o2 g! H \) g+ Z
module_exit(led_platform_exit);
- E7 Y9 \/ w3 r: Q) _ H4 @- d
7 l+ d% o, s3 G, wMODULE_DESCRIPTION("Led platform driver");) r# U y0 N- d, G, J
MODULE_AUTHOR("Tronlong");) k% h" m; s$ k6 b" X5 I$ R* z5 Y
MODULE_LICENSE("GPL"); a& P3 k* Z/ n6 V
2 {+ }& d# ^* @7 O |
|