|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ X+ y$ G: V$ J8 V& w* E: A" C#include <linux/init.h>
L, |8 Y1 d/ Q+ f#include <linux/module.h>7 w* K9 T6 { H
#include <linux/kernel.h>
\; V& z7 T" [- H2 }" ~$ \#include <linux/types.h>
% ^3 o" C4 l! m#include <linux/gpio.h>' F8 T1 a9 E( {$ x6 ?( n8 x4 z
#include <linux/leds.h>, b& E! a9 g% `0 { r0 }/ a: |' y/ K
#include <linux/platform_device.h>
6 k( o1 b8 F I5 m1 G: Q0 f# R S
: B+ c H) t' L+ R3 b# _+ P6 \6 o#include <asm/mach-types.h>
P2 E/ [7 \! s#include <asm/mach/arch.h>
: g. c+ ?& G b {) X. r#include <mach/da8xx.h>- c7 H; {* j! n( \1 w% c
#include <mach/mux.h>
, o- S; f3 @0 P* Q0 g
Q4 @' r& l+ X& ?( g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ H9 d: U1 p( J0 }$ v) n& M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 K6 ^. {7 z9 Z" i# S; `: I- A0 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# f6 z) m; t! c7 \8 f7 x: I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 d; a- `* J' l; b1 C+ H& r
- m3 D- { S( u3 _
/* assign the tl som board LED-GPIOs*/, E& h5 q% s, H( @9 f- T! q
static const short da850_evm_tl_user_led_pins[] = {; r; M- f) b1 v2 T) F
/* These pins are definition at <mach/mux.h> file */
& U# q4 j8 _- ^( D" n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- l& E8 W7 ?3 ?8 u( j8 f -14 x, u! L$ z) @
};
9 c1 W' h) |$ X5 O5 U% v" V; @ b# h+ n
static struct gpio_led da850_evm_tl_leds[] = {- m% w, ^4 e' k- o1 E$ X
{5 L+ A* f: y, l9 ^! a8 W3 Y" M
.active_low = 0,3 K# d. V$ q: {2 \" \& x/ B
.gpio = DA850_USER_LED0,
& E* q G3 U- E& A+ E .name = "user_led0",' l. f, ?( d# e* Z
.default_trigger = "default-on",
# N: r; Y. ~+ S2 z/ t. C },
9 {" w" C9 |' G, _/ Q9 w {/ V9 G! A5 `' T+ Q: k$ N* I+ C q
.active_low = 0,
( _1 t) f( C+ G .gpio = DA850_USER_LED1,: c; X( r' c& @) C" D& v
.name = "user_led1",! w0 c4 ~/ t0 P+ Z5 g
.default_trigger = "default-on",
0 ]' r$ n5 M" ]% B$ V/ u },
: c8 r( u/ t+ K+ z& D {
0 {3 ]2 R' x# \5 [. r .active_low = 0,
! x2 V U/ L* P& _ .gpio = DA850_USER_LED2,: l% E5 O/ T7 K V/ `0 s
.name = "user_led2",( u! k+ P- ~: ]+ o/ z- I
.default_trigger = "default-on",) o' V7 o1 ~! e6 L
},
% w) F- n4 n4 x$ p- p0 U {6 V1 D+ }6 ]* n; \
.active_low = 0,3 t$ G9 z$ `( L; v! `
.gpio = DA850_USER_LED3,' \+ F4 A6 V- x/ m) o
.name = "user_led3",7 I s$ s! x2 j% P
.default_trigger = "default-on",
, @7 K" i- g/ @3 J },( H+ ~; a( F9 ?0 _, H( d
};
6 R- @% c2 _& ^% {
' c4 n, |7 d# X% ^* ]! Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: W* S4 o' b" z ~& P .leds = da850_evm_tl_leds,0 b- Y# u- D2 ?5 S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 e5 N6 F- ?7 j# N5 c C
};/ [0 ]! r$ n7 L: ?1 b' t
/ V+ j1 {, ^6 D \static void led_dev_release(struct device *dev)- s2 G1 k" A4 c/ u
{
6 W; T% Q- [+ Q X5 v, O) J' \1 {+ d3 M};
6 A# Z$ E2 [, u, o- v9 R8 q, Z7 o2 }5 F2 n
static struct platform_device da850_evm_tl_leds_device = {
0 \. }6 z2 R8 s: ]; K .name = "leds-gpio",
+ I! R9 G8 W7 K6 V" c& t .id = 1," y3 h5 Y3 v$ j# [+ A M, c
.dev = {* ]: F: `/ g' I8 }7 w
.platform_data = &da850_evm_tl_leds_pdata,
1 S- p5 R1 B; N8 A9 D .release = led_dev_release,
. \; g5 r% }" j4 L8 C+ ^: P }
?! {- I# {2 V. |};& t d6 S+ J& m* E9 m5 Q4 B
Z8 i" l1 }# G# E$ ?5 Y I$ F3 Z9 Kstatic int __init led_platform_init(void)
3 ^' O0 Y' m! ]* j) ?9 s{
% s9 c9 x$ c+ X+ p8 H6 {7 | int ret;
0 B5 o, ^" i: h. O) Y% d#if 0! Q/ T$ R8 n9 X4 e. k6 R5 z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) b# M$ `: l1 z/ g* J# O if (ret); w7 T5 y! \5 b7 E3 U& ]# h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
s6 v# h. f: D4 ` "%d\n", ret);% k5 r2 s3 k$ @* \
#endif# C% e; n! l9 F! x+ b% M7 f. e& [
ret = platform_device_register(&da850_evm_tl_leds_device);
) [5 Y& M+ \, v# V+ k1 O0 R if (ret)
2 h) P1 c; l Y7 a) O pr_warning("Could not register som GPIO expander LEDS");
6 p2 q0 N( c& q& t4 Z else
& m! G4 V) r( N) M/ q printk(KERN_INFO "LED register sucessful!\n");# q7 O4 N+ }6 c# m- I
8 D3 Y0 o+ `& W, g9 \ return ret;
; R" }5 V7 L9 U U. N}3 R% C( z: i3 L
5 f; ?& E3 K ?6 dstatic void __exit led_platform_exit(void)% o" I: r6 h+ V/ R/ Q0 ~7 n
{) H% Q, [9 F; |! E6 J
platform_device_unregister(&da850_evm_tl_leds_device);# z3 T% J7 p0 S1 J' a, f
2 K [* W) p3 e4 H
printk(KERN_INFO "LED unregister!\n");; O3 P M8 m2 u9 p/ K
}
7 U2 ?. \; X+ E( x7 U( t" O8 S7 U; _
module_init(led_platform_init);8 K8 s" ~0 C i
module_exit(led_platform_exit);
$ E' u/ Q! C$ t' i! V1 G8 p7 r
5 B7 T8 \0 r4 H; R5 G! }MODULE_DESCRIPTION("Led platform driver");
. O$ z# ?7 F- q8 F' z# Q4 k- \, G& ]MODULE_AUTHOR("Tronlong");2 n, e p# ^6 q0 E. ?
MODULE_LICENSE("GPL");. ~$ Q/ @( W/ |% d
' c' l2 D" I3 C' Q; ~5 @( G) q, o# u
|
|