|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 A$ B8 W) i2 p* R#include <linux/init.h>
; C9 ~2 u' V0 \2 @! P#include <linux/module.h>; c4 D2 a1 l; N p. \* M0 [, J
#include <linux/kernel.h>
- k" C7 A" s# n- ~3 X#include <linux/types.h>0 @6 \ s9 ^" x! w; f& f$ h
#include <linux/gpio.h>2 o. f8 y4 y" V9 m* N; a v% u
#include <linux/leds.h>
9 N# ~1 `( x$ o- L2 `" L#include <linux/platform_device.h>( N* k, R# D* J# P
$ f' A& ~7 `1 p% j; Y+ _9 P+ u2 I#include <asm/mach-types.h>
) E5 T: I' _7 O#include <asm/mach/arch.h>
E( a0 v) B2 t, S( ^7 f#include <mach/da8xx.h>
2 c1 X3 _' q3 v#include <mach/mux.h>& R1 o5 J: r& Y G# v
* a' D" ?1 }5 q, t4 ~" d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) n5 ?3 q% y# V4 b% o4 K4 l4 `9 V9 x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 Q2 X8 E. A, `! z" t6 ^+ ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 T2 _+ Z* J9 M4 A, N& P% @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& l3 ], ?! s0 E4 |8 g k2 F
- c8 Z1 S, s8 l, n1 |5 A- O/* assign the tl som board LED-GPIOs*/+ O6 g( B7 q$ e- a( a
static const short da850_evm_tl_user_led_pins[] = {
) v: B- h1 x; U7 A1 _3 w- b( f) W /* These pins are definition at <mach/mux.h> file */
) L$ U; u* `, ^% W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) x7 ]/ h2 @. A" ~5 M+ S- @# n6 ~
-1
8 T/ O' i/ g7 A3 U9 o};
+ z5 ^9 C: _! Q( h. Y
9 f4 u$ u P0 ^% r0 N; ^. Xstatic struct gpio_led da850_evm_tl_leds[] = {; H$ K) n2 I4 e, A6 y1 {
{* ]+ P) U& Z+ A X8 [7 m- H
.active_low = 0,
( V0 U$ v2 S, W# E/ M .gpio = DA850_USER_LED0,# p/ V% w+ U- |3 s$ w
.name = "user_led0",
+ i3 X( |2 f( y: ^4 ?3 i0 X& H .default_trigger = "default-on",
4 B* i; O2 ^' f" h },
7 M7 ~! V4 S1 r3 p. G9 @2 p5 F z {
1 C u+ o! o( b; a7 X* [6 _* B .active_low = 0,
2 h: z# J' y7 R( q' @/ l" [ .gpio = DA850_USER_LED1,
5 h5 d- Y9 l$ q# ^ .name = "user_led1",3 V6 V; h" W; r- Z4 a; L. k
.default_trigger = "default-on", b2 Y% k a, i$ Z4 ]* J
},
5 l; {; Q. r9 J; N$ ]0 T: i+ e" w {
1 Y& S& J; U* c" C; G6 n; Z! @ .active_low = 0,4 ~* U& {- U; T5 Z% b# M/ B
.gpio = DA850_USER_LED2,
$ O. @: g. Y9 I4 }9 W- `. G .name = "user_led2",! U" O& K% d3 U* U
.default_trigger = "default-on"," T5 H- \& Z2 _
},8 G: K& ?- D( y& U5 g
{
$ F8 q( t% R# w .active_low = 0,
- \- f) w* {) _. `4 c! y .gpio = DA850_USER_LED3,
1 \5 \! V0 D7 W( d* t7 v .name = "user_led3",. ]) s$ C+ `( {5 B+ \
.default_trigger = "default-on",
/ l0 D0 ]6 R3 K7 ~* U6 I' | },
+ i7 _; Q6 A) ~- x+ j};. n6 e: J- ?9 `
# h% y) j- G3 Y- E" ~7 G4 r. \' N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 o$ p; g4 m' D1 R) V- x .leds = da850_evm_tl_leds,
0 |( h# E6 ?3 G, e8 j/ K7 A3 j, c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) i4 ~$ a" t3 f% F};
5 H+ d5 L: F- w8 A* G( h+ t1 _2 f; @$ z1 l. v' V% p
static void led_dev_release(struct device *dev)
6 f$ H$ ~' f1 l! I1 O{% S/ I" O6 q5 R: ~
};
. k' A2 |! l0 B. ^& S8 d# f, E' V9 B! g5 M7 E: k
static struct platform_device da850_evm_tl_leds_device = {: Y% [% H; i. J3 Q# ]( I
.name = "leds-gpio",. k% }) f3 L- K) K7 z) u
.id = 1,: X P. T: W7 y$ [# }% L3 h
.dev = {& x! g: B+ R4 v/ ~' }
.platform_data = &da850_evm_tl_leds_pdata,: ~3 v8 a B6 D8 H7 b
.release = led_dev_release,, c( C% K* M, O% K3 O+ r! x( B
}' ~& U9 }, C/ c
};
5 u) F6 _ d3 F* w8 g* w' y
& A7 e9 X! i* ?: ]# L! k$ i4 U) rstatic int __init led_platform_init(void)% U. S& m8 I: C! C& y! F3 I( K3 R
{3 S# ~2 f y' a7 [
int ret;
. h; `; z3 ^& q' w0 ]1 w! e* X#if 0; _3 d2 C, Q$ Q; s9 z, D3 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" _# O" r1 |" m# \ if (ret)
% h0 M7 M1 e6 J9 D. s: p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 l7 e! o7 e3 j# F "%d\n", ret);# ^$ y6 y$ x8 O/ \ ?1 C
#endif7 F0 J o- e% a, G) L
ret = platform_device_register(&da850_evm_tl_leds_device);: Y) n7 f# ?7 N) c1 y* n3 _+ \
if (ret)
6 b S: S: }/ H3 K8 ^: X& D pr_warning("Could not register som GPIO expander LEDS");
9 x; _* x* ^. ]) z/ K" r. n! N1 F3 i% C else
+ g. o G6 E( B1 ~- D. s printk(KERN_INFO "LED register sucessful!\n");
+ R. R! E2 q% J/ O# g5 T
; d B: r6 D0 [' ] G return ret;
" Y: F X2 `0 B% i}
% J. ]" t! B3 Z" t4 [
/ h0 F, q7 P- gstatic void __exit led_platform_exit(void)
' G: f/ ]4 M5 x. G! {1 Y8 K{; k8 W/ ~/ p5 f7 w
platform_device_unregister(&da850_evm_tl_leds_device);
* d. {# Q: Z$ g) V1 U% E: R! G9 @8 i
printk(KERN_INFO "LED unregister!\n");( O! y3 ~0 h* U: ^6 {6 @; B
}
$ q5 {6 G% U% S6 }2 W
* g% z/ c) s! n% {$ i7 u' pmodule_init(led_platform_init);* B( I' t' N. K! \( {! S
module_exit(led_platform_exit);
* Q5 C6 ^; y( K- g9 D
" T/ u( p0 j+ `7 A9 M- i% s1 kMODULE_DESCRIPTION("Led platform driver");' o9 D0 Z; J7 `' f& g) C
MODULE_AUTHOR("Tronlong");8 F3 z- g! Y+ l# O" _) X. G
MODULE_LICENSE("GPL");4 a) D/ L- K$ u8 p# Z
" Z |8 ^$ n7 y/ {. t' r& n |
|