|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 k; K% ? w @7 P
#include <linux/init.h>
f, ?+ J( P" [7 e4 u: x#include <linux/module.h>
5 M2 n& p" d2 {0 I#include <linux/kernel.h>/ T! l# _6 T, V2 w+ q) Z
#include <linux/types.h>8 n( q( ]% h4 ~1 u0 H% y+ }- k
#include <linux/gpio.h>2 X, j4 [1 A7 \" ?& r7 O
#include <linux/leds.h>
6 }+ `/ w6 U8 J) Y6 N2 c) ]2 J#include <linux/platform_device.h>
, ` |8 q( o* z8 z# G
: ]- C& ~; | ?3 G1 r#include <asm/mach-types.h>% Y! C2 L2 k* Y- f6 l1 {
#include <asm/mach/arch.h>8 I1 H$ H' C2 A
#include <mach/da8xx.h>
- B3 _) k4 R) U" c/ y$ F) f- f#include <mach/mux.h>( {: z' a- L1 j; v
7 c. ~% ]- c5 U9 A, G/ y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( q9 @" _' b+ [- [- z8 r' j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 E8 H# c* j. e1 @$ `8 n5 U7 v z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 e1 {. L' p+ n0 H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% @. a- E/ ]; q6 C8 j: G
6 V) V( G3 m: G' Y x/* assign the tl som board LED-GPIOs*/+ C. Z1 ]3 n7 r* e
static const short da850_evm_tl_user_led_pins[] = {
% |7 s" \, a5 }( }& l: c5 r/ z$ x /* These pins are definition at <mach/mux.h> file */5 c0 g4 C9 T0 k6 n/ L* r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 R$ u$ X+ k& @) R$ D -1
- C& a8 c* Q8 C% ]7 ` L};
' K& O# w6 S. z9 Q9 {- x- {# z( Y1 t! h, M) ]) S
static struct gpio_led da850_evm_tl_leds[] = {- H" b% C: G. ]
{
" U; u0 A1 }0 S9 W) _6 ]$ X .active_low = 0,
* F5 S* y. J+ _& F4 ^ .gpio = DA850_USER_LED0,
8 R: p$ A' [- [9 x' c .name = "user_led0",1 Y4 J+ q( u% \+ j, P1 d, ~$ ?% {5 U
.default_trigger = "default-on",
+ G& \7 Y9 ^( B# ^/ u4 j. J },
; x. ^2 X1 T% @" w/ O {
% p3 s' M& {" Y/ y. {( i. E .active_low = 0,
( H2 U; m* u) a) x, r* I .gpio = DA850_USER_LED1,
$ U0 g+ X% \2 j9 U2 v. N .name = "user_led1",, }' `! S. G/ b8 L' n1 z+ E8 x
.default_trigger = "default-on",
( X( \% w# u- m7 ` ` },
, U6 Y1 ^7 q3 i& j1 W4 N {& a) b, K. q: g; v3 k5 s
.active_low = 0,
. g. V h" @+ z+ S( D .gpio = DA850_USER_LED2,
% `- `' b% p" E& j+ a; q* s .name = "user_led2",
7 K" K% v; \2 l* p" ^8 d# _" c .default_trigger = "default-on",
- l3 ]1 R' m; s; G$ m7 I },
- o6 E7 d% v/ L% X" D1 J {
$ h" d: @' N& u, E .active_low = 0,
$ x+ `, A% `; t L7 ?) D( |, E .gpio = DA850_USER_LED3,* u# q9 s; p) _2 v
.name = "user_led3",
( b I) j5 `8 P% I# M% n, ?( K .default_trigger = "default-on",
# |/ D: `2 D) I },
: Y7 w: `5 l- a+ R2 E};
0 d8 c$ N! o' b1 J7 m z0 v S$ c3 K4 F {8 l) [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. \% O/ O; n/ i f+ @
.leds = da850_evm_tl_leds,1 ~% K- |2 s3 s. u+ O. H2 W& R! n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 o T9 M, ?7 G; [2 C
};
1 B$ I) P. z$ i2 `" l# q5 v5 ^* S$ e2 L
3 b( I- s1 ~$ U- mstatic void led_dev_release(struct device *dev)
& R" t; [* s; A( l{$ ^ X4 c- b6 J' ]5 Z1 E) }
};
6 I# g5 d0 O- G- \+ y* O& g* `' @ q3 ` W0 ]; G/ C
static struct platform_device da850_evm_tl_leds_device = {
J& Q1 R3 H& i% J- v) l9 L8 k .name = "leds-gpio",
/ {; _3 l& Z1 v0 P' g' d; |# y .id = 1,
/ L7 K1 A, { \- d* C .dev = {
3 o& l' D* i% m, Y z5 c .platform_data = &da850_evm_tl_leds_pdata,5 [8 f9 i6 ]/ {; c; }2 L
.release = led_dev_release,+ w! H7 Y, J9 k+ }8 r4 S
}6 m, s( h' ?# [, m# y/ r q1 Y
};
2 I4 Z: W( K; L, i) L# f8 g+ ^0 d' x; u8 C* {! s# [8 s
static int __init led_platform_init(void)1 o# d7 N$ F( n% K6 [; t) F1 ]: P
{( l6 q1 N% K* w, G
int ret;
6 l3 l$ r9 g9 t6 ^ Q: G; _% a#if 0
" O& A( e4 z0 a! Q! X* ]* k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) \1 N/ T( ~6 e; x
if (ret)( Z# f) u& S: o/ O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 v- i! P! O& x& h "%d\n", ret);% l3 Q. {. \8 A9 h1 a
#endif! Z' r, W- U/ }/ i1 p0 _
ret = platform_device_register(&da850_evm_tl_leds_device);
* J7 w) K& X8 X5 j+ q* [# o if (ret)2 q9 P( Y5 i% y9 \$ E/ `) |
pr_warning("Could not register som GPIO expander LEDS");( I) I! h9 s5 l& Z
else% H% a6 n0 N4 Z3 u2 u' F
printk(KERN_INFO "LED register sucessful!\n");, N0 }$ Q! @+ x% o/ C
% U7 `: {8 j7 B return ret;. n7 A/ @# Z& `' f! I* }) C
}5 p6 P/ j. R& r: o7 g, V
. p# C" H: e7 D m- S: I J' Xstatic void __exit led_platform_exit(void)
) Q4 `/ M# h1 J2 T{$ y' o3 ]6 W2 z; p
platform_device_unregister(&da850_evm_tl_leds_device);$ U$ F5 B7 o) M$ C5 g5 l3 z' T
, M$ f5 f! f* b+ |
printk(KERN_INFO "LED unregister!\n");
" Z" w& b I2 b}$ {" k% t2 T$ o2 b
' o: C# Y2 G3 S: S3 j, q, Gmodule_init(led_platform_init);
+ p5 i( ~& t3 g% w) r, Imodule_exit(led_platform_exit);/ T- Z8 `0 x$ L! I% Y
+ ~* m9 ~1 G% h& @
MODULE_DESCRIPTION("Led platform driver");
5 K% u5 T0 X6 f0 A$ y* i% }MODULE_AUTHOR("Tronlong");, @3 Q3 ^/ W. v1 F% N9 J
MODULE_LICENSE("GPL");
6 d% u ?( A. L& n# u" ]/ Y
- l1 e1 F, v% N2 j; e |
|