|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! E* n; f$ z! u#include <linux/init.h>
; d( c" ?3 V6 R; L# r#include <linux/module.h>/ h0 b+ i3 S) f
#include <linux/kernel.h>( J, N( m- I6 G& c6 w2 r) ^
#include <linux/types.h>! Q u5 _) [- f2 @& k5 r+ t' M( K
#include <linux/gpio.h>( M$ |1 d* U: u$ `' [% P
#include <linux/leds.h>
# }! v# ?/ T: W1 d#include <linux/platform_device.h>
8 X* h+ L& o+ J. `2 G8 w+ a! z& |; b- |; U+ c; t
#include <asm/mach-types.h>
4 C' ^ V, m( R6 v. s" e#include <asm/mach/arch.h>/ P* ]6 O2 p/ A: U& `$ M
#include <mach/da8xx.h>- |8 I& @7 L9 H7 _7 g/ ?
#include <mach/mux.h>4 ]) H2 X z( y" W" J
5 q$ y# o! O1 L f( H* ?6 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* k J. o% e, x$ t3 _3 Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), ?9 L$ [$ q; a. f! V* {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( F2 k" I, t2 X( I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 _ \( e7 _" g4 p7 L# `+ ^* r- g1 a0 c( n* y
/* assign the tl som board LED-GPIOs*/+ s( j# |, g& K8 N' Y/ [. s
static const short da850_evm_tl_user_led_pins[] = {* w: w) \' C& h& i* W6 h8 T, p
/* These pins are definition at <mach/mux.h> file */+ W: ]' e. V/ F9 {: r% n% `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ H( F3 l5 }4 i2 u& B) _
-1
: J0 A3 D: G, c6 J9 l/ ]};" P, V- K% B" S& q: O6 P
) o$ ~9 ^) R8 dstatic struct gpio_led da850_evm_tl_leds[] = {
4 N. X/ a1 n S" t- `8 f0 E7 |/ r {: n! O1 \8 Q+ D. A( a9 b* `* B
.active_low = 0,, X% ]( p, a4 B# p6 L2 ]
.gpio = DA850_USER_LED0,0 G; s5 j1 L4 o1 }. ]
.name = "user_led0",
. R" L+ o# a5 k. ^& s# ] .default_trigger = "default-on",
0 W2 D6 X: p) @4 T7 ?. B },
; P. \/ }7 h3 N: q; s2 _' P! [ {. e/ _4 ], t5 F
.active_low = 0,
( K+ ^+ T0 J$ v0 z1 i) [ .gpio = DA850_USER_LED1,; ~0 _' T, V1 U- b- Q
.name = "user_led1",
' ?- t. K! `* B9 I, f' W .default_trigger = "default-on",
' L9 m) ~: c, _3 B },* N$ Q" W1 z& H* H; D- x& N. e
{2 U8 u/ z7 b" \3 a8 R
.active_low = 0,& i |5 G0 v. F Z
.gpio = DA850_USER_LED2,7 O' [. Z' s/ a/ k. `
.name = "user_led2",+ H( u) _* F) u) J8 O
.default_trigger = "default-on",* a# c% W1 ^4 x0 N# u' o$ e: M0 T" Z$ i
},* K6 t u7 e* @3 u
{- a6 x# f2 n5 a6 W2 ~
.active_low = 0,# j' j3 Z A* I" e* N
.gpio = DA850_USER_LED3,/ x/ h9 E1 f8 O2 c- ?) s' M
.name = "user_led3",
$ @+ F7 v4 w& R+ u1 M# y, H .default_trigger = "default-on",' l+ X2 X7 c) S0 A0 e: e
},
. ?- a8 ^0 |; L5 t2 N- ]" s};
( h& N- d0 [" r2 a+ y4 }6 y
4 |0 R; K4 P/ L8 ?/ m3 U Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ f% C# h7 ^0 U' V) I
.leds = da850_evm_tl_leds,2 p0 B" I) |% V' m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
F2 j5 K8 j1 L2 v |};" l% [1 s; Z6 K5 k4 t
7 d: j* S' N: q; Kstatic void led_dev_release(struct device *dev)
# N0 v0 ~) Z+ p* I) J+ W{
5 c. B7 T) z6 `};. w. h+ T# _9 X+ M( I: \
- |, u* S( H) z+ r6 j8 s4 s/ y' ?
static struct platform_device da850_evm_tl_leds_device = {
, ~* m- Y; z% t# C .name = "leds-gpio",
! ^ f+ P: V' _1 ^" j .id = 1,
% S. E: Q4 L2 [ .dev = {% ?% U1 G/ L; Z! R) F7 \9 N2 t2 t
.platform_data = &da850_evm_tl_leds_pdata,8 r- M6 v' Q. h5 p' F# {
.release = led_dev_release,, I# c( p5 W: \+ q# Q6 ]' E6 r
}2 l' S {6 B9 y5 q8 V6 ~
};: ^3 W- \" ^8 T. y
7 @5 H# G. U2 \1 f% i+ h+ C
static int __init led_platform_init(void): V5 F) m0 @/ x+ b; _
{& f$ F% c$ d2 d; I* H) Z
int ret;
# d5 B! I5 G, y* P4 r- N#if 05 K9 m# n4 E5 ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; i& C9 U5 B4 a+ W M4 ^3 b if (ret)+ a& l9 X4 W; ^" i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 K9 P5 @* s: p3 { "%d\n", ret);3 _0 `4 T8 ~3 D% \2 {$ D
#endif
+ N) f7 d* ^+ T, O N0 O ret = platform_device_register(&da850_evm_tl_leds_device);+ q+ m# |3 \* ~( K% z! c
if (ret)* L- ~ Y1 D. ^% g2 G
pr_warning("Could not register som GPIO expander LEDS");) w) J F0 d* c+ [4 e
else
( ?7 Y7 D0 I: T* u2 ~: t% ~ printk(KERN_INFO "LED register sucessful!\n");, D4 H/ E2 g" p3 G& e4 v) a$ [
! o& [7 r2 n) @, b return ret;
8 d! ^# g' r5 ^. D% H- p/ ~}
& R/ r( J, x. l W' w) w; C' @" u6 V% I4 D
static void __exit led_platform_exit(void)
5 G: f' n; Q6 d! J8 j{
. v) g J5 Z: }, }0 ^, i platform_device_unregister(&da850_evm_tl_leds_device);
% V& C% F/ m' s# t9 d& p% o6 z1 Y4 r- I$ B
printk(KERN_INFO "LED unregister!\n");
1 f! C0 \3 O+ ?/ @" g# a& H+ e}* d$ {! g; w/ ?1 _+ S, k5 E
( j& f$ Y! X, L6 t* N, imodule_init(led_platform_init);
5 }, s8 q4 u' z" Smodule_exit(led_platform_exit);
' ~2 }( q# C& `, Z3 [& k3 n
4 w& y3 q8 {, e# h# dMODULE_DESCRIPTION("Led platform driver");0 S" O/ a2 w' u! E
MODULE_AUTHOR("Tronlong");
* B0 h# ?9 r8 h& z% B' S$ qMODULE_LICENSE("GPL");
; o @2 Z- U/ u% z; ^ Q1 R% j* M8 e* }" s+ ~. p' \- Q# Z
|
|