|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 A9 v, a p! p2 C6 @' w& U8 m#include <linux/init.h>
5 W7 q; C; N, \! ?2 c#include <linux/module.h>
8 J: x6 ?/ G) ]# H E0 y2 ]#include <linux/kernel.h>8 n1 s9 g- w8 Q; F5 ^ @
#include <linux/types.h>
7 ? r" q5 ]# j" d$ |' e#include <linux/gpio.h>
; ` J# L: X" f8 R3 Q* {( F#include <linux/leds.h>1 a2 h3 g9 \, @4 L) U2 Y* G
#include <linux/platform_device.h>
7 W- ^5 M% @5 p' k+ `1 z+ @' p2 O5 w) _/ d& ?
#include <asm/mach-types.h>$ Q; R3 P2 n. M3 {
#include <asm/mach/arch.h>
: W ~2 |5 C0 G& c+ ^#include <mach/da8xx.h>, o% I. a+ A9 M* W5 ]$ W
#include <mach/mux.h>2 ^- E5 W- t- n/ q0 I ~# x- W% j
7 s3 i: a6 s2 U9 u1 e3 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 N$ h9 V {9 S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 Q# j0 ]: L: A: D! P2 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( x, g% t% t- ~4 A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ x! p% c/ g* r8 Y! E
& ?/ \# i* y( b M
/* assign the tl som board LED-GPIOs*/
; c+ S. L' l ^" vstatic const short da850_evm_tl_user_led_pins[] = {
2 ^! x7 `% I/ U( f /* These pins are definition at <mach/mux.h> file */
, V3 x) X$ u9 G3 d. S1 y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 V2 {' N( M) u$ G
-1
2 q6 d1 h3 \. L& c};
) k; T" o7 B& v8 k9 U/ ]' x" b& E7 Y) o; k6 u2 o( A+ `
static struct gpio_led da850_evm_tl_leds[] = {1 v% i+ p; B6 ?9 F; ^. T
{3 v# z+ I5 I( v; a
.active_low = 0,
; ^6 m- v) b6 n0 e .gpio = DA850_USER_LED0,$ {) g& _) R* F& s! Y
.name = "user_led0",% Z4 q8 Q$ c U+ \0 B
.default_trigger = "default-on",: U' P% J! _2 ^" F* W+ S7 ]6 l8 E2 w
},
/ Y8 E" `: A8 j& g* j {- a- c4 O3 J2 _5 H
.active_low = 0,; L1 [- a) s- e; d9 n
.gpio = DA850_USER_LED1,
7 I L$ S; h2 q9 ?* G; U5 G .name = "user_led1",* K7 y& N% d! j* c7 {+ t
.default_trigger = "default-on",
4 ?. N* M) z& \7 {: H },
, j: w) T1 @1 ?3 A3 j2 \6 i$ a3 r. U { A/ N5 S3 b8 O Q9 C- |/ ?+ ^9 B
.active_low = 0,7 M: ^+ V2 f3 l! ^3 K+ _2 t
.gpio = DA850_USER_LED2,: a# J! D! e& T' h- r9 K9 ?! Z
.name = "user_led2",
/ ^6 h, p: z: N, o" N- U; D .default_trigger = "default-on",7 E1 |. }4 Z7 I; A3 j z. Y6 j+ y
},
4 H% h: }. n: b$ w {
% t% H6 Z; u) g6 X# Q .active_low = 0,
; `, r" E; H$ H. a' _2 x .gpio = DA850_USER_LED3, m" V, k: X* n7 a- M0 z
.name = "user_led3",
0 A5 d) o1 T3 {2 t2 q .default_trigger = "default-on",
/ w, T, b; \* g },
W3 x) F" l9 i};4 d7 Q% I8 c3 j: |7 j$ \
/ i$ h6 K: c8 |: Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ R- i: U1 t, r- ~ .leds = da850_evm_tl_leds,
5 H' l" X" x! {" x$ A6 K* j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 \( b4 l& L( m
};
- N& V# n* U x4 @& `- o. ^
/ ^. R2 o4 ^5 o* M( `9 bstatic void led_dev_release(struct device *dev)
2 `% b5 j$ [+ j3 V3 i- z0 z{2 H5 m7 K. [% }) I0 N1 f/ q
};/ h; j0 H$ e7 w
- m2 P% r; [% G# `2 O# r$ T0 \9 S1 J
static struct platform_device da850_evm_tl_leds_device = {
' b) B1 Q3 b/ k .name = "leds-gpio",
9 ?. k3 y" ?: W3 Z7 K .id = 1,$ B; B9 z D; D. }0 [. b- {5 x
.dev = {9 G8 N7 r, R% e
.platform_data = &da850_evm_tl_leds_pdata," q7 N" e$ b" @' K4 W+ i
.release = led_dev_release,
+ b1 K4 B8 U' c2 @# ~0 f! G# C( r }
' l3 _+ `: e% |5 b- j- x/ p};3 o+ r7 V4 W0 N
* R I; k+ ~4 D# X
static int __init led_platform_init(void)
, g {( B! c7 k$ R' J{
# z0 o2 e- i$ w int ret;# _/ D7 U. x: @; @" {# q( Y
#if 0. I2 f. u3 u7 l1 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! k& A0 z/ K1 A; m7 { if (ret)
) ]% B3 p5 S) u% e7 ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* L. D# G* R; F
"%d\n", ret);
* ^; V F& d6 P$ |* ]$ c#endif% k; T* x. \' X& C
ret = platform_device_register(&da850_evm_tl_leds_device);
+ v8 t) c* r7 i* I7 g1 q if (ret)
' r& i W, J q! @2 U' X1 ^: w pr_warning("Could not register som GPIO expander LEDS");
- b: J8 `7 A7 [& M4 N else
9 {' |$ r d. g* K% L: Q9 C/ R printk(KERN_INFO "LED register sucessful!\n");2 {' ]1 x1 u9 o+ A' u7 b
1 B, P, T& z l% c- i return ret;4 r5 [; R. M( X$ F3 ?2 }
}
. k& l# L* `) D4 t* i& i4 q
8 Q, R- Y1 F# X% W8 n" a: I9 [static void __exit led_platform_exit(void)
. L1 P( _6 ]$ `{
4 `! J* e) R/ B; Z platform_device_unregister(&da850_evm_tl_leds_device);
) {- X" G: Z# z8 a v" O* y" w* M
1 s3 S) ^" k- A. c* ]) g# ? printk(KERN_INFO "LED unregister!\n");
* \; t3 M: v6 |/ s( q5 g3 W3 D: Y}* v; R1 ~3 { s6 a9 G$ l7 ~# g
' j2 p4 \8 k! r
module_init(led_platform_init);
, A9 n2 t% J7 [1 x5 _module_exit(led_platform_exit);) s0 e( B0 N3 {! ]( Q: t4 S( {# m* P
8 Y4 U8 J. B% N7 G( z; s
MODULE_DESCRIPTION("Led platform driver"); K6 f7 N Q$ D* F
MODULE_AUTHOR("Tronlong");
) v- ~2 P1 b' J" u1 x& E. ?4 p+ bMODULE_LICENSE("GPL");& ?/ B, {$ i( p$ O0 m1 J3 A5 l
1 M$ x8 u& J4 r; m; w8 J) Q/ B |
|