|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, Q" i. [7 |! O3 f4 S
#include <linux/init.h>
& a, N7 N/ Y! I+ {#include <linux/module.h>
) ?- e9 r! L* [7 K+ C# p#include <linux/kernel.h>
% z' L, w- G, _9 I3 q y/ P3 `#include <linux/types.h>
/ m9 x6 N7 C1 o9 h#include <linux/gpio.h>
, w0 u! M) L- N0 W; @: _#include <linux/leds.h>3 }2 D& o- k; p0 P0 E' w
#include <linux/platform_device.h>
; I: i" B) n# Y. a9 Q3 ]$ w
( T, F0 g8 h- y" m/ G" H#include <asm/mach-types.h>
+ e4 `: |, ?6 H0 _2 ~" ?#include <asm/mach/arch.h>
* w# i9 M* W* r+ ]5 r0 O#include <mach/da8xx.h>: F3 c2 _1 D( t- t2 H( U
#include <mach/mux.h>
% D1 E6 r4 j3 W& ?
. y a* i" h8 S) k; g- w9 s& e$ Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- M4 l! d# A4 B8 W" V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% ~) V4 | d( x& x9 i3 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! S7 F2 J$ ]+ Q: Y% j1 L& Y! K4 ?, F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" C+ p% _/ Y. C, l4 O
2 f$ ?8 h6 I: ]- B" I8 V( p/ W$ t
/* assign the tl som board LED-GPIOs*/
& A% ~$ U+ [ {( `3 S$ Istatic const short da850_evm_tl_user_led_pins[] = {
2 R1 d& b* d4 T4 } @' C& z /* These pins are definition at <mach/mux.h> file */
! M/ Y8 D- J0 J4 x& y* o+ ~+ w0 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& d, |9 S* j, B1 c6 w$ D+ y4 l
-13 B; W5 G0 e0 @' G3 s
};
3 J3 _! U4 f& \* \/ n' L$ s; R" `* s8 @
static struct gpio_led da850_evm_tl_leds[] = {7 U; o- s6 w$ z3 Z
{! j1 Y1 V/ H0 X8 O3 _) f* R
.active_low = 0,8 C) O/ p, T, r U4 L
.gpio = DA850_USER_LED0,
. k- ?" J9 E: ^6 c K0 x% u# P .name = "user_led0",
* j; B' _+ f2 L8 u+ k3 q .default_trigger = "default-on",
0 I$ @" r [! K+ D0 L, p' f },, k, @6 X+ [( {5 ~9 M( F
{
, {" M/ L5 `+ q$ Z/ [ .active_low = 0,
. Y7 Z+ |. ?9 g$ ? h .gpio = DA850_USER_LED1,
9 U, _' x7 I/ n c6 V .name = "user_led1",
) z5 _, i, r1 J .default_trigger = "default-on",/ I3 b1 y' x1 R/ n
},
; \) _0 Z8 N( a1 m/ W, B {" x) m6 @) O7 P' }/ D& O
.active_low = 0,; [" E8 E# ?) d7 R" G+ P* w7 f1 ^7 @
.gpio = DA850_USER_LED2,
, ]/ R4 p1 q' f' N .name = "user_led2",# x t _+ _" C2 N8 x$ s2 v
.default_trigger = "default-on",/ Y8 z7 H' L& F
},
3 t2 L6 R G6 R4 n' ? {
* E4 [: e& g) l- a& d4 R .active_low = 0,' _, l3 \5 R9 d: J+ e
.gpio = DA850_USER_LED3,; c+ A: G4 U, W" Q X/ @
.name = "user_led3",' q5 R1 D8 N+ [5 _8 O
.default_trigger = "default-on",3 R8 |& y7 \. u0 \& a
},
! l8 t/ i0 h9 A2 g};) ]! Q$ k1 @% S6 z% u/ v) U- h
7 X- N! A+ Q; o+ b* Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ w" R" n3 w1 D .leds = da850_evm_tl_leds,
5 m5 t2 n- W; m& A e, E5 } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
~( v, _% |9 E# K4 A};
5 o4 z2 ?: N. U- R! R* v: c% @7 P' ~
static void led_dev_release(struct device *dev)
3 `/ m2 |+ @8 I! f3 Y{
9 O, N! P/ u5 Q- G$ x0 X7 R};
7 z, n& Z# u1 L1 e6 C& |, U
: u. G( ?+ E( C; F! @static struct platform_device da850_evm_tl_leds_device = {
: q5 i3 j& x7 t0 A* ?! Q' G- u! F .name = "leds-gpio",
. A n! N& W \ .id = 1,
/ l. q' p$ ^2 V" ~: P" M8 n5 Z .dev = {
9 l; j3 D4 t& v& M/ s6 z) b+ o .platform_data = &da850_evm_tl_leds_pdata,
& \+ J/ u$ O: Y$ }, E .release = led_dev_release,9 ]: E/ B J- m+ a8 Q1 ]
}
+ [# }6 m6 s/ L+ U0 c};
; s, J6 \! Z7 a4 \& k7 A* A- b5 z7 U
static int __init led_platform_init(void)/ a5 Q8 p/ t, S# U1 W% Y/ L
{' V5 o+ \ a+ m; a1 A* v
int ret;! Z8 d8 Z" S2 g. s+ E# S$ b
#if 0
) ~ m# z: y6 D( C5 o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& @3 O+ D5 y; v9 q) N$ ?# ]
if (ret)0 p& W8 T( B0 P7 [1 c/ U. p5 N- \( F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 q8 k. j( G# d! J) L "%d\n", ret);& ?6 U% s, m8 @7 U9 g/ z$ a& |
#endif7 g& d4 G# f4 {- G$ c- P# w: x( x
ret = platform_device_register(&da850_evm_tl_leds_device);! z5 L! c, c( B' I( t
if (ret)
4 A& Z* b6 m/ N8 N7 c; j3 ~% e pr_warning("Could not register som GPIO expander LEDS");
# L5 F) U7 U6 U5 S else. t6 Q: W: y# v' f
printk(KERN_INFO "LED register sucessful!\n");
* a1 a: Q3 x" t0 ^( _& A# o8 e& M# s; g
return ret;
6 m; ]' c3 Y2 f6 @9 C+ ]}9 {: p* o1 z' y$ I
; O! h. o4 I1 N4 M
static void __exit led_platform_exit(void)3 F# |5 n5 {( e, U! \* j
{
/ O0 b6 ?* S7 q platform_device_unregister(&da850_evm_tl_leds_device);& J9 {" Z. d" {9 E
1 O6 v! U" P7 E1 Y5 b& j( w
printk(KERN_INFO "LED unregister!\n");
1 F3 Z( t: r8 G' [7 W; j ?}
4 c9 E/ C2 X% I/ y
6 G- x: d$ ^2 x& k9 }module_init(led_platform_init);2 O4 m8 J9 R( d0 F
module_exit(led_platform_exit);
& }/ e: h* u1 s$ M5 }, v% p1 ~
6 }( R1 z- A5 X3 rMODULE_DESCRIPTION("Led platform driver");
( ?3 p" H7 j' `% T% BMODULE_AUTHOR("Tronlong");& `" z$ V( r8 ~; e4 Y4 e$ S" X
MODULE_LICENSE("GPL");
) ?( d& j E& l1 Z2 U$ F3 u* }; T5 H' p
|
|