|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* ~9 K) w& m, Y. P( H#include <linux/init.h>5 P! a+ v' F) F$ Y' U- ~' g& W! {
#include <linux/module.h>1 |" K" V2 w1 I$ P) ]
#include <linux/kernel.h>
/ ? }3 t: A4 W#include <linux/types.h>
/ W& _- r' t- J6 G, o B6 ^#include <linux/gpio.h>$ ?! r; z6 l$ s% _" s' b- X8 r0 ^4 }
#include <linux/leds.h>
8 x- C* @1 ]% X8 N6 k#include <linux/platform_device.h>- a, Y. o% d+ m; R
* ]: [3 [- H$ {% j/ y* @
#include <asm/mach-types.h>; T& k6 i) c2 q4 [) V3 i# T
#include <asm/mach/arch.h>
* C+ M5 K& T+ ]& y6 T. O#include <mach/da8xx.h>
4 @ X; I# Q; e: T5 {' |, B#include <mach/mux.h>
3 a% V- y6 j6 S3 ~2 K: H0 q7 j4 F% r! Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! ?1 r- u6 @4 ~/ z. |8 h5 i! y* f, H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& `2 a5 K9 ?* X+ z' S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 e5 p1 S& t6 g6 l! @4 D2 G" Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 d5 `& p3 @% c* T: I7 {$ Q$ P) ^. S) S3 j' l
/* assign the tl som board LED-GPIOs*/! k) U+ M3 Y1 _: i/ {6 j; W3 Z
static const short da850_evm_tl_user_led_pins[] = {
; J0 B) {* m- R: p. h /* These pins are definition at <mach/mux.h> file */
) ]' @' U9 s; [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& R" R) v) d# T; G, H& m
-18 v8 h. B6 M- N- Q* d
};7 {" e! \* Q2 F" I! \
- J* e' p1 G9 ]* E; u. q: X) }static struct gpio_led da850_evm_tl_leds[] = {: @1 s( K( n) X: ?6 M
{+ u" K% B7 h2 l/ |1 Z8 c
.active_low = 0,7 d! @& G$ j2 w8 }! u8 P
.gpio = DA850_USER_LED0,
. w: H" c# L0 t* `2 @' x .name = "user_led0",
/ w6 z7 `1 a W: @) S# v .default_trigger = "default-on",
2 a1 d& K& B' @, V },
, O/ L' f7 O' ?( V8 j; I' S {
! {% v" r. j% f) B .active_low = 0,& K2 E/ l: v+ B9 d6 M3 s( C6 f
.gpio = DA850_USER_LED1,
" K* ~- c. u" D; f3 J) N- c .name = "user_led1",7 k3 J! U* D6 J
.default_trigger = "default-on",& Y. D0 n/ p: P3 l$ h" p( f0 w
},
- T3 k1 o' _; M$ ]" W4 b9 D! K {! `# {4 D. a; a, n& t2 q; A
.active_low = 0,
( X) J; D, {# E4 { .gpio = DA850_USER_LED2,8 |; s- A' N9 x1 R/ ]8 }8 V8 a7 Z$ ^
.name = "user_led2",4 t" n3 C8 a1 g4 N5 P! Z! `) F
.default_trigger = "default-on",8 l/ x1 q Z7 c: _, I- ^, U' Z
},- F9 j6 z0 j2 @* o/ u0 P" d8 g
{/ Z1 _/ E! j: {3 A
.active_low = 0,
; t4 T: R( Q3 m* T5 o .gpio = DA850_USER_LED3,: m' b( ^. t. J+ n
.name = "user_led3",
5 X6 d. A7 ]( o' T9 b% N- U .default_trigger = "default-on",
' P: r6 c( N; @/ K( N( o },
/ k* d2 G# y3 X/ O8 \8 k};; V/ {% j5 t' p
: k9 a3 o$ J. w% B1 H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 A$ i% m$ V: B* l
.leds = da850_evm_tl_leds,$ J* k6 |3 X) q( k& Z" d! H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: b: B; J2 J9 }) {( Y};
- \3 r( P: p: w5 L* t( J4 i0 }! h7 W+ m1 x) i7 I4 z' X& C
static void led_dev_release(struct device *dev)# h/ c7 f% `1 Z9 q7 Z+ A) _
{1 u! v9 n- y* v% J& N3 {5 G0 Y ?
};3 C# B7 g3 A6 J1 f$ M, d& M# l
& O, Y4 n& Y2 v$ z$ cstatic struct platform_device da850_evm_tl_leds_device = {4 n P2 r8 Y) K" ]2 ?% C) b
.name = "leds-gpio",3 e# a! j2 w0 j( z
.id = 1,: V3 c" M1 S& u
.dev = {7 M5 j& ^ c+ O
.platform_data = &da850_evm_tl_leds_pdata,9 x& J$ n; u* [" O
.release = led_dev_release,
' C; x) @/ N: i9 y' A0 _ }5 c( G, }! T- M- I- x t
};
2 K' y5 {1 `! b% a4 Z7 Z
+ U5 O7 F! i2 `5 a: v9 q0 U0 h G H- ystatic int __init led_platform_init(void)" U: w! W3 y3 Y8 m/ `- v; e2 u
{
1 t0 L0 R9 h I/ y! V" V int ret;2 s. @2 ]5 Q% ]+ H1 ~; \
#if 0
b/ f" }8 D# }( F0 ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. J. r8 G$ Z* D2 \: V0 }6 \% u/ D
if (ret)
7 m5 w+ B3 {( H7 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :") H0 E4 U! o+ w" n2 c% {- q
"%d\n", ret);1 c) }8 L- H" y" }) _
#endif) f5 [" O: f4 E# f1 K
ret = platform_device_register(&da850_evm_tl_leds_device);
% D: ]9 t- |; c; l0 U if (ret)
- t6 B( `; y; U( a a% m pr_warning("Could not register som GPIO expander LEDS");
: c% W- {% j5 q& Z4 k else9 X( ]: N, ]: ?, U
printk(KERN_INFO "LED register sucessful!\n");- K3 a8 I5 S9 e! u
) C4 @- [, Z, C
return ret;7 s0 [7 \% t! M9 Q
}& y2 R5 {5 X* S* d9 U6 B! g6 L+ g3 h: W
( U* U8 u7 p2 V* P: ?4 g
static void __exit led_platform_exit(void), L0 ?+ t1 k* H/ d( N% C2 W9 Z9 t
{9 q- Q7 t+ H* P9 j$ U1 J
platform_device_unregister(&da850_evm_tl_leds_device);9 j6 |6 s5 v) d7 Z/ G+ i& z/ s
5 ~' k! l; E6 u7 G8 u, s6 T& t printk(KERN_INFO "LED unregister!\n");. J' I& p3 F9 W6 ]& q( P6 k
}
6 g: d6 R; T/ M8 A# f3 Q+ I+ }. s- U3 G+ f* J
module_init(led_platform_init);
2 C7 @4 x' \8 M% t. @module_exit(led_platform_exit);
' l/ J! [& o# b# O1 r7 ~+ |- ?' w8 ~7 {2 h* c* v4 h% O
MODULE_DESCRIPTION("Led platform driver");' n; C5 t; F# f5 v1 I! v: z
MODULE_AUTHOR("Tronlong");
9 t7 z! h* _! i& P' q6 u, kMODULE_LICENSE("GPL");
4 Z' P d& S+ G
! h/ t- B3 S1 j- N' z1 V1 Z9 y |
|