|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* F, F p1 W5 F) t
#include <linux/init.h>4 Q# G( G# p) r5 q! _. t
#include <linux/module.h>
: a2 N, T1 z1 r1 R6 V#include <linux/kernel.h>" w' \( s! O/ V
#include <linux/types.h>
: `/ y; w" W" T3 _. ^: J#include <linux/gpio.h>9 ~7 p) I6 Z% W7 k& I! Y! ]# Y0 M6 e) y
#include <linux/leds.h>
, Y0 S: r" {2 G# U; b4 M/ z#include <linux/platform_device.h>
2 Y% P# \! A& U2 S9 n/ c
7 i& h3 c) _* g9 Z6 W) o/ r- P6 @#include <asm/mach-types.h>
# K2 N/ F* b2 [0 B- z#include <asm/mach/arch.h>8 s+ h% s7 P' p0 f: M
#include <mach/da8xx.h>
I* K8 }7 `7 U' _' |; n9 M#include <mach/mux.h>
6 @" K4 ~/ G4 r2 t. o- f& o- i0 Q
% T/ ], {8 j, r: T0 @2 X# ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): w6 e! @6 y4 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; n# j' P! H; o4 s4 c- c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 k" s' u6 j( r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 {6 z. f* J5 Q+ Y
u M2 S2 I$ R; D/* assign the tl som board LED-GPIOs*/
2 V3 b* w9 p. {6 G/ a+ Sstatic const short da850_evm_tl_user_led_pins[] = {' }; @/ n* I3 o- @; ^6 r5 c
/* These pins are definition at <mach/mux.h> file */% I# E8 p3 I: ]& l4 o! _- j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- d% R6 u. d8 j8 B7 h: }- W U
-1
2 I+ m$ H3 D2 Y1 O( C* \};/ q; X- X# \' }+ M! g+ k
. Y, P7 f# x, V, `! k Q
static struct gpio_led da850_evm_tl_leds[] = {
7 ^' _! C( e6 V {4 e2 w/ W$ q* @: ?+ V
.active_low = 0,
, z/ l' T" m. A2 c, H: A .gpio = DA850_USER_LED0,
& g$ l. ?4 q7 p/ Y: R& R+ V: Q& W .name = "user_led0",* E* `, S( V; l0 |- j4 S
.default_trigger = "default-on",$ J' u+ @) @. f! S+ r% |, C
},
" }- }+ F1 ]" F+ ^6 X {8 J f* h0 Q) R2 K
.active_low = 0,$ k5 r8 F5 Y1 s3 Q4 L
.gpio = DA850_USER_LED1,4 y" H1 i3 b/ ?6 M2 p% _& [
.name = "user_led1",0 `: C" b" l5 @1 N3 S0 J7 }9 j' k
.default_trigger = "default-on",
1 P0 r0 T9 `" g* j) r },
9 P9 m( z- T) t {
4 @- j! D% o) E( T! ^5 n0 Z1 X .active_low = 0,
1 p0 C/ G* r$ ~( l- [ .gpio = DA850_USER_LED2,
6 \& J% t* V$ l- ~# z \$ f) r .name = "user_led2",$ d! A- B1 q" s3 n' K
.default_trigger = "default-on",* d" O- h, J7 \
},0 D D% _+ Z: N3 n. M; y" L$ c" ~
{/ R0 P" s' ?& U# j" H- }
.active_low = 0," ~# Q) Q9 V1 ^4 R
.gpio = DA850_USER_LED3,2 Z3 j+ ]& t; r
.name = "user_led3",
, m1 R3 M, h0 I .default_trigger = "default-on",& l5 q! \. D0 |3 d" a! Q
},
6 q# ^* ^' G+ [! f) N+ T Q};
" j& I7 f/ h+ m4 ?! h6 s; Z6 Q+ v1 p+ Z$ u- p# {. r7 L% F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( \2 O2 z) f% F; F' e" z
.leds = da850_evm_tl_leds,
9 a5 e9 m- A% e! t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ g2 K5 K, A/ d- b1 N/ g/ x
};
) Z! {1 _( t, W8 p
) g+ l: x) l0 x0 y* C3 F. istatic void led_dev_release(struct device *dev)+ I s: U9 F3 I% C* k( P% {( H- T
{
6 T$ T+ Z- Z) x( A& l, ^};9 Y! |7 m" |9 h' J4 l5 u, \
0 e7 C5 [9 h+ Ostatic struct platform_device da850_evm_tl_leds_device = {
* b* V5 i) F- w q, { .name = "leds-gpio",3 f5 N/ k' Q7 G: h/ x ~
.id = 1,. m( F6 e0 T4 ^- x0 h
.dev = {9 K; k8 R, Q$ ~% R
.platform_data = &da850_evm_tl_leds_pdata,
7 @7 l+ j4 Y7 u5 {: p, q4 ^ .release = led_dev_release,
& _; n% O! K3 e- ^ }
4 F) o( W* \* q};
( U7 x+ Z( I' L$ l# U. Q- B
% N8 P* W/ Q; d. `0 tstatic int __init led_platform_init(void)
, k1 X7 f/ v/ T v{
4 J" G' o" Z# j0 p# P: I2 \$ } int ret;/ u: j) k) l+ B" s5 k1 K4 Q
#if 0 F' i ^7 O7 i8 m1 _" f. `. y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 z" F. @& c$ t4 Z
if (ret): Z! ]1 o. y6 a& N4 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 J' ]$ P: O6 U. F" A "%d\n", ret);
. r* I( o5 L1 m6 W0 s# g#endif
) F2 c- t/ \/ j8 Z' l ret = platform_device_register(&da850_evm_tl_leds_device);: u; n" k7 S b# L7 k) D$ T/ y
if (ret)8 {4 f( I0 V+ R' b
pr_warning("Could not register som GPIO expander LEDS");# s& ]1 D I, v
else
7 S7 I/ e( _' B% f0 P0 V6 c printk(KERN_INFO "LED register sucessful!\n");
. p2 z. E8 P6 Y0 k' r. y8 V
/ v! K2 d- D, N' ~7 n! U& O return ret;+ o1 k) W* v) w* b0 h0 E5 v
}1 @4 `. ?( O1 t7 H x( v `
6 E3 \7 [: l9 ?4 {+ ?2 o) Fstatic void __exit led_platform_exit(void)' Q4 d- _$ H5 z$ \$ k/ j
{' U$ ~; k* \! U/ a6 O) U) L
platform_device_unregister(&da850_evm_tl_leds_device);4 t* E: f7 o ?
4 |. \ \& [0 r, c printk(KERN_INFO "LED unregister!\n");( f g: T7 t# x, _+ A8 z# [5 o
}0 _- y" Y' ~ Y6 ^" O4 N# @" w: _$ a
- p; z$ n- q7 M$ r
module_init(led_platform_init);
: g O; D" C3 s0 R" @module_exit(led_platform_exit);! s( \ }' E, k! K
% A3 a; L8 A- G; S; f& T8 }/ i
MODULE_DESCRIPTION("Led platform driver");$ u0 \( M2 p I
MODULE_AUTHOR("Tronlong"); m2 i- }8 Z( ?9 Z) I/ C; _; ]' h
MODULE_LICENSE("GPL");
$ u I; ]) G6 G* @& X8 C- T/ K( M7 B
|
|