|
求大神给下面的程序做注解,请稍详细些,谢谢。5 C ~# F- d* [# C
#include <linux/init.h>' I" E, W9 y1 K" @
#include <linux/module.h>9 B; z/ A6 t/ Q, q, t
#include <linux/kernel.h>6 Y4 Y' a" F; e
#include <linux/types.h>
" x, C" P6 k( [1 M/ z#include <linux/gpio.h>
9 j. C8 W* ]+ v v& _# X9 J7 T#include <linux/leds.h>
8 Q! L. c: G( K& S#include <linux/platform_device.h>
* x+ f5 f6 C' T8 L
1 C: N8 w- j. Y3 g8 ^, g3 L#include <asm/mach-types.h>9 S/ Z1 `( Q0 O5 P
#include <asm/mach/arch.h>
% N' [0 l( d( X5 z% ]; _#include <mach/da8xx.h>: m, K) b, ]( G% p6 ~1 g3 Q
#include <mach/mux.h>
8 k* x- K$ ~* z0 N; c
* ?3 u; Y( ]2 m) l T' I; d. C6 A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 w3 }8 h* h4 {, E5 j8 ?" M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) N. H# u5 k; I' c! R, @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 y- c# b4 M+ x, E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# c- E( o: f$ A8 R$ A% I# ^! B6 A J
; I: |9 P' U/ ~+ m$ ]
/* assign the tl som board LED-GPIOs*/
) X0 n! F3 o. F6 o7 @: Wstatic const short da850_evm_tl_user_led_pins[] = {
& h; g5 ^0 b6 L) m* k /* These pins are definition at <mach/mux.h> file */+ w/ V+ t4 Z+ Z; `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 [( G( E8 t9 a L L) B
-1 f) I9 Q% y/ v/ Z! R3 h2 m& h
};
" J% L" y( t6 h$ C J. f& ~0 j8 F: l8 U5 T/ [4 X
static struct gpio_led da850_evm_tl_leds[] = {
7 ~0 t* O+ a# p2 y3 C& | {& Q3 O H# X% e- c8 t2 [ J$ x" T
.active_low = 0,6 a' A, Q- `) L: f) D" q
.gpio = DA850_USER_LED0,) Q/ g( P! J. a9 R ^1 D6 P( V
.name = "user_led0",
% r& `# D6 o7 Q! K .default_trigger = "default-on",5 e1 o, [! E. G+ Y9 _# ]. s: |
},
3 e! ?: T+ @3 p L% a2 {9 Q {1 C0 _8 N$ D7 b- E
.active_low = 0,5 @9 O3 a4 }# x7 ?! Z# e% e$ t
.gpio = DA850_USER_LED1,
' ?/ ^( y9 O/ ?; C/ d1 q .name = "user_led1",
7 [- @0 W$ o9 S2 Y2 [* d .default_trigger = "default-on",
- f& P% T D9 q6 p& \6 S7 z },
7 o& S$ J# m: E7 {! \ {7 x/ b* Q4 ?4 ]- C: }0 ]+ @
.active_low = 0,# G1 w8 E: _# d) z j& _
.gpio = DA850_USER_LED2,; W( f1 Q' V& X, S* ]" H
.name = "user_led2",* q" O5 p' M9 \- l6 |* _- M1 Q# q
.default_trigger = "default-on",8 ~# Z/ ^- f, ~% I" e
}, b! U, ?2 ^; j/ L
{, r4 k' f- a: s0 \( z
.active_low = 0,
) {5 u9 ?5 r; O7 O/ @0 \ .gpio = DA850_USER_LED3,
8 b- r3 V2 I1 i# _( w1 O .name = "user_led3",, V" V1 I, o6 E4 o2 x
.default_trigger = "default-on",, s; g( x( L( y5 A, _% l3 q, r. {
},
% U. S" g! m u# |& A$ X3 ~};# w1 q' X/ o+ S
/ m3 T" N" v7 q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 Y/ A' t$ z0 ]0 _: c/ R& E* K
.leds = da850_evm_tl_leds,
5 q2 x2 r+ p5 R! ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ v1 t4 E/ `8 |" a, P9 J};; J% {( M! M0 N) {: ]# t# [
* n3 m$ m" j' qstatic void led_dev_release(struct device *dev)
. t& g1 W0 M7 z) D$ d; C* L5 T: K{
/ }, T/ E* [4 g# y2 _/ E a5 z3 c};
0 u+ p& {: w+ X' n/ o& w5 D& b2 l
`; J+ Z, B9 x) A2 f7 s, o" y8 Sstatic struct platform_device da850_evm_tl_leds_device = {
1 S4 }0 [3 K$ u& R .name = "leds-gpio",
0 H1 P l1 ^; {8 _% Q1 Y, y .id = 1,) f9 K* h; e; ]& _" O
.dev = {, u; Y5 Q) V- W$ i) Y" o E, Z
.platform_data = &da850_evm_tl_leds_pdata,
1 A9 z, N$ E+ M4 A% E% a6 { .release = led_dev_release,5 B" H2 w) `+ J, I& x* w& v
}$ `9 K# m# q; j* g* B& S
};
; H4 f$ ]3 @; k5 k$ m
8 [+ D5 ?1 J0 l0 ~* Rstatic int __init led_platform_init(void)
( n7 R) e0 ~4 O( z{
$ p) o! T# l, T. z! X int ret;& N& o U/ M% v0 V8 ~2 q
#if 0
+ y Y2 p' }$ A$ D* O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% h6 v2 t& m6 B5 g: S7 |+ e* s
if (ret)3 y2 a5 B- O; V/ E; q. F7 V1 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" z# C6 s$ T b2 n3 x "%d\n", ret);
4 z6 I) ]: e' c$ P8 C0 K5 w#endif
# N# I3 d1 {% S2 t. |$ n( S ret = platform_device_register(&da850_evm_tl_leds_device);
( S5 Z! y# N$ s. w5 E E. ~ if (ret)6 |5 Y* |+ M2 c" _9 o9 `
pr_warning("Could not register som GPIO expander LEDS");- Z9 G! z, w8 Y% b5 c+ b6 b @- J
else
8 ~ R8 h8 N1 A; R- ` printk(KERN_INFO "LED register sucessful!\n");0 t3 y# j/ r' `2 k. l
1 y6 Q4 U$ {+ B4 [; y return ret;
% m" y- z* C% }2 r5 C# d! _! q}
3 U" p# R3 u" W. w( z. I: y( R) W1 C1 `
static void __exit led_platform_exit(void)
6 U3 Z% s, F3 u. V# i3 ^4 s* u) s/ s. N{
- V! {! q+ \2 X% i3 \- Y platform_device_unregister(&da850_evm_tl_leds_device);( x. K; y( c$ P
1 r5 i# m* F% ~ printk(KERN_INFO "LED unregister!\n");8 f$ X/ y; r" `
}. k/ a% W- E% H, w5 w& @6 ?+ F
3 H* J, L. n, o" N% G3 Z5 ^
module_init(led_platform_init);( D w% F/ Y5 d, Q, Q7 H7 c |. K/ y
module_exit(led_platform_exit);; [. G0 A9 Q' m" m
7 \$ S) H. r/ D9 R" q
MODULE_DESCRIPTION("Led platform driver");
* E) X5 ?' H. v, m% lMODULE_AUTHOR("Tronlong");) K, i: ^4 d+ W$ M
MODULE_LICENSE("GPL");/ p t! x* x/ M
3 J8 T7 I1 n$ c& x5 [3 t
|
|