|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) d: Z6 n/ b3 ]8 e. _#include <linux/init.h>$ [% P' A4 D+ H1 Z5 z! a
#include <linux/module.h>: e' N; a1 p1 k! l" k! V
#include <linux/kernel.h>
! @ w2 t! f1 a% Y$ m8 e3 n( p#include <linux/types.h>3 l, S0 T( {" P8 Z6 O P- {
#include <linux/gpio.h>
1 s' J' q3 e% _4 G1 n, r#include <linux/leds.h>
& ^9 R( Z- m! z; M, d% ~% q#include <linux/platform_device.h>0 i- H' v: @( p, Y" i
& k9 P9 j/ D, R' X1 i! ^6 g$ z
#include <asm/mach-types.h>& v+ p2 |' }# d* I$ d" Z
#include <asm/mach/arch.h>: t: L# L2 e% H1 O, B( l
#include <mach/da8xx.h>
4 J& e$ [% n# m2 ?( c#include <mach/mux.h>
* d% u- `* u2 h, P$ [( e$ d( M4 o' x" F( ? [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ f1 _# g5 i( V- g d3 M8 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# E# m- E- Z) j1 a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 W& P; P. [- r" \1 `' ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' B; _0 a. ]' n9 m3 P1 W+ C* P+ Z0 |7 C9 W a% N! Z
/* assign the tl som board LED-GPIOs*/( i& ?+ W" [( A4 k2 h( E) e
static const short da850_evm_tl_user_led_pins[] = {
/ N7 s0 X, D9 ]4 }0 t8 J /* These pins are definition at <mach/mux.h> file */
! {! A5 I/ I9 U/ ^" g2 e3 L% [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- ~8 F' V _4 M' {- D' S -1
& ]' j( w' W C. \( r};
- n/ o, `% O' v C$ ]+ p
( y3 L, `& C3 i# G" b4 M; Vstatic struct gpio_led da850_evm_tl_leds[] = {8 g) j4 x5 K- {+ v f6 J( H5 I4 W( G
{
" m- K* F; C$ P+ ~ .active_low = 0,
% D* R' O6 L# \# u; P .gpio = DA850_USER_LED0,
; H, q: X) t1 C/ N2 v& R4 H .name = "user_led0",3 V a* E+ D2 u6 d( F( ^
.default_trigger = "default-on",
8 @6 Q/ Q$ {, M" ~- i" a },
, s: ` @. _; d! ~4 B/ u* W {
& z2 g* {. N1 ^1 X$ F% S .active_low = 0,& [' a6 }4 z/ M
.gpio = DA850_USER_LED1,5 w" s- D L. O0 M. o
.name = "user_led1",
$ D3 h! h; {3 O* p' C4 M, ^% ^ .default_trigger = "default-on",
4 g5 O+ r' f9 t+ Q6 \/ e' ~! h. |1 r }, J+ q8 y0 k1 I" {5 \
{ e: \- b& q/ Y1 w/ _
.active_low = 0,
# m, O% E+ g$ w" O$ \3 }$ L5 l .gpio = DA850_USER_LED2,
; W( I( ]& T4 v# R0 @- d: }& m4 e$ r .name = "user_led2",
# b7 p( @- E& O' z+ ]" ? .default_trigger = "default-on",( w8 F+ R/ d$ Q% ^5 r1 H
},
. H F2 ?5 Q2 ]8 g" D {9 k9 ]5 C( ]' w- G. \
.active_low = 0,( T5 Z' O* M. A# }) ?# b O
.gpio = DA850_USER_LED3,( g$ b+ J2 w0 y% L. H: h
.name = "user_led3",% T! @; {3 a; |& P$ \
.default_trigger = "default-on",
* V3 L2 [8 l0 [ },0 X ]; f' P5 h( T* U# Q/ V( S
};! ]/ g* d# [1 @$ e" |
: ` b. @7 F' j/ H E6 l) _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( x( U) [0 z5 @5 u: n
.leds = da850_evm_tl_leds,4 Z/ c7 \' Z( l1 |* L; P9 F8 Y, n) t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, @/ E. l: T! @};
: Y0 b% _8 a6 k- g8 x* Z! I9 r' {2 d7 y8 z9 @. i% B1 R
static void led_dev_release(struct device *dev)
! @2 n7 K8 a7 I# w4 P, V1 N0 E{
% l6 {+ M* [, T};
) q6 n$ A4 M2 d1 }2 K$ `0 @. h
z @& L0 Y' y2 r, N0 j7 O2 cstatic struct platform_device da850_evm_tl_leds_device = {
0 o& B+ j M: a, J" A& i .name = "leds-gpio",5 ]9 i2 E2 G* L/ G9 q
.id = 1,
6 K% _7 r; f# R; y5 b .dev = {) S3 x" a. U# _1 _
.platform_data = &da850_evm_tl_leds_pdata,
. l! f& f, |1 v, l* p4 w .release = led_dev_release,: i& y0 v$ Q0 x/ V
}8 E$ `2 Q& n N1 C" {* z; o7 k
};
' Z8 u% S% P* N" X
1 r3 b: G2 H- W7 V, nstatic int __init led_platform_init(void)) P) Y, w( q) H/ Y5 z
{ ]) Z8 Q1 A# x/ U% x+ w+ q
int ret;$ G; I2 @4 W; ?3 N
#if 0
7 Q$ c+ @. B# V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 Z: v' K6 `0 Z9 D0 C/ D if (ret)
' U4 R# Z3 h. a) E$ N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 v3 |* K# y. O( C3 F
"%d\n", ret);( a9 F. n2 L! d2 L# M4 @. V/ Y
#endif
/ E/ g9 v) {' c* J ret = platform_device_register(&da850_evm_tl_leds_device);3 M2 D0 M& ]( W2 ~# n; K4 D& c
if (ret)! `, I$ u" ~3 e5 s+ A
pr_warning("Could not register som GPIO expander LEDS");
; H$ @- n( Z5 i' i4 Q# Y `/ j else( v; N" O' [- n' G( k+ t+ S
printk(KERN_INFO "LED register sucessful!\n");+ S3 M, S8 T K$ _5 M. f# `
) H1 G/ M, U2 S) F- Y0 J return ret;% H- r) Q0 d6 A4 k7 A
}3 V( w, C# d* T" y$ J
) l! w4 Y" a7 F0 \: ?' |! Z
static void __exit led_platform_exit(void)
$ { t2 ^! b: K! m( ]{
( F$ s+ k0 X% Q, z5 U0 | platform_device_unregister(&da850_evm_tl_leds_device);
0 u7 K& D3 e7 a2 r3 W& X9 [
N1 W) y, o8 I' Q$ P printk(KERN_INFO "LED unregister!\n");
6 n( t% ~2 F, d% {}
1 r% t9 O' x9 d% K( |# f( S9 @1 |. q2 V' O7 u" E9 K
module_init(led_platform_init);( C' {; X. f( Z/ |& L
module_exit(led_platform_exit);
2 p. m" Q+ c- L" q! j
% }0 E7 t6 q1 K9 i. c. c% FMODULE_DESCRIPTION("Led platform driver");: M6 Q! i+ q- N/ T! V! q
MODULE_AUTHOR("Tronlong");% I9 F% h: `$ E; ]
MODULE_LICENSE("GPL");
+ _8 Q# r y; r3 v
+ R! h" ^4 o4 }% ~: I7 p- A |
|