|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' z) `+ ?4 A( V7 c) Y
#include <linux/init.h>3 d) A% O/ u& |/ E" n2 ?
#include <linux/module.h>
( y( u6 O5 W! | H, a7 g#include <linux/kernel.h>
5 F; \- _3 c9 V1 ?" R& ?#include <linux/types.h>- S l l) ?( P1 _
#include <linux/gpio.h>3 F( e2 y# S0 n7 j+ s" i' O% \" f7 h! n
#include <linux/leds.h>
8 m8 w8 [% ~7 N#include <linux/platform_device.h>
& t. g; C) a3 l5 ~4 v$ b- o' ~' P. L# r$ W* C. V
#include <asm/mach-types.h>
: w+ E$ a5 b& A( x#include <asm/mach/arch.h>8 g; H. Y: J1 V' s1 h. ~# Z" q/ I
#include <mach/da8xx.h>: d5 v% H1 P! Z) y& ~. r' j
#include <mach/mux.h>$ i+ X- V" v" Y
9 v: u) @" b! X2 Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& p9 f: P3 e# U6 W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; j8 H3 j% K7 W4 k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 G4 L# [# W- X& Q2 }. E* V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 J+ o3 _7 |" d/ b1 m- C
# a. ^' ]' \7 N
/* assign the tl som board LED-GPIOs*/, b7 J- V0 D* ~% R" C3 i) f
static const short da850_evm_tl_user_led_pins[] = {
" D) a1 ]6 Z8 \ d6 y /* These pins are definition at <mach/mux.h> file *// S& b; ]) F: M; f9 a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ V2 y) L0 Z; \! A) f P
-15 [ E7 |" n5 i; _
};! j6 m6 N2 ?+ n: y
) k" c* a0 G0 ~& y/ a9 z
static struct gpio_led da850_evm_tl_leds[] = {
& f$ S2 {/ m( H3 w4 q8 Z {3 [7 V# p3 E# i/ |# m# [
.active_low = 0,
* Q# i- x' A: }1 o; V3 p& v: D. u .gpio = DA850_USER_LED0,
% f+ ^! d+ ] o. K( \ .name = "user_led0",+ ^3 K1 }& K; p, h1 G* E
.default_trigger = "default-on",! ]$ p7 W7 s( _0 R t& N$ Y
},: O P8 J& G# T2 O) X
{
& C' d. P- N( y7 j0 A H9 e .active_low = 0,
1 d6 J. `$ { d7 Z- t .gpio = DA850_USER_LED1,
6 N0 T5 ^ S3 `. \; Q: S .name = "user_led1",
% ~% L3 s* Q; k' z/ g .default_trigger = "default-on"," H$ J5 y+ Z0 w* d, z
},# Z. z0 w3 Y$ }
{& N. _8 v4 g- f. A* ~- ~( a, Q6 T
.active_low = 0,- h6 R( c9 m6 t! {
.gpio = DA850_USER_LED2,: y* f! }2 S: s: v
.name = "user_led2",
' H( ^" o$ s g* g .default_trigger = "default-on",
. t, {" U0 Z9 w },' z# J) u- `2 R) p& O" |
{1 E- s* ]# Q! S. Q
.active_low = 0,
" c4 O$ C" j+ A, w .gpio = DA850_USER_LED3,
$ ?. m( P5 h+ m8 E k: w/ _. u .name = "user_led3",9 l1 S' \* w0 r' q( Y+ q
.default_trigger = "default-on",( @( N+ y# ~) I4 N% b& [( O
},% q5 }: y% y) R' R" d' R w2 N
};
0 @' @- c9 A, ~2 l6 \# d6 h4 o6 ?4 h# @- h( h, E& ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* R0 r: h- |7 P8 t0 z9 r
.leds = da850_evm_tl_leds,
+ O, {3 N9 z# e+ T( O$ U: M! | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' h @) G) T7 q3 ?};* Q1 L: D, a) _( h
2 j e# W2 K8 l) s7 C* _; {static void led_dev_release(struct device *dev)2 M- g8 Q% I2 M* Y. d9 [! C
{
* u$ Q- d7 o+ ]8 ~}; H- J1 Q8 V- m3 C
8 [( j& a& f* y: b7 C& e
static struct platform_device da850_evm_tl_leds_device = {1 ]- ]2 b' S& h
.name = "leds-gpio",$ V1 X V3 J4 @- n. Q0 P8 w+ X6 B0 @& s
.id = 1,
/ @8 v% B8 b9 t .dev = {
9 \6 `/ `7 v8 p. t% K* {! j9 C .platform_data = &da850_evm_tl_leds_pdata,% ?3 [5 n% |3 y! W% a! c
.release = led_dev_release,. D* d0 g0 p& y& W2 t
}
5 |4 f; f# b& ?5 w% S( x9 d};) L$ g0 Q; ]+ ~% D# H
8 H0 y; R, {! U% l) x0 Z
static int __init led_platform_init(void)
; k( {9 z2 `8 U3 E! f" L1 l. j{- Y# D" `% w7 e" M8 f- C
int ret;! M( D" @9 X" r0 a( m; Q. c
#if 0
: Q) U- b2 J6 E0 J3 f: [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 `% ?; O0 Q- j) I' K if (ret)
i* V2 ?/ X' | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* W! w u% K9 i; [1 q; O, R q" c
"%d\n", ret);
h* w, d( i c0 m, ~#endif
/ L m" l: U* P3 a' V; |! B ret = platform_device_register(&da850_evm_tl_leds_device);* j/ H0 h5 z2 U. ]# ~
if (ret)5 T! `$ f( q' O4 p) ?
pr_warning("Could not register som GPIO expander LEDS"); k6 q7 H5 j- k2 j5 G* o
else! _* r1 n- u5 k! n; s9 |8 D: Q
printk(KERN_INFO "LED register sucessful!\n");
. \% l7 R0 T! V% N) @, S, p/ _* ]; d) X) R
return ret;* M6 F# P8 c9 U& p: o: P) e
}
6 F5 _! v: O4 w' B: X7 w
. g! L8 l( d- xstatic void __exit led_platform_exit(void)
' \; s. Q" n' B2 c( _: H! U4 R{
$ A+ B# [' {9 T* |1 S$ S% t platform_device_unregister(&da850_evm_tl_leds_device);2 w5 `+ L: f1 K
8 e) ?2 I# O. @: N
printk(KERN_INFO "LED unregister!\n");) v, G9 Q7 J5 F: z
}! O* z% k ~8 W x$ _ H. U2 k+ Z
( r+ X- A* U0 |: G8 M5 _" Q0 }# j! \ Y
module_init(led_platform_init);
% [( ~) _9 n/ B: dmodule_exit(led_platform_exit);. z( n( d0 p9 f5 O6 @# A
, o( v' \' K: T& e& eMODULE_DESCRIPTION("Led platform driver");# R+ }, H* `5 j5 w
MODULE_AUTHOR("Tronlong");
- d0 S5 `' e9 s8 b, cMODULE_LICENSE("GPL");
8 N! w; P, T* o0 P2 C$ a; D5 W0 I% A2 y+ e, Q2 [
|
|