|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ?/ i( F" T5 O' E# u" G; S7 ?
#include <linux/init.h>
( _* [( P4 @+ b4 Q8 b#include <linux/module.h>
' A) A# Y: Z% ?5 F! t- z#include <linux/kernel.h>* V" K4 x! ]$ Y5 m5 p- f
#include <linux/types.h>! O) t' V. o' _5 C( Z
#include <linux/gpio.h>
* i- L$ L+ ~# q. f) M: }#include <linux/leds.h>1 T) P0 Q4 A( M9 k
#include <linux/platform_device.h> f( q: z: N" x7 h& U! ?
( \$ l# N/ F* U; S1 i; b
#include <asm/mach-types.h>
. X s8 h$ c$ K+ f) d" E#include <asm/mach/arch.h>
) w# u* X* V4 E3 A( s4 e#include <mach/da8xx.h>
; e) \% a% b; c+ |0 E#include <mach/mux.h>
% \/ [2 D( z7 x. V# H9 n5 X/ N, E) X1 N. Q! q7 ~7 d; y& x ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# E/ A. X1 ~4 W0 f9 ~1 l" H8 y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ R$ E9 ^ R8 p7 ^8 {# |8 z' n8 G4 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 x$ ^5 R6 o" M5 G& a4 A' c" x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! r' e, k* O9 Y& K2 }& F9 u6 g
6 {/ D- ]- q0 L/ f' S8 \& o/ Z
/* assign the tl som board LED-GPIOs*/
+ C$ z! ^: M- S5 M* W# |7 n7 Jstatic const short da850_evm_tl_user_led_pins[] = {
( J9 q+ E x9 d/ O( ] \ /* These pins are definition at <mach/mux.h> file */( w2 Y% L% D( [1 w$ ]- M5 |- a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* B9 N4 o# C {* k" r, a# R2 L3 O; S -1
- ~9 J- e5 A" K( u2 T* f! L( H};$ @ n8 g5 n W! r8 u
) i8 w7 n- c$ ?# p" e; k) zstatic struct gpio_led da850_evm_tl_leds[] = {7 d1 g% R7 x& T0 @( h2 ]) R
{
J8 j0 _* ^4 z+ a$ |; u1 A .active_low = 0,
8 c' `! G9 ^; L0 {3 k8 ?# g7 T .gpio = DA850_USER_LED0,
8 ]) ?' b' Y5 Q: T9 R1 R1 E1 z6 g .name = "user_led0",' b8 Q) x# r3 z, o9 a0 _8 `
.default_trigger = "default-on",
. L% k6 @& c/ K6 O, f8 w },! P% O0 K" X- N- z! a
{3 n: B+ q; C# M, g' a
.active_low = 0,
- i; m/ A, O9 E T$ V7 N .gpio = DA850_USER_LED1,
: i/ u3 y9 C4 ]" O6 _ .name = "user_led1",
4 R) G: Y& t- K* I! c% _ .default_trigger = "default-on",
8 X; Q( J+ h, O. N% v },$ [. O- A9 F# N7 ?
{
) ^1 F* M( F: V; B3 M+ g9 ~ .active_low = 0,# M; I# W2 L- T% q; D) J3 `
.gpio = DA850_USER_LED2,
T! z9 \* ]" D% e0 [4 y1 W. b .name = "user_led2",* n! X F* U3 l! Q! A) s. K
.default_trigger = "default-on",
- _3 Q6 D$ f+ d) W* c' @! [( t. ~ },
: ]1 n. R+ B3 {9 k* j" U5 k {$ a* ?6 l) d C" Q1 b. A
.active_low = 0,
9 n. X& y ~& H: ^. u .gpio = DA850_USER_LED3,
# ?8 a2 P2 i( s/ W .name = "user_led3",
) K! n2 ]) |% q0 V3 q+ I+ }8 g .default_trigger = "default-on",
! i( j) j9 R: D" Z/ p1 x3 H* s }, G1 }! w" B& p, E
}; r6 U, d3 O! c$ p1 [) t
. p; M; u" H* q; k5 W% @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 C' [1 _5 s0 s- f( U, W/ z
.leds = da850_evm_tl_leds,
% k4 i( u" k& ?6 C1 n4 M3 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 C: x$ @1 n) v9 S& k( \};7 {- M/ c9 k' }) H7 ^
/ c1 J4 c* B$ C: V2 Tstatic void led_dev_release(struct device *dev)
2 ?+ V3 G( |) P* j' g6 Y) Q9 i4 C{5 |, _& z, T! d3 R1 E
};
6 f- T' G4 }7 H
/ b+ y9 D( }$ ?8 g+ jstatic struct platform_device da850_evm_tl_leds_device = {
) l! Y( z) m) J, L% X! @ .name = "leds-gpio",
0 l c3 e' s2 l .id = 1,
* T& q! \6 [! Q& [0 J& L) A .dev = {1 b4 j. Z# U" o
.platform_data = &da850_evm_tl_leds_pdata,
# [2 W8 {: C+ i, T2 ?9 h .release = led_dev_release,
4 t0 [ F- A7 M }/ T) Q" v/ s& \& w3 A
};
7 ` Y8 l4 ^' }, r L7 R! X% C. [! ?' w+ F% V# R1 G
static int __init led_platform_init(void)( x' k3 _5 \8 |, x/ m
{
0 v) c/ j, a0 @% V4 g int ret;7 ]3 ^0 ^7 B1 d0 J2 s$ h% Y
#if 00 L) d, R* L3 V; A# K ]& ~ h; A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 c( R* u7 Y) @
if (ret)3 h7 p M" r+ L2 n, o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 |$ s# D6 U, N% i4 q' T! S
"%d\n", ret);
6 V! l# h' }! }+ A#endif
6 l" t% H, ?! f. u3 z ret = platform_device_register(&da850_evm_tl_leds_device);: @! M5 q5 R3 ^9 M0 g+ f
if (ret)
! F: p8 ^3 a( g. L9 A pr_warning("Could not register som GPIO expander LEDS");
4 g* G3 n" i6 ~& w1 U else
; T2 e! w7 N' x9 L& t/ K printk(KERN_INFO "LED register sucessful!\n");
- a! J0 W. b' V+ O# f' a, m. V6 F
return ret;( a0 g& O( T+ ^3 e9 v% j
}7 ~4 c" g) h* b8 ~* b2 i" C
& x2 q; i0 k5 {0 [( d2 O- o' ^) J
static void __exit led_platform_exit(void)' W6 f% |+ L9 H3 b8 j7 u+ Q
{% I3 T3 Z `# G- W: F! b n
platform_device_unregister(&da850_evm_tl_leds_device);
0 z% M: v% F2 R/ K% q" W. ?9 N8 j i8 ~8 D
printk(KERN_INFO "LED unregister!\n");5 d+ a' w1 r2 M8 Q" Q- y
}% y- W8 A4 e- @% `
1 v6 M( U9 F ^8 b( }) O) X
module_init(led_platform_init);% \9 m* Z, C# ?) y/ F2 ^
module_exit(led_platform_exit);
0 M4 P$ Q! ~. @$ r; m) g* B. i" H7 F
MODULE_DESCRIPTION("Led platform driver");
Y/ s; s( N/ E6 }MODULE_AUTHOR("Tronlong");! m* e. Q+ |& [8 V& O! X
MODULE_LICENSE("GPL");
5 A3 w v7 u% Y0 L1 ?2 x* k) `. _
, R* b# ?9 s. o& O1 V8 s |
|