|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% k1 L' V2 x( ~" x) L% Z#include <linux/init.h>
3 X7 G! F3 t/ g' \- G#include <linux/module.h># E) k( p: W @6 x) [
#include <linux/kernel.h># W- k& ^) o' w
#include <linux/types.h>7 q8 [' r7 ?0 p2 u
#include <linux/gpio.h>- `$ N- K* b! v+ R8 h: p
#include <linux/leds.h>2 Y+ p; u: h8 S6 ^: a
#include <linux/platform_device.h>
6 a! W; l/ y6 S v0 z+ q" h3 q( g9 A t* z- R
#include <asm/mach-types.h>
; J# |3 v# Z8 w8 X- ^' f#include <asm/mach/arch.h>% x7 m; }9 E6 f$ {
#include <mach/da8xx.h>1 ]! ^. H8 }: e( n$ B
#include <mach/mux.h> P$ H) P9 x" O) u4 Q
" \# D( L( g M# I M+ [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 h5 e f. k9 Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) |, H$ Y8 W0 `1 R0 @0 c, o* f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# A \/ f: Y# W) }+ r. w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 t. n' `# A8 j; I- B! y! C4 N" \0 B
/* assign the tl som board LED-GPIOs*/2 F# s8 b0 I5 S9 X) l
static const short da850_evm_tl_user_led_pins[] = {; A3 h6 c' a; y0 h9 J
/* These pins are definition at <mach/mux.h> file */& \% K4 B$ k! i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, O) h6 t I O! _
-19 q4 h8 w5 y1 p4 ?
};
9 u4 ~; ^# r. c8 |
4 Q4 P- N8 [# Y. R+ H& Dstatic struct gpio_led da850_evm_tl_leds[] = {/ I1 n% ?, w+ |" [* ?; h
{8 X7 M* ~ O; K2 S( M4 T# Y
.active_low = 0,
$ ?- J) u& Z( {! F2 s0 Q .gpio = DA850_USER_LED0,8 _6 N. P5 X+ X' T% d: j
.name = "user_led0",
2 b$ j8 I1 W7 ] .default_trigger = "default-on",5 q1 f4 [2 s( ` K4 O$ L
},
8 ? Z/ H: K6 b$ W7 m {) y, R$ N9 f! I. V
.active_low = 0,4 s3 j3 X) g7 |) }6 |1 k V Y8 B
.gpio = DA850_USER_LED1,
" h: e$ ?4 U' k .name = "user_led1",
! g7 E t% U4 d .default_trigger = "default-on",+ |! r7 S! m/ T d6 @1 x2 y
},
3 L$ C0 n! v! D" _4 @$ N9 _ {& n- {; C( V( T7 T
.active_low = 0,
0 O" f. J7 x4 G: B( f7 Y- ` .gpio = DA850_USER_LED2,2 ^ t# P: z3 y# h- V* b
.name = "user_led2",( S0 R1 w- Z! t6 S) W' w& K
.default_trigger = "default-on",
/ k5 V$ J" z2 F# {: t% A },& X+ O, }9 h Y! K3 A: O) b8 K5 ~
{
# y6 [3 F/ I2 [7 ^* M' ~3 E .active_low = 0,
1 `1 w Y7 {. r6 L' H, P) M .gpio = DA850_USER_LED3,
6 {# [9 E- m! O! E+ } .name = "user_led3",
5 d5 r$ |6 w* ^. U .default_trigger = "default-on",, K( a( Q4 w+ m; b. t, N
},
6 H( g: T4 _, \/ d};2 A" m4 `& e. V) v0 e
" }1 }4 K, m$ _; W* {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. v. Q0 g. L" g+ m3 P- Q .leds = da850_evm_tl_leds,, Q, M" x9 y; \5 F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! ?6 ]+ ?6 L7 p6 \" a};) e' B# S3 s _% {8 t. `8 U$ R
+ C5 I0 @! {6 I2 ~# Pstatic void led_dev_release(struct device *dev); ?' H# X1 y+ l6 S
{. G2 O5 z( W/ J# e5 l9 [
};1 K J4 K3 w7 p1 Q0 U4 o7 `
% r" |' @2 H" _static struct platform_device da850_evm_tl_leds_device = {
9 M& F7 [; b+ P4 Q) w# Q- t( r .name = "leds-gpio",7 z' `1 S8 a, u0 ]6 H% E1 B
.id = 1,
3 u- f; y1 p# m" ~3 k2 \9 W l .dev = {$ N3 H2 I, p9 G% j* ]
.platform_data = &da850_evm_tl_leds_pdata,
0 I! I. U. J! U( l- i .release = led_dev_release,& p) ^+ W) b9 f$ x: X
}8 N( [9 i0 P3 |) g9 h! n, b
};
& {, }2 K9 R0 e, ^% @1 v7 j$ L$ T4 D3 J' p( p8 {
static int __init led_platform_init(void)
, y" {. u$ Y. @1 T% t{
* i5 Y, L' j0 l6 n* S/ n; ~ int ret;
6 j5 F' C6 [3 b9 t) X. y- v#if 0
* ]: e( T- K9 k0 _6 V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" a: w( P4 B; w3 |9 X
if (ret). v7 C0 q/ T q' }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 G8 z: e2 _- d: A* N "%d\n", ret);# |- h- F, H" m2 {2 Y
#endif
+ v, _( k7 M0 \' S ret = platform_device_register(&da850_evm_tl_leds_device);9 C' d) g& U9 _, O9 V& o) F" P
if (ret)$ V* N4 d' e. ]. I9 z5 x! |9 E/ O
pr_warning("Could not register som GPIO expander LEDS");
# ?- p) t* S1 s. \+ t* t$ r: g3 S else/ H4 G0 v: s# J6 G" v" [
printk(KERN_INFO "LED register sucessful!\n");
5 I2 E7 ~* I% W; v, m4 q$ U* C: b* b
return ret;* S) U+ v6 p& U) q
}
" ^) E, z1 s; ^/ ^$ u- |
% c4 n1 P" O I$ o( hstatic void __exit led_platform_exit(void)" f5 w' z0 p. U# R: O4 \+ ~
{; E, @- G/ F3 J" `: u
platform_device_unregister(&da850_evm_tl_leds_device);
. E i5 R6 g0 `% u+ Y. X9 O( _. \5 |/ S* X% s9 @
printk(KERN_INFO "LED unregister!\n");8 x/ w/ I; {/ ]+ Q- ^
}
3 L9 S/ d! t" D0 n! l6 A
/ R9 h- t$ M7 _) Q3 \module_init(led_platform_init);8 ]0 K: Q+ @; `" K0 ]
module_exit(led_platform_exit);
' l8 E1 V4 o- e# }5 t/ W/ @
( M5 a* l T9 P; M( ^. hMODULE_DESCRIPTION("Led platform driver");
& W6 d; |3 G% EMODULE_AUTHOR("Tronlong");
4 Y! U% M" \# G# ?8 r+ XMODULE_LICENSE("GPL");' L) z, F5 u( o9 `! v
3 y! l8 }2 l4 K; Q: U' P
|
|