|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( p+ N. }' Y, g, L3 Y7 w% ^4 O; u#include <linux/init.h>
' o) v9 [/ F" K#include <linux/module.h>
$ ^% I5 `" n$ m/ r4 ]' ?; N0 f#include <linux/kernel.h>- E/ g3 T; e1 n2 A u
#include <linux/types.h>
) N& p- \# p" c% L; T& C; P#include <linux/gpio.h>
7 g T! D/ g; F+ S1 W, i#include <linux/leds.h>. _7 U) Y% j3 m# h9 H5 O
#include <linux/platform_device.h>
/ B, E$ t5 W( S% V/ [/ M; p3 x( j P
% m1 U' ^9 B) ?#include <asm/mach-types.h>- Y, S/ { h" ?3 Q5 S. H" g2 P: ]
#include <asm/mach/arch.h>
* o' ?$ ^3 h( p1 ^ b) J9 {#include <mach/da8xx.h>
# Z. H* V0 |, o# K, Q#include <mach/mux.h>
/ v# a( X5 d% T- w. |5 b; n
8 ^2 D* z" }/ Y& c/ A/ W4 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), N3 e% B3 M' L# a$ h( T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ f! r. J, b7 H5 d0 o1 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) E8 C% z" N& e. S5 H1 A/ {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 d! _2 O P5 G5 o% q' m! j' Q- |1 r x# I& p9 Z$ X4 K
/* assign the tl som board LED-GPIOs*/; |: F) \; W4 [
static const short da850_evm_tl_user_led_pins[] = {! K% X1 F: |0 d
/* These pins are definition at <mach/mux.h> file */
; z8 Y4 f6 r& p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& Y* U+ I, c9 M; F: J4 A2 T
-1
4 F! L6 V: z/ X};+ H4 [. U: B' z' e5 g. c
" m& }+ o, Y& V% r- P9 U$ _; ~
static struct gpio_led da850_evm_tl_leds[] = {, R$ k5 F0 P D# f7 {2 k5 h
{/ b. f" @, L Q7 h9 T
.active_low = 0,
* T7 A( l4 F- B* B$ a) R .gpio = DA850_USER_LED0,
% J; u5 P% x3 k3 p- i: `( i& W .name = "user_led0",) [1 b, h' z/ y( Z" j4 |
.default_trigger = "default-on",- Z$ U0 e* Z- V$ `- s8 U
},. q! U9 Z* a4 K0 L5 M+ c. `
{$ Y; O4 N2 g+ l. Q
.active_low = 0,/ I, d0 I/ L: L" o/ z
.gpio = DA850_USER_LED1,
: P( q; c) ?5 i8 [ .name = "user_led1",$ z; m7 R1 M1 n+ D2 @
.default_trigger = "default-on",6 y8 s4 p( s# W$ w) S" i
},
! W( g. m& N' P- l { d0 J3 O7 ?9 |" m! Q3 W) ]% |
.active_low = 0,
- v& R" g' K Q .gpio = DA850_USER_LED2,
$ t9 ~- ]+ P: G9 o: w" H9 r .name = "user_led2",
2 S, h3 o+ D" y k6 k! W! Q .default_trigger = "default-on",0 g- v' v, A3 p; |; B
},
. c, C- o6 K M' o1 _5 A9 t {2 U4 a4 K: D: ]6 C# S/ j
.active_low = 0,
/ `( {6 a) V! Y' d2 z# E; S .gpio = DA850_USER_LED3,$ t( s" e1 _* g' l
.name = "user_led3",
- V: ?8 P* n6 g0 Z .default_trigger = "default-on",9 D/ c, V: ]1 u
},
* Q7 G% m, w ~' J# t};
1 ]& d* V2 r0 Y4 r8 G; Z5 U5 n5 v% q- V" `/ }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% m( r Q2 \4 D
.leds = da850_evm_tl_leds,0 e; {$ l1 w* c$ Y6 G* d$ D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) {* o# _5 e- f- I' ?, |2 j8 Q1 O};
- T- E8 y/ Y) }8 \9 u8 O
5 }6 O5 H$ {# I2 {& P; \static void led_dev_release(struct device *dev)/ v7 d; C$ N4 q; K2 ?
{
) T( n* F+ f% S: n& ~3 y5 m5 v5 F, p};: V- F( _! o; Z+ |+ q( ?% n
/ G# v) h( g+ {1 u% t/ M
static struct platform_device da850_evm_tl_leds_device = {
( v) t3 [" W1 @! G0 v! o .name = "leds-gpio",
/ v7 u0 L8 Q( \, z7 l6 W .id = 1,
/ r# b* N. ]: w .dev = {
5 K) ]5 C$ n3 Y a" s s0 Y. E .platform_data = &da850_evm_tl_leds_pdata,- u ]/ x! Y- E2 h% h( K2 J3 t
.release = led_dev_release,
: s+ E* Q) m& \' K- ]9 @ }
0 u5 p0 s( F4 k# N1 w4 Q};" {$ {2 f3 y" Q; y. \
# { _0 K' ~* p& N' m% N
static int __init led_platform_init(void)8 C) v: Y5 c! |- g9 n3 Y2 J. i; U
{" _* W, W* ~7 @( a t u3 k8 ~
int ret;
/ u' M+ m8 l4 [+ H5 |. }; b#if 0- e+ r% o3 Z- u/ L% `0 p+ ~9 B: f" q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* x# Z! O) V8 }# }' Q/ Z% X if (ret): g' l8 S$ `/ l- x C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 g) S0 E) R& h0 ^1 \! |0 W7 b "%d\n", ret);, }1 ~9 {' V4 E) \* d- w
#endif; ~* B! ^+ `: T' k
ret = platform_device_register(&da850_evm_tl_leds_device);
8 A8 X% _/ }# E: ~4 X4 A! A if (ret)* v- t: P( ` D. B- n0 u4 `7 x
pr_warning("Could not register som GPIO expander LEDS");
. i [: u5 M4 _ else: t/ A. Z- B( D* L# j
printk(KERN_INFO "LED register sucessful!\n");) P! M' E; W* o+ O" b4 l
w- E$ ^* u& l Q/ ^
return ret;
' D( c- w! ?4 j6 T8 m( I}+ f, {6 P( J7 O- j$ q
9 q' y1 l4 p( l2 I; e y0 @static void __exit led_platform_exit(void)
4 [# J; z2 h' b! J! A{
1 K/ H0 t' S$ o$ t platform_device_unregister(&da850_evm_tl_leds_device);
- k( u0 @6 _" [( v% B
/ r. E2 V) i/ B* Y3 I% K5 ~: ^ printk(KERN_INFO "LED unregister!\n");1 m! ^$ L. a7 l+ Q# c/ |) T
}6 j, H" E! q3 h% s& ~
& \, O3 E$ F" ^
module_init(led_platform_init);
% e& V8 Q2 K- U q/ w: j- _module_exit(led_platform_exit);
0 V' v J6 Q5 a$ X8 t9 O0 T& p
+ Q! D# Z2 `1 g1 p; N1 m9 C4 Y5 @MODULE_DESCRIPTION("Led platform driver");
) x) J+ X' ^* M$ I3 uMODULE_AUTHOR("Tronlong");
4 f- H' a' D% `; m% HMODULE_LICENSE("GPL");, @, S( m$ _! c7 p7 n! M1 X
8 l1 B# f3 a: P8 ~! P% X
|
|