|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( ]7 l4 b! [, ~/ v#include <linux/init.h>& ?3 F2 u5 i* n5 r2 ]6 U. [/ ^
#include <linux/module.h>. q+ W7 j7 ^9 P. w
#include <linux/kernel.h>
) b: N" ~' S' Y#include <linux/types.h>! k: V" T0 s3 {" U$ S
#include <linux/gpio.h>; K4 t% D, \! y0 }: P. q% F
#include <linux/leds.h>
" U2 E; Q# ^$ [, m#include <linux/platform_device.h>
5 o7 U" L: e) o1 {+ f
N* S% R' o7 n#include <asm/mach-types.h>
3 _# z& y: }. l% o9 Y7 [6 w#include <asm/mach/arch.h>
9 s" s% S5 q+ S4 g. E#include <mach/da8xx.h>9 n4 Y @! v9 w1 [" b% w5 X
#include <mach/mux.h>
5 J% ?; `6 _# n( d( k% @& @
* W. p) e' a, H. n5 F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ t. ^8 @2 ]1 x- @$ q9 k% Z6 f$ G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); n- K0 r9 h8 U1 ~3 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# j) a0 b1 Q- G& Z5 l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ Z9 j B2 a2 v4 S" E
9 s/ l9 D9 a( `+ B* S/* assign the tl som board LED-GPIOs*/9 `5 z; i/ P, W1 P# u
static const short da850_evm_tl_user_led_pins[] = {& U/ Z5 t! B4 a! `7 m& X! T
/* These pins are definition at <mach/mux.h> file */
# P& A. h, J, b* x& J6 [# A# D3 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% }$ t5 C# z' G. _% @9 f
-14 K. b8 U6 s" @& e/ a" m. `
};" y5 U* a) p1 m% V- p" y" H
7 z2 E& x! l$ g5 C! b& F
static struct gpio_led da850_evm_tl_leds[] = {
5 ^8 f! [" h) a! t+ K$ W( k4 O {
* X; V- U/ W" u: [" W. w6 R4 b .active_low = 0,0 [3 v2 k9 M) m- b" z* a. v' ~. t
.gpio = DA850_USER_LED0,
# o, {6 h9 c5 [: q8 q( s/ [ .name = "user_led0",& L+ s, p( v9 B+ K. `! O9 J8 L! R
.default_trigger = "default-on",; G9 _8 H4 W) z. b1 a, w
},( c+ t2 X! B- z% v8 ^$ Z" Y
{
% n. i' x6 E8 ]- U( @" ? .active_low = 0,& S" o. k4 z* {' W- ~
.gpio = DA850_USER_LED1,0 o# m- F0 y& c( T% n
.name = "user_led1",
# e3 e4 A3 a$ i2 O9 j+ }9 ^ .default_trigger = "default-on",$ b1 V- V$ n- u& Y( x# j7 J
},
7 M9 k d! v3 J% v. y {
2 K' s# _1 Z4 M% Z) z5 I .active_low = 0,
6 [% N6 ?- U3 s9 I5 V. T .gpio = DA850_USER_LED2,/ C U$ F# p* j6 Q+ Y) t, @
.name = "user_led2",
n8 \8 V/ v% Y% q y) m .default_trigger = "default-on",7 [0 l- {9 x* i& U9 {. |3 v
},; B" j8 x9 v& J0 ]6 ?
{
; T& Z8 R' C9 M; m/ C .active_low = 0,
6 {" N, v. T# [1 H6 w7 s .gpio = DA850_USER_LED3,
# C6 g$ s% X4 G7 P/ y .name = "user_led3",. I# d2 f# \& |9 B w
.default_trigger = "default-on",
& U% N" \, l H# Q/ z# y% F },
9 F9 E1 C/ k1 z$ |. b/ Z4 m/ L' ^};7 |# J! ~) n0 h' {
6 [0 |- a8 i6 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! y/ ~7 J2 S f. q
.leds = da850_evm_tl_leds, u! L1 ?2 e z8 j' I$ V I, f1 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: Y3 k% f8 T+ Q, |9 b- ]7 J
};0 [: e" y" R2 B" c, ^. F( z
- h2 j6 w+ b+ B+ B. ]2 X) Bstatic void led_dev_release(struct device *dev)
; U" m3 S/ c2 o( X8 Q{* m$ G5 w/ j+ N; J
};& u8 f0 ?2 W5 f' g6 F0 i# C7 ?7 o0 w( y
( [8 T8 x L, R" a
static struct platform_device da850_evm_tl_leds_device = {* j ~8 Y9 G9 Q9 w% O# o
.name = "leds-gpio",
. e, |+ J! b& V( f# {4 w .id = 1,2 ~; F/ w+ B4 j' i$ m# z( S
.dev = {
7 p$ b- n9 j: E5 S" C( v: D- _ .platform_data = &da850_evm_tl_leds_pdata,- S8 |( C% D- }) [8 B
.release = led_dev_release,5 H/ ]0 A& Y- @! t
}; p ^" d% G* Q, ?; q; H
};$ ]) i! n( F$ F- p. h& E
4 j' @! m% \0 f& j B6 f
static int __init led_platform_init(void)% [3 {3 `: I2 F1 x% k
{3 X/ \8 P, T/ x. I1 I' Z
int ret;
/ h3 i' C: g+ a7 F7 s, C% v#if 0
' V( N9 i3 a. _8 L+ w T/ x. R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ s0 z* p( z' X0 ^% H
if (ret)
+ D" J/ n1 u7 _( F1 p1 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* \9 i w, r) m$ ]; |$ A. W
"%d\n", ret);
1 f$ J( {+ t9 ^#endif* m7 U( A: b- P7 _( w
ret = platform_device_register(&da850_evm_tl_leds_device);& }: v: ]! b% H7 y7 o2 L
if (ret)
+ g c: q9 Q6 h& x4 C1 s pr_warning("Could not register som GPIO expander LEDS");8 H0 w2 b; }2 h, k2 L
else
. }- v! R/ x3 F' R printk(KERN_INFO "LED register sucessful!\n");
3 _' M2 g# B3 o' `( Y9 y
6 S$ w: p: u$ e8 G return ret;, F7 h8 W( Y" J6 u
}/ F' n7 F. |) G3 w0 N
" N0 q) P# E9 t' f% l& qstatic void __exit led_platform_exit(void). Q. j) l+ E! P7 E; o
{8 K7 H4 L2 D' n
platform_device_unregister(&da850_evm_tl_leds_device);
$ e6 E$ ^* z* a+ K$ y4 W' ]0 w
: x. i6 z* D1 E1 K0 W# }! D9 U- d printk(KERN_INFO "LED unregister!\n");
& F. N' x4 m2 R V$ V}
8 O$ x4 C" m5 q9 j" i) k- L3 t
; c- {% ?9 t4 z: q$ W* {module_init(led_platform_init);4 [" ^# t" c+ s5 C" M# h- l
module_exit(led_platform_exit);$ _5 P) P: `# h. A; ^
1 H) F* ]% i7 K/ u9 ?MODULE_DESCRIPTION("Led platform driver");" y4 P7 m5 c) K5 C" ?8 ]
MODULE_AUTHOR("Tronlong");
% f1 H0 a$ L% j5 WMODULE_LICENSE("GPL");
, O7 }! l# A8 a3 D
0 ^" |+ |6 D1 W2 ]* d |
|