|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 ^+ d7 {7 K( \- w
#include <linux/init.h>+ V. L8 x" e% ]
#include <linux/module.h>
6 Y1 Q$ m& L9 Y" n% P; i#include <linux/kernel.h> ?5 h# }8 |& L) T
#include <linux/types.h>0 m$ t/ T; {3 i; ?
#include <linux/gpio.h>
$ a g0 Z) {7 t3 m2 r#include <linux/leds.h>
$ }% @* Y& n4 h9 J& W9 {3 W/ q/ x#include <linux/platform_device.h>
! q# o4 M* j" `3 V H5 d. W( G4 ?/ T" ~. @, O3 V0 [
#include <asm/mach-types.h>
1 A0 }7 K ~, J, k#include <asm/mach/arch.h>
3 j6 [8 ?3 n0 ?: M$ z" Z% | A) t#include <mach/da8xx.h>
z- `: L _+ X2 d4 y7 E#include <mach/mux.h>
( m* {, O# d2 b4 A) @' H
2 A, ]3 P' \; o' m' N$ d4 S4 Q# j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 g; Q; T0 w$ I3 }. `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& u8 P2 o/ W* S( h5 h- V7 [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ a8 D( X! @5 _1 J$ m4 T7 l/ D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 Q& d4 ], ?9 C& I8 n4 E
+ r% N5 p0 P0 \* b* O% w) W/* assign the tl som board LED-GPIOs*/
/ n* L$ E5 z- E6 Jstatic const short da850_evm_tl_user_led_pins[] = {$ |0 E; ^# a. r3 h# j
/* These pins are definition at <mach/mux.h> file */
2 Q* g2 U: N5 E" v( O4 i4 S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& O1 k8 p2 r0 N L
-14 j& B( \% k7 l; C4 |6 y6 E: [( R
};$ T6 c0 ?; z6 H& @
$ o7 W5 W T8 P& S' A. W& R! n" t+ i
static struct gpio_led da850_evm_tl_leds[] = {
# c# N0 e3 i2 n5 y' U5 \/ j9 { {3 Q" ^! I8 |7 g4 ^0 i8 t
.active_low = 0,$ D6 T3 x5 l, ?' p
.gpio = DA850_USER_LED0,: k2 o5 O. `: @1 P' _1 ~
.name = "user_led0",; j% Z3 ^8 n: u1 G. N9 E
.default_trigger = "default-on",
1 S6 c3 Q! w9 `! z3 f2 N2 A },( O6 u0 N! Q+ J
{; v+ m, D2 u' A0 J
.active_low = 0,
0 k) |8 l1 ^! ?6 c% } .gpio = DA850_USER_LED1,, m% W1 S* G' E
.name = "user_led1",
3 D! \2 \+ n& r2 ]4 @ .default_trigger = "default-on",
% L: s+ k0 u7 D6 o },% L' ~; I, t, |; \$ Q$ k; ^
{
4 w e+ b! ]* N* I' c .active_low = 0,
" b& [4 W, ~" b2 R! l9 K/ u8 O6 h1 j .gpio = DA850_USER_LED2,
. ^$ F, x2 f4 C1 w% Q; z7 H .name = "user_led2",
- |5 w4 r: ~) ]/ ^& Y .default_trigger = "default-on",
! j! e3 W! s/ \) j2 B },( O1 p5 m% a" D F" N
{
4 a/ T3 L. z3 d .active_low = 0," B6 \3 ? N- k: z# c$ ?+ {) O% _. ?
.gpio = DA850_USER_LED3,- n% _) ~8 T ^/ x
.name = "user_led3",$ m" t; Y/ g+ _
.default_trigger = "default-on",
: u2 G# q# Y0 @& P& F },
6 _; Q, K4 E. K4 g& N6 m+ V};( _+ |4 ~8 c- B7 O# s1 }4 A; k
3 g2 q! r$ G v5 _9 I Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
s9 w# M$ J3 e: P% ~/ ^; Q+ D .leds = da850_evm_tl_leds,2 x0 K9 H9 S' o) O' K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 n3 {. B- ^) K! Z
};
2 D! L+ Z+ ?- }
2 T$ Q+ f1 Z( R9 Gstatic void led_dev_release(struct device *dev)" @; d, Q& T3 n9 |5 O
{5 Y2 S* D! x. r( Z* C1 P
};" z$ ]. y' z$ r/ x* S
, U9 ]3 u# ^; X# l! V
static struct platform_device da850_evm_tl_leds_device = {
- ]: L; r# `1 G8 l( y .name = "leds-gpio",+ I, d0 g, |7 ^& p5 F; W
.id = 1,
, k- v% A2 P% S5 T7 h3 r .dev = {9 n5 {9 m U% L
.platform_data = &da850_evm_tl_leds_pdata,+ z$ p3 x3 E8 H1 ]2 A
.release = led_dev_release,
3 a/ m& H9 F! ?! y }5 C3 ~) |. e2 y9 w* j6 V3 z
};
) D5 c5 \ |& m* |9 [
$ o! t4 W" ?8 w& _, j" v jstatic int __init led_platform_init(void)
. M' c6 V! o ^1 _8 E5 H{
( T, P: M9 h! Z- v2 B int ret;
# w$ r3 G/ P& n#if 0
, a9 U5 j( u6 W0 N& Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) Y9 E( y: W" J8 n2 D4 F
if (ret)
4 V7 F" Q( z) B, x0 q! W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 _5 n, A, P$ s$ w% g. n
"%d\n", ret);
& O ]) I0 B; w7 t8 M ] v5 p#endif
/ d1 n) f `* {: S- b( M9 h/ G% s ret = platform_device_register(&da850_evm_tl_leds_device);% [' ]. {" w* k' {
if (ret)0 v+ [' a$ D" P' Y
pr_warning("Could not register som GPIO expander LEDS");# V Q3 u: D7 ~2 e# x, X
else1 m3 H6 z0 ~! W$ ]* k
printk(KERN_INFO "LED register sucessful!\n");
$ o' W1 I$ c+ n0 E7 B7 z* ^% _$ z1 ^* ^# D( s/ t
return ret;
+ Z$ m5 N O, A, ?# g}% d" `$ z2 k: W* L: g& T6 h) X
1 d9 V2 ^$ a4 ~8 |; dstatic void __exit led_platform_exit(void)
' P- W1 v' a8 z- _) @ }, q7 J" t{
8 ?* k4 s% O/ @ platform_device_unregister(&da850_evm_tl_leds_device);
! L* W/ u6 s; V u' E8 u, V6 \
printk(KERN_INFO "LED unregister!\n");
6 ^4 X' @! Y1 v) H. T9 q$ i}
! J/ y3 S$ m, A) o) n# y( w) i% `, G7 O- o7 U0 @+ C( C; o
module_init(led_platform_init);; x U3 A( o, ?/ `3 [8 D$ d
module_exit(led_platform_exit);! h) z7 U: f5 W ~7 M/ s
: b8 G1 c7 R8 p* Y' e; V1 Z, o' FMODULE_DESCRIPTION("Led platform driver");
$ l+ A( D% v. G# j' zMODULE_AUTHOR("Tronlong");
" L. Y$ T \( Q( k7 m# E% tMODULE_LICENSE("GPL");1 \# |5 X" z- H! M' m
; e) @; ^4 L* M
|
|