|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, l6 i9 z' g5 U/ ]#include <linux/init.h>
+ i; ?8 }# Z/ q, ^2 c#include <linux/module.h>
+ O: q# m. v6 k+ F+ i+ u#include <linux/kernel.h>8 {$ i1 i6 X# x) [# Z
#include <linux/types.h>
6 R" E! y; I0 a* l( `! v5 C#include <linux/gpio.h>, r1 B2 o3 d5 a. m+ m" R f
#include <linux/leds.h>
/ L* G5 X. c) ~" c#include <linux/platform_device.h>& y, u) B& C; P8 H. E" ?
% J1 C) J- @* k( Q* e( j% }#include <asm/mach-types.h>$ _! B9 [+ X2 D+ V- J8 ?
#include <asm/mach/arch.h>4 I8 A. x4 _2 A7 A( m( w8 O$ q( @( `
#include <mach/da8xx.h>
" N* {% ^" N2 j) d#include <mach/mux.h>0 N* Z- y: ^; T% D& _
$ @/ P# \! I2 e2 I, Y4 w6 e- F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ N% B' o) Q$ J K' `. [/ C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# \' T5 y& K. }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) _6 C6 k( F. f, K" o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' e! K0 d3 H0 r( \* f3 }" q) g- y% o5 g
/* assign the tl som board LED-GPIOs*/$ M* {; [2 J, H2 o# i
static const short da850_evm_tl_user_led_pins[] = {' [7 F7 _( I$ S, O) k+ y
/* These pins are definition at <mach/mux.h> file */# f( }: N2 Q5 ]( ? O! j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- L& ^3 n Z* p- d: A) u( Y
-1
" x+ ?( I) j z) M8 P/ f};
0 I) Y/ _$ I: c' @7 C3 D. M$ @) ^2 w" E4 l: S y1 ~
static struct gpio_led da850_evm_tl_leds[] = {7 Q" I% d2 e: W- _. @+ M0 S9 C
{5 H- t* T" n( c" a: V# s E
.active_low = 0,( z' }# i( H5 S6 W
.gpio = DA850_USER_LED0,
# M) X- ~' g: ` .name = "user_led0",
/ }# x: C% S X& E .default_trigger = "default-on",( `$ K1 s1 o. G9 c* E; c
},/ i5 |, \4 F$ p4 \7 V2 p3 C
{
3 x4 [$ `3 O8 Q+ K( V& p9 p .active_low = 0,
2 ~- C. b3 Z; _( M4 h .gpio = DA850_USER_LED1,; J5 L2 ^0 _, Z* L& E9 c; r' Q1 W
.name = "user_led1",/ l5 O5 Q) t# O
.default_trigger = "default-on",
6 t2 R" H& X. Q+ O% z- I; Y n },0 t6 \: K2 }5 x3 E+ t4 c
{' Z9 k$ R7 {/ Z2 c" g, @, R l1 ~
.active_low = 0,
5 y. i# d: W8 a: J. P( {& I; p8 A .gpio = DA850_USER_LED2,0 N( T6 Q. [9 W6 _1 U" b' c" o
.name = "user_led2",
, y! `8 A( H# ?0 E0 f# k2 U4 A! @8 C2 { .default_trigger = "default-on",: v$ O3 q- ?: I5 P
}, a! `0 e) U: r6 C x" |
{& j( T# q5 t+ r0 G
.active_low = 0,
, a# \4 c+ S1 T! v .gpio = DA850_USER_LED3,
2 ~; }1 I8 c! j( T+ X! B J6 M% O0 P* |8 l .name = "user_led3",
+ B7 o9 k! V8 ^% n8 d- H& o2 R .default_trigger = "default-on",0 Z( j: F( }& O$ `7 M9 j! S
},
+ i6 ?: u) p* ]- g8 F3 V7 {; K R};9 s4 q4 t* }: l" k$ a# { G- S8 r0 x
* N+ F# y" H7 F0 q! B- M2 o6 z% z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ V) O H# z' T1 ]. W( y .leds = da850_evm_tl_leds,6 U5 Q6 L3 o" y" k# S3 I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, P1 |6 E+ ~( {" k7 }};, ]$ g- f" \7 ]0 }! L
" S2 M9 a D5 K. W) H7 Tstatic void led_dev_release(struct device *dev)$ t0 A1 |& F4 l2 _
{& l2 u7 V8 b( a0 Z' K P4 M$ k: t
};
: c/ ^5 X% s3 f" M( l0 j: r* _. V* F% a! f2 r
static struct platform_device da850_evm_tl_leds_device = {& v8 v N1 P4 X2 v j! @
.name = "leds-gpio"," ?% L3 ?' @+ k i% ]4 L
.id = 1,2 |& Z$ D$ H+ Q' y; ~' M
.dev = {, o0 B5 L* G+ i* u
.platform_data = &da850_evm_tl_leds_pdata,- r0 d* s4 u2 B+ u7 F
.release = led_dev_release,
! h1 }" {- p, b" Z' w }
- {, z& T5 [( Y# A};# P. `9 \/ o" E! T" n
# G. }6 i. a. R( T% ]
static int __init led_platform_init(void)3 v; h' |- _. f: }, O$ |7 f; y
{
B& J2 H: F1 c3 X int ret;9 R- s G- |- c' x8 ~3 i
#if 0
) ~( T$ t( i4 C5 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. \6 ?* B& ^2 M# Q
if (ret). Z; p; {2 V3 a3 ^+ l6 P2 M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- ?! j4 u" e6 d6 s. w4 s$ L% @
"%d\n", ret);: @! A; A. X5 O6 V9 F
#endif1 C; ~& @( {" L
ret = platform_device_register(&da850_evm_tl_leds_device);, G4 _, ]* u' ?" T. e& I
if (ret)
1 z3 k" Q1 R+ K! @9 @& H5 t' m pr_warning("Could not register som GPIO expander LEDS");
/ |: w: {+ |3 L else
& S" m4 m* P$ i0 Q! |( L8 i printk(KERN_INFO "LED register sucessful!\n");( I5 t! \( |- j- [+ Z% A+ A
# z+ {! _, [) [/ X- K6 ? {( [
return ret;
: y+ {! M" _. R: f* K1 r0 k}
! e- S# V8 i6 N2 d/ m9 R& x
* }- T. ]1 ^2 o% q! P6 xstatic void __exit led_platform_exit(void)3 Q8 J( [3 D5 q2 a9 f2 Q, f) F
{1 r" n& U! c; t ?$ f: ~
platform_device_unregister(&da850_evm_tl_leds_device);; |6 m% U! L' L! ?8 N! d
' V' B' _' I! B) i
printk(KERN_INFO "LED unregister!\n");
9 T4 M) \" Q1 O" ^8 H+ ]2 z7 B3 M' l}7 L' @ J" y5 X1 |0 ?7 j7 Y
% u9 z' \& c' N% \& K1 rmodule_init(led_platform_init);
/ |" c9 R7 l) g9 S- @module_exit(led_platform_exit);
5 U4 F9 H! z& p8 ]4 M9 u6 d
' Q+ t2 G2 k$ LMODULE_DESCRIPTION("Led platform driver");+ n8 N+ p; X5 x: `
MODULE_AUTHOR("Tronlong");
- b9 s) A4 Z/ U4 tMODULE_LICENSE("GPL");) `# i) v+ e5 l6 n. G
9 B; @6 d' M2 E; A
|
|