|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! J& J3 Q: h( e# ]3 u#include <linux/init.h>
( h2 U( b0 K* X7 |! W. @) A$ L#include <linux/module.h>
y F0 C2 W; ~" u: T0 c3 d#include <linux/kernel.h>
d/ h; C% o, d' y3 z#include <linux/types.h>- h7 Y2 A" B, N! N0 D& p
#include <linux/gpio.h>, y$ `- g! a2 ~8 |$ k
#include <linux/leds.h>) f# I+ x0 L+ H
#include <linux/platform_device.h>& G4 {) b! Z) B( V9 t
$ ~% ~* B: J6 x3 N9 h) C. k
#include <asm/mach-types.h>
, B8 u, z0 z' b% `* n#include <asm/mach/arch.h> H% ?4 r5 H' w& J
#include <mach/da8xx.h>
' Q5 e. R* B8 k& @#include <mach/mux.h>3 J! f5 L4 j& O+ T
9 c; h* s8 A" W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ s0 C" Z# L2 P& f8 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( M5 D/ S+ ?0 }" a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 F' q0 _- p+ a$ _$ x( E9 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" {" U1 R% d* ~: U% ^, [0 N' B0 h% {' E1 k& ]5 P/ D
/* assign the tl som board LED-GPIOs*/' V- U1 z/ c) r$ y9 l) H
static const short da850_evm_tl_user_led_pins[] = {
, I$ q3 Z9 \* o /* These pins are definition at <mach/mux.h> file */
$ F6 J) ]/ }' [+ x: B/ {+ i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; `& F, P6 J: U& r! y, l- ] -1
5 Z( \ l1 O% d6 R5 q};
% D; t3 o: n3 u# H* `, {! M1 B+ O6 P- w# D3 u9 O7 ]0 W; @
static struct gpio_led da850_evm_tl_leds[] = {4 u$ K: X5 F5 w# y x6 a7 S
{
) S( c2 T( Y0 ^+ m# }3 I .active_low = 0,: e5 }1 N" M5 O! A) Q/ k8 I
.gpio = DA850_USER_LED0,+ y% a: l! }; k3 G- [
.name = "user_led0",
3 m1 C' ^2 }5 ]6 @. S .default_trigger = "default-on",
: ?% z! v, U! @& x) C! } },
, n! w: ^; G% d$ M i6 _ {
0 {& G3 M$ ]7 Y ^0 B .active_low = 0,
0 o: I7 A6 t' B4 b .gpio = DA850_USER_LED1,
' v- S& |7 H8 P3 t. f' K4 Y3 j .name = "user_led1",
) R" u( c' U9 h6 m- D .default_trigger = "default-on",
$ r; o8 m T7 R1 K3 n+ d' d# c: U },. a B0 R$ f+ X
{) u& _% K2 z5 R( l' \( d: c; O
.active_low = 0,, Z9 e4 Y6 G& o1 ?/ B
.gpio = DA850_USER_LED2,
+ Q- c. M) {) Z8 z .name = "user_led2", O7 p: x4 ^2 d8 H! V& K
.default_trigger = "default-on",) i# K# r" j1 }0 H
},: r) z# K! C- r: u+ ~# i6 U
{
3 u* ?* T) @, b4 x4 n# Q .active_low = 0,# T1 |1 A3 i, C2 q: V5 V, E
.gpio = DA850_USER_LED3,9 ^, l: c; _; j
.name = "user_led3",4 @8 b+ r( s/ z
.default_trigger = "default-on",
s1 r. K/ ^6 M S' Z- o8 d0 F: x& x9 { },
: T/ [) R6 O( W7 ^, ~3 m) F/ N};* V+ b/ j2 L& e q8 k. V0 L
2 k- [4 [, g& y V( }; K) hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% C7 N1 S7 x! h
.leds = da850_evm_tl_leds,
; \8 O& a( l* } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
q3 r$ A+ P# Z/ W};
X2 `4 ]; s8 S4 P( `* o/ R/ q+ W
8 i$ T2 }& S8 m1 Z+ ~static void led_dev_release(struct device *dev)+ I( Q0 a# k+ T4 `1 W8 X$ V
{8 Q7 K, ^, Y$ Y
};
% k, @6 t# E0 P _* q* `# ~8 O# t; m8 S$ w7 b9 w
static struct platform_device da850_evm_tl_leds_device = {, x/ @" ^1 A$ R+ P7 r
.name = "leds-gpio",4 Q4 a9 r3 T% H7 R4 c) b4 A/ D1 R- |" s
.id = 1,
5 W) h* X3 S" Q .dev = {
5 m8 ~. F5 |8 h8 Y .platform_data = &da850_evm_tl_leds_pdata,4 O( d, U- ^) U' l4 s
.release = led_dev_release,
4 n2 a) u3 t" F2 o E6 q7 m$ y7 A }
) c# p) v3 i7 V* K* ^# l q};
( R6 Z. u4 D. b" B* R: E" ]
1 f+ P _- B2 g8 {; `# Ystatic int __init led_platform_init(void)
9 D9 l- @& F: c* O{* D1 |, v6 r. G+ ?' `& A
int ret;" g' D c7 ^. u4 \0 @- e* J: m1 }& s, W
#if 00 m. M1 z: m8 F! H( z& v8 D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 K8 g+ }/ J. W if (ret)
6 q5 K" h5 m) d) U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% ]/ r9 L$ W2 }2 P "%d\n", ret);, n2 y) T9 n; o* ^4 G/ x7 J Q( g9 u
#endif1 s' p0 r9 h+ }3 u
ret = platform_device_register(&da850_evm_tl_leds_device);
. t5 p6 `: Z# t: P9 w if (ret)% `7 A; Y, \7 Z- a# ~
pr_warning("Could not register som GPIO expander LEDS");1 A' y3 {. U1 D; Y! g9 O @& i4 W0 {6 a
else( o, g+ w8 |+ v5 ~. x1 i9 p& @6 q
printk(KERN_INFO "LED register sucessful!\n");# E6 x7 Y. ?0 i1 U" i
# q1 Z5 o8 r9 w; n
return ret;
. `! w$ m R7 Y}
2 g1 X! Y) I. B' L" Y3 Y; O5 s8 ~& `3 K2 y5 ^
static void __exit led_platform_exit(void)
# d5 }& B! I/ ^2 \2 x6 G8 M: l{( z9 n/ z$ Y$ ]9 l$ c
platform_device_unregister(&da850_evm_tl_leds_device);
6 u* A. ]& }- Q. h7 _! z- N( X
$ S/ O# {3 G2 q$ g9 n& Y printk(KERN_INFO "LED unregister!\n");& t$ U% C5 `0 q3 S
}- F' q$ L$ G& `: c+ h
8 ^& t- l- O* Q& omodule_init(led_platform_init);' }% i4 u# w0 _
module_exit(led_platform_exit);' }4 y0 J$ s9 j8 E! d$ A$ L
! ]' k* ^# ]7 o# m8 }MODULE_DESCRIPTION("Led platform driver");
. M4 o7 X6 v- n: T" @' uMODULE_AUTHOR("Tronlong");
! ~* {, ]; t1 x( @! A8 TMODULE_LICENSE("GPL");! t* v6 F) u* h/ r0 W6 a: T e
; k" n% t( O4 e- X6 V- U/ e% I2 t4 H) ?7 n |
|