|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 G9 E1 b6 H( r/ Y5 A" G W# [
#include <linux/init.h>
6 D4 q/ }' e2 O! u& v, s" |#include <linux/module.h>* ?) m. I& |/ w7 k* Y$ }
#include <linux/kernel.h>" x5 w/ v7 y: B: ~' D
#include <linux/types.h>
. k$ N) E& n& ~% u#include <linux/gpio.h>
, y% O$ {1 v; i6 U#include <linux/leds.h>, [4 I7 `! ?+ Y' i% s
#include <linux/platform_device.h>7 h5 d1 h2 l/ U$ S v* g
" F$ G1 _' y1 S2 j5 D" K
#include <asm/mach-types.h>
+ ~4 B) T, ?8 j4 `, V2 w& w* D! ~#include <asm/mach/arch.h>
+ i' J: k+ U* V0 i. g0 i' y#include <mach/da8xx.h>
( V4 T6 X4 b/ F" k$ \#include <mach/mux.h>7 [% J2 U8 u1 Y3 Q! o
. j2 g9 t2 M+ i+ b1 |1 z8 p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: B; ]- Z o' h6 h) P! e7 X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- Z) g: I4 N2 L& @# U. F% v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), U2 H3 p. z1 u% V0 f' U1 i6 s+ G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 n; |" I3 I- V1 T$ B5 a
! b w7 g9 ?2 [
/* assign the tl som board LED-GPIOs*/
) X& E# R4 C1 S( u. Vstatic const short da850_evm_tl_user_led_pins[] = {
- z5 @6 r# X4 { /* These pins are definition at <mach/mux.h> file */
1 _0 x% g: J" p" s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. i- E, t$ F3 A
-1% r! v+ A5 R/ |
};, ~) P5 n1 R2 m$ j" [
8 p) E% }$ o% d0 Y, K( m: a
static struct gpio_led da850_evm_tl_leds[] = {& a2 \) } R# N
{% E+ `, X, d9 u+ _
.active_low = 0,8 i. M- G8 O' m* k% K5 u
.gpio = DA850_USER_LED0,
3 @+ f+ e6 O4 e6 y! }+ Y .name = "user_led0",
& _% N# N9 B8 u% s .default_trigger = "default-on",$ C4 [# s! W2 E! ` H7 V
},* `& R4 f4 @! p
{
6 B- j+ p' k; j2 r$ \ .active_low = 0,; }1 H1 w) `7 L& i
.gpio = DA850_USER_LED1, k5 \1 t) C' E v$ R
.name = "user_led1",& o6 J1 ~8 B/ Q% P J& w% j9 N
.default_trigger = "default-on",8 Q* @) J) K* |6 K& W( t
},
9 j$ o8 L9 U7 v) r {
* D4 y. z6 o q# Z0 e .active_low = 0,
8 t* p8 U2 }. c6 ^5 m7 b .gpio = DA850_USER_LED2,
% O; Q: f3 x3 M i; C1 ` .name = "user_led2",
+ f- z' \1 |1 {6 H .default_trigger = "default-on",6 ?. A- i Q: e2 C( Q; H2 N W
},
8 B! U8 u; n) f+ n% o! e1 J$ J/ w {
9 {7 ], R# ~9 n& {: F9 O5 b .active_low = 0,; ?5 R1 m/ y# d* t: h7 I
.gpio = DA850_USER_LED3,
4 p- s, r/ ]/ g; S, @" A0 Q .name = "user_led3",2 T' T( n9 ~+ f2 l
.default_trigger = "default-on",1 ~0 c( e, t+ F0 Q( m* v, w
},
! h7 |- r4 ~9 X};
1 b# [; u1 L2 X. Q. n7 ^/ P1 l, | p- M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ ]2 ~ ]1 T; j3 r$ @. q; N; I
.leds = da850_evm_tl_leds,
9 a/ v8 _% i- q. Y9 O: V) Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 Q" s9 M% J" ~, S
};* s+ Z/ x2 _ j
% i v9 F; x: J$ V9 f3 V
static void led_dev_release(struct device *dev)4 h" D9 A+ \' q" b$ O, D& u" z
{
9 e0 p$ {. [8 |8 ?$ R};
6 Y' x1 N# M3 k5 P' ?- s
' D+ T/ W1 i3 |2 G* \static struct platform_device da850_evm_tl_leds_device = {
k/ U. R. X, E' W7 @# A1 ] .name = "leds-gpio",
7 J/ y, O$ N( t3 t& {/ d2 y .id = 1,
0 D" D+ T1 c. t {6 n4 I; K .dev = {
+ n# R9 C, U: t& \: { .platform_data = &da850_evm_tl_leds_pdata,
) i# [9 ?: |) {) t% o" X$ @ .release = led_dev_release,
o; o( o( C- w& I ^1 A3 S' F3 h }
: Q x' K- F w6 |};
; e- {5 K1 m# K* [+ n
, j5 G; S$ q! {8 Y& l; ]4 Vstatic int __init led_platform_init(void)+ ?% \) {& Y O4 k
{1 ?8 y6 D r" i) W4 L
int ret;
- _3 k3 k# _; D* T+ R+ D9 n b#if 0
, n# t- z2 J/ _/ j! R7 j# l' @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& j! @8 J* g2 y) ~& R4 c if (ret)
6 W3 \ `3 ]/ r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ H5 c" h+ F! C- l$ [ "%d\n", ret);
' l. X% C! b7 m5 T$ `; `#endif
$ @1 |% ^5 K$ A& S8 P1 t6 R ret = platform_device_register(&da850_evm_tl_leds_device);
" R8 i: a9 Q' L) F/ g4 N; d if (ret)8 Q E$ u6 h: Z. }
pr_warning("Could not register som GPIO expander LEDS");
, k: `/ A/ h! j k3 D# L5 }' S' M else7 k1 w) |, S; c
printk(KERN_INFO "LED register sucessful!\n");. R, y" B1 W+ F- T# a
* z; @' Z; {( x' z# F% x return ret;6 }0 h3 V" v; Y0 K$ y
}& ~ L {1 w8 A9 n
7 [" A- ]$ ^8 a
static void __exit led_platform_exit(void)
- k1 [# U7 P/ |{! k( L' {+ q$ s- u
platform_device_unregister(&da850_evm_tl_leds_device);
, ?& H: o$ G2 K5 ]
- j2 |0 T4 E! h: M9 A- i/ M: Y printk(KERN_INFO "LED unregister!\n");2 c/ L4 i% e8 `
}
9 f; e9 H4 t( d3 I [* k4 t, d9 o2 I9 N3 L9 D; {& U
module_init(led_platform_init);* D7 f" D# n! b" |
module_exit(led_platform_exit);
3 p* ~& ~, q$ F2 C
5 d) [4 Z$ r6 ~" u$ b5 o1 WMODULE_DESCRIPTION("Led platform driver");
' f2 W% ^, [9 B. P* R* w2 p2 {* p$ \MODULE_AUTHOR("Tronlong");% F1 ]& z+ ]5 u& S: z& k, {
MODULE_LICENSE("GPL");+ }" H5 r+ ?6 i. W
/ L; J, w: r. K3 o- m6 x7 f$ z
|
|