|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% ~* ~3 ^1 m4 n4 S6 f, ]& t$ z
#include <linux/init.h>
, R6 A' O7 G4 Z$ c#include <linux/module.h>; y6 c. S+ {" S% a- k Q
#include <linux/kernel.h>
: T: h. W& c3 S% c' U" I#include <linux/types.h>
8 z+ I) f$ h! m4 I#include <linux/gpio.h>- v/ B' |1 `) j( N& O7 Q) h
#include <linux/leds.h>
+ D* r# P& u7 W2 O4 L/ X#include <linux/platform_device.h>- r: z: k" x$ j& I* e7 C* m
V: }/ |$ i2 n/ Z1 r; {#include <asm/mach-types.h>
( [6 ?" k$ t' m( j! C3 j#include <asm/mach/arch.h>
& O" h0 I) D3 x, s& x#include <mach/da8xx.h>
* {5 E0 `, U* c) W#include <mach/mux.h>5 r) d: p' l9 d* k- x2 H# V
' E( E# m) O- b% ]! f# f( ~: T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ~6 |8 r, J# J: {. f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! ? e, b5 i( S. j% Y( B. \! C# ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: S4 g' e' m9 m ^; k- x7 ?) z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 o5 B$ Q, @) l. a; h' P
* f: j: ^9 V& E, f% \/* assign the tl som board LED-GPIOs*/2 n4 g, D. F* N# Z% s/ E8 k' ?
static const short da850_evm_tl_user_led_pins[] = {
# \! d: f# H, b& b1 z /* These pins are definition at <mach/mux.h> file */% Q7 d5 v+ e: h+ K3 T# N4 \# k! C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 Y7 n3 W9 C0 J -1
) h* E; G$ `: [8 E4 C4 p};
5 p2 G5 E* p- f2 s, U) A& q' N6 B0 e3 B
static struct gpio_led da850_evm_tl_leds[] = {' M+ R" d7 [+ u1 M D
{9 _8 L3 O+ w0 ^. k, L" k
.active_low = 0,+ E2 a) _3 t$ q0 ^! w
.gpio = DA850_USER_LED0,+ I5 S# ?5 y1 w- z- g/ F' W
.name = "user_led0",3 s; U0 N' w$ C% \6 \ ^" h: b
.default_trigger = "default-on",
5 l# D8 m0 `2 t },; H1 N8 w. n- S( [
{
. X" {6 M$ k0 s* o& n+ {: b .active_low = 0,
( S @ ^0 ^3 X) A2 S" T& b0 Q .gpio = DA850_USER_LED1,
% i5 q+ q3 ]1 U( W5 p, _6 v1 H* y .name = "user_led1",8 q7 @/ I8 a2 w$ ^* Z/ x3 X' B
.default_trigger = "default-on",0 O6 M. x! Z1 P6 D, w9 w9 j
},9 F+ K) t+ X5 M& m
{
8 N1 C$ u4 H! X# l$ m0 j+ c) b& c .active_low = 0," J6 ~9 a' |. L! i
.gpio = DA850_USER_LED2,
% f) f& j9 e- Z3 W .name = "user_led2",! c3 R* r4 Y7 ~/ q- @- o
.default_trigger = "default-on",
4 f( f/ L# F n },; n, `5 ~) G+ z% T
{- k& c8 u) b' u* q8 r. z
.active_low = 0, q% ^7 [' c2 M
.gpio = DA850_USER_LED3,
9 B5 ^! L, h( V5 b6 N# `! c .name = "user_led3",
2 l# b! ?0 z% Y- G8 M$ y. C .default_trigger = "default-on",2 n; G3 g: F9 ]0 X3 n& k5 x1 b
},
O \8 d! _! E3 J};
! \2 V" ]; `5 j; D
' |5 O$ `, x+ e/ vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 _0 }# Z0 h' H, K9 i# k .leds = da850_evm_tl_leds,( a$ ]/ i# i. D2 C) c# @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ H* P+ p) }$ ]6 V9 l5 }: z
};
4 |0 {$ Y0 _/ l8 T+ @; R' E- A! `1 ?
static void led_dev_release(struct device *dev)
" I; f; T' t1 y1 U9 y. y A{
; V' V: Q( z* }7 W: l8 e9 ]};# x0 l5 Z! W6 j" `& O0 q% A
& D9 ^ u5 F/ v7 L7 q$ _
static struct platform_device da850_evm_tl_leds_device = {
6 K8 e! T d; S' S: H .name = "leds-gpio",
7 K# \, I* d& @7 p% w .id = 1,
7 Z: j2 l* W! x% b0 E9 P1 k1 F .dev = {
7 N7 z+ h7 M8 g$ W4 t/ h. K% p .platform_data = &da850_evm_tl_leds_pdata,
% l" s; k2 q6 A. x6 p .release = led_dev_release,7 L5 e: _$ p, A/ o
}9 r3 `; t, C% ]7 G% y1 Z
};8 P6 q* j: ?( |
/ t" v3 x! {. z( ^8 O; tstatic int __init led_platform_init(void)+ S- [7 I# j& @
{( {0 H" {" b8 w' m
int ret;# b# {5 _! H' w& Z3 L& k9 ]* V
#if 0
9 O. w: t# a# x4 i B2 z$ _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 l' U9 s. Y* @# B s" Q if (ret)( X+ c' O' d- z( E9 k) j: w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" E$ o( b) ~* m "%d\n", ret);' _" a% J" c0 ~8 M. w9 o
#endif" Z+ x5 q+ B \+ s6 m% `' w
ret = platform_device_register(&da850_evm_tl_leds_device);
0 v* A i# @! h% r2 @; z9 c if (ret)7 X# d2 R0 M- w9 t" _4 d- W8 _
pr_warning("Could not register som GPIO expander LEDS");
9 |) x) \0 f6 t$ ` else* d) H- Z2 f+ }' P: Q" Z$ B
printk(KERN_INFO "LED register sucessful!\n");2 {# s1 X) q$ q' d" X
7 |1 r8 i' w2 e
return ret;
2 N8 s9 L: l0 x1 T$ {! K}
$ L1 o2 D$ Q* Y9 g
3 t, N, U% N0 A. S8 qstatic void __exit led_platform_exit(void)
u% O5 }4 s1 v0 @{
2 v, O P# \8 @ platform_device_unregister(&da850_evm_tl_leds_device);/ ]% X+ w6 }! K
% x- U2 j3 e3 \; u+ Y2 a$ V _ printk(KERN_INFO "LED unregister!\n");
8 \) A' s2 N+ h' Z' i}* n) W* J1 W0 P8 P: u2 E
: X( B k; e0 O+ ^+ B) Q1 }' C
module_init(led_platform_init);' j: ? ]) f! D
module_exit(led_platform_exit);
3 I8 U) n/ E" k" _9 |+ g: V2 n) G- P# ?7 ~0 {
MODULE_DESCRIPTION("Led platform driver");( @4 ?1 O( y/ y% S0 S9 F& R/ w
MODULE_AUTHOR("Tronlong");' r) X; Y. H# W1 n" e+ ~" |" P
MODULE_LICENSE("GPL");
! g3 J9 F: y' C7 p- a
9 P6 s& d9 q, w8 }/ d' E. {' t |
|