|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 ~2 z0 y# ]2 J; d#include <linux/init.h>
$ u4 e/ Q# i _* g( n8 W#include <linux/module.h>
6 G; N+ Q3 D5 c, u B& N#include <linux/kernel.h>. h; q/ Y6 z, X: P
#include <linux/types.h>" [+ ?- W* {- |+ _, W7 ]% v. \
#include <linux/gpio.h>
7 q4 G- v% n& o8 Y W. {#include <linux/leds.h>
/ q3 V5 N# b4 x) v, A4 J#include <linux/platform_device.h>
3 V; Z' r! ]9 N2 ~7 e0 z1 Q+ ]" o& U- r2 @
#include <asm/mach-types.h>
, u) L, X$ j% J5 c1 y' g; h$ ]#include <asm/mach/arch.h>0 \' ~1 u$ Q$ B9 b" [, j
#include <mach/da8xx.h>
% f/ @; r" D* ^' _/ _3 Q#include <mach/mux.h>
. m5 e: w( c4 ?; O( r/ I3 S, ?; R6 c6 l1 E+ w2 l* k* J `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' H4 M, G. C/ i3 }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 V: M0 u4 C4 L, v9 Q& L8 U; G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 d: T( e. S j; q: H6 Z! E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 \1 `! B* E9 c! l+ [0 s
, D6 ]# |! ]0 j# `/* assign the tl som board LED-GPIOs*/) d" ]8 \/ C9 ]! \$ _
static const short da850_evm_tl_user_led_pins[] = {, e" N$ q& h4 E2 k8 @$ X. e
/* These pins are definition at <mach/mux.h> file *// u: @ ~; z- N1 c |- q$ r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 j0 O7 _1 J( a% T! u, h -1
+ {9 Y6 v" ?# M4 S/ d3 G};2 u/ y# a2 m, R& f6 C
2 _0 V4 N9 Y/ b0 \static struct gpio_led da850_evm_tl_leds[] = {
% O4 [2 `9 ^4 K( ~1 a2 h {
9 \0 B( s' X, o/ K: c0 x1 I .active_low = 0,
6 j' D( B& Z2 H& C, { .gpio = DA850_USER_LED0," ?$ O5 ]4 L$ c& t1 l7 ^
.name = "user_led0",
: E! M& N) ?3 o, o2 _$ B; ^5 @0 R9 r .default_trigger = "default-on",7 R* c/ o$ M! f
},
; ?9 U# Q( ]) K. v7 s9 w {
# M! P( S! y: C. P. y .active_low = 0,/ X4 F0 L2 @6 u" Z2 f5 l
.gpio = DA850_USER_LED1,
1 D. R# H3 p# Z .name = "user_led1",1 a/ ^7 h, U2 U; m$ ?* R& S4 z
.default_trigger = "default-on",2 \- y) F e1 z, I' l5 V& r
},
( ^, A- v+ \/ t/ g* j {
* P1 C9 Q8 n9 _+ |& t .active_low = 0,
0 O u+ \, [2 r* V; V .gpio = DA850_USER_LED2,
2 R$ F- C- E, B+ u3 p .name = "user_led2",! V- t- V% t9 s8 C' L, R# R9 G/ ?
.default_trigger = "default-on",
+ u( T0 Q9 n z9 O },5 ^5 ?" r* F# r" ?" x7 Q( U; I
{2 \2 r' d u+ B; b! P, R: |
.active_low = 0,6 Y3 }$ N( D9 p4 J' D ?
.gpio = DA850_USER_LED3,
, S: _9 D! S" Q4 w$ a8 C .name = "user_led3",0 I& k" m8 Y2 X8 Z
.default_trigger = "default-on",
) E& Y+ U- a1 b },
, e% U- q1 E9 _0 ?};
1 e r0 Q4 `9 `1 D8 S6 g v) @9 A- e8 Q3 ^# N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 W, p) |1 o" d+ J% ^& J3 @ .leds = da850_evm_tl_leds,
$ t1 y {* f1 |2 u0 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 B+ Y. m+ H' U, A" N2 f};
& }8 \. Z; D9 ~# a M' `4 \4 d9 Q! D5 I: j0 A5 u/ o' M9 a
static void led_dev_release(struct device *dev)
) W4 T% d+ g7 F2 j9 W{: q& K8 t" H9 U- U& E9 c
};
/ l2 K9 F( H9 {& ?8 ?" ~
, X8 L' X8 M% N ~static struct platform_device da850_evm_tl_leds_device = {
) @5 b0 V2 ^, l3 ? .name = "leds-gpio",
% a, U+ [, C ~* H4 a3 }$ ^, Z .id = 1,
% c1 |: y0 F B Q3 S .dev = {. y+ g4 F, }; j3 _
.platform_data = &da850_evm_tl_leds_pdata,- j6 K a/ R" V9 s1 W4 L; l% q U
.release = led_dev_release,
0 ~2 ^' e' V- n. r }
6 x+ x. | [7 L4 w* m) Y1 n7 P};) ?' f G" k/ Z0 X
0 H* F* j9 h0 {# p, j) H1 ]# S7 b3 qstatic int __init led_platform_init(void)
, [' S5 q9 ?( g' O" Z{
: Z& W" [) g( J! L* S: z int ret;( a8 e% Z$ }4 n- w3 t. h ~6 P3 q
#if 0; b* w- ~ w' z/ i$ ~* A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ P& s1 l/ h2 _3 l& k5 i
if (ret)
9 Y# ~! t% I" K7 K7 ^1 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ p0 S3 U$ _' K, t5 h) u _ "%d\n", ret);. M% o8 z9 D" l# a: H
#endif1 E6 |" @, T: i( @. W6 G- c
ret = platform_device_register(&da850_evm_tl_leds_device);+ M M, m- m- ]8 y
if (ret)1 L" m$ d9 M9 O5 [! S" f, G" C
pr_warning("Could not register som GPIO expander LEDS");# N1 V, h$ J2 i X0 ]# b+ G0 T
else
/ A j: E8 q7 N: f printk(KERN_INFO "LED register sucessful!\n");6 w4 x8 `' D& Q- {( k
P0 G' e Y5 Q# ]) f return ret;
- n7 p% B* B! s9 p" t# J$ s) Q}
1 a* V, \6 f: ]' C" T
& q; ]" u U$ d4 C b- r wstatic void __exit led_platform_exit(void)
+ K0 K7 F' D ?1 b5 B* S z3 {5 d{
9 i( h( Z- g. S) x9 B2 Y |1 ~1 k; { platform_device_unregister(&da850_evm_tl_leds_device);& B/ V s; U' k y+ ?
4 h$ T R' l8 _* ^0 D printk(KERN_INFO "LED unregister!\n");2 l. j* g- G$ q7 M7 T
}
- g1 G% L. D8 ]' \
$ K& {, u+ n! K. l& g Tmodule_init(led_platform_init);
: ?) }) k6 n6 r, X# Z' ], Ymodule_exit(led_platform_exit);) [4 h0 k8 I/ Z) o2 k6 {
6 f! V7 W1 Q' b' m3 w1 sMODULE_DESCRIPTION("Led platform driver");
) c r- \- \$ i1 O* s% |& QMODULE_AUTHOR("Tronlong");. J! |9 J, d% Q/ o# l( ?
MODULE_LICENSE("GPL");, \$ |* _4 G4 I4 E/ r" U5 t1 `/ w
: L/ k' S" O0 J |/ H. j
|
|