|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" O( a& L: C! y5 Q8 x p
#include <linux/init.h>0 @) X/ ^" f% k; e/ H5 U# L* y
#include <linux/module.h>" `. `# a/ _/ T2 V3 f% m7 M5 r& R
#include <linux/kernel.h> f; f8 l( T- }' [ ~
#include <linux/types.h>
# b8 w& W2 x" T. R# Y4 v#include <linux/gpio.h>9 ` i$ i- X/ V" \& b
#include <linux/leds.h>5 c# S1 l8 {2 J J
#include <linux/platform_device.h>5 i7 U+ }$ w: ]4 ], F* E5 Q1 s$ I* I
+ _& t6 r" e1 w/ C- k3 Z#include <asm/mach-types.h>9 G% R- \# @# U0 ~0 W
#include <asm/mach/arch.h>
: b& B( b. V( N% H- ?#include <mach/da8xx.h>
( J) M1 \0 B$ U3 I#include <mach/mux.h>
- b6 Y8 E0 S; J3 K' w
0 h* p4 Y) L! p- k" {% H* E, Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* s/ t! h4 u( |& f+ U* F, A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 i+ l b2 o$ \& J5 B8 ?/ z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 ~7 L8 C/ ~8 U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# K9 d7 h7 O: ?! J
5 H% m t2 _$ u1 W5 I( q8 W) [- e/* assign the tl som board LED-GPIOs*/
; o" P! i" [+ c2 estatic const short da850_evm_tl_user_led_pins[] = {
% w$ K6 s2 c' D /* These pins are definition at <mach/mux.h> file */( N7 D N0 B( s' _1 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 n5 @7 d7 k( @. n2 C8 c
-1
" x4 [. J/ {, a+ }};: v S* d1 L C
4 f( E# s2 H$ `3 w2 V% s9 gstatic struct gpio_led da850_evm_tl_leds[] = {
, s8 z% l8 ]* y( s {1 E4 q' \& C7 e0 H
.active_low = 0,
Y( V& v' I3 H" k9 a% p/ d .gpio = DA850_USER_LED0,' o6 H8 D; d( c ]) t+ n6 Z# F7 B
.name = "user_led0",- ?' T( o' L. G. T' H- ?
.default_trigger = "default-on",
1 N) j3 w3 j/ j) ]: k },
3 T7 m" o, T- |4 d! E {9 h; c% r7 }- x1 b( T3 Q
.active_low = 0,1 u1 O" Q$ K) b: l
.gpio = DA850_USER_LED1,
+ C \ I o! C# C .name = "user_led1",
% j) F8 r8 h0 r4 O6 _4 O .default_trigger = "default-on",
3 ]: l! @& e v0 z) v },- M& Q# A( j: i4 t' e0 j( l
{4 j" ?4 ^0 {6 X) ?
.active_low = 0,
V( Y: e2 x' A, t .gpio = DA850_USER_LED2,1 T9 _6 n9 @. P1 h) | _
.name = "user_led2",! f/ r ~3 B' ^; Q8 u2 B! k; l2 U9 @+ z
.default_trigger = "default-on",- ] K3 I( M) X* B; S# C, Z
},
5 L* ^1 {' P7 j' D4 B2 C {5 t7 r* k1 v6 G7 K+ {/ B
.active_low = 0,
7 n0 n( q7 S" [ .gpio = DA850_USER_LED3,
% z5 w( {# l. _; t( ?+ D .name = "user_led3",! V( N9 Q/ i* N9 ~& N7 J
.default_trigger = "default-on",3 j. B, w2 r' O+ r, O& Q7 y
},
( ?# _1 ]# v: |; l};
+ t# |, l) e, W, ^7 y4 `
' {& ?- g% T n' T8 m0 L! Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ P {2 k) O4 Z# b3 R% H$ h e .leds = da850_evm_tl_leds,
1 c# Q0 s2 g" i1 @% w8 v8 K5 G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ x- ~ g5 x% i f$ I% B
};
* F' z3 Z. U4 S* \3 S) T/ S) d/ V+ y& z2 j! _
static void led_dev_release(struct device *dev)
$ a% a+ a7 y# ^" L3 I/ u{. H( I7 @2 o8 e8 P9 T! D
};
% t8 i* \( z0 q0 L. N0 _0 o# |" j& D* f; |% y4 H" @0 {0 V! A* l
static struct platform_device da850_evm_tl_leds_device = {
2 n2 L/ m& ~; L( V .name = "leds-gpio",/ V$ s+ v8 q' m5 E' c$ |+ I1 I
.id = 1,7 u0 b" e, h7 Z5 [3 \
.dev = {' _, A! z: L1 M" R- ~
.platform_data = &da850_evm_tl_leds_pdata,. e: s) \. n2 Z
.release = led_dev_release,+ X' {: e/ d E, Q0 P
}
; f# F. Q4 t1 M: p};. U8 D( r. b$ u2 c1 {. _$ b
+ j$ t8 |2 f( l3 @4 S: zstatic int __init led_platform_init(void)7 g- |: z+ g( i# e- C# l
{. _9 u3 ]/ H2 Q! `3 P$ U
int ret;
3 ^9 h0 u% h* H" f& n#if 0
, b" @* {: T G/ q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ Y- _$ k% |) h) a
if (ret)
- I, A) B" d9 \* u3 [$ B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 T+ J) C4 k) N/ ^5 S7 g "%d\n", ret);
7 ]1 [/ R% d1 y" Y p#endif
* I; I) Z( C- [) n) D ret = platform_device_register(&da850_evm_tl_leds_device);- w( y8 S5 G6 _% m) w
if (ret)- ~1 p' Y) u1 K' L
pr_warning("Could not register som GPIO expander LEDS");- A# ^$ \# p& q C O" e
else
+ E* n! B- ^6 g( c/ ~ printk(KERN_INFO "LED register sucessful!\n");0 b6 r7 Q! V" ]8 [* [; p
" k9 t' q3 m# Q% U$ ^, d7 f
return ret;
! o5 s7 p" v8 w! \} D* G. d; C! J3 q L- J
9 C( M/ {0 L) P9 }5 c$ Ustatic void __exit led_platform_exit(void)
& Y/ i q: F: h) A* l4 G5 w. ?3 [{2 \" t" M0 e4 x5 g( e9 r
platform_device_unregister(&da850_evm_tl_leds_device);
* d4 d- O# N) a( s* B I
" k Q o L! R8 k- O8 l6 i printk(KERN_INFO "LED unregister!\n");
( e/ P; Q+ f$ U4 ]& m) d}
* P) T. Y; w# y$ ]3 w
6 L) ` q; [. c! B/ Q# c/ n4 G) b( Umodule_init(led_platform_init);4 q0 T% O- X; z; _7 u" A2 P- e) u" R" o
module_exit(led_platform_exit);# A% j4 F. O9 \0 S1 Y
$ Q/ {9 [5 U- y" D' J$ _% v$ w) i! c' ?8 A
MODULE_DESCRIPTION("Led platform driver");
( [; z+ j' ?, W& [; [) rMODULE_AUTHOR("Tronlong");
0 N9 r' r9 g1 J$ s/ P; v' x. bMODULE_LICENSE("GPL");
1 v/ d& X% B, _% j/ }7 Q( }8 V4 C$ Z; Q2 g- s
|
|