|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 C) j5 K$ O$ k0 l0 r, p5 _$ u#include <linux/init.h>
2 }; Y" ~' y- @3 x5 o: M1 G#include <linux/module.h>
; L9 l9 o: K8 q3 u+ Q#include <linux/kernel.h>
. R' V; M N0 ?- D! |2 ~5 m#include <linux/types.h>& h; Q5 m, r, G
#include <linux/gpio.h>( l- v4 k2 p& O* U/ e1 k
#include <linux/leds.h>7 s3 U& {& e; x
#include <linux/platform_device.h>
/ S! w' D/ G4 D1 x, }' x! r8 J2 v( x$ J- x
#include <asm/mach-types.h>
3 B- c3 x$ Z6 s7 T' e#include <asm/mach/arch.h>
2 c( Q* f: I: ^8 e ^#include <mach/da8xx.h>
% a" {1 `1 Q, l- ^5 R#include <mach/mux.h>; G f$ i3 {! M0 `
7 ]5 o; ~+ E% \2 t' ~/ f7 u) T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' ~% @9 c1 S% E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* _+ M' X% ?- y+ \% V, j' q$ r1 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 g( f% u* w$ ?6 D& R3 B6 d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 L/ \) Q( e9 b' ^
# g! \" G* z3 C5 h
/* assign the tl som board LED-GPIOs*/
' s3 X6 n% X" p/ l/ g ] Zstatic const short da850_evm_tl_user_led_pins[] = {
( e9 D: W/ ~6 q" w4 J- r" H$ g /* These pins are definition at <mach/mux.h> file */
" m: F$ E' ]# q2 X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
M8 |1 k# K* p/ W1 K -1, C- | X+ M1 h* E, j3 W; s
};/ X3 h; r+ V! A' g' S+ c9 C! f/ ?
! [* ?, J* ]5 Hstatic struct gpio_led da850_evm_tl_leds[] = {+ g. o" }" L' J' z( r- t [. [
{* i, i; G$ q8 C# x1 r
.active_low = 0,/ t7 L- D1 }7 N* @- m3 v5 j* _3 Y
.gpio = DA850_USER_LED0,7 O) h- N- d& N6 j* N- G0 `
.name = "user_led0",* V; q/ |9 u, y9 m( X5 I
.default_trigger = "default-on",8 G. K1 [5 F# ^0 N/ S, ]
},$ t+ V$ M- F3 {1 g
{3 h4 a- M, p( C; |/ `. f& [, w4 l
.active_low = 0,
) o0 m4 ^1 i; [ .gpio = DA850_USER_LED1,
$ |1 X8 |8 M+ L6 m) J6 q .name = "user_led1",! @1 l, y8 m* ] \+ ]
.default_trigger = "default-on",* S* C) |9 g: V% l G8 Y
},. A4 ]: D" \4 l( }- E
{1 Z. c6 t$ S9 C& k" A" f [9 y
.active_low = 0,3 s3 Z. Z- K. L2 o. r, I
.gpio = DA850_USER_LED2,0 _ |8 G* I5 Y% d Z9 ^& D
.name = "user_led2",4 b7 r+ L1 H3 j$ T6 q
.default_trigger = "default-on",
( w, b1 ?9 k# b' I- y },
. k" D3 n0 T) Z/ z8 |' M3 G; l; k {8 X. f3 T& q) l* R( w
.active_low = 0,8 C" A, J" V& p* U- {5 I
.gpio = DA850_USER_LED3,+ {2 h7 `* E, i. K# N
.name = "user_led3",
, J2 O! S: m; t4 l* } .default_trigger = "default-on",$ a/ N/ q" e- O7 Y: U& c _2 z
},: E1 g+ k+ n; K' t! w' U" M+ j. m0 \
};
- ^, {4 m& W5 N' [/ P; f7 n
, O- F. q* d5 w N% w- u: Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" F% A3 b& J7 x+ @& O/ g .leds = da850_evm_tl_leds,
6 l$ ?* V# X) Q$ \2 ~+ R: c' G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; S% A4 S: h" j. i( m# _
};# G8 Y/ ?4 L3 W# a2 r8 B
8 T* J E8 }7 O7 b: z" L* U' b
static void led_dev_release(struct device *dev): Q9 o- t6 b1 Y" V+ B; n$ W
{1 b+ \; f" C7 L- C7 T
};/ P5 A' k5 i7 y4 V7 p
2 h* W7 G% U1 A& j& `1 B. m
static struct platform_device da850_evm_tl_leds_device = {4 x$ C$ n+ P8 v8 \+ T2 T
.name = "leds-gpio",
& [) Z# M4 S/ t' @ x' d .id = 1,
" W* ^ }0 I4 j8 m4 e' |- } .dev = {! z: p/ n2 U9 q! m$ J. \% p) j
.platform_data = &da850_evm_tl_leds_pdata,
# h0 D' x6 u) j4 Q, {: ? .release = led_dev_release,
8 V* y# u) [1 d$ e( H, ?% v' A }
$ S" [* x* V; ~' G6 R};
- }' X6 R: B( _4 s m
* p- j: i+ K2 L* z0 I- \# C) f) A' rstatic int __init led_platform_init(void)
: Y& i5 V6 Y0 v3 p4 U& F{
- x5 Y( ]$ C1 Z5 p- V. F: x3 w int ret;, ?( P o6 l4 {/ K
#if 0
# d* N: r" u N/ k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 L: k- l0 P& A# U. s3 [8 i8 k8 c if (ret)
9 I: }% [& z4 Q) k5 F7 s$ R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ ~: L1 _! p, J+ V. Z* n "%d\n", ret);
9 `# f$ l5 g9 C" a4 _#endif
! G9 ^' K+ B, T! e ret = platform_device_register(&da850_evm_tl_leds_device);
% m: ]% v! X2 h5 w$ h if (ret)
% O7 m3 r/ d! `) k3 i- W5 g* b pr_warning("Could not register som GPIO expander LEDS");& y4 s' d! Q. j' p0 J' f M
else# L) P7 ~$ ]" N( ` K& y
printk(KERN_INFO "LED register sucessful!\n");
* n3 r" W$ V) `( _& p
9 m; {- C O8 h, { return ret;: P j( _# G' q) V2 S
}
0 \& E4 c9 ^# x s2 D% g9 M' n' e# N' s( E9 q# ^6 m
static void __exit led_platform_exit(void)
; T. K& t% ?( @9 E{
, q$ @. \) P% Z7 w$ v platform_device_unregister(&da850_evm_tl_leds_device);/ H' ^/ e5 B1 _- v* Z' @
+ Q' F( ~2 D) i, N0 Y+ M0 J
printk(KERN_INFO "LED unregister!\n");
& T" h; p# d$ h* B# t" E5 g' u}
) c7 ^: l* \+ P! [
9 o! y6 `: Y# h9 i/ E- c1 fmodule_init(led_platform_init);6 J3 U! e7 s" z: [. N: p) O
module_exit(led_platform_exit);
9 |7 t8 R' l; H2 G- K7 [1 d) V+ M+ Q8 L- y+ h S8 n
MODULE_DESCRIPTION("Led platform driver");& a, ?3 \) Q7 v7 ~; S- C
MODULE_AUTHOR("Tronlong");& a. J7 q0 z$ W7 T- H* `$ O F
MODULE_LICENSE("GPL");! a1 M4 L$ w3 b2 |7 P5 |
7 {' a1 I) G8 g, T+ P4 M' ~ |
|