|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, W" ]$ }' P1 N; G#include <linux/init.h>" O' F6 t! {; N
#include <linux/module.h>) g% U- n+ a! k) m% d$ K2 r
#include <linux/kernel.h>
. |0 `" d$ A4 c4 `& w. V; d; _#include <linux/types.h>9 m, d' Z! o4 E# |0 ~6 }
#include <linux/gpio.h>; e) _( z' C: \& n3 @2 H6 F. H& [' a" M
#include <linux/leds.h>
0 l, a( i. @( }/ F2 l3 w; @#include <linux/platform_device.h>3 u' W1 n+ v5 B# o
9 r& s1 t& m! U( X: X, }
#include <asm/mach-types.h>
& w* x9 |; x) s4 O6 ?6 d2 {; u#include <asm/mach/arch.h>
0 E7 K0 O1 [+ u#include <mach/da8xx.h>
% ?' i7 X" E& V/ x/ S" ]1 Z% U#include <mach/mux.h>
7 K8 g( X0 w j+ M
8 Y2 R4 z8 ^* T* p4 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 V5 i% Y4 d& E+ v5 U# R3 q; N. c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' ~4 K/ l0 ?/ Z4 S$ v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 o% U I* l! M0 J' {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ V( U, i6 I4 ] m; I
: i% @/ u' l, I2 f o! R# g# x
/* assign the tl som board LED-GPIOs*/
% K5 @6 v" C" l; |* }% E' l( Q3 Zstatic const short da850_evm_tl_user_led_pins[] = {* N/ \8 i2 l2 c K6 F" u
/* These pins are definition at <mach/mux.h> file */
% [" ]7 N6 ]& ?" |9 z( { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; _. ?) E! P; y -1$ a9 C# A. T# I& U6 d
};
' c3 L1 k6 N. N/ B! j" {7 \! S
, O. U( b$ J& pstatic struct gpio_led da850_evm_tl_leds[] = {
) O( _1 X- Z2 V4 x( q {
& M4 [7 L2 }8 L! Q" c" S( e .active_low = 0,
/ Y6 V1 H, E t$ P6 z+ e0 u# D* @" a .gpio = DA850_USER_LED0,) X* o) [# E+ B! A; M5 c# U
.name = "user_led0",; @, c) m! T# T' K q
.default_trigger = "default-on",
& @ w; X% ~0 q& T/ r },
3 `( |% U9 z, d8 A2 Z {9 G9 i! G p# }! Y1 j" h
.active_low = 0,# i, r7 Y$ y$ I/ R, Q
.gpio = DA850_USER_LED1,1 b$ @( Y; w: @& s
.name = "user_led1",( q$ @3 {% M, K' g, a! L! d
.default_trigger = "default-on",) V. [% D- p+ w$ G. }
},4 y3 U& u8 `! [
{0 B# K& S3 i% R" o. m! X
.active_low = 0,& r) L+ ]) @3 F' K5 b* C; S
.gpio = DA850_USER_LED2,- P: F# h3 C* ~ b0 l* A" ~
.name = "user_led2",
8 w' o) V3 U5 L+ i3 I8 L k .default_trigger = "default-on",3 k9 Z7 G3 c4 R( L0 u
},
# R' C0 N% Z$ u9 w6 C( @7 E5 M {& i4 ]3 M, y: l& k8 w2 n
.active_low = 0,8 _4 O5 Q* k L& S, m7 Y; x1 O
.gpio = DA850_USER_LED3,+ V# x% z+ x$ ~6 m4 w. \* a
.name = "user_led3",
0 `0 b3 M+ K' \7 r .default_trigger = "default-on",+ D; L9 q `: S2 ^% v8 @
},
/ p8 S: ?2 ~6 t% T" J$ e$ L0 H7 p5 o};8 e1 o- O6 E' o9 L$ R
' Y) E$ W! }$ K% ?" U0 z/ u7 `& Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 p5 [% E4 A! P& h0 L- w
.leds = da850_evm_tl_leds,
! N- K) S M0 l2 L* F* P* H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* p' o3 F. M/ `! g! ^};, k( \1 c3 y. T2 L+ a
2 K- h$ ?6 |/ A+ }/ j0 d
static void led_dev_release(struct device *dev)
! V5 m( I" h2 c+ q{
7 P2 x/ t8 c3 @+ f};, [, |7 _: P* L' e+ D I) [* i4 R
) }) b$ F( ~) ]5 _0 k; ~3 h4 k
static struct platform_device da850_evm_tl_leds_device = {! G {9 \6 B6 J: H7 k
.name = "leds-gpio",# a3 J0 m+ ~3 d0 l
.id = 1,, S, G& K& `7 u& Y+ q7 |7 Y
.dev = {
( g7 h! a8 W. ]& @7 f .platform_data = &da850_evm_tl_leds_pdata,
$ m" j* Y6 n! @4 |. u6 f7 m; {) V .release = led_dev_release,# j6 G7 ?' n8 N/ ] ~, z" C
}4 P2 {8 A9 a$ o; c' W7 C
};
9 G* t4 e* ~: v9 I- a8 p4 f8 ?& z- }. D6 X# X
static int __init led_platform_init(void)
0 K6 U8 |8 ]: W: }7 R+ H! ~{
: H1 O$ j- \. Z int ret;$ a; ], y) Y. r
#if 0! \& T0 Z$ l; d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" `* d, ?4 i4 l if (ret)) K/ U' V3 {2 w6 y( u0 p6 \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- j+ e% F4 _ P( ]% ~ "%d\n", ret);9 t' S |/ o$ p \
#endif
& }7 }1 B0 B8 e: M ret = platform_device_register(&da850_evm_tl_leds_device);
0 I% s4 @9 ]1 f& J8 r if (ret)
" K$ {. P5 M& i2 y pr_warning("Could not register som GPIO expander LEDS");
& R# X" @' s9 a8 v- Y5 ? else
8 r2 h9 S/ d4 n) O8 d printk(KERN_INFO "LED register sucessful!\n");
v# q8 b$ _6 e/ y( _. F+ ]% I1 ]
" u% i- S+ E+ G& g# }0 m1 [ return ret;; g5 u- r$ z9 s& {6 m
}
: S% ?0 ]' o% s0 l5 j$ v e+ D. Q0 B8 g y8 s: {9 E+ ]+ A
static void __exit led_platform_exit(void)
; i! U7 v5 z/ ~5 a8 |7 N! K0 H" b y{
8 a' W# M4 ]& S; c0 M! o platform_device_unregister(&da850_evm_tl_leds_device);$ ~3 D* B4 W4 U( f; O, M4 V
' ]' [- J8 W" X1 P4 b printk(KERN_INFO "LED unregister!\n");
' t* Z! E! `8 _: c" `9 W$ f}* L$ Q0 y: i; L# t7 s! H" G
, Z( _- G* Y" |; Xmodule_init(led_platform_init);
6 n6 i6 Y5 M1 a% umodule_exit(led_platform_exit);
' g" m c# [ Q ^
+ J+ q# p; ~" _ N* MMODULE_DESCRIPTION("Led platform driver");
3 H, x0 @" L5 r* LMODULE_AUTHOR("Tronlong");0 j$ ^% m; q$ R" o
MODULE_LICENSE("GPL");4 q4 u/ T4 [% J6 _/ W% R7 W* B( Y
9 n, q2 q/ {6 A$ |: W6 F
|
|