|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' z3 }" F; H& I5 r1 t
#include <linux/init.h>
. ^5 l- Y5 j4 Q2 L5 x1 T5 f) Q#include <linux/module.h>
& X, ^6 n- j1 y/ D6 r#include <linux/kernel.h>$ H3 p2 }1 W% l/ M
#include <linux/types.h>, h' l- A4 \3 d: Q, S
#include <linux/gpio.h>2 V) {4 z' V5 z" }3 g
#include <linux/leds.h>
- y3 b3 F! z" a2 _0 C) z) _#include <linux/platform_device.h>% m7 y2 f J2 M8 P) P0 {/ M
1 k$ C2 ?! H' T% U. Q6 _ ~#include <asm/mach-types.h>
: D" |8 b9 r: T, W r#include <asm/mach/arch.h>
: ]$ u M7 s) z$ f" J" j#include <mach/da8xx.h>
! T6 Z% w! p7 l+ [8 b6 |#include <mach/mux.h>
' b/ W1 g' [# ]5 U! Q' ?8 ?* W: t& ^& q5 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) l, C4 p: V9 B" k+ ^0 w3 F) g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 t8 e& `* K. C5 X* f0 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ L8 y' W2 j% c8 C' `; s$ E# J7 j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ o: `; j$ C2 y3 S$ ]# s' K% t
+ z0 Z+ b W C+ B4 t/* assign the tl som board LED-GPIOs*/
, L: q9 {& \% ]static const short da850_evm_tl_user_led_pins[] = {
! G- b. J8 Y' d( }& G5 d3 ^ /* These pins are definition at <mach/mux.h> file */1 S1 P2 K, H, H% _: }) O v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; P. Y( F; _" `3 A) K+ B9 l
-1
! } Q* b0 P/ ?! k};1 D# U/ @0 ^ _) |. V. l: x
$ p( q& K' S2 F' S0 N
static struct gpio_led da850_evm_tl_leds[] = {
) R* ?1 ^! R- P. n T; V {- c. e( [) L& V
.active_low = 0,
8 D5 ~. ^" F3 B( u7 Y .gpio = DA850_USER_LED0,
' Y5 [2 l# ~) l6 }' r* v( v .name = "user_led0",) D! p+ m4 g& b7 _
.default_trigger = "default-on",
* ?" }" }+ u0 k/ `8 `4 t7 s0 { },
7 L: s0 U! d i( L2 E T: | {8 `& o% j6 \" E0 E& p3 y @8 `3 B
.active_low = 0,, d# m7 O1 Y) q
.gpio = DA850_USER_LED1,
$ V. @8 ], r" v- o# X) d' ]: K .name = "user_led1",
/ l' e7 k% P1 \* L/ ^- v: _ .default_trigger = "default-on",
0 P4 W* n& X; @5 E },9 k0 Q) D7 {! [7 _% Y0 _
{
6 J: |+ `1 z) Y .active_low = 0,
) s m4 f+ B. e/ U1 n4 ?% g& j/ U7 k .gpio = DA850_USER_LED2,
: U8 ~4 a: d/ ?( v1 I& A* p .name = "user_led2",
% X3 d" ?$ O- l' g .default_trigger = "default-on", l4 j3 x3 `. U5 X+ i: V2 Y1 u
},
# o: N9 d1 N# b2 [8 Q. F0 s6 ? {
+ _7 g0 c9 i7 A1 Y4 E .active_low = 0,
/ D' F w7 S8 k2 v+ c' U3 I .gpio = DA850_USER_LED3,
( O- d* p. R$ ~! ?' \/ y; F .name = "user_led3",
* f3 Y3 |5 r( ~5 I% p% Q6 c8 r .default_trigger = "default-on",
7 W; m+ [3 `" R1 F* n% m0 f" v, e8 d },
! p* q) M9 h! X! B};
1 c; u, Y1 o( q6 x# P0 Y1 |! L7 f4 ~3 S: M4 x9 T+ |0 }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 P1 h6 ^9 E' M' \0 O4 ? .leds = da850_evm_tl_leds,0 l5 T9 {5 u. Q, D, U2 D8 {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 E! `* c, ^) w$ ]% i
};
/ F( H) R) P/ w' L( s
& ]+ c! K0 s8 p8 R d, F% M7 x7 Fstatic void led_dev_release(struct device *dev)
5 ~9 k% R: r6 _% o+ H# K: T{
' b+ t. k, x" _5 r. C5 U& X};
7 W$ B( j$ O8 g% D& E$ C! s( ~. l
static struct platform_device da850_evm_tl_leds_device = {5 e! `, ~* a3 N- G' H* D
.name = "leds-gpio",
. R# c E @: G .id = 1,
7 j! C* L! z; w" L .dev = {: V( B L. N2 s: ^# r5 Y
.platform_data = &da850_evm_tl_leds_pdata,8 k" E2 t+ g% ~0 y: v( I9 X
.release = led_dev_release,* l( A r1 R* m9 [" c& s
}
8 h3 A% z3 h4 H! m8 g' A. }: O};: B0 W* y% Y& _) a* v- z* r9 }' b& I; d& _
! J2 C' ?8 [4 b* ] m1 estatic int __init led_platform_init(void)
( L8 s- [+ }, m- q5 s{
+ g7 S9 ^( b+ c4 }8 l4 c int ret;
7 a, R. R2 |- V9 {' X. Z' E% L1 {#if 0
8 s0 `8 ^1 z" h& ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# ?' Z# k3 a7 K# i ^3 e
if (ret)
4 X4 F* @0 {8 [( J8 u2 S# X9 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 X' z6 c$ ^# u
"%d\n", ret);% D( ~# p1 V9 _. v$ ~6 B8 Q0 ^- N
#endif4 P7 E, d2 Y! J* G v) U0 r
ret = platform_device_register(&da850_evm_tl_leds_device);
/ u w3 w4 D4 G: |$ S* K. Y9 K if (ret)
5 u; K7 t: D9 B& Q3 m# j- P pr_warning("Could not register som GPIO expander LEDS");5 `1 L. N( e1 F# h8 }* y
else) J& n* W# }! i5 f, V+ l% ]1 q, ~/ C
printk(KERN_INFO "LED register sucessful!\n");& U0 @$ ~, G! Z }$ _6 e
4 |3 R; d4 y& n: \0 s) x return ret;8 B: j, P3 U- a: t# h5 g
}
" N3 A, a3 j) `5 b' }( d
+ n( s5 u' T4 ^& ]3 b# F8 `( lstatic void __exit led_platform_exit(void)+ O) ]* J9 P; ?/ }* B7 z; J
{
+ _5 u+ `+ z* R9 Z2 n! l2 F# | platform_device_unregister(&da850_evm_tl_leds_device);. u4 c( L$ i7 k4 U9 ?: N! s
5 N, z* V4 t( u: H* B printk(KERN_INFO "LED unregister!\n");
# [8 G) C; L8 ~* w: d8 }# y- l3 z}' X2 u+ ^1 D- ^8 |5 e% I# I! o4 i
: w: ^ j1 c% p2 P/ ]4 l+ S smodule_init(led_platform_init);
7 W5 C# U/ \1 t0 k6 B- V/ Gmodule_exit(led_platform_exit);
! G8 ]5 ^. u0 M* ?# ?2 R& V! B: _5 l: t! j
MODULE_DESCRIPTION("Led platform driver");
) b8 E+ I* r- C" W& u# ?# dMODULE_AUTHOR("Tronlong");0 ^ i/ w! Z3 c6 k
MODULE_LICENSE("GPL");& |7 G1 m, W9 O5 L6 `* Y1 |
: A3 l7 s8 n) H1 u! | |
|