|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 b% [: x$ X4 y* H V: z3 Y( x9 ]#include <linux/init.h>
- L4 @& g1 S" }5 M# ]#include <linux/module.h>
& S/ ]1 X! V2 M, v% p#include <linux/kernel.h>5 v( B, j+ Z5 R, ?
#include <linux/types.h>( m; X( P# d0 _6 Y
#include <linux/gpio.h>
: } z: ?$ H Z$ e# }* z% ~9 i#include <linux/leds.h>6 Y0 i" _/ G- m7 |- c, M
#include <linux/platform_device.h>! L& @4 r: l; J! {" A
! p% r2 w4 u6 Z B2 K0 O! d/ Y#include <asm/mach-types.h>
0 \/ y/ D, {+ f B6 }9 t#include <asm/mach/arch.h>1 U; B7 P2 E6 {& M& F, b" j
#include <mach/da8xx.h>
0 E4 s; s/ M, B2 z/ u#include <mach/mux.h>0 K {7 J4 S0 V7 C. J N8 H6 c- L
% h4 j1 U! B6 S1 R1 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 L" A% q/ W! ~$ s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 D2 v3 k3 \, D6 ~4 } M( M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); S# z9 ^. i$ K' ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). d& C$ x, m# X
: R6 o: |& E* o0 e1 H1 D
/* assign the tl som board LED-GPIOs*/7 V: W/ }" J A" H6 w+ T
static const short da850_evm_tl_user_led_pins[] = {4 w- Z. o! y# f( S6 Q
/* These pins are definition at <mach/mux.h> file */4 b5 y* v$ x0 N& q# [9 [& o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 ]; B1 b$ h, t$ n! C& c
-1
; N- R% D+ [& p};- i) H" H2 V0 s; N9 C. j" f# a5 U
9 |3 R4 i+ W5 \
static struct gpio_led da850_evm_tl_leds[] = {; x0 k6 y/ ^6 z8 L0 d( v, i
{
2 B4 q1 }0 `' h8 ?2 L( Q7 u .active_low = 0,& u) u9 F U0 R3 D2 c$ J# g1 z5 t4 F$ r
.gpio = DA850_USER_LED0,
+ W9 i$ G6 \" u1 j .name = "user_led0",) b0 m% ~) G3 p5 |4 ^
.default_trigger = "default-on",; G& \1 h) @. _
}, O, i$ s0 {1 B+ G
{
" ?( ^- u t6 T! L" b .active_low = 0,8 N( X0 t* Q) `% l) Q) T# d0 P
.gpio = DA850_USER_LED1,
) B( J/ W$ N) Z! B+ P .name = "user_led1",. d9 q6 U. a* d/ S: v# l7 F( r
.default_trigger = "default-on",/ K g- a8 V) ~( P% I0 R
},
6 a/ R* K# p- Y& } {5 b& I0 @# g3 X3 I
.active_low = 0,
$ D3 L8 ]9 A2 ^3 J .gpio = DA850_USER_LED2,* f! R, L0 O B* p( {
.name = "user_led2",$ S, Y. U, |- j$ m: y
.default_trigger = "default-on",
. T9 @3 Z1 C1 X5 @# l },
- z( f% |0 }9 [; L3 y5 v) P {
9 N: l% e& [! { .active_low = 0,! e6 z7 v! I0 F
.gpio = DA850_USER_LED3,, z9 B! m& X+ \1 s
.name = "user_led3",9 m! K. W s/ M
.default_trigger = "default-on",; J% x. r" U: F7 A# i
},
2 c/ ]; m5 u, z, O9 P};
7 q% Z$ {0 J) | }3 ?7 g/ r: g5 p% g9 y2 f; Z: C" }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ t! |' e* ]7 J1 Z$ b# \ .leds = da850_evm_tl_leds,
# r% ?/ |4 @" i+ n+ | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 x; s J1 b) X, |4 D0 c};9 |+ @5 |/ H! V H9 H- n
, [" S! j& m, S S" d1 cstatic void led_dev_release(struct device *dev)) y- J% l3 {4 M, \
{& V/ }7 _( P) e# e/ A
};
7 d7 `- x5 e+ b3 H( v
5 ~/ T2 Z! O" S* w7 ]static struct platform_device da850_evm_tl_leds_device = {
# _* i% q+ p" o .name = "leds-gpio",( S; P* Y; ^1 n
.id = 1,* m/ ]8 q# ^: r
.dev = {
+ ~5 g# p& N- `, s7 L0 t# ^. r9 p .platform_data = &da850_evm_tl_leds_pdata,
9 w- P# R+ P( ?. q) m1 l5 k3 [ .release = led_dev_release,
' Y M+ Y1 G4 h3 ]4 {' Q- { }
3 ^. q( `6 ]$ U: D};- u( ~, ]% ~$ Q! Z4 M. s+ i- k
* e3 R& D w4 B ]static int __init led_platform_init(void)+ L& Y. T q; U/ c
{% | k( P' e8 c2 M0 ^' `6 c$ _
int ret;
2 [2 |5 t% F* w3 S( ~' M p#if 05 h4 \1 m, u$ y4 G1 ~* _. L4 T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 D6 B h2 o% i# _5 S6 {2 w# H
if (ret)& N. f X& ]- X. n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 j* A5 d' f: g6 ~- h- ?" F% u
"%d\n", ret);6 m0 {, p& Q7 p) O X8 K
#endif
1 o! J# b" S% F! R7 q# n% t ret = platform_device_register(&da850_evm_tl_leds_device);
' R( a F0 o3 M# c/ A c ?2 t if (ret)
/ i% G, _% g2 c3 h pr_warning("Could not register som GPIO expander LEDS");' n% P- v: @8 {3 D& r# ?
else# s/ w+ F- }3 G; Z( v" j
printk(KERN_INFO "LED register sucessful!\n");
* }. Q9 h y* `4 u
9 H2 J3 d: O9 g5 V# R* `. t, a return ret;' S1 r$ p, m" B5 ~& [
}
; S/ m7 p3 Z0 I5 l9 B( _8 q' T. ~1 {$ u+ O" \* i- O% c O
static void __exit led_platform_exit(void)' j- H8 Y! H: O- @6 x" f
{3 \# u3 h1 B9 Z- h- m
platform_device_unregister(&da850_evm_tl_leds_device);3 M( t3 i3 m. {7 s
^5 ~4 o$ a* i; A
printk(KERN_INFO "LED unregister!\n");
9 z" K6 n2 `' F$ o}( R7 a& p3 R: |, e- |
1 @1 |7 B" D% e0 wmodule_init(led_platform_init);+ v# b, h. u* C7 ~* y8 I
module_exit(led_platform_exit);
* S8 R4 f$ i( L! w
+ W9 p( N5 @2 o) l w- JMODULE_DESCRIPTION("Led platform driver");5 O" @$ O( R% M7 i Z2 w, x+ q
MODULE_AUTHOR("Tronlong");
) F& I4 @8 `9 Y" n0 k. B" wMODULE_LICENSE("GPL");3 k3 l% e0 m% o9 a( [. f; b; q2 p
. F# c& m4 h+ y/ ^, J1 ]5 j; `3 j: D |
|