|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. G' P A6 n7 P B: \. ~% Q
#include <linux/init.h>
5 e# r5 q+ Z4 x& h8 c; i& k w, g9 X#include <linux/module.h>$ z: O3 q4 M3 ]/ \+ h
#include <linux/kernel.h>- |) `5 S2 |5 @2 D& K
#include <linux/types.h>
, C$ \6 ]7 L9 d% M#include <linux/gpio.h>! F; U& z; _* }( Q/ o
#include <linux/leds.h>6 N# i7 K* M$ w T2 w
#include <linux/platform_device.h>
: x/ _; Y# Q2 M; m( f: b0 y/ w1 J! `2 @" r' `6 y1 C
#include <asm/mach-types.h>4 q, f7 L, s2 m. p
#include <asm/mach/arch.h># O! E9 R; G5 p& ~
#include <mach/da8xx.h>
W" Z6 [5 G$ X1 D#include <mach/mux.h>* u6 c- o9 H# O$ S& I+ r
6 U2 Q* m! u6 K1 Y0 i9 d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 A# ^0 d u5 |# A! v* E0 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
S! L0 e- t/ v- F3 O0 u! a3 g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 ^/ c1 I9 {5 q" @8 q1 O8 Z7 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ h- }( \& k2 x2 V8 F0 b0 r) a0 [9 Y5 J
/* assign the tl som board LED-GPIOs*/
2 Z+ G5 h# ^' I# _* r# y/ \* ^, hstatic const short da850_evm_tl_user_led_pins[] = {
# W( a. Z, H% B# y% [ /* These pins are definition at <mach/mux.h> file */
I' t6 @8 o- b# O/ r l( @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ C; X0 E* ?" ]% K+ I I+ H
-17 @4 Y3 d7 S5 Y$ U9 _
};+ Y$ R* v. b3 W% e& }
8 N) O, V$ Y# g- R v1 ]static struct gpio_led da850_evm_tl_leds[] = {
k* o1 V9 k9 } g( c: D( B {! k9 G0 P$ n9 }. U: m: X- K
.active_low = 0,5 q* D# O1 Q4 B0 z$ Y7 O, k- e9 f& V' O
.gpio = DA850_USER_LED0,& o/ O$ I) v0 v. }$ P
.name = "user_led0",
5 E7 N/ U, C4 s6 @9 t2 X: ] .default_trigger = "default-on",
" e- B+ k/ e8 H) |3 C3 `2 m6 P },
" [2 a) x8 t" o+ Y t {
2 H& Q0 c$ C7 g3 [& i .active_low = 0,
/ [9 ?9 J" u4 ~& ^5 J- Z .gpio = DA850_USER_LED1,: C% \% u- u7 k S: v6 o" ~
.name = "user_led1",7 a5 p4 E% Y/ s1 j& K7 O9 ^- T7 y: \8 c
.default_trigger = "default-on",
9 e& \$ ]/ y, p) V" t$ P },3 E A4 x* Z5 S, l6 V
{
- ~8 k3 n/ J' ? C) B4 V5 V .active_low = 0,. X8 R E) G' j9 p+ c# {6 n
.gpio = DA850_USER_LED2,
- T# X. b7 _! E+ N# R9 d6 j .name = "user_led2",4 C# r7 X4 Y7 I0 w1 C7 g0 F
.default_trigger = "default-on",
, e/ u1 [1 Z' G5 P. T },
5 }, N( p8 H- R5 c# y4 [ {
% O' E6 K" ]) r .active_low = 0,
) j4 O; ~8 I2 | .gpio = DA850_USER_LED3,
. z8 C7 }: y3 m, C0 g' C0 F' Y" n5 J .name = "user_led3",! N8 C. q, [8 a3 f
.default_trigger = "default-on",% v9 N) k: C5 E9 K; u% A% y
},5 b: a! q e/ x L
};
. M# s* T% g3 d) L, i# S6 m6 B* y/ z3 w! e6 [9 n7 {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" a# A0 O2 [. F$ E3 b0 L; y& V) T, ~
.leds = da850_evm_tl_leds,
1 ]" D% d8 u u' f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* A$ ]3 }, G+ T2 p- E
};1 p4 a0 T) g$ \) v
+ M9 O ?+ ?# J' D9 ]
static void led_dev_release(struct device *dev)8 d4 @: L7 R1 @
{" r$ @' |# Y" q, M* p4 a6 U
};/ T/ M! g; S. P* F3 J
4 b2 R* k4 u1 ~+ Y' m; J/ Wstatic struct platform_device da850_evm_tl_leds_device = {$ o; D5 x; G0 x( r/ c
.name = "leds-gpio",
a- x% u W0 t& }/ s .id = 1,
3 D# C% U% C6 A2 } .dev = {
1 ?- |* X# ~4 ?$ E5 [" m1 T .platform_data = &da850_evm_tl_leds_pdata,
% B' q% s" q/ O .release = led_dev_release,. ]: P. J, g1 }! k! ~
}% n y. d# a7 P+ \0 m1 i
};
, V0 z( d1 q, v' i
A7 y) c" F& Q: N) Q g0 F) F& q+ G! Hstatic int __init led_platform_init(void)
9 u# ]2 M0 |( H+ R8 z9 u4 ?* v" x{
$ A7 W0 M- M; x, F' C; r int ret;
2 F7 N/ y9 W: A- G/ u( e#if 02 ?/ E% N3 c5 T/ ]3 o( B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& i8 n+ U4 w3 F4 [4 z$ ]
if (ret)
3 _- W0 ^7 i$ y8 Z* K pr_warning("da850_evm_tl_leds_init : User LED mux failed :" m; h3 D. q- ^$ b
"%d\n", ret);
, W2 s. \, ]" S5 u5 Q) i6 ^#endif2 w& ^& e( u4 {
ret = platform_device_register(&da850_evm_tl_leds_device);
7 j' P2 j) \3 }0 X if (ret)
* N- T, B4 Q# }) E pr_warning("Could not register som GPIO expander LEDS");
0 |7 P" P* n5 `( n* | else' h3 E$ G: z+ K
printk(KERN_INFO "LED register sucessful!\n");
3 u- f5 u; i2 `+ Q2 Y7 N
# r% u1 n9 T# @3 ?, `/ F; w! h return ret;
5 N1 Q$ ~) J) d}
! d8 I0 w2 k' V9 _ l
# q/ E5 L3 ?# F+ Lstatic void __exit led_platform_exit(void): j) u! P* S0 a0 y( t# _
{
* e* `/ u9 H$ O) R5 w- R+ |5 F7 W platform_device_unregister(&da850_evm_tl_leds_device);
0 k" z K" J. {5 [/ B
2 f3 d# i1 m% d2 Y6 D# n& ?* Q printk(KERN_INFO "LED unregister!\n");
7 `/ T) {/ U6 Y# }% o! p}
6 ?/ ^! u3 V6 a4 z c6 q1 [$ m2 F9 e$ H/ W' P3 \9 _
module_init(led_platform_init);8 e2 `! H6 ^3 L* `, p
module_exit(led_platform_exit);0 P1 g4 ^) J5 J' Q! O8 Z: A( T
& v8 R# ?9 W) B+ ^, N. wMODULE_DESCRIPTION("Led platform driver");
, Z% D k) D/ y/ Y$ v6 z, OMODULE_AUTHOR("Tronlong");
" H$ J# g; N, o5 s8 x# {. C( @MODULE_LICENSE("GPL");
* M# x% S8 b+ J7 z S
" B% g; ?4 Y8 A$ U) x/ O# p" B |
|