|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ G8 s0 y7 h% I7 j0 h- X2 Y& S
#include <linux/init.h>( Z ]8 k0 C2 X9 I9 n
#include <linux/module.h>
* h# U# I1 m+ L#include <linux/kernel.h>( R# H+ ?; X9 N+ q7 }. x7 A
#include <linux/types.h>: A. _+ N# @# @1 q& v! y# t% \0 ~% u
#include <linux/gpio.h>" W6 B5 d# z" H4 c3 N0 G C( K
#include <linux/leds.h>3 a2 z4 e7 l$ W: A
#include <linux/platform_device.h> Z% G5 R" g+ \3 n
( }; F+ A* `5 T/ O8 Q$ d
#include <asm/mach-types.h>
2 ]+ G( C6 v7 W2 K' q#include <asm/mach/arch.h>) E) V, n4 g) S* W8 ~1 ?0 g
#include <mach/da8xx.h>
9 Y. a5 Q; h. z8 O#include <mach/mux.h>. a9 Z+ F5 }5 ~! \! z. T, j( S1 t
9 U; Z9 J. J1 \/ c/ t" k2 n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
[3 Z6 ^+ S' m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ B+ w- @5 [! }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); i6 M. g9 O, p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ K8 e; q5 P, Y* @7 w: s1 n* l' g1 T
4 d. } c. y' D: ^ W
/* assign the tl som board LED-GPIOs*/
$ w& w. H0 d \: I V5 v& @6 f9 hstatic const short da850_evm_tl_user_led_pins[] = {" n+ W& G2 D% d: g9 V* |8 h
/* These pins are definition at <mach/mux.h> file */( L* K1 {6 P* j! l1 ~4 B) b& [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, P: @" F& g% v$ N3 n& `2 c
-1
% X% z; c! S# O1 l$ Y' k};7 c% B# ~3 V _+ Q& Q9 J
. t) w4 i& ]$ c$ s3 Bstatic struct gpio_led da850_evm_tl_leds[] = {! Y. C6 |+ T' [& W$ q5 D. l
{6 r, ^9 U6 k$ b& ?
.active_low = 0,
1 c! t. K3 [% R3 c+ f .gpio = DA850_USER_LED0,
- N8 ]( V' L& m* {: v; n .name = "user_led0",
0 T. s3 w2 U8 {$ q0 c .default_trigger = "default-on",
/ L( W: z! _+ u1 [* z+ U, O" S: x7 ` },
7 U9 b8 O9 W! Y- V1 z1 I$ Y {
, L" O: s) T, |) j .active_low = 0,# h, d9 I$ \; Z* @; p$ {
.gpio = DA850_USER_LED1,
# H3 N- v3 f( x, H3 H/ s$ t .name = "user_led1",
1 M! F0 e+ z4 m0 x0 \ .default_trigger = "default-on",
/ w: k) T6 c6 }; [2 o. | }, p$ F: e* s) k, L9 C
{
, a9 ?* n5 W( a- ~% `/ o+ \ .active_low = 0,& k5 c" ?# f* @0 W- F
.gpio = DA850_USER_LED2,6 u6 l/ }7 C; c- q8 s
.name = "user_led2",
' D& \: ?1 g4 y+ b3 m4 l! v .default_trigger = "default-on",
7 I# f5 K1 j: Z% {/ z },
8 ~. i, g" B# O5 S {
7 d) j& T3 w* h; V1 w4 C9 w .active_low = 0,
+ \" F2 S7 v* W* F3 x2 X .gpio = DA850_USER_LED3,8 K0 w6 @4 z+ H& k2 v
.name = "user_led3",
) ~) z9 l8 ^" a+ q( y .default_trigger = "default-on",9 Z: @( q6 n( o1 u! Q
},2 T7 N* R) |. e* S( D" @
};: Y( N+ i1 M3 x C6 @4 U7 B
4 l) \2 Z' M$ O* Y( H6 {5 N- A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: p, y/ Q# D8 I4 w( ]" h9 g .leds = da850_evm_tl_leds,6 B3 W9 @ `- @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 g2 X; D% t* t6 U. B% H};
. N$ Q1 [1 `4 X% `( R% u
t( n/ F+ ?2 u1 q; ]3 I( ]static void led_dev_release(struct device *dev)
) U R2 o% n$ O! J8 G2 [{, M9 d% V l! }0 n1 |
};2 z, u6 n. d; g2 D# j3 j
. f1 g" A; G5 A+ A" p* E3 g2 p$ sstatic struct platform_device da850_evm_tl_leds_device = {2 i/ s; q- r3 I# [
.name = "leds-gpio",9 h4 [0 [- g7 w6 w5 L
.id = 1,
% z0 t7 i! n8 v( a5 }, E .dev = {7 o* k/ f" x- X6 v: Z1 A
.platform_data = &da850_evm_tl_leds_pdata,: P: a6 ]0 u- Z2 T5 J4 D' J
.release = led_dev_release,
" D& I# V% k! n/ l6 K } x2 X& p. B. ~7 k: n
};4 f+ s1 @; X: u9 p' B
; V# m; g. a j9 \! jstatic int __init led_platform_init(void)
! Z- F: S3 t# F, J, W: I7 z{) s1 h6 M e6 Z h+ d
int ret;
5 w! d0 b) S) U( {3 Y2 A% x) c0 h( g#if 0 c1 c" H+ e6 e1 |+ X4 |( E8 [- q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 E7 b2 u" c; ~6 `
if (ret)& T5 I! h1 l& x. m. @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") ?; L( [$ C+ P* o
"%d\n", ret);
6 `) B9 P: ?+ a: r; M. j9 _#endif2 w, U0 r; N8 I4 i# o) {
ret = platform_device_register(&da850_evm_tl_leds_device);- x: q0 L8 Q9 e I+ X, o5 W
if (ret)
6 n' i$ T- ~# B* h: r' W pr_warning("Could not register som GPIO expander LEDS");
) h9 x# [4 F$ X) {( g9 d else, b& m+ k" v0 e" T7 B
printk(KERN_INFO "LED register sucessful!\n");1 ~) x) q9 h d, b: {
, O+ L' h5 Q5 P( P3 O# n7 E5 Z' K
return ret;
+ [- B {# y/ A5 E}' |5 [- k. y7 x2 w0 Z$ p* W, u
7 H0 _1 n9 P9 f: |8 K
static void __exit led_platform_exit(void)8 P9 N3 K4 L- E5 r& d9 M' r. g
{# n: q4 f9 U+ d( C( w# U+ p! i
platform_device_unregister(&da850_evm_tl_leds_device);4 k: d4 f9 r) n, I5 N9 S9 S
8 b/ D9 t0 Z5 e& | S printk(KERN_INFO "LED unregister!\n");) v- x+ J7 S. h0 f+ v0 b& f
}
* d6 ~+ z! I! g7 s3 V
- F* d4 A9 _- W2 N" e ]1 Gmodule_init(led_platform_init);4 F: ]# Q- T. E+ a
module_exit(led_platform_exit);8 {/ `2 h5 _$ a9 O
5 f, Q( v. N1 [* [; }8 p* t7 YMODULE_DESCRIPTION("Led platform driver");
& Q3 s4 | ?" x( ~MODULE_AUTHOR("Tronlong");# b/ q" q9 A) V5 S' C* d; e
MODULE_LICENSE("GPL");, Y9 k# X9 p5 T8 L8 w0 d
9 D& ^2 X: T2 T+ [ |
|