|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 G9 T6 |3 J* U, v4 t
#include <linux/init.h>. C# U/ D. q) M6 u! W S
#include <linux/module.h>$ w2 V5 S" b2 h0 n$ Y
#include <linux/kernel.h>
+ I) o" o! s1 d0 J#include <linux/types.h>" @9 j; j: C5 ^; H0 Z
#include <linux/gpio.h>
4 l1 `: W/ E. c* w% D#include <linux/leds.h>
- O) J6 l! ~& X! r% j#include <linux/platform_device.h>1 | w0 D, c) h
$ p& L" W6 l1 \: \' n
#include <asm/mach-types.h>
# d ]5 |0 n8 U( \4 P2 N#include <asm/mach/arch.h># _+ C7 V( ~8 ~( ?
#include <mach/da8xx.h>: k4 T X C8 L' T
#include <mach/mux.h>
) ?$ W/ ~+ \& ?3 ]- C
j4 G& ^) k5 i/ J4 N% p: h! ~% N0 Z& {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 A; A" e; n0 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 D0 u* }6 H9 S2 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 V& Z- i5 \; N; G' }! `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( c( r4 h- T" r0 b% e1 T1 {! s
) t! A8 A# z% b1 d: f. [- g0 e; r; `/* assign the tl som board LED-GPIOs*/
+ f; \2 `. n7 Pstatic const short da850_evm_tl_user_led_pins[] = {
; ]1 g/ M8 m* s% I: ^# g /* These pins are definition at <mach/mux.h> file */
5 _1 N7 j! K* C5 o' V: g1 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# k ~4 k: p$ S$ e
-1) h; O' c ^0 G7 e9 F( s
};" }# e6 d" c& F! j9 v: d
* g& y+ e& M$ L7 m% s: |: M' G0 z
static struct gpio_led da850_evm_tl_leds[] = {" _4 q4 i/ w. \
{
' E2 n* d1 ^& f .active_low = 0,1 d3 l5 Y1 [# H4 A1 s9 g
.gpio = DA850_USER_LED0,0 Q! C0 ` j w3 Z9 ~9 x
.name = "user_led0",, `$ Q- h, M, M9 j; ^
.default_trigger = "default-on",
: R) L5 ? ~; I },
3 `* D7 j9 o* \0 A0 b4 S {4 a- z( e: v& b/ j* |2 @
.active_low = 0,* }% _$ j3 }5 e1 R" G
.gpio = DA850_USER_LED1,
- s" r- i. e5 C; u' v .name = "user_led1",' u% I% A7 S; H/ p
.default_trigger = "default-on",
; w4 |, D9 L" g1 S3 d1 m },
; G5 N1 C. T& O% T; b0 i$ w" [) t {
, m0 R! F% c( L6 Y .active_low = 0,
1 `/ i9 K' {; K. n# t+ e2 ^1 n: { .gpio = DA850_USER_LED2,
! S3 M% i7 l! ^, y: W .name = "user_led2",$ Y) `( I! z' L4 t
.default_trigger = "default-on",' w# {/ {$ B, J& I- [
},
( o& q+ y, _* j* H, _, X* q C {
, O$ b+ j7 G8 L, K2 e .active_low = 0,* I, r: x( u0 Z# _; w P8 M7 C2 \
.gpio = DA850_USER_LED3, {% k+ G+ k( F, p: C1 v
.name = "user_led3",
: D! y, F* t0 M' d8 S0 L- V .default_trigger = "default-on",
8 t) h0 K7 I% D( w% P" w },& R, S' k! ^* L* ?: H/ }
};
+ q4 Q3 n; i t0 }
0 ^4 x1 b: \* Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ G% m( ~- p L, q3 {2 y, ^2 Y .leds = da850_evm_tl_leds,7 `8 R1 m4 ]* A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% E" M, O& \0 q T' \
};6 q N6 r" R& \/ G
$ o8 T" @7 r0 @- p, @. lstatic void led_dev_release(struct device *dev)+ A: a! h) H# \# M* _+ R
{
5 M4 ]* c! ]' s- W6 R* ?4 Q1 @};9 g7 [5 V" m0 ]' A. N
' i; X. S7 z% I# \% ?( b& B
static struct platform_device da850_evm_tl_leds_device = {
/ t1 C& G8 T) ]1 ] .name = "leds-gpio",
* I! s6 i6 y0 i9 u8 A% L .id = 1,2 a, I& r0 N; R* Y$ f& o# z% y8 F; b
.dev = {8 c+ ?/ d) }; a2 K: u
.platform_data = &da850_evm_tl_leds_pdata,( Q/ p, ~: X" ^2 M( Y, }
.release = led_dev_release,4 o6 }" s* V0 i! W
}
7 L" I7 y/ u7 G};
+ {9 R. l/ U+ T
" Y; j# ^2 @# H( C; @7 K6 Dstatic int __init led_platform_init(void)0 g1 m) @3 Q7 p( l- G! i' ^
{% k' q: L( H9 ^) f; }# b6 i, i1 r
int ret;. E" h' G/ S6 R; v
#if 0; K* t: b3 i" q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ u' e" E+ J5 O0 j; O# H4 V
if (ret)( J$ s! ^& l0 A/ k( ^+ h2 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ o3 ]' U: f) @: Z8 T "%d\n", ret);
& s0 l8 i- ?! y#endif: _$ R$ L3 V7 `% B" m* _$ ?8 ?
ret = platform_device_register(&da850_evm_tl_leds_device);/ T0 ?5 E/ H5 _9 g
if (ret)
3 j4 S* ~ B9 H+ u4 G. T. u+ t pr_warning("Could not register som GPIO expander LEDS");4 F$ i. V# b/ ]0 T7 }0 p I
else
5 ^! d" `& Q7 q( s" M+ [+ E1 j printk(KERN_INFO "LED register sucessful!\n");9 s8 W4 m/ ^! g) g- C8 l
1 V Y) P; P% h$ l
return ret;$ }+ S0 s v a0 p% J$ _0 T+ `
}
6 h* q5 R; d. Q3 e @6 g7 I3 }. ?; Y0 E
static void __exit led_platform_exit(void): y9 w" ]* P& m
{9 D: N6 p, \# {5 E
platform_device_unregister(&da850_evm_tl_leds_device);: t9 E, L7 o5 y7 p8 q3 h) V
- [, a) N& K O# V printk(KERN_INFO "LED unregister!\n");# q/ ]5 q- I3 w$ Y' I$ F
}
+ o( u9 ~0 Q9 K+ @8 j7 J9 A+ ~; w
7 Z% B/ ]; q# \; w+ }8 R! Gmodule_init(led_platform_init);
! i( \7 a& M( R* j& qmodule_exit(led_platform_exit);
3 a) ?, ?( E6 B4 J: d B' g1 o4 S5 v* I
MODULE_DESCRIPTION("Led platform driver");
( O- A% f0 v- V5 MMODULE_AUTHOR("Tronlong");
, f1 `" T5 ], |6 x5 H; N5 EMODULE_LICENSE("GPL");$ A! f6 d+ s) E
7 b9 p7 m7 {4 m8 B: T |
|