|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ v7 D2 h0 l& h7 _" X9 t
#include <linux/init.h>
5 V% y8 U/ _7 L9 k! V/ T) y0 ^#include <linux/module.h>
! n; i$ {; [- p3 s$ r/ T#include <linux/kernel.h>: ]+ h! z) S' Y' ]( W [
#include <linux/types.h>
0 \ |3 B* G7 v" {#include <linux/gpio.h>% M# l" t- ^; D7 P) `1 @
#include <linux/leds.h>
5 u& ?2 T! f: _; W#include <linux/platform_device.h>; `/ n: f% v5 J& o/ A
1 G; z2 g" ~- [# H& E Q: |9 @8 b% L#include <asm/mach-types.h>0 W. S5 Z) s% O/ K& P
#include <asm/mach/arch.h># T/ ?4 F2 }6 H" t* t7 p
#include <mach/da8xx.h>0 Z$ J3 r' a3 {- R# x# v# I
#include <mach/mux.h>& p' ^* z' @. m9 Z% c# B+ w
. D& m; A2 N% n/ [: A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% R* G7 l7 n# c: z+ Y1 i) E3 J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# G9 P2 G3 c6 z; F1 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 J! Y$ `; s1 ]' r3 d9 y/ [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 X, ?) I5 u( i$ Y9 h# G$ [$ t
" w R' ~6 o2 O, O- X/ c' U/* assign the tl som board LED-GPIOs*/
( V# g) ~: D5 m( p2 J9 |static const short da850_evm_tl_user_led_pins[] = {
) ~6 a+ A! U* K8 g /* These pins are definition at <mach/mux.h> file */
/ Z* `/ b0 i) r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 f% K0 O5 f" l8 Q& T% [1 t, ?
-1. E7 L5 T+ u5 T7 Q4 {3 B
};; f4 S4 ]( j1 W: w! m
) Y1 \/ `; E1 m, ?static struct gpio_led da850_evm_tl_leds[] = {0 l% a5 T7 _7 O/ ^$ J
{3 j3 n8 G3 J) Y0 T
.active_low = 0,9 H; {; Y" {( b1 {
.gpio = DA850_USER_LED0,5 H- ^6 q, ~8 b3 b/ k/ l: o6 V
.name = "user_led0",0 p- G5 f. a* s/ o
.default_trigger = "default-on",1 z% L& R9 u2 u3 ~: k
},- e( E: L9 q# u& G' r
{0 v- U ^2 Q0 ~: ]6 @' U- \
.active_low = 0,
' J! ?, t9 T7 L$ w) G .gpio = DA850_USER_LED1,3 B9 `3 ~. u2 m: F& h
.name = "user_led1",
0 p9 g" T8 z9 i0 r) Y3 B9 u2 R .default_trigger = "default-on", Z: r% o( i& J7 \8 F
},6 _; C6 `6 A5 X$ o% ~% R; {
{
8 P; e2 K" E& [" j7 J .active_low = 0,
7 J5 Y2 R7 `0 ~$ c( q# }! w .gpio = DA850_USER_LED2,4 f3 B t2 G2 K% [' {
.name = "user_led2",4 ^2 f- [! y1 }: I% [! J
.default_trigger = "default-on",9 _) x9 l: G4 m# A" {& m" n
},4 B6 I. D# b0 l( c. F! c
{ f! J0 D: B2 n( |
.active_low = 0,. ?5 x! j6 p9 }( V
.gpio = DA850_USER_LED3,
/ e, ~! [: h7 @- ~! g2 f) D .name = "user_led3",
" I, s0 D7 L' i2 r+ n" j0 w# \. a1 O .default_trigger = "default-on",
) }& K' b( y9 E },
& ?9 y; A+ b4 y* W};
+ w, c, ]: Q3 m6 U% m! l' R d/ e' z W- J6 v2 d+ }# u2 t/ {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) t4 c5 s1 {- q# z# d4 y .leds = da850_evm_tl_leds,4 {5 Y3 w0 e0 K L" y0 M; v! ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) t! J- u3 v% y6 I& p" o};9 Z7 v- _# O; j9 u% D, m6 {
. {0 J7 z9 D- G% F: S% I
static void led_dev_release(struct device *dev)
) Y4 ~. j4 s/ V2 x$ a{2 e- t! U1 B1 K6 e; ^, m; `
};
* _ p8 q, [$ h* S
- v) B; Y# R, r ^$ cstatic struct platform_device da850_evm_tl_leds_device = {
6 R) v, z& i! ~4 d3 x7 L .name = "leds-gpio",
# j: [- ?& _: ?5 m4 [8 i# q .id = 1,
: ~" C, x6 v% N+ P' }( i4 O .dev = {4 F8 O! y }1 F6 x6 \. D4 c# @7 h
.platform_data = &da850_evm_tl_leds_pdata,1 ~8 ?: x) d# o! m5 c
.release = led_dev_release,- p* }4 @. i: i5 B+ I$ h
}
; Y' v7 z* ?: v" @! \1 F};8 D) W, }1 C9 I, r1 P
1 ~* @9 J+ G R/ x, N& [# K" ^
static int __init led_platform_init(void)
}. m9 g: k: R% X# j; S: y$ J{- U6 d0 |/ r/ Y9 ?1 x
int ret;) C, `9 Z# x4 [( ~7 F9 @* T
#if 01 C" i+ J$ j5 { y0 \1 _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); l9 t" Q* S; A- [: x
if (ret) S$ D4 T6 ]7 k& z. u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& J- l+ u3 V1 H "%d\n", ret);
4 v4 S9 K' s& y( ]#endif
( L4 j% q, p& [ ret = platform_device_register(&da850_evm_tl_leds_device);
( m0 p. ~" a& x& W3 E3 t; A if (ret)
+ X; i4 B. c; `! @ [ pr_warning("Could not register som GPIO expander LEDS");
' A7 }) @# f% V( J% G4 J! p) j/ o else0 o H: s. S C' L! C% {# l% @! ]
printk(KERN_INFO "LED register sucessful!\n");
- K$ }0 f8 c& R, ~% O* S
0 C( o1 S: t2 e: B+ { return ret;) y0 q0 w* y8 @: n
}
( s0 }* W* O4 X& x+ g
, O( h& [$ n* Q; `' v+ T. @static void __exit led_platform_exit(void)6 @! t; b) z: ~( B
{1 `% F) N$ l: a$ Z& v$ [! p+ R; {3 S
platform_device_unregister(&da850_evm_tl_leds_device);
0 l( t0 e" Q( F' B- `- e
* Q% S' Z2 t4 g; H" J printk(KERN_INFO "LED unregister!\n");9 p$ K7 I3 n. W1 G8 R3 K2 T
}4 _" j; U" p& h
1 N$ x5 S5 {! M' S* U7 Y% q+ Dmodule_init(led_platform_init);
) i) {" U# a2 F# ]7 e; s0 Mmodule_exit(led_platform_exit);
3 k- z' Q& p& x9 ^/ [4 _" C3 m3 X5 W9 U) K7 Q+ d& Z
MODULE_DESCRIPTION("Led platform driver");8 z( i1 [/ ?/ v0 d C7 R0 D% P
MODULE_AUTHOR("Tronlong");
8 p9 H% \# [# a) N. D6 \9 j+ gMODULE_LICENSE("GPL");
/ f* z* I4 |4 v! S5 h% v \* b5 r, z! S: \' [1 x) \
|
|