|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 g/ r9 E+ y& P5 p#include <linux/init.h>
0 D% L I8 D: ?" M0 m V#include <linux/module.h>! ?* D: `7 \. b" O6 P; m% }+ K
#include <linux/kernel.h>
/ x6 ] w$ a* h6 ~ f' q6 [#include <linux/types.h>
8 Z$ L/ v2 t/ u8 R#include <linux/gpio.h>( F8 l" M8 r+ L1 C* C' d- ~
#include <linux/leds.h>
! p) \; I: a( s7 W#include <linux/platform_device.h>! Y8 b6 N( ]' N5 n
- T, V; _. {. b6 k9 R% Y. Y" ~#include <asm/mach-types.h>
- d, }. P( G& ^6 |! T#include <asm/mach/arch.h>" Q- E% w k% k
#include <mach/da8xx.h>% ?; Q( R8 w% Q0 i3 T
#include <mach/mux.h>* [' f; d, m9 B) N+ c
. U% m: I% N& N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 C" g& C+ Z% S1 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. l# `+ ]* F6 Q# m6 V8 J* r0 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" W3 B7 |; q! y8 g" a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 ]5 ?( R, r8 n* P3 z6 {) F0 q, j Z+ H8 n
4 g5 @( ], C: |6 H0 \- R
/* assign the tl som board LED-GPIOs*/2 P9 k, V0 x/ q6 P7 d* I
static const short da850_evm_tl_user_led_pins[] = {8 X8 K8 ]6 _9 c. b' N, ?
/* These pins are definition at <mach/mux.h> file */; F4 d2 K& Z1 e0 l& A# Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 t$ i; `, U$ F2 { -1% z- E9 X, {- O3 _# j
};
( _$ ~" o9 j! n& v; B8 X5 f3 t
- A4 X/ F! \2 v9 nstatic struct gpio_led da850_evm_tl_leds[] = {
2 n: \6 y( e4 h8 a* R3 ~ {& M) s/ e$ O) W0 T
.active_low = 0," J; {5 I- r0 p
.gpio = DA850_USER_LED0,5 [7 \( t6 `) j/ r9 e( g
.name = "user_led0",
/ W$ f" O# x7 b% t. w: t .default_trigger = "default-on",
' v4 D- B1 X4 }1 W& i: u },, k! k. r: c, ?) B- O, H6 y
{
" U( I7 ^$ }# t+ `( n .active_low = 0,6 |) P+ {' Z: \/ S3 n" \
.gpio = DA850_USER_LED1,9 j' t9 f8 W b9 P! Z- m
.name = "user_led1",
* l; [" N1 p- S .default_trigger = "default-on",+ W# n3 u) E; A- s1 F
},
: G) A9 I* ]/ [! }$ ^ {
- o1 `: O; N0 G9 p+ J. x5 I .active_low = 0,
" d1 b6 b8 w8 R1 z5 t .gpio = DA850_USER_LED2,
B$ l! [$ _; W' ?) {1 ~ .name = "user_led2",
& l8 ~) ~7 k0 E. l$ e$ | .default_trigger = "default-on",
. p2 j; O- f2 }- V9 l# k },
. P! h# L3 V' q5 o- v) y4 Q {
7 U0 a& F( X( H+ n4 h% x8 Y8 f .active_low = 0,
9 h. ] c. E0 h .gpio = DA850_USER_LED3,4 m/ j t2 x$ J* K0 `* V" Z
.name = "user_led3",
9 l& L6 |' s' s) z: y .default_trigger = "default-on",
, Y' M9 R2 d, Z1 i },
& e4 c0 m4 Y' h" ^1 d2 \};
! b; ]) u6 C4 o/ M* ?+ C# l4 Z# v$ O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ ] `# m ?5 R) h6 B. r3 {, u1 @
.leds = da850_evm_tl_leds,
& g6 |2 r3 q* y0 v( g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 E6 f1 J# o6 n; k. M# N};
5 k; _' y, u: P; p% w7 E. q5 M
; j! X1 k3 h0 H) ?6 H9 ?static void led_dev_release(struct device *dev)5 ~) E5 c7 G, {/ j& o
{
1 g8 }6 C# w |9 H5 P! r& L# J! ]! _7 Z};
0 }- ~) T' s9 ~% D* v" S: L) G/ m: B% F) K3 B* `3 s
static struct platform_device da850_evm_tl_leds_device = {8 s" G; N0 ?& C3 Y1 j% \5 P
.name = "leds-gpio"," z" }" B$ H$ n2 e% |0 j4 L
.id = 1,
$ K; ?7 U4 k4 l4 F .dev = {
' G: o( g. z! t* y* \ .platform_data = &da850_evm_tl_leds_pdata,8 R {2 F8 z. T8 |
.release = led_dev_release,% H# [& y ^! J
}% [6 U) _; o" s
};
6 H" R; L' }+ P' Q7 _4 t2 }: y
6 ?2 ^, J+ t Tstatic int __init led_platform_init(void); ~* l' f' t; B+ ? }, u
{
1 [7 ~+ @9 N* K* I; }% ~) D int ret;
; ^, k) v8 d/ @7 |* D#if 0
2 p. M- `* _5 c; E$ H% O' ~/ E$ _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
?% H% L/ h+ _- @7 [ if (ret)
1 [' M. H/ ?# P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 i: l8 r" [7 B' u1 g- s: f% i" O "%d\n", ret); N9 L. E! S6 U6 g/ G- x
#endif6 X& U5 P- V: I4 R7 d6 v
ret = platform_device_register(&da850_evm_tl_leds_device);/ T4 G. l# O: l7 M/ c
if (ret) P1 {$ t1 t3 K W; I2 h
pr_warning("Could not register som GPIO expander LEDS");
' E3 l* R$ w7 T else
! p. C1 f9 ~/ u; {; T& C printk(KERN_INFO "LED register sucessful!\n");
4 h: l: s8 ?4 W9 A) G# _" P1 K% I+ q3 g: i3 p
return ret;
& a& |2 G9 u5 ?3 q6 A3 I1 Q- ^}
3 e0 i) g5 J7 A# W
8 |. O) ~! F( E; Z* Q4 ]static void __exit led_platform_exit(void)0 M0 C* u$ n, G3 _$ `" g7 ^8 _9 b
{
- i& Y3 ?9 w/ E- E, x7 Z/ H( [ platform_device_unregister(&da850_evm_tl_leds_device);: v6 j/ ?! u. [# U% ~$ G1 z+ z
- Q0 }& b \2 u( ~ printk(KERN_INFO "LED unregister!\n");
7 q# T3 G! w4 y}; c+ C7 ^; \6 W D
! g% {: h6 R6 Z; G: }7 q
module_init(led_platform_init);
& `3 u* r" Z. J7 ~% z2 kmodule_exit(led_platform_exit);
. `, k/ a, x9 J; o) q4 ~( R# h- \% J8 C, _4 l9 }; w4 P8 }% i1 M
MODULE_DESCRIPTION("Led platform driver");
9 d/ c: `7 y0 ~3 `3 F' R- Q: @6 gMODULE_AUTHOR("Tronlong");
$ e2 s. |) d/ k/ ^: o2 NMODULE_LICENSE("GPL");) P7 v. C1 F: g6 }# W+ T) i" T3 m
" O. C, D5 Y2 E7 z3 g |
|