|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. H6 f8 R, r# k6 w5 {8 ^#include <linux/init.h>7 H' f3 N+ V) _+ n# j% k
#include <linux/module.h>
: e$ w+ R( x% A" d6 y#include <linux/kernel.h>
. r7 @( c4 o9 C6 a% o" T3 f: n#include <linux/types.h>
1 j0 [* I9 m1 g0 M#include <linux/gpio.h>
7 s% i3 u7 Q x8 w5 ^#include <linux/leds.h>$ {: C7 W1 Q& T- q6 F/ G
#include <linux/platform_device.h>3 T/ y% {# M/ u. [* ^4 z' I' V+ L
! U7 O6 R s0 G7 x9 z- D" t2 p. u#include <asm/mach-types.h>
$ _. p6 d/ B; j6 C+ W#include <asm/mach/arch.h>/ v) [8 l! R! X+ w' K( t; e
#include <mach/da8xx.h>) u+ i6 H: \9 D8 p
#include <mach/mux.h>3 _0 N& K7 H* q0 U& ]7 K7 N" J9 W" b
A( [5 H% ]( l2 L, A. E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 J8 R9 D$ `% b/ ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( Y! d/ u2 k+ I N# c. |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' ~) e. ~( B* d. d L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ y( Q" M' O9 [! a! T) [$ I
6 S# X/ W8 j4 H' ~
/* assign the tl som board LED-GPIOs*/
" ~+ _4 A+ p8 W5 k+ `# G' Sstatic const short da850_evm_tl_user_led_pins[] = {! c( ?, _5 l/ R" k
/* These pins are definition at <mach/mux.h> file */8 [( ~2 i, r! I0 i3 h0 x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* U: N7 u: Q0 x -1- w! H$ B! s5 r
};* v/ \2 z: z; P8 L2 X
8 [, Z8 B" V* }static struct gpio_led da850_evm_tl_leds[] = {
8 k3 {5 W! P; Y {
$ q) |8 P/ S6 X .active_low = 0,
* Q* x* }% k G3 K .gpio = DA850_USER_LED0,
& ]1 w1 n5 v2 x# I$ Z/ Q .name = "user_led0",# I1 `4 n: l$ t! k( N5 j* S& p
.default_trigger = "default-on",9 N7 c7 d1 m) G/ [1 P+ w" L5 `
},
o( j8 w( f* k: a+ | {9 t1 E, ?. o2 }/ m# B8 S
.active_low = 0,
( C# _& ?/ R& i% I/ E/ T. b .gpio = DA850_USER_LED1,. |( L9 c @+ k% i9 G; G
.name = "user_led1",
7 t8 x+ a; P4 s7 d; @9 D! c .default_trigger = "default-on",
* t% g% d$ T% D# m },
$ i4 Y. [: t @1 b4 b6 x {
# P' U4 \ K- W5 Q. [' [, x .active_low = 0,2 _4 M$ K% w3 `
.gpio = DA850_USER_LED2,, f/ B9 Y/ u. d" B1 Y' o2 c
.name = "user_led2",
w9 _! t6 |% { P+ C .default_trigger = "default-on",$ ~! @' m6 D- m; v
},( P& Y. q" ?" v, J" ]* w6 {7 B
{! T. v. e1 Q! V/ Y
.active_low = 0,6 y8 Y7 H% s5 g- y5 J W! U
.gpio = DA850_USER_LED3,( a; \% w5 c& F( S; t/ R, P
.name = "user_led3",7 h$ @3 J" j8 e, R0 x
.default_trigger = "default-on",1 `2 E, @; t) u, @
},# }- k% _( x. x& L5 U3 A
};# g- k3 y' W1 e H T) F% A
% U! p4 W( O) B9 |( D( l6 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { w9 G: W- d! q2 _5 G7 i+ [
.leds = da850_evm_tl_leds,
5 z! Z0 i7 D1 m) n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; E. C! E( j/ g# b4 u};' @0 k/ n+ W1 _( [
5 i- n) l8 _4 Q0 J3 m. |2 \0 {& istatic void led_dev_release(struct device *dev)5 s. c* ]% ~3 F6 I. M* U
{2 F% d& J* [3 b/ `6 Q
};. s$ M5 q, J$ D' r% e7 l9 j' s
; M' A6 L) j+ o
static struct platform_device da850_evm_tl_leds_device = {
4 v" H+ ?, z* ~3 G: W0 T .name = "leds-gpio",
( S1 Y1 d1 Q1 h: n+ p9 G" l .id = 1,. U% t; N8 X6 l x" s! N
.dev = {
7 R# J; n) @* y& |1 \6 ~! t .platform_data = &da850_evm_tl_leds_pdata,
$ X M( K; Z6 F" D2 h2 P .release = led_dev_release,
+ n& E/ l1 ~( G: C0 @. Z }
1 C7 J1 }$ ?9 D) Z* A% x0 S3 C8 h0 j};
+ A2 t, s9 N& }' a6 J5 E5 e6 W6 e) [; s3 W
static int __init led_platform_init(void)4 B- L7 U1 j3 v
{
, H% k! e# C, q int ret;* t5 _9 c" m5 m
#if 0
r3 B9 p3 W! D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); f& M% [9 k% t) l
if (ret)
/ m# M: f7 B8 ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 \! ^2 {) t9 u5 D: n "%d\n", ret);
; r7 i# w$ }- B#endif) s7 n) z6 V! W0 p" n
ret = platform_device_register(&da850_evm_tl_leds_device);' a7 _3 s: y: U
if (ret)! V& n4 I9 [, c- M- | u! o T
pr_warning("Could not register som GPIO expander LEDS");$ R! ^- [; ^: |. H
else4 j7 _/ R) ~3 ?0 z
printk(KERN_INFO "LED register sucessful!\n");) H) |) x/ G1 [+ G% b2 E
1 f9 q, u6 C* l5 L$ f
return ret;
4 w6 C5 X6 A# i}
- f1 t& y" w0 e. ^8 o( c8 a i1 [2 E+ q
static void __exit led_platform_exit(void) ]/ d( i) M, o9 j; [1 y! s
{
8 d8 b& [. X( b9 E: L platform_device_unregister(&da850_evm_tl_leds_device);
0 ^3 j) U; `- z. P; V+ I. {8 D8 f! y" `- `* u9 w% ?
printk(KERN_INFO "LED unregister!\n");: U& L% b2 l8 ~. B# Z
}
7 x( V0 t6 B# I3 H$ _8 B7 j2 p0 G% Y5 s9 l7 n: S9 ^" ~
module_init(led_platform_init);
- v" w. b1 {, jmodule_exit(led_platform_exit);
" G- { l4 `+ o1 [) }; E4 [
8 m+ B7 E4 [; `8 Q) H# T8 c/ MMODULE_DESCRIPTION("Led platform driver");
a; R6 l% v) ^" jMODULE_AUTHOR("Tronlong");( t: ], l. Q+ q8 C5 z- X
MODULE_LICENSE("GPL");
+ ^' h4 c# {7 Z; q4 c; y( p
& W/ w; |2 Y/ Y; m+ M: U |
|