|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* L' ~. M8 A1 v4 i/ O1 n#include <linux/init.h>
" A) p, [2 S; L1 O#include <linux/module.h>
, a' @/ B; M# E' F; H; `( A( F#include <linux/kernel.h>3 f( g0 J r% W: O+ ?
#include <linux/types.h>
4 T& r& i: U( [#include <linux/gpio.h>: _0 ~- `3 V, F* k$ `) m+ k# Y
#include <linux/leds.h># r W- z; o$ r$ G* Y3 a1 i. x. w
#include <linux/platform_device.h>
+ o! d) f/ l0 U6 o% ]! ?4 O
# |' S8 M5 h( h( c0 g#include <asm/mach-types.h>0 \. l0 X& C3 Z; T8 ^
#include <asm/mach/arch.h>
/ l' `* @' S6 L1 J B#include <mach/da8xx.h>. l# t7 G) K( k" `: b5 L
#include <mach/mux.h>1 n. k) b+ u/ L, |$ Y$ V N
; i+ ~' u. b& v8 z" ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" u) Y; n6 T4 s/ l' u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) ^/ H- D: K$ z" t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 g" }$ k8 D u0 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 r: f+ J: @2 y
5 ?- O4 |4 \3 N! q w& m$ p1 t/ ~' K/* assign the tl som board LED-GPIOs*/- B# _: y2 o3 I) Z N+ ^& M! S% t' R
static const short da850_evm_tl_user_led_pins[] = {
2 R' D2 _* P# ], a$ _ o /* These pins are definition at <mach/mux.h> file */
/ y) P5 k; D; q: q! Q' u) Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, W& k2 @1 n! h. j8 P6 s! I -1* X3 f# t, ^% i5 _* @
};, c- u( _$ N+ V1 a" `9 k
4 |8 Q* g7 [# K. T
static struct gpio_led da850_evm_tl_leds[] = {: u3 S9 O$ U. m# \ b9 R4 y' \
{
4 }; N& V: B* M9 h .active_low = 0,
# ]; W6 [- P* q7 e .gpio = DA850_USER_LED0,2 Q" D8 t! K% I" {" I- L
.name = "user_led0",
* O, |, v) L8 W6 f .default_trigger = "default-on",4 |( {- Y3 V4 ` H: `+ M3 T3 F' b
}, o% I7 H4 f* d: u l
{
* i. X) c! K. \9 M2 N7 U8 | _ .active_low = 0,+ E+ k2 N: n9 s c% { p
.gpio = DA850_USER_LED1,
* D; _5 O9 S3 z" `, U3 g' Q& W .name = "user_led1",: q; o: ~; _. [- Q
.default_trigger = "default-on",+ `8 V4 y3 \2 Z5 J }
},4 B: ^, }! G% E ]( b- r
{
{2 r3 j3 z* @2 B8 u1 _ .active_low = 0," S1 k5 @- k) @( s" n6 {
.gpio = DA850_USER_LED2,5 d9 U0 ^" P; H' C; R! a
.name = "user_led2",. X) c& a7 t$ i$ o
.default_trigger = "default-on",
: c' \$ W3 T* u4 F" s },
' T' d" E7 N7 p+ [! U8 u0 R {
# K0 b3 }7 ]1 d+ B9 S .active_low = 0,' |. C @% M7 e1 L
.gpio = DA850_USER_LED3,6 P# ~0 o" I* o9 w" `
.name = "user_led3",
+ Y# M; [- Y7 T+ A: U/ ^ .default_trigger = "default-on",3 B' |- \' W0 f0 h2 ~
}, ^0 ^& ^. U6 A+ f/ m& V# e# {
};
0 Y- ~7 a6 F: \0 q7 {5 {2 a+ R K4 c& f$ @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, d2 ?6 W9 \# H6 u1 R# D
.leds = da850_evm_tl_leds,1 w! ?, S- R( g" [# x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 F2 B# X( j- v0 J/ q4 A
};) M9 T& q, x3 d6 O* \3 l% ]" F
, Z4 o/ q) b2 W6 K6 N: p9 A, m. |1 k
static void led_dev_release(struct device *dev)& ~' C( `% n |) [& V
{
( i8 @! T5 \" ]};) w7 y0 t8 P! ^/ L. ~" j
; b) w+ w; m1 G- f( @1 j" I
static struct platform_device da850_evm_tl_leds_device = {
# `6 U {0 f8 c% T; i .name = "leds-gpio",; s; `9 U# `! \. k: e
.id = 1,
9 o4 i8 [8 L* h3 Z7 J# Q .dev = {
4 w& {( Z+ T9 t) X$ q& Z .platform_data = &da850_evm_tl_leds_pdata,
% y! n7 A* b. G2 \! f- Y' V .release = led_dev_release,) s' _ L! e% m+ X& J
}3 w7 o; L j. U' h! r X
};
8 c8 ^. ?1 F+ v& L6 n+ j( Q
+ t8 h* d6 q3 ystatic int __init led_platform_init(void)1 m) R% y$ B; O4 M% w6 y! `
{
4 t6 `1 A4 B _5 Y int ret;; x4 }0 Q4 u, x3 q' u- i$ N
#if 0
- i( B$ \$ H1 n: p V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. K/ B+ C1 o; b/ b# ?( C0 d
if (ret)
4 [) M3 u7 H5 }, F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 x3 g. n% |* Q% J2 y "%d\n", ret);
! x0 [ l: }4 ]& d; I; @2 A#endif; I( T! f- m- P/ p4 r
ret = platform_device_register(&da850_evm_tl_leds_device);
1 Y. R% ~0 d- Q7 G# _ if (ret)3 T. k$ W) U- T! t: s5 {: S
pr_warning("Could not register som GPIO expander LEDS");
* Q, w% T y4 l9 d% ` else* l- m0 X3 Q% ?2 A" g; U
printk(KERN_INFO "LED register sucessful!\n");# _% E6 P/ b! U2 ~; R. n
8 ]$ m K& e5 f, g2 f" ~
return ret;+ U& M. O5 S7 {; a5 w9 w @# T9 z. V
}
" `6 ?5 V+ r' [( i9 l) F+ w9 B( d6 E2 e: a* h9 r0 r2 o: r3 z4 d; A. e! H
static void __exit led_platform_exit(void)# C( ?' M: ?1 U0 \% @
{1 U3 R( Z3 ^( _% `7 x/ O( Q
platform_device_unregister(&da850_evm_tl_leds_device);6 o8 [0 I" n. a# X9 [5 R4 b2 t
* S& w7 k% m9 Y5 W printk(KERN_INFO "LED unregister!\n");
0 T/ y4 }6 H' ~}
- ?4 H! p0 e' i* p. x
# k" m8 y* [ r7 _module_init(led_platform_init);
8 U4 F3 N9 {' [- l' amodule_exit(led_platform_exit);5 b! w9 [; j, A
+ N- @+ \5 P! \3 u3 _
MODULE_DESCRIPTION("Led platform driver");
- N* l" @& B3 `* j% oMODULE_AUTHOR("Tronlong");
; n6 J- [' D4 `9 W" c& [MODULE_LICENSE("GPL");) g( k0 O1 E: n: E& X7 Q; {# _
4 d0 G: H! a0 Y0 |. k |
|