|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% _; G$ b1 W# i0 D
#include <linux/init.h>
9 M/ I0 W) d# I4 Y: n#include <linux/module.h>$ S3 a& r8 Y, O0 y5 K6 U l
#include <linux/kernel.h>
$ N+ Z9 d; O1 Q+ E$ l( F#include <linux/types.h>) q! W0 F: M9 O5 T9 L& x4 [
#include <linux/gpio.h>
) N! j. Q( Z7 ^#include <linux/leds.h>4 Y$ @. q4 i4 e2 S" z0 r& ?
#include <linux/platform_device.h>
; Q W- w* G6 B J& R3 f- L
# ^# }, h; Q2 {( q' P4 I#include <asm/mach-types.h>
$ |" ]! l- k" \9 A! F# ^#include <asm/mach/arch.h> X4 {* B, b# D; @4 l t
#include <mach/da8xx.h>. ?5 D* m: ^0 J9 n7 @9 v) }5 k- T
#include <mach/mux.h>% H+ }+ Y2 G! n' r, Y7 H L; v
9 }$ j7 @' ~' K9 @8 P6 C. v0 e$ H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 j4 V( S# f. {* S, t, `3 E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 g( f6 A* I, l- A( Y( p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 a' J& _; V: P: \2 J; c! n4 ^& c1 _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# r/ i9 h6 P8 S3 ~- K5 x6 q% p3 c1 s
/* assign the tl som board LED-GPIOs*/
# k& _7 O# E& n: Cstatic const short da850_evm_tl_user_led_pins[] = {
) @: g4 I7 K/ d/ { _! \ /* These pins are definition at <mach/mux.h> file *// x! _7 U) Q( i Q9 [$ K) U0 F3 d1 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- N9 w1 b) ^$ |' ? -1
1 W4 y* Y R* m$ [& x1 `};
8 Q! W, Q v( Y) P1 t1 z/ a
/ m2 a6 q3 S- J6 _9 xstatic struct gpio_led da850_evm_tl_leds[] = {
& e7 ^8 A, D! B {" W9 n Z+ B# f; `+ M# N
.active_low = 0,
% R4 k# K- s% S) Q% f' _+ I+ f .gpio = DA850_USER_LED0,
+ T* j9 t8 u1 W0 b .name = "user_led0",0 m5 k g* k- }. C3 ~$ y$ n" z
.default_trigger = "default-on"," C" ]6 l5 B6 m5 o
},
6 }) [+ g* u4 R( s& Q4 e8 v {+ V% J: J9 {" a. d$ @
.active_low = 0,' {6 k# e- o' t; w. G9 b
.gpio = DA850_USER_LED1,
3 h. h( A. X3 `0 i3 n .name = "user_led1",/ G1 ~1 H; K$ N( h9 ?$ p9 `
.default_trigger = "default-on",
) M* c$ p7 x m" G! F },
2 F7 D. y" s" t% Z) x { V- J0 P1 t- h# v% B' D3 @0 M
.active_low = 0,
. N' R6 T) H$ s' A) y. U .gpio = DA850_USER_LED2,( p' \- Y r# Z/ o# E" o
.name = "user_led2",
6 p% W# [9 g, b9 t .default_trigger = "default-on",+ k6 g7 A- o8 q# x5 i1 S0 F) r) e
},
- T. r8 {+ H# d5 _4 P* k3 Y) y {
9 f1 V: Y6 Y0 o7 W- `0 a7 {9 E .active_low = 0,
% A% y' s x. M# q$ I2 `3 x .gpio = DA850_USER_LED3,
9 U: ]0 P/ C& A8 ~( w# K+ u7 r .name = "user_led3",0 w. u! l$ ^) w# W2 v
.default_trigger = "default-on",8 _: c# ]6 o$ }* d' v
},$ B' h4 i1 h3 s3 p. h3 v% G
};- U- M' W3 \/ i' F4 k! A6 ?+ y/ L
3 H1 h' K% C' a& y8 H+ S/ x* _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( b0 R) q J, T+ U2 T .leds = da850_evm_tl_leds,
' c2 R, ] W" a( \+ v0 P2 E. }" w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* b2 d' M D" S+ {1 s
};; ~5 A \8 r3 D* C) K# g' S
5 @ b) o% x& x" @; }3 h, B
static void led_dev_release(struct device *dev)
+ h6 F' K2 y/ f! E- X& p, a{6 G9 f$ K1 u+ ^; u
};6 @' k; l7 M& R( s* F( M z, z0 [
c& b2 [- c' v# nstatic struct platform_device da850_evm_tl_leds_device = {$ R: x6 K: Z" Q ^- H' b
.name = "leds-gpio",
4 d3 H3 p A! a2 r .id = 1, t0 B6 P8 d2 Z1 G r
.dev = { G$ X v0 c+ [+ S
.platform_data = &da850_evm_tl_leds_pdata,7 m$ W& d6 G/ B% p" U' k
.release = led_dev_release,
, `- `' j- R& e0 [; R* D" v }4 T U' G/ y# g- t
}; i1 m6 G) R k8 ~5 l q x( p
# _. [( Z( m3 S3 d- N, H/ r! o$ L
static int __init led_platform_init(void)7 d1 v4 u& t) i, Y
{
4 \6 ] e! M( w, Z0 @ int ret;
P8 k) G" O8 z6 A* H#if 0 {! m4 X! R9 a* W) M$ M; Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 |! ?8 X6 u, I4 q) e* G if (ret)5 @: M2 W7 s( J# ^4 V& W9 y& o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" ]$ _! L/ |- o4 ^1 Y$ t "%d\n", ret);2 H/ K* t F5 s: v0 V5 d. j
#endif4 U1 b- e0 V8 B4 |+ ^
ret = platform_device_register(&da850_evm_tl_leds_device);
% v! ]6 \# @8 m; s* j if (ret)
' I5 A v' e( M" H% I pr_warning("Could not register som GPIO expander LEDS");
' L9 H( D/ H4 B, ~5 b1 V else9 X7 G' F" o! D$ U' i, e
printk(KERN_INFO "LED register sucessful!\n");
& X* m/ v- }2 I# h; n/ b T3 k$ ~# f
& A8 a8 G9 @$ U) ]6 [1 |3 E4 A return ret;' ?/ }9 W( M1 [+ a" h
}
/ X, c6 \# [# t( O: K: R5 z+ a
static void __exit led_platform_exit(void)- Q- L/ D3 F" c3 R
{
v, V, P# ^2 l2 E: e) B/ \9 l platform_device_unregister(&da850_evm_tl_leds_device);6 Z* r* N, J' {" G0 p2 m
9 M, P4 K! S" y7 q+ v, _: e- { printk(KERN_INFO "LED unregister!\n");( C9 n8 I# T' l7 R
}
6 g; J* B; e, Q: e: q& J+ W$ F, _* w4 I
module_init(led_platform_init);
) d+ B$ K9 g* hmodule_exit(led_platform_exit);
; |* R% d- F+ m
3 m$ e8 [: x6 m% J* ]" q; vMODULE_DESCRIPTION("Led platform driver");/ H4 W6 M7 S' B6 _9 Q( x
MODULE_AUTHOR("Tronlong");5 g" C& I [4 g7 |
MODULE_LICENSE("GPL");, {" A( D) d$ \% P2 W- u
5 j/ o$ p0 q# O |
|