|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 Y# a. B4 h$ T+ u# \) s#include <linux/init.h>- H5 O+ S: J- x( U; b; r8 ~
#include <linux/module.h>
; h3 O4 D# U( f1 E#include <linux/kernel.h>
* Y+ L" v& v5 r5 H! O1 a' u' Q#include <linux/types.h>
% X7 P5 R) I, \2 o8 @#include <linux/gpio.h>. I3 M; B' B# L+ w# \0 P
#include <linux/leds.h>
* q; M( G& V4 }6 v: c$ c# E) j9 \#include <linux/platform_device.h>! v2 y1 a' V8 {) y% |1 d, N
8 ~2 r5 M% p# e2 V9 Z: s3 P
#include <asm/mach-types.h>; w' H& _+ v! f% X! s" N; x
#include <asm/mach/arch.h>; C% M* w. W; r" V1 _( A
#include <mach/da8xx.h>
' z. e2 p, ^& H5 z: I9 \+ m5 T#include <mach/mux.h>
: E3 B" p; Y' w" n6 o$ @4 } }/ ~5 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 h0 e [1 p# b2 A7 Y3 }) U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). S% N8 l/ W: y h2 N5 J& a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
^3 D1 D$ X5 O5 [0 K" H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 D ~* w; X' K% d
+ R' |# q2 R! _. \0 O/* assign the tl som board LED-GPIOs*/0 B' v2 l8 h0 V) q' V
static const short da850_evm_tl_user_led_pins[] = {
6 q4 p' O8 D& m /* These pins are definition at <mach/mux.h> file */
$ [: q" Q/ d4 K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 H6 j4 q7 h, c; g6 x -1
+ U" }% z9 {. G5 t7 d( @};
2 K5 ~' [& U5 p6 _, @2 O9 q. V) P! N- z
static struct gpio_led da850_evm_tl_leds[] = {
/ Z% G9 j# Z0 G' \$ W' } {
6 {' j0 [; B* V) m2 b1 H .active_low = 0,
; ~2 k3 t& @1 n. X$ ?5 A5 d7 W/ g+ s .gpio = DA850_USER_LED0,8 L- r( D& v$ n8 l5 C
.name = "user_led0",- s+ a4 L" j |8 T, E$ Q4 F3 J
.default_trigger = "default-on",
# P5 V8 t2 h6 `* g },
4 ?+ @% I% H& N) S$ x {/ b8 `+ E' ^4 Y, l: d% x: g
.active_low = 0,
2 X9 F* M+ {% h* O* U0 M .gpio = DA850_USER_LED1,
, X6 T$ n ]+ i3 s1 ~ .name = "user_led1",
9 [# }; v {, L! o2 K& ?- P8 H .default_trigger = "default-on",$ \* _8 n3 g) ?% {9 H7 z
},
) N; k: k2 i& V5 V8 O {6 ~0 K9 \. S! [* T9 X3 o5 `
.active_low = 0,! |% Z" O0 B4 D+ i8 k. |+ r
.gpio = DA850_USER_LED2,( ]1 H# b% ]8 s6 Z# W: H
.name = "user_led2",1 h$ m1 S+ G* |% [
.default_trigger = "default-on",& w* Q7 o9 Y! _+ i9 l
},8 L+ f3 i3 v/ c3 U& K
{9 a" p4 a6 o5 a8 @5 ~
.active_low = 0,
7 f$ c* x7 y& q .gpio = DA850_USER_LED3,& X+ g0 X% T3 j( D8 T* j2 r' v
.name = "user_led3",! e- D# ~ G/ K8 a* _
.default_trigger = "default-on",
( z/ Y0 B3 @1 S% f2 Y1 P },
) {0 o( x9 C" [5 K: ]# n" V};% d% T+ `8 |/ z) H- w
$ x- j5 N6 P- W8 y D+ B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) T. l7 z6 z* Y( e+ K0 L0 l$ s .leds = da850_evm_tl_leds,3 w4 v6 k7 e% p. n2 B4 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* M! ?& y/ y9 N; N; p1 t" A
};- E0 w* `/ J- K& {! l# u
n2 w" d7 B, L
static void led_dev_release(struct device *dev)5 T2 ~+ s2 w1 c% q+ ]2 D
{4 T& {& Q! ^# R9 X$ U- n8 D
};
: a: `! }. ?' k0 g5 C
; q. ^! f9 k: G+ l; L+ nstatic struct platform_device da850_evm_tl_leds_device = {+ h! M6 Y1 E- I
.name = "leds-gpio",
* O# o4 R( Y7 Y | .id = 1,! e6 }3 a; t8 _. v7 L- X! E. }
.dev = {; x+ ]5 i6 Q' c3 p
.platform_data = &da850_evm_tl_leds_pdata,* A P9 y! S) l' h$ o9 [7 Q2 }. r' I
.release = led_dev_release,
; e5 L" _8 f# q7 O/ m$ r( O5 h3 H }' E* F% q0 G% h, Q9 l
};
- \% v D/ L6 c! u2 D& G- C# S) G$ n. z$ i
static int __init led_platform_init(void)$ J9 w5 \5 ^0 V3 P
{
7 H/ ?7 x8 @3 G$ g int ret;% w2 T4 B% l& I3 G8 ~
#if 0& N S2 m) Y. t$ [0 M! G# D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. }2 ~0 O# A& e: T& ~) n if (ret)2 ?1 h8 b0 o" O/ L4 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. y/ U( g9 L1 a: n& ? "%d\n", ret);
5 p3 ^/ d. h; L#endif
, E9 R( [% j( \8 H% O! S ret = platform_device_register(&da850_evm_tl_leds_device);% {' l6 O( M; q4 O2 z
if (ret)3 V) V, x! c1 U: `' Y7 [
pr_warning("Could not register som GPIO expander LEDS");! y3 B) }' C* q9 A! |
else
$ O- U8 r8 m, C printk(KERN_INFO "LED register sucessful!\n");# @8 J- P: H3 }# b2 R
% w/ c" o+ b& n- X8 K* W: ~ return ret;
! M; t& T0 y6 ~; e}8 G6 ^9 t. r8 |0 H2 a
?1 v1 t, w9 ~# a/ t- [
static void __exit led_platform_exit(void)8 d3 `# x! y4 h: R2 q$ b
{7 c2 r8 c: Z9 ^: `- W
platform_device_unregister(&da850_evm_tl_leds_device);9 t% b x: q1 K; d0 F8 Z
) x _# y% m0 ]9 ]
printk(KERN_INFO "LED unregister!\n");2 q" z% }+ T* e9 M1 Q# f/ n, T6 [
}; L7 w0 J9 a* m- }
' u+ G0 F( m5 y H6 E) r2 n
module_init(led_platform_init);
5 ]1 v: P T7 D+ y" } Mmodule_exit(led_platform_exit);
5 z9 S+ M& b- ?; v
6 y( Z8 m: y4 j+ Q' ?MODULE_DESCRIPTION("Led platform driver");
- Y7 y" ]) s1 R6 RMODULE_AUTHOR("Tronlong");
1 o6 n% j4 r9 H O+ vMODULE_LICENSE("GPL");$ y% y, X# Q( Z4 Q" g9 F
1 i' F; [9 M% V% P* O |
|