|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 |) H+ h/ m) j( c! N2 y#include <linux/init.h>
0 D$ B: s- n( L7 @' b7 y#include <linux/module.h>
3 t4 {2 J: W. m: v- ~" e* B4 I#include <linux/kernel.h>/ c, R! G0 U p% c! A" t# @8 A
#include <linux/types.h>
- [9 p5 k. j, g& \8 @#include <linux/gpio.h>) ~3 T* c3 h$ F. _5 ]
#include <linux/leds.h> q# D5 H$ @% n6 w8 J! e; u
#include <linux/platform_device.h>6 Z; `" J* e: Y
/ E l4 |0 }. r+ h) y" f! a2 I: w
#include <asm/mach-types.h>
2 p6 t) F$ n0 h9 ~" v#include <asm/mach/arch.h>
4 }$ o# H) |5 R1 Y* k, o! A9 F#include <mach/da8xx.h>
1 `; A. J; P5 b" }#include <mach/mux.h>
. k" T+ \. r/ \' @+ w; S" e7 X; y- L$ q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- [" O9 O. }& e$ ~% t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- s3 J. O! C1 y D/ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ C5 T5 P5 e& d% H- t" k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. h+ v, {0 `4 h1 j. N
( L4 V6 y8 e5 E3 V* L/* assign the tl som board LED-GPIOs*/
9 h9 G8 j2 a. I+ {( t- Kstatic const short da850_evm_tl_user_led_pins[] = {
" ?& G8 _7 z* @ { /* These pins are definition at <mach/mux.h> file */0 o* r/ o0 {2 E2 I' E6 D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 i+ o0 w0 }" U( a -1
3 P+ s8 d# X0 S& q: O};
9 f% f2 U8 ?, \2 A1 g! ~# Z
1 T6 X- d! d* V3 b4 j" B6 nstatic struct gpio_led da850_evm_tl_leds[] = {
- s' ?' M7 O Z5 f! {' z/ C {
& o- m5 W9 a9 v0 @# s0 S .active_low = 0,
* h* G/ t/ |" _4 \1 V8 e# A .gpio = DA850_USER_LED0,
( G1 W' @7 A9 o& M6 ]" i, b3 f .name = "user_led0",
6 b9 H& ^8 |2 e .default_trigger = "default-on",
3 n5 T/ y: W" E$ w) Z: k },' S0 ?6 D/ q! f& V9 Z& {: O! i
{. P, e: U3 }* f$ U* x; V
.active_low = 0, h( S4 i m% Q! h% d" E, o
.gpio = DA850_USER_LED1,5 d+ F% O$ E+ V' u X4 L6 h
.name = "user_led1",
u0 |* L5 F* Z: C2 v .default_trigger = "default-on",
: `9 q. _1 q: e$ G! M9 v: E },4 K. N6 S( {; t, D+ Z) z
{
$ Y4 n3 d# B& ]5 \1 E .active_low = 0,, \) e" C9 s$ F' A9 a
.gpio = DA850_USER_LED2,: [. V+ V$ Y& S+ \3 W u
.name = "user_led2",& m& d( x1 I! ?. x, g- b9 F% N
.default_trigger = "default-on",1 |( M8 G( i' ?5 N
},4 G1 F6 T9 J9 W9 f6 M
{5 C% j4 Z# M% W c' h5 V+ m- G& u
.active_low = 0,
* {% x d) m( S .gpio = DA850_USER_LED3,; p2 F" b1 h8 m" \- ^0 s
.name = "user_led3",3 _# @$ L, \! F' f' E
.default_trigger = "default-on",
2 N) P; V( u7 J B6 V },5 R5 M" f/ G; t: @ Z' Q
};1 ^3 I; _+ `! q6 }) A$ S
; N& M6 b5 ~6 y3 e/ h/ o: a$ c% l. {. e7 x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 ?: R1 d; ?+ l4 ^8 v$ e5 T
.leds = da850_evm_tl_leds,2 ~7 D8 e; Q F3 p; _" R3 l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& X: h' U- h. |$ v7 i
};
7 G {* X3 k; N* x8 a& O
% h" O1 U" B0 n7 N: T- p$ ^" bstatic void led_dev_release(struct device *dev)
5 D6 V$ @; I( o+ c+ p v9 t4 y{
( F* l- e2 H" N};) h1 A9 o3 {; u# V" F6 Y) a4 k
6 y. j& t9 R- D' s- `3 ~. D
static struct platform_device da850_evm_tl_leds_device = {
% o* ~$ g4 R' ?- E .name = "leds-gpio",: W4 q5 p; s- y& o! \' k+ I# p
.id = 1,1 X: `. n) E4 Q+ }7 X
.dev = {
- l# G" s5 t4 V/ \7 _. _; \: [ .platform_data = &da850_evm_tl_leds_pdata,
6 Y& S$ L$ U% l$ ~ .release = led_dev_release,; [( j y0 v& h1 `: {# j- J
}( E- @' |- m' ^( s, x( }8 B0 D1 ]
};- S. g+ v* v9 h* D* E. t" S6 J
/ `/ T1 o. ^/ @8 E) Q. ^3 Nstatic int __init led_platform_init(void)1 U/ t5 o- H8 d, u
{
& {, F6 L1 D8 t4 I/ m5 @) c5 f5 @1 C int ret;8 Y. T, `* {% M; V
#if 0. C8 a! m+ F3 t. W1 P5 J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: T1 o, \1 B( ` if (ret)( s. e) ^' `, d/ V" F8 r! t+ `$ C( M" e) g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" M0 ^- K, P% r2 a% c) x3 F% k "%d\n", ret);
^' X3 z' C! ~9 h#endif
- z) l/ g0 [$ ^5 T- I2 o& P ret = platform_device_register(&da850_evm_tl_leds_device);
8 G; w' f8 M5 o0 h9 z, S if (ret)
4 J. |; |3 w2 e+ y D- ?# h- w pr_warning("Could not register som GPIO expander LEDS");
! X8 U3 S4 t; X' K! ~7 K1 @: F else' G- l+ c$ z% z' s: C4 ~/ H; R3 U
printk(KERN_INFO "LED register sucessful!\n");
8 x2 {6 K' y* x- i% l# [4 }8 T6 [! J0 M- l4 P0 D3 A, D0 y9 ?$ H0 ~5 A, g8 M
return ret;
" x0 P- v, k# Y; H# V( p7 `}. D0 l" H. Y$ k
. B6 v3 i: D+ J C8 t4 W5 t2 Vstatic void __exit led_platform_exit(void)
! q# `, r4 g! ]/ w+ r, e{
7 B0 f% \ h0 b, P. C platform_device_unregister(&da850_evm_tl_leds_device);& G7 B1 ~8 u, L% w6 H$ A- ~
- M! \) ]) y# L; W. f/ Z& U8 k; C printk(KERN_INFO "LED unregister!\n");
D0 p. R# T9 W3 m! }7 C}
0 G) N; b5 K# H! P; B8 [. a4 N, B% \
module_init(led_platform_init);1 v6 Y- \# q1 _, ^9 D- D8 z. ~
module_exit(led_platform_exit);- p0 o/ n: p1 p7 S
: y2 x! }% `3 B2 S0 b8 iMODULE_DESCRIPTION("Led platform driver");! X* _: |' G3 B: Y0 e! Z1 T' X
MODULE_AUTHOR("Tronlong");
+ f4 t/ D: `* r" y5 ^MODULE_LICENSE("GPL");
?8 ~1 D7 j# t( A0 x5 P2 T
2 A2 j% Y |4 x, T: | |
|