|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 g: X, N; a* O
#include <linux/init.h>6 P# m) K/ W+ |% i( {$ g! o
#include <linux/module.h>' ?0 K& x4 P# n
#include <linux/kernel.h>
# q2 J: z- Q: c! S: `, J9 w#include <linux/types.h>
8 @" Q. U+ d3 m C/ w; i; y8 \2 {#include <linux/gpio.h>
1 ^! N r( Q+ D( Y#include <linux/leds.h>1 w# d& g" D8 G( `' l( r$ K) R+ A
#include <linux/platform_device.h>/ Z; I' q& x J' ^, {8 G9 u
4 u4 r" u( O6 x5 C8 H: Z+ Y
#include <asm/mach-types.h>2 x. \5 R4 i- j( ]7 k
#include <asm/mach/arch.h># O# |0 D9 y |, ?5 \! J9 Q5 W
#include <mach/da8xx.h>: g7 U6 k7 g. b3 a9 E
#include <mach/mux.h>0 u% l" [ O/ k+ d
3 n& J, n) R) q4 Z0 e, i7 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( U; H3 f, S3 D8 {- ~1 P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). G! Y2 P; T6 S0 G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' }6 ~) \/ X8 v/ N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% \% L1 m6 m! {5 A, w) E
" n5 f/ K A4 u2 P0 w/* assign the tl som board LED-GPIOs*/$ e8 s7 N3 u# {* X+ v) r
static const short da850_evm_tl_user_led_pins[] = {" k% E0 u+ t4 d9 u
/* These pins are definition at <mach/mux.h> file */- A. m6 F" |$ Z3 T" {9 f* T8 K( X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* R" z2 v+ N' b1 a
-1
; `9 H- t R: m, u" E- p};( X5 G( F9 l# ?- @( d6 N8 o! J+ b P
1 a6 ~- ~# J; i7 M" f; |+ Q& }static struct gpio_led da850_evm_tl_leds[] = {; _% B$ e2 |. x, T4 {: q0 s. R) {! S
{
. M' g. ]$ E1 a2 t# H .active_low = 0,
8 z! s: f- s, x! @/ ? .gpio = DA850_USER_LED0,+ T$ H* X5 s8 s% j0 B
.name = "user_led0",
7 O0 |6 y \1 k2 r: X6 ?: |# \ .default_trigger = "default-on",
2 n, j( ]1 K3 m9 j9 S! y },
# _; D7 [( W ~% g- p- t3 U- ? {0 ~/ i0 n% ~( M, a0 z( a4 b' z/ H
.active_low = 0,2 X5 [- h j/ d' V& e- z) Y# v
.gpio = DA850_USER_LED1,
. P* K1 R9 U- {2 K7 X .name = "user_led1",
/ \* h7 R+ J% d" k0 z .default_trigger = "default-on",
8 ?, h8 M$ n1 T5 j },- r6 \: r T+ Z" e6 S: l; c- x) d
{0 H) @& ^" r4 S2 j4 D i& h
.active_low = 0,
U, |7 U& u8 R9 U1 M .gpio = DA850_USER_LED2,2 s. j$ @& |9 k
.name = "user_led2",/ g- P2 Q$ O, H2 q( y- P
.default_trigger = "default-on",! _; _; B1 _6 a/ X: }7 G
},
* T3 f W0 S( l$ a+ Q {
# _! O0 J3 Q7 _8 i, ~ .active_low = 0,! j/ a3 p4 E$ o! {' L w- D7 P
.gpio = DA850_USER_LED3,/ n, g/ a, b# v* D( t+ a9 n7 z
.name = "user_led3",
' ]& C+ x/ k, @8 ~ .default_trigger = "default-on",
* y! R7 W+ |. w1 Z: T; w e( _0 G },) U( |4 u9 G* n; e( G
};
4 ?- n L/ u: U7 j7 i# n+ [5 \" P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( p- C, ~1 J q# j: p6 o9 M1 l3 `
.leds = da850_evm_tl_leds,5 }, i0 o9 L3 g) T$ z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ _0 e' c5 b" h! }* s; A};
: @: q# J0 R2 t
0 X2 n/ X7 ^- Jstatic void led_dev_release(struct device *dev)
6 P4 a; p! R9 l{( V( R, F6 ?5 d$ C$ e1 a
};
( G) R' l$ D( F" z
, J, N, w3 G/ L$ f" j% C/ fstatic struct platform_device da850_evm_tl_leds_device = {
5 K$ s6 P; V4 t- Y .name = "leds-gpio",4 B9 V4 c" s. l3 L* [0 Q7 y0 X% b
.id = 1,% f0 }" |% j+ [3 j2 q$ s
.dev = {8 U0 t4 l( Q- d, o2 w
.platform_data = &da850_evm_tl_leds_pdata,+ {' C% Y+ s B& f+ U) [, D5 ^; a2 q
.release = led_dev_release,
9 \: [( u* m( |- v" r* ^# W9 \ }8 f1 |9 y b. q2 C$ t
};
/ [0 J1 p) H/ @1 x; k& x! ^* N% c% X4 q! e' ]5 ~
static int __init led_platform_init(void); n: Y, d z0 Z7 _+ W$ ]1 V
{
, A% T. k' K$ H" S, @9 E int ret;
3 W2 q3 r3 M! _6 T( ~* g#if 0* t: y+ p' p8 I9 S' j& ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 Z; S2 C2 y* s3 S2 [ if (ret)# m4 n: ]; z$ P* ^+ l2 a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( Q0 X. d0 f/ v! I0 Z "%d\n", ret);$ T5 t$ v4 h8 L0 U1 }9 p) t
#endif
: @1 V) d# h3 i7 D3 v ret = platform_device_register(&da850_evm_tl_leds_device);
" S+ S4 F; I* K) S' ^& b1 P if (ret)
; W- v; r3 P$ @4 B pr_warning("Could not register som GPIO expander LEDS");
- y# l8 J+ h1 O! W6 M else! E6 [" A, Y' Z1 z9 e0 x
printk(KERN_INFO "LED register sucessful!\n");
( x- m, u% C" h, U: h9 r
) B/ ~4 A9 Q- v7 P/ f return ret;6 `# T, ^* L5 W+ y" [
}
) i, a) l8 K4 G0 L: _
' g; X) @1 K0 Y* A& `static void __exit led_platform_exit(void)
% @6 p: [6 @0 i) x0 u( E{
" b; X- { P+ q8 D7 _& s/ ]8 @ platform_device_unregister(&da850_evm_tl_leds_device);
8 P& l' C' u3 W! K/ R8 ]5 ?( ]
3 @% d+ p+ _; g* W printk(KERN_INFO "LED unregister!\n");. r- C! f( A3 X( }/ W9 h
}
+ I: D1 Q( y$ A P# [0 [/ q
& a" p: b3 P$ g6 L- T# ?6 Pmodule_init(led_platform_init);9 s5 L. `% Q3 J6 C' k
module_exit(led_platform_exit);, _/ }/ D8 Y! I7 O+ @6 Y1 T- U- }
# |$ V# w( w7 K' d tMODULE_DESCRIPTION("Led platform driver");0 W+ I* Z! V, O
MODULE_AUTHOR("Tronlong");: U$ U& f0 J% t0 G
MODULE_LICENSE("GPL");3 ]0 o; x: S1 m3 ]
: N- a. H6 h* X# e4 F
|
|