|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. |5 g5 N7 l- i, ]" ]
#include <linux/init.h>
* i/ w& L+ d; j" q8 a1 _#include <linux/module.h>6 U- W2 E# d: x) x# p
#include <linux/kernel.h># m' j) k7 l. s( { W( A
#include <linux/types.h>
9 V- p: b6 O, Y; }7 `. M' u. F#include <linux/gpio.h>
7 _* U8 A Y$ l' N#include <linux/leds.h>
- u% r# p" N/ l( M/ O) A#include <linux/platform_device.h>
" k! F w6 ^0 C- g5 x( I
7 A- ^+ b( T8 k- o7 M4 k#include <asm/mach-types.h>$ N( _2 j W; j* m- H, Y, H* Q4 H
#include <asm/mach/arch.h>
1 w" z9 e7 h1 F' S5 X0 M2 j#include <mach/da8xx.h>
6 p7 U# ~1 e, M8 H#include <mach/mux.h>) |+ T2 O- N! M* Z9 U; g q9 o L* ^( p
" y" O. X0 ?5 ]5 [5 o6 {4 A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 K/ F0 r$ \3 [% @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! {+ Q/ }% h f% B1 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 H* M! a, ]$ Y' s4 M& n" G9 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ }0 l, E2 v1 o2 C7 z) [2 C" s! W3 H# P' b B# ^
/* assign the tl som board LED-GPIOs*/* ^8 B- Y( X& e3 r# b1 j
static const short da850_evm_tl_user_led_pins[] = {
! t- P% i& j0 B z! g' b# [ /* These pins are definition at <mach/mux.h> file */
5 `5 E( R( L6 Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 n' O3 a1 R0 n4 t. O
-1
9 L6 r6 C- O$ C. x};
) `5 h( W0 V# t# I2 x1 u* g6 r- k4 G/ U$ Q
static struct gpio_led da850_evm_tl_leds[] = {, p/ u1 x m9 w1 _! }& n" A
{% m+ [7 V; W5 w/ u) d. W5 b
.active_low = 0,: K$ ^/ d, k# F* F* Z% I
.gpio = DA850_USER_LED0,. _; G9 q+ x) g+ }# I* V
.name = "user_led0",6 y3 z) }" N3 X; B3 D* g
.default_trigger = "default-on",# k. U7 Z/ f: g; s" c9 X
},! N3 R. g4 k# b5 S$ R: M) Q$ r
{+ q/ Z. ]* y9 C4 ~
.active_low = 0,& B% h5 S( A7 O" b I8 o
.gpio = DA850_USER_LED1," ~7 |) `7 ?0 i1 {9 U
.name = "user_led1",
6 _/ \/ g9 T+ K5 l1 X. i .default_trigger = "default-on",% o! D4 A$ f8 H4 v1 b% K, B0 s1 x
},* u: m# ?( S4 |2 k
{
+ {! V0 `! s/ a( U% t N .active_low = 0,
0 c7 q5 u7 [, \% ~; p .gpio = DA850_USER_LED2,7 }6 X9 e: M( W) [% C# E
.name = "user_led2",2 S1 d( F2 T% P: R+ t
.default_trigger = "default-on",4 w+ U7 B9 j+ G! j- v1 f4 `- E
},
6 ~/ L/ x2 T$ t {
1 e/ J: [+ `* T/ @ .active_low = 0,
3 E; B( U5 o6 h, j* S$ L .gpio = DA850_USER_LED3,' b5 V) G4 j' o+ x% W
.name = "user_led3",
$ f4 k2 W9 X8 z7 c/ K" S .default_trigger = "default-on",, u5 [# u' @8 l3 S* z2 c
},6 I$ o p; S. B/ D) \: I
};: C2 N+ X* \7 x) N+ x( ?
( _! v% j# Q: T A/ J. W* `% astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 w4 Q0 Y4 D. |( c .leds = da850_evm_tl_leds,
2 C! ^% m" a! b5 h% f# e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. }# p ? H% Q* z3 f* \};5 V; k- q3 V- x% C$ l# P
! v- z9 z' |: {# T# q7 p
static void led_dev_release(struct device *dev)
: ?0 ?: v8 d; N M# e9 ]0 D. x{
2 e6 u* N: P* U; @" e4 B4 }};
9 A# V. G7 ~% C4 G: S& ^, G
8 U/ f, h$ A& Z5 W0 k, f$ J7 U% Gstatic struct platform_device da850_evm_tl_leds_device = {2 f# ?2 k8 l5 I/ h+ V: h
.name = "leds-gpio",
+ e; k R$ b. ~: ^3 \9 c$ y6 s .id = 1,
. j% S% g5 W6 c .dev = {' U6 g0 b$ {4 \, G# R2 h
.platform_data = &da850_evm_tl_leds_pdata,0 w' Z9 G. m% R+ C
.release = led_dev_release,
1 a' h+ G6 ]/ Z. z: M5 E9 }2 g. f } u! e5 m8 U9 s) W- T6 i. b7 n
};0 r. t5 c. k, O' {& j
8 u3 T- {2 j6 K! W. h; @static int __init led_platform_init(void)
9 Q& u' x, \! [* q{; D* f8 K, _# n( M; Z: Z
int ret;
+ o f7 j6 u& @6 k1 i8 {3 G#if 0
+ ]# ]/ Q. q' @+ [& n- w" c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 I o ~) w9 i% m4 \9 }
if (ret)% k% j1 P P3 ~/ \# S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! _) e4 b; G- D7 w! U
"%d\n", ret);0 [2 O( ?# b! b5 p
#endif$ Z. b; ^) ~, x3 l' P3 ]
ret = platform_device_register(&da850_evm_tl_leds_device);
0 |9 p/ D) b$ T( q. M$ c if (ret)
8 p4 f/ N; f. g* j' H pr_warning("Could not register som GPIO expander LEDS");9 j: x( n/ q* a
else
& f7 L. b. l2 S2 W( ]# R! H4 Q printk(KERN_INFO "LED register sucessful!\n");
, }6 S( u+ X2 ]5 O
0 ]" j) `. u7 {4 A) N7 w return ret;( I& d# q2 O2 s
}
, l y" N# B: B1 b1 T- q3 S$ H5 N/ A. K' \# ?8 A! p, ^
static void __exit led_platform_exit(void)8 n1 s9 U4 z1 a* L3 B3 s4 E
{0 z6 g2 a9 a; D
platform_device_unregister(&da850_evm_tl_leds_device);; H) G* t# e3 s( Z0 j
6 K! R4 a& j# p+ P4 [
printk(KERN_INFO "LED unregister!\n");
# Z4 H0 c; L) T6 v! z' D; J}
2 E" i8 M o0 I7 C# u/ }* e
r6 {) t, W) T9 kmodule_init(led_platform_init);
& x( l5 u5 B& O0 H, Nmodule_exit(led_platform_exit);) o3 F5 A5 x: |* s8 Z
: v `3 A" X1 w) \4 U7 X$ I8 o: ?
MODULE_DESCRIPTION("Led platform driver");0 ]7 ~+ p1 q' c( e l
MODULE_AUTHOR("Tronlong");
) v3 n% _9 s/ x2 U: a. ^MODULE_LICENSE("GPL");
+ Z2 z- ]0 ?' r
* b" O& X: U& ^4 K" G* ] |
|