|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, O ~" M7 r* q' M1 r. V2 X. p/ _6 S: Q
#include <linux/init.h>
& W8 u; n* t/ K3 a: K0 r0 V0 X#include <linux/module.h>
* E# b" Y5 Z8 Y W2 g#include <linux/kernel.h>% {$ K; C: c# I, B
#include <linux/types.h>
$ w9 g, K0 Y1 K7 @' B* l" n: h#include <linux/gpio.h>. i/ e- U: K7 p5 `9 ^- p5 c
#include <linux/leds.h>* t& {& ]: I) R% h: L7 r2 i
#include <linux/platform_device.h>5 _! ^7 b: p6 _5 d* e
3 r' C) n- \' I+ b7 N2 }
#include <asm/mach-types.h>
( G; X2 Q' x" c& ]#include <asm/mach/arch.h>
3 @- E$ C, Q# I0 @) [$ P: {$ k: z5 _#include <mach/da8xx.h>' t6 D3 I( G* j$ b
#include <mach/mux.h>
% p: H" U$ [, Q3 W& _, C
4 m) f1 @3 t! J9 R! [8 |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( S G% x# t" C) S9 Z ^8 l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! i3 H" `4 p z7 t4 R3 Y3 J @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& Y; s. m/ q8 g p7 Y3 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
L9 i! G( j% j( j6 b3 m
0 ?7 l1 j* V; }, K$ Z! Z( e7 E/* assign the tl som board LED-GPIOs*/9 {3 B- w8 v3 B9 [
static const short da850_evm_tl_user_led_pins[] = {
% l' o% G1 ~! u, P6 U& J+ D) B /* These pins are definition at <mach/mux.h> file */- ~6 u3 t \) C U1 s# r2 U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ w6 g8 p) |# @: {; F; Q" v q( T+ E -1
3 @7 u( R% J; x( Q1 G$ ?+ o) C};( T! Y9 H% A9 K
& `6 q3 w9 X, x+ N6 ^1 d5 c0 T$ ^
static struct gpio_led da850_evm_tl_leds[] = {* t( j& o4 I) v$ i2 c0 e
{
2 g( U# l! Z' ?. D8 }! B4 d" v- ~$ b .active_low = 0,
! L2 d. N5 M. j3 S6 S .gpio = DA850_USER_LED0,
" H2 k- X3 y' x5 G; u: ` .name = "user_led0",
. s k# ^. e! J4 h/ x, { .default_trigger = "default-on",
& @* p; I5 L. Z" R$ n( r" c },
b3 l/ W# j* p {
4 q* w7 ^, E2 Y! S2 o/ e .active_low = 0,
3 I/ E6 o1 B+ h1 b3 V B .gpio = DA850_USER_LED1,
P/ m8 v- E7 x) o .name = "user_led1",
0 C$ |5 |: v& o- V' d .default_trigger = "default-on",
+ z+ O: g# [! x9 i" w" a },, E8 |( {6 d5 j8 Q C t
{
4 h' l6 V" m) X9 L .active_low = 0,7 Q% A. o k. Z! d6 e
.gpio = DA850_USER_LED2,
* D6 C' V% R9 w& _ .name = "user_led2"," Y' h! o t% ?' B- w! F( h4 P
.default_trigger = "default-on",
1 E! v/ h2 o @( a: c1 _ },
% M( F: H6 p5 V: V* u: ? {
3 G0 Q" `# i% s# F .active_low = 0,
7 v9 K9 z. o% m; L .gpio = DA850_USER_LED3,
; T0 b9 A9 u6 c: R% G N' i) }# T .name = "user_led3", ?3 C# v' y- L4 N& Y" y6 h! l
.default_trigger = "default-on",
& c" @2 h/ {4 `3 N+ i& W4 [8 X },
) ^. W6 N1 ]8 y) F- l1 D6 X};& I+ T0 w: b: b' ]: R; I! v
" @, t7 f0 V* I1 t( j8 g' J' ^6 P& J. ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ d# Y3 v$ r r' b( m& S .leds = da850_evm_tl_leds,
2 H- F8 F) y* {$ ^( g- V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 }9 q" {6 k. z4 V5 `
};9 h! B7 r& }- O
5 v9 a/ G' E& R3 w1 w& v4 n
static void led_dev_release(struct device *dev)$ U! N* _2 f4 C+ J- j
{# {; V! O7 J( L2 @7 `' Z6 Y
};
9 I9 w& C3 r/ w' c/ h8 Z3 b4 J
static struct platform_device da850_evm_tl_leds_device = {
' ^2 D0 f. _/ |/ {8 v6 X* x8 O3 u, { .name = "leds-gpio",
/ K, ^& c% V6 ~- C .id = 1," v1 z4 ]# s' x" |# z6 c
.dev = {
0 \3 b1 Q: l! E" d2 O .platform_data = &da850_evm_tl_leds_pdata,
8 |5 r- U! x. t# [# U .release = led_dev_release,
& ~6 V6 h: B$ W- \ }) |; ?# U8 R2 z/ ~- b
};
3 G, e7 Y' m$ |3 K% i. f5 x
9 T' Y/ x# F& l: xstatic int __init led_platform_init(void)
, Q6 k6 j9 l1 d/ M F; Y5 y8 X, e{
; o. Y: _* e! U# y int ret;) s3 K7 h6 y: c3 Z6 V+ C$ Y; m
#if 0
- ~, @7 A8 M# @* [) M& D1 w3 \1 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ p1 [6 w2 C8 Y" Y* I
if (ret). g- G1 u- U5 t3 ^4 V) r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" e' z+ i4 a. P5 W: S% ~5 r4 G "%d\n", ret);- G% u( I1 U; c% G- W' l* t6 u
#endif: C h, ?, J- N: D$ t
ret = platform_device_register(&da850_evm_tl_leds_device);% \1 L, e% Z5 v/ ]6 e# t( b
if (ret)
' p* v5 V! @0 s, G* C pr_warning("Could not register som GPIO expander LEDS");7 Z2 X! m0 |6 @+ g
else
& e4 s9 ~; l2 l3 s# }2 K* Z printk(KERN_INFO "LED register sucessful!\n");
5 s; f6 W+ f) G M. Z% @5 O3 e9 D1 C8 }) L7 o
return ret;
8 m# N0 Q2 y1 m2 o2 U% B/ m}# J: S/ @5 y* L! y
/ @/ a, l& J( G# ` {6 `+ J9 Q
static void __exit led_platform_exit(void)
3 h* W8 f P8 A6 B, |{
, a, e+ L# C( K5 O5 y' H platform_device_unregister(&da850_evm_tl_leds_device);
7 B, m9 N) H3 x* n
8 Y) f) i/ p% a0 L6 S printk(KERN_INFO "LED unregister!\n");) g$ F- z& z- a; ^5 ]
}5 K0 i$ f( u; ^: _
2 r$ z8 q5 l5 i, y7 Nmodule_init(led_platform_init);0 S5 O' d8 f/ y# h& t& U
module_exit(led_platform_exit);
5 m+ h8 c$ V5 I( E4 J9 j2 `
8 @/ S% H Y a- Z; ]MODULE_DESCRIPTION("Led platform driver"); q- F' P* S3 ^- i1 c( I! p) ?
MODULE_AUTHOR("Tronlong");3 p" z* Z$ i# i+ X9 f
MODULE_LICENSE("GPL");
, T7 G: s3 E" d$ w" a8 x5 j2 B
# Z& r& q: ?* y3 z/ R- F* l |
|