|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ r, R- y& D- t/ ^* @#include <linux/init.h>, [! J) u# \0 k" u* h9 O0 U/ s
#include <linux/module.h>
2 A' O8 P! F+ ?* a' f#include <linux/kernel.h>: D) T) K8 b1 F
#include <linux/types.h>3 \; L# O8 j0 J$ K+ b$ M. n7 p! c
#include <linux/gpio.h>' T: t3 B3 R6 f6 m$ L7 [
#include <linux/leds.h>$ o0 S6 b( v [" Y3 l
#include <linux/platform_device.h>2 }1 r& R" r1 z6 o. L' {6 K
! H! D# W1 i. d- a# L3 v8 \
#include <asm/mach-types.h>
9 w1 y+ C: k: x2 U. a#include <asm/mach/arch.h>
- O" S6 q/ V6 L4 L; K7 c0 G* {' m#include <mach/da8xx.h>3 q! I! l& u# M
#include <mach/mux.h>9 y; q& t6 ]3 n* L5 b3 {
( C( m! O# { R; B; x$ D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) |! Y: K( Y" ?+ |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ B8 L8 I, I6 H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). _# I9 U7 u3 A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 g% y: T% n D/ B O; V* K% `: s6 m/ r# J' C2 ^" T+ q7 `+ \) M
/* assign the tl som board LED-GPIOs*/
% c, ^) H6 T) E- `8 Nstatic const short da850_evm_tl_user_led_pins[] = {, y8 S; |8 Z% R0 T( u% J8 n
/* These pins are definition at <mach/mux.h> file */: W" C7 U& ~5 i7 v4 T, Y- L. f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 [' s P; J2 s9 |% t! g& g -18 N8 G" G1 @* |1 s
};) p+ H3 [: o( C) |4 o2 D
0 W9 P) K8 u% g2 f
static struct gpio_led da850_evm_tl_leds[] = {5 J8 J4 q' L0 a
{* E9 b( J' H3 |, x& D6 l4 b
.active_low = 0,
; D) f0 |1 p$ H( H$ h# X Z .gpio = DA850_USER_LED0,
: D5 L, g9 Q/ K .name = "user_led0",3 S. G% l; v' A- A/ g0 h2 x! J
.default_trigger = "default-on",# X0 z# [6 n% G$ d0 C3 t
},
: x* v% I, i3 t! k0 Y. ~) F4 r) M {% w a! l) }% r7 R
.active_low = 0,1 Z+ d0 }# B/ w8 |8 q; b
.gpio = DA850_USER_LED1,
" P6 b- U7 I$ S' H/ u .name = "user_led1",( k& t/ H/ Q& O8 E! H
.default_trigger = "default-on",
( [/ `! ]6 k$ I* I6 z2 t" ` },4 r) e- K4 w% K' i/ W/ F) R2 z+ R
{
! u! V& s7 e3 q3 n3 ]3 ^! D4 E .active_low = 0,
( d* s- W7 `1 [ .gpio = DA850_USER_LED2,+ S- Z* _8 A: f e1 }
.name = "user_led2",
# Q% L* b, |, R2 |2 L .default_trigger = "default-on",2 K H$ z D) a2 g
},
- @2 }3 a8 n$ c# @ w3 @) | {
1 l' l) a9 O/ I: f .active_low = 0,8 N, t5 `; Q# c
.gpio = DA850_USER_LED3,
9 Z0 V- o" T* T; P; s .name = "user_led3",9 o3 D5 e. j2 K, j5 D5 A% y* F
.default_trigger = "default-on",% R- ]6 p- Z3 V/ U* N3 \
},' t6 Z2 W% q. x! |
};* O5 l- X2 w4 i; v9 S# q$ w
- X0 W" l$ X" \2 b" V+ D& E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: i. r6 [# ~2 P7 C( K9 y( l U3 H .leds = da850_evm_tl_leds,
9 w/ r. x+ i x/ H# K% K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 X7 `" R+ S; a; X. L& ?' k};
, X- @/ q0 I& o: o0 U) A
0 w3 Z* N9 L3 W8 \3 S; G7 Bstatic void led_dev_release(struct device *dev)
, F; A3 ]( x7 J{
y5 s! }4 M9 A# w0 ]};
- e; S- n$ r+ \( a6 O" f3 f) k; h' n6 N1 T9 a: K
static struct platform_device da850_evm_tl_leds_device = {- Z q+ c( E! c; ?6 q: K
.name = "leds-gpio",
7 X9 N! K5 v4 f1 F .id = 1,' g* m& x0 w) C
.dev = {% `/ a5 H& R U2 `4 D
.platform_data = &da850_evm_tl_leds_pdata,8 m6 A9 l0 J; V0 ]6 e& e
.release = led_dev_release,9 ?) L' U! j& {. V' T: t
}
; u4 e) w2 y9 Q; y1 J};
0 u! ~7 b2 I/ z
/ E) t' ~/ v2 A8 A- J1 e/ Astatic int __init led_platform_init(void)& r# |+ h# p$ f
{# M1 F6 b0 F8 t6 J1 h
int ret;
# ?; b) B+ w9 b* F8 J9 @#if 0% v; I+ _% f: }6 z3 B6 u1 [' l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& ~( K* L6 k ~* C: y if (ret)% N* {. r6 M: G" l- b" ?0 j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 J A4 k B7 Z
"%d\n", ret); s. f$ s# q2 s- U
#endif0 p1 \- b. p, q6 h: j
ret = platform_device_register(&da850_evm_tl_leds_device);( K3 U/ G7 m& E( Y3 ]
if (ret)
+ u0 x4 Z9 |+ L1 U. @ pr_warning("Could not register som GPIO expander LEDS");& |! a- ^: q! c2 ?
else( e7 g1 N c9 b) e" ^
printk(KERN_INFO "LED register sucessful!\n");! Y. ?( s2 j) {6 E! h+ b; h0 t2 A
* P2 p t9 x9 r: a, P% E
return ret;
8 F, F( v# L. R# @}7 f7 \4 c$ H! m+ Z( j- W
( e- c+ V2 w* e) F5 i1 Rstatic void __exit led_platform_exit(void)
1 C; B6 J7 e! |! H{8 D" |6 _2 t3 k
platform_device_unregister(&da850_evm_tl_leds_device);* \& r/ H! a5 f. H
6 |/ G% R( ~& }# s5 f printk(KERN_INFO "LED unregister!\n");2 X5 |: P! n5 m# J% R
}1 h, i0 K6 B: ~
0 m' l ~; o" k8 `" j5 s. O0 Rmodule_init(led_platform_init);
( n- c/ k) {4 I3 l% pmodule_exit(led_platform_exit);
9 K, _7 \/ @2 y2 r( B
8 }- Q- a0 e e4 F$ A: [8 J5 e. `' FMODULE_DESCRIPTION("Led platform driver");
' T* v4 S2 y0 j, `8 C, j: H3 wMODULE_AUTHOR("Tronlong");5 P+ P+ R4 L! J5 H$ s6 L! y
MODULE_LICENSE("GPL");
( i7 c2 [* J, n0 e9 E A
1 {$ c: F$ a, T( M+ o* | |
|