|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' j; p; K3 L5 r: ^& h: p0 E
#include <linux/init.h>
$ c. {& L/ N" \" d#include <linux/module.h>: B# m: k3 O F. _1 {1 s
#include <linux/kernel.h>: U7 y8 Y8 P+ D- [8 Q
#include <linux/types.h>, N! s! i8 X3 S1 Z X6 o% U
#include <linux/gpio.h>- `8 n j$ S* \6 T1 l3 f* p
#include <linux/leds.h>& s8 B2 R( Z5 I! ~& ]) t* C0 E0 J
#include <linux/platform_device.h>
% n' d3 P# @/ Y; X+ @2 r: t0 h
* M1 l# i; G# T* V3 K#include <asm/mach-types.h>/ c8 `# L4 S( B# m3 L! _
#include <asm/mach/arch.h>
' t6 H$ V5 P0 S. w" Q7 |3 C4 n#include <mach/da8xx.h># p6 l+ u4 x' s( _( G# G
#include <mach/mux.h>
8 X# N& S* D) G, ]6 R* L/ l4 B- Q' d* p" J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 s# D3 [3 s# S4 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 X# ] W% V( O4 c6 i: C( ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( x# I! J; J! h* k( R; I& k+ u3 l3 Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! I2 |7 |/ e6 b `$ \% c# Y
1 @8 n( m9 y6 P' w. z. ?/* assign the tl som board LED-GPIOs*/
( ~" j8 ~8 `+ {% Fstatic const short da850_evm_tl_user_led_pins[] = {
5 g) h- e: P3 ]) I( k! [ /* These pins are definition at <mach/mux.h> file */
. F% i. ?- e: {" _) {: w$ h. W. u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' [9 n6 s$ I, E5 P
-1
; r4 _$ h5 K& y" f- O# g" B4 V1 e9 _};
- Z1 |- }$ C" |9 c7 v0 s- [$ B4 ?
" X9 u, s1 x7 }- r- Y t% a1 Fstatic struct gpio_led da850_evm_tl_leds[] = {
- W' M W! B! e7 G% n0 J } {, H. `/ Y* |3 D5 w% ?
.active_low = 0,- U& M/ F( u7 E; j0 A$ a* o
.gpio = DA850_USER_LED0,
5 u+ |/ o' Y! b# X2 _7 ]7 D .name = "user_led0",( Z3 Z' D3 R+ t& p' J7 r* H0 u. Y/ T
.default_trigger = "default-on",* t$ Y) e- m! Y% R' |3 }
},
6 i& ~& m0 v+ W1 z' Q {
1 x9 r4 U( i( Z6 ^6 H. O .active_low = 0,- q0 r! {0 `% D7 g9 D: q
.gpio = DA850_USER_LED1,. } f$ I6 t9 a3 ]# g2 g( I" a
.name = "user_led1",: f2 [$ c- N% ~ A3 l/ P- `& W
.default_trigger = "default-on", M* S7 p$ O; K
},; B- h9 z4 X" o6 }: n8 O1 o
{
9 V4 ~" i/ r! C1 q .active_low = 0,9 R! k: G' d3 S' J
.gpio = DA850_USER_LED2,0 ~6 c$ \2 O. `
.name = "user_led2",
: l( J% }7 e/ n; c .default_trigger = "default-on",
s- K" Y# t5 h1 q: o },3 U9 F1 W. ?8 \
{* c8 H, B( @! B# y. Y
.active_low = 0,
: u3 Q" N) T( @) }8 ?6 @ .gpio = DA850_USER_LED3, {; A. w {% K9 x/ T
.name = "user_led3",
% S6 d/ ?7 q' \3 _% M6 O `8 d .default_trigger = "default-on",8 S3 j5 g+ p2 ?' w
},
' e6 |/ `% p& I" M/ `9 q};
9 e+ o5 @5 ~ `6 L1 b4 d% C
) S" z; P9 f' |( w: X( ]# s# K |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ \' v0 t3 w. P- {
.leds = da850_evm_tl_leds,
2 K$ j' X8 [# x- H9 a5 d* a: R, j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 g& y) c' b/ V5 e3 e# [
};7 q% B* l ]9 C' w9 }1 h6 T
2 e. j/ h" f9 [! a" \
static void led_dev_release(struct device *dev)2 h% {1 V; I p: z! R
{
$ M0 }$ h9 Y% s0 q* ?; |8 g};( I' \8 e$ _3 l4 ^! H: Y
# a, z$ Z2 w" y8 w' @7 @static struct platform_device da850_evm_tl_leds_device = {
# y3 e( f2 Y1 Z1 w/ {& h0 Y4 p9 i .name = "leds-gpio",
2 d& u- Q4 m9 G! R& Y* l .id = 1,* Y2 s8 u0 K/ k' K- I" U
.dev = {7 K5 M, j. l. `
.platform_data = &da850_evm_tl_leds_pdata,. X% a5 o0 e g* ^& m S! m
.release = led_dev_release,
) _9 @' r- c3 {, ` }/ o/ }$ \( l0 ~9 F
};
, p6 Z' s! C' ]$ n, G. k3 l0 P* i
$ H$ C. D% c8 V1 L' {static int __init led_platform_init(void)
! A7 T8 L( s1 Z U5 x4 t{
) d8 p' h7 W/ E$ | int ret;& ^6 ~- c9 j' M& T
#if 0. \7 V z+ b; {: o! P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, S1 x; m. v: g3 z, p/ J: @ if (ret)* M: `/ g$ E1 g. B. ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 x4 \3 A5 v# _( y "%d\n", ret);. l' ]- v5 z7 b- v, E" j% J
#endif
l3 [6 }( `" x! s. \" }" R' h ret = platform_device_register(&da850_evm_tl_leds_device);
! \3 x: _$ |+ R1 H" [; U if (ret)) ~5 ^% ]0 T- l1 n' o- c- Z0 ^" \; r
pr_warning("Could not register som GPIO expander LEDS");
# b3 y* ^) J8 k else& s N9 o8 i J2 U& T$ g! \
printk(KERN_INFO "LED register sucessful!\n");
1 Y# x/ `1 C" ^4 l. t
% T, I% _' C7 b+ n. F return ret;, H' d" J* n1 N: Q6 n- q. z
}3 N: d& b$ x/ L) M1 U3 _! R
- M# k7 b' P ?* s/ r
static void __exit led_platform_exit(void)' r3 T& R( |5 T2 p: D! V
{/ a- v1 D* e- p' X! D& @! r& z( D3 A' I
platform_device_unregister(&da850_evm_tl_leds_device);+ f, L6 K+ u. @
3 v' ^, c, G% M; R" p printk(KERN_INFO "LED unregister!\n");
! \ _4 f8 Y a# r. W}5 p$ z0 K' C# B( K0 I0 Z2 i H2 w
& Y$ g6 C* ~, }0 m( K
module_init(led_platform_init);
% B, ]) |: K" q+ S p, n5 tmodule_exit(led_platform_exit);8 A6 r; _, ^+ k' f# k! S
+ F( `! R, h$ o; U" h% Z& l
MODULE_DESCRIPTION("Led platform driver");
[6 Q A6 {8 F& n0 Z: vMODULE_AUTHOR("Tronlong");
8 q: d$ a/ o' T; nMODULE_LICENSE("GPL");! F/ K8 X0 ] }" V
) S7 Z2 c% i# D5 s: j* \( d+ V- t6 q
|
|