|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; n+ N! i7 ^2 G- R9 W& C
#include <linux/init.h>" c; |; l8 w# }! `% z
#include <linux/module.h>( C* {& G" D+ s) Q
#include <linux/kernel.h>8 x7 Z$ U# y* ~) @
#include <linux/types.h>
" K5 w& S3 [3 `9 P( Q5 b& k& e#include <linux/gpio.h>
$ h8 T/ w9 o# D* c$ W6 x#include <linux/leds.h>+ B7 G6 I; w$ M& R
#include <linux/platform_device.h>
( F" |" L: f; n8 @ I
' y1 w# p/ {- M' T#include <asm/mach-types.h>" s" V& r- J3 o/ J+ T) M0 ]
#include <asm/mach/arch.h>" W. ?6 @# b# y6 N
#include <mach/da8xx.h># c6 D; R1 [ f
#include <mach/mux.h> R; Z% M) m3 S) L
6 x4 J! M% p, k9 g' g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 g- _9 C6 b7 ]0 F/ \+ t* n; G. n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% `4 r; ?" Z; i& {! X# z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 q! j; B! S7 d; x+ b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); I% D0 O/ G( M4 Z9 v" o7 g
7 e' b, g. }& h j B
/* assign the tl som board LED-GPIOs*/
: W" N5 R' S lstatic const short da850_evm_tl_user_led_pins[] = {: c$ A# x! G' s) k$ X3 R `
/* These pins are definition at <mach/mux.h> file */
8 q0 ^. O+ V; H- a5 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 a. l. x& x' \$ p6 l -1
) a' L0 b9 [/ D( l6 x% m4 O};
! s% f, Y5 L) G, Z) z1 ?2 c" E% s
static struct gpio_led da850_evm_tl_leds[] = {
& q4 e5 d* K: @# h0 r {
& b j) F4 n8 o .active_low = 0,4 z4 M: h7 B4 a+ t6 W0 l
.gpio = DA850_USER_LED0,& @& m# t! V. `: i7 X
.name = "user_led0",' ?+ {9 E+ I; S6 R5 j/ P* }
.default_trigger = "default-on",! L! g! u1 Y6 u7 i" }6 ~, {
},
3 d' t. r W# e" ? M {" l( _0 Q! c/ x- V# X
.active_low = 0,
/ Z j9 X$ V4 F7 X# w: D+ V .gpio = DA850_USER_LED1,
: _2 b, E+ M. [- r7 \ .name = "user_led1",
! n/ _2 E" S5 X o .default_trigger = "default-on",, F2 E8 u. `, K9 s) m" G
},
) S: t8 S) M2 i& b {% T0 `) S( Y; F" N$ M& f0 \9 x
.active_low = 0,
. I( @! h; \/ H .gpio = DA850_USER_LED2,! H4 i8 o8 x: l. I4 |
.name = "user_led2",
5 v- t7 P- O' l# G: ]# Q8 y .default_trigger = "default-on",: `; M5 R) r6 ]8 H# [
},* P, N* N3 V# Y% y
{
1 w2 A6 N/ Q2 Q- Y: F' e( Z .active_low = 0,$ A, S- `: J" d, d4 X8 j
.gpio = DA850_USER_LED3,
* S v" y' G6 b) }& B3 T .name = "user_led3",
7 |! t2 P' @8 p: x( k' F .default_trigger = "default-on",( m, `- [' \& m# H( _ n
},% @( t2 m6 d8 T+ k
};1 ]6 A2 F" N8 t
1 k/ K) w; d5 U; K }- Q5 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* `, U: x T* A% X+ m4 w5 Z2 Y .leds = da850_evm_tl_leds,! @2 o1 Z$ k" {3 T4 d/ N3 A7 \/ Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ ~2 w& ^6 h) V};
4 `/ K& P+ u/ t0 b3 L
2 Z1 p2 m% z3 @static void led_dev_release(struct device *dev)8 n7 U l# e" \% o( |' G5 T/ {
{
% S7 S, m; Y2 N/ L9 p0 f};( G! C, B% c, o7 {! D# T8 x: I
/ o& [7 e, q$ h! X
static struct platform_device da850_evm_tl_leds_device = {
" Y4 X5 Y( m+ r. T .name = "leds-gpio",
( _8 k' `( j' v: _# p .id = 1,: b% k/ U: X& k' e6 b9 H5 H4 Z
.dev = {
3 L7 R6 M, o1 X7 T .platform_data = &da850_evm_tl_leds_pdata,
9 [2 W' X8 y, W. k8 { .release = led_dev_release,. z s! Z$ L* M) Q- `6 V
}, A+ m& r& T. w) J
};: k, P( P: o" X* m1 d: R9 W1 o
A/ H' d+ {1 ]6 q* @# d8 j
static int __init led_platform_init(void)
* s, U: ^1 x4 v8 D' H4 P{
y. a. N* U& V" ]$ P% |6 ] int ret;( a4 T% @& c7 S# y
#if 0
% `4 E! K" @. v' d ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 H8 Z& b" ]! k! D. e' T' Z" `4 i
if (ret)/ A$ f: Q& F9 U. [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ a; x8 H M/ @; e; a& a
"%d\n", ret);
/ E7 a0 P; v5 U* t( N#endif
# P- L: j6 E' W" _ j; n. {1 T ret = platform_device_register(&da850_evm_tl_leds_device);. |' k; ^+ k" n' B. S. t" @
if (ret): M t$ x; T/ C
pr_warning("Could not register som GPIO expander LEDS");# j& \% q! [2 D; [1 u% Q
else
9 {1 `8 q! r2 Q) p( W* q* B/ @ printk(KERN_INFO "LED register sucessful!\n");
5 l0 m" l+ e- j& F. F
6 O1 \/ }2 S/ M" A- ~ return ret;
) k5 a3 P9 r5 J3 N$ O w}
0 {0 C: v b8 @5 r, V. V0 r9 X5 ^6 \4 @! e% W T0 O
static void __exit led_platform_exit(void)' L+ C2 l1 _% K
{
" I1 n) E. Z# h& m" Z% V platform_device_unregister(&da850_evm_tl_leds_device);
' W7 B" z' e4 _2 E$ {' W# s- a0 j& ~' R9 ?- ~: K
printk(KERN_INFO "LED unregister!\n");& A1 n$ ~* J: J! N; s
}
0 `0 J. _ _7 u% R/ |' v5 F, \; E" Q9 ?. [3 z& K
module_init(led_platform_init);7 ]( ~/ k( E: R0 z* S* P& U
module_exit(led_platform_exit);
6 ]+ e. \& ]6 p$ Q
% \( O: S; k- n8 I$ l3 l% tMODULE_DESCRIPTION("Led platform driver");
/ V1 T6 x* c2 r: U6 a) [$ S) SMODULE_AUTHOR("Tronlong");
2 c3 c& w1 j1 `9 D1 BMODULE_LICENSE("GPL");
3 V$ q& H; t, g9 |% d; V( C( I
7 ? S3 n* U' w |
|