|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# P! ?5 b+ N9 c) G8 i3 N
#include <linux/init.h>
3 G0 t! R. \* K% a#include <linux/module.h>7 B- Z h9 A* p. E8 J
#include <linux/kernel.h>
2 r2 e/ U) o7 y/ \2 H8 L$ W- r# ~* S; G' k#include <linux/types.h>7 `, s. u: h; T: e1 l0 G' Y
#include <linux/gpio.h>
7 X5 O2 c* i3 p/ D! s s#include <linux/leds.h>
" q/ {8 A8 ~+ p#include <linux/platform_device.h>/ S, X0 E5 l' a+ X8 Y) d
! w/ p( s# K8 p; E. Y+ p#include <asm/mach-types.h>
! h) E/ B% b+ [" }+ Q#include <asm/mach/arch.h>1 O1 q9 [" R1 ]! J/ ?" x
#include <mach/da8xx.h>
; V, k5 e( m0 O1 K) v6 {# F: c#include <mach/mux.h>
+ Y* L- A7 t6 ?! ?# Q& Q9 k4 Q4 Y1 ?* k6 N! u3 c/ Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) A* I: b# ?7 [& E& r4 i8 ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# m0 g3 H: e5 W8 F! J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ P2 @& |9 i- p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ `! {/ w m2 {, e
. T; x& ?( [8 E/ i* m a/ q
/* assign the tl som board LED-GPIOs*/
! Z, [/ T' L: j& c# pstatic const short da850_evm_tl_user_led_pins[] = {8 W5 L7 f; \. F
/* These pins are definition at <mach/mux.h> file */
, s% S2 Z g' s% r- z5 n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 a3 _: w8 T2 T& e' y0 ^) n
-1/ `5 r# V4 H/ k, }' Y3 O) `
};5 Z& E: H9 u6 m- N' O. Z% ~0 U
l- K3 E# E& H. w$ ostatic struct gpio_led da850_evm_tl_leds[] = {
# X% n2 W8 w' _2 k o! J {6 Q8 B% C% P& m/ i
.active_low = 0,& A- Y8 }3 k3 e+ p
.gpio = DA850_USER_LED0,6 o3 ~) g( d) ?
.name = "user_led0",
7 X6 [+ I* {3 Q6 h' P4 h .default_trigger = "default-on",% m2 G3 i8 F# d: M
},. M+ R+ h- x+ i! b/ |9 S5 ? r
{: G1 j; M# s, k9 S) K+ M5 z
.active_low = 0,1 B1 k C& y5 ~# f. E
.gpio = DA850_USER_LED1,
$ Y, `5 \. X. o7 p .name = "user_led1",
$ y/ G/ t# Z( L j5 F, J7 @! w5 W. V .default_trigger = "default-on",1 V: E( e& J7 V% A) W2 c. a
},6 j) f/ ?7 ^* D7 y, A( p
{
' ~" O" d% H$ i* d3 _3 j( I .active_low = 0,
$ [2 n+ Y, D: x3 J2 b) Q* f .gpio = DA850_USER_LED2,
0 I4 q; F( [. j .name = "user_led2",) ^3 a, O+ m2 p& {- ^3 A% Z
.default_trigger = "default-on",% N2 i8 U2 {1 F6 K% V2 L
},
( w G: f8 `* y' s" o% K {
1 d1 l( l5 i" I! ~3 o1 x% o .active_low = 0,
; H4 V. Q9 ]! }! D+ v .gpio = DA850_USER_LED3,+ u- f: o0 Q/ w3 z2 A
.name = "user_led3",
/ W! @/ m2 c1 i( O/ @, o .default_trigger = "default-on",8 i3 W/ V( e1 s$ c
},
8 n' z* o" A1 O2 U};2 ^: b. }6 ?) g5 n0 j7 s
% {& L# ?9 B$ `* Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) k9 G2 {3 ]( h8 C
.leds = da850_evm_tl_leds,3 X6 I' K. |; X5 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 i* T y& Q. m& ?7 @5 _5 W- m) H9 ^ K
};
6 H |, Q8 g. O Q* e- g
0 t- m( [% }! e |static void led_dev_release(struct device *dev). r- C8 B. e {- M$ v
{* z% K6 H6 S1 \& ^
};
$ h+ J9 R4 j# X" E4 {4 i- k1 e5 D6 I1 ~ J8 T, i5 L5 [
static struct platform_device da850_evm_tl_leds_device = {
" l5 m' L- I8 Z. Q# t' a0 z( t! u% ] .name = "leds-gpio",
5 V% s2 H- f( I9 B5 Z- i4 N7 l .id = 1,* s, ]$ P* [$ W9 f* B' w5 H, }4 C- p
.dev = {0 v# N4 F4 ]8 _
.platform_data = &da850_evm_tl_leds_pdata, ^# V- s7 @6 Q, i
.release = led_dev_release,
0 _( L7 R! l5 v! T }
- U5 {7 w% N; E9 y};5 P3 C4 A; l7 b% |$ v. A' Z
% O3 y) b: p, O( f! \' a7 O/ w
static int __init led_platform_init(void)
9 h/ M9 D+ j8 w! \* n6 N{$ o* q4 F. r" I: B3 c9 F# t
int ret;3 r0 f9 A" n3 z' m: m
#if 07 l3 b& F- }# i& s+ N" i2 O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' P, ^, r- z7 Z, w9 w2 b if (ret)/ f7 }- \) r4 {5 `: ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# {5 f' p6 n* w0 b
"%d\n", ret);
2 B, W9 @3 P, g#endif
7 B3 |% s; {$ H `4 w: \ s ret = platform_device_register(&da850_evm_tl_leds_device);
2 ~% C y' u5 d/ l# a6 M: @ if (ret)
* R4 a* r' Q+ f I- z% ^" N- u pr_warning("Could not register som GPIO expander LEDS");
4 z- L! t. y2 ?& u+ K9 w1 a+ B |! } else
. |; k, v4 A) K' s8 b' ]6 k3 ~* @ printk(KERN_INFO "LED register sucessful!\n");
; Y% U4 k# p: D9 R2 ]4 d
# X! q8 e) H$ d+ } return ret;
`7 |/ m7 n4 V}" ?) r" t. H) D1 t" F6 _; E+ F
( ^, V3 G6 c# ^& k' E' i) P$ I
static void __exit led_platform_exit(void)& x O6 B$ e+ T1 ^2 M, A7 i
{
7 b4 i& }8 F( `) T7 A( w platform_device_unregister(&da850_evm_tl_leds_device);
0 H+ V6 ~' s; o2 }
% H3 m( p2 y( F0 x% { printk(KERN_INFO "LED unregister!\n");6 Q. z) o8 O2 k( [0 G
}1 p0 ?. P, ]3 ]/ Q2 B1 z
$ U4 s& o5 B+ W7 X4 H- S" }3 u- M
module_init(led_platform_init);
; a3 Z- O: g* ]5 `+ zmodule_exit(led_platform_exit);! z/ B3 l5 f, X5 L
/ J/ B0 c% ~) W7 U8 |* \! Z
MODULE_DESCRIPTION("Led platform driver");3 T7 B' U {8 K; r% f3 T
MODULE_AUTHOR("Tronlong");+ @- u& \( A" F5 s) l3 |
MODULE_LICENSE("GPL");3 l! V. ]. H$ ]& F
/ Y( J5 b4 r) {# G" ~, _
|
|