|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ?6 ^; [( n* t9 k# B
#include <linux/init.h>: g/ M% ]" P# A% U# G
#include <linux/module.h>
4 }0 d6 Q; O+ _% k3 }3 P$ y#include <linux/kernel.h>
- _' F& s9 \& u& S8 |7 K" I#include <linux/types.h>( `% ]% `# x, q1 G
#include <linux/gpio.h>
, ~6 Y% d0 r9 a6 g+ U: z#include <linux/leds.h>
. A3 U1 r8 ~4 b8 L#include <linux/platform_device.h>( ], g+ ~, W! m
; y. d9 a- O7 q* g#include <asm/mach-types.h>
. r6 V0 e$ l* `#include <asm/mach/arch.h>, ?( z7 Y% P0 S$ }- E
#include <mach/da8xx.h>; ]$ t' @ X1 T* B7 G
#include <mach/mux.h>
& i) K9 x3 ^1 T3 m9 j/ U0 m( H+ B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! M- W7 v9 v3 [$ F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 ~; X1 n D; p1 R3 J6 G4 i6 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" `! w. `3 o* r) C! F9 }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# T& m9 ]3 i/ Q0 L5 J, n( r, C I3 x6 f* D% F* z! N
/* assign the tl som board LED-GPIOs*/) z0 n6 k8 |0 s, u
static const short da850_evm_tl_user_led_pins[] = {* m; U! I* [8 q8 o! u8 V. K
/* These pins are definition at <mach/mux.h> file */9 g! z8 S/ \7 z+ U( _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ W9 {* Q8 s) O+ { -1
6 a M# ?. t; L, J% }! \};
2 j3 N2 j) s* m. o
: e1 I) \) R) M# e; |! ?static struct gpio_led da850_evm_tl_leds[] = {6 p2 t( W$ r, p2 u; u2 L
{
7 X: Q) E( j e* h& q7 F, I% E .active_low = 0, C7 j6 r! C% P) S
.gpio = DA850_USER_LED0,( D& i* ~& H% I6 v
.name = "user_led0",, R1 Z4 l0 X! S: o' E. W7 Z
.default_trigger = "default-on",8 x9 m$ @$ y) v. F0 _5 r4 S; m- m3 ~
},* M, [/ \/ J5 h& N. G; M1 V
{1 a. L1 G4 z8 P* c
.active_low = 0,
, A" w5 T4 Z! V7 ] .gpio = DA850_USER_LED1,& X' q4 Z' j, A! P
.name = "user_led1",9 s: n& r3 O: j. Q/ R
.default_trigger = "default-on",- E2 T) y* m4 J. x1 ?3 E
},
7 \3 n. d% f) E& x: U! s {
* t/ G% F: Z; L* Y .active_low = 0,
7 y/ ?& Y/ v' K { .gpio = DA850_USER_LED2,( n2 O3 F2 V& u( t$ M
.name = "user_led2",
R0 c; o# j$ T3 |3 _4 J* D .default_trigger = "default-on",8 O. @* J$ l2 o, u
},8 P3 R- v* j M- l+ Y$ U
{
. ~% r; i5 }+ m/ Z: J4 H& D .active_low = 0,
+ q! c5 A$ m- [ .gpio = DA850_USER_LED3,- e: j6 |/ D# ?- |( G( D
.name = "user_led3",
# H5 }6 L0 E; ~9 r5 d9 e& ~) H& \ .default_trigger = "default-on",
! b4 v. ^( i$ b6 P },
7 i0 z m' C" E @};9 ^6 M* i/ M( P0 t
5 I6 Q0 Z3 D* m- _$ _, ?" ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. k! M! w8 @" l8 O& g/ F; i .leds = da850_evm_tl_leds,
e+ J. k1 _) } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ T, ~! u0 V) [) t5 E0 ~7 A2 y0 }};1 u$ c! K$ [. H/ b8 k
" X3 N p/ t' ~& ^+ }static void led_dev_release(struct device *dev)# h, |2 O8 }3 l# O+ R6 o; @6 K; ]
{
% C' L9 O( `& ~7 `# {* m: m};2 C! z' v( I. A/ u. O7 V* c2 h
9 S3 w# e9 z- ], \4 A; j* W; F- @+ ^! @
static struct platform_device da850_evm_tl_leds_device = {
& d! K: w2 t" s7 n& M .name = "leds-gpio",
& u# |* b2 P; D/ w3 } .id = 1,6 U* W, t6 b7 N9 x! i# j" V
.dev = {
( d' s# B, d" W5 L$ d1 E/ s8 c .platform_data = &da850_evm_tl_leds_pdata,
3 y a6 r* r8 Y/ }% ]2 r .release = led_dev_release,
1 `5 `# G& t3 V; Z }. T7 P& ]5 W8 R& o8 V
};( d# b5 M: S) L8 P7 J# s5 ?
# z! d) y4 K J& [: K# |/ r
static int __init led_platform_init(void)$ ?# n1 w) _6 h! O! Q5 Z3 E
{. b% `; }, c; q/ A0 E/ j# n/ P
int ret;
9 e) Z" R$ D, v5 D" ~9 [ x#if 0
0 P; {+ @' [; [1 n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 G' E6 M. {: `) z: C4 w
if (ret). [2 w- G- u' f) R0 ~$ ^- i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
U: S, v$ X4 j7 t; B( @ "%d\n", ret);
8 G0 G4 a6 Q# u Q9 V#endif, U4 `, ]1 A0 {+ b1 i
ret = platform_device_register(&da850_evm_tl_leds_device);: E* H7 x; d) e: y3 k
if (ret)$ Y+ I& H( o& e, ]% |% G2 ]
pr_warning("Could not register som GPIO expander LEDS");$ H8 h1 k* U$ ?9 _9 ~# n
else
5 Y9 R8 o6 F: O+ u. w0 C1 n- M printk(KERN_INFO "LED register sucessful!\n");
$ P/ D; j' W; B! C' z8 F, w) x
return ret;/ K0 n- j- w* q' @/ O1 q
}4 s, {* B0 u/ Q7 D- |
8 e/ c% F( h: D2 R- X' x4 F7 h, z9 v( w' Wstatic void __exit led_platform_exit(void), x/ H7 w- U5 X- t7 P9 ?- g
{
3 X, S2 u. c: }+ z, ^* J9 n& l platform_device_unregister(&da850_evm_tl_leds_device);
& h+ j8 K; l5 t2 Z. U0 e* M
0 Z( v1 c$ s' Q9 }* N printk(KERN_INFO "LED unregister!\n");* I1 q% _5 o) \" |
}) C9 ~+ \: O7 | x
1 v' B. p4 ^1 v2 `7 V- h, smodule_init(led_platform_init);' J5 u! _: F6 @ d0 q
module_exit(led_platform_exit);* |3 |2 u& @. }
& Y3 P! Z- r0 s* A9 b
MODULE_DESCRIPTION("Led platform driver");8 \% q: \. y P7 r Y+ s
MODULE_AUTHOR("Tronlong");8 q8 Q T9 L7 h! _4 n5 }6 w- N
MODULE_LICENSE("GPL");% }9 g# s6 t* K3 V- _& k
9 ]1 ]' F' A4 z$ x2 b! ]1 T/ k |
|