|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. A. K/ v! D' P) ~9 `0 s, @5 E#include <linux/init.h>
- F) L D7 c' v& X2 b! t7 Z' _9 N#include <linux/module.h>6 X2 N, k" x" H( p1 y" }7 e* {
#include <linux/kernel.h>4 ]; |& d" V1 ^8 x
#include <linux/types.h>
7 g" C4 t5 x i! v Z- e9 J#include <linux/gpio.h>* f5 W7 o7 C5 X6 R
#include <linux/leds.h>; u5 L. I' t6 s2 e8 `& R7 \
#include <linux/platform_device.h>
6 Q6 W, L% c- Q+ U! v* C7 I
) h; e% \9 K4 H2 J0 o; i8 T#include <asm/mach-types.h>7 H' }) u# `1 ]% B3 U
#include <asm/mach/arch.h>( _' n! Z4 H4 d6 E/ N/ o
#include <mach/da8xx.h>
; p5 J1 n6 W1 p! l- b8 e#include <mach/mux.h>+ B, y! p" t% x* K% e7 T
6 }5 j- m! m$ T# ]+ c9 z9 Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 b6 J& U6 e4 _+ q" G b2 h/ q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
l( q8 H, f3 C A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 u( ^! V2 Y& d% `; k) k& c x4 T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% L7 j/ h. h0 a; T4 m; e% i* @& s+ ~7 b4 x
/* assign the tl som board LED-GPIOs*/
+ q) t" O# P2 j) zstatic const short da850_evm_tl_user_led_pins[] = {
# O* w4 Q& t9 x! h4 n3 Y; W /* These pins are definition at <mach/mux.h> file */
& r$ y% m) L2 t, d8 a. _" s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 X/ t" r) ]# ~! [2 F! s. r1 j -1# j8 W: O& |0 W" E+ s
};
l, G; z4 U( T# v8 A
( Z$ B2 W- @. Y Q$ J- ?, wstatic struct gpio_led da850_evm_tl_leds[] = {
3 m2 T8 r# `- ?( ~8 y- M* D {
# V0 b& ~# i5 g a; @+ H! B5 l' S .active_low = 0,0 z4 U7 V/ y: @' M* A8 R
.gpio = DA850_USER_LED0,5 \6 l8 u9 {4 q, C+ n
.name = "user_led0",
% j: i8 _- m' O5 A% T P .default_trigger = "default-on",) F/ T' }2 s! b8 S
},
- y+ M) ]; y9 v {
, g, a r( R* q& w .active_low = 0,6 J$ C! U6 P8 z" O
.gpio = DA850_USER_LED1,! `, ^5 {' j. k% H. u
.name = "user_led1",3 C. h; u' I. N1 o( P; J
.default_trigger = "default-on",
; P/ |( L2 c& R. o# c. ` },
) G7 j5 @/ J: h& q9 d {. w3 A2 H6 _: {2 u$ H. d
.active_low = 0,3 C. v; @6 d5 g5 M2 `6 @
.gpio = DA850_USER_LED2,; R3 Z+ o1 _' {7 y4 W
.name = "user_led2",4 _7 [- L3 y5 d0 l
.default_trigger = "default-on",
1 C3 E* h$ l1 z f },
6 g4 d6 ^6 c3 I+ |- x {
4 l( S8 u' G$ c& X .active_low = 0,- `/ I# V2 A( x* c# u k- j
.gpio = DA850_USER_LED3,, a$ u* ], o3 l
.name = "user_led3",
! S+ ] u* Y* Q) X" Q, T .default_trigger = "default-on",
* H$ Z3 q$ r! o+ a; D2 L. f% D },
7 x; _ h' @3 f$ ~};
. f' m f' a* r1 ~( M6 o
/ u, ^1 A. L8 s7 p& hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 l+ c4 j) e; f) E0 P .leds = da850_evm_tl_leds,
; d) s1 c% _( E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 G: ^$ |* _9 I/ u
}; K+ j, {; B0 u3 i8 Q+ j
4 ^6 l4 G/ r/ }6 ?6 e
static void led_dev_release(struct device *dev)7 Z0 E5 R# Z1 ?: B; R1 J
{% [2 ]2 x8 _# e' c
};1 {2 S* c! [4 Q
' W" r+ F# g; r' cstatic struct platform_device da850_evm_tl_leds_device = {
6 Q+ u% m) O: G0 c% H& x .name = "leds-gpio",7 p, [, i4 H2 V# T' f1 R( Q
.id = 1,
5 l% L) ^) V; M, E7 A I .dev = {6 W# r, F, h2 w! G' s. k+ X
.platform_data = &da850_evm_tl_leds_pdata,
5 ? |% ^ X5 H7 \* a: T7 H .release = led_dev_release,+ [& q; |7 f* h+ C& V
}, m. M9 |5 t# i1 E$ n- f8 H
};
" |/ m; W) q* J( |$ \# Z$ F- W0 L! T# _; v& I( ]/ [
static int __init led_platform_init(void)6 O( g l$ s' e5 S: w. n4 u0 h# z
{
C+ y5 F3 d( s5 j4 m T int ret;
1 x9 U+ d2 \( @% [2 L#if 0; q5 w5 u+ _' x0 e. d! ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( y5 n6 X, T! K3 O
if (ret)5 X, K. a0 J' E' k: l9 b- u' s( {! m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" E, g$ H( x. O# x8 [ "%d\n", ret);
- |6 v$ |( _+ ~+ I3 V" C; `#endif( `; j* @+ r8 @/ t1 j- R
ret = platform_device_register(&da850_evm_tl_leds_device);# q( h* D# s0 A, N% R
if (ret). p! m3 g, R T: x+ t, {6 |
pr_warning("Could not register som GPIO expander LEDS");
* ~+ D4 V9 m' e4 b$ g# ` else
0 ^' l7 W" R. @) p3 P printk(KERN_INFO "LED register sucessful!\n");
, n: k5 G, E& B+ H2 T; E! B9 A
9 O* l( o6 w" w7 J1 q* U return ret;
% e+ c7 `" @. ~2 w/ r( r& Z5 n}
2 @1 ~: G% n8 o% z3 A
) l: \$ k( u0 q# O( X8 c) vstatic void __exit led_platform_exit(void)
2 F! S' g9 R9 C9 H2 w{. c4 w) n+ N/ P, a
platform_device_unregister(&da850_evm_tl_leds_device);
, z( c/ v0 K* m; {+ Q, A8 [- m* m& Y
printk(KERN_INFO "LED unregister!\n");
6 f- q# i- x+ x3 A; T( l}0 {4 _4 k+ I0 D
6 z! @/ U6 Z L' _4 \
module_init(led_platform_init);
7 @; R, Q4 {" x6 L- I" \3 A; j. ?; Amodule_exit(led_platform_exit);
9 F2 e. M# s* [* m
3 K- |& n7 t- R* G/ z8 SMODULE_DESCRIPTION("Led platform driver");
- N! h: o! d; f& e) u5 cMODULE_AUTHOR("Tronlong");
& K: d. ?' |+ Z# n7 V; XMODULE_LICENSE("GPL");& n/ S; H4 }! I9 Y! t1 \
. L: m4 s, _3 J6 Y8 O+ `# Y
|
|