|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 L$ V5 ?7 `# m$ X" i0 W# O#include <linux/init.h>: W8 J+ u7 c1 x4 z# i8 T# b/ X
#include <linux/module.h>
8 ]; s8 P/ g# v; O#include <linux/kernel.h>
' O* x# B0 v5 [9 W& F! y. f#include <linux/types.h>' q( F% }' c- X1 T3 @# u/ E$ w
#include <linux/gpio.h>
5 {+ M% e0 c& G#include <linux/leds.h>% T' H% b9 t/ ~, _& K& j7 {
#include <linux/platform_device.h>
$ `* Q9 M- n# o X7 H/ p! ]3 K% H' n( `5 u
#include <asm/mach-types.h>3 H% \5 K8 `2 D' f, }# t
#include <asm/mach/arch.h>! s. w0 ^/ x' X8 X
#include <mach/da8xx.h>
; P3 O* Q/ j x' [* M$ ]+ m#include <mach/mux.h>
! t; i' U* W! C9 h$ ], G0 u
3 ?. r7 l) e- [- Q7 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 T- a+ w8 w; x8 R. f9 ` D I$ r- i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 V/ F4 k8 O) t/ n$ u/ ^# d* x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( H" M. n0 V7 A% g9 O5 I# M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) }, F1 \ c3 W0 x0 n
0 |% z* Y4 ~0 j' i% {
/* assign the tl som board LED-GPIOs*/
7 f; @4 ^. z% F* Kstatic const short da850_evm_tl_user_led_pins[] = {
( D* b7 ~) h* t/ p1 s0 I' C6 A /* These pins are definition at <mach/mux.h> file */
0 M0 e& ]' [; [3 n; X4 `( X+ A: w( H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 |" i5 o3 `2 m3 h# A7 _( p
-1% }! u# v8 L6 q) p$ q/ I
};, k8 t- x* n- O5 ]+ u- K
( v, X* a; l i/ v7 o, Kstatic struct gpio_led da850_evm_tl_leds[] = {
5 J% n1 K" k; @$ ?- B {
" `' S) I9 P2 m, I! k .active_low = 0,# a! E8 H8 B% |) U$ m' H8 ]
.gpio = DA850_USER_LED0,2 b7 l& D* W8 C
.name = "user_led0",
! D1 y: r! U @. k2 l .default_trigger = "default-on",
0 H' V# T; n* ` },
* T0 z; p7 w! l0 E" x4 q1 A) ? {, }2 O; h2 L1 M& g
.active_low = 0,
) E: \. g o4 s3 U1 w .gpio = DA850_USER_LED1,/ V+ D4 H9 B: y0 H
.name = "user_led1",
: ^; j0 L$ m4 h* \( f& P, L2 J .default_trigger = "default-on",
/ z' Y# D' O6 @) ^" c },
* y* X F L! ~% ?4 Y {5 i/ Z, F4 R6 _3 V! L0 U
.active_low = 0,
2 V+ U9 a4 m( j- ~; p .gpio = DA850_USER_LED2,
! s* q$ h7 u! t J+ | .name = "user_led2",
2 p4 N* \5 |/ Z' C$ K6 q( y4 u) ? .default_trigger = "default-on",
C+ x/ }" L; H4 t },
6 |* U: M7 s2 I6 B {
" B, v) U9 R4 t/ ^' ^ .active_low = 0,! ]9 s2 q1 h8 a* o, {
.gpio = DA850_USER_LED3,# R# S2 N. [% ~5 |, a9 D
.name = "user_led3",8 a6 ~6 l. ~; c- W
.default_trigger = "default-on",
' z' v" `3 E# a& u# E$ F },
( \, `" R% f$ ~/ q};$ [+ f! k4 s Z: N& T8 a
3 x. F7 M( n; k- ^7 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- X/ _, o1 ?+ c* h8 X! F
.leds = da850_evm_tl_leds,0 m: I! y! m" w- u8 o! j* o4 T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 v! ^6 S6 s# p8 E x) C( T: n};; H3 R$ ^/ H: w m' d3 f- O
# R9 J U7 p6 l/ m7 h9 l* ~+ f1 J
static void led_dev_release(struct device *dev)8 |0 _. p ?( O+ _( Z4 _0 ~
{
) D3 w+ F8 j! w! g& B7 n};; b, |3 Z( ~) S
~& D' @ f2 {) r+ x |static struct platform_device da850_evm_tl_leds_device = {0 ]$ J4 J, l* E0 m$ l
.name = "leds-gpio",
: J/ } D5 j: ]) \ .id = 1,
$ W S* Z( r1 Z0 a0 ~/ B7 s' a8 d7 l .dev = {
i( d) J) C) t$ d% h .platform_data = &da850_evm_tl_leds_pdata,
+ L2 Q" K# r$ P+ Y* f0 f3 C* j .release = led_dev_release,8 m" L* z0 P0 o, m+ {
}
/ {( k8 A. }+ G$ h1 z" j3 c};" |. \. k% q1 R; g2 {; v
( E- P; c- k* X" D7 \static int __init led_platform_init(void)
' r9 N' i. O; L# n _{! O t2 H! `4 |" Z
int ret;& F6 `8 H+ m' O
#if 0
1 x( P6 \; h; L- p- B1 F; @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; u3 D3 Z) _% f$ w$ t' y
if (ret)
) o; B1 s! v7 e8 E( B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; {9 g1 K' X n
"%d\n", ret);
& b; E s8 U" R; c) Q#endif
8 L& X( x6 [* _; a \9 m1 N ret = platform_device_register(&da850_evm_tl_leds_device);
: K2 h w w; [6 Z+ a if (ret)
0 D2 i; ?1 k. k ~) Y pr_warning("Could not register som GPIO expander LEDS");* j: }% W& m1 y
else
; R3 h/ \! C; A7 w4 M/ P" ^ printk(KERN_INFO "LED register sucessful!\n");% u+ D' p: N+ q; v
" _9 _" C9 {) a: ~/ j return ret;
' B8 Y/ H8 E5 l5 ?8 \. B k}" |8 X4 @- d+ A. F* T8 e4 a
, [6 E7 @6 [7 S8 U
static void __exit led_platform_exit(void)% R7 r6 }& t2 w( |$ G& U5 N( k
{
3 z3 _5 s7 c0 J) w1 q4 E platform_device_unregister(&da850_evm_tl_leds_device);
2 X% z/ B- d& K s
* R# G# `4 O1 {( I/ U | printk(KERN_INFO "LED unregister!\n");0 X/ d: M' q, Q' }
}
8 b5 U t+ X! n4 [" e9 _
: _6 Y" e2 `6 w1 {! Kmodule_init(led_platform_init);
7 d2 W n* K* H" T& i, omodule_exit(led_platform_exit);9 {) i( g; K, O* t/ x t( P2 c
, Y |6 p) q6 qMODULE_DESCRIPTION("Led platform driver");
, G7 l6 |% S# t* EMODULE_AUTHOR("Tronlong");, y. v1 G4 ?1 _0 B8 @
MODULE_LICENSE("GPL");5 b4 _8 u0 {9 r# {7 V% X
# Q6 B; {5 Y7 l2 L; z' U5 _
|
|