|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: Z- U3 L+ s2 ~$ o9 G3 O# R' M/ o#include <linux/init.h>
$ z! q( C2 m) b0 Q& O8 f2 V9 V2 A#include <linux/module.h>
" [" E2 ^4 _2 e& @5 Q2 H% h#include <linux/kernel.h> H$ m0 f) J! M# R( K. f- c* ]
#include <linux/types.h>
2 E6 Q9 q# F4 Y# D#include <linux/gpio.h>5 V+ L+ {8 Z5 j
#include <linux/leds.h>& f1 g( y% \7 |3 Z' x4 B3 ^
#include <linux/platform_device.h>
! Z" v, t4 T: v) D4 e$ x# Z' w2 F, e U% k9 Z0 z2 W, k( t5 N1 L
#include <asm/mach-types.h>9 V6 L: i* C, t, a
#include <asm/mach/arch.h> h6 M; U' b6 Q w( [' f9 g) N
#include <mach/da8xx.h>. f4 |. ?* R$ p/ A
#include <mach/mux.h>1 n. c0 h7 c3 H" h: ^( `
& ` o3 W8 T' j5 {- g- P1 p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
|( P+ R9 u+ g, o ^7 u) g$ Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 S: o4 {" l) N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ r8 k* E1 k3 e, n* o# h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 ?) f0 [6 }- b0 ~: G' M! r
( h' N: A ~% w4 O( r3 d: h2 g) b/* assign the tl som board LED-GPIOs*/
, @6 e q7 C K9 x" xstatic const short da850_evm_tl_user_led_pins[] = {
. _0 S2 J9 f2 a$ L /* These pins are definition at <mach/mux.h> file */
/ p, L6 S( I, ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 u* E6 G+ e/ F H: e: T# N" Y
-1
. h6 h' h# h; Z4 R1 @; k};
7 w% O$ w/ {8 O2 I
5 s* [+ j# c" }% U; dstatic struct gpio_led da850_evm_tl_leds[] = {
) b( ^1 z- y) x2 i1 C0 ~( f: B {
6 p8 r5 O) r7 a7 C% s. g9 ] .active_low = 0,( r# `4 |( t3 a, Y% \- j# q
.gpio = DA850_USER_LED0,
7 L" o1 V- Z0 o+ |) Q: j .name = "user_led0",& @9 E, \* X4 D, f* S( T; @5 _
.default_trigger = "default-on",
/ a. _" [8 I; ^* o) @* q },
8 E9 c+ D/ K0 ~0 L& n# K4 H' P {
( P4 g* j2 l3 s3 l .active_low = 0,
% ^7 G+ G: M+ Q .gpio = DA850_USER_LED1,' T2 r& ?: m9 i& L: I9 t7 ~
.name = "user_led1",
! @* D0 a& x/ {" q2 Q" l7 m' D4 F .default_trigger = "default-on",# a5 b k/ P: ?
},2 [8 B& Z- d; ~! L
{2 o) A2 E) W4 m" \: P3 ]
.active_low = 0,
5 g3 h+ Y s ]' M( L) j5 {* w: l .gpio = DA850_USER_LED2,3 L- h9 T6 r- }/ O+ P+ u) S
.name = "user_led2",
$ s' J8 R8 Q' F9 k# t; Q# M2 @2 M. j .default_trigger = "default-on",
- Z6 V4 n1 N! k+ @& f: d2 ?+ n },
3 X: w. p* c0 Q1 }4 h4 m5 W {4 w0 x- c. \( ?7 O- y+ q
.active_low = 0,4 T& {0 h7 Y) A3 W
.gpio = DA850_USER_LED3,
6 J" L7 t8 X7 F' a2 ?) r8 Z .name = "user_led3",/ B& X$ b Y% i' M9 c J& z5 V
.default_trigger = "default-on",6 `3 \- w5 k% O* W" _& }6 @! l
},
; ]! m9 l9 ], L; l};2 b% v" l5 G- h( j3 U
. J$ P: V) f/ s9 Y5 Q" P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" ?. t, H" [; v6 w2 t% p/ P# C
.leds = da850_evm_tl_leds,6 Y' ~# l/ U) L8 A4 I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# w' ^' v* P& u; P};
# c; B8 _( i; a& D. o" b$ g5 `7 q9 S1 Q; q' K6 p/ y" l
static void led_dev_release(struct device *dev)/ Q( a. h0 [) \$ c$ A. [6 j1 K
{
: @' Z7 l5 z/ `) `+ c, l};
; B. W8 T; L7 w: Y. `% J
* g, p- B7 U% {2 [& kstatic struct platform_device da850_evm_tl_leds_device = {5 {" E% f& u& e3 r5 }
.name = "leds-gpio",
2 \# k( p. U$ V, `3 @' ? .id = 1,
- h" a5 N: Z3 B. { .dev = {0 m& h+ v3 e. `6 _3 B
.platform_data = &da850_evm_tl_leds_pdata,$ T9 F4 d5 F" n9 R
.release = led_dev_release,
1 } m% }$ T9 r; E4 t& r$ ~ }
' s0 Q9 ~ S3 o* D* I};
" `, c1 \8 ^- I4 [
+ z2 E% f' v4 m8 g% H- |- Hstatic int __init led_platform_init(void); Z% |5 n; l, `! Y
{2 v0 S5 M! S C& }' ?
int ret;- Y6 N5 t( [! q
#if 0
# v- c8 u b/ p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; V6 C5 I' g ?) }
if (ret)
# E- r; ]3 U0 }. E, W( t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
T1 w0 A6 i! S! h "%d\n", ret);, }5 R# P7 k6 ]# l( z, k
#endif A* l4 T, `7 W; k
ret = platform_device_register(&da850_evm_tl_leds_device);$ S& I& {9 J6 ` j
if (ret)
+ ]8 g0 Y$ }* v2 r' e2 @ pr_warning("Could not register som GPIO expander LEDS");1 L& \7 f, o+ O+ `% b
else
+ F) m% x8 e. u" A( | printk(KERN_INFO "LED register sucessful!\n");
9 L) b4 U7 b* x# Y: J: D: K. W$ D7 M! I( L4 e% }) ]3 ?
return ret;( a. G5 i9 A5 r2 g. W6 s
}
6 L+ r! T' O3 K6 Y6 V' p
* ^3 g. M7 X$ [) l+ E+ I0 vstatic void __exit led_platform_exit(void)
. M b' \# |( F$ v8 Z v! f! Q{
) I3 r. w0 M' H" `8 |/ v9 X platform_device_unregister(&da850_evm_tl_leds_device);
. C2 M( b, s- L% g
/ ]3 D7 w- g) P5 F- @ L, C printk(KERN_INFO "LED unregister!\n");; q/ H3 g/ `2 p5 A
}
8 V, m H$ [* }' o& w( {9 a0 H
+ }& l {' c J* Tmodule_init(led_platform_init);
- x3 B- g x* N0 K- \$ Umodule_exit(led_platform_exit);8 T- ~! n6 f+ U. J* l! q% T6 l
4 N8 ^ e+ A+ r; [; O* w0 @& ?
MODULE_DESCRIPTION("Led platform driver");) B0 r7 }/ k, s4 S/ E; @
MODULE_AUTHOR("Tronlong");" p# h+ t5 z5 K$ W0 b
MODULE_LICENSE("GPL");
( @& b0 M0 S7 Y" s r! y6 @4 j
. e1 }; j3 X5 f1 e. F% U' D4 o" }' g |
|