|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 d6 e/ r5 z/ U/ I& e& R! F: X
#include <linux/init.h>
- f3 Z$ J& N* h/ v. @. y6 _4 X#include <linux/module.h>
9 b+ B2 Q" d3 C7 |: L( `#include <linux/kernel.h>+ S. [. U1 J# }( i' \/ n. y
#include <linux/types.h>, p, h9 T8 H* A
#include <linux/gpio.h>2 @0 U6 y% p6 D1 `
#include <linux/leds.h>6 w7 H4 P0 L8 J2 q/ |# N
#include <linux/platform_device.h>2 N. G( u7 t% u! s
5 a5 s5 A# I& q. d' O4 P& W; b8 r#include <asm/mach-types.h>3 {) L2 C" x2 b6 w0 w" c- W
#include <asm/mach/arch.h>6 {/ T B; P4 K% N2 v7 I7 Z0 o( H. L
#include <mach/da8xx.h>
9 P0 S0 B9 s' h; o# n4 [ _ N% k#include <mach/mux.h>
" l/ N1 w1 O; D5 M, [
2 r. w3 @' @& Z1 c; l# t" Z: c9 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 j) e; b. r) r) R' l* }% y {8 p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 Q1 Z1 T1 B c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# p' T" J& g- m2 v9 u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ \6 z- v% D0 L2 z# r3 f
3 v9 R' V. ]# l' S: f) f/* assign the tl som board LED-GPIOs*/
$ I) c% x& `# }) O0 I* ~static const short da850_evm_tl_user_led_pins[] = {" z7 z% y! j0 c' _( A& @3 A. J
/* These pins are definition at <mach/mux.h> file */
5 x& |$ b" j" h$ E" k' g' [0 w7 d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) K9 L3 _3 ?# w. c; @. u. c -1
7 v. _4 Y1 `, P2 y};
' u; _# }/ r2 C, B4 I
% C; G [, t* l; v! ? Nstatic struct gpio_led da850_evm_tl_leds[] = {& l+ V+ Q/ Z- ]
{
* X; S6 \) @( s8 K .active_low = 0,+ p9 H9 s8 _' }3 u+ ~% y
.gpio = DA850_USER_LED0,
. g0 Y% _8 f; v .name = "user_led0",
7 H/ Q" j: c5 S, z/ u9 m .default_trigger = "default-on",
# t0 q2 [! |! N. s. I8 z },# i0 ?' y! x$ k
{" y6 A4 H7 p! d
.active_low = 0,4 R" p/ D& h& _3 @* K
.gpio = DA850_USER_LED1,
; F: b% @0 I7 H/ g3 A0 p8 C% U .name = "user_led1",
! I. H! F" h3 U1 {% m* p1 m .default_trigger = "default-on",
9 p- @) _$ {( [5 A7 G- L1 m0 c },
& Z$ h) J, D$ O0 a% m! y6 P! T. q B {
; P3 [5 D1 D" E" `0 _$ u .active_low = 0,
% G5 `8 d5 A2 b8 J8 ?; o .gpio = DA850_USER_LED2,
. G8 _/ p# m# [( W- L& O .name = "user_led2",+ _* t. _7 O6 j9 d, |& o
.default_trigger = "default-on",0 _! r+ h; V& D8 P% ~
},6 _, K# K) L5 t
{
7 E% O1 l0 q: d3 W1 u .active_low = 0, p! B: @7 Q* |
.gpio = DA850_USER_LED3,1 C# ]2 N( R' I, ?2 P4 I& r0 G
.name = "user_led3",
$ A& E7 C5 k7 {( ?+ X .default_trigger = "default-on",' K- o- `, x9 C Q9 ~( ^
},9 u% O) P2 c$ }, C* z
};( u. N3 F9 A; t3 s7 Y
* @1 n4 k, D2 ?% c4 P3 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- M6 \- o$ Q7 Y- Q .leds = da850_evm_tl_leds,
# o7 c& m* R d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) x5 F0 r, T% [& y9 q};
7 Y2 ?7 `" d- l, ^$ |# J
/ ?9 L2 K7 ~6 d( e |6 ], W0 Bstatic void led_dev_release(struct device *dev), q+ L5 p2 w; y4 D$ h
{
% ^% \1 o7 g' r7 H' J};
" `. E7 u$ Q6 z. b! P4 V5 s3 y% b% Q( b2 N( g! G/ j2 i
static struct platform_device da850_evm_tl_leds_device = {$ B' k+ v. T. T2 J0 j
.name = "leds-gpio",9 O7 Z9 o7 b& I, V
.id = 1,
1 L; ^7 |$ J" S R1 g/ [( w .dev = {& L ~/ q2 e" v4 e$ A
.platform_data = &da850_evm_tl_leds_pdata,$ t* r9 _" m7 |; {
.release = led_dev_release,
# g c2 y5 @ w( n' I }
. s- _/ {6 L8 q# C};
$ q; x2 W- I( `- o( e# X+ F$ y# k% X
* q! y* A x/ |" X0 B1 t3 lstatic int __init led_platform_init(void)
9 q9 |. p2 j) d6 u{
1 T* \, M7 T: M( Y1 R; C int ret;' H7 c' q2 q+ B0 N
#if 0" |/ f2 X! F1 v& d, r1 W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: C" f+ v0 q. g4 t
if (ret)
6 f; R+ g: J$ v. V# O) t3 [# D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* n( F* o8 ^# [- k7 K
"%d\n", ret);
2 s$ M, Q, Z2 D; C1 a0 N1 X#endif* i `. T @3 o% e# D: J* o7 v
ret = platform_device_register(&da850_evm_tl_leds_device);, ~- R6 R! s- r3 z6 w# `
if (ret)
# i4 X: @% _1 r pr_warning("Could not register som GPIO expander LEDS");2 z) G- E0 _% C+ a9 u3 [ d
else- I. L# E4 d4 h% X7 w" w4 ]9 a1 D) \" j
printk(KERN_INFO "LED register sucessful!\n");; _/ n* _/ F/ H. G2 k: m. w3 S6 j
+ ~7 j9 t2 S) f
return ret;, I( i8 }2 \" G
}
4 Q: `1 }. V# d! i8 ^8 [; p
. U$ e& {6 y# Qstatic void __exit led_platform_exit(void)+ y. U5 T; k9 `4 f/ F6 Z+ Q
{
* [" Z8 E& t/ U" q! q8 g platform_device_unregister(&da850_evm_tl_leds_device);( b6 Z( n u7 `9 c& f# C
. E. k/ {0 L7 Z5 l. z5 P0 H* r
printk(KERN_INFO "LED unregister!\n");9 M$ C$ v9 H/ K& C
}
% [: V A( j/ Y4 g/ o) z4 K: q- M7 H# x% Y" y8 D
module_init(led_platform_init);6 Q1 }* H4 G- u' d& g
module_exit(led_platform_exit);0 x1 O' Y5 V |" }+ D
; F$ N4 q! S# B& q# R4 T# lMODULE_DESCRIPTION("Led platform driver");9 E- i# m P! Z7 ~5 H
MODULE_AUTHOR("Tronlong");- Z+ U* g" L9 }1 F8 w2 T; y
MODULE_LICENSE("GPL");
* _, y) n0 |$ E9 m$ I1 R( W4 Y- ]# x$ t: `) y
|
|