|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 }; _0 {8 `7 c' o6 C" u#include <linux/init.h>3 C8 n1 _( t' r' q: H
#include <linux/module.h>
& s' A" z3 [- }, V#include <linux/kernel.h>
3 G* Z3 z* }$ q#include <linux/types.h>
: C1 Q& {, ]1 W5 k; c: v8 c#include <linux/gpio.h>
9 [' d2 D1 @+ _8 W9 A( P1 Q# k#include <linux/leds.h>) l* h2 ^7 ^# d3 o! R$ Y4 Y; A# c6 @
#include <linux/platform_device.h>7 M# Z6 w: b/ \2 H
2 N, t' }9 H/ X% o3 o' z4 F# J#include <asm/mach-types.h>
3 v k$ `8 @ [0 l6 K; w' W1 F#include <asm/mach/arch.h>
, t* C h, H; u- k1 F- g' b#include <mach/da8xx.h>1 C8 s5 _2 Q9 _
#include <mach/mux.h>) |3 i9 `- K7 x* J
& u* J5 N9 K) O9 ?4 f z9 ~# s9 Y7 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ T4 g5 w' p# k6 `4 X3 C' @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ e+ J9 V# j7 E+ X( b4 ?/ k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# h( h' |4 U Q4 ^7 @1 P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), Y, ]7 i4 m/ Z; f
% d, l& _0 Q$ ^9 F) `/* assign the tl som board LED-GPIOs*/( n3 \" X6 |% W, k5 x9 ^$ p+ h
static const short da850_evm_tl_user_led_pins[] = {7 a! d2 f4 a/ t o5 B, T) @+ G( I
/* These pins are definition at <mach/mux.h> file */
- e( [7 \' X" P& W) d/ B6 t9 K" v3 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! S/ a! P% c& M5 [+ Y
-1
) v) Y6 o. |3 b( G; b};3 `2 u8 v9 S3 c" L7 _2 M2 ~" I
0 ]: n$ b3 N! `3 F$ f6 X
static struct gpio_led da850_evm_tl_leds[] = {
9 Z2 J6 w# Y; l3 R; j2 b {
' P+ n6 R1 d/ N! I .active_low = 0,, |) r" l2 M6 O! J V# N
.gpio = DA850_USER_LED0,
; x0 s7 V |# b2 v .name = "user_led0",& u [0 ^4 ?- x1 ^& N5 u, ?) C' f
.default_trigger = "default-on",1 E% q% V: J7 ]0 [# s/ a S
},* m; m b( j# U4 k: Y
{
" A$ X, H8 A) ] .active_low = 0,
) X& }2 F) A- b S5 J .gpio = DA850_USER_LED1,; G, A, k( C" Q9 S+ L8 N1 V0 O
.name = "user_led1",
2 @; j7 g I1 r1 S$ W .default_trigger = "default-on",
" O0 g# B# ?3 _1 q* Z+ d1 v" L },
$ W. G" p% W# ^% a( ~$ | { s4 p# J( z# E$ n% G; ]
.active_low = 0,1 \9 y2 t1 \6 R4 E/ |9 v
.gpio = DA850_USER_LED2,' O* e. y& E. K9 _
.name = "user_led2",$ Q7 `: d1 a) k
.default_trigger = "default-on",0 M2 j3 D$ U3 B/ U0 w/ B [; C2 U
},2 n+ P% v+ g7 [0 V- k1 X! |
{% J6 O! C Q; j6 d& f
.active_low = 0,3 t5 D, e" E! `* [4 f: r2 L
.gpio = DA850_USER_LED3,
: a6 P/ y' x8 r4 W9 u! J .name = "user_led3",* m$ e* \3 L+ J7 o
.default_trigger = "default-on",
( v6 z* ^4 h3 {& e },
+ Q4 J% Y# R3 F N* p8 ]2 ^, l W};
1 u4 N3 E# u* E% t
* [2 s) R5 ], o! _1 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& q: I0 n$ R l# z6 h& K1 ` G
.leds = da850_evm_tl_leds,
3 |2 {2 Y* A3 y7 Q5 M/ {: I# t' N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: v# q* B8 K0 I1 I9 N/ T
};: Z4 F2 C8 W, _& `+ a7 r, r5 D
& o% f% Y( {' I& k, t, M, g& _
static void led_dev_release(struct device *dev): g! H6 F6 K; i, e9 {# }$ c
{
7 s+ j% o, X, g( d4 U0 [) H. ?};/ i! j) I1 j# @: t( c* E
; c! |4 _- u: K" {5 Y) E% Q& M9 Rstatic struct platform_device da850_evm_tl_leds_device = { [) j/ S0 R1 | G$ { B! L
.name = "leds-gpio",) [) X- h/ i. K g6 C' \4 x
.id = 1,) s8 j4 e# x0 p" T
.dev = {3 m, \5 R, g) z1 W* i1 }: z" t
.platform_data = &da850_evm_tl_leds_pdata,
" s( N! v: p/ V3 A# g# y2 d .release = led_dev_release,
6 c8 g* O4 g+ n) M* s }: L* t: O/ K* U2 Z" i
};
$ M+ C9 H8 S7 c* e! v
4 T1 m7 t" K& n' D) {$ K( Sstatic int __init led_platform_init(void)
5 w- K# E6 Y, {& B{
% b l: u, z Q5 j+ d: n int ret;; ^% X* ?, K5 ~7 w# H
#if 0
5 T1 G. q' F) i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 O2 C) h3 v2 V% U7 w0 \6 [8 c" @2 _ if (ret); R- l( Y g* A8 j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 M5 A/ B. E! P) n' `4 i- o% ^ "%d\n", ret);
1 a/ O& R- h/ U& w#endif8 q& \! D" [% }5 \: a( a- \
ret = platform_device_register(&da850_evm_tl_leds_device);
- I( M" @& C: ~" {# Y9 U; z if (ret)2 |6 | K% E: Z: {
pr_warning("Could not register som GPIO expander LEDS");# }6 q( d5 v% W/ c3 Q
else( r( v S2 W$ l6 E. W9 p) V: K
printk(KERN_INFO "LED register sucessful!\n");3 Q! O* v9 L% @
/ B) D3 R U# A: F& W: D
return ret;* k% U b4 |" E9 s9 L
}
, S1 N& `: G( Y9 S. B {7 L7 m! G" V/ J, k6 m0 J! x: Z" _
static void __exit led_platform_exit(void)
r! Q$ J+ ?5 G& L" @5 i{5 C' ?* J4 M B- Z5 Q$ X
platform_device_unregister(&da850_evm_tl_leds_device);6 _" }' v( A7 `: d; V5 H
5 u1 M, A4 n" z- A" v3 H u
printk(KERN_INFO "LED unregister!\n");
C( n# w, f5 O l: ?. i0 c) J}
1 l! o3 @: l: K5 {# }! _2 ~5 a r; {- J
module_init(led_platform_init);
9 L7 X g+ Z, M9 G' R; ~/ y5 wmodule_exit(led_platform_exit);; H- i7 n x0 d2 V5 N
- e& M/ m- E6 b8 oMODULE_DESCRIPTION("Led platform driver");+ E. q9 U5 x/ N* F0 ^2 s3 W2 a6 E: s
MODULE_AUTHOR("Tronlong");0 Q" B% q, U; r7 M
MODULE_LICENSE("GPL");4 w# o$ r! F1 v4 [
% C, O, m. D" k& ]
|
|