|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, |& U; D! x, R* Y8 O0 c#include <linux/init.h>. c c1 s$ `7 N8 t4 r. H5 F
#include <linux/module.h>$ `/ [1 P/ S: S6 p# J. q/ L
#include <linux/kernel.h>1 |! p6 Z% ^' [6 c) q
#include <linux/types.h>
0 p; S! u V' m4 o: m3 r#include <linux/gpio.h>
. @9 U5 D5 `' A6 M. ]* X#include <linux/leds.h>
. _. x* Y% b$ t; \#include <linux/platform_device.h>. I- U0 [0 g; a( {7 h" d) w( w
" Q+ q% g2 N& J0 j#include <asm/mach-types.h>
4 f# T" L, J9 Q: s, z6 H- Y#include <asm/mach/arch.h>: y# }9 y! n) ?$ @7 y# t- a( G
#include <mach/da8xx.h>
1 s) G L( G- l) |% q. O+ i/ e#include <mach/mux.h> ]% U: b/ e" |/ g: ^
) J& X+ X* j8 @% Q4 k( n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 V$ E& @( \% `5 M" r& P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! d7 {/ _) k% g0 ]3 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) ^6 E$ {+ j9 Z1 y0 O; Q& ?6 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ }9 K' R! b6 @1 w! X& e9 q9 h. a, M3 G; `) j- _8 ^: \
/* assign the tl som board LED-GPIOs*/4 f# @3 E2 u: E6 |0 V) ?
static const short da850_evm_tl_user_led_pins[] = {! I5 ^, n H- g+ A- V: {6 H" a3 F4 T( D
/* These pins are definition at <mach/mux.h> file */' e# w0 V2 G) M' Z3 ~ g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 |, y2 H5 }4 I/ Q2 I T9 A -1
: f7 \7 ]' A: l! C3 P" l};, a# I8 `# Y! Z7 r( L g
+ S; U2 [# X4 ?% L' w# a# c' L' Pstatic struct gpio_led da850_evm_tl_leds[] = {# v$ e: q! }) @: d
{4 F" ]. @/ U6 s2 ~
.active_low = 0,
/ O3 c- P2 h2 ~ .gpio = DA850_USER_LED0,
$ D7 r2 f. t' Q .name = "user_led0",. }) M& L5 D/ q6 a/ H! y
.default_trigger = "default-on",
* m3 }+ R) b) @$ `- S },& Y( E% Q& g% f! t. B+ z( r
{
. u5 S" v) M2 N) ] .active_low = 0,, O5 ~* v& T! \, [$ _
.gpio = DA850_USER_LED1,
/ H' a, W$ J2 I) f9 E: f5 `: n .name = "user_led1",
) S& u! M$ ]1 l, e: g .default_trigger = "default-on",
% F5 x2 Q% K" m# r' X5 k },, `* e( |' n0 z8 S6 ~
{' V+ `! O3 o2 E- U+ I; ~4 ]% O
.active_low = 0,
! y) t, T/ V7 A' m* W .gpio = DA850_USER_LED2,5 X* h8 L2 B O' K
.name = "user_led2",
2 S; d* ?& d N. k0 c0 p+ u; I; D .default_trigger = "default-on",
: z+ f G. U- N1 f; F' J6 r; t$ E" [ },
& `! U" Q# ~0 n4 }! { {
9 y9 L( J s- w/ O* R' y .active_low = 0,
2 H9 H, B- ]0 Z8 `3 D .gpio = DA850_USER_LED3,
. H: D- A% x" {8 s$ w$ p .name = "user_led3",
: }/ P7 J+ T9 I6 \" O4 p0 s .default_trigger = "default-on",/ ^/ b3 y9 V/ ]& V6 B/ \; i; W1 X6 R
},
+ R& L/ O& j! e9 B! e( m, h% u};
2 N5 ?9 P- H; C: X% ?' k6 n4 H" V! p2 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 A4 P/ u3 i' n% q
.leds = da850_evm_tl_leds,
) s: M& {. J( w# K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 _! p# s( E, E* [6 g7 z8 F g7 C
};
) Q& Z2 l, V4 H# F) A& V
* Z( I! l% @' i! ~static void led_dev_release(struct device *dev)! f* z# V. ?$ C) |: X
{
0 }1 V0 Q5 K( y' a) h& E1 d};! Z! P+ ^& E9 d! a' j5 D9 e1 I8 h
- ~$ D- W4 B# D
static struct platform_device da850_evm_tl_leds_device = {1 b: S! B/ w% V/ r
.name = "leds-gpio",
8 o1 P0 `# l2 Q+ U- ]' N4 x( U6 | Z .id = 1,' N; w% B R- @- P& e
.dev = {1 q- W0 z3 y/ v' X( a7 M* J! L5 d
.platform_data = &da850_evm_tl_leds_pdata,
3 _' p; N7 [) ~, y$ ? .release = led_dev_release,
8 I; A& @: F: ]1 \+ O7 H }
! b2 U$ _7 Y4 W/ F# o};) j W2 K# e- x" ?1 e& w# A/ ~
+ F2 G9 W5 T: c! e
static int __init led_platform_init(void)9 Q0 b; m" n, O+ I; [" M
{
6 S x! {2 Q' ~/ x int ret;& E4 A) Z6 u2 A6 B, H4 w/ t8 X
#if 0! L; p- v+ L- u& S( L e% D5 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) ]( P4 [& T, R: a3 d7 `- z P- i if (ret)5 P+ [& c/ K+ E4 d* N- R" O% Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ R' I# ?/ X3 N+ N "%d\n", ret);1 a0 @- Z6 G% f( _7 D6 R. S5 e
#endif/ a+ [% l; G$ u5 j' o1 f3 n3 O
ret = platform_device_register(&da850_evm_tl_leds_device);) g a: ?& j( X* a
if (ret)
- q0 f' i" X. O3 e/ Y: w u6 G$ F pr_warning("Could not register som GPIO expander LEDS");8 ]/ [0 H: _" S8 s
else x. ~0 _4 X* I9 U
printk(KERN_INFO "LED register sucessful!\n");9 p! Y, {' @, }: u3 y
s2 ?0 B' U% p# N- v$ s+ w return ret;
2 T/ N; y, w. e0 t}
0 A" s: @! V7 `
; J$ D: N3 c1 F- _9 lstatic void __exit led_platform_exit(void)
1 e8 O( g8 g H$ j; O{$ G( ^. A* u E8 m% `$ V5 _3 W
platform_device_unregister(&da850_evm_tl_leds_device);
5 Z+ M9 Q. |3 d: G3 }( M& [. e8 d9 s8 N3 H) g7 L
printk(KERN_INFO "LED unregister!\n");
; L7 X; S3 u2 E4 w: G4 v% v}
. V! I6 x: j% f. s" S
: y6 ]# O- D. `; @1 y/ `; K" m1 U4 Vmodule_init(led_platform_init);
8 b5 p4 x. ?' ]" a o# Lmodule_exit(led_platform_exit);
1 k) m+ r6 w. h# t$ ?3 j- W3 C% V! x0 A0 m5 o/ c- b2 Q8 `! D* p
MODULE_DESCRIPTION("Led platform driver");
( T6 a2 E9 e3 _8 o* _5 `5 vMODULE_AUTHOR("Tronlong");
& i/ M4 E2 d$ q( UMODULE_LICENSE("GPL");
2 O& L! f% O+ S& w3 e
* t, {+ m9 b1 e" ^) d* g9 e |
|