|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 X" C- K$ P# _$ m' _ Y
#include <linux/init.h>6 M& u8 y2 G: M" W7 P
#include <linux/module.h>$ }; i s' O# A( b
#include <linux/kernel.h>
, X& D% O( `, L#include <linux/types.h>
2 z. ~, ~5 X* b+ q#include <linux/gpio.h>
9 J9 K, t/ T* |4 w#include <linux/leds.h>
3 q9 p" V9 a" k1 `#include <linux/platform_device.h>
# G4 T4 M) o% ^7 Y- y! j3 U* q* K* z# S* h9 h/ |
#include <asm/mach-types.h>
3 J# e7 y% F+ C) F2 @3 n) \#include <asm/mach/arch.h>8 O7 U8 p3 D' p
#include <mach/da8xx.h>
% S- P8 r$ B! D, g' S# j8 X6 W. J6 n5 F#include <mach/mux.h># q, j a8 Q% e% y l) v6 b3 S$ S
5 N- U( e, H4 S/ ?% z, R/ u+ V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 m' D) d+ c1 x# x v# U) c9 r/ k8 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ k" @: `& g; s$ T1 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" S; l6 Q, ?' u2 s9 A5 D0 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* m/ g# @' F2 v' F
" D6 C( G9 {6 x3 G
/* assign the tl som board LED-GPIOs*/1 s0 H' Q; ?0 x( `
static const short da850_evm_tl_user_led_pins[] = {
r' T- Q4 p f; ] /* These pins are definition at <mach/mux.h> file */) T. n3 S$ J1 l7 m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( [9 J; o ^% |4 V4 m -1" y7 r; c; ]1 d, A) [8 `+ d6 ]
};
7 h0 _+ W/ K& l6 d$ i4 Z2 q, }
) p$ P1 S# A+ h: t( xstatic struct gpio_led da850_evm_tl_leds[] = {
/ L( O; @( e. {( i9 K {
7 @- y5 {3 G& J$ f .active_low = 0,$ u" N6 L* O% M
.gpio = DA850_USER_LED0,( k( w& _7 G1 E6 R% t
.name = "user_led0",
% N9 a( @5 b a+ h .default_trigger = "default-on",
3 x9 }7 c! o3 {8 G$ X6 ~ },
6 y t$ @) Y' J2 f1 Z/ K {
4 u9 e5 G9 Y4 t .active_low = 0,
5 ]2 } }9 g4 ]' d' O .gpio = DA850_USER_LED1," f8 K- V. D6 K$ g0 Y- t
.name = "user_led1",/ `) Y' U, h/ {0 E- t; K5 M# R
.default_trigger = "default-on",; i+ _$ n* a+ ?; G7 O
},+ @* M/ K& ]- s, B7 q
{. p1 y. C2 k7 H Z8 ~
.active_low = 0, h @/ L2 r- Y7 O/ ]; t5 T# b
.gpio = DA850_USER_LED2,) {0 j' R8 J$ a
.name = "user_led2",/ L. m% E! a" _" k. J* i7 J5 _. ^9 _
.default_trigger = "default-on", ?/ b" B3 W& u& K
},. U! z% c+ P$ h* n/ U
{' T7 _. ~1 v2 C _
.active_low = 0,2 h; ~' [5 M; O3 P' u/ c% e/ X# a1 ~
.gpio = DA850_USER_LED3,* n- X0 W6 {5 D# S! U1 d& L
.name = "user_led3",/ M o. ^* w& O1 s" ?+ {: M
.default_trigger = "default-on",) ]4 C9 V# I2 Y* r) }" k
},
& f) X" a* K+ `$ j0 v};0 e% G: r8 }& p, \+ n: O
; E5 Y# N4 ?) S2 N7 \( B5 C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) i( f0 s% j$ v2 t5 Y .leds = da850_evm_tl_leds,$ A3 P3 r2 q7 C7 t9 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ G2 U% b# v0 H) k& V0 {7 s2 C};: Z2 _; y/ G) z
- a: Y5 a- S( k6 cstatic void led_dev_release(struct device *dev)
, {% ~* h; `3 @2 M5 I{" q k+ V$ Y8 ?" `
};
- F9 R9 I% ^: w. A& i
" Q/ c' o! c; ?. h) nstatic struct platform_device da850_evm_tl_leds_device = {
* M6 D+ H4 @1 y' y/ Y2 e( h3 [$ w .name = "leds-gpio",! ^# `' W0 J q5 y. g. G! R. H
.id = 1,
/ s; s$ C# ?: c1 _" { .dev = {1 C* F7 X( x, A3 }! \$ @
.platform_data = &da850_evm_tl_leds_pdata,1 T8 }- ?" b& ?) e
.release = led_dev_release,- C- }+ y5 p k/ }6 l5 k
}
2 [; L0 D+ U* M! Z; h( _3 ]5 S7 ]}; C- ~. h# a% {- W- b
# V; k$ u, P' H9 E* ]( M0 r7 _6 ustatic int __init led_platform_init(void)# ?+ B7 q* R9 S, a: u
{
% C- {6 u7 a0 T: ~ int ret;
# k4 Q( \$ J) s i& `. N#if 0
$ E! Z2 |8 C3 T: s" [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ i) p; ?7 v* A. K' `& c* ?
if (ret)2 l8 e, b! J1 r4 n1 h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 L9 Y$ ^) }( ^ "%d\n", ret);
; A. O2 S5 I% E3 [ V* K; b#endif1 o: q( j) Y$ f9 |& C+ U8 _& |; y
ret = platform_device_register(&da850_evm_tl_leds_device);
) K8 {( H o# y3 u2 S9 j if (ret)
`% i/ }3 c! v pr_warning("Could not register som GPIO expander LEDS");% z! U# [6 W& \- X# G
else
2 U; S2 Q% J6 z( Q printk(KERN_INFO "LED register sucessful!\n");
2 Y/ E1 J) ^( ?* [* w- N: S0 q
1 A0 e- d v7 P0 Z3 Y( \$ \- a4 O, ~$ h- P return ret;8 ^, g9 D- d# a$ }3 }8 q/ } R1 t. n
}
" S/ h/ F; @1 D3 L
3 [: g: `; _& g3 Y& t# Gstatic void __exit led_platform_exit(void)
' I0 U) n3 r: O$ z( ]5 ]{& M# r; {# k* K6 N+ i
platform_device_unregister(&da850_evm_tl_leds_device);
/ s A4 s! C; L" A* g+ \1 ^/ V# |+ l5 |; P
printk(KERN_INFO "LED unregister!\n");
/ h( W% B& a: R0 c7 h4 a# B( p}
M5 g- y7 m8 r f; A. F. B" o1 J! Z' R" t( q
module_init(led_platform_init);
5 I/ ~; ~ l/ R$ g2 O+ C8 ymodule_exit(led_platform_exit);
0 y* l, x! b/ W, @8 q5 t
5 L1 k1 Q" V8 ]8 r0 z+ h. AMODULE_DESCRIPTION("Led platform driver");
: Y) c6 v4 I @9 \4 k P. ?% EMODULE_AUTHOR("Tronlong");
" h! p5 v6 y9 k, EMODULE_LICENSE("GPL");) G! ~/ z( A8 r$ i, X7 y
7 I2 K6 C1 x' `8 ~2 H |
|