|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ r/ g c% g% h' z% A- L* U1 u1 j
#include <linux/init.h>+ i( |9 b7 D) K2 Y0 X) I" g
#include <linux/module.h>* R/ }# {0 ^0 p T# J6 {
#include <linux/kernel.h>
! K" A; y% W R: X( x' A#include <linux/types.h>
" @9 G& D% G! q#include <linux/gpio.h>
2 U) t( h& v p8 k% ]# Q4 _& E#include <linux/leds.h>
6 E! a& g+ m6 j, B1 m1 A#include <linux/platform_device.h>
5 L- j( ]+ A# V |! ~9 O2 f
. a* `7 m, r) n& N+ q) E$ z; U#include <asm/mach-types.h>
5 A ]% m) N! T- C#include <asm/mach/arch.h>
7 z# a# ^3 j c6 l5 Y, [. T1 P; X#include <mach/da8xx.h>
, |9 `# ~, c2 C( G#include <mach/mux.h>
1 i9 S9 ?3 v) \, l/ C% H
, `# e# W6 L3 `$ D) b- z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" j) p" q/ h! ^& S, }2 x O0 D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 y+ d4 z1 }0 s1 q) z7 F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) j" J" G3 L: p: e3 ^8 H! l/ r) _- s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 ]2 o+ g5 ~2 ]- W5 i% ]5 Z' J8 n& p
/* assign the tl som board LED-GPIOs*/
. b! c2 O: w( W9 ]; |5 v0 L Wstatic const short da850_evm_tl_user_led_pins[] = {
; J* [5 N I- U /* These pins are definition at <mach/mux.h> file */1 B+ Y/ X0 Q: v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, G4 q; \' I2 o& [. l- J3 E' r& ?
-1
: n9 ~! g0 u0 q. X( N};' Y$ j& i* `8 U3 L: z
* S, \: h* p- P7 C4 J% e; C2 V% rstatic struct gpio_led da850_evm_tl_leds[] = {
+ x) y$ ?$ J2 i0 ^3 b7 h2 [' t {7 ~ J: D* a; U: e6 B
.active_low = 0,
* _" e2 u( _9 N. _0 r .gpio = DA850_USER_LED0,! C3 S- b _" }- R4 O/ H/ M' X
.name = "user_led0",. M( E4 V' ^ Q6 a
.default_trigger = "default-on",
- Q* m o" W3 v },
- {* h4 z+ R' n* ]. w/ M; u {
4 Q5 y! G0 s+ e9 x .active_low = 0,
V4 }5 D' V" x. q2 \ .gpio = DA850_USER_LED1,
) M4 [4 N3 ^+ I, M8 _8 g$ x .name = "user_led1",
9 D" q! Q6 {& y) a1 \ .default_trigger = "default-on",
n$ e+ F/ m d( Z+ z6 F },
! `( K+ x: W! D! d" O( o0 w& G" q% V {* H& H/ L% c5 C6 w6 o
.active_low = 0,
' R" q6 S4 Y; v' G& M- S .gpio = DA850_USER_LED2,
5 h- k: q4 h1 s6 `/ I- [ .name = "user_led2",
# e3 o2 m% k! Q# b N( U .default_trigger = "default-on",2 a' K# \& y5 S6 Y2 d) S! j% O
},
; C$ q5 ?6 d1 g/ `0 s; I {0 s( J" a. F9 }5 x2 m' y
.active_low = 0,% Y" e$ a7 o- e
.gpio = DA850_USER_LED3,
' s/ x8 n( }5 {1 d5 n" @ .name = "user_led3",
/ G3 A' \8 ^& i/ \. d( H .default_trigger = "default-on",. H, [8 \2 r! b& R* I$ m. ?
},
) o$ G0 Q* l# }, I; ~9 Y};
, X' E% K1 v$ K4 d4 F) v* M" j/ j1 \4 L/ O4 p5 B( i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { u( \3 m9 @3 h: q4 F/ L8 Q
.leds = da850_evm_tl_leds,- N5 d c( G$ I; {& J: }9 P% s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! w+ W) v1 Q- F( v: [% n};! g! Z4 ?4 b7 M. [1 O4 K: c
% M, G3 G! Y# C/ s- v2 pstatic void led_dev_release(struct device *dev) b# t- Q g$ `
{. U* L0 g2 {" N. l
};4 h" S) C) J/ V; H. u
; W/ {( n& ^: q' Xstatic struct platform_device da850_evm_tl_leds_device = {
4 I4 C. {# t( L& _4 v* J .name = "leds-gpio",
% d3 t+ D! F& T( e- U% _" j .id = 1,
" p: _! v% s! V9 e( F6 G7 p: U .dev = {1 q* z8 U; V I- z+ M. i
.platform_data = &da850_evm_tl_leds_pdata,
# \% d) f3 M& G H .release = led_dev_release,3 c. q- z* i* h4 w& |/ O8 o/ i( h% ]
}
# d0 j m4 x6 y% u9 l3 i};
; y, J& g% J, |
R: o& K7 X* U# _# S) rstatic int __init led_platform_init(void)$ \4 c2 Y. T) C3 A! ]$ ?2 ?) P' X
{3 ?7 \' o& A' s, G* I
int ret;0 Z$ S$ _: g3 F" e
#if 0& S) [$ e' W( X$ y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ i, z+ @& X) a& I l7 I if (ret)
1 J$ h& Q+ b f4 l* G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 X8 \2 A( W- s3 h9 ] "%d\n", ret);0 V! x" F/ ~4 y
#endif
! J$ [" v+ P+ d- N$ Y! b ret = platform_device_register(&da850_evm_tl_leds_device);) j& D: s K. N0 ~3 \
if (ret)0 P, Z, y- {1 A
pr_warning("Could not register som GPIO expander LEDS");" P8 e* Z" r: q
else
F( _6 W. i- C printk(KERN_INFO "LED register sucessful!\n");
) Y1 _* V7 w9 }& w( E6 r p
+ e2 ^9 N0 J3 g8 \0 ?- X return ret;
% Q+ W. I4 H5 o& L9 S8 i}- |( f1 y {! F- x1 h" A1 w2 K
) Y5 J3 K$ @- c
static void __exit led_platform_exit(void)2 J1 v8 V# T0 d7 {! a7 N6 T, b& `
{. ^% W8 w' e+ H, ^& D7 n" L
platform_device_unregister(&da850_evm_tl_leds_device);
5 O4 T' f5 ]/ {/ ~; R1 t" u
9 i/ ?8 p* q+ W- M% y2 o/ z V printk(KERN_INFO "LED unregister!\n");& T! P( ?# b# `, o7 F+ ?3 w/ l
}$ ^: \4 @) F3 I( N' A! `
; c2 u3 W7 {; K- Bmodule_init(led_platform_init);" e0 T7 O% m0 Q: g2 W" J( h
module_exit(led_platform_exit);5 h J! X* k- d6 g8 v/ _* M
, ^3 m, I; c1 uMODULE_DESCRIPTION("Led platform driver");
! x5 _( f+ M5 q8 F1 d( ~2 EMODULE_AUTHOR("Tronlong");
$ }7 F0 Z1 p& ^ `" [4 r0 p2 c; cMODULE_LICENSE("GPL");
: t: U" r w/ n7 D: a9 q% W: d( G$ W) T2 b
|
|