|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' y# u* Z, v8 q6 P6 v1 }
#include <linux/init.h>: p) r' S0 B E/ I) m" x
#include <linux/module.h>8 h8 D3 r& n2 k$ ~ R2 [
#include <linux/kernel.h>. O" |% a3 ^0 D6 j, B* U
#include <linux/types.h>
4 Y, L% {& ?$ b8 K% p' h B4 v#include <linux/gpio.h>+ B; C8 | m9 @0 W: ~. Q5 ?
#include <linux/leds.h>0 T$ U ]; b. ~
#include <linux/platform_device.h>
5 {, H8 T, U9 O8 k: L6 i$ j; u+ h/ r1 z4 E5 }1 s/ K0 z
#include <asm/mach-types.h>2 ?+ m+ ^- y$ _; T* K
#include <asm/mach/arch.h>
9 b. D( C. I# P) Z7 }1 \8 ^#include <mach/da8xx.h>7 R2 U8 a: v, s# ]4 Q
#include <mach/mux.h>6 R: @" J& B9 e0 P7 Q2 c8 B/ R
( o3 b$ |" y* k$ g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* ^/ {5 _7 \$ ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* A+ m9 ^. f% [) U! @9 B" B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 A' `, S5 o: L( }" D% F$ y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 X2 [3 m+ m& U; h6 C; | ^! `6 ~( |) w: ^- y N
/* assign the tl som board LED-GPIOs*/
; X' ^0 }/ U! I8 R; I9 g- tstatic const short da850_evm_tl_user_led_pins[] = {
# P# d2 ?' F- L- f9 {. f# }- q& t /* These pins are definition at <mach/mux.h> file */
1 L& q# V1 t3 v2 }, T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! m2 e Q6 n7 C7 `
-1, Y' A" S; P2 A+ c
};; Q- n. W' T5 r; n9 C# @5 C2 u
$ f# \- Q2 s( Lstatic struct gpio_led da850_evm_tl_leds[] = {
?# p: D; [7 Z. ~2 d4 n! S {! J6 H* X3 ~% g0 `
.active_low = 0,
, \) n# X, q* V2 {! H; b .gpio = DA850_USER_LED0," v; v" T8 I1 _
.name = "user_led0",. a0 h+ A( p+ `1 V: e) w
.default_trigger = "default-on",/ a A5 C( Q0 N- u1 M& P2 O( R
},$ d/ j0 h) s4 y8 W* _
{- s) f( \) j" S9 P% z9 h
.active_low = 0,
( V S" Q B0 f3 C9 t .gpio = DA850_USER_LED1,
0 B$ e T- l, p+ I" h .name = "user_led1",
% F7 n: f; S7 K6 o; X# N" }. ]! J .default_trigger = "default-on",
$ }' y1 y* d9 B5 n8 L },8 C: C3 y N7 u
{0 h2 a" s5 C6 E* J7 c5 ^) t9 p
.active_low = 0,# m4 |) D. S4 O8 }* A# P# _1 ~
.gpio = DA850_USER_LED2,/ J1 A" m) n1 T: E* o
.name = "user_led2",$ }4 @' r( Q" k4 ^8 l& G2 a; t4 P
.default_trigger = "default-on",
" Y( l: R& S9 }3 c },0 s" W- s, K# k6 Q5 z* J$ G
{3 ?1 b( a8 _. e* D
.active_low = 0,& B+ }, O. \1 s8 @4 i
.gpio = DA850_USER_LED3,
: ]* I: L& p8 h1 B' \( i .name = "user_led3",+ d/ f/ p0 s7 l0 Z# o5 A
.default_trigger = "default-on",
+ G" z4 E B) h- t8 Q },
- ^3 q4 T) A( y9 U$ y" T! _3 Y};/ g0 A7 ?1 \5 y; h4 l
5 B' @1 a1 U* b: Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 b" W0 v/ c. R( `6 ] .leds = da850_evm_tl_leds,6 K, ^7 X) b& `/ h: e. G: B7 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 d# c1 }/ ~" o7 [* o! _5 q) _& j
};' I. Z( I7 }, n. d8 g- s; c2 s @( D
9 C# |% z0 ?$ c0 n- E7 c
static void led_dev_release(struct device *dev): L! d# s; b9 |- t
{
( W0 `. X: d1 N8 `! T. f};
6 j( f6 X- o4 r6 B4 m+ \* _2 L$ [1 y8 E: h. Z0 E, g+ U6 b9 F1 E
static struct platform_device da850_evm_tl_leds_device = {
+ @+ o5 G! V9 O. O4 k .name = "leds-gpio",
' q5 c4 t/ I$ v' [7 E% L1 B# g .id = 1,3 X. v+ c- x2 B* s" {; G9 O- Z
.dev = {
) F, V6 z8 R/ f1 a c .platform_data = &da850_evm_tl_leds_pdata,! Y5 t; U+ k9 i( [5 y2 b
.release = led_dev_release," i$ o0 }7 b R% M1 t1 u
}
/ K% B$ t4 m8 u4 h% a% {};
2 _+ ^" H; c- {+ {
. Z% o& \& F# w& jstatic int __init led_platform_init(void)
. G) S! z; x$ g5 N{: z- b3 L8 h# W, t2 {
int ret;
, s8 g0 E2 P8 b2 l" J#if 0
3 ^6 a* N2 m3 V6 b$ d6 b: W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 |2 e- h4 Q) U0 [) n% b' M if (ret)( l8 w" }9 R8 a) |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
q* E" t% z1 I* C1 t3 S "%d\n", ret);- l' i" \2 ^8 d6 y
#endif
' I- }% j m. C ]; |2 P/ A ret = platform_device_register(&da850_evm_tl_leds_device);2 V/ j7 d. V6 ]$ l" D
if (ret)4 K3 P6 M( |( V3 r q
pr_warning("Could not register som GPIO expander LEDS");" D4 |0 x% \( x
else! N; I D' l; h( `6 z% e7 c
printk(KERN_INFO "LED register sucessful!\n");
3 l+ z2 O5 K: o' v) o
e3 ]# M6 u1 j# V R return ret;
3 S, B; x0 a7 Z7 X* y% c' q+ |}/ v% v% n) x) ]* T; f7 {/ d3 p
2 O6 D$ S$ h e) W
static void __exit led_platform_exit(void)/ d F. X# N% [
{
2 j; t/ E. |5 h& a8 L+ j r; h platform_device_unregister(&da850_evm_tl_leds_device);
7 I7 G8 j; K0 [4 v9 s, K5 i( _) S! g6 t1 p8 R. P2 ~* m2 `) n1 Z
printk(KERN_INFO "LED unregister!\n");- G( d ^* k' x. b2 w" ^' E4 e
}0 {6 s8 W3 B( P) M* ~
4 {% E7 F4 l$ s+ w' Z0 _module_init(led_platform_init);" N2 _# {: a4 O$ N! \
module_exit(led_platform_exit); D9 m e9 t7 t! m
$ G6 g8 B, p2 q/ y7 v
MODULE_DESCRIPTION("Led platform driver");0 } u% j% u0 \$ V, X! Q0 I
MODULE_AUTHOR("Tronlong");/ J0 r, h! T3 C6 ?
MODULE_LICENSE("GPL");
' f# u8 D1 W; G+ @1 }- y5 W1 R2 K2 ^( p/ Z3 ? i' _
|
|