|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- u: C& t+ [0 ^4 U4 w
#include <linux/init.h>
2 a7 \* ] `9 u6 Y#include <linux/module.h>
7 r/ O4 X' f |7 h- h#include <linux/kernel.h>
* C+ v- t; Y& s$ j" |; E#include <linux/types.h>
* Q) l* u8 F4 Q u#include <linux/gpio.h>* ^. i- c4 P& C. R! [1 R
#include <linux/leds.h>" c, Y3 Y6 g" } @# X. e# A
#include <linux/platform_device.h>
, W- b7 x: y4 Y( {) k6 k4 X
3 Y5 X( ? w8 v o( \2 e" Q4 k8 v$ h) J#include <asm/mach-types.h>
# s& m, F: K6 E6 v3 n4 a- \2 u8 s#include <asm/mach/arch.h>! v1 H8 V. p/ b: @6 i4 C: W
#include <mach/da8xx.h>2 f$ N# J t x$ u$ q
#include <mach/mux.h>
* T4 {0 B- `% g$ R U! M' h; X, B
- b1 w1 y! h8 @, |! I- ^* }3 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# @1 n1 s; N* Q6 M9 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 [" G2 k4 D U1 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) ?# {" L* Q. k# q ?, J8 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). ~6 |+ x4 I& n2 I: N: S
' N0 R5 Y4 }; ^$ M5 c/* assign the tl som board LED-GPIOs*/
B' }* w6 u: H, Nstatic const short da850_evm_tl_user_led_pins[] = {
1 a+ t$ U0 m. J0 F2 }8 n /* These pins are definition at <mach/mux.h> file */
% F% ~0 t1 X- I, o: ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ K* _' Y' t9 Q, |5 O0 D1 I# z -10 F1 P7 X% y6 k7 G, q; E2 K
};
$ t7 x, R2 A: E: ~% x, b. i
3 E( F4 k' Q: ]! Qstatic struct gpio_led da850_evm_tl_leds[] = {
# z4 u! K/ r6 I {
: |# @; T" v+ j) k .active_low = 0,
) R" B' ^1 P' ^( q1 A/ l .gpio = DA850_USER_LED0,
( y8 N. v7 C4 x5 T. Z5 M, [; G l .name = "user_led0",
# X. a ?9 p) D' V# O .default_trigger = "default-on",& @3 Y, V- w' C0 B! X
},0 f- {3 H7 }+ L
{
( P! K; F( a' ]% k4 ]0 D% e+ `2 { .active_low = 0,9 J, Q% e' g9 Q, P; D" {1 r9 ~
.gpio = DA850_USER_LED1,
7 Y; a( D4 C2 ^( D- J6 l .name = "user_led1",
4 L' ?8 H, M s+ S9 e .default_trigger = "default-on",
% b2 d- z* x6 G1 Z7 S3 r0 l( g1 R },5 A; w$ D! a( _# S( |
{. Z: S9 x6 U2 t2 k+ G7 Z
.active_low = 0,: g! O( l+ l5 i: Y
.gpio = DA850_USER_LED2,, J& j$ I' u9 m1 ]
.name = "user_led2", l# w2 j* c7 E, {
.default_trigger = "default-on",
4 s0 G% G) [. F# O },
6 N+ C+ t( S, ~ {; r% P# x3 R( Z% g+ j
.active_low = 0,) P) @9 m& l7 X1 } t) Z9 z
.gpio = DA850_USER_LED3,. P0 \& g# `1 L7 Q
.name = "user_led3",
1 l) k5 Y8 q! `$ n) O, f7 ~, ` .default_trigger = "default-on",
8 I5 k* @0 D w1 V* K },: h$ K9 }4 W7 D4 Q" o( _* ]
};
) g( X1 N) J4 @: j; O5 y- U
1 e( R& z, A; S4 o% e7 k# Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( Q% V h N3 ]; _+ r' z
.leds = da850_evm_tl_leds,
2 Z3 n. ~; J: C: c- M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 R i3 `, e) P& w. m* n% I: X};- e& l% H& i( G8 e( L) q
; T2 V' y- ]! s0 n( Y/ Hstatic void led_dev_release(struct device *dev)
$ B) b) g! g2 a+ u$ }7 o{
9 X9 S2 H! T1 }. I# G% f6 S};
7 }" O% [* Q: v' c+ Y( Q
5 y/ L2 s0 q5 I2 Mstatic struct platform_device da850_evm_tl_leds_device = {/ }" x0 B0 a0 \) x2 G
.name = "leds-gpio",
& c% f: `& y% R .id = 1,
7 C! ^1 {$ s9 {/ W .dev = {
) D+ K# t" |3 _) O- b: g: j .platform_data = &da850_evm_tl_leds_pdata,
7 |) \- x$ u! u4 r .release = led_dev_release,
" j Z" q4 R8 q }# y. V, Z: J1 F1 s
};
# t5 L2 e) `: A5 `$ J0 h; Z7 d7 F* L4 \# d
static int __init led_platform_init(void)
9 W7 _( ^/ R+ x( D{5 g! {4 r+ I5 |, Y& T1 K
int ret;
" r) J9 H' y2 L' s; b#if 0- [/ l4 s+ m) |0 s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( K5 E, U6 Y4 [0 Z/ u9 E
if (ret)2 h$ z% S: J! B! h* M( Q0 d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' a3 Q" V, o- R) H+ C9 i "%d\n", ret);
# o9 ^6 I ~, O' c#endif/ C$ j4 h p6 {+ r8 U7 _8 j$ F% l
ret = platform_device_register(&da850_evm_tl_leds_device);
; U1 U0 Z: v% d, H6 u if (ret)
0 \+ i( q9 {% _9 q! u( F pr_warning("Could not register som GPIO expander LEDS");4 B& |5 T" Q: B
else: M/ s% }' w) b ^
printk(KERN_INFO "LED register sucessful!\n");
+ l- s3 m8 S& X0 _0 R3 J9 ~8 y' X* @+ v$ K
return ret;/ K+ B, f6 z7 L2 U8 I
}
. N* H1 k& K1 _# M5 A. f$ G; {# X6 K2 n: `
static void __exit led_platform_exit(void)! A# K9 N& H" U1 m u& \
{$ |- e5 u" v# W
platform_device_unregister(&da850_evm_tl_leds_device);' Z$ V3 }. _( }* Y" I5 F6 A
% ~+ @3 {4 p: Z0 O7 |
printk(KERN_INFO "LED unregister!\n");
r& c0 w: L$ i g3 e}7 z: q3 a; e. G. Q( z
. `: e, B) v( w1 n1 S) z4 m6 P2 Wmodule_init(led_platform_init);
) I" i0 p; ~; l! d" N; Ymodule_exit(led_platform_exit);
* ?& H- n0 j3 Z$ Y! ?4 d9 C, O4 P: |
MODULE_DESCRIPTION("Led platform driver");' f4 D. v7 t$ r7 V/ E5 t' Y3 o
MODULE_AUTHOR("Tronlong");8 S8 G4 @# Y I. x5 p& \
MODULE_LICENSE("GPL");" u9 x4 a& p' N) I# h
; v4 g4 E( x" S; _. g |
|