|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! w( ~% @2 _3 i! {& Y4 o: o, b
#include <linux/init.h>
c2 A0 g4 P0 l/ D; ?#include <linux/module.h>* G' d3 ]! F, _) x) D& P6 {) j
#include <linux/kernel.h>
$ V+ k9 ^ J! x" {5 b$ C#include <linux/types.h>7 t5 e/ Y& F; g+ D2 V: T
#include <linux/gpio.h>
2 ~0 s( w0 c4 \* D8 o: D+ _#include <linux/leds.h>
2 Q! k+ `, J" G#include <linux/platform_device.h>
8 G% i6 l& C' A2 r( ]/ T( s3 P
#include <asm/mach-types.h>5 m, y2 j( q: c' ^7 |
#include <asm/mach/arch.h>
% h1 I8 ^( I( x* H$ d#include <mach/da8xx.h>
- L* Q5 Q* X' t1 o#include <mach/mux.h>
8 P# t6 H9 x$ x6 ^+ c) Q
+ S% Q K3 s' g6 h* s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ N" X7 |) r- G2 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 B# R0 \ M; u- R1 p6 @6 i# Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* L; t9 ^/ }6 w) H( d& Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 ~$ w7 D, Z7 E5 ^2 |7 P/ p
: @ P1 k$ u! ]$ p
/* assign the tl som board LED-GPIOs*/
! Y) I8 I$ |' {7 e+ lstatic const short da850_evm_tl_user_led_pins[] = {4 Q( l; p/ P4 }' u5 V
/* These pins are definition at <mach/mux.h> file */
) X0 H: k0 U0 l, ^$ ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Z" [% R$ _+ G -1$ A! ~. ^. p ?; }8 B
};3 }/ O$ l, H- B/ q# V8 g
* A4 q% T6 p" h6 Q) d) z
static struct gpio_led da850_evm_tl_leds[] = {
7 j* z. A1 Q; ~; t {
2 E: g% c, L+ E s" X .active_low = 0,
$ R7 [) @) C2 U* w .gpio = DA850_USER_LED0,
% }& I6 \3 }2 ]6 ^/ j .name = "user_led0",- ~3 l, i7 n+ L9 [ t
.default_trigger = "default-on",
7 {7 F2 X8 i! ?. J) U },7 v3 w) k4 `& p; q1 F: p% S
{
1 J) E3 A! g6 L0 Q; `) t .active_low = 0,1 f; [& l9 P+ ?. l6 t) C" O
.gpio = DA850_USER_LED1,9 S/ l5 m8 M' X1 A
.name = "user_led1",
8 f# d' B. h% v! k B .default_trigger = "default-on",# |0 b l; D, ~' J% X7 ]4 }9 Z- ~
},7 u u6 ]: K+ ?, q
{
' m& p" D; b9 \2 d- n! O .active_low = 0,5 f) T& c# x: U2 A( L' ], n% P! @% D
.gpio = DA850_USER_LED2,6 N( Q: C+ L! F
.name = "user_led2",6 e. b* C9 z1 ^- @% a! v
.default_trigger = "default-on",
8 F' I* g0 J' e3 M6 R+ z },0 r5 h$ m3 |8 r0 Q. ~% V
{
: ?2 u7 O- f8 V# J5 \' }) ^ .active_low = 0," f1 p& V* |2 G5 T9 P
.gpio = DA850_USER_LED3,$ H- `9 e5 r9 a) A1 K" w& r+ v/ j
.name = "user_led3",! L* l* ]2 D4 a
.default_trigger = "default-on",1 R$ X6 b: m3 |
},% r# t1 a! u8 x+ m/ S9 z% l4 `2 t
};
7 d' J' p: u* j; L% a, x$ ]6 G% G) m1 V* @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" r+ m! Z2 u* W' r .leds = da850_evm_tl_leds,# `) s5 l0 q5 i( }2 M5 U9 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 `+ t2 t8 ? D3 ~8 j: l};$ a" M. \6 [8 P$ T) G' f3 ?: i" j
( W Q t% s0 r& M0 Ostatic void led_dev_release(struct device *dev)6 ]3 F; n$ K& Z. o! S
{
2 ^ A( R2 p t};7 n8 r$ d7 s$ p) S6 b- x! D, I
+ a8 x% H) k' j! e' q7 z
static struct platform_device da850_evm_tl_leds_device = {
+ p9 A2 o. T- [$ Q- | .name = "leds-gpio",7 p' k: y* \, o( l5 ]
.id = 1,6 D2 {( l. `9 R/ K6 r7 @/ {
.dev = {, M" ^1 x9 }( U! K( P9 E n
.platform_data = &da850_evm_tl_leds_pdata,$ O. z% x& s4 o3 q! n) G6 P% r
.release = led_dev_release,6 r% |# O% J4 i: }, ]. j j. C7 U
}
5 k3 J7 O; V: D4 \1 @" f};
9 }" a" ~, C% K
; n2 i( E6 _, k1 s3 M* Ystatic int __init led_platform_init(void)
+ V4 g2 f: j9 T1 b( i/ k{
, V/ N9 i m' W# y' ~" s int ret;- i( X P+ ^3 Y" y6 m0 G) [
#if 08 M8 |, M! [$ z% D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 G! G/ j' @( P4 f2 k. O" s if (ret)
) k/ [4 y3 f; p+ L$ t; h$ ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# L' k4 |2 H. n- y "%d\n", ret);
( L. d. J9 U- w0 \4 c: o#endif9 a! i/ h2 r1 l: j9 h; S" Z8 A
ret = platform_device_register(&da850_evm_tl_leds_device);
0 q7 L0 p! t) X if (ret)7 ]2 n4 j# p L$ _5 s0 \
pr_warning("Could not register som GPIO expander LEDS");. h1 t+ L A$ O" N5 r5 v! L: w
else v, [- O+ W" m' A. k
printk(KERN_INFO "LED register sucessful!\n");
8 Q s2 i8 y6 s0 M) s- C4 ^$ F5 x
return ret;) Q( C7 ? x8 i5 h0 P
}
. U, d$ E7 x% M# c9 w" ^- k7 r* X+ n' Y" z7 U
static void __exit led_platform_exit(void)
. Y- N3 P' B/ c. p" @1 G8 t{) p# ]. U0 z p- W' `
platform_device_unregister(&da850_evm_tl_leds_device);5 H. R9 J8 C/ T) S( ?) \& ?
! Y" {7 s! J; x! N: R/ u5 `
printk(KERN_INFO "LED unregister!\n");
$ n: l5 F, n% `3 S" ]: r}/ o% N# T0 ?1 T
+ m+ W( c6 q: E/ {8 Fmodule_init(led_platform_init);1 M) v/ L5 Y @) E
module_exit(led_platform_exit);% a+ Y+ M: H0 }9 g, _1 s5 k
. ?( `$ {- i) m3 z( s9 Z
MODULE_DESCRIPTION("Led platform driver");
/ A& E6 |1 `* ^1 B! z' X" l, S) yMODULE_AUTHOR("Tronlong");
8 _) t b. \4 U& D2 |! s9 sMODULE_LICENSE("GPL");+ q" I' a! n3 F. V
( ^0 |7 k/ i- W) t |
|