|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* y1 k) Q" x. i1 z#include <linux/init.h> C3 m* ]/ b$ O, y
#include <linux/module.h>- q A/ q* H z6 m0 T2 S7 M' a+ h
#include <linux/kernel.h>
3 d1 [) Z- A( B4 L" v#include <linux/types.h> h& s j4 r5 m' A/ V4 ^4 z
#include <linux/gpio.h>
6 ]' z5 E2 A- J: f4 Z#include <linux/leds.h>
' u$ H" e# H1 N0 j#include <linux/platform_device.h>
6 q+ d0 w' I8 f5 o7 H5 N3 g @7 A1 D* P8 @7 X& _5 {
#include <asm/mach-types.h># o' {/ |+ a: m" g" ^+ @" E. `
#include <asm/mach/arch.h>
2 S9 Z$ f4 J7 `$ P* ~#include <mach/da8xx.h>
$ M+ L; t4 q# F" G1 Z, f% b#include <mach/mux.h>
: p3 [% Z" z; ^6 V2 @6 V4 l6 G" D# d" t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ Y$ m8 t W( x9 v* g7 P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) ], w, D7 N% M$ g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 S% g( c3 ]; G8 |$ T, P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 X8 j: t" t1 A, p
# U7 z/ C2 R9 o; u/* assign the tl som board LED-GPIOs*/9 u5 Y# \% h' n/ o$ B6 g! Z' r- A
static const short da850_evm_tl_user_led_pins[] = {' k. I% Y4 k+ B" O' _( F* W
/* These pins are definition at <mach/mux.h> file */7 I) E2 w3 s# U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 A5 R, e2 h* f& A1 {/ |1 V: S
-1( \0 t6 P) C" V3 t! p
};) ?7 R; R. [' s! x. P6 C/ K0 K
$ U. B8 {/ |9 V. |/ q/ xstatic struct gpio_led da850_evm_tl_leds[] = {
$ {5 `$ \6 y* K" L: J {
1 ]. h1 s) m& b d* X+ ? .active_low = 0,, h# V5 g0 b$ W7 N
.gpio = DA850_USER_LED0,
2 B" f& ?. J8 q! G2 S2 J .name = "user_led0",
0 n, e3 o3 c u3 u+ C .default_trigger = "default-on",3 g/ e d* j1 H/ y- s' k" B+ [
},2 E6 F V( ]' N9 ?
{9 l& R" H3 }. d8 ^/ F0 M% B
.active_low = 0,7 }, X4 v" e' j4 V, l
.gpio = DA850_USER_LED1,
/ K# z2 Y2 O+ X6 W6 i, ] .name = "user_led1",
/ @ B2 ^) j/ h .default_trigger = "default-on",3 o6 P2 s% n+ s2 Y4 U. L
},
8 w8 |: f4 j; @) A {
! v! q- |4 g) | .active_low = 0,
, P+ c6 {# P+ }- A3 u. q" @& Z .gpio = DA850_USER_LED2,- ~; Q( T! U( k
.name = "user_led2",
8 l! l& E9 p+ J, Z* j .default_trigger = "default-on",
# n2 \( [% S5 H3 \' s },- V8 u: N' k: @& O E: [2 }
{
3 C3 K# B, ^2 K' S" Z .active_low = 0,
6 m$ n z, D6 p9 C% F* ^ .gpio = DA850_USER_LED3,* A `% s8 S! H5 u
.name = "user_led3",# {, D! D. k* H: d8 d- G( s' [
.default_trigger = "default-on",
) c" f3 f4 _' }3 X* S, x" l },
: M! k4 z) b- {: h% a};
2 X4 J* {7 n- ?$ T
7 ~' l6 x9 K1 d4 A$ Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 P- W5 E( {5 X7 G5 ]. R
.leds = da850_evm_tl_leds,! g& I1 [" I5 K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 t0 Y W& E' _$ Y3 U0 v: v0 r
};8 X3 d. r- s. s! X* d; l7 l. a* t1 Z# Z
% P3 V7 C; w; _
static void led_dev_release(struct device *dev)
E( J3 v2 d, m{( g/ {) t, e* P2 D7 k5 T1 H
};6 T# Y: [% T) Z6 g
7 g8 l- |0 `$ S/ p" ~/ ustatic struct platform_device da850_evm_tl_leds_device = {
2 M8 ]' ]$ P8 A; q7 I8 V .name = "leds-gpio",
, D7 j V1 g- ^- ~ .id = 1,3 U4 x- f% ?+ t; \2 j! x6 G$ A j3 N
.dev = {
H6 Q& F1 U* s .platform_data = &da850_evm_tl_leds_pdata,! t1 f- B$ G9 V7 B
.release = led_dev_release,( o3 F H- P, ^7 `) p, q
}9 s$ w: s0 s) c; F
};* L7 _1 o9 b: k6 d3 @/ q
# H1 ~! N& Q( Y% ?' W& Estatic int __init led_platform_init(void)+ k: I+ N0 w, g4 ?; E! m' C# B
{1 s) e: A# v t U ]
int ret;/ {4 d) {% _. ]1 s- U b/ N: ^
#if 0
; k1 z( a7 O" k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ r0 ~$ T6 R) z2 \% b w+ i3 Y, V* O if (ret). m. c6 C# N# `, H- d( o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 H0 C0 y: p" r3 [' m2 C+ p
"%d\n", ret);
# N& G- t T! Y" L#endif
1 c6 H1 k( w4 |5 D4 t3 @8 x ret = platform_device_register(&da850_evm_tl_leds_device);
. U C7 { F% R4 u! Q! S if (ret)
# i6 Y- t: Y# ? m pr_warning("Could not register som GPIO expander LEDS");- {) G" B: S: G
else
) B/ [& B/ `) O$ N, c6 ?0 L printk(KERN_INFO "LED register sucessful!\n");
! q: h! S8 Z% k! H# [7 Q7 l( B6 _) e8 G/ H' `# B5 r/ A
return ret;
& V! V" t! F; y9 H; n" J5 g}
. X. k# a# U4 i {) y' T6 v& U I7 V9 v" d2 U1 Y8 u* N+ p
static void __exit led_platform_exit(void), Y4 }) G3 M7 Z9 g! p" S9 G
{" H. F9 M1 A% k8 ?% ]
platform_device_unregister(&da850_evm_tl_leds_device);
( E1 u" K3 Y9 m# x' I
1 u# @1 z3 X" b5 M: _# _, W printk(KERN_INFO "LED unregister!\n");& G) }; M. ^% p3 a
}( c. N% o, H- [+ O5 u
- u7 z- z' {% o7 smodule_init(led_platform_init);' m7 m& Z: l( j1 x3 Z
module_exit(led_platform_exit);
. U w% x9 H4 E6 S. o8 c4 ?$ c! |, h" ^ [7 G9 o% ?2 B, ?( v( p
MODULE_DESCRIPTION("Led platform driver");
7 X" A8 T8 B( k* bMODULE_AUTHOR("Tronlong");6 ]& }* ~0 {4 N/ v, \* i1 v; ]$ D
MODULE_LICENSE("GPL");
( I- e7 `/ g, z, ^3 q. l
5 N+ _6 ^6 `4 C2 H T |
|