|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 ]7 o/ s! l# v8 }+ K- L
#include <linux/init.h> W1 r& d% v1 Q0 Z0 } h
#include <linux/module.h>
- O; L; j" s" D1 Z- ?#include <linux/kernel.h>
. C/ @, Z6 ^, f1 T; y( c( i% e5 P#include <linux/types.h>
" i. e: E5 \! M* U3 a#include <linux/gpio.h>, A, w+ Z0 y/ M6 [# t
#include <linux/leds.h>
3 k+ ~5 q2 @0 M2 l: h#include <linux/platform_device.h>
+ J& X( r# m$ C M) A
# C W! \& I1 y$ U5 K3 @#include <asm/mach-types.h>
$ {+ r; ]1 W. U! Y+ s: T7 `8 n( t$ z#include <asm/mach/arch.h>) D7 [$ O" D6 B
#include <mach/da8xx.h>
5 ~! Y V6 x- g! c7 c( [6 `% ]) h2 r#include <mach/mux.h>. s0 j; A. b6 A8 {$ ?* f
/ y0 P: x" ?7 U2 W# D3 D8 H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), t, H/ f" g' @" R6 G5 g. M- O* O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); n8 i; F5 k* y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 D0 p0 Z- }- U" F& U; Y& M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ E9 ]7 w. U" p* J. O# c, R7 l, t
6 f$ N& |; r- c# K9 Z1 f) d
/* assign the tl som board LED-GPIOs*/
4 k# @) g% b- k$ y& g3 ~9 D8 U3 ~+ Tstatic const short da850_evm_tl_user_led_pins[] = {
/ L' o6 D9 t2 K. X* i! ] /* These pins are definition at <mach/mux.h> file */# u. W# A6 s J6 F2 O0 C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, G: m$ F9 |5 A7 S }1 S: F
-1' U# m( \* {1 T: I+ o
};1 G" M @2 [, S5 V" y! \
/ v# Z, z- {* }- B* v5 ~/ Z
static struct gpio_led da850_evm_tl_leds[] = {
% y* h& K/ J3 X2 v. b, C {
5 l) W2 c* O7 _5 p, O* _1 T2 n' b' O) o .active_low = 0,
3 V! N: o4 C: c5 T0 E+ X& X2 } .gpio = DA850_USER_LED0,
3 x7 }7 e) u1 u3 G- S .name = "user_led0",1 e, a2 q" f6 v
.default_trigger = "default-on", A/ _' Y" W' H( ]& j
},
q' N, u5 c* |; b$ E { k' }6 j) M4 d" r- G5 x8 e: L
.active_low = 0,1 i. M* N# N& d7 F5 t
.gpio = DA850_USER_LED1,
) K Y% R" D2 O/ V2 Y# @: D .name = "user_led1",
0 q" v: i' ^5 l$ D' I .default_trigger = "default-on",
. J& ?) Q- t- j$ r8 F1 q },
/ z) R) I5 c- N y {! g0 Y ?( y6 }+ e* P
.active_low = 0,
: F/ |: E v, t! { .gpio = DA850_USER_LED2,
4 E* ^# F' A( K .name = "user_led2",
% l! [( L) V) k: v2 R .default_trigger = "default-on",0 U1 j T4 I6 U9 Q( K. s2 C
},$ E6 d/ Q0 S4 ^5 R$ G6 ^
{
6 e% Z+ Z% ?8 q! i2 x) I, a .active_low = 0,
, Y6 o+ P n9 ^ G$ Q% [2 S .gpio = DA850_USER_LED3,
5 ?. P5 R5 ?% h .name = "user_led3",
- C8 v j% t- O- u) ?2 F0 s .default_trigger = "default-on",+ w3 Y9 ~% X6 K' N9 s9 K5 o: q
},
: ?4 C: t4 @3 Q; i6 v) Q2 D};
0 e+ w U r* p# }- \( `4 U' P3 {! J9 ]! T: U; E+ \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( h6 ^) l" T: W: a
.leds = da850_evm_tl_leds,# B6 d6 D( ` _: t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# }4 _: d' \% S# [% t! _7 f' ~};
+ a) l" g8 B# J+ v( j. t
# w5 G) k% R' m- Y0 jstatic void led_dev_release(struct device *dev)2 h0 Z% G4 z' G7 Q0 d `
{. j3 t8 j. a$ j% f I7 I. W" j; X
};2 x+ j! t( F. V1 k2 R9 n
9 l' [8 w, s0 i% a0 X; dstatic struct platform_device da850_evm_tl_leds_device = {
0 | q9 J8 {* b8 _ .name = "leds-gpio",
" t% ^* |! U' R4 M! _$ J .id = 1,
5 }' V/ x3 H! {! Q! i; W0 M .dev = {, |6 }7 ^: R( @ G
.platform_data = &da850_evm_tl_leds_pdata,
! k2 \$ X1 t5 N; E .release = led_dev_release,# W& i! w! r M1 p d
}$ V! l+ u5 p* s( \
};
+ l6 p& s% I) K' ~2 N
Q; h% ^7 r1 }( a- Dstatic int __init led_platform_init(void); N! V. x" B, }* u3 M; q+ P- W
{
5 @8 }$ T! k; P$ K8 I int ret;, z* {1 k! n. V
#if 0
: p9 C5 v3 K4 G- Q- D5 @* ?" W' S) G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
R( \* C, w. m* t if (ret)
' h6 p W2 S# T9 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :" w' ]$ }2 B9 y! p/ b% I5 v8 N
"%d\n", ret);9 M" y0 m% f$ t& ~" s
#endif/ ~/ J* w; I8 S$ z X
ret = platform_device_register(&da850_evm_tl_leds_device);5 Z; i6 U( |9 a) v0 X
if (ret)
! j5 ]) D) N( {0 P; @ pr_warning("Could not register som GPIO expander LEDS");4 n( ]# D6 n: T n/ h% Z
else
9 J$ n6 U1 i, R4 v printk(KERN_INFO "LED register sucessful!\n");) A+ A$ ]' {5 q5 d2 P" p& h( a: U
# r0 I( X4 y, o% M% j* X
return ret;4 t' L _, x" X; _ g) {* Z# y9 N# B! g
}
) g m" N) e. y# T2 m' Z$ |, d( H/ {1 o. i$ z
static void __exit led_platform_exit(void)+ }/ n. d/ I/ E- U" D
{
% n1 l$ g k# l4 R3 g- R) w. O5 c platform_device_unregister(&da850_evm_tl_leds_device);
/ F/ [4 V, X1 F4 P1 W
6 g' j/ |- H: G! k( p# z | printk(KERN_INFO "LED unregister!\n");
- ^2 _4 _2 K+ {& N3 E}
9 [, c2 t+ Z% [2 T6 `# L
' a- a( y, | A. rmodule_init(led_platform_init);
2 ~, a2 g: w. f/ V9 Amodule_exit(led_platform_exit);
0 n5 G) Q: ?" ?3 F! G
+ ]( V6 ]$ B" p) G0 C4 j8 _' DMODULE_DESCRIPTION("Led platform driver");% [' P. A5 K7 b# c5 X
MODULE_AUTHOR("Tronlong");' S- Q& B ~( X' B
MODULE_LICENSE("GPL");$ |) U: v0 ]4 n: y/ i- |
% y' \% h# [8 K0 U |
|