|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 _8 ]( U9 W) z; v6 H3 ?#include <linux/init.h>( |6 j, a( x- T7 B$ ]) ~4 S7 F/ i
#include <linux/module.h>
8 U: _0 J) v6 _. F4 C#include <linux/kernel.h>" c+ r% ~3 f4 d1 d: {0 X: C, n
#include <linux/types.h>
( C, q5 I4 m4 D! H#include <linux/gpio.h>
+ { Z2 S5 |, I0 j5 B: b# P, m#include <linux/leds.h>
0 }8 f* W% u6 O& K( I$ y1 {) J2 W# ^0 \#include <linux/platform_device.h>
8 q! K) m9 @0 h
9 s5 A) W, z- k: I! c4 ]! V) Y" C#include <asm/mach-types.h>
: n a9 {, Y# _5 j; b, Q! Y7 e- Y#include <asm/mach/arch.h>* T& N: f0 r! b# j
#include <mach/da8xx.h>
; B) Z8 S+ c7 r9 @0 `* b#include <mach/mux.h>
/ o9 e& C+ ^$ s- m/ j9 {0 V0 w5 v+ l6 g+ e- h) d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 F; y9 D9 Q C' Q7 e/ Z" W: Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. r3 M, }- x! j( D- N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 A" I) p$ r5 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- ?7 H. |5 {- \ w- p% D. K9 S1 t% M
: D: T+ r, A8 @8 Y/ {' F |
/* assign the tl som board LED-GPIOs*/ C% T( n+ J ^! ? T# C% F
static const short da850_evm_tl_user_led_pins[] = {
7 i2 X; n1 x. s7 H7 Q5 b0 J /* These pins are definition at <mach/mux.h> file */( y- M0 ], u6 b# p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ j- G6 T9 x4 T* E+ ? ]
-1. h( O& |5 m; j% V8 \2 y/ P
}; v& V4 w. @' u$ s5 z6 h
) R3 r5 i$ c# ^9 K% L6 X% @
static struct gpio_led da850_evm_tl_leds[] = {
4 [% ?( n( \6 E, D {! Z# }; B {7 T0 Z8 u
.active_low = 0,
! P9 j3 T3 u) c6 _ .gpio = DA850_USER_LED0,
7 q0 D ]+ \3 e$ d" S: G .name = "user_led0",& }" x# V5 t- Z
.default_trigger = "default-on",4 A0 [) s% b" Z: w- M
},
3 q1 i. d* Q; m/ U8 c {( e0 x1 q M* T+ l* E
.active_low = 0,& D: |; j$ s# O3 \
.gpio = DA850_USER_LED1,
/ y) _5 _7 c& x G .name = "user_led1",
2 y; c6 ^8 D2 B2 I1 K$ `( ^ .default_trigger = "default-on",! l, @9 F5 A! g9 i! J
},% m; D3 |; G9 r
{* s& e- ]: W6 X1 A+ d s
.active_low = 0,
5 k+ k+ D/ n5 J9 E2 `# L5 n .gpio = DA850_USER_LED2,2 T7 I8 a" T8 Y8 t& X
.name = "user_led2",9 {( C% A$ N; Z& W( S
.default_trigger = "default-on",) h: q9 r' p+ u% G
}," g/ M V, V" _3 ?( b8 H
{
& W0 K8 j, J+ O .active_low = 0,
! u8 {* Q! ^* M1 H1 ~8 | .gpio = DA850_USER_LED3,
g' J5 B3 P7 r/ h) n* P .name = "user_led3",
" W- f* i9 M g- J( S8 t1 y .default_trigger = "default-on",- X( Z% U$ o P8 T, }. s* m$ A, p
},/ _3 ?' G1 r% M+ Z- Q2 o) Y
};
( K N3 }- V* |$ d9 t9 Y
' B! u/ u) {( F; v# I* Y( ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' F8 \. i: \( ?2 l, H .leds = da850_evm_tl_leds,4 x9 M: S" l% X6 [2 C7 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% S4 P2 I, j" g7 j. @
};/ U. s# A! J, w6 z1 A# H
- H' Z$ p3 Y( Z2 a( o+ astatic void led_dev_release(struct device *dev)
1 J) a1 W/ G! S' q7 m{
8 A/ M0 |7 S+ W/ ^- g" P) T};8 N" r6 t4 n }3 w! W$ L! D
( h1 x- C0 c2 e, a- W. ]3 ^: O
static struct platform_device da850_evm_tl_leds_device = {3 |' |0 S* ]2 ~1 g
.name = "leds-gpio",# F6 U# J4 s( D; I( x7 I M6 I
.id = 1,
6 j- x7 l* k* p% _/ N .dev = {/ K8 }( s$ N3 V
.platform_data = &da850_evm_tl_leds_pdata,& t3 o9 l! w5 a1 r3 A& |
.release = led_dev_release,
" h. D. Y p- H }
* [- y! Y+ n7 j1 B& O9 M7 j};4 y0 ?, b4 q* m3 P5 X
$ v, L: p9 @ |( o# S6 b, Vstatic int __init led_platform_init(void)
9 C% l. V- Z. U+ J/ N{( ]5 s* H' m0 J. b+ U3 ~
int ret;) B* v* Z8 H% k, h: d; s
#if 0
; Z. h- P# B* g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ `: q% \0 V- D6 V1 [' t3 C
if (ret)4 s" U: B$ e3 j! T% \+ k+ B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; u/ k( j$ K/ B0 e; A' A2 D% p "%d\n", ret);
}. E; ^" e; M#endif
/ I) o8 E. H+ p6 Y$ {, ?, y ret = platform_device_register(&da850_evm_tl_leds_device);" V5 q/ E% D( D# I
if (ret)' d* S5 c# ^1 G/ G \& v5 h
pr_warning("Could not register som GPIO expander LEDS");
4 X& e; j# Y( K, z7 R8 o else
0 D( L. `* E9 H) U6 j9 v8 B printk(KERN_INFO "LED register sucessful!\n"); a* Z& V7 y) m! `( t9 b0 Z
! M8 ?" R a2 C( q8 A% \) z/ L return ret;
/ N8 x- h4 v2 [* J& `" u}+ U1 c: }; L; s6 X2 \8 a# r
: H+ z B1 w) q U
static void __exit led_platform_exit(void)7 K. t, [3 J* l' Z) E {$ T$ _% S2 n
{
7 }' V: g9 \# S) N+ {: V8 K- \ platform_device_unregister(&da850_evm_tl_leds_device);
: \! z& E, }: M- ~4 ] A2 y" h2 I2 a w4 m$ `$ x/ j
printk(KERN_INFO "LED unregister!\n");' S8 w- s+ z! B+ @
}- X6 b* C; z* r; ]- S6 I& G
! Z3 O/ X D. G
module_init(led_platform_init);
/ G8 R( G9 w9 e7 {module_exit(led_platform_exit);
/ g0 Z! q4 q" H; j1 V p) d1 L2 g, o m0 [ A# a$ V: r
MODULE_DESCRIPTION("Led platform driver");
( Q. n+ Y" D+ }, S& zMODULE_AUTHOR("Tronlong");
/ h; ~% A" A( V6 w+ S: ^4 Z5 ZMODULE_LICENSE("GPL");# Y( B" m8 u% w- \3 T3 Y2 I8 m( _6 Y+ g
8 p# ]2 t: B I+ ]6 U0 P |
|