|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( S% o3 K" U6 u* K/ y1 ?
#include <linux/init.h>
/ @: E; x. [" l. ^4 B- k#include <linux/module.h>' H0 a% Z0 d0 i( y3 [! I
#include <linux/kernel.h>
2 o7 [5 Q6 ]7 S7 e#include <linux/types.h>
" V, `0 k5 K9 l. Q5 S- b#include <linux/gpio.h>) l* V; e& E. r* p
#include <linux/leds.h>+ Q1 N1 {1 J: n2 s2 w) e" |
#include <linux/platform_device.h>: M$ W3 B6 M8 h" U- j+ p: q( x
: l/ X) ^5 p$ O6 i# L#include <asm/mach-types.h>; f- h' P7 H# f9 ^ [
#include <asm/mach/arch.h>& n* x, a* z9 U2 u' y; N
#include <mach/da8xx.h># t( m1 P0 J( \7 u: B$ i/ k9 v
#include <mach/mux.h>
* b# Y) g0 d* G
7 K& L3 s1 d0 \' @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 W. S7 F% e5 B- R0 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 E4 @% V9 s% r) x: F3 M$ l. j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- n9 K7 e, T% \3 F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# |/ w6 q" e; n8 M0 q! K
' E$ Q8 T3 v8 c" K! S/ M* }/* assign the tl som board LED-GPIOs*/
( q; I. h% d; fstatic const short da850_evm_tl_user_led_pins[] = {
5 w/ Q2 ]6 r: |5 E /* These pins are definition at <mach/mux.h> file */
/ E% o/ q7 J4 v3 O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ G, s4 S+ u7 A# E+ w, a, r* L0 u -19 B2 v' C3 x( M: l6 D; _
};; v1 U- D0 k7 V/ O- Q) S0 b6 J: N
/ t2 X) x% M& z4 @& C' @static struct gpio_led da850_evm_tl_leds[] = {5 ^% W1 g# Z) Y$ N
{
6 u+ \* |* F! V9 }/ e: E0 b9 D _ .active_low = 0,
# L8 b7 P0 `8 }' F .gpio = DA850_USER_LED0,0 e( I3 N* g6 R9 J+ w: h b3 @* a
.name = "user_led0",, J f; ~# \# l. d4 O
.default_trigger = "default-on",( R7 a5 r6 f" ^* p$ H) R5 I
},
- J" z( ^# a1 A9 \ {6 w! Q5 |: {4 b+ T
.active_low = 0,
1 x7 a5 j+ u) P& D' s .gpio = DA850_USER_LED1,
- q K$ k R' m; D( f" o, k7 R .name = "user_led1",& b3 p$ p+ w2 l; c ] |0 T
.default_trigger = "default-on",
|; r! H7 w" D, i6 m! u }," u8 s3 s! J, u2 z6 H! n
{
1 m9 f" ]" I: S3 e7 _2 a .active_low = 0,1 l( }7 Z( W+ w& q1 H; Y1 p
.gpio = DA850_USER_LED2,/ r, }8 L4 B- q0 ]2 u
.name = "user_led2",0 c$ U9 c9 k* z' n7 z; O- X
.default_trigger = "default-on",* G* @# Q+ S6 i4 u. F
},( m5 W0 {& P" {! h$ R) y
{
9 p) {& u- s/ Z+ v9 O .active_low = 0,
' P7 Q) Y+ P2 f" X; S- T' e .gpio = DA850_USER_LED3,6 q. j6 u! z- e
.name = "user_led3",
( k! M9 f# a% \' ] .default_trigger = "default-on",; ^- w7 X( |& d" m& _3 v* ^
},
3 _3 U/ A7 k# z4 P};
3 T$ Z" e! i: W3 K0 j8 R' U( [/ G1 Z: h6 I+ r: `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; [( E% T. n# n
.leds = da850_evm_tl_leds,
, ~) N0 O7 V- o6 z' P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ ~ f. T$ `7 ~5 f7 ^6 Z};
! E' C* F3 z" C# z$ w% x
/ [" E( r8 K P/ i0 S0 X {static void led_dev_release(struct device *dev)
a+ m( n& W$ W7 A& `& t{! ^+ N2 e4 X5 M' Y5 i3 @
};
) Y f: h1 O5 u5 M# S. g5 k$ a* @! S
; P# [+ W% [4 u) c8 V0 A/ x9 U, Nstatic struct platform_device da850_evm_tl_leds_device = {2 m' y: O2 J# Z
.name = "leds-gpio",
5 P$ Z+ T- t" p$ r2 V .id = 1,
( K/ t# E4 e0 l1 k7 ^# a F .dev = {
9 z/ {# X+ p1 r8 w0 O+ n8 S. c6 R% V .platform_data = &da850_evm_tl_leds_pdata,. F6 \: @" v0 X; L2 s p
.release = led_dev_release,
1 Q' q# i, ]. A$ ~8 O# k: Y }
0 u6 b$ ^. I9 Q};, U8 n- I' J1 F0 K
, v0 l) q( A, x' r1 Estatic int __init led_platform_init(void)) }7 k" q. e1 y7 O: @
{5 w+ e- z/ c |- Y9 h+ ^' {4 S
int ret;1 X- \) i1 G. p% @, h
#if 0
- D; L8 b6 s8 e$ `4 x2 s3 {3 u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 n7 O( ?/ F1 [, O3 _4 P if (ret)
( d- E2 Y6 S5 v- p. U% P* Z( w F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 A# S& l: f* x( }* ^. f0 X "%d\n", ret);- o# B" b. B5 o# a
#endif
" j9 \3 J" y0 }& s) T ret = platform_device_register(&da850_evm_tl_leds_device);6 z1 m* O+ C" ~4 [% A) b$ Y3 z g# w
if (ret)
7 `1 p9 k4 g( Q' P pr_warning("Could not register som GPIO expander LEDS");, m3 ]; Z4 Z' W& [5 x
else
/ f0 i( y! l' c# G printk(KERN_INFO "LED register sucessful!\n");9 t9 h+ O$ ]2 [8 V2 `
0 p! A0 q% j) M% e return ret;+ @' |( Z3 ]2 o L1 S9 B/ e
}0 ^3 y7 ]; {/ C$ D! |; h
6 O% S, {7 \- p: n! Dstatic void __exit led_platform_exit(void)8 e7 s) R8 j5 M F4 v/ B4 H
{8 W+ |- q6 A% ^1 F
platform_device_unregister(&da850_evm_tl_leds_device);
8 w; O/ f% N+ m
& [, f9 N: c$ W# u$ u, n printk(KERN_INFO "LED unregister!\n");
+ Z9 K9 c5 h5 ~}
3 b/ q3 B9 N; L2 P2 g% w) y9 v K& i3 Z. [
module_init(led_platform_init);
2 U5 [6 N& K! xmodule_exit(led_platform_exit);# `1 N6 `. d# N% d9 w, p
, W# Q9 ^4 Q6 X% T1 iMODULE_DESCRIPTION("Led platform driver");
8 q: z) d W. ~$ UMODULE_AUTHOR("Tronlong");* F' M( T2 g! O( Z" O" u
MODULE_LICENSE("GPL");& k6 F. B" j5 [1 H! b
Z6 ]! Y; e& ^4 v+ f |
|