|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 n4 `5 q# J% H/ M5 z% {) Y#include <linux/init.h>9 k0 |1 l0 P7 c7 o8 t, E+ v
#include <linux/module.h>
$ |% U- S. E' v# _, o: s#include <linux/kernel.h>6 v( L# ], B: R# U9 T
#include <linux/types.h>' a' y! _8 B8 W& t* s
#include <linux/gpio.h>; G6 O' _& @$ @! g: |0 ^
#include <linux/leds.h>& K8 W: ?* j6 v+ v
#include <linux/platform_device.h>
/ [2 d3 y# F* M3 j1 S) G' l: V0 s" b% a: w8 @
#include <asm/mach-types.h>5 h$ j7 @' g6 u2 p
#include <asm/mach/arch.h>
, S0 h, ^& t# [: X `( C" w#include <mach/da8xx.h># Z* t! e+ i/ T* x+ D8 V8 g" {
#include <mach/mux.h>1 k# [3 z0 x. h, i
, Y& c. M) d+ k& x, R2 t& m8 q- s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 l, Q& q8 v& F0 `/ I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ p9 r% s/ K% ]1 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! x+ r! h$ M% {7 J% `' B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, Y- i; S) H0 M- b- X( u( ~6 f, N2 P8 d4 L# \' W7 x
/* assign the tl som board LED-GPIOs*/# w" R' Y( t2 k" r, c4 f9 [/ L0 h
static const short da850_evm_tl_user_led_pins[] = {* [; \; O/ U7 K2 D- e0 t
/* These pins are definition at <mach/mux.h> file */
% Z3 G( T/ m$ X: H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' n. K: u* x* L( T; O -1
8 T" h: f& o& g8 ?};6 z) u0 b! z! @: b* V# z
* D g" V4 N6 p1 Z" Q( a* O
static struct gpio_led da850_evm_tl_leds[] = {
% ?5 L) J6 u4 }& D4 [$ l9 J1 { {
1 L* B- o( |( y6 T& s; v .active_low = 0,2 Y5 i$ t2 f6 c" d6 l
.gpio = DA850_USER_LED0,
7 X+ d8 b; m) k9 t .name = "user_led0"," ~$ m( c/ x0 x, y \
.default_trigger = "default-on",# J5 N: V8 A/ g+ h. V
}, ?' `8 H* s2 @ L- F9 p
{
" h5 u% ?3 ~6 e. F$ g% f/ I0 [# ~ .active_low = 0,
/ S6 X9 g1 o/ C$ m* c$ B .gpio = DA850_USER_LED1,
9 V# ~" y' g$ B& o6 L4 s .name = "user_led1",, D9 ] a% _6 U' P! q& p( G( C
.default_trigger = "default-on",
8 u* z" `: [( Y' b4 w G" K, n },
9 ^; G5 V# A& A& P( [ {
6 {, Y6 |0 t) C5 y, W .active_low = 0,
3 g+ ?( b9 w3 }& P+ k8 y .gpio = DA850_USER_LED2,
# n+ M1 q8 L# ?6 S- x( J .name = "user_led2",
. K; V+ `" I% V7 J F+ z( P5 `5 V .default_trigger = "default-on",7 H. u0 o9 T" t: O- a4 i( H& r
},: c( B* V3 F& U( Q$ P
{
. Z# P' C! y" C) z .active_low = 0,& u3 a/ p% Q& G0 s! x& \
.gpio = DA850_USER_LED3,
( M8 K' \, |. S+ f; a, v .name = "user_led3",
9 h7 ^7 C7 r) o0 |1 A .default_trigger = "default-on",
7 s3 ^0 @3 V' y0 t; G* l },: k _% x3 X( S ^ d' q- K
};% ]4 c2 D0 @( a+ I& n2 e$ k5 O
3 o' E0 Q: ?/ u# p+ q: w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( E4 e! M7 ^, {( c8 o' l+ v. e .leds = da850_evm_tl_leds,/ z7 t: u% c3 g+ [! F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 Z$ [ O$ z: Z9 s8 j1 }0 c};; f8 h+ [, X4 F+ \: C. \
" }& z8 B3 H& Z
static void led_dev_release(struct device *dev)
/ {1 q E# s2 [9 a, F8 b" v5 @{
" w, H, ^. D( Z, x};4 {$ K5 W% s, C+ @- }6 u
0 x; z) q/ R8 S( a8 ~; P) @3 zstatic struct platform_device da850_evm_tl_leds_device = {# E$ }3 G( [# C
.name = "leds-gpio",- r8 t: Y* C8 a$ q G- { D
.id = 1,
, E4 u- f( W. Z1 W$ U& B .dev = {2 p+ {( E$ b9 E
.platform_data = &da850_evm_tl_leds_pdata,
; y# M, ~) k6 K# v6 z .release = led_dev_release,
8 x" D# y6 p1 t3 F }
; F! s1 O" w. R6 e( l) g' K0 S};
' v2 p1 {. L0 f9 {$ j. l* v( K$ k
static int __init led_platform_init(void)& l4 K' @ a. v7 b. y
{6 E+ n* f% d8 Y- [ ^) B. {: A
int ret;
4 D7 b& q; X! I1 j#if 0% _% I2 A: N) f* x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- v: m/ k# M1 Q0 e2 w
if (ret)
$ p# S5 r; M- g" I6 w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 x/ i; k% G ]: f- u/ I/ p: @
"%d\n", ret);5 s5 Z: Z" n7 C( ~
#endif1 K% j1 i. j+ x# i
ret = platform_device_register(&da850_evm_tl_leds_device);
, I( T1 c* P0 J& B) D+ a' Z if (ret)2 n. I8 S' M$ l
pr_warning("Could not register som GPIO expander LEDS");( n. L- j2 y* S2 S6 l# _
else
$ r4 a* r. z$ V9 g/ y/ J" t3 j* a$ V printk(KERN_INFO "LED register sucessful!\n"); |' q- J0 i* M2 V; j* Q9 r" o
5 `: }) n* S( i return ret;. I6 V; v( X+ c
}
5 Y: ^8 q8 \: H- v7 g8 {2 J5 E9 l& H! W; \3 d
static void __exit led_platform_exit(void)2 Q8 Z# p- }7 r# Y
{
5 G9 H% {$ k4 C& o4 C, q& z platform_device_unregister(&da850_evm_tl_leds_device);
6 [2 R. p! F+ R+ R% z! C1 R7 `4 Q1 s8 ^$ g9 e' r2 d
printk(KERN_INFO "LED unregister!\n");$ D0 k7 q' ]* n) ~
}
7 ?, B0 {$ \1 J7 @% @4 A
5 |( |; L8 l4 p2 g7 {* Zmodule_init(led_platform_init);' _* A6 e' F; V. v2 k" Q5 R
module_exit(led_platform_exit);
' x& l$ Z3 X4 W8 M" o+ V4 h: D; E5 ^
$ V& H# Y7 [" I9 e5 F5 vMODULE_DESCRIPTION("Led platform driver");3 u6 c4 r c$ k, ?
MODULE_AUTHOR("Tronlong");4 G: {0 w! v8 d' W
MODULE_LICENSE("GPL");
% `5 _$ c5 b4 \# C2 r$ A* B2 \
9 x! ~1 H' N3 G% k; S |
|