|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' }3 I* S1 x4 k& ]3 U4 x* A#include <linux/init.h>
C& M8 f9 v- B' S#include <linux/module.h>
4 W7 H5 q) z0 o6 x1 ]; F2 B#include <linux/kernel.h>
% V- L- k. ^7 _, s2 l4 M* {#include <linux/types.h>& c a! U" |6 u: R
#include <linux/gpio.h>! X5 m- j' X; g5 L, F8 u
#include <linux/leds.h>
5 d& G# p. _( x+ `! `. j+ A% ?$ Y#include <linux/platform_device.h>
4 } k( |# R4 h) c* h" \+ U7 h9 j z9 x4 ]
#include <asm/mach-types.h>- M- \# B/ f5 D/ @, r
#include <asm/mach/arch.h>3 e0 ^6 }$ Q Q7 s- ]9 }# e# T) a- M; x
#include <mach/da8xx.h>
6 F9 ]4 r- W6 f. \3 z#include <mach/mux.h>
! o2 C4 p2 {8 m" a3 p, }( m) V/ S/ L
7 f% x! K& m$ J) q# I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. S- L# t. t4 o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( s% N3 n m1 r7 k- {4 Y* k8 a2 s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). C9 V( f. P' s& S9 D& [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ c1 W; r$ Q+ Z! x n( _
+ E$ s) Q! c/ u& E/* assign the tl som board LED-GPIOs*/
- Z( f: T1 N. s% d. Pstatic const short da850_evm_tl_user_led_pins[] = {8 U$ s- |. s; M4 P) J
/* These pins are definition at <mach/mux.h> file */1 v1 N6 `; ?+ l! T7 |, J7 E3 A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 x9 u5 O) L+ J, y) z( x% l
-19 a3 I8 r) P6 q( A: a. L
};
+ i0 ]) E. Q& p0 A7 ?4 Y/ _. Q0 k w$ |% R- o6 T0 l7 U e1 }6 n" R3 Z
static struct gpio_led da850_evm_tl_leds[] = {. U. y5 \' o; u8 A+ e
{
' j3 W1 b8 s2 `% @! n0 a .active_low = 0,
6 }! m" ?/ [& I; Z: S( K" @: J .gpio = DA850_USER_LED0,2 T& H, {/ P3 {( \
.name = "user_led0",7 K& A4 {9 z* N
.default_trigger = "default-on",
. k6 K' K+ x* Z5 q$ [! j6 @6 G% w },
) d2 `3 ^9 h1 k( S1 w {
5 T$ F4 O% V; \* M .active_low = 0,
* `+ d1 S; H4 }5 S7 P0 a* r .gpio = DA850_USER_LED1,' N4 \: o! H; q% A2 v8 J/ f$ X) ~1 u
.name = "user_led1",
9 l. @) t. Y+ [% V [8 s# k .default_trigger = "default-on",
0 g9 Y# J7 t6 b0 c* E8 n9 Y },1 X9 y* w8 N3 F/ s1 m4 ?
{
/ M7 u& z% p" V; n( o8 q" ?0 | .active_low = 0,9 C* \ K% s* B+ n/ M1 Y
.gpio = DA850_USER_LED2,
. |$ \& r% F$ a .name = "user_led2",' g$ ~. D" ?1 I' V3 K+ b" D( Z
.default_trigger = "default-on",
4 J& Q! b2 }$ \7 l( K$ g },
4 V; S$ p3 A9 E' K# i7 h {
4 d7 ^. Z, O1 b/ H .active_low = 0," J. c' t% v2 u( t' e8 G- \6 L
.gpio = DA850_USER_LED3,
: u2 Q& }# P- p6 ^% R' o .name = "user_led3",
0 c: x9 l& h7 c- f* d2 ?. d$ r .default_trigger = "default-on",
' d9 k5 w$ R$ G5 V Z, ] },
' ^8 v- K# e/ x3 V |: d};8 d8 A& G. G; b# E
' q+ y3 c4 O$ b1 t4 M6 x, W+ Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 q! _9 d$ z+ t9 p
.leds = da850_evm_tl_leds,
1 k }( ]* F6 V! z" G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) a" p% U3 E) B7 K0 |- ~9 z0 g};3 }/ N2 t2 h7 H3 x6 {/ X
+ E/ e* N: S3 v' ^ f" ~: t
static void led_dev_release(struct device *dev): ^; y4 u2 Z- S8 e9 a( J
{
5 H* K7 E" }" R# R4 }& I};
0 E+ u; J+ c' r6 N4 T$ D$ h# t3 N+ k" b+ U `. U1 s8 d" a% K" X) H1 q
static struct platform_device da850_evm_tl_leds_device = {$ U1 U9 a; O+ z. J
.name = "leds-gpio",8 I1 T, `4 o; l* h. k% U# z8 B5 [
.id = 1,
- N& ]: H2 u+ u4 L .dev = {
, r( E- c% }6 ]3 u .platform_data = &da850_evm_tl_leds_pdata,5 s8 l6 D* X+ g7 H& D5 ~8 s
.release = led_dev_release,
5 A: |: p. T* W8 E. n; X0 N }
; X' f! x! S" v' P; I! m5 N M};
8 H' [: o6 O( ^' ^
* P( B; g3 @3 U7 @/ ustatic int __init led_platform_init(void)/ d; n. S# g4 o$ }2 C: y w$ @
{' r4 n U. q( m3 \& y; H$ K
int ret;, k! Q9 T+ q8 C. L1 ^8 k, k
#if 0
. F+ P3 s2 @4 c8 V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ b& a H7 H6 r6 ~ if (ret)- A4 ~3 \, K0 w) E3 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 _2 `: D! B- ^3 j+ c) c, W
"%d\n", ret);
# A# M) n% [ t, D3 U* _& T G#endif. Z T" j* h# x- e+ u6 q
ret = platform_device_register(&da850_evm_tl_leds_device);
" ?1 |# {; j K if (ret)+ @ z) H* b: M5 q |2 w
pr_warning("Could not register som GPIO expander LEDS");9 s- m2 \' r; x* [; U
else# t9 c3 T- ?% h( F: G
printk(KERN_INFO "LED register sucessful!\n");0 x$ m% v8 r5 ?4 i: x! z
) K# y) O8 [3 h& s7 |5 w2 d/ Q return ret;
' z# q- f; T' V4 h$ |" S6 Y) `}
3 }' d: ]& J N' b( _$ R+ t/ A1 k1 P4 ^' o
static void __exit led_platform_exit(void)% C0 Y+ L: L6 B! \0 Y
{
8 v, q' v6 M% | platform_device_unregister(&da850_evm_tl_leds_device);
) B3 v- O, l, e# G; X- ~$ W: k) a% a9 a! w3 q9 e
printk(KERN_INFO "LED unregister!\n");
1 ]9 x0 E E3 g1 l, x3 E, P}- Z: K' z! A! Y) |$ I' x
- z! \3 E. a( j. y: J9 n1 bmodule_init(led_platform_init);
3 d7 u( W7 A+ C0 B) Q( _* ` |* xmodule_exit(led_platform_exit);: T9 e# ?3 ? b/ [4 u
: J' T5 d+ E+ fMODULE_DESCRIPTION("Led platform driver");
- H$ M8 O6 e* Q0 C0 X# YMODULE_AUTHOR("Tronlong");' H2 R& O3 O% ]! ~/ Y7 {: q8 r
MODULE_LICENSE("GPL");% i O$ z9 G% V' w# {
/ q( ~5 V% Y8 ?7 g/ C |
|