|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* B% g* y# ?$ u3 P1 [$ K
#include <linux/init.h>
, E# p/ f( w8 `: e% a#include <linux/module.h>; B: d) G9 B' r) m
#include <linux/kernel.h>4 J! t, Q8 z' }- Z/ W9 a5 d- \! o
#include <linux/types.h>
2 d) ] @) g% Z7 w7 H1 ^#include <linux/gpio.h>
$ ~. i* x. w+ A& V- N) P6 s#include <linux/leds.h>
1 ]$ k1 g% |& I& P* G* P( M#include <linux/platform_device.h>
7 M; w- ?" o( l: [; U6 S
3 K) N* c6 {0 k#include <asm/mach-types.h>
8 M w ?, s: c3 b$ q0 H4 t#include <asm/mach/arch.h>
8 D# ?% a' m; @3 E( ^- w6 C#include <mach/da8xx.h>+ s+ i Q6 N4 f9 k+ p/ C
#include <mach/mux.h>5 f. `' u o- p7 f+ f6 \5 a
8 k" d2 F% H0 U) D* H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 V1 w1 m9 J/ @& K2 n9 D$ e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: f8 U2 ^" C b1 H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( y) X! R# X0 X9 l$ Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 V6 s+ u; P8 q5 j
. H4 O8 g6 W' [& _! _/* assign the tl som board LED-GPIOs*/4 K$ W- y+ n$ r+ N
static const short da850_evm_tl_user_led_pins[] = {
& _' B( [% C) c+ s& e3 m! p. X /* These pins are definition at <mach/mux.h> file */
4 i6 |/ z2 e" u5 Y# y1 i& ]0 w5 G, ~7 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% P& g, Q7 O6 l- X) d: {- v% ?
-10 i- a' E5 Z6 w: n
};. d' F, C; o2 w1 [
5 U# h! M: g0 R' tstatic struct gpio_led da850_evm_tl_leds[] = {5 w8 H r: R$ n' a6 g0 w( b
{
: ], @. r6 a0 c! c; y .active_low = 0," Q9 X9 d! k6 n/ I5 e
.gpio = DA850_USER_LED0,4 r9 k; p! r @7 R" Y6 t
.name = "user_led0",/ U. n, |. L) ^/ r- T: N1 {
.default_trigger = "default-on",
% U8 M9 r% j# a3 B/ D# \ },
6 i6 [3 Y; a9 A {( B8 _, e$ f5 q6 a4 G' q0 m
.active_low = 0,. w& x: f. H5 V, @% i
.gpio = DA850_USER_LED1,
$ ^$ V$ D6 j* _9 V2 p .name = "user_led1",
9 g3 G) y* ]: p5 U" s .default_trigger = "default-on",
! ?# N8 s: J0 \' [+ C: ^ },
4 c$ A/ @( u, ]; m! F4 n5 ]5 x& o9 w* D {( x3 Y8 l8 C D u1 @8 T! w
.active_low = 0,4 ~" p/ D' J: I# U9 b
.gpio = DA850_USER_LED2,
$ _+ }. w! v: [: b, J% a7 T6 v7 } .name = "user_led2",
. L5 K8 [2 S& X$ |. J4 a, Z .default_trigger = "default-on",
2 O$ \6 S+ \7 r },
1 s+ {: H9 J6 H {/ d8 }& f3 y* m5 @
.active_low = 0,
% R0 C9 f) [0 N* b8 ` .gpio = DA850_USER_LED3,
* @, f" D% n4 h) a. N5 `; H .name = "user_led3",
/ V% j1 T2 U+ N$ a# z3 M+ ?8 v .default_trigger = "default-on",
2 ]. N& Z& y# D3 G& C },6 b4 G4 s0 F" S2 v6 A; @
};8 | D4 f. y" k. U2 k
9 T/ d1 y, ?* M% j& }# P# h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 P: y5 e" z2 T .leds = da850_evm_tl_leds,# H& v! r5 l9 w. r1 d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" P2 O. P& W. o/ U+ C};' j0 m$ T& t9 m1 y# j; p: y
- E7 }5 J/ Z# O: L, a5 i0 n. Dstatic void led_dev_release(struct device *dev)
* \8 G- Q0 `8 S, H" O; E- R{
! d4 U4 x2 `9 x& h/ q* i};
0 B4 | H8 c( i4 k) i
: [+ ?" R/ J g# v% ^. j- M, qstatic struct platform_device da850_evm_tl_leds_device = {
0 e) t4 m& _& f' n3 V& |5 d" h' s% { .name = "leds-gpio",
" ~6 ^! q* u/ ]* X& O" _5 d .id = 1,9 d* V$ f# i: P/ t
.dev = {
. V- t7 M( p( w$ q .platform_data = &da850_evm_tl_leds_pdata,
, d- E# i' ` T; q H .release = led_dev_release,
, m; O8 @+ d1 D' j! K, M5 |' R- _8 n2 U }/ A! U3 Y5 J6 a% }0 @7 `" I
};
8 o! _3 B. p2 n
' {$ J9 q3 b/ b6 X% y" pstatic int __init led_platform_init(void)1 g- }! M5 K( ^- e- A6 E
{
6 S3 e3 ^( B: Y4 {/ t8 c% T1 B B int ret;
' @8 t# c! R5 E8 o+ m, m#if 05 P/ C8 I+ z% v" ^4 |3 w; _% c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! C) b" u, B' d7 F! q n9 `: U( \ if (ret)0 D L0 r% P2 V' y9 l6 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 V& p- s, V. D# A- ]- |1 K! Z! d "%d\n", ret);
/ k8 [$ |( \/ x#endif
5 `1 N% t8 Z3 F( n l) b ret = platform_device_register(&da850_evm_tl_leds_device);
0 q7 ` ]- j2 g4 L/ {0 ~5 o0 T) E if (ret)9 c% n' v3 ^$ s' f3 j
pr_warning("Could not register som GPIO expander LEDS");
1 ]) {; ^3 z% B7 u2 O! i' C else
% ]) V' I% e: o! U# ]; g- Q( S printk(KERN_INFO "LED register sucessful!\n");8 s& Q( w+ ~5 D( E2 \6 d1 {
% V* i5 S" i9 K$ K3 c
return ret;9 A0 s9 [( D) D) H9 V, ?/ e6 R
}
6 J! P& {* J2 |7 f
$ k4 I( k. \; S# _& _static void __exit led_platform_exit(void)
1 ?6 m& S" U7 v- x C6 V{
U7 v" }9 J; g K platform_device_unregister(&da850_evm_tl_leds_device);& J0 j' ?" {* c- Z- C7 u1 y: d& H7 S1 O
5 q) V' W- Y5 N X2 D) z% v" L7 d printk(KERN_INFO "LED unregister!\n");5 T- b% q6 ]& y m, @; ?3 Y
}* r9 @+ G% O6 ?
8 x' Y$ H G: f2 b" Bmodule_init(led_platform_init);, ~. S; p' P8 I+ G3 {
module_exit(led_platform_exit);
0 P& i% h8 B7 P' ]1 k: E/ S% B
$ U" J2 a' p; |; g0 O! oMODULE_DESCRIPTION("Led platform driver");, K7 o4 j6 {: Q- Z
MODULE_AUTHOR("Tronlong");/ S/ P* R) }3 `" B
MODULE_LICENSE("GPL");. S9 F j2 h2 W: g
# w: H, B2 A1 `- b8 s
|
|