|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& G# M+ |- d4 ^+ | B
#include <linux/init.h>
3 v- L, h- r% s1 H9 q8 @5 P& {#include <linux/module.h>$ M+ U4 {/ v5 ? J- c+ @/ I F
#include <linux/kernel.h>5 q# c# x& C! ^1 z! |
#include <linux/types.h>
! B9 W% s6 t1 R; E" j#include <linux/gpio.h>& A& J# n+ ^# p* H' \0 m0 ]
#include <linux/leds.h>! Q2 h S3 \ A
#include <linux/platform_device.h>
; ^7 ~5 U! j6 C3 o$ g: ]1 s0 s$ W! z
#include <asm/mach-types.h>( o. i6 s# y' }) L
#include <asm/mach/arch.h>5 W+ K4 W6 f# z
#include <mach/da8xx.h>
/ v2 V: K/ X* ^7 M$ r% H9 N#include <mach/mux.h>+ b/ x, R8 t c5 D
, w2 v+ H5 l& ~2 E6 o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: e$ B# F/ o3 W+ Q! ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 |) U' D0 w/ N4 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 o6 I9 Z8 X$ Z, l i, y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* J$ u. A: S; h# V# ]
# F+ a' T) \1 Y Y. x/* assign the tl som board LED-GPIOs*/
& x5 `: p: l5 v7 l1 A: ^# dstatic const short da850_evm_tl_user_led_pins[] = {
2 |6 _ `, e6 e5 G2 y$ Q# s /* These pins are definition at <mach/mux.h> file */3 h9 I2 P0 ^' @3 A5 b# P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 d6 W7 g7 @+ M0 q" c1 p. |5 a% ^
-10 `" D" n" V- D- c9 X0 g4 s$ a3 Y
};
6 w8 G6 F1 [: p9 Y/ E# ]
7 n' d% I& O; h( x. x) p" Xstatic struct gpio_led da850_evm_tl_leds[] = {
( @5 G( F1 J7 Q6 y% g5 k8 t {
1 k2 O1 Y5 E) _8 r5 G* ]4 J2 F .active_low = 0,
! ?% A7 k: r: i5 _ .gpio = DA850_USER_LED0,
7 w, K& V5 q- G .name = "user_led0",
3 y) b. F3 r8 l3 ?# s& C .default_trigger = "default-on",/ s1 X' R- U" T n
},; _# l/ Q, }9 A# r, L1 A- s1 @5 t
{
; v. w- r6 M5 X! h* W; ] .active_low = 0,
8 |! h2 t( Z: I9 M .gpio = DA850_USER_LED1,
" u' p8 @& [' R5 F .name = "user_led1",$ l$ X. ^, q+ Q, v* x9 H) ^
.default_trigger = "default-on"," z7 y( h# j7 R. D: ]8 b) ^
},
0 d0 M' H/ Y, {2 X {
; z- t# {3 K; q3 q+ K .active_low = 0,' a$ S4 ?3 j1 X G( I9 f
.gpio = DA850_USER_LED2,, u7 |* z9 v4 [: G) k: D
.name = "user_led2",8 ?# p! W! n1 Z8 T- L* b
.default_trigger = "default-on",
3 T1 F7 ]5 A; ^: T4 f },
8 K$ O4 s( ~ s. a4 n: q {6 s1 ?" N) m6 {8 G1 j& M
.active_low = 0,# I+ n1 S; C1 o! S+ [6 R$ H7 M& q
.gpio = DA850_USER_LED3,
. p- R4 a. H# x6 w# b! Z7 W. S .name = "user_led3",9 Y5 P2 i3 |: ^ c+ j. F
.default_trigger = "default-on",
5 r+ x, ~! N6 s2 U4 l- r },
* n' _3 J+ Y8 }* F* G2 z+ t};
7 P0 w( s7 P u) G" K b3 s
2 o5 N! r' x Q6 W& H) xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { R f( A2 d- H% F% c! n
.leds = da850_evm_tl_leds,$ \* p7 `) X; f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 o; F* z" p3 K$ t% m# P
};0 @. t, z( x& f( Z# k6 _
0 W+ u E. R, B& u! n! a- Lstatic void led_dev_release(struct device *dev)
, p+ ?0 q, [2 \( z4 F( j{ S; S/ ^: L' s
};; a0 i7 i& \0 a5 H
/ d h$ X/ x4 E7 X4 Wstatic struct platform_device da850_evm_tl_leds_device = {0 g" u% ~7 [7 q N$ C6 B
.name = "leds-gpio",
1 ?- D F# P( L _" y, R .id = 1,
% ~6 U' N6 D2 f2 f, Y .dev = { n/ L8 T E4 M- P4 s* S
.platform_data = &da850_evm_tl_leds_pdata,4 t1 J% G6 k" n2 ?4 Z. b9 U5 [# A4 F
.release = led_dev_release,5 `2 e# _9 p, b/ R
}# ?6 b- U( {6 @+ N4 S/ a
};' ~3 p6 Z9 S$ N7 W
1 c2 o# j& q% O/ n% Tstatic int __init led_platform_init(void)
0 e" H h" w& `2 K3 R# j7 J{, s" ^8 M, K" C7 r; ], G
int ret;1 l: Y! d- R" W
#if 05 Z4 L. {/ I8 q# C7 p2 q1 A! d) R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); a1 U) O6 B2 ]( V, }9 a! M
if (ret)% l1 I' x, n/ O4 R e7 F$ n$ B$ j; a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ m2 n- \2 A8 h5 z "%d\n", ret);
6 b" }% O0 q. U9 H. P* ^. v$ L. y+ F#endif5 T1 L+ o! b5 X
ret = platform_device_register(&da850_evm_tl_leds_device);8 ^9 U, A1 G1 E0 l. `% c
if (ret), r, C2 i z7 l' U$ P) r+ Q: \
pr_warning("Could not register som GPIO expander LEDS");
; o. ~# h" e8 A* h% y else
# y2 C- w5 A4 Y' c/ l8 u printk(KERN_INFO "LED register sucessful!\n");
! q/ w) _1 s" |' S, b) v
% p, D; f H5 r# y: R* d return ret;
: A* @$ r$ G+ `}
9 c9 n! g' e* O& ?
9 ^* o$ V: {/ z: Mstatic void __exit led_platform_exit(void)
5 p) q' l# x. A{" w4 I) q4 c; U. F0 e/ [
platform_device_unregister(&da850_evm_tl_leds_device);- J& L) a) g( g* O3 @) u8 C5 n
7 r9 X& T% p& \3 m4 e* a# S; }
printk(KERN_INFO "LED unregister!\n");
4 j. U3 ~- w3 R" b/ c}
6 N/ \3 K, E; d! U1 F/ |8 D9 Z% Q( W$ @6 `
module_init(led_platform_init);0 ?. Z' c/ q: f
module_exit(led_platform_exit);' j8 {; Z/ _* o/ z
. U% A2 n& B, l
MODULE_DESCRIPTION("Led platform driver");! y0 `+ w% ~5 P; B
MODULE_AUTHOR("Tronlong");
: I# H6 y# w* ^# j* KMODULE_LICENSE("GPL");, |! R# B6 C4 K% n% t& j
5 f6 p# R9 W% @ z |
|