|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 a: I/ G/ @. I7 t: r" v' r# }#include <linux/init.h>2 a" [5 N. t1 `3 `
#include <linux/module.h>* t) l5 ^* X7 }) S5 _/ H" p
#include <linux/kernel.h>; A$ o1 {* q; o
#include <linux/types.h>4 Q) y/ } _% x7 }2 a
#include <linux/gpio.h>
m& Z8 I7 j& X4 Y& p$ X3 z#include <linux/leds.h>
( W; d* w) Z( ~4 _#include <linux/platform_device.h>
^& \# L6 [/ R3 }! d6 ?# m! k. e+ @& C) K
#include <asm/mach-types.h>& f# g+ T; u$ v# Q/ y( J; E
#include <asm/mach/arch.h>8 d" y. H3 }/ T" x9 n% r- h
#include <mach/da8xx.h>! v& z4 e; s7 B3 W: _( c; o
#include <mach/mux.h>
2 J7 w; ?& Z5 w/ V" h1 C! c% m; H$ o) X4 T# N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" T9 L. H- B3 y. E7 C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 k0 k/ Q/ F! p4 G' a H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& }+ F @# q( L. `# c4 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% O+ M: B- W6 ~( X% V, e0 m( g1 k) M0 _+ f# A+ B
/* assign the tl som board LED-GPIOs*/3 \* k- L, {9 _8 q7 u5 d& c* P
static const short da850_evm_tl_user_led_pins[] = {
" V( Z5 k0 N0 h" K; p( `8 m /* These pins are definition at <mach/mux.h> file */
1 w E' _* A r# i! x5 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; M+ |1 h( T/ {1 ?3 x7 V3 y -1
- M$ i, S7 J% ]5 J9 P2 [7 K};
! Z3 {. H, \$ f. d- G
7 e6 Q$ j. \# E O/ `; g$ Ustatic struct gpio_led da850_evm_tl_leds[] = {5 d+ B% H" k* [% W5 D6 C
{
$ S3 v: U" b8 U: ]8 v .active_low = 0,3 V" [9 X7 s; I$ x d
.gpio = DA850_USER_LED0,
! N2 k- R* a& f ^( l .name = "user_led0",
; V! M: ]9 A3 f% s# m" x .default_trigger = "default-on",
8 N8 j$ \7 _; [) b) V6 F* \ },: ~3 _9 J6 d) D( }5 N, g: j6 f
{* J. _& U% \) F5 c! |( ^
.active_low = 0,) |6 A$ }6 y) w7 f5 K# j
.gpio = DA850_USER_LED1,. M' N2 s" ~7 v+ k5 M5 j
.name = "user_led1",
: |7 F; ^8 a! h& \ .default_trigger = "default-on",
& n1 K8 d! T1 n1 s( S },
* N( J% c! F2 H- D8 H {
9 R* ]! H% ~6 Q4 B .active_low = 0,
; F( y1 m, Y, h5 T+ ~ .gpio = DA850_USER_LED2,# T4 c* }* P! x2 B [" [$ t% P
.name = "user_led2",
8 W0 ?0 f& ^) X) @- }+ @ .default_trigger = "default-on",
4 p, A3 J1 i6 J3 A2 {5 e },
. v7 e0 n! D% |- K/ h. t* t {
2 p# }: u" x5 P! y3 e: x, b .active_low = 0,% A! l& @; J0 S9 E N$ u# }- ]
.gpio = DA850_USER_LED3,
9 ~1 ]* Q1 Y9 Y1 a7 D' M" P* A a .name = "user_led3",) J' y. R: S5 ^8 _/ d4 b. f; ]+ K" G+ c
.default_trigger = "default-on",2 @3 ]: E& j! H) ~
},
3 U# s' f0 {2 ~+ L};
* z+ t5 t5 K$ P% ?; W. |5 M3 l! j! L* J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! o, M+ g. t8 J( C, G3 g .leds = da850_evm_tl_leds,0 P: B4 t# W. ~! t6 ?" U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 f, K: R: U( j3 b9 A0 T; ~4 B# T};1 N( m" w/ @5 E" U' @
4 x% S4 F2 e$ m; g- f7 L
static void led_dev_release(struct device *dev)
' D9 s" P# [0 v) H9 K{! Y2 ]0 {) ^4 M3 t1 j/ g
};# G o; E0 e' F, Z& t8 d4 G: y
* L: q$ [5 l% Z; q) S( F" w6 [, m- bstatic struct platform_device da850_evm_tl_leds_device = {- G! Y, U9 @( \1 D
.name = "leds-gpio"," x: H3 `; w; @# a" I1 [% q: i
.id = 1,6 a3 E: a5 r K$ Y5 {. d
.dev = {
6 j8 G' H! y2 t) g8 I .platform_data = &da850_evm_tl_leds_pdata,
3 @3 p9 l Z1 f3 A+ n .release = led_dev_release,
6 u; _* m! G w) E4 T J) j }8 T. L! x7 F; t- C0 O
};- U$ E/ \8 q+ D3 `3 m% q/ c
2 `0 N8 d7 ]6 v: C$ Ostatic int __init led_platform_init(void)
) D- v/ B% M* f2 ]1 n5 Y2 [8 H{
* l" w* m8 Y( H' c4 R: s int ret;9 _* F% U1 @. ]
#if 0) I! r7 p# _+ L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 T" u4 ? w+ o; S& Y
if (ret)
7 ^! _ ]- a' F! `2 _$ Y$ I4 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 K0 c M1 n3 L0 f B "%d\n", ret);. K% K# \" ?# {/ Z9 m! T6 M9 `' V
#endif9 k* f' _# B$ Y% X" u9 G7 P6 A2 l
ret = platform_device_register(&da850_evm_tl_leds_device);6 j) @4 [/ h' T
if (ret)
" n; J$ J4 T h: p$ @& ^! z+ g pr_warning("Could not register som GPIO expander LEDS");3 e7 ~. o' L$ S
else- y2 k# `$ e: x6 C: K; P% a
printk(KERN_INFO "LED register sucessful!\n");
: e" v& F& C7 Q& J2 U) ]9 o" l: B( |9 H6 u! G0 b+ p5 ]
return ret;1 c4 d$ A9 F# u# |' S. S
}
* ^( {2 ~. g7 `! }+ ]( z" E6 \% ^8 v p, s C
static void __exit led_platform_exit(void)
( A+ j$ k4 u* m& v a{
; ~9 ^9 D2 `5 O% n5 e+ k platform_device_unregister(&da850_evm_tl_leds_device);
0 m. k3 I% u$ X7 r8 T: E5 [+ g7 H. w- N
printk(KERN_INFO "LED unregister!\n");
: x( s9 Q+ [7 o1 J7 O+ h} k4 J5 E8 a% E6 @& X p
% [1 t! t. M4 ~3 v, c
module_init(led_platform_init);
9 K, z$ g6 n( v+ Umodule_exit(led_platform_exit);
$ K( ~' p& I8 Z% A- Y: l& {
4 N% A- _% _0 s" m: [# SMODULE_DESCRIPTION("Led platform driver");( ?7 A; A4 N- N. p. p8 T4 i/ H
MODULE_AUTHOR("Tronlong");
9 a( y2 [2 F5 I& \2 ?! w% AMODULE_LICENSE("GPL");
/ I" H9 f& o2 [/ z4 M2 Y2 ]( s- _& ?! H- q' d+ w
|
|