|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 S- G1 D- K( F) q; R7 |#include <linux/init.h>; |" j7 x% D) U8 g8 c
#include <linux/module.h>
1 y+ M9 J) ?" c! F#include <linux/kernel.h>
% Y; ^7 n1 h9 o#include <linux/types.h>
. N8 |3 D$ O1 } [#include <linux/gpio.h>( A/ s0 z* y/ m$ a( A& v
#include <linux/leds.h>
, u6 W6 D Q/ E5 r4 P: `#include <linux/platform_device.h>
8 w# s1 z% W0 y- a! o* ]; e3 t1 M8 V' \# X; I; C9 D! k: R
#include <asm/mach-types.h>" i" G: {! }1 B0 t' P$ B
#include <asm/mach/arch.h>( _2 J" V8 D4 h f
#include <mach/da8xx.h>- v& {+ l' f. e. t1 w7 U* s- t
#include <mach/mux.h>
# O( @8 _! \" K- e; X7 n7 U
6 @% I1 J- J! |0 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* h( q- Q3 n4 ]8 F H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 T+ w4 t0 @3 a4 n% N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 p% y l6 E0 ?! v0 G) X, r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# n3 n* @7 n% A* D3 `3 O
& p/ U7 Y+ c; y3 D7 L/* assign the tl som board LED-GPIOs*/3 }9 Y2 R7 u; \% w; t/ n
static const short da850_evm_tl_user_led_pins[] = {% G5 ?& R4 D+ x( G$ a: K$ R N3 ?
/* These pins are definition at <mach/mux.h> file */7 H0 X% v6 }# z8 a- b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# I/ M8 G/ A2 {
-1; g+ t! O( O! c( y$ M; T) p
};
1 d! z( s( M+ V$ G6 X: H y
5 G0 u& V- q$ I7 nstatic struct gpio_led da850_evm_tl_leds[] = {
2 {* K3 Y. ~6 m {
$ z1 W. h/ Q; a9 J5 G6 p. o .active_low = 0,3 L- E6 s Z/ h; S" m7 N# E1 ^) ~
.gpio = DA850_USER_LED0,4 v0 t! H5 X' a' a c- d1 T9 K
.name = "user_led0",
" ], U9 i9 i! M5 y, b X: H) N) E' @ .default_trigger = "default-on",
' L8 n5 J- ?: n* @# @1 L" | },6 L, b1 A. R. v% _6 r7 E5 l5 O
{
U/ m" L. y/ }" n .active_low = 0,% l" [ v1 Y2 ]+ s. o
.gpio = DA850_USER_LED1,1 p1 a, D9 E' k6 N
.name = "user_led1",; h+ H1 s+ h5 X' J
.default_trigger = "default-on",
/ T' U- c0 D5 ?9 D! a },3 b/ M! z7 B- {5 J5 C- n# X
{3 q8 k' |7 |: Z5 A2 C+ j
.active_low = 0,4 ?. H. O& S) ~+ T
.gpio = DA850_USER_LED2,
9 ] m& v/ s/ h+ K; T+ \- G7 d .name = "user_led2",
; U7 X" Q9 K1 k( j .default_trigger = "default-on",) d& K- I0 T- G1 a3 y9 A
},: {. f8 M R8 a0 w( ^" y9 k! g- P
{- S+ q- [$ B; r/ y$ h1 G$ \( w, C( u
.active_low = 0,8 @' a2 {! {# R1 ~
.gpio = DA850_USER_LED3,* G8 O7 g* [7 w. k* [% W# R, w
.name = "user_led3",% w: U' c: `5 G% r
.default_trigger = "default-on",
9 ^. Y% M+ B) G0 z/ ^- i5 @: x }," U( L0 m- U" I* n
};
T7 I4 v% M( y$ W# |
1 f2 k; J' E' r! ` `6 V- o( \8 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 |' |! \" _8 C! K, `1 p! I
.leds = da850_evm_tl_leds,
' a* {9 R3 [) E; c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* V# }8 ]4 Y5 i* O0 j; j4 ?
};
2 X A7 y! x, M3 B9 ]
; m6 F4 {7 T6 Rstatic void led_dev_release(struct device *dev)3 [* k: P1 i- E/ Z
{" `: }8 Z0 ?5 f# \- L
};7 U- _( t6 w: D6 S6 \ W5 ^3 W7 z
$ ~ `7 d3 k8 i( t* xstatic struct platform_device da850_evm_tl_leds_device = {
! ~+ U# ^' H6 ?: H' M* X8 t .name = "leds-gpio",
& |3 K, D: f( Z! [" X# P3 P- ]' } .id = 1,
9 ]5 m( {2 x3 W: B0 W .dev = {
) W( V* s3 g: a8 w7 `4 i, @ .platform_data = &da850_evm_tl_leds_pdata,
6 A3 ] X) \3 c .release = led_dev_release,& q- |, e1 v/ H& e4 m: d: |# u- v
}& z& ]1 h2 }# Q. J9 Z5 Y
};
4 F% N' t3 T1 x2 b; ?: N# W% x5 I& O4 ?
static int __init led_platform_init(void)& a& l+ R4 I1 a% X. Q
{
3 A+ G% W5 @6 V3 [1 J int ret;: e" F: l9 a2 x7 \, P
#if 0
w5 q) w- x" A# `1 X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 U' g, u! o4 ?; |; O( O# z if (ret)
! I a' y, ?7 K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 ]! r, L& e) }3 M, C "%d\n", ret);4 z O5 x/ j# x
#endif* d+ ~5 v+ F5 j. E2 Z3 d0 z
ret = platform_device_register(&da850_evm_tl_leds_device);
9 u6 L; @) L" O( [ if (ret)
+ i: k; H+ u+ x4 J! @ pr_warning("Could not register som GPIO expander LEDS");4 l" ?, S) X4 @& f
else
5 \1 t/ z0 z( K& h, c) y printk(KERN_INFO "LED register sucessful!\n");
+ F( ?0 Q% n1 b9 G- d
! J4 \, }7 a4 R6 X* I1 Y* g4 K return ret;' V& J9 g/ Q! c+ ~5 _, ]% p
}
% h; ~4 i; ^8 I$ L) _" n& b* M" U9 c* s
static void __exit led_platform_exit(void)& Z. p) F' A( o, L0 P4 c2 k
{
- ]+ Z: G; n$ M/ D7 { platform_device_unregister(&da850_evm_tl_leds_device);
4 p i8 t) `, p3 t) s
$ l6 d( m3 H- G) ] printk(KERN_INFO "LED unregister!\n");6 e/ e; k5 ]2 \" w& L
}2 m' N H' U5 T& f. `; X' k
6 B# @6 y2 g1 g9 y* D( P" S
module_init(led_platform_init);
; [( [4 c0 j5 ~7 `; K/ Jmodule_exit(led_platform_exit);7 X# A8 w% G* j* R% ~& ?5 Q
& x, T7 {9 t. {9 d; ~8 y# Y5 W3 I7 s
MODULE_DESCRIPTION("Led platform driver");
/ N8 v7 `1 w4 i9 s8 bMODULE_AUTHOR("Tronlong");$ D1 `0 C& R/ b0 K6 l& ~$ b
MODULE_LICENSE("GPL");- v J$ o" c3 c. I V6 O
+ i' q8 x5 `3 a/ K5 \$ e# F) u
|
|