|
求大神给下面的程序做注解,请稍详细些,谢谢。
! m, N4 b4 C; ?& h#include <linux/init.h>
1 a, |& F# V* e9 j& @& p3 y#include <linux/module.h>
8 I* F9 R) l. u; j: A2 R#include <linux/kernel.h>
# Z% |' X8 [: ]7 w7 T8 S/ [& r* G#include <linux/types.h>& f8 Y J( U X! N1 t! F
#include <linux/gpio.h>
3 T/ o( X: K% o#include <linux/leds.h>
9 @7 Y1 J" z# E+ j* L- X#include <linux/platform_device.h>* x- `. D* V; `3 H3 m8 F
6 p o. G# ?( a3 l( O9 ?
#include <asm/mach-types.h>4 \, R" ?8 p& ^0 g" c
#include <asm/mach/arch.h>' h, o% A' x" ]# D
#include <mach/da8xx.h>
; `7 L, U8 r3 G( w# O# z8 D#include <mach/mux.h>
0 b8 m$ T: C# |
6 d$ a- W5 L2 |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ m: a: r9 q% H3 i9 i, k5 K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 N+ r+ y2 r3 K9 w: _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 j% a+ c4 T6 p r; Z6 H' V9 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; W- I$ l" _. Z/ A4 i6 d7 C+ R7 @6 `3 _* U1 Q9 N
/* assign the tl som board LED-GPIOs*/% {7 i5 s; o& P
static const short da850_evm_tl_user_led_pins[] = {& [( {2 H& o x1 p0 W
/* These pins are definition at <mach/mux.h> file */
" }9 D4 k! S# o4 e, ]/ U- G# s# p F, t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 t" S9 P2 _- \$ B9 y$ D
-1
% Q# _6 K$ X. ?; p4 d* I};) ~( y5 ^% L( a8 @( Z" Q6 P
% l+ @/ f* n1 Q
static struct gpio_led da850_evm_tl_leds[] = {9 y( C/ V5 Z4 J8 u
{
& {; ~8 `8 y" _$ [ .active_low = 0,; B# M% e3 J1 t a
.gpio = DA850_USER_LED0,1 b0 T8 I8 R) |5 h* r8 _# [
.name = "user_led0",
6 u+ K: A2 N, X# y B .default_trigger = "default-on",
" i0 `: E( D, b },
2 k- o- A" N* U. E1 r! N! g+ N( `% }( s {
0 L1 ?$ [( g; D' d; ^6 C) u .active_low = 0,
9 W" a, S" | J3 G! |- E" k .gpio = DA850_USER_LED1,
7 j# @8 H! Q" V; {" j .name = "user_led1",
6 t$ \1 E1 A* Z$ E0 Y2 J7 r .default_trigger = "default-on",
. B: G/ m6 O' s5 o },& {2 m: b" `+ |
{3 b4 j- q$ M& D
.active_low = 0," C* A9 q' n+ N8 B! K* ?& U
.gpio = DA850_USER_LED2,5 G1 K- Z4 P q3 K' v' l0 o
.name = "user_led2",
: i Y1 F3 [ X4 x' D' l& x .default_trigger = "default-on",' ?7 b8 F7 x- D1 C- {- i
},- o4 o8 f- p3 ]1 K" w6 g" M
{: S2 q2 M P* G5 h+ c5 X s
.active_low = 0,( Z6 a: e/ v4 D# c% k1 E
.gpio = DA850_USER_LED3,
- f! X, x: K' F0 K& d" U& K2 Y .name = "user_led3",9 {, m/ p& \# _4 N' t4 X6 X$ u
.default_trigger = "default-on",3 v9 j! }4 g; Y, Z7 u7 f) N
},
, f1 w& M* W9 E, Q/ ?- N4 v5 ^/ e: A};7 A' B1 G/ M! N& U. @$ v1 E* [
! j3 d7 [+ ?* `6 X( D. m. Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 z- U# @5 D3 `- x .leds = da850_evm_tl_leds,
+ s5 i( c* N$ Q9 K5 K( b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! ^ B# v2 p8 Y) W0 Y
};2 v s( l' C- V. t8 p+ i/ ~( B' d
+ D! }6 N8 W& o2 F* A6 Q7 Vstatic void led_dev_release(struct device *dev)5 x* I9 S: V5 o, W4 }1 R2 _' I: `
{4 Z6 E, U! g) }6 p/ t: V e
};
( S4 R' V2 j4 Z% Q, V& ]0 Z y# d/ k0 ?" R
static struct platform_device da850_evm_tl_leds_device = {
0 u$ y1 G7 V" f6 o( V3 P/ Q7 {, m r .name = "leds-gpio",
/ b; L' S+ J: ]: m5 i4 B% ~. G .id = 1,
$ g6 P6 [( s. I4 h+ b/ Q .dev = {
$ Y0 f- T. B5 G+ U8 ], ~1 j .platform_data = &da850_evm_tl_leds_pdata,- R/ V% [& v( R1 J' U' L# B
.release = led_dev_release,
5 ^* z) O6 ~/ U9 q }
) a; C8 D& P" Z& f, \( Q# D};
6 | |$ ]7 P9 R- v3 i V9 E- C" M5 ]; J* T
static int __init led_platform_init(void)/ Z% q# Z) V- N5 o) c/ k, U: J9 Z
{: t/ V6 g: N( K: {: M8 k) L0 A. r
int ret;
6 K, p! f) O" b/ _" o#if 0
$ v- I8 v: Q/ t" ?2 I* C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 J7 g: F: j/ B2 j& h, m if (ret)
3 k) Q1 r7 h2 o# c: a' D. [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :": ^7 W+ b- ?% r
"%d\n", ret);6 L* q4 u7 ^! E
#endif
0 g0 [2 A; n/ I1 i" w ret = platform_device_register(&da850_evm_tl_leds_device);$ ?; R: I! O. w+ ^
if (ret)& R, D) J$ I. e; w9 A
pr_warning("Could not register som GPIO expander LEDS");! ], d4 @: X$ `# ]9 x B: w) B
else: C" D& ]! }6 w, W. M
printk(KERN_INFO "LED register sucessful!\n");0 J- ~/ T! N# @+ g5 m
/ H, t- B2 {6 H r( B return ret;
, [# b* z; W0 `6 |/ w# C}3 m4 Q4 s6 Y5 t9 p; L1 F. b% C
+ m* y5 o1 U i& x
static void __exit led_platform_exit(void)
/ `" f: L6 x5 N5 Q; L2 ~7 ]{
2 u& x1 K' S1 M& q8 a platform_device_unregister(&da850_evm_tl_leds_device);
1 S5 {, i( w2 w: q" R7 ?# [$ @
# ?2 }1 @9 x8 D printk(KERN_INFO "LED unregister!\n");
; _; l* _$ U$ [4 i$ K+ l}
4 }9 ]% f2 Q! ]) B$ G8 a% F1 w
* ~! V+ q) q! }/ a. d- _. N9 O8 r$ zmodule_init(led_platform_init);
# e, F/ v$ q' S9 ?: Amodule_exit(led_platform_exit);
" S( k. l+ d4 u" w* o3 R5 N* d1 u/ `
MODULE_DESCRIPTION("Led platform driver");
' d/ @, y; ?3 X4 W/ S* s7 k; HMODULE_AUTHOR("Tronlong");6 m3 i: \# ~+ Y' U. s8 G5 \
MODULE_LICENSE("GPL");
9 Y+ x3 q$ y& b+ k9 m
1 F! w; r2 Z; ^6 j" W6 w# ~; Y |
|