|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ p, Y! i: X4 S& k& b5 y
#include <linux/init.h>( E1 `5 G0 |# N' A: a: }
#include <linux/module.h>
9 V5 t* G1 @ P t- _ S) x3 Z#include <linux/kernel.h>
. i) o; R& @7 u; e( v! z" J" P$ J7 _! ^#include <linux/types.h>
: j0 c1 t9 `! b3 Y* {: C: A, J#include <linux/gpio.h>
4 Z5 z: c6 L- E' r1 a#include <linux/leds.h>
- S) ~- f7 k) V0 {#include <linux/platform_device.h>" E3 Y6 Z- K8 D4 `+ P/ J- x) a D4 K
/ ?# M/ P4 i D+ m( E
#include <asm/mach-types.h>! b. g6 Y, R# U0 P9 q
#include <asm/mach/arch.h>+ K U. o, G3 }
#include <mach/da8xx.h>
1 Z. B3 U( C1 i, h) f#include <mach/mux.h>" {' a1 m6 z% i
% r% k6 l" y' j2 `/ b# ?5 b" p+ D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ V& n* o' @! n5 f0 s- d% a, k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) s2 T& O$ |, ~; q* N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) S: V) C5 _! ?. V0 ^1 r* L, m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( B2 s+ k, D5 l1 \3 s- ?
) o, ~) m7 n- d$ Z/* assign the tl som board LED-GPIOs*/$ v. j1 U, ~" Z2 H5 c" r5 W% V* z
static const short da850_evm_tl_user_led_pins[] = {6 R w1 Q0 k$ Q, \
/* These pins are definition at <mach/mux.h> file */+ J3 w- J# `$ b1 S$ D/ q8 _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: I" ?# a1 [! o, W' E6 K/ c -15 Y! R; G V4 z! ~. l- o; T' w
};' N$ _ e& |' v. m+ Y
! c* h$ ^) g7 S/ K, T$ Z5 Qstatic struct gpio_led da850_evm_tl_leds[] = {2 J5 r ~' X, ?3 e
{8 Y# _% f$ k- ]. u$ C
.active_low = 0,
) @: ~! {7 i3 g .gpio = DA850_USER_LED0,
8 R x9 g& b/ [ .name = "user_led0",
% ~3 A) U/ u" Q' t7 o .default_trigger = "default-on",
* C% D! x/ }2 f" S. f# i2 d },/ l& G9 ^& T; g( @2 C/ A' F
{
$ B/ m7 z* V2 r4 T .active_low = 0,: ]/ ?+ p/ d P9 E! _+ b
.gpio = DA850_USER_LED1,+ N* s3 j# [( j3 S# J
.name = "user_led1",
, i/ W; d& n' c3 R6 ~9 N0 R; X& Q .default_trigger = "default-on",+ e, h# n8 g3 A- n9 O
},; l/ y) C8 F' @' A
{
: v: T1 E: F+ }, H .active_low = 0,7 Y4 v! {( W* m/ w% q. @: x7 l
.gpio = DA850_USER_LED2,, I( p# j9 N9 ?# g
.name = "user_led2",
" d1 _- T8 n: M- v .default_trigger = "default-on",3 ]$ J5 @9 b0 M/ I' \# T' \# y
},
& W. W; J3 }1 u' m( C {
0 V- z! Y; n) q7 L .active_low = 0,
' c' n$ U: d: L) Q) f8 `/ E .gpio = DA850_USER_LED3,
" t1 F5 j+ t- p$ f6 k1 Z7 d .name = "user_led3", H" D) S$ i+ c- ]6 L& d9 z
.default_trigger = "default-on",# g9 Q% O8 s% o
},% K+ @' o0 l1 E+ d0 ^' v
};
+ _; C p! _ }* T9 |; J; U9 \8 l8 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 d6 g( m5 r$ p% R2 e5 g* L
.leds = da850_evm_tl_leds,
- h1 M2 H5 q l4 ^ c2 V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% k* D; e" H( Z9 x
};1 t8 ^5 \6 ^+ z+ j) H4 J
1 s6 }8 i# W* O& R
static void led_dev_release(struct device *dev); ?/ O \5 k0 ?* M# M
{9 R& @% @$ @& A! m
};" L7 r3 a3 b6 O% X- F( @
4 i9 W/ X. C1 ?4 Y, U; b. i
static struct platform_device da850_evm_tl_leds_device = {
% i% ^1 a! v# a6 t1 v4 i6 ` .name = "leds-gpio",4 _$ ^: _; r* F# Z
.id = 1,( x% u Y6 o5 e4 c# G7 }( s
.dev = {3 s/ g# B8 D" c, X$ @
.platform_data = &da850_evm_tl_leds_pdata,
/ N( X0 j' s" J8 j* t* Y9 ?7 L* h2 y .release = led_dev_release,4 b/ S" I9 {9 ^
}) m' H* w# G! O& ?, E3 ^
};
, _& e7 x x0 E& ]
* b. o. I" l9 m' lstatic int __init led_platform_init(void)/ I$ S9 N) c8 C
{
9 [ E' I8 O4 G9 P3 ?+ a int ret;% I. w `/ n% N9 u {! ^
#if 05 a0 _4 s5 G% ~# J) h8 D, \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 l2 I6 V; N# g if (ret)
+ o* G$ B3 O5 t9 z1 Y$ c0 s( m0 @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ z1 m% [# n' Q1 F @5 k6 Z2 F "%d\n", ret);
! K0 v- V9 H1 R9 Y! X2 V#endif9 u$ t. o7 s. t& q
ret = platform_device_register(&da850_evm_tl_leds_device);
) Y6 v7 {2 p+ W3 I if (ret)
* g' x0 B' w: s9 E pr_warning("Could not register som GPIO expander LEDS");
4 g* N) C5 g# I3 |. j+ F else4 c# p& m# t) e, k
printk(KERN_INFO "LED register sucessful!\n");
$ D7 a8 _& M- D% N9 l. f; B& V
/ N# P% Z/ d( E! I return ret;
3 T) H* S" N- B2 Z) h}* {; ^4 q# S+ C7 M3 f3 x
; h( T! `& l {static void __exit led_platform_exit(void)& a8 I& a( U4 a) |
{
9 p6 k9 R" m0 n- q platform_device_unregister(&da850_evm_tl_leds_device);, i% a% u. E& b9 y
{3 T+ y- g8 A/ R4 T" l9 U7 O4 i
printk(KERN_INFO "LED unregister!\n");8 L8 [- D) Q1 V$ W( R: `
}
4 a6 I9 ~3 S, _& O _7 B
6 V& s/ Y5 w$ o3 u Omodule_init(led_platform_init);
3 ?, \4 B8 j$ g6 h& v7 fmodule_exit(led_platform_exit);
# Q' j) K6 c: y, G7 T8 q0 Y& T: c5 B, \/ u h0 |: t; S- F
MODULE_DESCRIPTION("Led platform driver");- z! C* J* R+ U( z% W0 O9 k
MODULE_AUTHOR("Tronlong");
* V6 k% A% U( \6 g* mMODULE_LICENSE("GPL");: Y8 K6 R9 v" v/ |% K4 b
+ A1 S/ n" e6 \& {" s) \
|
|