|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 y! K* x7 _# `. e, i#include <linux/init.h>
2 P% X; ?' M0 m5 @#include <linux/module.h>
+ e; G1 s+ `/ J' T" K#include <linux/kernel.h>
' ~' D0 ]( K* [7 e! |% I+ i& b#include <linux/types.h>
: E$ }* G9 r5 M) u3 i#include <linux/gpio.h>
1 v* H! F E/ C* I' e#include <linux/leds.h>) G( ^8 N |; N' m& _
#include <linux/platform_device.h>
! Q3 p v$ k- U9 z, v
1 v9 B ?6 J8 G; Y$ n#include <asm/mach-types.h>0 Q$ L7 V* {6 k7 s: A! c$ E! N" h
#include <asm/mach/arch.h>& P# N* Y8 E5 i# c( m" W- R
#include <mach/da8xx.h>5 v9 q, |3 A. E: @% u4 b2 |
#include <mach/mux.h>
9 l% ~/ `0 j( O' G% H/ F% q$ f8 _/ Y7 U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 ?, |8 r4 H( S% r7 j* |! c" j9 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# \- x$ t* S) z, u4 p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) G. n( C! b0 U1 V. {+ ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 y! \/ ^5 ^7 `! u5 s
( A% m6 {9 e& B4 C
/* assign the tl som board LED-GPIOs*/: G, r% u, N9 ^, X7 F) ?* u
static const short da850_evm_tl_user_led_pins[] = {
/ \ R, P* m1 ?+ t( ~. X0 {8 B /* These pins are definition at <mach/mux.h> file */: C+ g O0 |: z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 x, \# C6 N. d k7 y2 f
-1
* s. P% h3 B3 w0 }6 C9 |};
9 A: Y% A2 I n, \7 v' P
$ B1 J# W' Q$ A$ |3 h1 jstatic struct gpio_led da850_evm_tl_leds[] = {$ A0 }/ ]8 Q! j3 F7 O
{
: H0 Z7 d: K) C4 v$ t5 i .active_low = 0,
( [2 b1 I$ b: M9 c .gpio = DA850_USER_LED0,* V3 _3 S% N |) E3 t4 s
.name = "user_led0",
: D5 u- U: R- Q3 j .default_trigger = "default-on",
m% ~4 b; j5 J3 w0 u8 e( V },# ?9 j$ h. b2 p8 s6 v
{" P+ f- F' Q# C% L
.active_low = 0,
" r& x6 ]& X! @ .gpio = DA850_USER_LED1,- v" B7 C2 Y8 O: @ G6 ]
.name = "user_led1",+ t4 w. W, U$ o/ k1 e' Q" B# z
.default_trigger = "default-on",
$ N8 w0 |4 ^+ H' x; S },
& i; t% a4 Y* p0 @7 K {
& n7 }% v. G$ _1 p) C .active_low = 0,
# l$ s6 Z# M/ B$ u- B .gpio = DA850_USER_LED2,
' _: B% w- [) ~% h# n* z2 v .name = "user_led2",
& V# I t1 Y3 w% b6 `# E9 T! } .default_trigger = "default-on",
/ f: x& F9 o, e1 [ },
' A" x& S: ]# M, `! U7 Q {3 b9 ?, z- A+ o/ \0 u+ e5 v
.active_low = 0,7 X! a% }7 z$ m; o" S+ Q
.gpio = DA850_USER_LED3,
5 b7 S' O4 J9 B9 V0 F8 ^7 U( W .name = "user_led3",
& U& H4 y! g9 @! z .default_trigger = "default-on",) E/ J5 A1 n* [
},
! {# S' X! @5 j9 _" D; d& B}; m, _ r+ O8 F: {! O; i
, G C. k3 c0 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ Q) o. Z$ v# h4 l4 Y E$ V- T3 a Y
.leds = da850_evm_tl_leds,
! ~7 Y a( r% v% R4 H' T0 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ m% k- S* x; g7 p- ^# s6 K8 C};6 ~, c& Q3 k" r# L3 E5 _
) d, S2 D5 `8 L/ P: A( ~# gstatic void led_dev_release(struct device *dev). m2 M; h9 N$ S2 O! V
{* i* k$ i7 s9 T3 y. X6 E8 F/ p6 {
};
( M x2 z% `; P: ^1 |' s" s6 A& G/ X# \
static struct platform_device da850_evm_tl_leds_device = {
. H) F" W4 Q" {4 m .name = "leds-gpio",) \' k8 Z/ p1 I3 u
.id = 1,+ Q+ P: m2 g4 ^9 V: c5 |8 a" M
.dev = {# W! r0 Z9 k- E! S
.platform_data = &da850_evm_tl_leds_pdata,
/ Z& x! o/ V L" [9 R& v .release = led_dev_release,
- k! v) A- j, _: b: L: T! {& y }
5 d/ o+ s8 g- Q+ ~$ w+ H};
" n! p" [! l! D1 d$ i8 X5 L' W! r& `& g' f" ~
static int __init led_platform_init(void)/ {: j, L' V8 K _/ T7 u ?) P
{
) R9 ^2 J3 _% t4 k7 Z int ret;" r. i6 [6 i" n7 @5 M
#if 0
/ J9 c6 |& l' b; _9 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 m; ~% D7 W7 I8 [# \* J
if (ret): k1 v+ @+ e1 q% R* \! |9 I% t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 A6 y2 }4 s# j' X6 _) u. h
"%d\n", ret);
, p+ C* r7 V. b& J+ M7 s#endif+ w/ o0 `& h7 y ]! R5 W ?
ret = platform_device_register(&da850_evm_tl_leds_device);* P+ d! ]9 a; t/ ^
if (ret)3 A6 N7 J- s+ F! l3 A+ ~/ j
pr_warning("Could not register som GPIO expander LEDS");
% ~+ g5 ?* F4 v! }8 [6 c9 C! J else
& ^0 W- n; Z' | printk(KERN_INFO "LED register sucessful!\n");
8 {) R& G: p6 u1 j/ k6 s3 U# p3 l* R
return ret;. p1 U$ m; [) ~+ B1 e l
}) z9 v1 D+ H5 N% x! k6 [
5 p% E0 F5 ]% k+ w
static void __exit led_platform_exit(void)
3 a: P2 l* X* l$ z" J2 C |{
, Y4 F2 e T) R4 K/ V, v4 A+ s- a platform_device_unregister(&da850_evm_tl_leds_device);
1 E! G+ o) }5 Z2 v. F" L: B4 ?- q
printk(KERN_INFO "LED unregister!\n");) g6 c: Z* o4 Z; \4 j# k
}
C+ a1 ^" Z9 ?7 S2 \3 N- Z1 b& h! Z
. l+ V% \4 H( u! z/ \8 smodule_init(led_platform_init);, R C3 w. {6 [( p& F3 K- y( ~
module_exit(led_platform_exit);: Z$ K3 E" i+ y7 a8 J
; T5 ^; X2 z; Y7 I* i& ]3 {MODULE_DESCRIPTION("Led platform driver");. U4 p2 a2 k; M
MODULE_AUTHOR("Tronlong");' A/ s& }0 a4 T( Z) s6 \* G
MODULE_LICENSE("GPL");
, {5 N2 B3 N6 O% I3 J1 H) `8 g& \% H4 X f4 x* S" K, p
|
|