|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. O9 M8 b+ x& m#include <linux/init.h>
I6 \; b; W/ h; X+ |- B#include <linux/module.h>' [% Y4 F0 N9 @9 c
#include <linux/kernel.h>, L: L4 s; u, {7 S& m
#include <linux/types.h>$ c4 y- @6 |; p5 j5 Y
#include <linux/gpio.h>7 N# Z$ @9 ]0 N& ?
#include <linux/leds.h>
! K- f. f* H/ U" Z f! ~1 G- K#include <linux/platform_device.h>
% M/ P9 M) d; B1 \0 J; j: P! O e: e! z5 r: Q
#include <asm/mach-types.h>) S5 z& I& z/ f1 W8 d- _5 _
#include <asm/mach/arch.h>
% g2 ?. Z7 L' c3 i/ g. K3 g8 V#include <mach/da8xx.h>
( H! M1 q- l0 }; m3 m e#include <mach/mux.h> N8 d5 z) V6 t/ \. D3 f% M5 L3 _
" ^/ q, f( n; W5 q+ |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* E' z5 `. a2 X8 G0 T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& K% n1 N! ?- B/ g' \# q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' A" z) P, i+ M' [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 d# S% R/ u' z" |3 _
! [, ?" n" N7 H/ W& T. s. y# W/* assign the tl som board LED-GPIOs*/
8 C1 X9 P" h: P( c( T. Cstatic const short da850_evm_tl_user_led_pins[] = {! a3 v: n) T5 s+ @, @- Y
/* These pins are definition at <mach/mux.h> file */, E4 G W, K% X' [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( H+ N/ q' }: G5 g" Z
-1
I( ~% l$ I8 Z* M& E};
* l7 f5 u' G2 k5 Z* H$ r$ H z1 X9 e0 U2 z! v
static struct gpio_led da850_evm_tl_leds[] = {8 z2 c* ^2 R- x6 B
{5 ]' c" J* ]% x
.active_low = 0,
5 g+ @! H& ~0 _4 l: c+ l .gpio = DA850_USER_LED0,% ^, P( i0 e W9 o$ a$ _
.name = "user_led0",
8 y+ T( C9 W/ g, q, ^ .default_trigger = "default-on",
0 G# a) ?' f$ e2 @# N o% }1 T },
9 r, m" a! R( `; c {
5 Y% s8 W" }1 t0 X1 g3 G& T$ x .active_low = 0,
: J9 u( K1 p3 x .gpio = DA850_USER_LED1,1 p' N9 A8 B7 d9 r" j
.name = "user_led1",% J) Q$ R$ D1 Q2 \, u! D
.default_trigger = "default-on",- {2 p! o' S. h4 _, L& K6 H0 P- @
},
1 n* n1 K* x" ?, b% H {
7 _& i4 r2 n7 U. T! n6 W .active_low = 0,* _/ Y: N7 Q$ l2 m: k# W, k% V
.gpio = DA850_USER_LED2,* w& [3 Y# D6 M: |8 c5 F
.name = "user_led2",, u: ?* ~' A" X* m4 C$ k6 d; @3 F6 Z
.default_trigger = "default-on",! u# H6 D3 M/ C/ G1 \* i0 R
},
/ F0 I4 \% E0 l, h( v$ k/ O {8 V# A; E/ _/ J8 t' ?1 Y; m
.active_low = 0,& \8 i2 U# Z7 k2 B* X
.gpio = DA850_USER_LED3,
, ]* R' [4 g' G3 } .name = "user_led3",* [: g# n: g7 l1 E; j$ t5 q% `
.default_trigger = "default-on",3 |0 Y- B3 E; a$ p5 H9 _
},' x% {! W! ^, x! j. F# V8 t @
};
7 J* e% E0 l _" J% u, o6 N$ ~" v* n3 p5 D. ]: V7 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" T5 A" T5 ]) o* R% z$ M .leds = da850_evm_tl_leds,
" a+ B! A# v0 R0 ]$ [: U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: o: A* w) C' H
};
6 i, ~+ o; {# [% I4 _# l1 H0 b' }* K7 U, t* s" Q
static void led_dev_release(struct device *dev)
( P, e7 Z& [7 f- B9 G6 D& x3 A{/ }+ D) M+ S7 K. Y2 {5 v/ A
};
% a. N" v" @4 p. H
% m$ |% e( l; ]0 n6 hstatic struct platform_device da850_evm_tl_leds_device = {
: K3 U$ o. h7 _* a; u& ^ .name = "leds-gpio",
2 u; ]; S2 {8 D .id = 1,
6 P8 J- |2 E6 X! [3 S+ W5 V .dev = {
2 b5 w" d9 T7 f& B9 L .platform_data = &da850_evm_tl_leds_pdata,
4 j% _3 M V/ N: T" ` .release = led_dev_release,
9 f! \3 e) |; w8 H9 x" B" u2 Y8 C }3 F& x& K8 _1 T, ~2 n
};
5 c% ]$ a. `# o6 K7 `2 }+ c, o
$ V) V- w, w3 f$ N* ^+ L, _static int __init led_platform_init(void)
! `2 J* n- b/ o{7 C) e& l W/ z5 j) O
int ret;
* f. R5 \' o# d- O# @- c0 _5 m#if 0
; H) s& I% y+ I! z4 L6 |7 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 a9 I, w8 c4 Y4 Q# _) j$ N* J7 H( c. t
if (ret)) l2 O5 k6 }3 b4 v' C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' K& R' z7 O$ M5 A# _
"%d\n", ret);
! m* f( U a% K2 \3 T4 k, e2 Y#endif- }" X4 Z; S2 z0 H" n
ret = platform_device_register(&da850_evm_tl_leds_device);5 S/ Q4 ^+ P# L' r$ D
if (ret)2 L- U% U$ N. A
pr_warning("Could not register som GPIO expander LEDS");
3 B7 R, E3 g( o# k& y- e( L5 l else( F9 ?! y$ P4 I& t+ S9 g
printk(KERN_INFO "LED register sucessful!\n");- p: j+ H8 V/ P$ H
& x q3 ?" d' e R* a3 {) L return ret;* {5 p+ V+ ~% G2 n: g
}
/ F7 J" r. t- }
' M/ ^% ^7 o6 }- S! [! lstatic void __exit led_platform_exit(void)8 p1 s$ o0 O0 t; R6 S
{2 t+ K# h+ u; A: a
platform_device_unregister(&da850_evm_tl_leds_device);' F* }6 Y6 M u
" ]) v2 ?5 W, u: ` printk(KERN_INFO "LED unregister!\n");
9 p; G2 ]8 m9 p8 u}
7 J2 @( t# v5 s3 s* F& b. k. F0 g d; _6 I. {% o
module_init(led_platform_init);
6 Z7 ~: a7 }3 J3 G+ C7 G, E- Kmodule_exit(led_platform_exit);: E* W# `0 m1 @/ v5 q
" j; m+ k: e& m* N" w) P# v6 L/ ^: t& g9 vMODULE_DESCRIPTION("Led platform driver");
# t) h0 Q! `5 T- |) aMODULE_AUTHOR("Tronlong");7 P3 m, ]3 N$ {+ Z9 g* B
MODULE_LICENSE("GPL");
7 l1 X" D; X! t4 J0 m* ? o* ~7 G4 p! d7 z$ V- F8 l2 u4 ]
|
|