|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 k+ J# s% ^/ _0 A
#include <linux/init.h>
+ Y# I& d, d* p& f! _- |#include <linux/module.h>0 I8 L7 m7 Z" L) y( A: M- Z! W
#include <linux/kernel.h>
4 y! u, z2 ^5 N6 v0 s4 g3 Y#include <linux/types.h>
: R. U; y4 `7 ~#include <linux/gpio.h>- M/ o* e; Z" {4 s/ A/ J
#include <linux/leds.h>- g( N, m3 |- F+ C: ~' p
#include <linux/platform_device.h>
/ K L1 @( L y+ L$ ]- P
, I* A- p3 ^2 Q$ Z1 y( }#include <asm/mach-types.h>/ K+ E# y( `4 [0 V
#include <asm/mach/arch.h>& J) [0 n+ T5 ?, O, w: s
#include <mach/da8xx.h>
) ^1 B2 }' b# T#include <mach/mux.h>
/ V# _' d, `* [; N1 c5 R% G' U- O2 r+ L+ C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ ?! k' l; b# P4 H6 a5 Z! g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& B0 F8 f/ k d1 R% K1 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 [$ Z& o3 ?9 Y* ?$ X) N# f2 A; L- i3 ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). {7 {+ ^: Y3 K
/ Q# b( [4 G& V$ j; I, u# m( A
/* assign the tl som board LED-GPIOs*/% s# P/ q0 O( i' H3 n/ z
static const short da850_evm_tl_user_led_pins[] = {
f4 v* C8 k8 [: T }/ y* K, W) [; k /* These pins are definition at <mach/mux.h> file */
& p/ m) s; v% r* F- Z' p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ E. J2 ?. U4 c% M) Q, D, h
-1; }$ c8 e: m( @. g3 K
};
# c' k* x R( t( G! s$ I2 h0 U) ~; ?
static struct gpio_led da850_evm_tl_leds[] = {- h/ O" _9 O) b2 H
{
. B1 b* x1 l7 v; m6 b- K- t .active_low = 0,; j0 N4 Y- ?: q# w+ H4 t
.gpio = DA850_USER_LED0,
- ^1 ?9 L' m- ^ o1 f8 U .name = "user_led0",
; X. M1 O% C4 A6 L- |: K! V+ C .default_trigger = "default-on",$ C i, n/ _$ i; t2 b: o
},
% k) q9 g/ {& g' N5 J3 k( D {& z3 o9 D5 S- T
.active_low = 0,
5 ?; V; {3 f& u, {+ s* V% v; O9 | .gpio = DA850_USER_LED1,4 O7 q, K. o7 O
.name = "user_led1",8 {% A- K8 N: Z/ A. o
.default_trigger = "default-on",
4 M' d2 K( L0 B/ } },
$ V) |% d( `! `& I6 W5 e {$ F" M+ U, i; s/ [
.active_low = 0,: c! E* s( x6 U5 a1 ~8 U2 K" J
.gpio = DA850_USER_LED2,% [! j4 F4 k, p5 L5 S1 D
.name = "user_led2",& P( L, p7 x* I# J( H9 p
.default_trigger = "default-on",! e. _" y5 N! T# H) x4 T
},
. c1 N! Q: P6 `4 w( G1 } {
0 S0 e+ t# E9 m8 l .active_low = 0,' Z2 t4 d! T! S4 t
.gpio = DA850_USER_LED3,
+ G2 c6 D1 D7 j0 H- z7 D. a4 P .name = "user_led3",4 @) J8 i: h1 S; I& Q
.default_trigger = "default-on",4 U; i' l" H; u$ V1 S+ k) s
},
# V+ J" z9 u, L};: i1 p3 X# a/ P: R
/ N0 \3 w9 u* a# n1 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! F& z) U2 S' [1 o2 C .leds = da850_evm_tl_leds, A0 J. b) Z5 k; P) k/ Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 d8 h2 I5 q: J- W
};8 c7 \! _3 L7 D; S
; q# w4 e5 p, E* H& ^% P
static void led_dev_release(struct device *dev)
! u4 u+ |) R R2 \{4 Q: y7 m$ o% A* b$ g/ Q
};9 J& Z& x' J' o: P7 O2 D: [2 A* L3 v7 w
# A6 X' {% v( ^* X& K# ~static struct platform_device da850_evm_tl_leds_device = {
# J8 L0 Z) E4 g .name = "leds-gpio",* e9 d. w% Y) b. O- g. {5 Z' _1 t; Q
.id = 1,
% w @ P# F7 ^$ g( N/ d .dev = {
o4 V7 @9 E- @& x& p! A& p% R .platform_data = &da850_evm_tl_leds_pdata,
5 j1 V% P6 m( u3 y8 @3 z' u: g .release = led_dev_release,
& }9 Q" i3 k" \6 n( ~+ b }. h& N" n" P( b; y! K+ H
};+ Y) p/ t6 S+ y" M$ Q" ?* w
# i' N# S8 @& K: s
static int __init led_platform_init(void)0 Q1 P2 C3 u/ q ]! \, `1 ~, f
{) T9 u" \& A3 D6 L- Q
int ret;
3 V3 E9 L# I d4 H#if 0
: J1 J& _+ e: r) h) P: q* V' |6 L& \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% }! h$ R5 e4 f8 {0 J- S
if (ret)
1 O0 O+ g) ]) j# R- ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! e5 Z% a& Z' ]; c0 D; M "%d\n", ret);5 U4 M4 _9 F4 ]% ?
#endif) K$ I$ w1 J6 u6 y7 m
ret = platform_device_register(&da850_evm_tl_leds_device);/ E5 d( [" _9 Y2 V8 I! [1 L+ t% R( W
if (ret)
) K9 x$ V9 M8 ]* c pr_warning("Could not register som GPIO expander LEDS");2 m: L) `5 E n+ I5 } l4 u/ I( i
else
( ^! W2 T0 t$ {2 I6 V7 l0 R printk(KERN_INFO "LED register sucessful!\n");- p. E9 _; h+ a: G
2 A t$ q$ c. R: H6 L1 p& u9 N- F return ret;5 x0 _ a4 |4 a3 d& ]# v
}
- e5 \' f/ P4 ^) L+ g0 u: y
, j# v$ R+ `0 f, x' P1 N: I. D% Nstatic void __exit led_platform_exit(void)
& ^8 C- Y( s1 E% J6 n% b2 D{8 [4 |' S# h+ `: W5 J
platform_device_unregister(&da850_evm_tl_leds_device);' G/ \- }3 |4 ]- u9 B
! U) P# A2 R9 \5 { T$ t! N+ B
printk(KERN_INFO "LED unregister!\n");& f) ^3 w7 x% n% G
}( a$ @2 V& z8 y( K; X
4 b( i0 f. D9 i# kmodule_init(led_platform_init);* p, l& G/ ]5 s. ^ t! b* |
module_exit(led_platform_exit);! l$ z* i, ?# ?5 I1 f
V) O& ]! Z- [4 L" L
MODULE_DESCRIPTION("Led platform driver");
8 J3 X# f8 p5 NMODULE_AUTHOR("Tronlong");
. M$ W; w" q4 d8 iMODULE_LICENSE("GPL");
1 H7 ?1 ]9 [2 z8 l9 s2 n# u! W' l$ ?2 H8 O0 s# e; q
|
|