|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 @; H( ~% q( u0 f#include <linux/init.h>' n' D" y$ _$ S
#include <linux/module.h>
1 L' w L1 I+ e1 X# @#include <linux/kernel.h>
& M* N% C2 F7 l* s#include <linux/types.h>2 L" K$ ] m' b" B
#include <linux/gpio.h>1 N* t, a/ }5 y' }
#include <linux/leds.h>
/ w/ V8 E) K ]" \9 R& J#include <linux/platform_device.h>) F5 @: ^5 h5 j8 D ]
9 }9 _' u& a. S5 r$ S; t#include <asm/mach-types.h>( _; x5 }; S) @' y
#include <asm/mach/arch.h>
2 [8 C# M: k- l#include <mach/da8xx.h>
+ i" w7 e# F6 F) d% I#include <mach/mux.h>
4 @# _* j3 t+ w' @8 y6 y- h- W/ C/ Y) \: J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 m# I+ [, _9 o( P. B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ y L" u$ K0 k7 H. }) j" l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: [# W: y9 ], d' i, ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% j& V T P p# i# h) h! z9 a
# V3 k, P/ M" G4 \3 v6 O. {0 o/* assign the tl som board LED-GPIOs*/. ?. R) `! i: S: U- k. ~4 ]
static const short da850_evm_tl_user_led_pins[] = {
$ N: j7 i& T" E1 s) X# E. K /* These pins are definition at <mach/mux.h> file */
% W* x3 T7 x5 P8 p) o- a1 W+ ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! j( ^$ L+ t( S O5 @; f: N" w. H -1
& F }9 D( j" N' a2 M% [1 n};
1 }- w0 M9 k6 D+ L; s4 }8 H
1 D) h% v6 h( A5 m2 S6 Z1 u( zstatic struct gpio_led da850_evm_tl_leds[] = {
" E0 E; B8 U- ~9 P7 N. D {
' u! l M5 Y, Q! P: D .active_low = 0,
2 _) P, B- ~, P, h1 @# n% n& c .gpio = DA850_USER_LED0,
: q" }5 T W' }2 t$ x" f9 ^4 O+ e .name = "user_led0",
2 P( l$ ~) d } y0 M .default_trigger = "default-on",+ i; S% U$ |0 D m6 N
},( {- c" P: t; Z+ m9 p' p
{
* X( w# P3 H; ?$ t& r .active_low = 0,: u& c1 c+ k% @' v$ N6 ~7 D1 i7 @
.gpio = DA850_USER_LED1,
' I8 s6 |7 Y9 k .name = "user_led1",
) M g+ M5 r* s% L .default_trigger = "default-on",& B& P$ K7 n' x, s* s
},% D% k) g; [% O" |
{ I9 _1 z/ M' z8 E
.active_low = 0,% |& h; I' X+ V! k _
.gpio = DA850_USER_LED2,1 Y# b$ [2 M) N' }7 @
.name = "user_led2",
- s H; {- j9 z8 } .default_trigger = "default-on",
/ u/ `% u y& o! |3 A. k/ z) n },
9 s3 h/ S/ _$ i {2 s0 `# C9 H) D+ [. X i3 U
.active_low = 0,) P F3 n! H3 Z8 j; Q/ t
.gpio = DA850_USER_LED3,
: h* ^4 T5 f7 S# {! A. C& c9 g .name = "user_led3",, D/ S% g" Y- f9 M' M
.default_trigger = "default-on",, J$ W- E5 S. K( X" O: O: K
},/ |/ M- N" k. o! z
};& G9 V( l! d% o5 _) T0 T) R
% {3 M/ R' ]9 X$ k8 U% A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( Q! {1 M; e: M) E( J$ L6 n: z .leds = da850_evm_tl_leds,
, @+ C2 J: P( t# |! J6 m- F: ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. B7 X5 f" @) h9 G) h& z
};
4 w1 |5 Y8 _% A5 ^9 k) R" _$ O$ P7 X! s5 z8 i# ?
static void led_dev_release(struct device *dev)
; c1 r' h( b! J [9 D) x' t{& C. S' |+ M* R8 ]5 r J, p
};- e8 ?* q; \( R+ d8 a
3 N4 D1 U0 R$ [( X/ |! jstatic struct platform_device da850_evm_tl_leds_device = {
8 A" E; E9 f y; e, E .name = "leds-gpio",8 D+ g# w' c& j! \/ H, v/ u
.id = 1,
2 n) G8 p+ c( ?& F& Y .dev = {3 ?" X3 I' B8 @$ v3 b
.platform_data = &da850_evm_tl_leds_pdata,4 z& Y7 e0 h8 m
.release = led_dev_release,0 ~4 Z- b- k7 r2 x
}
! S; D! j, ^" @) H};( e" \9 K, T2 ~* x( {% j- x" {
* u1 c8 A- C( B% H( e3 I
static int __init led_platform_init(void)
( d9 \ H( y3 I4 g' ?{
6 c6 Z$ [, g2 k( Q1 o int ret;
( O) V0 O ]9 p7 z9 f#if 0
2 a* |1 K; ^8 L# v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ d8 J1 [; i3 F) i/ _' F% _9 f if (ret)# | F5 |7 s4 w% J. v8 i( }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( W# h5 b! H1 Z/ l0 a* x% J7 H6 c
"%d\n", ret);/ w$ v/ O! B$ H" B) o
#endif
* m0 m4 z# K o6 Z3 G2 V ret = platform_device_register(&da850_evm_tl_leds_device);
2 E- P- A) ]9 V3 L9 o" N6 |6 n if (ret)
$ a" h1 y/ F2 X0 E1 ~; r pr_warning("Could not register som GPIO expander LEDS");5 \& H2 W7 k; P, P/ J& Q' h/ _
else
* \( H6 u1 ^7 [/ z6 R4 V) ? printk(KERN_INFO "LED register sucessful!\n");4 c( F. |8 \" ]7 y7 u& c( a
Q4 y/ F# A/ t- B- e( y* k
return ret;
/ \2 v$ x8 w/ a4 N" M% Q( S}. Z: N3 C+ I+ v, c6 t+ \
$ K, Z% F+ i. v0 G. s
static void __exit led_platform_exit(void)
& H/ y2 ^" c1 V- L{
9 U2 A* ?2 ~$ R5 G$ B8 R platform_device_unregister(&da850_evm_tl_leds_device);* o1 W+ M) X/ [, J% N
. [* P! e9 t0 {
printk(KERN_INFO "LED unregister!\n"); x) b+ d& U& r0 U6 m
}
% d& c2 _+ L# K; [* H% z& Y0 m" P; q! ]8 q
module_init(led_platform_init);
1 M; b, ?* X0 B: Kmodule_exit(led_platform_exit);; b2 c" J1 k0 S" j, j
' v6 [; M6 c1 k4 B y+ R& @! Y1 E
MODULE_DESCRIPTION("Led platform driver");
: L6 C8 _# P* e: f, QMODULE_AUTHOR("Tronlong");/ t3 I$ c( ~/ K" c
MODULE_LICENSE("GPL");
+ g" j2 |. H) L
, s1 T( n: q6 i& Z8 u |
|