|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 {, e! e8 \$ y+ C6 P) @1 _
#include <linux/init.h> g( ]; G0 k+ }# @# w5 M, n6 Y3 V
#include <linux/module.h>
. F9 g' o7 |9 W3 K4 b5 i: B# Y* Y& [#include <linux/kernel.h>
8 `1 |1 ]2 x: g9 `#include <linux/types.h>
2 y% j- [% m7 C2 O* g, e3 u6 T3 L9 n#include <linux/gpio.h>
0 g" }7 ?9 v% B/ G' ^+ T, r#include <linux/leds.h>. t8 K+ P. ^* f- ]
#include <linux/platform_device.h>
1 L/ M0 ?( | {' m K
4 S0 V5 k7 T4 {6 K#include <asm/mach-types.h>- ^ _% W5 `3 B8 @$ y; \% ?
#include <asm/mach/arch.h>
* R" B7 y6 V+ ]- x/ w) t#include <mach/da8xx.h>
4 h7 `9 p1 M1 G/ }#include <mach/mux.h>
/ \$ h6 \: a2 n+ }4 a8 i- B& _% t- |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" L9 }, ^- J) k) A) \4 N; _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 D8 X4 T! Y! u7 n! I% B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( \+ o) p/ P5 a8 f3 W3 Q7 D3 @ k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
w9 ~& V( S% v# H w' q" t
6 P9 W( O% @( B: ~/* assign the tl som board LED-GPIOs*/
4 [8 q2 @$ n) J7 E# ?static const short da850_evm_tl_user_led_pins[] = {
$ o: s' i" @9 _! q) _ /* These pins are definition at <mach/mux.h> file */
9 y) p/ ]# H: A, Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 g9 @. d% X1 ^7 P* _7 `8 v -1" T& W( H3 k& J" R v5 |' t
};( V. n$ l8 n4 B6 v
' q/ y" j) x/ Q" r: F" H5 n$ i0 V. G. Tstatic struct gpio_led da850_evm_tl_leds[] = {) C' C* w" {) u% Q1 r& {
{
' d! B) C. }5 p/ I5 U" Y .active_low = 0,2 f; ?! U7 a( G: x7 K! G8 W
.gpio = DA850_USER_LED0,
E# G2 m$ C+ h+ N3 e6 G$ [ .name = "user_led0",
9 Z# a0 F7 y/ ]9 L# n .default_trigger = "default-on",- t6 k7 K1 i; t1 {9 ~
},
i' u7 i* G$ r( ?0 m {" r) L. e$ Y: \! c( {
.active_low = 0,
. y) ?- @3 y1 W0 B! Z' q" B" X .gpio = DA850_USER_LED1,
9 {. u( r% V9 Z9 b; m$ C .name = "user_led1",8 l4 M5 z9 A9 t5 n2 v. x
.default_trigger = "default-on",0 h" g* c; ~: s/ c9 e
},# V0 V' K3 S0 Y6 r3 t
{
. A: Z0 w7 d0 j" I2 _2 l .active_low = 0,
% {, B/ s: j/ F2 p .gpio = DA850_USER_LED2,
& h: s0 Z' y8 X4 y- o: u! Z$ f .name = "user_led2",1 l e% \2 {' f
.default_trigger = "default-on",5 Z+ X9 u8 X; _, z/ U6 R
},
. D `6 {( @9 f$ S {
/ W7 D8 O, O! u+ c4 m! Y7 K/ W .active_low = 0,* G9 P* t m9 _6 r4 p8 b
.gpio = DA850_USER_LED3,
3 ?0 j9 R: f" z2 Z% o6 w .name = "user_led3",2 | k, z& f6 \7 G4 Z
.default_trigger = "default-on",
2 E0 u& ?+ s6 m: u },
1 l5 i3 A1 I: s};* r- O. G* A1 G/ [
5 E6 `4 E) u8 X" U! [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, m# }4 F- [& i( }3 I
.leds = da850_evm_tl_leds, ~: k5 g4 }; h* E" @6 _. A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 K) E/ T& G6 j6 ?- X: s
};
5 ^ F8 M' j0 R( p) R
4 I! \' j B- ? o4 D+ zstatic void led_dev_release(struct device *dev)
- ? ^ g9 |' M{
- R0 W* G$ P. @};% ^" ^. K* m3 G) j9 S U. P0 A0 v
% Y0 s9 h6 [" d6 t% B1 Vstatic struct platform_device da850_evm_tl_leds_device = {
3 f4 t2 L* T$ z, E: Z" [ .name = "leds-gpio",4 p5 }. Q9 f# h7 J% q! M9 F
.id = 1,$ p6 K0 f, p4 o: v' B G$ `
.dev = {
0 M# \0 x, u5 G( w! } .platform_data = &da850_evm_tl_leds_pdata,
5 \0 l& ?# h8 d4 `) { .release = led_dev_release,, e" c! z, ?, n
}
4 p' N8 q& d# J, O, a+ d0 ?- Q};
3 k+ l9 D2 R; Y% P7 p( ~! N! Z. K' I! w4 a
; \( {7 N0 v7 Z9 H$ Nstatic int __init led_platform_init(void)5 @% x8 O: q! T% x: @
{
/ L1 M/ C1 {; |+ e1 Z int ret;
/ x% c& Q3 ?! L; N2 `" B- t#if 08 Y8 `& y F" d- e( z9 c$ t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 S/ x D! p. i% u& R
if (ret)" H/ j0 Q# a( |) }2 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ d' h% r. z; v6 n! d
"%d\n", ret);
3 H) d* C; K. T: k- f& |9 x#endif
# m- a+ z# @) h3 y! |/ f ret = platform_device_register(&da850_evm_tl_leds_device);& \; O. ^7 C1 w. q) d$ w: M* @
if (ret)3 t$ F3 _* b8 r9 X* h l+ U$ D
pr_warning("Could not register som GPIO expander LEDS");, }( ]3 f' z+ ` o) U7 b
else: V/ }. J! M r0 {7 g
printk(KERN_INFO "LED register sucessful!\n");5 w$ A% q* H, s# l' m" G
6 l% ~( A9 Z! H& f; ? return ret;: L2 W( l% j# _
}
' I1 y$ _9 I7 g/ @
) }) v# X& {0 `9 d: L* Tstatic void __exit led_platform_exit(void)7 m" }% t5 F! q. m* d6 _
{! F* h9 S! A! l
platform_device_unregister(&da850_evm_tl_leds_device);' }" h/ U& E Q+ A% K; n/ u. `
5 x: }6 g }9 v1 L3 v. T1 j
printk(KERN_INFO "LED unregister!\n");' A9 U# {+ ?' ?
}
; i9 P4 x- L9 f, v" s5 V$ h O9 R$ v
module_init(led_platform_init);
& _4 G2 w' {& O2 p" J' m8 f8 Tmodule_exit(led_platform_exit);* E; r! }' [8 {2 L+ j# Q
( e$ |- n) f, B: F. @+ nMODULE_DESCRIPTION("Led platform driver"); N, M1 {; S. x0 |& a
MODULE_AUTHOR("Tronlong");
7 j' [% A7 E& f' ^- mMODULE_LICENSE("GPL");
. L% d" }. ?) S" S1 y8 a, _
! @, d" f/ A/ t4 f$ g2 T |
|