|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 `' `! X& t4 Q" @) n#include <linux/init.h>
! e- R* J* ~ S# F#include <linux/module.h>
2 w) K) j( k( r0 P7 N- z6 V#include <linux/kernel.h>. r3 P, `8 @* l( ~: k
#include <linux/types.h>
6 N/ W% M% a# j#include <linux/gpio.h>) W+ h7 B" U5 D* o8 ?
#include <linux/leds.h>. V% V& f) g7 M9 c5 S6 n; H) K; g/ w
#include <linux/platform_device.h>
1 s' Q& c* m+ v. {- n3 Q
0 a3 D9 a/ N# s; [) Y* o#include <asm/mach-types.h>
& \! k9 W6 w1 m: Q#include <asm/mach/arch.h>8 Y0 j6 v8 i4 l H8 \9 [/ p
#include <mach/da8xx.h>
3 Q K( N; |* E#include <mach/mux.h>7 ?! v* ?/ k, { t$ \* T# w7 O+ G
6 N2 I% F4 j, p4 v3 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ |5 L k+ z3 o6 t+ n0 o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* F7 d% f4 }3 e& m; H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 g' J/ A6 M1 W3 Z( Z6 B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 s( ~: q3 V0 H; C; t: a5 d4 W- `$ h7 X
/* assign the tl som board LED-GPIOs*/
( d: u5 T8 [- \7 h" o: Ystatic const short da850_evm_tl_user_led_pins[] = {
) \. G. {4 p8 K0 f# ]" i /* These pins are definition at <mach/mux.h> file */
6 @$ z: @- H$ s9 p- t" B9 B- Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 L b; {7 P+ g# O4 l8 I
-1
4 |% c) q, |, c; q4 [1 G" N, w};9 ~) v( m4 M h0 v9 h
7 w, }- ?" s8 n) {1 t; G. O, F
static struct gpio_led da850_evm_tl_leds[] = {
9 ?6 G; Y' }3 e% r5 M0 h; E {
" q# Z( f2 O3 n T0 m. m .active_low = 0,$ V' q% w% T2 D1 @( }% G' h
.gpio = DA850_USER_LED0,; v% s& b# L% T# B
.name = "user_led0",
4 S* j1 c% U: ~, C# o .default_trigger = "default-on",
2 d3 M! v. E2 h( R' p" H },9 D0 w$ ]/ Y$ k3 G5 l
{$ B' K. z1 A& u
.active_low = 0,! `/ z' X" r( c r6 {
.gpio = DA850_USER_LED1,8 m! {& S+ ~( G! @0 V+ K
.name = "user_led1",4 j0 x. S3 H2 E# C! t: i
.default_trigger = "default-on",
7 ]2 T( s1 }# E: e! S4 Z/ u },
- `5 R: q2 W7 y- ~! F3 h" m& E5 S {
; e$ k) M/ u ]5 \% `2 a2 B .active_low = 0,0 I( x$ r0 ~$ s% |; T
.gpio = DA850_USER_LED2,5 z: X9 D$ o7 i+ p+ }8 A
.name = "user_led2", B& |( i% m8 M$ g
.default_trigger = "default-on", j9 f" l) Q- m% r& |2 N/ B
},
* z. `' F) E. n- _# `- n, J {
/ N i1 Q2 Z7 R) g" u# G .active_low = 0,0 M$ K6 h# S; t& x/ ~' H& o
.gpio = DA850_USER_LED3,
6 Y" H3 t. c2 p' O% s1 `' w* v .name = "user_led3",
1 W9 u& W* {5 ?) P& B. I! G: W .default_trigger = "default-on",/ j" O% l# Z) \! p6 K! V" K, E
},% H& P8 I% a4 }& |" g
};
3 d: H8 b0 A F. Q5 u' a1 C* s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! V- f" [9 k4 t% C0 s1 g8 ]
.leds = da850_evm_tl_leds,
5 S' c1 G8 j5 D9 ?8 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( ^5 M+ R6 a1 I3 r5 t* H) b, d};
0 ?* M4 u7 p0 h" d# U R. P F0 I) g Q P3 }5 ~' _
static void led_dev_release(struct device *dev)7 N. A) M! t, t( q
{$ p! ]4 [ u5 a# C/ x
};
) \$ O4 [! h* z$ l* g1 y5 \6 H5 G# M# S' @+ g
static struct platform_device da850_evm_tl_leds_device = {
/ f1 K, D4 |2 b; X# K' Z* ] .name = "leds-gpio",( Y( z7 K4 e/ w4 n1 k) n# |
.id = 1,2 k* O' W* I! w0 G% F7 A
.dev = {
: i2 d# y* i0 _. W+ T .platform_data = &da850_evm_tl_leds_pdata,* a' s" l. q3 f! [$ }
.release = led_dev_release,
5 i/ w9 D0 t! H, v. M/ y }
. _" L9 b" c4 P6 j0 j: d};
8 S/ z! g, U7 c/ {7 o3 b9 F* b! M6 V* u: r9 ~
static int __init led_platform_init(void)* U9 y- k# P& Z3 Y" P
{- M F- n3 b. v" M" G, c
int ret;% |. P9 p% g2 d, U9 H: ~' o
#if 0' r/ N/ J: t. M6 Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, P+ A( B# P3 r) I7 _5 H5 R! s. a# ? if (ret)
- ?" ~1 t( _* B" @) C: \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* @% i/ m/ V- s2 ?. b0 A' J: f
"%d\n", ret);2 ]0 J3 N6 r( p u5 r) G0 ~
#endif; J; a s! ]' f! o4 H/ f0 e% D8 I
ret = platform_device_register(&da850_evm_tl_leds_device);
- o4 I% v, W$ Z. ^) }/ `1 D if (ret)
]; S0 ?/ S% M" E0 [" i# s3 c pr_warning("Could not register som GPIO expander LEDS");
* M' }# g3 ?2 a4 Q. k( ` else
/ _& F/ ]! {. ^' B( [ L0 P printk(KERN_INFO "LED register sucessful!\n");* W2 j% l* j4 L! k d
' K8 s! d) C3 q
return ret;3 G! H. r7 X( u# R
}
+ r b- W3 |, j4 _% Y, A8 Z- Z" ?9 K
static void __exit led_platform_exit(void)/ {% w- s$ Z1 ?! b
{( y1 E# F% W4 p, L- S
platform_device_unregister(&da850_evm_tl_leds_device);: {) p$ G( J; \9 a7 T0 L' F; e
; U c; `5 |, _/ ]1 E9 x# _ printk(KERN_INFO "LED unregister!\n");
* r9 ^- _1 s( u2 M- t: S}9 _+ {! W; o: s/ o( d" I7 l, k
& R0 ]* I6 o% e& Lmodule_init(led_platform_init);
( j3 N& t r( N# M" Vmodule_exit(led_platform_exit);; ~' W6 Y; S: v3 x8 q
# Q" o: k' t. L0 l5 D! H8 D
MODULE_DESCRIPTION("Led platform driver");$ P9 P8 }" K" |7 z# s: R, N
MODULE_AUTHOR("Tronlong");$ A6 ]6 w( }! }8 x" C) h" D, _* R1 P
MODULE_LICENSE("GPL");8 }9 V& `: Q! v2 \, f! q
. |9 E* S/ E; O m, { b Z# y |
|