|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
d7 [1 T; x7 v; c6 D#include <linux/init.h>5 |; A+ t& Q8 U; Q8 w
#include <linux/module.h>$ n. J4 P, { } T5 I5 t- Z! z
#include <linux/kernel.h>
' }- O, s! `( A8 i! F6 F$ @# z2 w( p q a#include <linux/types.h>) B) q/ x; T$ K8 y6 M
#include <linux/gpio.h>
0 o0 U# _. T G6 Z+ T+ z#include <linux/leds.h>
" i& _. T/ s3 l4 \. S#include <linux/platform_device.h>
j9 C! z# F! C4 m/ X/ D# |5 F7 s4 e: m: T. T2 P1 F
#include <asm/mach-types.h>7 L8 B. ^3 _2 a S# i
#include <asm/mach/arch.h>' P# |3 m( u/ F3 M6 x7 T0 H) y1 }3 g
#include <mach/da8xx.h>, Y' S2 H1 t- q: Y! ?9 n% k5 N1 i
#include <mach/mux.h>- L1 b3 |( S! b& q' g' ?
6 t! I6 G$ C' S$ U* R2 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! E' F2 g8 `" z4 T( K8 s/ ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, D3 t1 k" [8 K8 T6 ~: v) t1 {5 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 a& o f* `+ E- \8 o; c* W* ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- J6 O, b7 h0 _* k5 p
0 a, }9 T c; \) V" @ ~2 i+ e/* assign the tl som board LED-GPIOs*/
E: M# b5 s1 X) qstatic const short da850_evm_tl_user_led_pins[] = {9 c8 }% ]% U0 z7 f7 m
/* These pins are definition at <mach/mux.h> file */& P( o* _% w1 h1 n1 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, W' n$ {' W; K/ y4 p: E' n
-1% i2 u: H, h2 L c
};
4 ^( W& h! f2 ]; a7 ?$ r$ e6 a5 W
8 E$ k: k. _. M/ d$ R0 }/ Nstatic struct gpio_led da850_evm_tl_leds[] = {
2 U' W, i5 l( g) d* c; v {
8 ?6 Z; X; x) u: g G4 D .active_low = 0,
& x1 t, I" r$ V0 {' g, y7 P .gpio = DA850_USER_LED0,
; m- n2 Z: u; _4 M$ v% V: Y2 w .name = "user_led0",# K9 Q( n( |# T5 R* E0 k+ h
.default_trigger = "default-on",
4 O; K0 t1 k$ O; T e5 r6 b- {: X. y },
' [+ r. w8 R4 f) Y- t( E {* u- q u! _! D* @& U) L% g ?
.active_low = 0,9 G T/ S: \8 U. X# ?
.gpio = DA850_USER_LED1,
$ F5 N% f* _. w' `5 O t3 U .name = "user_led1",
6 d% n [# W3 R6 T5 J .default_trigger = "default-on",
$ {: R( T) `' Y4 y$ c: B9 K },$ s0 f7 x8 e/ q8 A; R
{
' ^$ D& [. g6 G5 f/ W) |5 ?+ S& ^ .active_low = 0,
0 \- o/ R" |( R; C .gpio = DA850_USER_LED2,/ ~$ X0 u# G% U" G6 k
.name = "user_led2",
0 W. g' l: H( [( O+ w" m6 P .default_trigger = "default-on",
4 P; |/ u) W/ D9 n },0 R8 k# [" [2 \( d" j4 `6 _# s
{5 S1 e5 e, m ?) @- Q) G2 m
.active_low = 0,
9 x* q9 N d1 P# s .gpio = DA850_USER_LED3,7 U! Q# h9 C) X% H
.name = "user_led3",
( W" y% {6 D* ~% N3 Y6 T1 f: s .default_trigger = "default-on",) f( H, R& c6 e3 n7 Z/ J: R2 G
},
9 `" w, g2 Q% i. c( {+ i0 N3 v};5 r; y& c; J1 K/ F0 U4 F
7 L* o0 k9 W2 G. [6 m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ U8 W# V7 Y: |9 z& v9 z/ R
.leds = da850_evm_tl_leds,2 X4 j- Y' |4 P1 o4 q7 d3 Y' M' O5 u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 \3 x2 a* F k% U& g& e9 V};5 T4 N/ |6 d3 w; h* N. ?+ B
, H, a( Q* t- L% K- F) q" R
static void led_dev_release(struct device *dev)
# `3 t/ }4 Y( U+ E4 ^/ t{; D [; d' C& S/ }6 G
};5 Q2 O# g0 _! g4 Y, E+ H9 W
* e+ `' N) T( s: q5 \0 f% ]% s# `
static struct platform_device da850_evm_tl_leds_device = {5 v! K2 s! `( r' O
.name = "leds-gpio",
; _/ E: b7 s7 V# X7 f- g .id = 1,
2 h7 e3 ^( Q, r" x# h .dev = {
" q6 I; C) E. f: z) t. H0 h0 { .platform_data = &da850_evm_tl_leds_pdata,
& }, u4 T, ?4 @1 A .release = led_dev_release,4 k- ]# ~& v, {% p
}3 b" V' T% s! E% Y+ S
};
# N: {- L* N6 S; j: L- w6 h/ L: c9 D8 x' ^0 v5 d4 k4 N( j
static int __init led_platform_init(void)" p8 z1 Q% ] [3 E8 G
{
" L; B$ F. c5 g" T3 m0 t$ G int ret;- T" B& S6 T) T
#if 0/ a8 t: I; P/ ^3 ^7 W0 C" U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ f# c& X+ D0 j) K; X5 `; @
if (ret)
# x" l; F9 m2 D7 D& {5 U8 b- o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! D" p2 y: Y4 f( R
"%d\n", ret);
2 ~7 C4 r' n/ J0 _# `" Y u' B- b4 }#endif. |7 H4 D$ C: l+ }
ret = platform_device_register(&da850_evm_tl_leds_device);
( J2 r* C( n* U4 D: y if (ret): ]9 b! Q$ J9 z; m- d
pr_warning("Could not register som GPIO expander LEDS");
% n$ w0 m9 } ?! N9 s' f6 w+ y else E& d- I H( L7 Z% d% t k7 G# b
printk(KERN_INFO "LED register sucessful!\n");
( B T4 B0 t& B9 m
! h. K2 y8 ?7 O0 p4 e' X- m; W return ret;0 n, d& Z0 Q) P, J( j( ?
}: b1 A, U0 X2 [9 w9 E9 H
$ G# g* ]# q: p& g- b0 Y) m& ~static void __exit led_platform_exit(void)
4 g9 T8 T u: u _# r$ i7 T{8 G) A- A9 e! N, T* J8 ]0 E
platform_device_unregister(&da850_evm_tl_leds_device);
: \0 V" ^/ k+ @
$ P( ~0 u, d ^& g- L' G printk(KERN_INFO "LED unregister!\n");
4 k$ b# H! q/ S; j6 m8 A}+ o5 {$ I6 a* K1 e
) E' ^- b4 I* I0 v( K: {. J5 Smodule_init(led_platform_init);
$ V+ B' Z) ^7 S8 D* m$ J$ t! Fmodule_exit(led_platform_exit);
% y# G8 [3 ~. N9 b$ u8 c: a
5 l& d6 p" W# W- [MODULE_DESCRIPTION("Led platform driver");
: d) {" L: H6 L+ Y& ~% X1 GMODULE_AUTHOR("Tronlong");
: P. O% K4 \* ?. V" U0 n& T+ @MODULE_LICENSE("GPL");
: X. \6 |9 E8 A5 J+ q9 h, N- k t# X& l; e# g: T# H2 k& _6 f
|
|