|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. I* f8 W) J+ Y; w! E6 m; U#include <linux/init.h>
# H+ X+ u3 I! u) ]" z% t#include <linux/module.h>2 P2 S5 t+ e* u& \9 c8 i
#include <linux/kernel.h># u# h5 l3 r' I. |
#include <linux/types.h>0 A/ \& V' G1 i' Y" a* n
#include <linux/gpio.h>- s8 h7 U% i) v9 u+ @
#include <linux/leds.h>) w7 d* e: v) H. }0 p& C
#include <linux/platform_device.h>2 i; J4 b% ?7 b: Q% O
- {0 P6 x2 \3 n9 J- O#include <asm/mach-types.h>
( k3 \( u0 g# F1 D3 D+ K* @#include <asm/mach/arch.h>
" M" B. p; G0 a5 `#include <mach/da8xx.h>
5 j; q3 ~* O& r) ~7 |/ b# m& Z#include <mach/mux.h>
0 M6 D# A$ t) d5 ~& {4 m U& P5 }2 x U1 m$ g9 ^. c. p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' R% q$ V! U5 ?- H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ y% A0 |7 z2 t! g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 g+ s. ?* |# }" Y1 D0 n) m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" \$ t4 ], N4 E" i0 `1 ]# V1 c0 H/ x9 ?3 P; r" _) ^" {
/* assign the tl som board LED-GPIOs*/- y, g% C7 y% u% L( V; j4 R# N0 A
static const short da850_evm_tl_user_led_pins[] = {2 z. J- u' ^5 N" D; j1 |
/* These pins are definition at <mach/mux.h> file */' d, t4 d& g @! s. I' H4 g5 t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: B3 E7 s3 L! m* t6 b8 T
-1
8 l6 X# `6 Y2 V) o2 \. S7 d$ Q# f};: M7 p% U5 _5 O: J, i9 O- _' D. s
2 f7 `5 Z: c. Jstatic struct gpio_led da850_evm_tl_leds[] = {4 |3 }/ \, ~' {4 X
{
. Z: |- C* A% T! k& R0 V: _ .active_low = 0,/ C6 h' O% i- x$ p
.gpio = DA850_USER_LED0,5 Q+ V& N) t4 E5 }8 C1 Q4 |
.name = "user_led0",( \4 c ?8 y6 j1 G4 G" w2 K: f- a4 M
.default_trigger = "default-on",# N5 r' l3 A( p& k7 V' m* T
},
U$ ]( y. u7 c! a9 d& Q& J {+ D; N- w" }9 Y% r% ~2 b5 k" ?
.active_low = 0,
- m" d0 i. g$ g4 O/ n2 x .gpio = DA850_USER_LED1,# c! s- f5 ^ k7 K1 g8 k
.name = "user_led1",, @ W& @# ?* S) [6 T' b7 g
.default_trigger = "default-on",
6 c ^2 S8 v. P) l! K+ j },5 p6 [6 w( {; i; e2 S# ^+ A
{
8 c7 m9 s7 J4 P8 C .active_low = 0,
/ T8 l8 O4 L1 V) j# X. t .gpio = DA850_USER_LED2,
+ i. H, p/ K+ l+ Z .name = "user_led2",* {% G* A; B, ?' ~
.default_trigger = "default-on",2 ~6 Q5 C7 D2 H+ Z
},7 S, P$ o+ U1 K/ Q, D$ U
{
3 b+ G" ?. d l4 F J5 C$ A6 Z .active_low = 0,$ g7 i3 R) Y! J: ]% D7 |9 C
.gpio = DA850_USER_LED3,
6 W6 \6 K# I% e .name = "user_led3",
: ^+ K1 E. w: ]5 U3 Z) u .default_trigger = "default-on",
7 f- N* G$ `- T },
' x# a7 C1 ~" E+ f9 k6 g};
* t: H! o& M. S5 x
* g; J. x; u8 g& }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 t5 m( X+ S" O5 n% ^8 }
.leds = da850_evm_tl_leds,
! Y( x" c6 H; d3 _0 F& d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 f& @# j7 v9 q, R
};
3 q6 { F9 p: T3 e% k+ @% |+ w/ o/ k z+ U
static void led_dev_release(struct device *dev)( a/ C" |' p: {/ A" f- b& z- a
{
1 J' y4 V1 W0 Q* n0 l0 [" o n; O};
# b4 u# q4 f J m2 V" E) R- M9 _. g3 z; g/ j( g
static struct platform_device da850_evm_tl_leds_device = {
% Z4 E- U+ W' Q* u1 D .name = "leds-gpio",
% |) {5 d' m! ?6 ^! C- S% ^+ k2 w9 q .id = 1,( [4 h/ @0 V& I6 x8 t" T" V! I
.dev = {
/ a% ~5 o- O, R5 q$ O* ] .platform_data = &da850_evm_tl_leds_pdata,0 l! z" x7 o; m# E- b, b+ U
.release = led_dev_release,. r/ U9 e. R: N' f4 q( ]
}
& t4 L, V) }) L( X};
) j$ [3 i% s4 D7 I0 R! ~: K D1 B8 l9 Y) J5 e& r+ |" u
static int __init led_platform_init(void)0 r ]+ C! j- X: F
{
Q& {6 ]) {: V) A8 x int ret;% [% d# K* \: R: v/ X
#if 0
0 k3 n4 z9 U# b5 l' @! S# i; e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 G0 Q) z& i6 J' y; R2 ?6 A1 t
if (ret)
3 _* s' W$ u% j7 c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: B* m$ N) Q, O4 J& k "%d\n", ret);8 B# w( h: h) g1 C
#endif! n9 [2 n0 S% Y5 J9 S" c% L2 h
ret = platform_device_register(&da850_evm_tl_leds_device);
) K2 z! A# ?. f( Z5 |4 n1 m if (ret)& A& I% z$ H! h( W! H
pr_warning("Could not register som GPIO expander LEDS");2 q) `$ N& G; ]4 A+ |: h9 U
else
2 h9 M6 }/ @- _2 C. k8 K9 K5 e printk(KERN_INFO "LED register sucessful!\n");/ a) P' \/ Z) U% a3 O+ m5 f4 J
8 a& ^& j7 a. C8 [0 H& G
return ret;
* e# H3 C, a& d" |0 N( O}
- p h8 s" k o% s' T- w: g& W' B: k" f6 `1 j' w. K
static void __exit led_platform_exit(void) f# ?6 G' S. K( h6 m; u
{
+ j* h" I! z5 z4 A platform_device_unregister(&da850_evm_tl_leds_device);
: f1 w; _& O/ V V; r1 s% F3 B; k5 u$ X9 u5 I7 D
printk(KERN_INFO "LED unregister!\n");
- ]: B( y/ m, Y" s5 w! J}
( j9 r8 o' N2 M$ G9 [* ^- s/ F
' E% I: }2 F4 |3 h. {7 q5 s9 E4 b" Hmodule_init(led_platform_init);- o* t* ~0 B9 Q+ I* O
module_exit(led_platform_exit);
2 O# k3 e) k" G' x/ Q3 r& I; {0 ]- E& i) s" y' M" a: Y) _
MODULE_DESCRIPTION("Led platform driver");
& S) o4 G& N: |5 e4 ^& UMODULE_AUTHOR("Tronlong");
2 m! a: F7 F& V6 a& {: DMODULE_LICENSE("GPL");
- T, |3 N' ~. H" o9 v w- L
/ D6 m, V( B! L7 h2 p9 I |
|