|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 U# y5 X' R- g4 [
#include <linux/init.h>5 A( B: v0 m* g8 f5 j6 J, }& k( c* s
#include <linux/module.h>
, p& L$ n) N) K) c5 q I#include <linux/kernel.h>0 Q' ]8 I& \! K5 y
#include <linux/types.h>
/ F+ X" X# S* Q/ K4 f5 _* o#include <linux/gpio.h>5 P: \2 o% x2 X2 k
#include <linux/leds.h>* V0 R+ o q. @; j& g L( U6 r
#include <linux/platform_device.h>
. o o$ x8 |4 A/ N% U5 I% m3 F& F4 T( Q- Q
#include <asm/mach-types.h>
2 n2 J' ?$ n! i/ P- o#include <asm/mach/arch.h>! J4 B+ Q% p) a/ ]7 Y. _
#include <mach/da8xx.h>
+ L5 U( b$ _+ Q3 h#include <mach/mux.h>
: _& e& u% G8 Z' z5 ?/ Q- R- ^5 G6 w- C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 K- K3 ]+ d# a; Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 y5 u" a6 y9 `; {2 U! ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ y( c9 {: g8 L, S0 j* |2 P7 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ t, d, _7 m" ?5 n6 D, w8 \6 A% Y/ h" t! X
/* assign the tl som board LED-GPIOs*/
, O( P$ ^# G8 D. g V( F" Bstatic const short da850_evm_tl_user_led_pins[] = {
; T% x- u" O9 N o6 W% p: W! ?0 J /* These pins are definition at <mach/mux.h> file */0 Z w! z' o1 e# D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( G3 _+ n: l, Y a" z+ O1 Z
-1" z" }; N% o& E; h! ~& E
};, L" o+ \( |% e, K9 e1 I! c3 b
. J1 y1 l' P: J% E9 k5 L
static struct gpio_led da850_evm_tl_leds[] = {
( h, \2 X: R' d. i3 z8 B9 `, g4 Y {- ]# j5 K0 S, P
.active_low = 0,7 f6 S5 F9 C/ }( [( _6 s8 a! t
.gpio = DA850_USER_LED0,
! L' @/ P6 B8 X& h .name = "user_led0",6 C, }" e5 }. ?9 r; }
.default_trigger = "default-on",
( M" k8 n6 e1 _" j. u },, [2 m2 l) ~* O4 ?6 K7 D8 G/ w
{
# w( E1 A& N5 y" D .active_low = 0,) n8 y4 d. V4 M* Z- ~4 x
.gpio = DA850_USER_LED1,
1 ^. c- t1 t8 F! G% g2 Z% c; @/ } .name = "user_led1",0 [( X$ K3 l0 }+ _8 T
.default_trigger = "default-on",7 F8 ?2 Q. r( G! y6 F# J4 Y4 {3 C
},* k& b. [; I" v0 ^
{' }; l8 g n2 S2 R
.active_low = 0,4 J, ]/ i; p1 Z% N0 U
.gpio = DA850_USER_LED2,' F4 E5 K) x& } ]
.name = "user_led2",
v; L( Z7 s9 |0 _0 v .default_trigger = "default-on",4 d( w; c" ?; d& Z7 c; s
},
! T' i/ v3 U8 A+ Z" o( B {- r; N* m& @4 X. h
.active_low = 0,
a0 y0 T# n& ]9 q$ R .gpio = DA850_USER_LED3,
8 U$ x+ [$ S6 H# w .name = "user_led3",
`" Z$ G& t: r2 s) ?8 Z% i .default_trigger = "default-on",
" _3 S; H5 b8 _3 A$ O7 L },
8 g0 i0 D& |7 Q};
+ d( J- r. w8 p1 F. i9 W! k/ H0 t0 |' D' h) V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 U4 X+ Y* f8 J
.leds = da850_evm_tl_leds,
- G Y5 ~! ?3 Z9 W: j. e! n6 R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, V4 C9 ^% b8 _7 n7 Q# a& n: ~0 p1 l0 K
};
! y' b2 g y+ e, {. V7 o+ F' Z, m1 X& }- R
static void led_dev_release(struct device *dev)* j+ X2 L, ]2 E5 x7 |' A2 W3 F) U
{' F5 s( P3 a8 g! ^9 ]) J
};2 b7 p. C* C) k
9 _* C Y- b1 T7 n& J+ B+ b- w
static struct platform_device da850_evm_tl_leds_device = {
7 e7 f' v, t* O- ~1 g7 M E .name = "leds-gpio",. a, D4 g! }& ?% t8 A
.id = 1,4 h& Q) i9 e y4 p8 v
.dev = {
0 s% e* z2 d5 F8 n: M .platform_data = &da850_evm_tl_leds_pdata,) R9 z1 G: r' [7 M
.release = led_dev_release," ^3 [0 W T+ \1 W+ y" l, L+ e
}, ]% Y4 \$ n9 ?7 b
};8 O2 \; g$ F+ r6 @) l* |" p
0 O5 G& w' w8 k9 P6 \static int __init led_platform_init(void)( [& u8 E0 k, Y
{. P) N3 R' A+ l/ ?3 Z
int ret;
8 q. i4 r9 Y s |' D$ O8 H#if 06 I' ~6 n1 x0 e% A- p6 g' F: |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# r) F3 l' U" R$ `$ Z
if (ret)
5 Q9 \: D7 U! `, ~ B0 C- J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 B* M# P5 z Y7 V "%d\n", ret);
& ]8 j. n5 a9 B! A1 n#endif9 g( ]2 w- c3 H" \0 v# x
ret = platform_device_register(&da850_evm_tl_leds_device);2 o8 `- l- L) m0 h) y l
if (ret)
% S* Y- m. A. }5 E pr_warning("Could not register som GPIO expander LEDS");
( ^1 ]4 n2 M6 K+ Z4 x, w; B$ S8 \1 V8 ` else
9 E3 ]2 l- c1 M4 P' d* G- m5 O printk(KERN_INFO "LED register sucessful!\n");
( @9 b6 ^4 g$ m0 V! V6 j. i: m) N+ R& n) I8 e
return ret;
0 j* u z! E: N}' s- n2 m6 Q0 k
; Z4 r7 X- V5 {8 pstatic void __exit led_platform_exit(void)
# E$ v T7 t4 P9 _ d- p9 f5 Y7 T{
( c/ `) F' ?2 g& e q: A platform_device_unregister(&da850_evm_tl_leds_device);8 L' ]7 L" Z# c9 m; X: s
* E0 D) g9 G) a& {9 u! L printk(KERN_INFO "LED unregister!\n");
8 g: j* l) I& n9 F- V$ `6 t; ]}" y. |! |. U* f+ `$ k* u
% n$ c) t' C# a! q2 \/ p
module_init(led_platform_init);1 Q/ A' B/ X4 q# S( n( h* @
module_exit(led_platform_exit);+ a' K5 \3 h' |# ~* i4 J( n
" P8 T2 d5 ` w' g
MODULE_DESCRIPTION("Led platform driver");# |- }4 q' H4 V3 z- F
MODULE_AUTHOR("Tronlong");
) q8 b& m" p( r' ]; A7 `- M# ~8 r6 SMODULE_LICENSE("GPL");
$ y, N Z: I* P- C
+ [1 `0 y: l' }3 J |
|