|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: A1 P% j- ] V \
#include <linux/init.h>
& X8 M: {. r2 S$ S#include <linux/module.h>
8 y0 V/ Y4 d _. T* T& ?& _#include <linux/kernel.h>
& U5 g5 `# ]6 h6 l#include <linux/types.h>
+ Y3 l, k1 S6 Q' t+ ?#include <linux/gpio.h>
+ r1 a7 K r0 `+ `, b#include <linux/leds.h>
% {' i5 q2 @8 d#include <linux/platform_device.h>
( I `4 i# q4 q* s, r
: e/ y2 D! _. ^0 `$ @/ @#include <asm/mach-types.h>8 s/ v: b& y% a
#include <asm/mach/arch.h>
- p# e& u K8 U6 D% M#include <mach/da8xx.h>
1 L' M4 N- x2 Y8 v#include <mach/mux.h>
, `$ p; u6 d; ^0 T% A9 W& j* w6 ?" N: Z, t. v2 F: e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" }7 w. y* d& @+ v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 j$ @& k- X/ Q8 t' V. L2 C* Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# ~+ Y b& M# K* ^* c" |) y4 G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 L7 i* n7 f( R' s- a) R5 w
% O: [9 u/ p3 N8 ~+ \/* assign the tl som board LED-GPIOs*/
- H/ }+ R! c4 ^; l |# U$ B; Pstatic const short da850_evm_tl_user_led_pins[] = {* L9 L! P: W% s& B7 u# Z- U; u
/* These pins are definition at <mach/mux.h> file */3 J6 V! b2 p9 {+ p( ~, K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 ^" W' o* s3 J" U7 }, @
-1; u0 H8 y7 F7 M2 P
};
# ~. l( G& M* a V$ P+ C8 Z* {8 N4 m5 Y' `* a3 z
static struct gpio_led da850_evm_tl_leds[] = {
% ], M4 F* Y1 W) E6 `! K7 J2 i {5 G- b: J& g: B0 d0 q; F
.active_low = 0,
6 \; l6 f, y( J9 e6 R; G+ v# a .gpio = DA850_USER_LED0,; O; T! g* ^% T1 y8 l- @
.name = "user_led0",
7 g/ S7 e$ G/ p2 B% H' D4 }( x .default_trigger = "default-on",
8 L2 C1 P: H7 E4 T8 N },% Z2 s6 U. T' y2 C; H' w6 n
{ f8 B8 e( s3 L& V
.active_low = 0,
; v0 C' q" o3 `' B .gpio = DA850_USER_LED1,
7 E8 Z$ \6 U2 g, m .name = "user_led1",
; i* Y a+ ?- t f. p .default_trigger = "default-on"," t( T! N# T6 C5 i- }
},! V* ?8 q# o2 D" t6 B1 E
{
+ _, \, n9 h+ ]1 a, E .active_low = 0,
1 X0 r; Y, W7 P N .gpio = DA850_USER_LED2,% ^* _- n: c( p, X
.name = "user_led2",
7 i0 H b5 F9 x# @$ a .default_trigger = "default-on",
9 l( w; x" {/ N5 @. T },: r/ c. o* Q- c( H- G; \
{5 W! `& [" s w( i5 \# q# B# f
.active_low = 0,8 z: p8 G+ r& }. R- m' O
.gpio = DA850_USER_LED3,, A. g+ ]. P# B- o3 p
.name = "user_led3",* H+ ?1 r8 E {: G+ R
.default_trigger = "default-on",
) l# t6 }% `7 E& ~5 V },! Y5 R- e7 |+ B; y$ ]9 W
};
0 O3 m0 O5 `( M P% b, T
2 o) c( S9 ~& m6 N# m: estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, e' R$ u" L4 H1 Y: Q1 g .leds = da850_evm_tl_leds,
' L8 A7 h8 V1 @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, y8 \6 n/ X" O# `3 Y
};" H3 c( X! B# _
: \( ]+ I+ ^ ~8 E! M* G
static void led_dev_release(struct device *dev)9 S ]$ r$ a" E; S4 m
{
- ~& h* u# _0 g: M- x# q7 L};0 x. y N1 s1 V" I' v
/ M' C- b8 _7 u6 i7 M& D: q) cstatic struct platform_device da850_evm_tl_leds_device = {! k, [8 F6 b" X$ r+ s
.name = "leds-gpio",
1 ^9 K E7 B" B$ H .id = 1,
6 Z$ E5 `7 v% x* ~) l. S) q .dev = {% Q, ^+ ~8 n- U- y \
.platform_data = &da850_evm_tl_leds_pdata,
8 i0 e0 _4 J x$ j* y .release = led_dev_release,% Z$ r" Y& z; H v3 i) T4 r- j( X
}2 X+ I: |& u. {0 m0 L3 z$ X
};
& B- M) l0 H4 L* i. t2 E
. q, x% u. P; O) D, @+ ]static int __init led_platform_init(void)
& V: K3 U8 H$ w% c! Y" e% ~{
M! f! R3 ]: O8 w int ret;
! h+ y7 U* u( H" R. q2 v$ P9 B#if 0/ J0 `4 @9 M/ E, c( a# X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! a3 f2 D" P e
if (ret)
/ d6 y' |$ R# ^$ G0 S3 F2 w; R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 n6 O T D# u3 O, x
"%d\n", ret);
( d& y1 A" B) ^% p8 A" f: }#endif2 |' T& Q$ e& ?
ret = platform_device_register(&da850_evm_tl_leds_device);
/ D5 M9 p ^( \6 l- V9 M if (ret)/ o: z& a ?4 S* B M7 S: q ^
pr_warning("Could not register som GPIO expander LEDS");
0 _ I/ d9 I) P6 G else
; Q8 `* q+ C" B1 b/ w printk(KERN_INFO "LED register sucessful!\n");
# M$ S# h. a4 w/ ^$ H
% e" _9 _: }" X) |6 k return ret;
4 Z8 N, y# U4 F}" c# u5 O- v/ c% @( y$ c
# k. b- G! ~% b5 |* k- f: X2 ?static void __exit led_platform_exit(void)
" m2 j2 B/ |/ Q3 K' N. [{
/ w& ^- p" v0 a+ M) D- L" I platform_device_unregister(&da850_evm_tl_leds_device);/ t# L- B( n0 ]: L* A! Z
# w) o( t2 ^ L
printk(KERN_INFO "LED unregister!\n");) T/ M% a/ Z# n! b6 L+ m
}
% z( W' ~' q9 V T- _# x' t5 q2 @- E% o
module_init(led_platform_init);7 [3 e; T6 Q% Y" q
module_exit(led_platform_exit);' g' g. Z, |0 T% W/ @2 j
6 a: j8 w1 d3 q5 v c+ l% ?MODULE_DESCRIPTION("Led platform driver");
( y% a0 k* P1 o0 YMODULE_AUTHOR("Tronlong");
4 Y7 L* f3 g+ O/ A4 O. [MODULE_LICENSE("GPL");
* e$ d: z a! Q* o' P& h% Q1 \! |7 G
|
|