|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 F3 D5 m! g5 l2 M1 P#include <linux/init.h>
8 W% K7 t, \9 U" B/ `' i2 |#include <linux/module.h>
0 ^$ x9 `8 y q9 E& Y/ P/ M- ^#include <linux/kernel.h>
: L8 U( \5 k" H. c; C! i% S" j#include <linux/types.h>9 H1 Q. }. c4 p# A# a
#include <linux/gpio.h>9 W6 ?' u6 A" c$ I2 C
#include <linux/leds.h>
1 ~4 `8 Z* x0 B; |7 ~5 C#include <linux/platform_device.h>9 y0 a& M$ ]1 n. [
/ s* h/ J9 ^; r! [# \! s
#include <asm/mach-types.h>% S: E; d& h/ g8 k' N$ T7 f, e- w
#include <asm/mach/arch.h>' T- @5 [/ v* ]. @+ ?/ K$ T; S
#include <mach/da8xx.h>
5 o* J$ x- l. a2 |* Y$ i1 x1 r: k) c#include <mach/mux.h>
1 \2 m4 P, u% K' m. j
3 M, S$ |& ?9 u2 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 @* v7 O) K* `3 w1 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# r: S7 `/ ~" ?2 c- `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) {* i5 M7 S* s `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 Q9 X) e/ e+ u
9 B. u( k: a0 {# P/* assign the tl som board LED-GPIOs*/
9 Z4 C% m8 E. s! Nstatic const short da850_evm_tl_user_led_pins[] = {
1 r1 x% Z4 E( k% Y' C P$ [ /* These pins are definition at <mach/mux.h> file */
( J: @( e* D1 J& H1 Q3 \1 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, b! T' m5 f! g+ T$ g1 E) ?
-1% ~+ Z8 M4 S2 ^+ J
};
8 \+ J/ R& [# Y5 L
' w, o- [6 L9 J% Wstatic struct gpio_led da850_evm_tl_leds[] = {
: k* O/ k$ f3 z; Q) U$ A9 D* K {
X0 a+ r; J5 ?8 c% f" J .active_low = 0,8 t' I, m7 v r! S P" O, w
.gpio = DA850_USER_LED0,
4 {, _. D/ S& A .name = "user_led0",/ c w) G6 d4 w$ r; N6 S
.default_trigger = "default-on",
' v) G& N0 a* F8 _ u },: X/ v7 L2 S) k! s' V7 R
{, P( N+ Z/ t; \5 }, D$ E3 |
.active_low = 0,
, n9 L5 ?; C& R6 E5 X+ k$ X1 v .gpio = DA850_USER_LED1,6 i6 b" g: K8 K, P4 ]0 H e2 K( _
.name = "user_led1",$ s( o( m% ]/ ?0 l1 o# h! b% u' S
.default_trigger = "default-on",+ s( }4 [1 ]7 p C1 d6 Z) x5 w
},
; [4 U9 |' B8 R" c# K* v3 t {+ f) R9 [! d% l. {
.active_low = 0,
) Q( g/ m5 J* }0 J .gpio = DA850_USER_LED2,
) W' Y% G/ l& l3 ? .name = "user_led2",
0 h, S7 u9 t8 o" i! O1 { .default_trigger = "default-on",5 J, T, a1 q. d4 D8 k X
},
2 n; A) Z( f0 R {
1 _2 x2 l& \1 Q9 g& H .active_low = 0,% `- {8 I, R# o! ^/ |
.gpio = DA850_USER_LED3,
" D3 f+ f& W, u# e: W .name = "user_led3",
2 k+ ^1 s4 W; t( o( @3 i: l% { .default_trigger = "default-on",
( R* w& b1 Z, e1 K7 q },, \3 k0 W/ [7 F( U- M/ b9 D
};
8 J9 h3 j: |! d% d
9 T4 Y& F( |- @/ @$ ]& P; Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ w8 m0 ]" S) y, V( j
.leds = da850_evm_tl_leds,% h' A# x7 M" A8 J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 i+ I' \6 }' f- s6 N
};
1 H: R' |0 a+ T& l- j5 S; E7 B8 _0 }7 o2 |9 w1 a1 `! b: A
static void led_dev_release(struct device *dev)
- M7 M9 ?* C0 L6 c: \6 e( v{
# K& v, Q7 i( a" _};
; k* S- H8 J3 i( r7 ?8 Z
5 x3 J6 e& \1 S% y& Ystatic struct platform_device da850_evm_tl_leds_device = {! M. E0 w& Z1 z% s3 F. M
.name = "leds-gpio",- s, f) D* W ?3 h" {! @7 L' J
.id = 1,
9 d: }; k) ~8 N0 E# s% \ .dev = {8 y I G1 p% d5 n- t8 G1 @
.platform_data = &da850_evm_tl_leds_pdata,
/ ^4 _8 l/ g: B6 ]- ? .release = led_dev_release,* g: w1 ?& H5 \0 q$ [
}3 V( R9 V" R* z# ~/ u- Y
};! Z+ X: W/ e! F |8 @
- C+ Y. F2 |5 y* j7 |3 \static int __init led_platform_init(void)
; T( S- H G+ W+ \9 Z4 i* o m{
6 Q$ @! M1 v; U; Y* H int ret;9 o1 l: `0 J' Y+ _
#if 0/ B- ^. e. E* h [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! E8 M Q6 }, ?- F: K
if (ret)
& v) e! V* @4 W1 n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ j! G! B/ @& Y9 ?2 x! u "%d\n", ret);3 G- L. V/ y* d% W7 |2 @
#endif, A, v% L6 x/ J% h8 A9 O
ret = platform_device_register(&da850_evm_tl_leds_device);
: q5 z4 R) }/ d; K. C if (ret)2 X1 `' @* w( p. X! V* _
pr_warning("Could not register som GPIO expander LEDS");% z1 U% h) E; H+ _" [
else
- I9 H4 {% [9 E printk(KERN_INFO "LED register sucessful!\n");* u* R. D7 S: T* e1 ^ P$ d
* }. v) ?' k1 I/ t
return ret;; ` }( ?# b r; v% ^# m. h9 D
}
1 U- ?$ T' v6 J0 o6 P$ k. d) `6 E3 O& U/ Y# X2 E
static void __exit led_platform_exit(void)# R2 J/ d& n. [+ Q
{3 \; }5 R8 ^$ e# j0 I
platform_device_unregister(&da850_evm_tl_leds_device);
' i- U* g% s0 Y q2 v7 A
# ^( X( {2 _8 ?1 J printk(KERN_INFO "LED unregister!\n");
L- g/ J+ A9 o; [* W G- O6 ^}
' K y: W/ o: r" [- X: H. A2 }; j. v% q2 V
module_init(led_platform_init);0 P7 F) y6 q0 f- X4 s
module_exit(led_platform_exit);' C# E% s) I! }2 ?; a- X# @, U
S$ \: x/ J @4 N9 i, z8 VMODULE_DESCRIPTION("Led platform driver");
6 Q) L+ ?" Y6 ?' o" m4 lMODULE_AUTHOR("Tronlong");
) K" {$ R3 [/ d8 bMODULE_LICENSE("GPL"); P/ t$ G5 q0 E3 V9 F: i! A
1 h6 }& x- b n0 Z x- p |
|