|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. W L+ Z6 B" _$ B3 ]! M
#include <linux/init.h># L4 |, ?& V' X/ w
#include <linux/module.h>7 H: U ]. L# y
#include <linux/kernel.h>) w' Q* V2 n4 r8 Y! J& l, X9 l# b* x
#include <linux/types.h>" V3 c$ A0 I: X: i# B- Y
#include <linux/gpio.h>) D6 s5 \# E5 v, ^/ ?
#include <linux/leds.h>
9 L2 b* c+ v$ F#include <linux/platform_device.h>9 k' j8 L( Z* I& l$ ?
* s }0 i6 j# R" ~/ Z$ [& {0 w9 x
#include <asm/mach-types.h>
) i& B% u5 i9 T4 `#include <asm/mach/arch.h>
$ @, J0 T4 q/ I9 S- T#include <mach/da8xx.h>' y* B6 u( x: v! g8 y& \
#include <mach/mux.h>2 i) e, {! J1 _& w- |! w6 |/ ~+ r
* @6 K _0 f( j- e0 Q/ n+ x: q3 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). S0 A, _: e/ Q: p5 _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. @, `, K' X3 i1 H0 S# z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 [2 s9 [' G+ [) P8 b. C; Z+ u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) o6 V6 o0 L+ T1 e- D3 |
7 h# Y) a' I+ w/ v2 O5 q/* assign the tl som board LED-GPIOs*/) w C* S6 X9 R! ]1 g
static const short da850_evm_tl_user_led_pins[] = {
5 ^6 d1 }" D5 w /* These pins are definition at <mach/mux.h> file */* W6 R- d5 f" T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% f. |+ |+ A$ v* l) y/ P! c7 y- S -1
3 R% E: N. r9 {};
, Q; b: e0 X( T
+ p6 J# R4 t! F" O- Tstatic struct gpio_led da850_evm_tl_leds[] = {
; y2 q2 W* y# c# e/ C {
' _! k4 x, M; V5 q* {' c .active_low = 0,2 O( ~0 h8 b, X$ z3 k
.gpio = DA850_USER_LED0,/ W0 v" H% M4 @" n* T
.name = "user_led0",
7 [( k+ N1 U" C .default_trigger = "default-on",0 o+ {/ `! I5 p& Z$ `% G1 e
},
: O9 {: _9 n) h% o- a8 u2 N: i {- d7 _0 Z7 v/ T0 b% s7 b2 b o
.active_low = 0,
" K3 G+ Z6 `: P4 ^, [) T; T- ? .gpio = DA850_USER_LED1,
$ |( F a* Q9 {6 Z .name = "user_led1",3 z$ m0 f7 K- i$ t
.default_trigger = "default-on",4 R' y/ u3 e" O/ F! {" K! L4 Y
},
! C' b. ]% \9 m. n {2 P7 ^! J& M3 f# w( U
.active_low = 0,: u2 }+ L' y F' j. ]4 z! c. ]
.gpio = DA850_USER_LED2,- D0 z3 u; U! e8 r' \
.name = "user_led2",5 q4 U4 d# M5 C9 I+ ^
.default_trigger = "default-on",4 a8 ?/ E" g% m9 E e9 C
},
- U0 G9 O; G% x6 U {4 V( t6 {9 O: _6 _+ v, H
.active_low = 0,! O F: `8 a, |5 q$ g. _0 Y
.gpio = DA850_USER_LED3,) _' S5 x/ U1 e' N7 s
.name = "user_led3", T( t( M& Q W. i% V0 e
.default_trigger = "default-on",- e. u8 ^ R6 t" J) O8 I
},6 z* E' W) o% V3 Z8 N: [1 Q1 `
};9 s9 b; L: ~/ V! V, b, p; y
; g3 J; \9 s; |; C' K4 n' J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { y7 g* ]- A* b% ?& H1 p$ B- o' O6 _
.leds = da850_evm_tl_leds,' d2 Q2 E, q8 H. Z$ J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- @2 s, E; l9 n3 Z
};8 b% {% `2 y& C( k' n
# k6 N) c8 r& z# Tstatic void led_dev_release(struct device *dev)" ^/ X6 `& h1 \) \
{- U9 Z( U W& r4 L( x
};, J; _* O3 R: K4 \6 K& T" u
2 }+ @2 H$ W; Y, I+ y; \; u
static struct platform_device da850_evm_tl_leds_device = {" z: a4 o9 m) j7 ?% g, g" M
.name = "leds-gpio",. H; I5 t( y- q
.id = 1,0 y( u% q7 A6 f( d* A/ z
.dev = {
! f2 @/ ^8 f/ _; f .platform_data = &da850_evm_tl_leds_pdata,, Q; N; U/ l6 r" W
.release = led_dev_release,% w" S" G$ }( Z8 b# j" \ L, Y' _$ k
}9 Y$ b2 Z4 W0 @) L( U* C
};
2 D* F# m) {2 r, y- o0 |
$ Y& U* ]1 G" u, h. R6 c% istatic int __init led_platform_init(void)
7 v6 @ L5 C. e$ }/ L8 G% p1 {% r{# a, o! {2 I# g* ]
int ret;9 J% ]2 s* e$ Q, J5 D0 c V4 O+ W
#if 07 v6 ~& c$ T; W" \+ {: J$ a3 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 _0 X2 Q6 I( o/ i/ \ if (ret)
/ s7 `8 J' y3 c- o* x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 F w8 l$ N- Q+ q2 U( C# M7 |: \ "%d\n", ret);5 R3 r+ M3 ^# B
#endif0 p) E1 J/ B5 C/ i1 E) T
ret = platform_device_register(&da850_evm_tl_leds_device);. r% X6 O# _* _: R7 Y& o
if (ret)7 h8 a; ^( h1 i0 c; M6 J4 u
pr_warning("Could not register som GPIO expander LEDS");; h. a+ z& G4 P# @
else
: Q0 O) f% p+ q1 p) h6 t0 b printk(KERN_INFO "LED register sucessful!\n");
2 [1 u9 s* R2 y& y5 K- m
8 g5 {4 J% F6 @$ v5 I5 a return ret;3 ^* f0 g2 j8 N! t# C. i/ N
}
* D( @( Q3 _- `9 \2 W* K
5 N4 A) |+ T A- Ostatic void __exit led_platform_exit(void)
0 C$ r+ D2 d& U% J4 R$ o- {. u% M{
$ [: s* \5 k2 A2 C platform_device_unregister(&da850_evm_tl_leds_device);
2 t/ `0 T2 g/ N" `$ S: v% ]7 N8 Y
9 C7 U5 k, z# ] printk(KERN_INFO "LED unregister!\n");- X& M* u: X" T+ s6 w* d8 d6 y
}0 e8 i7 B3 \% _. M
5 M6 [" A, s# F9 S7 Jmodule_init(led_platform_init);( z. q/ M0 U+ s G: F
module_exit(led_platform_exit);8 M2 ]; y) B. U. I' c2 Y- e
1 [9 Z1 Y F3 W4 ]7 c/ K) dMODULE_DESCRIPTION("Led platform driver");
( _ o0 k2 M/ {0 C9 ?" t) V+ `MODULE_AUTHOR("Tronlong");$ X- Z+ J3 P1 U4 E
MODULE_LICENSE("GPL");! g0 t H( v8 Y* [) ?
+ P" K Y0 H: P: _8 p: y0 T |
|