|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' j6 p) K3 l& G1 I7 W1 P/ ]& ]#include <linux/init.h>
9 `1 X( h) f4 o. U! {; z#include <linux/module.h>
: h" x. Z. j; E' r6 l2 g" I' F#include <linux/kernel.h>
9 A2 H" V1 P% ^) l/ i4 A( |#include <linux/types.h># l) u) ]4 U" ^4 s5 {4 W. B& \
#include <linux/gpio.h>2 R0 \( _# {: M
#include <linux/leds.h>9 S6 }- \2 _. g- l: y9 w$ H. `, N) m
#include <linux/platform_device.h>
. i( w. H# I; b, Q% c
" N n5 d9 y; g8 B4 [4 k6 C#include <asm/mach-types.h>
+ Y4 U( L! q* B#include <asm/mach/arch.h>
& O/ ^ A: H" F* H5 `4 D#include <mach/da8xx.h>
3 i9 i; R# \4 m; O#include <mach/mux.h>. e) u) v4 G4 H( H0 H7 z& L
4 j, A: {! U f4 K, Y: n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* o# P7 s1 ^4 T; A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, {5 ^6 J0 t5 @9 X+ A4 l* U0 R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), `1 T7 }: _7 [% ?% q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 t$ {% J) \; ^- t" {6 F1 c$ o# x" w
% g/ |) @0 ?/ v9 `. B- D T+ }2 r) |% I/* assign the tl som board LED-GPIOs*/9 Y) C% T) a9 W
static const short da850_evm_tl_user_led_pins[] = {
7 a( x3 q: v$ A6 F$ G /* These pins are definition at <mach/mux.h> file */
, a0 _( V/ p1 N' m& b M3 {; d% t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 F! X+ I) U! f( K! B
-1
% v- l, p4 X# Y7 K};- M% G$ a1 r4 K& a% z
; j/ f7 Y/ Y. Ystatic struct gpio_led da850_evm_tl_leds[] = {
/ U- ^8 A! o2 u& c {
5 {; d( j# J+ q/ A& B& u% U .active_low = 0,
: D1 Z+ o2 w5 S4 y% H .gpio = DA850_USER_LED0,5 E8 j" S2 D; B; a/ f
.name = "user_led0",: U& C' f/ a$ j) \
.default_trigger = "default-on",- x0 |( C9 f9 E( T7 L: Q. {# E
},7 n: K$ w$ b; H( @; e2 j, j9 o _
{. _. i1 W' U7 S; I9 [6 @% K
.active_low = 0,
. ?# l* h6 E G5 u .gpio = DA850_USER_LED1,
; ?9 K; V3 C( z) i# s4 e, c6 B .name = "user_led1",
9 j( ]/ e$ y+ Z- l9 B- A' {6 |. h9 Y8 { .default_trigger = "default-on",& O. _ [) G: N1 R( L+ G6 C1 M. m
},. q, k' A/ q% \, ~( J" `
{0 s& ]6 g0 A4 }5 t
.active_low = 0,9 f) I0 k& l1 J S+ N8 ?1 E. f
.gpio = DA850_USER_LED2,
7 [- V: Q; t0 W; l% ]6 ?: u .name = "user_led2",& e( H; H6 b5 Q8 P9 ?! ]4 M
.default_trigger = "default-on",
$ @- j3 i8 E2 I: h0 C M },% {( H+ J8 F- J; z/ u
{1 S |$ v" B3 R
.active_low = 0, f/ D- T7 ]) R
.gpio = DA850_USER_LED3,
8 z7 A' T2 u3 u% d/ n .name = "user_led3",9 ]( k7 A9 K. @+ O, Z9 p$ z
.default_trigger = "default-on",
5 _# M Y7 d4 v3 n; C },, ^1 l. A1 p* Z; m% l( t, C w; x
};0 t) g0 e" Y e5 H( W" {
/ s# y2 f4 u6 V- l/ ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" s1 K p$ q* Z5 m0 M( ~ .leds = da850_evm_tl_leds,
4 ?- G& @2 {. r' ^3 f, d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# U. Q, r5 a4 V, {$ x, F};
0 Z4 h& h+ p: a% N: W! i( b0 e) m$ H% f, R! X( e+ m
static void led_dev_release(struct device *dev)
! j9 b5 d, g4 |& k& i8 _* K{6 U: C7 E' [' I6 [+ X- r: ^
};
* w0 ]+ P- t3 k1 a/ G. `% f/ E& U$ U3 Z( J% t
static struct platform_device da850_evm_tl_leds_device = {
. k- a$ N. A' H r# J% a. v6 f .name = "leds-gpio",; @6 T* n, ~, }0 \1 Q
.id = 1,
) p5 ~ u5 E! Z: Y O .dev = {$ U3 w0 x: F: ]
.platform_data = &da850_evm_tl_leds_pdata,5 S4 I* k: Z' M1 ~
.release = led_dev_release,( C" Z0 V0 B; L0 k0 t
}4 u' {) L5 \" ^' X5 ~' q8 G
};
( S! J G& X: Y% Q) L. s
, J' O6 A* z, D; U. _2 o/ vstatic int __init led_platform_init(void)$ E2 j( x# q. b8 |3 @# _
{
; z4 n( p, u% M int ret;+ N% E- @" O( _' x
#if 0
. h) U* o9 W6 e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; Q- r! }! B P9 k- u1 y( g
if (ret)
& M" x% L: z9 f0 n2 t+ { c8 U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( z% @: \2 f9 t; R5 d# |9 R
"%d\n", ret);
$ P1 }# ~3 A" t1 A3 e2 S$ S#endif2 n6 {' d- _8 M' }
ret = platform_device_register(&da850_evm_tl_leds_device);0 |6 |: j6 \$ b
if (ret)
8 L4 P9 ^. L( c pr_warning("Could not register som GPIO expander LEDS");+ L! c8 d; v# W
else8 D& ]" M K. J7 N
printk(KERN_INFO "LED register sucessful!\n");
9 L; P8 @* Y+ o' U( m) Q# K# s: s1 s. {& F6 R' y
return ret;5 K# O9 J) \ \5 Q# X4 \5 k
}% A8 f1 M0 B. q% v
0 F- z) p( j0 J4 c E# t
static void __exit led_platform_exit(void)$ D0 m' K4 Z! H$ n1 z# ~
{
! ~7 U; W' d* e( x) h! b platform_device_unregister(&da850_evm_tl_leds_device);& K+ r* u- f( a# Q; m; W3 c
# {* X, U" f H7 a+ x) T
printk(KERN_INFO "LED unregister!\n");8 B& m. c* O! \) Q
}6 S: k2 R" O7 M- m6 F; s% m% \
0 Q) C1 F1 ~8 }5 {
module_init(led_platform_init);; l3 z: Z8 m4 W1 h$ u; C
module_exit(led_platform_exit);, Q% e" X" T: u
5 W. R$ ]/ L1 G' `! a' @
MODULE_DESCRIPTION("Led platform driver");
X# M' O" H( ?8 r. D9 L2 S3 rMODULE_AUTHOR("Tronlong");
6 k* e6 G% I/ o9 s/ y4 LMODULE_LICENSE("GPL");
" a4 ?7 C* g2 R+ r5 G- }2 o+ c" K5 p* {
2 P/ G# G( R$ K: I |
|