|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ [* c# T; q) l' o; g$ h#include <linux/init.h>" e- ?0 q% r; ` u. X3 F) ?+ L
#include <linux/module.h>
0 F3 z5 {( E7 c#include <linux/kernel.h>; }# n/ y6 u6 f0 J
#include <linux/types.h>
2 D0 |% `* Z5 F) {) [ H#include <linux/gpio.h>
# C# a$ g1 b5 o9 q% }" Z#include <linux/leds.h>, I4 D6 |$ }0 r& d
#include <linux/platform_device.h>+ r6 L1 T* b* J+ `" l$ h6 W: k
4 ]9 W4 s6 W# k$ _/ [# H+ ^#include <asm/mach-types.h>% U9 ^2 S! D% v" P
#include <asm/mach/arch.h>+ @" e+ F% v/ [. p# B9 n
#include <mach/da8xx.h>
8 |6 ]' E } D#include <mach/mux.h>. z, Q, b' }& R
5 ^, }1 Q* `5 {, V- w( C+ W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& ]1 k0 p& u, S4 q) H8 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) T$ V+ X7 y# h( K$ p( w4 Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! M# B, h( v9 |% s3 N% w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- r7 D( c# p7 O _" V. t
3 u: F! M7 c9 |: }! k( B; p/* assign the tl som board LED-GPIOs*/8 }4 Q4 a" n7 b2 ]: h
static const short da850_evm_tl_user_led_pins[] = {3 J% { X$ Y; i9 X4 s
/* These pins are definition at <mach/mux.h> file */: N: v7 y6 d4 B4 s; r. K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 i7 `7 C/ I7 q5 U* k$ O -11 n" y$ S( D* ]* |2 v
};
- y9 P7 [- T" M
8 t9 k+ k5 o# Q; ^static struct gpio_led da850_evm_tl_leds[] = {4 F. s8 f$ ?8 U" b. o
{- }% H; h: K, ]5 W3 p" |" h
.active_low = 0,
/ _' g2 x' D) j0 t4 }; i1 a9 K .gpio = DA850_USER_LED0,7 Z2 l6 t- s! _7 r: V, u) R
.name = "user_led0",
& S3 [( i4 G9 k3 ]/ Q .default_trigger = "default-on",
- n5 T# a6 R1 _- M },
( u! _: X* t3 W6 p% F$ E' o, F {
$ D8 U5 e, H0 a/ |+ W6 p9 e .active_low = 0,% L. j; G: r0 d1 {# Z
.gpio = DA850_USER_LED1,' I5 N& q; x% O0 v3 l
.name = "user_led1",6 _" X9 x/ Q) k
.default_trigger = "default-on",
4 k' [+ O* o9 b) S },
7 s6 ^# k! O7 {8 U: C {' ]' A/ A4 ?& }) L( _( A* [
.active_low = 0,
1 S. _9 T' e( L* o9 R .gpio = DA850_USER_LED2,0 B6 l3 h+ z! X' G3 r
.name = "user_led2",
3 d$ _7 g- k/ L! E; J .default_trigger = "default-on",1 u/ ] o; [/ _. c
},1 s+ a$ u8 e# D) T8 C5 a
{' E% ^4 c7 P7 C! Z# k+ z2 F
.active_low = 0,
' V+ g" R7 t. z/ w .gpio = DA850_USER_LED3,8 w2 A: w# G7 s/ p' A T& Y
.name = "user_led3",
/ w/ ~0 w3 m1 u .default_trigger = "default-on",
9 y2 E- F) E: C% E0 n# {# r; S2 a }, T% u/ x. A/ s" e) H/ E
};
+ X% p8 T3 d p5 X" D& g5 l8 T
; ^& J$ M( g1 T$ ]7 W, Q fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ w. D3 r. q; _, k0 K .leds = da850_evm_tl_leds,
, Y5 V: G W U9 n- a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 @" e: t) x; C: ]
};
2 ]/ r4 U% h2 o3 u: ?7 W0 Z
6 n+ }. W7 J8 y3 G# c5 R8 ]static void led_dev_release(struct device *dev)
% M% f. l" C+ k, e{/ `; I1 V: u; \3 i; i6 d0 Y
};
9 @" [! M' e( i: y4 q- {$ R# y5 |$ R* C9 X0 K* s4 b% T
static struct platform_device da850_evm_tl_leds_device = {/ F7 f' C6 g0 D
.name = "leds-gpio",! A B) @" U6 m& g( y5 ^
.id = 1,5 w* Q. N. c) @0 m
.dev = {
6 o1 |2 ^2 H! R) ?5 } .platform_data = &da850_evm_tl_leds_pdata,
5 X a9 K9 N+ ?% t7 S .release = led_dev_release,
& Y' l: U& G! f7 D$ @" O/ I: M6 Z/ c }( c: |; t) e' @) @0 w/ G5 I
};
; N' u$ m) r, p! x3 u9 {+ ?2 N' d+ w" c6 V3 H
static int __init led_platform_init(void)
. B+ P7 o' d( x0 l! C! E9 e0 K{% ~: D% v6 k6 w! F6 \! {
int ret;
/ n: M+ \( r( ?5 g7 Y) ^#if 0/ E- l. x0 R( K! s, z% d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- p3 s$ A: }$ h. @
if (ret)
: K% G+ f4 g5 D! I. _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ y; T. U7 `& J1 j4 M "%d\n", ret);; [ t5 x" x: [" c" g$ K
#endif: e5 |4 N2 C- _# B! k K
ret = platform_device_register(&da850_evm_tl_leds_device);
: ^9 Y; U+ [ k1 O if (ret)* O* \) W7 h: c/ }
pr_warning("Could not register som GPIO expander LEDS");) K8 U3 S) P2 W
else9 B- ?7 a7 {( h5 X# p
printk(KERN_INFO "LED register sucessful!\n");
3 |8 \4 h- |+ m+ Q6 p- r* E y1 v/ H/ Q0 [) @1 e
return ret;" T; ^ ~+ ~$ w* ?) d
}! x& g: u: t! W8 B8 {# ?' J
( V' f4 O- X0 Nstatic void __exit led_platform_exit(void)3 U1 g6 f% l; _$ Y
{
# a& `! G2 C5 E; i platform_device_unregister(&da850_evm_tl_leds_device);, y5 \4 v3 }! h: g7 P
+ R# B) I1 @* g q" N printk(KERN_INFO "LED unregister!\n");& J) z; I- P8 r9 |8 H7 }9 `9 I
} W p5 k2 ~3 a( _( a& o; w5 u
5 d1 J6 b5 K% }+ K* m
module_init(led_platform_init);
7 y# m& D& q: p9 ?9 R# g- dmodule_exit(led_platform_exit);
/ |: P6 s5 U' \7 |: C- Q2 X$ J+ j( s6 Y
4 H7 Z# I# z2 Q6 l: tMODULE_DESCRIPTION("Led platform driver");( ~8 k- y8 {; `& x
MODULE_AUTHOR("Tronlong");
/ f6 ]" j% q* F- U7 EMODULE_LICENSE("GPL");0 R4 c6 f! X8 \- Z
* L+ i6 p3 C ^5 b/ O
|
|