|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 n1 T3 K% _0 D1 ?8 G; Q5 A#include <linux/init.h>
9 t; C, w3 C& P' [* G#include <linux/module.h>
# R9 b1 x0 x) I$ S8 q+ |. m#include <linux/kernel.h>
( {, k# u7 q' ]0 F#include <linux/types.h>
5 A& g, M1 w% e( }- I2 D7 W7 G7 Q% p7 U#include <linux/gpio.h>4 J# L4 _% o) z
#include <linux/leds.h>
& X0 ]1 Y6 m" n9 b- k: W9 @2 p#include <linux/platform_device.h>
) \+ o8 I' o# i. D; H: w7 ]4 ]1 H' D
#include <asm/mach-types.h>$ s: W4 C4 ~7 t% E
#include <asm/mach/arch.h>1 C$ \6 ?. I4 s" _) v1 a9 N
#include <mach/da8xx.h>: I! ?; j$ s! v( \9 f
#include <mach/mux.h>
$ T7 L; N) V: A/ i6 k( |5 p" V
$ J- l6 W, u$ f! p/ L% _/ r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# D d9 L. U- R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 V, k1 o- T. Q4 Q8 t( g, I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- T; C8 i5 C7 B7 I2 H. W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ D; r$ P6 \% o k) J1 @+ k; i' ^
4 U) _6 p$ O; i! z
/* assign the tl som board LED-GPIOs*/* x/ L: o4 a$ j
static const short da850_evm_tl_user_led_pins[] = {
7 L: L1 n0 H8 k% k- Y: Y9 p1 j /* These pins are definition at <mach/mux.h> file */
2 ?' l) @- f) T& a. B; a1 I- s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) i; G5 W5 c3 S6 }6 b -1
9 r, S: V% P: D$ A};3 D9 Z/ x" E9 n& u3 r& r) u4 A& i
5 a& Y% r! G% q/ q( C* _. W, t4 Z9 k! i D
static struct gpio_led da850_evm_tl_leds[] = {5 r8 P- Y2 G- C A
{5 S5 m9 r) E# M
.active_low = 0,
2 s, s3 i5 M/ Y! `, T .gpio = DA850_USER_LED0,( H3 R: S# p" c D6 _& J8 n3 O
.name = "user_led0",
$ c7 T$ `5 b, z .default_trigger = "default-on",
9 S' @8 n: P* M. d7 ] D) c3 q$ }0 ` },
. P) f* X& L, h/ T" b+ \5 G9 p! `. d {
0 E1 e, L# T: b. t .active_low = 0,( X5 W( A( G: X0 I& l _% d7 F
.gpio = DA850_USER_LED1,
9 Z! s$ {% k7 A; C .name = "user_led1",
2 a' O* Q# ^7 G& x .default_trigger = "default-on",
9 ^6 P8 N2 E/ ~& {0 h },
1 C( Z7 H$ ~ t0 U8 G- @# X- w {9 ?7 U! p3 X3 a" J
.active_low = 0,/ I) K- ^! K% j5 V2 ~' I) e
.gpio = DA850_USER_LED2,
2 ?( o c8 s. `- G .name = "user_led2",. g7 g' v/ g( P- T( k+ u7 i
.default_trigger = "default-on",
( T7 ]" @- S7 V) i; m6 ? },* A& F# L# R2 R. S
{
6 |9 q$ I. u% _ c8 k$ D .active_low = 0,/ n6 z$ U' b! J, j0 y0 {. a$ P# q
.gpio = DA850_USER_LED3,2 q* N: W- m0 K! y# x: R
.name = "user_led3",( {/ G" z' O. }
.default_trigger = "default-on",9 y( q9 h1 v. H) Y0 y0 Q- Z
},/ V5 h R! \: v
};
4 G$ f, e. N8 m6 s- u+ R) I6 ~# ^
6 L' k5 Y3 s1 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' e4 D' Q& G: X! ]; [
.leds = da850_evm_tl_leds,
. l; b! R/ f+ Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: @. B) w/ K& }( L, r: d7 T};( P8 E1 O0 L/ V1 I; d0 t
& F* t* L' N Istatic void led_dev_release(struct device *dev)5 q' u+ `' p* q8 o/ e
{# `4 a+ o" y9 b1 J
};) r w% u- h& x0 b
) u) g/ x7 ]! [static struct platform_device da850_evm_tl_leds_device = {, Q9 M( `1 f9 _, A- q% k
.name = "leds-gpio",) ?3 N% _. {6 P; k5 l3 K
.id = 1,: r4 f( x/ z( v, n- i0 M) u
.dev = {
+ ~. h2 s: X6 s0 W+ U7 f .platform_data = &da850_evm_tl_leds_pdata,
5 f& [+ {) w; l: o/ I4 a* [ .release = led_dev_release,
! ^+ f1 L) i P }
; G) } }1 N9 {: W' Q I};2 i! U& K1 {4 Z
+ R5 q% e H, V2 ]5 {) `% z
static int __init led_platform_init(void)
, j/ c# P B- h% j8 @; u" S{- |5 r9 O2 P2 M
int ret;
, u3 a! r5 c- ]% {; K( L1 N9 T* o#if 0& p3 O: Q8 L; V3 v/ R& _+ `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 k+ q- R1 F0 D+ B
if (ret)
8 s0 i; R8 [2 S3 y, p4 n" c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 h5 M* }0 u9 Y! ?5 E. _- I
"%d\n", ret);
/ n6 _3 L% w8 Z#endif7 z' x; X" ~5 K2 P
ret = platform_device_register(&da850_evm_tl_leds_device);
5 l' ]! u1 [' h if (ret)$ @2 d4 F0 Z6 f- X ]
pr_warning("Could not register som GPIO expander LEDS");: ]5 H- `! m8 _/ [
else
4 j. c8 N& V( v" }: s) b% X% t8 [ printk(KERN_INFO "LED register sucessful!\n");
: f8 t) [1 ? b5 r) w
5 I5 P1 ~ v0 a. `+ _+ P. u return ret;6 f. G, I! H, v
}
' s9 J6 \. [' J- ~
( r$ Y( d8 P0 B5 ` Pstatic void __exit led_platform_exit(void)
2 l9 [0 H! }* ^% R a0 G, U+ R{
# L* K, A% j; {5 C7 } platform_device_unregister(&da850_evm_tl_leds_device);
3 w6 g( X8 E/ A
: I# f6 h5 R/ g$ n printk(KERN_INFO "LED unregister!\n");& r# E+ _; m5 U( d% \9 Q- K
}
: ^9 X# k. |/ o1 @8 l
5 _2 x: c( G6 r4 O' o% \2 smodule_init(led_platform_init);
/ e/ q. j4 X; l" A+ L' g1 Wmodule_exit(led_platform_exit);
+ @# K# I! n- d" k" [% [! k7 |8 t! i0 z; M( o. ~! u2 p9 N2 |! H
MODULE_DESCRIPTION("Led platform driver");& b1 f: X; E. U3 m" O8 u
MODULE_AUTHOR("Tronlong");
3 N( O* M/ Z7 P7 ^# f, \" k2 {5 WMODULE_LICENSE("GPL");( d: V( X8 s0 B' t; J
5 X8 a* a& ~+ i* j
|
|