|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* X/ W! Q% g( W
#include <linux/init.h>
1 O% g$ P. P w/ D" }" l" N#include <linux/module.h>' f- Y3 a$ J3 Y6 {! k* I
#include <linux/kernel.h>
- t9 J7 N* N2 e' S7 z8 d#include <linux/types.h>
, |# S8 }% [: y0 D#include <linux/gpio.h>+ i7 ~4 U* z4 K+ F/ u
#include <linux/leds.h>
( G$ i) R5 }8 y#include <linux/platform_device.h>
) x7 S0 G* X' w1 n0 Z" S: I1 W9 q( _# i( N, H
#include <asm/mach-types.h>9 }: V, [! M, X% h; G( H
#include <asm/mach/arch.h>" B% h+ V* w+ X) B1 e7 G
#include <mach/da8xx.h>
2 l d( r1 I% `#include <mach/mux.h>3 [' n/ y) k2 {) \: x3 y; w. D& E
2 |0 y- _, h" F$ D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% z" O* P0 J4 H) a& ^1 f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' w* Y2 A) S8 l0 Z% {0 A* d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ i2 F* d) U: ?7 X1 A; } _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! ]+ W7 V. W( u3 u5 Y6 n$ e
& @8 h+ V2 U2 @$ P9 z- B
/* assign the tl som board LED-GPIOs*/
4 X- X! Z7 h: S, hstatic const short da850_evm_tl_user_led_pins[] = {& U' ]( \! ?' P
/* These pins are definition at <mach/mux.h> file */
9 x; h) Y/ @% Y# K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 H# {8 x/ L1 O% Z. B5 F! `* W
-12 I6 S! [$ T$ N
};+ ]; r O5 d$ s7 A% s2 E8 c! Q* b
}* _! U' U2 Y! c) J" tstatic struct gpio_led da850_evm_tl_leds[] = {7 z. x7 I2 U' t3 |- r, S: Z
{' I3 I2 ?* R4 Z
.active_low = 0,
( w# K/ z5 G3 m9 O: { .gpio = DA850_USER_LED0,
$ \) [2 c" f- {) h- P; b U$ I .name = "user_led0",1 u; B W" E" R9 k9 j* [, h
.default_trigger = "default-on",: F7 D8 B% D1 F8 m
},1 m+ c/ v2 R/ s3 m2 |6 n/ N0 w
{
) F3 x E% u( I9 C! Y7 S$ r) ` .active_low = 0,5 i1 G8 o; D ]% |
.gpio = DA850_USER_LED1,
6 ]8 f/ ^$ y5 ]4 B% I% X9 o .name = "user_led1",% z' a8 a; b K1 x) i# _; f
.default_trigger = "default-on",
& \; ]% S& X$ Z2 _2 o },) i/ i5 J" j. S; X0 _6 l# r5 n: `
{; e- m8 ^9 ^4 @7 C/ z% l
.active_low = 0,0 i$ u, E, ]. P. {" e( E. w
.gpio = DA850_USER_LED2,
& l, z" B2 y k7 D& \ .name = "user_led2",
2 h- B5 |5 u% P .default_trigger = "default-on",
# `* {: x: A U7 N V },
3 O( U3 w" H, l" B3 }# f {* R* {2 y# C7 G
.active_low = 0,
& z" X; Z4 }! M2 u* |. b .gpio = DA850_USER_LED3,
% ^' e4 F2 U6 A; A/ h( X .name = "user_led3",1 j+ x) e2 }! p" {
.default_trigger = "default-on",$ G- ^ |& c( m; S8 Y7 c3 @, _8 g
},: f7 u0 k- D' B
};! M; ?% i+ I$ A* d8 n" ?
& q3 F1 G+ p% t, A5 B9 f" cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, \2 X3 e* N' S6 K k .leds = da850_evm_tl_leds,; j( S+ N1 m+ \6 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! E& ^5 A5 @2 g+ O2 O% n6 Y
};) c7 Z$ n0 k+ }
# U- n2 R$ ^7 Z# X# d6 \static void led_dev_release(struct device *dev)" N) H) C0 x6 o1 ?* W# I
{. P, ~1 Q4 z4 k9 X2 p& E
};; |3 r6 Q1 k7 x$ G& V( u, m
5 p+ J; t1 i4 xstatic struct platform_device da850_evm_tl_leds_device = {! a% p0 F7 P; @) A
.name = "leds-gpio",0 S3 P: p; o* ~' O# x3 \. d
.id = 1,
2 Z; P: W6 M; `" g* _: s5 A .dev = {9 ?& Y5 G* k; x+ a2 N; u
.platform_data = &da850_evm_tl_leds_pdata,8 x9 ]# F# G; z/ \$ _. X
.release = led_dev_release,
7 G: p: q+ }% P1 W& {1 m) l }4 z4 M$ l* \& [3 n1 g
};) t, ?2 I5 ?$ D6 K( h
/ I5 q4 ]! |! N; ~4 t* K9 n/ r
static int __init led_platform_init(void), F @2 W' }4 X W. m* {
{6 N: c' [) o. \* H( p$ K1 S
int ret;
7 n i" r* S# O( j: W+ j#if 0
5 U' H* }: g5 H6 i& P# P; u# H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) r. j+ c5 z: P8 K _
if (ret)1 n5 ^5 H7 i% C; S8 W% s4 n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# N7 I5 f$ w2 z* H8 i
"%d\n", ret);) j9 I* U. K, E' g; y& J9 w
#endif
* f& E _% U* y& ?* x1 _% t ret = platform_device_register(&da850_evm_tl_leds_device);7 T) O; m7 k& V( U3 W% {* m
if (ret)6 |4 K% @8 z- z' @0 R- ~
pr_warning("Could not register som GPIO expander LEDS");1 r& j! a/ y: Q# y: }! R2 }
else
V/ Q& t3 C7 N" |( y printk(KERN_INFO "LED register sucessful!\n");. t2 |% P; i$ D( u: H% G2 j5 m
6 U5 c# [$ v( T9 v3 N) t0 w y, n return ret;
6 u7 Z7 J: U6 Y! o& n}; V# i% R f1 z0 m5 C/ d+ \
8 H8 x( z- F/ z7 jstatic void __exit led_platform_exit(void)
/ Q7 i8 H" J8 _' @. D8 U) @{+ p2 N2 ~& o* o& w6 p
platform_device_unregister(&da850_evm_tl_leds_device);
: u, y* e- e+ o |# d: m5 b) [
" m9 v+ ~( e5 @: d printk(KERN_INFO "LED unregister!\n");
+ D1 W2 O6 l' ^2 z5 c$ R}
# U$ z9 }, S' I5 Z' E0 F. D% q% J# \; R# r q+ s% {
module_init(led_platform_init);
- j# U0 Q. y3 { @. _, [: nmodule_exit(led_platform_exit);
# x6 n& F/ F0 g/ J3 E; _ c4 v2 R9 w# Y
MODULE_DESCRIPTION("Led platform driver");
; r% g, S; F, |# X: L& MMODULE_AUTHOR("Tronlong");8 c& X' Z5 _, T( q0 n1 q/ |, a
MODULE_LICENSE("GPL");
& t% `9 Q* [4 ]5 a, o! \/ N
d- w0 D3 m& u% E$ C- a- U |
|