|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 o) n- C. |1 A: s
#include <linux/init.h>+ p8 E- N1 W r' d: E8 ^' K! V) j
#include <linux/module.h>& k* e- n/ z1 c$ b1 {- R
#include <linux/kernel.h># M8 A5 z$ W) z0 x- e! F
#include <linux/types.h>* |4 K" E4 m9 C
#include <linux/gpio.h>5 E- y& M+ C3 {9 X; D( Q4 D8 D
#include <linux/leds.h>$ m0 P3 W$ O M- m5 U Y
#include <linux/platform_device.h>& S m$ f1 r, x9 G% _
9 p- ~: U! u1 V0 w" n
#include <asm/mach-types.h>/ c7 k& H1 A: R: E; m
#include <asm/mach/arch.h>
+ X1 K1 W# q5 M; f O#include <mach/da8xx.h>
, O! O" V: }( l N#include <mach/mux.h># r& T, P0 k7 b
1 g) d2 ?( U9 r/ q# L; Z) {% g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 f7 a8 `8 O6 U" T r" L! @4 U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 q5 v* X3 R& e: ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) U {; ?0 _" q& F% S+ R* g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 T# c M( i' j$ E& u
' W& k2 \) X7 |% P- i' g, J/ s; P/* assign the tl som board LED-GPIOs*/( ?; L! @1 `; n& v/ s
static const short da850_evm_tl_user_led_pins[] = {$ A) Z: S: ^/ _ [
/* These pins are definition at <mach/mux.h> file */
4 }; {* r1 R7 G$ R2 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 m: g/ _4 \$ D7 Q' K* g -1* U- H8 E# H. L" s8 j3 @5 N& w
};
7 k0 p, W& x0 g( I: q% M; Y7 Z% V4 b, D% { E! l
static struct gpio_led da850_evm_tl_leds[] = {' G, ?/ I; ~4 `/ J. R
{. ?5 S% l" n l
.active_low = 0,8 ]7 ]* ]9 u6 ]3 c. s, s. ?
.gpio = DA850_USER_LED0,
# A0 @: w: y. o% } .name = "user_led0",* j2 x/ r# }. H* q/ I' R: @; |
.default_trigger = "default-on",
' d; X. I+ m7 A2 K },
6 g& X3 o4 a. S {7 }1 ]5 a/ b+ c0 N: F$ H/ d Q
.active_low = 0,7 Z# |% u( u0 k6 E! H: v& S+ I
.gpio = DA850_USER_LED1,
% u9 X* `, A. a. @ .name = "user_led1",! j7 g( e% N9 g: D8 z! X6 i5 Q4 n
.default_trigger = "default-on",
' \0 e X2 y! Z- R },
1 v+ e# {7 N1 j$ d# H" j& v9 g {
- a/ D- R8 g O8 ?5 p4 H5 M1 T .active_low = 0,
0 O3 ~0 c" h4 y' I2 q% g .gpio = DA850_USER_LED2,
4 ~- D; u8 Q- Y8 I# J .name = "user_led2",8 U" h: ]2 X' D1 Z: C* \0 O
.default_trigger = "default-on",! n3 [6 l. S" {" ~! X4 {+ |1 }" ^: W
},1 C$ C+ L, r D& {6 L2 ~
{
) }. j( k9 F6 h. g1 f, p .active_low = 0,! r- ~; L3 R+ y4 A
.gpio = DA850_USER_LED3,4 G2 ]! I4 M+ X1 [
.name = "user_led3",5 d7 Z) _6 C; Z$ G9 \$ S
.default_trigger = "default-on",! M4 r4 Q- P* U4 ]" X, q: Z
},
; x; A% J0 U" |2 N1 {% m; R};/ L g# o* }, ^: a
+ z6 X9 |( O; X" M( D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) p1 ~$ }; q% J8 Q9 `; V .leds = da850_evm_tl_leds,2 @$ [$ i# ?4 P4 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ P7 ~/ P' \' L1 \* V/ F0 p, K6 {/ F
};
1 A% K7 ^& o7 t
8 k, \2 i* r0 Y. Q1 jstatic void led_dev_release(struct device *dev)& I6 T1 s$ h# p( n
{
; T C1 u% i M( V- B, n& I9 Y6 v};9 [7 Y+ P; ~; u% e4 P+ A; l8 G
' m/ J( u- b+ \. U$ h8 C2 _static struct platform_device da850_evm_tl_leds_device = {' z& m: B7 X) b1 m- |9 g2 E
.name = "leds-gpio",
: {: N3 p9 V* r& w# V. c .id = 1,, g& }5 R! {+ t2 ?
.dev = {
) b7 A, K" B/ L* X8 z2 j$ J .platform_data = &da850_evm_tl_leds_pdata,
( [1 [, T6 n5 N) c4 y .release = led_dev_release,
0 F5 k5 c. H) \4 U }. N+ }7 m- f6 C2 k! Z6 D. ~& [
};
& U6 J5 ^5 Y8 z, J6 g" _. h" ?. M ]* g
static int __init led_platform_init(void)) [. }4 v8 @( m' X
{: A- L. Z, b% ?" h4 j( ^& |
int ret;
; I! y+ c* }, B5 o#if 08 O& b) b! F" O% |8 i$ `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% g8 [/ ~# h: @: Y0 h0 P* J" c
if (ret)6 N" C3 i$ [* l0 Z7 U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 r/ j: k. m9 F+ [ "%d\n", ret);) F. B2 Q& I3 W* X/ Z3 W) |" A. [3 d
#endif% ]3 C$ |( R* }: l6 q+ k" `6 i
ret = platform_device_register(&da850_evm_tl_leds_device); [) P1 J3 w5 P$ v. G+ c, _3 A. C( B
if (ret)
* o" x. b2 X" D6 f) w5 C pr_warning("Could not register som GPIO expander LEDS");* ?. v* i Z( A+ F- l5 w9 Q" z X
else
^( E; X o; y4 }! z \ printk(KERN_INFO "LED register sucessful!\n");
`/ B$ w8 D0 s, S
4 F& |: o3 j* J/ ?5 P6 E0 c5 O0 k$ F: O return ret;8 W# }! m) n4 S q" x
}
1 }( I: o$ F1 u: O; T3 |9 \0 ], i& F4 l1 t6 F% [
static void __exit led_platform_exit(void)3 @6 X. p$ t8 k( T/ F
{
) v! p) p; }: H9 H. [" b platform_device_unregister(&da850_evm_tl_leds_device);
5 B% @9 I4 e" ^# P$ B; t8 [5 s4 U2 }+ J) t. K; v i
printk(KERN_INFO "LED unregister!\n");
- i1 j9 N I* i# ?. N& d$ ^% E @8 _}2 Z2 S9 v F4 n. h8 }
9 M: j: }" q2 |+ @+ A4 L7 T# k
module_init(led_platform_init);% m6 Q" r$ M+ u8 a
module_exit(led_platform_exit);( U4 E/ N9 `+ H% |' Z5 K
: q9 W- h/ Q$ m' ]2 _- J8 [* kMODULE_DESCRIPTION("Led platform driver");
3 ~! \4 Y) A* a1 }" [$ y3 ^( u$ @' ~MODULE_AUTHOR("Tronlong");
2 g' V# C Q! x$ ]6 R. c w* XMODULE_LICENSE("GPL");1 l, e' j' q7 c# ?+ ^
; X/ ]) m5 Q6 h# d/ C. B2 n5 T
|
|