|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 {, r7 t, a* L
#include <linux/init.h>
) j. m, r! l) ~& O- `. q#include <linux/module.h>
' q- Y# r1 `. |2 U#include <linux/kernel.h>
7 m- c$ K3 r6 w9 ]) G0 h3 ~1 v. k#include <linux/types.h>
! Q& u- P) x+ `# @/ }, b0 q; Y& ~#include <linux/gpio.h>
/ G2 w: v5 {: ^7 M& ^#include <linux/leds.h>
# k$ H7 q! z8 v6 ]7 t#include <linux/platform_device.h>
) E5 A( z9 [3 O: M+ D$ H% p5 S) S* ~+ P5 C7 ?7 b
#include <asm/mach-types.h>
0 q; E+ q; K \- d#include <asm/mach/arch.h>
" w4 s9 ]; y% v u/ X#include <mach/da8xx.h>
p: j/ ^) E; V" K7 I8 W#include <mach/mux.h>
4 T2 Z( Z) @7 A3 |
1 E/ F! {# Y1 l1 K1 c5 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( O1 L6 F$ R( I6 c. w" c# ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): z" ^) O* O& I# _ _; p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& z7 R D! G! w! k7 I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! m% m9 V o! J0 m( w
4 K9 m$ g( U" [( P, k/ L6 [5 R7 A/* assign the tl som board LED-GPIOs*/" Z1 M0 Y6 f' F9 y' ?
static const short da850_evm_tl_user_led_pins[] = {- H9 d" A, s+ X% K4 u& w% v: C, R
/* These pins are definition at <mach/mux.h> file */! w9 r/ N0 J( z, P2 R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( N# h( v9 d6 r8 H: u
-1
( R, l, Y5 p# b7 H2 t& W' c};
2 S0 R/ a( d6 T# e# H1 m, c! a8 m! q; @) z# F1 Y
static struct gpio_led da850_evm_tl_leds[] = {
9 A8 U; }: O" G- n3 U% l {
5 m2 U, u3 ]) G3 X .active_low = 0,
2 [) W g# D; v& k- l' a- c .gpio = DA850_USER_LED0,
: U) K1 m8 R- s1 ]& H+ S. o .name = "user_led0",
6 K, R* {. M1 F .default_trigger = "default-on",
" s1 ?1 ^6 {/ _! c$ Q6 V },
. E$ a$ C( l; W7 z. j$ T8 w7 w {
+ \4 [' {: k! X& t3 m. [6 Z .active_low = 0,
6 f7 |2 m/ u6 M4 h .gpio = DA850_USER_LED1,' S0 P5 V2 O1 a2 W) `
.name = "user_led1",
% _% {! x# ]" P1 ~6 A3 L .default_trigger = "default-on",
7 x. V1 G/ x" L: W! O },* ~ q$ \. d' |
{* E) E/ Y/ o7 I( h. U: [
.active_low = 0,
* B* Q* ?7 e; T* B) Z- S .gpio = DA850_USER_LED2,' ^0 |2 V3 C4 N0 b* k
.name = "user_led2",# U; O: s$ L, x; |7 h5 X
.default_trigger = "default-on",+ a& J" W! Q) B& `9 q9 T8 Q& D2 ^
},% E% Y3 \$ i! M" p* V0 O. [
{1 g9 ~" @5 Z4 ^4 h6 f) [$ ]9 D
.active_low = 0,3 e" s a2 h! x7 H# o- |3 a+ W6 w
.gpio = DA850_USER_LED3,( i# O- q4 `! @+ @5 s
.name = "user_led3",
4 j3 |# {5 i& g0 m* k( ` .default_trigger = "default-on",
7 ?% o7 a$ n1 b* @" }( p },
, p/ `* I. j: K4 k8 F};
?; B1 K) G2 d& }
0 p- g/ p5 B" i4 p8 V$ v. fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- d3 U: |; k3 b" A; I .leds = da850_evm_tl_leds,# [- V) q6 Z: r7 _0 {* c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 M7 p$ Y% p6 e: z' \};( q3 ?4 Q& j" r C: o! n: y
& E* X% F0 t8 G. `static void led_dev_release(struct device *dev)4 p( D4 l* o. R* |0 p3 X9 M2 q
{
# \4 `( |2 \' W5 H$ n% Y};0 B" r+ b8 a! H- N
9 W2 o7 x, y+ y2 x% ]static struct platform_device da850_evm_tl_leds_device = {
5 w8 P% \2 N% C$ h .name = "leds-gpio",
' y6 c; ]( x6 V6 e: D# \3 G7 j! V .id = 1,% V! A: C5 m% M- [2 k2 K( C( f
.dev = {
, J. j: f4 R) e/ c: O2 E .platform_data = &da850_evm_tl_leds_pdata,: _- h( ^" Z. Y3 @- r7 d
.release = led_dev_release,
3 i `* j3 z5 r1 M$ c }$ K$ m% L: \* I, x
};
! ?, E9 s: D0 D Y1 M0 p/ g/ D' J6 r# h V& P% W7 G6 \ K/ S8 A
static int __init led_platform_init(void)
8 j5 u& Q) l( |7 x _{6 A. v- w. F5 _; L# {
int ret;
4 [* g. c. M9 P# W7 z#if 0
R+ E' F9 R2 M4 @" w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 U* P7 `5 [* _3 x2 h2 j7 Z# s
if (ret). L; v2 q, |& k+ A% L, @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", @ w* x' o8 X; M \
"%d\n", ret);! j3 u# d) e( i' X
#endif
$ n* y& P4 x! A5 I. R) I ret = platform_device_register(&da850_evm_tl_leds_device); F% }' u9 B. R& f4 ~/ c7 b, Z
if (ret)1 ^! Y/ ]. ~1 {% U- v
pr_warning("Could not register som GPIO expander LEDS");
; I! {1 P) R1 d& r else
1 U! y a# W2 X: g C- ` printk(KERN_INFO "LED register sucessful!\n");
/ b5 a7 d8 b! d
. {+ o( k) d7 L" F5 B return ret;
$ {1 H$ S$ x6 h}
* ]1 u% d( S$ `- _7 H
& T; R% I) c7 N" v. \/ lstatic void __exit led_platform_exit(void)& N4 t9 b6 Z% H4 a# q
{
/ S$ f J ^0 K9 B: ?# O platform_device_unregister(&da850_evm_tl_leds_device);
8 _* C. g9 \* H5 I& d+ C# g6 I/ I# Q/ o9 K( Z
printk(KERN_INFO "LED unregister!\n");* s1 j! Z7 ?( E1 K, z
}. W8 {2 A+ Y/ T7 H& N+ V) R
( ^' o @' v- ~; smodule_init(led_platform_init);
6 |# t s# i/ R- y+ V& _+ H/ q+ imodule_exit(led_platform_exit);
0 s* X) }" S' m+ {! C0 @% A/ D/ L
- G8 @1 e2 a+ sMODULE_DESCRIPTION("Led platform driver");6 N0 c$ [/ x# p% B3 V
MODULE_AUTHOR("Tronlong");
$ [7 R/ E( Z( x1 ?6 E1 c8 HMODULE_LICENSE("GPL");
4 i: S5 x# F3 d7 r4 A
1 a4 z. T+ l' K3 H* b! s0 S7 `7 P |
|