|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 M* f* d0 B c0 q: D
#include <linux/init.h>
* P: x' H+ y7 Q$ J#include <linux/module.h>
. g/ ]; y' u) \/ p8 N: L! c+ x#include <linux/kernel.h>
3 J5 x0 M5 B0 P#include <linux/types.h>. M1 V3 z5 m8 V: ?
#include <linux/gpio.h>
7 u& k" M- X: o6 o6 ?#include <linux/leds.h>! c4 g8 \( B3 N K2 p2 P
#include <linux/platform_device.h>
* v0 B. M; J, S/ x6 ]
' Z1 a g% T, a9 r- o; W0 V+ e* `; f; e#include <asm/mach-types.h>9 g9 |! D3 J& _/ R! X( \+ D
#include <asm/mach/arch.h>( e3 O( W- S" |) }
#include <mach/da8xx.h>- S* ]0 g9 J) f" r7 @
#include <mach/mux.h>( z( Y" x* c# I; s" x* V
3 B( D9 W9 w: e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): V+ W3 f& N/ _3 [" M8 z/ Q- E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( w# ^% R. h; N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 Y% ~: J: A1 N$ @" W# @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* l0 T2 _9 ^) I Z7 n
4 F. x2 T7 K4 U/ X/* assign the tl som board LED-GPIOs*/4 l& U; k0 g* l5 P4 q* E. ]* @
static const short da850_evm_tl_user_led_pins[] = {& `6 l+ ~) f3 f9 p
/* These pins are definition at <mach/mux.h> file */
& ~# L5 d3 J) `5 V2 a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; F$ _" V! b6 F9 m
-1! X4 h7 I4 a* b, l/ Y9 y' j" ]& w ?
};! k; F% F+ \$ H1 l
( y1 w% ?" X9 _. n# M
static struct gpio_led da850_evm_tl_leds[] = {
5 F+ l" M- a; o2 J0 a! J/ I' Y {2 w4 ~" j$ ~$ S7 T
.active_low = 0, O) X# F' f1 u% }, K7 L
.gpio = DA850_USER_LED0,( M5 R- R* B+ `) G: e8 d4 {
.name = "user_led0",3 |+ `, Q' W5 s) ^
.default_trigger = "default-on",
4 T8 V- j {8 @' V. Q },, E. I2 \2 @4 C. C w
{
/ P" u$ h8 i1 c: k( {: ?# o .active_low = 0,; v( L- }$ e( i" k
.gpio = DA850_USER_LED1,
; C- S) o# X9 X! q/ L9 b2 u9 |1 v .name = "user_led1",: V w1 ^! f4 Q, O! V# q( a
.default_trigger = "default-on",6 b6 ?! R7 a2 U8 X
},
' Q1 i; x" p1 r1 P1 v A- T {
( k" c* t; W/ U" v# V% _ .active_low = 0,
. m8 d& m, T8 {- O; m .gpio = DA850_USER_LED2,/ p7 M6 w0 ^% l
.name = "user_led2",& H& R" D/ }/ m3 ~4 r
.default_trigger = "default-on",# F$ k! B) C2 }* I( j
},7 p5 H" b# h- I+ |* L ^
{4 L4 D$ G1 v2 I$ q
.active_low = 0,
1 y5 }3 h& q2 F# `% D .gpio = DA850_USER_LED3,
7 q2 ?% l A' M .name = "user_led3",% c1 c' {0 y5 M3 M% Q( ~
.default_trigger = "default-on",
% X6 _9 j( e e },' p/ V0 Q, C3 W8 [
};
" a6 X" N- y' Q: P4 X% T$ N9 F; o9 [9 b/ T8 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. K X8 [- C: o, K$ e9 }$ U .leds = da850_evm_tl_leds,7 p6 {/ p: G; `$ w6 n# P" B$ v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' I+ O7 A: i- A2 \};
6 B0 h& f9 ^6 q6 c( Z' S9 W: o' O
. S4 K" r5 T+ I/ g1 a2 y% e/ [static void led_dev_release(struct device *dev)1 d! d9 }$ N9 l1 S; L! d
{
# }, @) O% F. s};6 M$ W# ~; E5 Y4 ?6 I' K! L
; B8 E. b/ W$ _# [; ?4 W- C( Z: u
static struct platform_device da850_evm_tl_leds_device = {
5 Z9 A, ]( c. X5 ?: N .name = "leds-gpio",- [' y1 h' \& ]" u' L3 S
.id = 1,
/ m$ t3 s8 }; O) x8 h .dev = { k0 u8 m' \( u& s; c
.platform_data = &da850_evm_tl_leds_pdata,
/ b9 R4 _' y2 f* ^ .release = led_dev_release,
- o) B% V' ]7 U% {- Z# v8 ? }
1 g- {) @$ C, W u$ s};" l) q" b6 T3 E
5 `0 g$ j( i; l }3 R9 n/ l
static int __init led_platform_init(void)* I$ E/ t6 T& I8 x& B
{# h8 e1 ^4 u. l: ~3 d6 [
int ret;
8 N- T. K9 z( r' m' H d3 n#if 0
6 I0 e6 s$ n- v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ Y! V. B' ^) y9 J, y- Q- S1 Y
if (ret)
5 q l2 s: L2 `1 P. F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- i" l8 D" P, }. W8 Y7 { "%d\n", ret);9 M4 v# o7 n% y9 ]- T
#endif: k6 w0 o* }. F7 u. ?
ret = platform_device_register(&da850_evm_tl_leds_device);
/ C! f% ?. V% g( i \$ p8 ?; ^ if (ret)
* \- C$ o3 f" h pr_warning("Could not register som GPIO expander LEDS");
. e0 {) J/ d! d% U else2 Y8 X# |2 \8 P7 i
printk(KERN_INFO "LED register sucessful!\n");9 @" K7 F, i, m3 }$ s8 u. f
. [. R* e5 V* l2 q* a
return ret;7 v& @) a3 V( i
}
# V$ g* m3 [+ s; B" ?8 X5 {9 P& b
, k8 A6 Y8 M8 J5 ~8 U5 dstatic void __exit led_platform_exit(void)( d% S" ]. a5 i. Z& k5 f" V
{, K( I7 z2 j s3 R& A
platform_device_unregister(&da850_evm_tl_leds_device);! h( k; D5 ^5 k; p6 h
+ Y7 {% M1 h% G& O
printk(KERN_INFO "LED unregister!\n");2 o" U$ }& k2 Z; T9 d
}
# z$ H( T; F- G; v- P) `8 p% q4 b4 I$ i
module_init(led_platform_init);+ G9 q4 l$ b" l( M4 a
module_exit(led_platform_exit);
1 D; |5 @' c% Q2 p$ \6 g& ?" a3 O" g) H& P- n
MODULE_DESCRIPTION("Led platform driver");
( [0 \" {$ k% ~! }MODULE_AUTHOR("Tronlong");' c& Y* t% l( \, {3 d1 u2 g
MODULE_LICENSE("GPL");
/ k. X) @% _6 G. X3 A3 Z/ x) }3 t
0 o" R( B( a0 z. ]; o9 |; f9 J9 b |
|