|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 Q* w3 U" J( u+ D. V: ]. }7 h
#include <linux/init.h>
* ~& q& h w+ ~" I#include <linux/module.h>+ A) V% v* m2 m" |9 P) C# S1 }* G
#include <linux/kernel.h>
x' M6 P0 K, K0 J& F#include <linux/types.h>* r1 _6 v4 M2 B, [7 Q* _2 s
#include <linux/gpio.h>
5 |1 M2 A! g$ A" x: ?#include <linux/leds.h>
- J# Y9 p: s; c4 ]6 Z8 v#include <linux/platform_device.h>
. ~, f( g, {- D( E4 Y. X
7 P! s* d& E3 `% X& p" r. e; F#include <asm/mach-types.h>
9 M- h* s) H8 W) S1 w8 N# j9 J#include <asm/mach/arch.h>
& Q0 o* ?' E( l7 A! k d( ^#include <mach/da8xx.h> ?" `! p4 ~) E/ Y2 u& B" g
#include <mach/mux.h>% ]1 ?. c6 |6 X
1 a- q1 ? K0 Y- M8 D. `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 }- Q; c1 @( P) R8 n8 U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) W- j3 z/ h% [ K% v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 z% U- B% M t4 F ^) }3 n- c) ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* y" E+ {- T0 r/ [7 L; P
3 d2 `6 e+ j) Q6 }! g" ~: \/* assign the tl som board LED-GPIOs*/
; N/ a4 ?. t- P( ostatic const short da850_evm_tl_user_led_pins[] = {
& Q' p; f; D* b6 z/ K2 f" T /* These pins are definition at <mach/mux.h> file */. F' r, w7 N. s2 h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ B3 T, l/ b' I3 ~/ q -1$ S3 R0 ]$ m; [& T2 ^( L
};
* i8 O, ]+ x, Y. B2 H' _3 o; S# _
/ y) E* O+ s7 Kstatic struct gpio_led da850_evm_tl_leds[] = {
0 F; `7 h* F; a7 i- d+ R/ D {
3 w, |/ @( t6 T/ ]3 W9 \. j' R .active_low = 0,
: d4 y% `& H) O- B: Q3 _4 q .gpio = DA850_USER_LED0,
; p4 r- w; t) T" n% h .name = "user_led0",
b! K: Q) k; A, S' u .default_trigger = "default-on",
. Y& g, \. t4 } t* J },, _8 J$ k1 U5 @
{
& ^7 y) j0 [) f) M4 g .active_low = 0,4 y! J9 ~8 b: F; P
.gpio = DA850_USER_LED1,) v3 b# M0 t; g+ T A0 D
.name = "user_led1",
( p0 w6 _6 [# {9 c8 R1 W .default_trigger = "default-on",
. i& l; e# S9 ~7 B. \3 k },- B" e6 ?. |3 r& ^& N/ `: Y3 b. b; e( V
{
* ^% l; y' J9 S, @. ?, u& g .active_low = 0,
7 Y: `6 ~" c9 J: a; D! J; i .gpio = DA850_USER_LED2,
. W" E# A( H4 k. I" Z! r7 F .name = "user_led2",
7 E5 s. Q Y7 j .default_trigger = "default-on",
/ C+ L# ?6 c+ e1 t },
0 g3 G1 T. \7 r( U. w: {/ q- R5 r {8 z! K9 h0 k( S2 J
.active_low = 0,
: @1 k/ C% O, o/ h6 C- } .gpio = DA850_USER_LED3,
/ ]! ?) ~* e6 i% P! Y; j .name = "user_led3", F* F; d0 n2 \7 w1 z
.default_trigger = "default-on",0 Q& C8 u: @& o; m3 v9 s! K
},' P/ q6 ]- H9 ^+ } R
};1 b# N% V" p0 Z Z0 a2 t4 Z- t
$ O6 R7 W, R5 F" ^, B& Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 B. R3 V. N0 \8 b6 ?) e7 c .leds = da850_evm_tl_leds,6 \( J* O Y4 E4 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: [% ]# o2 P3 ]1 h" D2 x};
5 ?2 G% U6 G$ M8 n/ J F8 W% P7 x" z j- ^/ `, B& y7 N9 N
static void led_dev_release(struct device *dev)$ s# }& U$ ?- [) l5 l- i0 G; G* \" ~
{
, S, Q& F2 M; a) D};
0 Z$ e6 N2 p) r9 T2 X @3 T. c
* J f5 j9 _) O4 [* c! ]static struct platform_device da850_evm_tl_leds_device = {
' q, n) t7 Q9 W5 T .name = "leds-gpio",& k% g5 Z4 Z \/ |1 f5 C
.id = 1,7 a0 M& Z7 Y& n5 q4 F) r
.dev = {
5 V' u8 r: y! _, `# ?* m .platform_data = &da850_evm_tl_leds_pdata,& i( q k" d- V" r8 g
.release = led_dev_release,% K: P) r8 t1 h. f
}
0 [3 T8 F4 F# k: u};$ M3 a- [& Y0 ?1 s3 M
& S1 ]/ ?! M# ?0 a: F+ y3 R
static int __init led_platform_init(void)
- A7 U0 Q9 w8 I" z; D# s{
x4 o6 l# u/ q% }2 h int ret;
: R, v- A; G+ D+ q+ j7 M7 Y#if 0+ c+ B( E0 ~2 \: V- H& _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% F1 Z# K: k8 I if (ret)
7 n3 R+ g% c$ z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ z6 _0 `, n0 m; @6 _6 ~
"%d\n", ret);: O- D% r6 @. J. z* D9 Y7 T' D
#endif
& G- `1 T2 x: s$ h1 S( h ret = platform_device_register(&da850_evm_tl_leds_device);
# N& c) s+ _" w+ t& @+ o if (ret)8 V7 B! J9 n) Z2 T, \; X1 ^
pr_warning("Could not register som GPIO expander LEDS");
! U1 B2 x( p* l9 W else
+ N$ J* A# R% Z+ z" E7 z: N7 P, Q printk(KERN_INFO "LED register sucessful!\n");0 [( e7 m( q1 M
$ i' R) r, P g
return ret;
! M: V; f! a1 T}
% [. |2 z- ^7 F, b5 [. E
7 T$ {, X+ e; R* T$ Y bstatic void __exit led_platform_exit(void)
. I; I# B$ l! \{- g+ x! v6 ]# d+ b$ b. |2 |
platform_device_unregister(&da850_evm_tl_leds_device);
5 k4 i% k0 x! q2 M: B6 m, L) I# m0 q* D' r
printk(KERN_INFO "LED unregister!\n");% U" h8 J5 x2 x1 }' Y* d6 C% V
}* X O( _ ], ^& C- z; ]
! [) ~3 h3 R! h& O; E7 t
module_init(led_platform_init);0 r( s! M0 q0 x/ ?
module_exit(led_platform_exit);9 \0 c0 c1 {) B6 f4 u% |
1 @0 F; f# _; {( nMODULE_DESCRIPTION("Led platform driver");3 v5 y' S# U$ A: W! u
MODULE_AUTHOR("Tronlong");0 c! r' d# G/ ~% C
MODULE_LICENSE("GPL");5 |: ~/ y1 S% R
+ S. v7 R$ ]( [ Q% g+ G/ w- k
|
|