|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 a$ B. e/ Q9 y- q" @2 _#include <linux/init.h>1 o# g% w0 J4 h! j8 b
#include <linux/module.h>
5 o9 E' {/ W- p8 @6 C4 F4 _#include <linux/kernel.h>
' H$ p2 h3 n* C#include <linux/types.h>
7 Q$ h8 X5 j- R7 r9 |( `& u/ S#include <linux/gpio.h>
4 m3 o: I7 I: E) `8 V#include <linux/leds.h>5 g! O# r5 \& A6 b" ?/ d3 d5 ^7 B& ~
#include <linux/platform_device.h>
- h7 L+ f4 i4 ~) U7 u( B- k. s) ?, \1 _3 G; |9 y: h$ ?
#include <asm/mach-types.h>
f. ^% y$ D* @#include <asm/mach/arch.h>. I! w7 F8 `, ^& o5 Q8 k
#include <mach/da8xx.h>
, g6 v& e- v7 ^6 _4 s#include <mach/mux.h>- [1 y" |5 C5 d3 @, j C
/ X9 d* s$ n7 c4 z1 E/ @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- P/ j# I3 @2 Y4 P6 V* P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: e8 ?, E: f% i- ~0 a* E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 l5 [$ l( _/ e9 I3 N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: T2 \7 }: C, h
9 l) W9 n8 j7 V9 E5 D; {/* assign the tl som board LED-GPIOs*/, C) s: y" R, L5 S/ ~
static const short da850_evm_tl_user_led_pins[] = {
5 y; S. d7 }4 A5 U* f3 h /* These pins are definition at <mach/mux.h> file *// s: Q2 K( O ^# i- w3 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 K' C: _& h# A5 B
-17 V( B( r! [* o' {$ f ?
};
* s# X; _/ r5 G! Y
! a3 h* x) I# y, \static struct gpio_led da850_evm_tl_leds[] = {
2 R9 V1 N* f9 L* J5 b7 A {
+ C/ H" s8 I9 H2 k7 t .active_low = 0,
; t- g, w; O: E) C$ E' U/ Y! S8 c; M .gpio = DA850_USER_LED0,
8 m& O. M) E0 P+ } .name = "user_led0",
, A4 c. p' e2 M/ C- s .default_trigger = "default-on",# h% f4 r* t k5 L
},+ T% V5 x `' a* _$ i% J' {" K2 J
{5 M f5 O: G4 w( u( E9 F
.active_low = 0,
: k. O6 j" u8 r% I .gpio = DA850_USER_LED1,
* k, J, ^- n' \' g9 z# g7 [. o- X .name = "user_led1",: v" ~( [& {% ~) _
.default_trigger = "default-on",, x" b7 Y1 U1 U9 W' Q
},% T8 Q( Q& N$ t k; u4 [
{
0 ]2 |: A' C3 ?% h6 I+ J4 b8 \- } .active_low = 0,' V0 U0 p. E0 N' e6 @& |
.gpio = DA850_USER_LED2,
3 y7 o0 K- F7 B3 s3 h .name = "user_led2",9 M* L# u" t/ Q6 ~& X* F
.default_trigger = "default-on",
/ g/ ?9 r) _6 A4 w% j1 i- c+ m },+ P* a5 d% M4 {9 y
{( Q; X# F0 T; f( l, w
.active_low = 0,
; O; Z6 s; e9 W8 H% f' \ v. u+ E .gpio = DA850_USER_LED3,
/ U: ]: j2 o. y' ~ .name = "user_led3",9 X! g% ?4 B5 m$ R
.default_trigger = "default-on",& s& Q9 `3 e; \! [6 F4 N6 o
},
1 U+ L. q& X. X6 k3 A' f( Z1 {};
' T1 W: U, T, i' V/ x6 w$ w6 g$ J+ ^& `5 h1 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- _/ o" I I# q2 \* A, q$ L' [
.leds = da850_evm_tl_leds,
o3 h6 C$ n$ s$ Z. `: S4 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# ^# d7 `" _9 I7 N# x6 p5 i
};0 K- \6 S+ C4 o% t( R
/ F# l, \. b( R0 N5 Sstatic void led_dev_release(struct device *dev)7 F' V% k9 ~ D2 ]( j6 L* f! w8 r
{
! N- N; T6 y j& ~1 N};5 W2 T; O; b, u+ r9 S$ Q: }
+ Z( y; V! |* C# G8 R( Gstatic struct platform_device da850_evm_tl_leds_device = {
/ J* @5 ]' [8 _" Y9 v .name = "leds-gpio",( C8 D3 ^5 |8 ~6 Q {8 N9 ^9 F" x
.id = 1,' s, x2 j" M4 E
.dev = {- u9 u6 N4 L: U1 q: _
.platform_data = &da850_evm_tl_leds_pdata,
. Z# G; V1 ]) U+ H( ^9 S) p .release = led_dev_release,$ R# v1 y! ]9 l
}
: r8 w# w; M2 E' h5 z& ]};0 d7 r) J, e& [" x+ H' ]/ P# q
6 B8 b& T. ?( O6 X0 M+ z
static int __init led_platform_init(void)
$ ^$ x W+ S5 X/ Z; q{6 V! X" B. \, f8 j
int ret;1 p8 |' d' Y% d9 q7 K
#if 0. t) u1 [6 n9 X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( [/ ^5 A" w5 H. ?9 ^, w/ P& F8 A
if (ret)
4 n% R* A, U. w/ N% r* z7 u# K; n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ z* l$ S# w+ }7 a% B "%d\n", ret);
6 \2 l, i! g- s- [4 r7 u#endif
: H- a7 m/ V0 ?% z' C- V- V ret = platform_device_register(&da850_evm_tl_leds_device);
& K" b0 v5 } i/ b4 X if (ret)
7 x( }( H: w8 Q8 |: C pr_warning("Could not register som GPIO expander LEDS");, s/ u; T( Z3 a! q/ e
else$ a0 U+ a4 W1 M" ^% W1 a. B
printk(KERN_INFO "LED register sucessful!\n");( g0 w; V3 u3 X2 o6 P G
7 {$ Y- v5 v8 Y; G2 X7 c, k( l
return ret;
; J+ c, Q: W- T3 G1 s# b8 z7 s}; T/ f; ]' S `! g0 w- f
7 Q# e, j1 C9 q. w
static void __exit led_platform_exit(void)9 S4 C# [. v- L2 @* t
{
) V1 s- S$ w/ j+ `4 J1 s platform_device_unregister(&da850_evm_tl_leds_device);" V) f) A3 V+ E
! q. E+ l& {/ A+ o
printk(KERN_INFO "LED unregister!\n");
: y1 ~" f# D$ j) C9 Z0 b1 l8 k4 j}
, E' ], l. G. K& D# o! q9 Y. ?, T+ C4 f, o! T; n& O
module_init(led_platform_init);
5 J% S, g% g2 O3 f6 n8 zmodule_exit(led_platform_exit);
* i+ l. ]8 m. x G/ X% O! E" d b
& v9 g+ ^, U! P0 ?8 H- Y t0 OMODULE_DESCRIPTION("Led platform driver");
* w0 d5 P. t& B+ i% a `2 o, G% o mMODULE_AUTHOR("Tronlong");
5 P' e2 Z# Y, c8 r6 W$ pMODULE_LICENSE("GPL");* T) e$ g2 h) a0 Q2 R, v$ s( E
/ N; l& l* `' l4 m4 L
|
|