|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 c+ k4 D. \, `: l
#include <linux/init.h>
3 C. T% [) Y5 r3 B L#include <linux/module.h>+ n- s8 R9 q1 i( x. R
#include <linux/kernel.h>9 {$ t8 I# X" S' m, i) i0 r& m5 p
#include <linux/types.h>+ F7 b& d$ e* A w4 C" c
#include <linux/gpio.h>
5 q$ o4 n2 u: e) l( w#include <linux/leds.h>, s8 H6 `/ {- h0 }$ ?% x" |
#include <linux/platform_device.h>" x. p* Q8 u+ y9 e6 H4 e
8 m- T+ r$ `' V; Z s7 ]
#include <asm/mach-types.h>7 y' o2 e+ d! N, k. @% p! [, d
#include <asm/mach/arch.h>4 I5 N) o( F1 ?! Q5 ]
#include <mach/da8xx.h>% |+ W5 D. Z* n- F. S
#include <mach/mux.h>; U0 e5 V: w9 p+ |
# Y3 ]; S; M/ T# V" K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ I; j+ U5 g" ], }+ p& {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 m, t8 v5 l6 N S0 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ u0 c+ O* S) p2 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 i) y S; @ ~" u1 R
6 w! Z$ y5 y6 R7 `& k
/* assign the tl som board LED-GPIOs*/
% Y q( ]4 R$ s+ @* b# R8 @static const short da850_evm_tl_user_led_pins[] = {
7 G1 V" L0 }3 |" Z /* These pins are definition at <mach/mux.h> file */
. t" N. E. k5 ~" ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 P% G v0 l4 }4 d: f& G -1
! V0 U4 l; R p};+ v3 n" s1 b4 h. O @! h
9 k8 r6 m5 Q5 l0 Y% C5 }: s/ o
static struct gpio_led da850_evm_tl_leds[] = {" ]8 _; L3 n" a/ c: O) r; ]
{
* h" v! j2 b3 o6 @: N# n# @ .active_low = 0,
! C" M; s: k' d' h1 q& C/ U .gpio = DA850_USER_LED0,- _/ }- K% _( i" P" [/ @6 v% q- z
.name = "user_led0",7 L. y; c! n7 N) F$ P: ]% Q
.default_trigger = "default-on",
/ C5 }1 Z4 D5 G4 ^0 V' ] },
0 N3 R+ a! ?4 h {
& y) B# D! {" a0 W. q8 M |! K .active_low = 0,7 G% H6 Y7 |! g# S/ b
.gpio = DA850_USER_LED1,# l( S; i4 d: {! O: K
.name = "user_led1",
/ q1 u/ c) H& }: o: L .default_trigger = "default-on",& F) ]7 K$ |7 z- t6 s
},
+ l5 F9 s# q8 n4 d& `% R8 J" h {
: R* j! I* k) C0 m& ^ .active_low = 0,
2 v- T0 `8 M( r; a/ j: J/ _ .gpio = DA850_USER_LED2,
- u) U# m$ ^+ O .name = "user_led2",
& v; o' h! u3 A# @; f .default_trigger = "default-on",
2 B" _3 n4 D2 x9 F, w* i+ R2 ~, ? },
' {: V' e& Z7 K0 H! i! r7 Y {
/ o& v8 D+ S2 f2 g; `: ~; m .active_low = 0,1 z" _) ]& o% ^2 e( ?
.gpio = DA850_USER_LED3,
2 H$ G) Y' k- C1 D; a .name = "user_led3",/ F2 ]) Q6 `9 ~
.default_trigger = "default-on",
" d: w# v0 v1 [8 s1 j6 a },0 x O2 s! R7 a H3 g1 [
};2 V0 N( z6 K% w
# P! M |2 [ c4 O+ G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, v4 J* D( P0 {% ]4 E" Q
.leds = da850_evm_tl_leds,
, ]% C- o8 ?" i9 s' E# A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 J- N& @/ |) r: H1 Z( B5 z
};, b0 ]6 g: E% N# X5 q& U- }! e; Z" U ?
' v( l% [2 P" n& |
static void led_dev_release(struct device *dev)
" s8 ]: ^+ ]5 s9 |) @{
& c9 d5 T9 V5 m7 q, ]6 z" K& T};
" T1 H2 \2 e' h2 ]- w& ~. t3 h/ ]* D, m \1 T
static struct platform_device da850_evm_tl_leds_device = {
$ P0 x: p) h% V2 | c .name = "leds-gpio",
" i# D! r! F; R: J( T" t! x- s+ m .id = 1,
7 `/ W# G, z6 t8 e% q) A .dev = {2 O% |' C8 v! h3 ^0 Y
.platform_data = &da850_evm_tl_leds_pdata,, A, J( N) L2 P8 {- {7 ]
.release = led_dev_release,
2 S8 a" F! P" I- ^. s }5 ~, h2 v7 H+ t0 R
};) X/ x( Q5 N; ^. ?% a0 K7 ~" b
: C( H6 K6 \ tstatic int __init led_platform_init(void)0 t5 L, L# R, E8 v% ~9 E0 h8 _. t
{
% x6 W8 G! @/ W, N2 [: c int ret;7 I0 [5 V' v+ A9 ?
#if 0
& e5 u' z! E8 l% r4 x' R# B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. a* k$ ?7 t3 z# z8 ?
if (ret)
. c8 x+ p `2 k4 ^2 W4 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( y! g7 `0 E2 Z+ L' j# o$ o
"%d\n", ret);5 B( D2 ~: F' B" I( y% |$ Q
#endif
6 Y) d5 R( R9 E& n5 _ ret = platform_device_register(&da850_evm_tl_leds_device);
9 p. K* D& S$ k if (ret)
. U4 L2 ]" S p6 E# B/ K* V* V pr_warning("Could not register som GPIO expander LEDS");
& R0 [4 ]3 O# d9 D; V& n0 l! O. l else' t6 f- B, d4 l" t2 J) ~* u
printk(KERN_INFO "LED register sucessful!\n");
/ x5 e3 E. }4 V+ ~
, e$ [0 }' n. B. o return ret;6 f- y {" E" |$ ^$ T3 k
}' n r2 K- |0 K& t
) I8 V% f1 O/ S' \0 \
static void __exit led_platform_exit(void)7 G0 j' |+ m# V* `" d# h- Z6 h
{
. G; Y* [. s3 p! s& c platform_device_unregister(&da850_evm_tl_leds_device);
' J, s4 u3 Y. X Z$ V0 ~5 w( M4 `$ M; X' a9 H) B
printk(KERN_INFO "LED unregister!\n");: c( V8 H0 {. s2 U! G: t- D/ e
}
' j% v4 ?: I: V$ T" c$ A0 N
) Z- @) ] I9 U, v/ L9 xmodule_init(led_platform_init);7 ?9 E/ y2 X* x8 N2 Y1 b7 C0 Z8 z
module_exit(led_platform_exit);0 y2 p8 ]: z9 k! H
3 F' E- _6 ?8 i
MODULE_DESCRIPTION("Led platform driver"); } e8 t7 v* e, { y- S- j5 C
MODULE_AUTHOR("Tronlong");% {8 d5 E) V6 m
MODULE_LICENSE("GPL");7 r9 y. w6 s3 T( @0 u6 H0 ?
' V$ ]+ x/ O# _1 U1 {: R8 S |
|