|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 z3 k `+ C* C7 s6 i+ g D
#include <linux/init.h>6 A" _5 h" H% {" \2 H1 ^; C9 A% h
#include <linux/module.h>3 W/ n: F: i. w3 p9 V
#include <linux/kernel.h>$ H+ k z) x. g) A
#include <linux/types.h>0 Z5 ?! v4 l6 Y; L7 Z+ S* E# j
#include <linux/gpio.h>
5 V( C6 e6 P( h" B M! j& ]#include <linux/leds.h>
& D# v+ O( a: a9 _#include <linux/platform_device.h>& x/ D \2 k3 |' G3 n, \
; g% U; |" u2 D/ b/ q
#include <asm/mach-types.h>. a+ u9 \8 T" g5 y& I8 Z( t
#include <asm/mach/arch.h>1 ^ s' ]# w+ @
#include <mach/da8xx.h>
Q/ m6 O, x& o1 ?; a9 ~& s; F4 D#include <mach/mux.h>
" }1 [: K4 t: Y* L& p' v1 v
, Q7 @: a/ E* f( w1 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% N! V* `9 V' y6 S8 r- y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! R+ T. ?# {; v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 \* o( t+ L5 ], s2 A3 i. R/ k# a' ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 l: z+ Q' f' a6 d$ [( F; G3 t7 M4 e
9 \) K, V& w' t+ O# N& n3 U" E/* assign the tl som board LED-GPIOs*/
6 I! ^8 U/ Z A' n; y2 T* j0 Gstatic const short da850_evm_tl_user_led_pins[] = {
+ I7 _( q+ _, E7 `! J9 s /* These pins are definition at <mach/mux.h> file */! B& P# A, D/ Z/ X/ ^2 P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 p7 G) `* m3 e* L -1
+ m' x, l u- P};
% X- H2 _! E+ j1 I
7 `4 x2 v7 o, \5 e: D, ]static struct gpio_led da850_evm_tl_leds[] = {
' j" z3 z4 T4 {) q H/ T! K {4 u5 k. @% p0 l* H2 U4 y% N0 `4 m) M
.active_low = 0,
6 V7 x% O0 a6 ~# O .gpio = DA850_USER_LED0,! Z6 r( B- R" V. T
.name = "user_led0",
; b% E7 C3 O4 H/ o" W8 T) e# | .default_trigger = "default-on",
8 ]$ F- m( c+ Q9 r },; x& g& F+ V! x n0 a
{
4 M' p/ W# d V2 n ^ .active_low = 0,
/ D* g" N: f% `5 k7 F l) M) ~ .gpio = DA850_USER_LED1,
9 _; G' w3 k. }+ E+ v .name = "user_led1",; o! ~; R4 D. `
.default_trigger = "default-on",
+ ^. }! [: O, V! u, C },& t' y# }! L Y$ \$ C# y
{
( M8 e: j4 U& J5 k+ _1 I | .active_low = 0,
h% ~: T2 M8 N% R: k .gpio = DA850_USER_LED2,$ ^1 ]/ r' q0 j; \" \; F
.name = "user_led2",- W1 }. {( H/ v8 o
.default_trigger = "default-on",# Z5 M/ k* \( J1 x l% v. k" o
},
$ R y0 i8 ]' h& Y {9 ?, _ }- U( @) @
.active_low = 0,( n S; H. ^+ v0 h& I0 f
.gpio = DA850_USER_LED3,0 R3 }8 q% S3 I% }
.name = "user_led3",% E; v: v) ^3 `2 M$ H
.default_trigger = "default-on",0 c, W& g5 n+ t1 X3 o
},
* k9 b {) a* f7 t5 U+ j};" ^4 y8 Z6 Y0 n' {. Y* n* p
9 X" Z. \- L1 \) W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" \# y- S9 M M8 X
.leds = da850_evm_tl_leds,
3 m" _9 e* U$ t b- x% j5 f, R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 g4 `4 i! Y u9 o- [2 H};1 k/ x* d$ z/ G
; H* |1 A9 O& m. |7 N" g, `
static void led_dev_release(struct device *dev)
, [+ I) R+ [% q- y{% ?' v( w8 w) \# N; d9 ?
};, ~: x9 }3 q3 S, N; `7 t( G
, Z: x& q: `6 r# g
static struct platform_device da850_evm_tl_leds_device = {
- Y% S0 s7 P8 M. O .name = "leds-gpio",- |% F, Q4 L5 i! O1 c( k W, M
.id = 1,0 Z/ f6 A9 k0 L7 i; B
.dev = {3 |9 Z/ X5 y: j4 f0 ]+ w
.platform_data = &da850_evm_tl_leds_pdata,
! |/ ~$ Y5 n1 S& t6 Q n1 g .release = led_dev_release,
& B" B! o$ s( o0 J1 c$ f. y* M6 L }+ G! K( r5 E/ z. Q* X. p
};
- R, y0 z; n6 x& b* R' l# D' }: f4 u2 o$ w' W* P3 Q9 s
static int __init led_platform_init(void)
8 t6 r! w ?: X2 l! J" Q; Z{% j9 [, [8 \( ]/ _
int ret;2 n9 X7 U2 N. ]# h" |+ X$ x: {1 z
#if 0- M) s1 o% c4 ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: \; {; C/ ^8 [5 j# S if (ret)
1 X6 w4 j7 [! ~3 T4 U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 u# M p" T5 g/ N
"%d\n", ret);
8 Q( W E" u3 ` s1 r* ^, Q#endif) p8 K' s6 U: r! a4 A
ret = platform_device_register(&da850_evm_tl_leds_device);: Y9 b2 P9 O6 \- p
if (ret)1 X+ g. ]# F7 ]" [3 g
pr_warning("Could not register som GPIO expander LEDS");) L$ u4 F% Z+ {! h9 S& {. s
else
: U. P n; f& [ printk(KERN_INFO "LED register sucessful!\n");
, |7 e/ ^. S( N# _+ l# Y$ x& f7 g0 a7 _0 s
return ret;
8 i6 W' \8 k9 \7 `}
, O( F ?1 h# N1 g' o* B$ |( [- y p9 h& O0 t. P C
static void __exit led_platform_exit(void)0 [+ u+ W D2 k. W" o @0 B7 u
{
9 H7 l; Q, A% O5 j7 k" H platform_device_unregister(&da850_evm_tl_leds_device);
- n" ]8 i, N) `: i( R @' a6 c% ?9 [; x; x) x
printk(KERN_INFO "LED unregister!\n");
: g" i( y& \6 Q8 b* F" t}! p, Z& w- M4 a6 J: J+ C4 k2 n
+ w+ T& N! o7 x7 j5 O: `. m5 \
module_init(led_platform_init);- j+ r# r, o! F# m7 H$ M
module_exit(led_platform_exit);! g7 t1 ?6 `8 R; a
# B0 t1 w: ^9 f* @2 O
MODULE_DESCRIPTION("Led platform driver");
2 ?. m5 l# s& b0 c; `* EMODULE_AUTHOR("Tronlong"); q) k1 U2 Q I% w: A* a* s
MODULE_LICENSE("GPL");
! c% G- G! _3 {6 P7 ^, W) d/ i7 }- b# a" t2 i. k+ y; ?( Q
|
|