|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 \/ A: M" d! `8 U
#include <linux/init.h>
: T% I# L3 i+ t0 [) x* }0 o8 R/ [5 ?# j#include <linux/module.h>
' t1 Z0 N% Y3 u2 c2 P5 ?#include <linux/kernel.h>4 O' x5 O! G; S+ y; y+ u
#include <linux/types.h>
2 ^' K4 T; f' {$ \3 H#include <linux/gpio.h>
9 B7 c* C, V3 X* o" d# X# u! G#include <linux/leds.h>
) [5 |* c3 ^7 x+ r; ?#include <linux/platform_device.h>& i+ v: F( P x* v4 L9 p" Z9 Q
; p1 b% F7 M3 H, o) ?#include <asm/mach-types.h>
8 f3 k( a/ l" F#include <asm/mach/arch.h>
4 r3 X$ S! S* x1 U _#include <mach/da8xx.h>( h; m3 H1 x) R4 r% J) y. \
#include <mach/mux.h>
k u% l' H0 T: W) e* L8 R, c" p1 ~' k5 p: Z5 f7 G1 G( F1 v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- ]5 u. f; T* |% ?5 Y9 d/ |! }, Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& s! Q$ v: n" R- E) s% n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 W, B6 X* ?* L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
m- {& Z+ k& e; y' s/ n8 t1 e2 Y6 A9 d4 p% V
/* assign the tl som board LED-GPIOs*/
+ h" u: ^9 j0 a' zstatic const short da850_evm_tl_user_led_pins[] = {; i! h* m: e, y
/* These pins are definition at <mach/mux.h> file */
+ I% H9 q" @5 y3 O# Z L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* F0 m9 s; q3 w5 w# k8 x; F
-1
1 q$ X; ]+ p: {. ~; @};
' `; Q; u! P: I$ G5 E
0 }7 f% G8 j5 s5 s$ d% x' A Istatic struct gpio_led da850_evm_tl_leds[] = {
9 U: o8 q( i# e5 O$ Q {
% t- U7 u8 i* z9 R) L( { u3 r! O z .active_low = 0,
; R, r( n- N! q( h$ \9 p' | .gpio = DA850_USER_LED0,4 Q% \& \7 D& M$ a
.name = "user_led0",
( X7 Z3 U% Y2 {3 r0 S .default_trigger = "default-on",
- l4 l" o; y: \9 L# @+ e9 a9 ]9 g: H },
) F$ C! L8 T$ ~& l {" g( J$ v+ h: R
.active_low = 0,
7 H n/ q" z A0 n* {: |/ D .gpio = DA850_USER_LED1," h- R9 G( H/ z9 w v! x3 ?
.name = "user_led1",1 e8 E. s# \* @, }
.default_trigger = "default-on",1 ^: Y3 o4 I! G5 m, _$ q
},
1 n( X# f l6 w5 s6 O) j2 j {9 \1 X% s1 |6 Z& f b; \' t
.active_low = 0,, {4 N. P' G( G/ }& ?+ L
.gpio = DA850_USER_LED2,& G% c% g8 h! r; G, s( X0 W
.name = "user_led2",
; M) q7 u ~5 J r0 | .default_trigger = "default-on",, {' l1 J$ c$ X" i
},
1 r5 y3 d! O+ l$ f% V% E {: _0 ~) z) o- y/ _( D+ H
.active_low = 0,
Q+ @8 U, P* ]4 Z) l0 p( H .gpio = DA850_USER_LED3,6 u9 m# q* p+ v& ]+ e; K, I
.name = "user_led3",5 _$ V, {2 }; a4 q
.default_trigger = "default-on"," X4 ~# R# i) K7 t
},. M/ s6 ?9 c6 I2 M: ~3 [) f
};
7 Y6 w+ M8 R* k+ h+ u* E
# }: u' z8 H* h5 _/ n% W% bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' U. o! n) U" k N5 b) W8 ]' x# r3 m
.leds = da850_evm_tl_leds,
' K9 }: c! R$ r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: \& }% P ]4 e' j% I6 N% r
};
3 d- [: Z0 |6 p$ I" _6 M9 ]) U
5 P/ A! i% A* C. K. ]9 i. Sstatic void led_dev_release(struct device *dev)+ b& ?' g: v- W1 l% P! O# x/ _% l
{+ Y* k# s: [1 q" B3 |* U g
};
, X8 W9 p+ [' v6 G: V l! C
/ t1 F3 s* D; L; g$ vstatic struct platform_device da850_evm_tl_leds_device = {) r! b0 K; @1 a- O. y: \
.name = "leds-gpio", A. p/ s! w% X" m
.id = 1,5 a, H) a' U ~& L+ {, r/ E+ d
.dev = {
7 [" u4 y0 V( ?/ Z9 ?. R9 w" h( ^1 Y .platform_data = &da850_evm_tl_leds_pdata,
2 p5 j/ `; m+ ~9 D1 x( x .release = led_dev_release,) u, b! i; H4 R; q; V2 a7 V
}
4 b5 l7 X" T8 }9 G};
" l6 C( w. r" ~; p
; c" Z0 j+ i+ \( Istatic int __init led_platform_init(void)1 J) G+ F; w2 g' J0 o w
{8 n9 a- i* a: r0 J4 o T
int ret;6 v# M4 {, G6 }. L
#if 0
$ D: Z e: n. I0 X# ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 S7 Y" N. W ~ K" H8 `4 O% n5 `
if (ret) M# t/ A/ @6 ~5 B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' P+ W7 k; M, r0 S6 w8 W; w8 u "%d\n", ret);; ^2 A" n+ q) G: ]
#endif9 ?. i7 I- q+ a# d" V4 a
ret = platform_device_register(&da850_evm_tl_leds_device);6 [, x9 X$ [( }- o( P* k
if (ret)* }, ]/ m* K7 f
pr_warning("Could not register som GPIO expander LEDS");# f; h! m! ]. N, p
else) T Z; l. }0 l5 k$ w# Z. K* I
printk(KERN_INFO "LED register sucessful!\n");$ [/ K8 F3 T8 \* P
' ~4 s6 X6 j( \9 P1 E1 N% ]; U+ q return ret;( b# V# g- ^2 n6 x$ c! E# |$ C
}9 u9 Q2 o4 S) B: U$ u! u' }1 O7 d
7 I6 _9 K: _; W! w9 istatic void __exit led_platform_exit(void)
/ v, z" W. \7 p0 B" X5 R _, o{
. ~+ v! p/ X9 L) k4 g' }' A platform_device_unregister(&da850_evm_tl_leds_device);0 @: Z$ U. b4 _% ~! g; R
. r% b$ D; e: b printk(KERN_INFO "LED unregister!\n");
2 z) s) B3 X* N9 W}
" i+ B% a$ {3 R- y6 e n
7 L! k l) T- p5 c8 x1 `/ xmodule_init(led_platform_init);
# E8 V8 D" U6 @' t7 R, K! Rmodule_exit(led_platform_exit);0 {5 v! k1 ~, W e# m
, X; d( O6 s9 C# V; `9 P. W
MODULE_DESCRIPTION("Led platform driver");, z1 h5 W5 o- I4 H
MODULE_AUTHOR("Tronlong");6 ^/ c, H* ^/ E9 Q* z* N
MODULE_LICENSE("GPL");
3 s* p2 h. k/ k; }: M# M v2 r1 B
|
|