|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; A% o$ A: j$ A( P6 c( {#include <linux/init.h>" r/ ? s. C, G) A4 Y- f, z$ r
#include <linux/module.h>
- _2 u% p$ D: W: z4 A5 n( m#include <linux/kernel.h>! u4 w# M" L' g' M
#include <linux/types.h># ?$ y( D; U7 e6 X* J# r6 p
#include <linux/gpio.h>9 ? k3 y. N" Q; I
#include <linux/leds.h>& A9 Q- }% v& O% R, [6 u
#include <linux/platform_device.h>! q7 J- i% J- Q8 e1 V" H' H3 Z: p9 h
% k' f9 i; M" i% N5 j: p+ i3 t. N
#include <asm/mach-types.h>) i! v; j8 P8 x, v
#include <asm/mach/arch.h>' g5 [$ }$ B9 l- t
#include <mach/da8xx.h>2 H3 C0 T" e3 u9 x3 N
#include <mach/mux.h>
" V `9 R5 f% d h6 E
o% f) [- q! l8 j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 P1 g8 C% Z- D2 ]* V1 E; J* d4 a+ d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); o- y0 V R- c% J8 s' s1 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 X$ [* a f" k) O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 g) H- q9 m6 A4 e1 u! g$ r3 q' G8 s
5 n8 k" ~0 ]$ h8 y
/* assign the tl som board LED-GPIOs*/: v& {2 G$ J: N" E0 V2 [
static const short da850_evm_tl_user_led_pins[] = {) Y3 y. m+ Q* n# H: e8 {
/* These pins are definition at <mach/mux.h> file */
: S; n8 t: a% d3 O9 g5 u: j- b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% B1 x2 H8 `- ]4 o, E -1) a6 M; i% q$ m* A5 D* @
};
- w- r% |$ C* ]/ L/ \* d& c9 l. R+ x! Y
static struct gpio_led da850_evm_tl_leds[] = {
4 h$ W3 p: m+ T* K* q6 Y8 I {* {( w6 K3 E+ T @" \% ^ M- E t5 @
.active_low = 0,
0 A. \$ h* E y3 F .gpio = DA850_USER_LED0,
' C N4 o$ w) ?: b/ n .name = "user_led0",- U2 [0 _1 ?! ?$ ~( d7 s, z! b: a
.default_trigger = "default-on",
6 m- j' [3 o: n6 V, X },) i! i; ^8 y& _- }0 ^
{
5 }1 e3 d) V" Z. U& X .active_low = 0,& o, L2 k3 ?5 G: G K# `
.gpio = DA850_USER_LED1,
7 J z! V* T8 l: n5 z# G .name = "user_led1",
) G/ N4 c8 f0 j) i9 \& v .default_trigger = "default-on",
% ~* c0 {- a$ ~8 s1 d4 @ },
' Z. H4 L$ A* K" N1 D% U; k {5 a- F# t: b! i8 X8 ?. u
.active_low = 0," C3 ?* r) ^( G6 j4 E
.gpio = DA850_USER_LED2," a/ r5 {1 ^* S* A+ A4 ]
.name = "user_led2",
|8 B4 c5 N2 A6 J0 C& J .default_trigger = "default-on",
/ n7 R! {% j$ ~7 w+ a& [6 q },
7 z0 y' c1 w1 X' y$ [ {, z0 D4 v+ V! S9 e) z. I
.active_low = 0,
: o+ Q8 t4 G7 V- O2 G .gpio = DA850_USER_LED3,& K5 [! n5 X, F# q8 h
.name = "user_led3",
; o( t* V$ O ]8 o. B( Q q .default_trigger = "default-on",
0 J# S0 q3 m2 r# \5 o. H },
3 F2 N) _8 I: J3 E! ~0 q};
& {! d5 i2 q% J7 ?9 g. Q
- R$ h- d6 }, v# Q1 w' f" Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: r' y4 _4 V G9 L, u1 G& {
.leds = da850_evm_tl_leds,. ^5 B1 Y" C9 ]% U( O! `; `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ ~6 J5 W% U/ H! H
};$ I4 w* r4 B, y$ A, X
6 \) ^ r5 Y( H/ c. kstatic void led_dev_release(struct device *dev)
% v% F, F, \3 i5 z{
4 P0 A1 ?5 ?8 E& L* g/ V7 W6 ^};+ B- H3 J: L1 E
' F9 W' ?# ^2 @* ~. m; `% s& xstatic struct platform_device da850_evm_tl_leds_device = {; @) {/ B; n( k* q7 D4 \
.name = "leds-gpio",
% k/ y) P" X9 C, m2 ] .id = 1,
! G) X7 d2 C; ` [: V' `3 w! n .dev = {
! D, x7 f% Z; R# ^2 \ .platform_data = &da850_evm_tl_leds_pdata," K( |3 N! N. i3 u
.release = led_dev_release,
: Z* n6 c) D7 [: W% y }* M7 |# P: P0 n. @/ J( o
};8 x- K2 _( } q* y: X7 q
7 S5 J: o. W# j! Ustatic int __init led_platform_init(void)
% a8 v8 \6 H$ |7 ]9 o d: M{8 _3 D- m* [6 Z5 j# v* y
int ret;
5 {) ^& ^1 L& ~' `#if 0" }4 S' w! b% M( [3 w% P o$ y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# t% {% _0 i' }0 W7 N \ if (ret)* b6 E1 b1 A8 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 s: x/ h7 F# q% r0 F) ]
"%d\n", ret);
0 E$ `# Q, d/ C A/ C) m4 z4 z/ v#endif
& M1 r# p! O) i: a ret = platform_device_register(&da850_evm_tl_leds_device);
- K2 c+ e" d$ Q7 |4 ~4 B; Z( [7 A if (ret)" C& X! w: A& K& ~+ m
pr_warning("Could not register som GPIO expander LEDS");$ q3 ~) s' p$ p
else
& _* B) y! g# `6 v6 P printk(KERN_INFO "LED register sucessful!\n");1 K% T4 `6 r1 ^# u: s1 I; `
+ _9 v8 a! p/ S* w( n: Y+ w4 N return ret;1 ]. B- ~1 m3 x
}
* C1 T4 \# o1 l( B9 `/ g, W: b \' `6 S4 R( _) N5 f4 ]
static void __exit led_platform_exit(void)
! k7 D4 L( W) Q( E{( Y3 P+ F0 c6 Z. l ]
platform_device_unregister(&da850_evm_tl_leds_device);
1 i) w* k1 m+ _4 q" Z F) t3 {
( J6 L* i8 R8 l3 ~7 n' g, }5 _ printk(KERN_INFO "LED unregister!\n");
e7 f1 G4 d3 R- X8 F* u}& O, i: \/ t# ?( Z
! @+ m B+ M' w# Z9 [module_init(led_platform_init);
: X4 M' c. W4 D lmodule_exit(led_platform_exit);
) S2 W5 J; h# X% `0 o+ i# I+ ~' R, p: `# ?+ |& X# f4 s
MODULE_DESCRIPTION("Led platform driver");
4 x" P" W& O% _* _( _1 P R% eMODULE_AUTHOR("Tronlong");
* R- z% O/ m# n! ]MODULE_LICENSE("GPL");
8 n, M8 i4 `3 u4 ?; U; `, l. I5 h& J! [7 k& c
|
|