|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' l0 l7 P# C: x- V4 T#include <linux/init.h>
# U" r8 A/ @( _, v#include <linux/module.h>) H' |9 Y6 u3 h, K
#include <linux/kernel.h>
0 N$ h. R: }+ C# F5 {% y1 y9 \#include <linux/types.h>* a5 {2 |& w+ s; u/ S! m
#include <linux/gpio.h>( B$ K: X/ }( c# O3 s, x( w
#include <linux/leds.h>2 \1 t+ t9 j/ u/ ?! D
#include <linux/platform_device.h>' o8 q6 Q, Y! q# s+ m
( R& M/ \0 r$ i6 @3 D#include <asm/mach-types.h>2 }; `$ b& D* R7 \
#include <asm/mach/arch.h> N( t/ r5 x8 v- s2 E; L
#include <mach/da8xx.h>
; I R2 e" G7 W#include <mach/mux.h>) S' \$ _* r* [
5 b6 D; _, \( e7 H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- C( ?9 H5 R6 J; f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 |/ C" E+ _& S% q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& F4 l) d# y( {: ?% B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 \$ t/ t( p/ t( u# @, w6 Y: }
0 ?3 v; @ U7 g2 O
/* assign the tl som board LED-GPIOs*/+ A( j& K6 ~4 B! e
static const short da850_evm_tl_user_led_pins[] = {
2 @# W' l, z# g8 e r /* These pins are definition at <mach/mux.h> file */) r( Q* s. r% R1 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 v' K: i4 [ I -1
9 H& \4 j& R; ?; X};
3 K o8 Q4 W$ y x
9 y- v3 b( z" B9 m6 Y0 bstatic struct gpio_led da850_evm_tl_leds[] = {) I \/ e& b% D1 H- s
{) \" a1 a9 n7 ]6 W" | \
.active_low = 0,
0 k: y3 V: [, V/ V .gpio = DA850_USER_LED0,
7 T m* o; P( s; x, X* }$ R .name = "user_led0",6 D% P" ^! i) t+ s: W: p
.default_trigger = "default-on"," l2 V# g @% N. r K
}, Q! l' e9 _# n" [
{
6 c: [# Q# P, y7 p. \$ f4 U. K .active_low = 0,, n3 _8 [ f3 V1 M3 X3 W+ n
.gpio = DA850_USER_LED1,
6 }. U" J3 |& f: ]! Y( E4 e .name = "user_led1",9 q# n i$ Y c" C: Q e
.default_trigger = "default-on",& j; @2 {2 L4 w: ^
},) C/ N$ @0 a6 N" s4 ?: L9 n
{
; c: k! v7 S! x/ e' E .active_low = 0,7 a }2 t! o/ O! h: I
.gpio = DA850_USER_LED2,
7 b$ b( R# G0 d# h0 N: J1 t .name = "user_led2",
4 k: x0 b! y2 \4 [' y# Q9 u .default_trigger = "default-on",
' t6 i2 {) c$ F* K },6 o) P- w$ c9 K& K: |2 B+ G+ \; r
{
+ G- T' M s8 j .active_low = 0,2 M' N, x4 |/ Y5 o7 C/ }/ z# N; \$ O3 H7 J
.gpio = DA850_USER_LED3,% y9 x$ V3 a& v; `/ l+ s
.name = "user_led3",- i: \0 |) F7 M6 q( Q
.default_trigger = "default-on",- |- X$ \' l8 n* [8 `* ?
},+ N) F0 R3 x8 [- w5 A4 ]' m
};
) O# U+ t7 \$ T8 K
% h8 T. l+ m9 T6 {. W4 W3 L+ I7 Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ m9 M k$ q2 W; E3 d2 u
.leds = da850_evm_tl_leds,4 o) l! y6 o8 o, Z! k% e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ q1 a9 r' N, P1 R+ J# c+ w};6 |# h; f) z/ y) [% ]/ O7 p
" G& |# a9 ^/ t1 F3 N. \& Bstatic void led_dev_release(struct device *dev); J9 c. l7 h2 o* @+ y' S
{7 s4 O1 u$ Z- }/ ?2 A
};0 t& ]5 i; p/ s9 [5 u6 b
* O& ~! e1 Z2 N% v7 u
static struct platform_device da850_evm_tl_leds_device = {0 c R5 S7 f3 C
.name = "leds-gpio",
m* L+ k- T) `4 i) R$ \ .id = 1,
% ? s0 d0 Z" _# | .dev = {
. K8 f/ w4 P+ R! v6 r; u: F8 B .platform_data = &da850_evm_tl_leds_pdata, N! m" J0 P$ e5 c# {* F8 a# O( B
.release = led_dev_release,! V+ o0 G1 d2 \7 c
}
/ U' U& R( f; D% k5 h( d};
5 E: U6 q, M: d$ H6 }
]' S7 f& p( g) `' hstatic int __init led_platform_init(void)0 ?8 l ?3 k% T/ ?
{
; @: g9 k4 Y- {$ l" T5 B0 P7 y9 ^ int ret;
# O/ x h2 T; y3 j7 A& c: X( _#if 0
7 V0 t2 n+ B+ P1 ]$ i7 L& s2 ?) ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. v7 {& Q9 l& i' b if (ret)
& T9 J" g; O/ o6 f# L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 t0 @; I4 W9 Q& E7 e; {/ F T2 ~
"%d\n", ret);
# w! f2 K* G/ f$ [" {#endif
+ V) t6 J( F2 o% E ret = platform_device_register(&da850_evm_tl_leds_device);
. c! q+ o g0 U: L% s- R7 _/ F if (ret)" e3 a7 Q/ u: V% I6 e% P
pr_warning("Could not register som GPIO expander LEDS");
/ w+ O5 W) B* G% S else" \9 G) l j$ Y, B' Z
printk(KERN_INFO "LED register sucessful!\n");
4 Q1 Q6 ^$ d2 P) ^* Y' M! L+ k6 {0 ]% O8 r
return ret;
! c8 H4 U" \6 N- o$ ]0 ?" M}/ m0 r, H. m! {# a
/ l0 q9 |5 n0 w* f I9 a. K7 r. L
static void __exit led_platform_exit(void)- K" k& y* y y% J- W g: W3 m
{ b* G5 L8 \0 y: S
platform_device_unregister(&da850_evm_tl_leds_device);/ V% j- Z' X3 u6 C9 C$ V
( c! f9 j0 ~ H: Z' r3 D printk(KERN_INFO "LED unregister!\n");
: s. m; v* z" ~: Z2 o}
1 q; q8 P2 g8 \2 L+ d% i$ Q
) I; i! k* H( }0 |5 _module_init(led_platform_init);9 }% q, G4 f, ^$ `6 o
module_exit(led_platform_exit);" n. O4 ~5 c: s
8 L3 [9 c+ A! S% k LMODULE_DESCRIPTION("Led platform driver");$ _6 e, e% m; b6 l# C- f0 m
MODULE_AUTHOR("Tronlong");
* O9 b" {4 y# U# c S2 ~8 m; k- ^3 JMODULE_LICENSE("GPL");
3 d+ [* @4 @) w5 Z# b1 x% z2 B' F4 ` g* J
|
|