|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 t1 H% i0 A7 _. l1 ^#include <linux/init.h>
; g$ Z( {, g# V8 T, W/ c, n0 n#include <linux/module.h>) c. y: D; y. T2 e, G
#include <linux/kernel.h>
1 [' h% c" x$ z8 H#include <linux/types.h>2 c7 \ m2 G( B0 s6 X5 m
#include <linux/gpio.h>
, a# D9 M" a% Y' z) b& q#include <linux/leds.h>
* u/ a$ m" w- I l- ?, m8 Z2 a#include <linux/platform_device.h>
# ?3 a' X# x, ~8 c( Y) k9 t1 e& ^2 Q
#include <asm/mach-types.h>) Z( D+ J2 r6 m" n+ Q8 f; }' G
#include <asm/mach/arch.h>
: k0 N" f0 ~+ H2 F$ z% O" X#include <mach/da8xx.h>- N: f% O+ W+ X6 E5 `, M$ m1 K# z
#include <mach/mux.h>
) M4 g+ e* A. T) w. i4 j$ o. Y, |9 Z) d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ j$ S" k( E# i- A- s: R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' F$ A: j# H8 m. r8 j- n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! W5 E) K; W5 c3 c% Y" v3 d#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 C, q! ~$ |/ q! }) g
f) y6 I4 N8 S8 N
/* assign the tl som board LED-GPIOs*/* g; N9 y6 M1 E; E+ T( X& T! J
static const short da850_evm_tl_user_led_pins[] = {
6 R& p7 \$ u& |+ C3 P( j /* These pins are definition at <mach/mux.h> file */
3 A3 h$ k6 e; j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- @4 u1 H z- F2 M -1
( i: Q; q" {" k/ g. O};5 i- ~' w' u2 q8 x
7 L& I+ V0 R, b$ E& S" N( T, _$ t& ]
static struct gpio_led da850_evm_tl_leds[] = {
5 b, A% X2 \8 y! c" v {3 v F8 B6 Q. }$ j/ S
.active_low = 0,
7 G: l% o! y/ S) `4 U S .gpio = DA850_USER_LED0,3 g! X( J( S) H! P7 I
.name = "user_led0",
. s) m, {6 q" c .default_trigger = "default-on",
4 Z+ W7 h% i6 R/ A# X' [$ G },
- o$ ~) F: o, e. l; B) \2 S% p) t9 N; E {
2 e0 T; `9 e. z, @) Q7 q7 i .active_low = 0,
3 I- j' }6 }) _" L/ _ .gpio = DA850_USER_LED1,8 A- o. G1 t9 y# S" o f5 O* H, e7 w
.name = "user_led1",+ [& F7 U3 B& @) L; O
.default_trigger = "default-on",# D+ x& ^4 U1 u& F; `
},
4 k0 L( Z, o2 T0 L0 { {1 I9 W" s4 R# z) G$ [/ z
.active_low = 0,
' o. g: j5 I% b; p8 q .gpio = DA850_USER_LED2,+ g, p% V! o4 n2 ]
.name = "user_led2",
' \9 p( X" {' \6 q8 g9 c .default_trigger = "default-on",% n [' d) v6 @8 c" J
},# n8 Y( e0 X$ \9 L0 X! f! m' t+ m+ a
{# O$ G' o8 W2 ?6 V- S% x
.active_low = 0,( f- h1 S' ]$ T; k$ v V
.gpio = DA850_USER_LED3,3 w O) |% v* L# a: z, `: d" \
.name = "user_led3",8 U4 B8 O' h9 B7 G. w8 d3 `$ V
.default_trigger = "default-on",5 e2 m" @5 w% z) T8 c' \4 ^$ }4 m0 v
},
& x, A# Q/ g! j, @" U# n3 t& x3 D# u};
% r9 f3 W" C; o1 _( ~! A& V
# i$ g9 `% s( h1 w* A) b4 |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 H5 i1 H3 o. j5 C .leds = da850_evm_tl_leds,
( v% r* {- T1 x ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ r6 h/ p1 A3 ~" Q' \$ W3 l
};: A( z- J! S/ ?6 @; {5 O0 s
. N \* D e) `! p- a
static void led_dev_release(struct device *dev)
4 I) D% \! \8 \. a2 K3 s{" H5 ?* J& P, @* z' `
};
: Z9 I4 J5 Z3 g* ^% Y& V
0 a; X7 N3 i& i7 Fstatic struct platform_device da850_evm_tl_leds_device = {. B( U c+ J9 @$ ]' ~9 D( i f
.name = "leds-gpio",4 g" d0 D3 \& r2 ~( b
.id = 1,: L% M8 ^" T1 ^) ?
.dev = {
% A. S% }$ @8 ^7 R .platform_data = &da850_evm_tl_leds_pdata,
% v% z0 c+ O2 n+ P, F .release = led_dev_release,
, F Q* ?% h2 |! h' N }; {, |4 o9 h* _/ e
};% w+ x2 d& r. {, C( d; [9 r- _
% N0 e& |7 b, N; Astatic int __init led_platform_init(void) k+ G& T; t/ d; w! \4 O+ Q7 L
{! p0 N) j0 G* w4 ~! C6 `
int ret;' l) r; C6 t. [1 s/ x7 I; P% o# Y- h) |2 g; e
#if 0# ~0 q# t' ~3 J1 e0 F9 H! G! f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* s7 ?( r C' G6 Y4 u# b3 u/ Z if (ret). ? l6 M ]4 g& u# N J7 C+ Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 h: N5 d8 D- ?- s0 b w* c# T+ G+ I6 E
"%d\n", ret);
! I( _- G; V; e4 Y' b; X1 ?# T( ]#endif3 p0 B" R. K8 ~8 Z4 g/ z2 d
ret = platform_device_register(&da850_evm_tl_leds_device);4 ]/ Y- G0 Z9 {# z5 k d! O! v- N( m9 K
if (ret)
+ \' ], C1 I' [) N5 D& T( {; j; v pr_warning("Could not register som GPIO expander LEDS");; u4 |2 T f- U0 n6 z% Q2 }
else
" {# Q: v/ ?" s' A printk(KERN_INFO "LED register sucessful!\n");3 n; T' q8 X1 X& c1 ?
& f& z. [8 j1 Z/ |1 n return ret;
$ s: B" [/ V5 W/ s}% a6 [9 J: O. _0 A( {
. o5 S. ^; V( y- F. C6 d
static void __exit led_platform_exit(void)
) p: K- w6 Z/ d V: t9 d" b{
g+ j! ?1 _ U- X7 }+ q platform_device_unregister(&da850_evm_tl_leds_device);
1 u1 Q9 N; h2 ~. K I, ^ z: C1 C1 G! v
printk(KERN_INFO "LED unregister!\n");
; B5 Z' N p2 O8 j& g}
7 C" g. _ ~( |) _$ O5 K9 K/ C; `) R. c4 ^7 o
module_init(led_platform_init);
4 _9 x7 c; b: `: v7 r* g2 N) ^module_exit(led_platform_exit);1 b7 Z s: R% M
/ d# Q. G) P1 [3 o- K0 ]MODULE_DESCRIPTION("Led platform driver"); J1 N5 c+ O1 K C* t
MODULE_AUTHOR("Tronlong");
$ ]3 U9 K/ B4 {4 RMODULE_LICENSE("GPL");
' Y b) }% x6 E* F) d- e5 P
* e7 R: c C! |9 L, E2 F% @5 S; h |
|