|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& G- V2 u5 q( Q, a F. c#include <linux/init.h>
7 C9 e% ]( k: @9 n7 O+ M {' X' V0 `& g#include <linux/module.h>
. u1 n) v# ^) Z' U' A4 ?#include <linux/kernel.h>+ w4 n( \- }; m- J2 o7 J
#include <linux/types.h>! \6 _- P: H/ k. C7 J0 E9 k
#include <linux/gpio.h>' o! W; F! R" C9 I
#include <linux/leds.h>
- F- a- B2 ~3 K( r#include <linux/platform_device.h>
, N! X `4 D: k: ?) n9 T" F; W# J9 g
0 N+ H& S( I! m7 v( q8 K) K) `$ |#include <asm/mach-types.h>
% O7 b( z5 h* v! |* s" S% Q* w7 C#include <asm/mach/arch.h>/ [! Q% o3 E: S- L
#include <mach/da8xx.h>: { G4 ~) y8 j8 }* c
#include <mach/mux.h>, r5 N8 @ a7 [# F
' W; p9 d0 y4 L; k/ o' P' d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ g! y) \. U3 K# D' H5 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 H+ `( {+ v$ A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 p/ j7 K! L$ N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ Y$ x' w. x7 a, {9 w: S5 x
0 ]2 }8 ]" d4 C; S. U
/* assign the tl som board LED-GPIOs*/: m t/ ?8 V$ z/ o3 w, U
static const short da850_evm_tl_user_led_pins[] = {
: C% {$ z9 j4 ~* w /* These pins are definition at <mach/mux.h> file */9 w: O- H4 w- F5 U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 w$ x. F7 `# I+ u; f. t6 k -1
) E& u' R: T1 y: W; ~' Y2 i};
1 L- {# a$ R& M/ T' _6 a4 ~- {! F2 T( J
static struct gpio_led da850_evm_tl_leds[] = {
8 g, v5 d' W6 Q2 h! y$ C( r0 r, | {& x" U( I5 _9 h
.active_low = 0,
% h% g$ D8 `) z+ k" [" [1 U: h0 I .gpio = DA850_USER_LED0,; c; v$ _9 B6 b& u% d* n% S
.name = "user_led0",
* o5 J, C: J: Z7 c4 v! u. a .default_trigger = "default-on",
3 N' I. R" `, o R* }% P },0 {9 _- y. |# ~+ H0 L: Y; K o' B
{
4 R6 ?: _, I7 X .active_low = 0,+ }( O' F7 A) m( |
.gpio = DA850_USER_LED1,
- _6 |- ~5 R5 }; I7 O .name = "user_led1",7 m, @' W# d& \9 g# {- U( n
.default_trigger = "default-on",% e: [4 r/ m3 O; P
},
/ V+ m. b5 O2 E! y, L {
* C: n0 U2 m! E2 R .active_low = 0,$ F, t/ Z1 \ p1 R8 q# [5 x# ~
.gpio = DA850_USER_LED2,
{* p* o* y5 V; Z9 o5 W; c [ .name = "user_led2",% i) C$ K/ x9 I. I1 d4 S" N& M
.default_trigger = "default-on",
. H- t+ L' h; ]! { },
: m4 Q0 ]3 |2 i% C5 X# I: o {) B: D+ }% g4 n' O R% i7 F
.active_low = 0,
- B7 |, o2 q% ` .gpio = DA850_USER_LED3,
1 H& c) h+ r! \) k$ t .name = "user_led3",
* m/ c6 N7 f7 a& H8 G/ Y .default_trigger = "default-on",
9 s) z" @$ `" F0 V },
7 R6 u( N( I* ^- n};& Z* T/ s0 a; V+ h2 k2 w' n n8 Z
! l) [. E7 y/ k1 N8 E+ `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! n v4 h8 b2 Q4 s M. G! b/ D .leds = da850_evm_tl_leds,
( n5 q7 c" [8 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 x8 J# n) n% q+ U/ ^2 g
};
$ I' f# x( r, X9 R% G
% S4 e' v2 o: d) k4 e) ^static void led_dev_release(struct device *dev)' ?( Q& n. X& `, j0 `
{
# i( z' J3 q$ {8 o- v. B) o};' g. {6 J( X# S, v; {. u* M2 `
1 d1 r3 U$ ^4 d! `
static struct platform_device da850_evm_tl_leds_device = {
/ v& R Z7 J( ~ .name = "leds-gpio",
, _) w- |# u7 S! f8 d .id = 1,
' R: N4 |* h I3 Q0 W; b .dev = {
( |8 p j8 n! O5 o6 R& ` .platform_data = &da850_evm_tl_leds_pdata,
% Q& ^$ C" A- W. j$ b2 u) Z .release = led_dev_release,
6 @$ h7 ?5 b! Y) k }
; d. {7 b! _* o! Z* P5 W};
m7 w9 p2 |" Z! x% W5 X
8 l: E/ T. I& c# g% E, jstatic int __init led_platform_init(void)
9 ^% o6 H2 {6 ^2 N* b7 I$ [" F3 p{
# W" H" S& u/ o int ret;
/ I: L( m' ^. j1 x4 @% T1 o2 f+ @#if 0
8 f2 s+ {/ r2 U: w( d, s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: R4 X, t) v* s2 G8 C/ e9 q" P2 K
if (ret)
+ _ H8 c6 ~6 {. b% M, V0 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# d/ w y0 J3 ?1 j# P "%d\n", ret);( {9 U/ R" t; u1 U
#endif
% k9 f0 D2 m$ s/ O$ h3 k8 O5 e ret = platform_device_register(&da850_evm_tl_leds_device);
/ Z$ ]8 s" P5 E% r) C if (ret)3 N% m' g7 r9 W+ Q
pr_warning("Could not register som GPIO expander LEDS");
) s: D1 X1 Q! L- u else
7 T: `/ @. Q! ~( X- p* Y' U printk(KERN_INFO "LED register sucessful!\n");
$ I! [. |; O" ~. G/ B& l- A( C. Q( z
return ret;* E" t) X2 G* |( F9 C6 D& F
}
" u4 S4 ^1 R4 o1 d8 y
4 M" U, G$ h5 V j* J% I( f+ x8 dstatic void __exit led_platform_exit(void)
7 h3 s; L' e* r2 g& J# c; X{4 j" W/ [" z! v: ]" `+ Q
platform_device_unregister(&da850_evm_tl_leds_device);
7 ]' X/ R2 w: g5 ], W
5 o' `9 n! @7 J6 O9 l" m; o printk(KERN_INFO "LED unregister!\n");
3 W1 z+ b! p/ e8 ?0 H- z/ ^}& v1 a6 ~9 v6 L9 s0 }$ S
{/ L- v7 o% o) W1 @$ X% D/ f3 Fmodule_init(led_platform_init);% s5 J+ q( i- d% b$ p- N
module_exit(led_platform_exit);
$ ?) P! C( V& k- p2 b6 ^
6 K4 ]4 a" {' j' @) v7 h# }MODULE_DESCRIPTION("Led platform driver");, ^. w: z' D Q' D! D
MODULE_AUTHOR("Tronlong");
. Q# G; K/ C" r7 R1 ]: \0 VMODULE_LICENSE("GPL");
$ g- r6 l; I8 U' P% b( u6 L4 n6 t3 C% b' f: s; h% {$ _
|
|