|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: v' H9 c) F5 V. D0 s1 J5 M1 E7 ~#include <linux/init.h>
. u% v7 r5 `9 `- w# ~1 D#include <linux/module.h>+ G4 g& N, r! U" [. `& ]
#include <linux/kernel.h>
: O4 m' |6 M+ Z {; G#include <linux/types.h>
* I% r4 M% ~7 F' T6 m6 O#include <linux/gpio.h>$ X5 G- c/ m2 ]2 U5 c
#include <linux/leds.h>. s! g& m9 t6 [/ J; ^2 B2 ^& J+ s4 `
#include <linux/platform_device.h>/ a' j* g" @: z/ W1 \0 n' D4 p# W
: M) [/ I# v) ^, O( j6 ^) _#include <asm/mach-types.h>6 ^0 J( d7 z- q! {6 V7 x0 @" R( o
#include <asm/mach/arch.h>' q6 U# _/ ^3 R& b
#include <mach/da8xx.h>
6 K9 n8 u8 m+ t+ l }# f( H#include <mach/mux.h>, n* S) d2 ^4 F0 o
& [4 d$ c( |7 n: f' s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# Y: O/ E6 t9 ?$ U1 F, y; V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& d/ {" p; [4 X! Z& b( y1 X% @( E3 r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* y9 F' T% `+ e6 j7 X) u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 R% R$ G- x! J3 S: i5 A5 L5 c% N9 d8 b
/* assign the tl som board LED-GPIOs*/6 l( L% H3 u+ s( a' M1 o2 Q# {7 j
static const short da850_evm_tl_user_led_pins[] = {
; h' P/ d5 s; u4 W /* These pins are definition at <mach/mux.h> file */
- V; D5 z+ q9 q+ U; E4 E: z7 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: x( @: C" i9 n# {! A8 T
-1
3 v2 x& O, o- d};, u0 a L1 p/ {' y
' q& q5 U1 \6 V w! [9 S8 G5 I
static struct gpio_led da850_evm_tl_leds[] = {- i8 x U2 A$ k
{# p& b2 h' \ \
.active_low = 0, k! u3 K. }! L: V
.gpio = DA850_USER_LED0,7 e& i* w) a4 a
.name = "user_led0",3 Y/ P6 {+ B/ [/ \1 n$ [
.default_trigger = "default-on",# k7 F% d# E; k. |4 U3 s1 e. I
},0 z) s2 _: C- K
{
+ q3 |6 K2 w9 L# C% J .active_low = 0," s+ j* u7 n3 r, Y4 n/ i
.gpio = DA850_USER_LED1,$ o B% w8 I: o' w
.name = "user_led1",
$ Q. t9 _$ v9 M5 C6 D, j .default_trigger = "default-on",
* R/ p" z; g, { q( m6 Y0 `& x },4 l& ^3 y. q2 I5 ]
{
" k0 z% e q' E; u* v .active_low = 0,# R* D( z7 ^9 z5 x0 B4 R8 Y) p7 |
.gpio = DA850_USER_LED2,
" h8 A9 Z1 K3 P* l7 a .name = "user_led2",
; M3 x6 q; ^* Z, \8 H3 z6 |0 N .default_trigger = "default-on",
( G$ Z `. }( x, b5 R' T% P },4 T1 _) @ j% Z. O% f, e: H
{
z, x- ` |/ Z; `9 j) ~, P( r8 g .active_low = 0,/ n0 U" \5 {2 ]+ p
.gpio = DA850_USER_LED3,
2 `/ E+ B7 R1 l .name = "user_led3",& h2 q8 ?6 U" \, `: N$ ?6 D* L' ]
.default_trigger = "default-on",; g& v, N4 b! t! e1 H* N1 q X' v
},
7 H1 j( t) @8 u6 C! [! J9 r};
+ l. A, q# u; x# p
+ t. ~. {: S* J. {3 }+ ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; W1 H+ l1 `- J! G* N- u .leds = da850_evm_tl_leds,
" T$ h5 e, I& q9 u# q" h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 U; p+ f- I# ^) H};' T8 v: p7 m8 v' _
0 o. G% z1 s' U! E
static void led_dev_release(struct device *dev)* l$ ~2 @2 k4 H c1 X) d
{
7 e7 W e; c2 Z2 U0 O" X3 }" y};$ a: S# v0 ^8 c- M7 }
2 D) D$ y P% e) @static struct platform_device da850_evm_tl_leds_device = {- ] `8 C2 @( |/ ]/ {/ T
.name = "leds-gpio",9 q D' D$ ~, o/ X
.id = 1,
]6 l: Q: W) B& t3 ] .dev = {3 v* U+ {# L: P. K: g1 j* e
.platform_data = &da850_evm_tl_leds_pdata,
# Y1 F0 n) T# W" O .release = led_dev_release,
' \5 h! C0 G, e4 u }
+ o& ?- a. |+ G3 f; k4 v0 Y};, D' i. r' \( [; n2 x
6 K- T3 E7 g. f4 y# p5 x
static int __init led_platform_init(void)
0 y& Y3 Q0 j/ e$ C, f3 x6 E5 |{
& j* L( x+ }( r9 I+ c: I. Q int ret;6 ]& q# K5 ?- y9 U2 q$ Q% j3 Y
#if 0' I5 g! c0 Z* F3 p) @' c1 C, [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 S% q# s+ j g6 [ if (ret)) f" w! |/ I$ r6 P5 Y/ s( y5 f, c0 g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. Z$ J. @" w8 ^9 t) L) N2 b3 F "%d\n", ret);
+ p4 x9 G1 \: w7 _8 J% N9 Y2 h#endif. i7 m D% U# z4 u H, e7 g2 c; F
ret = platform_device_register(&da850_evm_tl_leds_device);- Q! F% Y/ F$ l: H$ U) v# s
if (ret)
3 [+ ~) D' K* ~+ i3 ? pr_warning("Could not register som GPIO expander LEDS");
( M- t! Z+ w; p else7 l: ~. z0 j6 a; H
printk(KERN_INFO "LED register sucessful!\n");
& w* G$ Z+ f l! k p8 R
$ B, c( h, \ e1 v return ret;% @4 k6 Q+ E# Y0 j
}
/ @/ m; N& g& @* x$ ]% Y( p9 c
- v8 o8 j w% Z, ~2 M: d8 k; vstatic void __exit led_platform_exit(void)
0 N+ ~, v6 P; `. p: s{7 n0 d& w! d2 _& C' S; b# k
platform_device_unregister(&da850_evm_tl_leds_device);4 o* b( Q5 v2 N
4 G5 \, R: A* t. c- w
printk(KERN_INFO "LED unregister!\n");
2 w1 m3 G, |: x& K}+ b) I' ~$ \+ D( x
" r$ I! J2 o# L* S1 L1 k
module_init(led_platform_init);( ]. q3 @ s7 Z# Y: o
module_exit(led_platform_exit);* k H% i0 T+ z) q
$ k' B3 \# |- ~. r! ]. ^
MODULE_DESCRIPTION("Led platform driver");6 N0 E. O" p( N6 e6 `/ R
MODULE_AUTHOR("Tronlong");* D' h! p# R; y1 I; G( W7 X0 c
MODULE_LICENSE("GPL");
/ t5 j+ M' L" I
$ Q' h1 R4 @7 p7 d# m5 f# G6 Q |
|