|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 x* a1 d/ l0 J: F
#include <linux/init.h>0 t8 t! M$ P* S8 @- V
#include <linux/module.h>, l6 C b) F/ I+ s3 G2 l$ I
#include <linux/kernel.h>
9 K) E- [1 p5 l! b# e) x#include <linux/types.h>
' k% A( ^8 {9 {- e! L, s4 r#include <linux/gpio.h>8 `" e. u' A: T; U) D
#include <linux/leds.h>+ @" H- y1 W, t& v
#include <linux/platform_device.h>. }. t# E. J L* P# m
( N, ?- a; e2 w( k* F7 h$ a3 \
#include <asm/mach-types.h>
" T( p, H2 H& R3 [6 ?# j( F#include <asm/mach/arch.h>5 x$ L6 G, z! r& T
#include <mach/da8xx.h>
' v. s9 f; _7 Q, a#include <mach/mux.h>) M7 {. B2 J, M' a( k
( \ l. J( l4 U! ?1 E3 E2 ^3 K! X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# e) p8 X) B+ T! H. v* Q3 {% [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- P1 y" l" v3 G0 \8 L8 H7 L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' v' A& W* \9 f9 O% h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ w! [1 U0 W7 m5 [3 v$ Y
j! l9 @4 C) M
/* assign the tl som board LED-GPIOs*/
0 U/ }! u; s( O+ \static const short da850_evm_tl_user_led_pins[] = {
; j J8 p$ u' y% j, c' B! ~ /* These pins are definition at <mach/mux.h> file */8 E( s h7 U1 P* Y* `5 |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( I2 ?9 o7 A. H5 y" `: g
-1
8 `3 h7 r* w }6 D};4 K P. m/ I- N/ d
; O' S, q" o1 Q, G$ D6 G
static struct gpio_led da850_evm_tl_leds[] = {
5 a' Z% y# @+ ^$ d% A$ P/ R {
2 p& ~4 a1 \- g% w, s v .active_low = 0,
( Q) {0 M. J" T) q .gpio = DA850_USER_LED0,( Y9 v! ?* F. C2 M7 w
.name = "user_led0",, U3 C/ d! V0 N
.default_trigger = "default-on",
/ L, Q% |* s' |9 H },
T) H5 f# M, |( a/ L {7 D7 I5 _) ^, w3 y, p- x3 }
.active_low = 0,( k: g- ^! f- Y; l3 K. K
.gpio = DA850_USER_LED1,. G; ]' L, i$ r" `/ a9 M* S
.name = "user_led1",
2 {/ W, f( l, a" D/ |( G .default_trigger = "default-on"," M' y; T3 q0 q" x* |
},
$ ~ v. T6 X- @% _! H$ |4 } {- d8 Z% N% F- e, f
.active_low = 0,+ `3 V# k0 k# ~+ l
.gpio = DA850_USER_LED2,
- e2 }: v, r* Z) B+ x7 w P( e6 c .name = "user_led2",3 y4 G' `( M6 r, |" p
.default_trigger = "default-on",* c$ }2 V( |- w+ z9 \, I" g
},3 u% V# T9 A6 e. Z5 S5 c: J: v
{: S! [! `' T) [: ^- i
.active_low = 0,
# P- X: j- C) ]4 z8 O. O .gpio = DA850_USER_LED3,
! [! t, |( c3 M8 z \. j .name = "user_led3",, f$ W$ g7 T' z. r F( x0 |
.default_trigger = "default-on",
0 p9 ^- a F5 y- | },* ?1 ^0 g0 h1 p9 i/ \! G0 N& z
}; A" n3 S' ]' L
6 V. s' S; V* o3 W/ ~) Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 ~9 d) w3 t% c1 X2 R .leds = da850_evm_tl_leds,
' a9 P2 w: A0 H1 ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, u8 U; ]* Z3 V a2 Z
};0 T& v8 t$ }% g( S0 S
; M7 [& F$ e( f4 d
static void led_dev_release(struct device *dev)
, y4 \) g L, i$ N{
: P! V/ O, Q3 m" w1 B# G' Q};
4 A+ \0 E* o' V, Q- O
" P& ~/ I/ w, G' x& {; }( P8 Nstatic struct platform_device da850_evm_tl_leds_device = { F- |' O# x+ g7 q: j) v/ l
.name = "leds-gpio",
$ R+ W8 j% D: d f: d, U8 U" l .id = 1,
' c$ z: N# w6 [) D! c" t& A .dev = {; N0 p$ g' Q' v
.platform_data = &da850_evm_tl_leds_pdata,6 d2 _) d1 u0 y9 ]% }9 J5 P
.release = led_dev_release,
) v& p w5 L6 t; ^& H# ` }5 E% n3 f3 N( J7 q. K, f" _- a
};2 u; Y& v! k) `. M# R( K) f$ w
% F) x3 I$ [* [/ |static int __init led_platform_init(void)
/ b# a1 U$ `- n2 W6 }1 R% t{8 d8 l2 r" P- d( Q. m' v: ?
int ret;+ x( ?6 W6 o' K/ o/ a r- {
#if 0
3 |, E4 G3 G1 }# t+ Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' S9 ^) h8 r9 j4 @" N3 L if (ret)
* G4 O: a: ]3 X/ v7 I( k4 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 `* O. `: A9 }# |# x1 l
"%d\n", ret);
6 N) A6 I( e6 F$ ^- L#endif
* b! t7 C0 W2 n# [ ret = platform_device_register(&da850_evm_tl_leds_device);
7 E. \: N) M" s; D$ r if (ret)
n, X* E- S! h# I% m0 T9 W pr_warning("Could not register som GPIO expander LEDS");4 P3 K3 ?: T! i& e/ }1 C
else
% k) A9 y9 Q t# Q F+ q" v printk(KERN_INFO "LED register sucessful!\n");
9 j/ ^2 B' ?; w' x* I% O* ] s' k9 @7 G& m' c# \
return ret;1 r9 b* V6 ^7 `1 F& c7 m6 F
}
Y& L$ [0 H8 W% P& M c) Z+ R% k) g
static void __exit led_platform_exit(void)- m$ n( j% t$ V6 G+ n `
{1 B3 f$ Q0 A2 u5 Q; K
platform_device_unregister(&da850_evm_tl_leds_device);) U# `& q7 f" G* W. a3 [7 v
# @; \4 i* i9 a! U2 s }
printk(KERN_INFO "LED unregister!\n");: q+ i2 M+ z* t: Q7 I# ~7 t
}
0 u+ r& X! s8 F+ t9 f6 K+ b: {4 o/ m3 b7 t: b1 J* U0 u) U9 u7 G
module_init(led_platform_init);
; T% L1 ?4 ?# f% G/ W$ F6 j& smodule_exit(led_platform_exit);
j8 O1 S# ?) h) k* D! A: h" Z% f* j! }9 g$ j. F
MODULE_DESCRIPTION("Led platform driver");
& _ N; I; _& Z% p9 MMODULE_AUTHOR("Tronlong");# v% s, z8 J F4 L
MODULE_LICENSE("GPL");
7 M6 D0 x. ^5 E& o5 y
% g5 f& d0 }; O+ ^% s8 r- ? |
|