|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 d# x7 Z7 V8 e8 c. {
#include <linux/init.h>4 M g% }( S- c& ?
#include <linux/module.h>
$ l, d, k d# v! I% ]& e; |" e6 G#include <linux/kernel.h>
+ m+ ~; L" L! f#include <linux/types.h>
0 D. X R D1 e6 W, Z9 {% E& s8 E* J#include <linux/gpio.h>* A8 ]7 B' g7 C! c1 |3 f: W( G3 t( I9 _- S
#include <linux/leds.h>
6 |* g( |% ~6 Q% `, y. b; S9 y* g#include <linux/platform_device.h>
3 ?, L4 {6 X: f+ C9 a$ _( ^# k: F2 n) @
#include <asm/mach-types.h>( `1 a+ m, G4 X1 O6 S, K
#include <asm/mach/arch.h>) n2 J. t: ]( @9 y' e4 g% l7 `
#include <mach/da8xx.h>/ C1 Y/ e5 i3 C# q1 `: a, W$ C" D, P
#include <mach/mux.h>
7 G& c) }' u7 n2 r8 w
. E: e- z- r) A9 q! W& g s) }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 Q' Z" ~9 i9 N) W0 U6 Z A! r! m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* P+ D: V6 j: a. U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" b* c# s/ w" v+ g3 u) X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ u( G7 l4 @6 x0 c6 J
" D( L/ u2 L# _! ]5 ~0 Y$ O# g1 W. p
/* assign the tl som board LED-GPIOs*/% f& P! f' D9 f
static const short da850_evm_tl_user_led_pins[] = {
( q2 f6 Z' b D /* These pins are definition at <mach/mux.h> file */
! V5 |8 w+ _" k" E1 s# d. N' ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, V+ l1 \, y. i) A
-1$ D0 m/ Z& T. h! }% m* i/ [: l
};: B9 q) G: b. d1 M1 N! Z( T
- f( h9 c* |) p. Q( B& g* t' Rstatic struct gpio_led da850_evm_tl_leds[] = {" ?$ y6 N: s# j
{ Y5 x5 J9 c- ?! p/ Y/ Q
.active_low = 0,
! [* l& L5 |9 x& v .gpio = DA850_USER_LED0,; ^7 F9 V. h2 V4 C2 ~+ \% U$ I
.name = "user_led0",( a0 t8 Y, b1 n* f b
.default_trigger = "default-on",( Q3 p' o6 t7 H* O: q* a
},5 |* t# \6 u& {+ f6 x
{
$ q: z0 `/ W( O) S: m8 }2 l" `, z .active_low = 0,9 `6 {' m$ H4 x9 a' w2 u3 |
.gpio = DA850_USER_LED1,
/ _( R% l Q3 d- C9 n9 a/ ~ .name = "user_led1",4 U l3 S' {& z
.default_trigger = "default-on",, K' Q4 r5 f0 T4 w2 y+ J
},6 a( }1 i/ ^& B- e) A7 u
{) W& q- _# y3 c
.active_low = 0,/ d5 G& M1 y# Y) k! ~
.gpio = DA850_USER_LED2,; F! t6 h0 k$ g+ U c7 S5 q
.name = "user_led2",, w0 ]/ p% n" U7 l! P; ?
.default_trigger = "default-on",
" r2 j, k8 A0 X7 h! E& b2 c9 p },8 s7 T! o7 P3 F+ k4 M& N9 A8 |) a; n& |
{* M6 k; o) y. t
.active_low = 0,$ ^# d6 k+ B' `& |: M: t
.gpio = DA850_USER_LED3,, I' J5 q6 M& ~ l2 Z
.name = "user_led3",
# A$ q: g5 L" q/ D: {! H .default_trigger = "default-on",
. Z8 G* X; @- P/ V$ w$ ] },
4 u8 a6 m1 b& \; Q};
; H+ Q" e- V! g: {) ]% @
: b# p S; R; ?: Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 u2 S% M' ]. B! j3 z% i" ^
.leds = da850_evm_tl_leds,
* b& n7 F% p$ d, ~: Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# `- h0 ~ u9 c- g1 V: s9 a" U
};
6 s' h4 G, F, U( u+ q- Z- \" L* \) v2 l3 Q, U% U' ]% G3 c6 q. @
static void led_dev_release(struct device *dev). L7 F. U6 q3 w7 s. j4 a4 q
{% D' v" A; Q$ O! ~) S( M
};
/ H6 o7 x9 t/ f& M+ C
6 D) \$ e) \* _% M) K6 `( V8 ~( c6 [static struct platform_device da850_evm_tl_leds_device = {3 s# ~/ K$ s2 _. Y8 b6 M
.name = "leds-gpio",
3 n, F D8 K0 S a* ~ .id = 1,
* v2 |+ Q8 c5 i9 n) L$ f Y .dev = {* J6 k2 [# J9 c
.platform_data = &da850_evm_tl_leds_pdata," m9 m9 n* |" h- S, @" m6 I
.release = led_dev_release,
* h) w" K5 O* x5 [) E }
" I$ x) N& r# f! s! n};
; \8 \5 ]7 v- k0 H* I) ~9 y" r! y0 ?6 `& B2 s: U; R! Q
static int __init led_platform_init(void)" Y( o# ?4 I; J# s2 O0 `
{
$ b5 c( C( V' D/ S& ^5 M7 ` int ret;
0 g+ `9 e- k1 a' K% u#if 09 i. D0 R) w1 y, Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: z3 z, v4 B7 k" |
if (ret)
+ @+ r! I" P- c% z$ y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% E* D1 @ P6 g2 ~! R2 A
"%d\n", ret);
' j1 y7 O+ J% O1 C#endif: ~$ _& ]% Y+ P2 Q7 W+ n
ret = platform_device_register(&da850_evm_tl_leds_device);
3 E: F, z* M( I( r5 r8 ~ if (ret)' ?3 D* C9 ^$ |0 y: l0 R: E
pr_warning("Could not register som GPIO expander LEDS");) e7 n: M: M; e/ `$ \' k9 S
else# c. K" M1 j5 Q9 ` V
printk(KERN_INFO "LED register sucessful!\n");( n$ y, a7 L6 [7 R3 [) ~ B
7 I) ?8 q) e2 V return ret;
7 a4 p& j7 k1 \1 T}5 C! ^9 c4 _, h: s' C$ a( E
* h0 h3 p7 z/ h5 U/ Q" j5 T
static void __exit led_platform_exit(void); L. \8 F# f, ]4 c2 U
{1 m+ `8 q D# x. s# F, M
platform_device_unregister(&da850_evm_tl_leds_device);
) C5 V) @5 r. E5 y) S" }2 X; s8 _/ _
printk(KERN_INFO "LED unregister!\n");+ W0 k' r/ b7 u# D+ F( I7 |: V
}
q: x* k7 Y) B0 E" Y, z2 `- [- F& ]% {; T4 d+ k: G
module_init(led_platform_init);
n5 K, D. g4 k9 w* v* kmodule_exit(led_platform_exit);
/ {! d; T! D0 ^8 V+ q' e( N' j% U
MODULE_DESCRIPTION("Led platform driver");
5 z" c; i# o8 H5 l( K! jMODULE_AUTHOR("Tronlong");
, j6 V' {' ~3 D9 nMODULE_LICENSE("GPL");
8 R% K+ {( p7 z0 ^' t' X5 p4 c3 ^ r( l! \; s3 p
|
|