|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ y% Y3 m5 S4 f2 h1 @1 K#include <linux/init.h>: a9 O$ Q* l. R4 i% F! m
#include <linux/module.h>
7 I1 r k& b6 C2 H#include <linux/kernel.h>
* n& p& x6 s& d% j6 N#include <linux/types.h>0 O- E. w! B! X. e9 C
#include <linux/gpio.h>
5 s: ]2 o: U8 n: T' g3 A9 \2 o#include <linux/leds.h>
, k8 M# F7 m: ^1 D: [( k#include <linux/platform_device.h>1 Z! X @* A* d4 u4 A4 w
5 S7 r& q" b+ g7 }#include <asm/mach-types.h>4 k/ Y+ D1 u E0 z
#include <asm/mach/arch.h>
, p6 U {! m( R#include <mach/da8xx.h>
& s0 V6 }( L% q/ V+ K8 d5 A#include <mach/mux.h>
3 |4 T, y! k' n
5 p7 F2 t7 m- t5 n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# u7 i& N0 @5 f" w, g) J8 f% d, d7 w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% @/ S$ s [- \0 ^9 n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ y0 q8 P7 A, t, D& r6 j' q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! k# C0 n. Q8 t) ]. |7 I) r
; C4 [9 |" j8 q0 V/ l2 t: L
/* assign the tl som board LED-GPIOs*/
! C2 I' B6 V L( r9 _6 \static const short da850_evm_tl_user_led_pins[] = {+ ^; {+ _' v, Z4 V, Y
/* These pins are definition at <mach/mux.h> file */
- S( `6 c& C) `! s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! O& u `/ g1 `% A1 p. p
-1
; j" W: L- U! P7 Q};* H( U9 O* e8 U) c7 [' L6 z
2 h4 S( `. E( e- s% S3 Lstatic struct gpio_led da850_evm_tl_leds[] = {! Y: T8 P) b! y+ j8 n8 V4 H
{
2 K; d1 ~5 e/ h6 z, V .active_low = 0,, O0 p2 h' m1 r' s( O
.gpio = DA850_USER_LED0,% U8 |! C" G2 A) ^6 D# L
.name = "user_led0", f/ u4 ]. W, h
.default_trigger = "default-on",- z" b$ j) g, B/ D/ @% E
},' A/ c) a7 a# i& f! n
{( Y! S8 G3 |& a9 r G: N, l# | U
.active_low = 0,/ T: P5 U* u7 x1 D" A/ K6 h
.gpio = DA850_USER_LED1,# P2 c% e) m- w# [! n6 J# A
.name = "user_led1",
- \& b" ~. t, ~3 ~1 s8 ` .default_trigger = "default-on",' S3 b. B5 X/ k" d% z! S
},( o& S1 t9 H5 `' ^, ]
{9 n, b- X4 T6 E
.active_low = 0,
6 N( c* q+ _2 ^5 R3 K .gpio = DA850_USER_LED2,* n+ { x$ y7 N" Q7 ~$ y
.name = "user_led2",% i/ q5 ?" @/ N; L8 B
.default_trigger = "default-on",; _- A9 w8 j! @
},* @& C% }! m, n$ i
{
; }/ O5 e3 y3 M% X; [$ W .active_low = 0,8 q' \, x4 e8 C) m! I! A
.gpio = DA850_USER_LED3,
) E1 p9 d' k- T .name = "user_led3",
1 K) ?' t: D4 r, t9 g .default_trigger = "default-on",2 Z) J0 Z' p% s. l( `% n/ D9 \/ n
}, b( E1 T2 E/ X& |
};
$ d% l; g! [' B( I: |3 E
4 m3 b: F$ R4 V+ J( a, pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 X9 N. ?, p! l- i .leds = da850_evm_tl_leds,
]4 [+ O' T! H- K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 Z. m: z, Y5 m, v8 ]- ?};3 B( K5 F0 r6 A$ j; U
' n% D2 }/ l& d) I5 zstatic void led_dev_release(struct device *dev)
/ \2 b2 w. B3 k# ?0 ~6 F2 z# p# \{# M9 K2 p! Z; w8 Q' Q
};2 Z2 g& C" H3 o: w2 ?& R
; h; ?2 }6 V8 I5 f6 L& r
static struct platform_device da850_evm_tl_leds_device = {
p* M* _# L5 w+ x8 V# p .name = "leds-gpio", U0 i& O+ A" B* c, Y0 s2 A
.id = 1,$ M- q) ?0 R8 v; y, @9 D
.dev = {' ~- o# V" m1 V2 q1 y2 R! q9 Z
.platform_data = &da850_evm_tl_leds_pdata,) {0 L' t; q* s% i
.release = led_dev_release,# `8 i5 K V+ E" ^; L# v* S
}7 ]7 q: s% h5 \- K' F
};
, S. u4 p1 N8 H7 n2 f, ?0 t5 `" f# V* P, n" w# S9 X: [2 u
static int __init led_platform_init(void)4 ?* a% v8 N H! V- I3 ^
{0 ^3 M6 u: u) i& Y4 F: M% v7 X
int ret;7 i3 S3 Y: p$ U2 c0 x9 h7 O
#if 0" R* ]. y: j6 U# d1 k3 {! H1 [& Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. U+ g" J Q' m- v6 [' }- C- E5 W5 F
if (ret)
9 E4 }0 }% b* |' W0 E3 x$ s$ z8 k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 x& H2 f! ?' A# b- O! b& Q "%d\n", ret);
2 w$ r. B7 v9 b% N#endif+ G! o8 q7 J4 x0 @$ o, ~
ret = platform_device_register(&da850_evm_tl_leds_device);7 z# h- W" r' ~
if (ret)
6 ^7 d- c+ C0 o1 U pr_warning("Could not register som GPIO expander LEDS");
$ B/ w% |/ q" C. c6 _$ Y9 @: ]3 ] else
7 i8 Q& x- `* v. { printk(KERN_INFO "LED register sucessful!\n");( Y0 s% Q0 X. N1 [
( I" P4 ]: D* z, b* ~ return ret;4 I. l! r6 B+ [. m6 E
}8 ?; e# ~4 q" e- o
- T1 c5 e3 X( x* k K) t$ U
static void __exit led_platform_exit(void)
|9 ^# K$ h* x% o3 s{
5 u1 b9 F: a# ?6 a+ ^4 j platform_device_unregister(&da850_evm_tl_leds_device);
8 @- C) u9 _' K: Y+ I% y. }5 B( @! c0 \, K9 d p6 h
printk(KERN_INFO "LED unregister!\n");4 D) c4 `) ~6 R* e( P
}
4 g* m3 d9 d( _7 {( Q' [
: s/ U5 W- \3 V& e$ \module_init(led_platform_init);
4 o2 @/ I2 \+ _module_exit(led_platform_exit);* ?6 E, h1 \4 Z, L6 R2 H X
9 A3 R! X% l9 ^1 E6 j E) y6 c
MODULE_DESCRIPTION("Led platform driver");, F" s* ~8 n9 y& o. S
MODULE_AUTHOR("Tronlong");
( w$ y5 q: b7 v q: ?MODULE_LICENSE("GPL");
5 u# n* @3 H8 A4 W2 V; h# b
: n$ w8 D- m- j9 P& f& o6 K |
|