|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. x( x! j4 |" e9 M2 q5 s#include <linux/init.h>$ H6 }* x! K5 K
#include <linux/module.h>
! N1 C2 D e" O% `- O#include <linux/kernel.h>3 J: O- h+ ~! z$ n) [, v
#include <linux/types.h>
% @9 \& X- k c#include <linux/gpio.h>2 U! f( C- G* D0 x. D& a
#include <linux/leds.h>1 z6 q7 [9 b: u1 X9 V
#include <linux/platform_device.h>
: p, S7 U; _) D3 n5 c
. K0 `& w' L1 W; G#include <asm/mach-types.h>- o5 O0 p4 `0 @3 M" f
#include <asm/mach/arch.h>3 l& O( f' t9 ]# n
#include <mach/da8xx.h>
" Q# M+ r p) H' Z: h# W#include <mach/mux.h>
& ]0 u! d2 k1 H
; i" d) y4 r9 |1 y( @) U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 @% M- k; ?. s; R% o+ G( @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ v! G' R- y; Z4 v' G- P1 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 e7 j$ [( C4 y$ e" [6 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; R% j2 d1 i( n/ Y6 S5 H* j) j; s& |5 Z; k
/* assign the tl som board LED-GPIOs*/" Z% {1 U. H# T' @7 i! n/ s. y
static const short da850_evm_tl_user_led_pins[] = {% p. Z, A1 `% ~- |2 U. G" T$ Z$ @. y3 o
/* These pins are definition at <mach/mux.h> file */
8 Q1 U3 d$ C9 ^' c: f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& w2 A$ u! H3 z R% M -1
+ X* m% Z0 ^1 I( K9 v$ S- G! S# d};; b3 T. A2 j% o8 T6 C
n" ~! X6 l6 P2 k
static struct gpio_led da850_evm_tl_leds[] = {: u" X) x) M0 H0 H5 ^$ P) r" C
{
# s0 D9 u- k3 ~8 ]: L$ S0 W .active_low = 0,5 j, _8 G/ k5 D" v. V o
.gpio = DA850_USER_LED0,3 y/ B1 n# n4 p- p2 y1 u' w
.name = "user_led0",
/ P5 @: ?& d- C1 m+ f2 z! _' t .default_trigger = "default-on",1 H% y# F3 R- `/ _" ?$ R D% l
},
' P# N" Z8 @* X: w {4 I' g# k- g" i+ q/ l) b3 i
.active_low = 0,
' [9 z9 V, y' ~' g, V' C1 c3 | .gpio = DA850_USER_LED1,
* ]! c8 o5 @5 |! ]6 C* q/ g .name = "user_led1",1 F+ G H/ W$ l% Q- k
.default_trigger = "default-on",
) I2 P" i4 u' R+ o$ A( U3 \ j },
|8 j; @7 q c0 ?' `5 y$ u! w0 v {" J& R% P* A& X# g( P- L B, c
.active_low = 0,
/ [, S" u* G$ o- a! W6 l+ U .gpio = DA850_USER_LED2,, R8 C, f6 R+ S8 x$ B1 N# J
.name = "user_led2",
2 m: Z2 V# f3 _ .default_trigger = "default-on", q% h0 Y+ g! i! l
},
2 ?0 ^9 r! t3 Z, A+ ^ {" C$ M4 Q D- e* _7 P: y
.active_low = 0,
# Y0 {/ r3 G Q$ y& _ .gpio = DA850_USER_LED3,
% O2 x1 ?5 D0 V0 V% Z" z .name = "user_led3",
. n* F1 ~& D! L5 C8 l .default_trigger = "default-on",+ z2 @+ T% K8 b S/ t* J3 j# N2 E
},' {9 Q! N6 L( }& X8 l9 d8 k
};
% ?9 S+ V9 W) b U( Y( a; L, `( D; ?5 o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# K; t0 I7 G. o7 K
.leds = da850_evm_tl_leds,& m% Y' W# i- } I& i& y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; [, A0 c c6 f" ~
};0 i8 m5 b% @; B1 k$ {
" s& S: ^4 `- v' ]: [
static void led_dev_release(struct device *dev)6 s K; ` O% Y6 N# z
{9 P O) ` {$ U- N [
};; L% D5 n B* p$ C% q8 w
. o" n" U" y( F- b( O0 Mstatic struct platform_device da850_evm_tl_leds_device = {, Y+ e9 F0 q: E1 I6 j
.name = "leds-gpio",) S! b" x: `1 B' M: N) \
.id = 1,
* A" Q+ D- B. N( {$ W9 Q1 E .dev = {
6 b' _# a/ W P u! o' p2 ? .platform_data = &da850_evm_tl_leds_pdata,
9 d" Q, U5 n. Z, d. x5 Y$ Z# l .release = led_dev_release,! _; M: y% y. i9 }0 R
}
; X( i4 }, M; |% [0 n( Q};
) h) |2 x2 ~/ i2 h! X/ Y
6 c( U8 u. w- }static int __init led_platform_init(void). M% D; M% h& _6 K% f$ S
{
! G. E4 ^3 @2 O0 F+ D3 d* s int ret;& Q, m! O& V5 @, _" o& u' K7 x
#if 0" J. V/ J, i9 E; W9 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 n4 @, L6 S9 ~
if (ret)1 W+ Q( @% z( m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ ~7 D Y3 R+ d "%d\n", ret);3 E' R5 i9 A: R0 r1 Y3 K
#endif# w* n, [! d+ y1 x. c4 v6 X
ret = platform_device_register(&da850_evm_tl_leds_device);
1 E8 `, C: G# v! w! m9 y; l if (ret)
, i( w1 c* s8 L+ H8 I pr_warning("Could not register som GPIO expander LEDS");$ U: B2 ?$ a: \1 z+ [
else6 S5 z! M a- z8 j# y) [
printk(KERN_INFO "LED register sucessful!\n");
8 N7 e: X' s/ L$ P, x+ A) C* e V+ L {% Z2 h
return ret;) L0 w. D$ u. x/ |5 [
}* o5 n+ S# K) }! M O* L5 {
4 j8 } Y% f+ s4 w3 T
static void __exit led_platform_exit(void)' k) I; P: s1 S& Z
{
$ @8 P$ \# n! B7 h4 a) y" G platform_device_unregister(&da850_evm_tl_leds_device);
. K; B- G4 f- h3 g2 x, I7 ^6 R2 k& l+ F4 C1 p
printk(KERN_INFO "LED unregister!\n");+ A7 z- ?$ |2 J
}# G7 J& e1 d* ?" H! D0 U, t% ]
3 t0 C3 x8 l1 O- @% n; U! c# p3 s+ ~module_init(led_platform_init);
7 L' t% F2 J# K( Tmodule_exit(led_platform_exit);
* J0 H. k x/ V$ u" U7 b$ z* U1 i
& _" q3 f& u( WMODULE_DESCRIPTION("Led platform driver");
) p3 B. O# c' A$ r1 QMODULE_AUTHOR("Tronlong");& K8 W* f) E( t3 m! j9 J" m& w
MODULE_LICENSE("GPL");$ ?, c6 ?6 r' j9 s( Z$ e
; I6 n8 ?: a. X
|
|