|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# r) Q( Q; d5 e u$ h5 _. {#include <linux/init.h>
) c1 \1 Y. I3 E+ Y, S5 `' Z6 f( s! t#include <linux/module.h>
) D2 V+ p' H! n \* p9 ~, y#include <linux/kernel.h> o6 }( m% F6 z& C$ R9 k- g
#include <linux/types.h># B9 p% }$ }: R' H
#include <linux/gpio.h>3 O& d0 b# ?4 F; L( u/ R
#include <linux/leds.h>
0 L9 u |* `' b8 q#include <linux/platform_device.h>( Z( r |6 J% F- L7 {. d3 m7 g( V
& t, j$ G8 @- {5 K; @- T7 w
#include <asm/mach-types.h>
8 i2 C; X- d# z* W4 \0 @# @5 V#include <asm/mach/arch.h>
, Q% W" B3 ]0 o* p$ K" r: h9 Z#include <mach/da8xx.h>
0 }, r# u* d! h#include <mach/mux.h>" `. `' R$ m {$ G1 D
9 ?& i( W$ |6 A0 X. u" M: s+ c8 }: p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). a$ o9 w. h$ y9 `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): a. d7 c) J( B; r/ R# a8 E+ V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 Q% S) k; n( ?8 L/ T) g" N1 A* O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ ?2 f, `! v) M- o' l; Y! H
0 y* n4 K9 d8 a% ^4 n+ L) a7 D1 E/* assign the tl som board LED-GPIOs*/. P% r& D5 y' b! r; R( r1 l+ Z
static const short da850_evm_tl_user_led_pins[] = {
3 n1 X! t3 ]1 ?" `1 ?4 | l9 E/ h /* These pins are definition at <mach/mux.h> file */$ o5 t2 ?9 W: x( N: a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ c5 Y8 ?( p0 O- o' c
-13 m/ I( e) I! J0 O
};8 [6 W$ L& o" r( X' u v
8 q' ?! V: s; ?: x' s1 }
static struct gpio_led da850_evm_tl_leds[] = {' v+ e' Y/ e) h$ Y
{% l7 P* [# v1 k: c" X; f& @
.active_low = 0, U* z9 b6 L; U9 m# B% j! g/ U
.gpio = DA850_USER_LED0,% C$ u- D8 Y4 J% s
.name = "user_led0",
& \/ c- [7 Y. n1 ?! l1 y .default_trigger = "default-on",1 \% y! W* i. ?9 |) s7 z9 O
},! k6 c7 U$ ?% w' J4 D
{1 ~0 C* u: L# N T2 `0 ~
.active_low = 0,
9 ^4 h( X( z# J' D! x& H' W% s .gpio = DA850_USER_LED1,
- W% n9 ~) B @, P# N .name = "user_led1",
/ h# }% j% z: |% l, D .default_trigger = "default-on",
# ?! w5 E& S* o) U },
0 X2 l* ?4 f4 s# l4 z2 |# A& C { W# t* B! v- Z: E9 R
.active_low = 0,
! k; `1 A: Z) E y1 z/ I .gpio = DA850_USER_LED2,
5 S0 a+ a5 r/ e! h( m7 Z .name = "user_led2",7 q) }$ k1 [( h: U) K
.default_trigger = "default-on",
& S7 Q# Y# H4 N( T: Y* Y( W5 a },
6 E' N4 T' l+ \ { M. }; g: R0 U$ @% N% U% Q. m- {3 `
.active_low = 0,
' z3 L8 @9 o: F( z% _: H$ Q .gpio = DA850_USER_LED3,0 D9 U. Z% Z+ o) a0 [
.name = "user_led3",2 M7 h. N" {) ^5 M f1 B
.default_trigger = "default-on",
" L; _; ?- Q4 g+ I9 \ },
# ~# \1 m; p) W3 T! p) N};1 Q7 @& N8 A# G: H
% m* m0 D+ Z" Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. z# z: S! A' J0 W/ W: @8 E4 f
.leds = da850_evm_tl_leds,
, v c8 D- j. l; @; _& z" g% [; n, m, A! l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- y: `5 r$ c) }) a8 N5 _% E
};
6 N0 v x" l4 {% v0 n
) C, r1 C2 |! {! ?4 Q2 j9 Estatic void led_dev_release(struct device *dev)
: u" R5 x* V/ Z3 z: Y{4 w# Q A2 m7 e4 d3 F- m
};& R. b" C/ Y" v( g2 o! m' _
( U3 O# x2 S4 c+ Y( l( Z, pstatic struct platform_device da850_evm_tl_leds_device = {
6 I* D& t' e! ] .name = "leds-gpio",& [& a+ \$ `! }' X
.id = 1,; j7 l% z% W, W% K) A k0 z* L% V
.dev = {
2 Q$ s" b* a1 _9 y# |( G0 v .platform_data = &da850_evm_tl_leds_pdata,& ]2 F5 g8 |6 F: u
.release = led_dev_release,
: y: B$ u$ ~! @ }
8 }) n, z) r9 m9 A/ R) s2 I};" |! m7 S9 R9 x0 u$ r
% i) T; q% x) c( h, J ^$ G
static int __init led_platform_init(void)
, k( N5 I0 c4 W% X{, f5 m0 w# `' }
int ret;! {' X4 m/ f. f- f! k0 P8 i( O* g- i
#if 08 @. n" ?% x$ ^) c. G2 v) ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 |3 k! \& ~; a. r* M6 X( E0 ^2 Z
if (ret)+ K" O+ L% s7 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
I. u. X% ?- M. s "%d\n", ret);* u/ j) v" d* Y4 J
#endif ^0 j/ \2 g- y7 L/ j# {4 h& y K
ret = platform_device_register(&da850_evm_tl_leds_device);
! \; c3 S3 K- D$ a6 N0 c! O5 E if (ret)
" ?5 V0 E: @# a& Z pr_warning("Could not register som GPIO expander LEDS");
- E* h! d/ X8 `7 o* m9 h else
, ^ v+ s/ g! U printk(KERN_INFO "LED register sucessful!\n");
, X, L% F/ ~, { ^' ]7 b0 p; L3 u" M% h2 [' b, @0 o& U
return ret;& r2 y8 u5 A) ?
}
6 X9 A* |" o$ o' h2 `5 `. i, }, K% \) q3 J9 u4 p- t
static void __exit led_platform_exit(void)1 d3 t( l" k' @( C
{( F7 _; x: E0 i+ u9 N
platform_device_unregister(&da850_evm_tl_leds_device);0 |* M: m6 w# d2 p, J" h2 c% f E
V8 J T5 m5 I1 F2 U0 J: i+ c' c printk(KERN_INFO "LED unregister!\n");
* s! K! x' m8 j1 p- U$ K( Y}0 N% U& z4 b8 }" B5 n
& H% s7 F9 A; D& ~
module_init(led_platform_init);
$ P9 H% p- v6 b6 u8 Smodule_exit(led_platform_exit);
/ V6 d: ^% x2 l* u* U1 a+ g+ k' G; ~+ u6 O) Z
MODULE_DESCRIPTION("Led platform driver");2 [' _; l: R& T9 J: S: a
MODULE_AUTHOR("Tronlong");
3 a6 D! W$ q# x* aMODULE_LICENSE("GPL");5 N2 C4 E; P |( Q& k
+ B3 L, L* ?( K; R% L9 [( Y6 m* w5 S: u |
|