|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! N( k, p! e- u+ p
#include <linux/init.h>% a- y* }# Y" s
#include <linux/module.h>+ H" z5 ^- Y- j W% j+ q
#include <linux/kernel.h>
! e0 l% v" ?/ i( G1 j- R t4 E#include <linux/types.h>
( w1 m, P3 g8 `: O. q#include <linux/gpio.h>: Q" S6 l& L; @: S, b2 I
#include <linux/leds.h>
" Y P" ^ T( h' p#include <linux/platform_device.h>
7 G9 v) n8 Y7 X5 ^: S: ~7 T& {
& a+ I2 z2 y6 K6 @$ g#include <asm/mach-types.h>
7 W: I! f$ @9 i: `1 `+ V' o#include <asm/mach/arch.h>
" B) Y( E! n$ E#include <mach/da8xx.h>
, @ q( A9 k- N" B9 o8 o6 b#include <mach/mux.h>
+ Z, l( K& c, G0 W- a1 u
0 ^2 g% x5 Y' @; o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ e8 k" H8 V' _% X2 g( n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, ~4 J$ k$ c9 l M, j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 p2 ?2 a0 w1 J# C7 M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 O; J+ T7 j: G& y0 @0 Y+ P* @' \4 d- a
/* assign the tl som board LED-GPIOs*/
}% S: ?% \& m. d' C/ J9 `$ j, X1 `static const short da850_evm_tl_user_led_pins[] = {) m4 Z7 H1 y" B; f9 P. H3 C, \' V6 P3 B
/* These pins are definition at <mach/mux.h> file */
! u% I2 F1 a9 P% W. k% u/ w" i" d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 W4 e; h. Q. z0 ^* T9 K! X
-18 N/ K) j% L( x5 |
};
3 e# t+ e/ u/ M3 L$ f( }/ N# r2 x2 X$ r: v n$ @" w4 g j ], ?5 V
static struct gpio_led da850_evm_tl_leds[] = {8 t4 d+ j7 i& e$ i, W
{
. T5 o& l8 E: z' \$ m .active_low = 0," U* O ~4 s# ~! K; x2 T& X. @+ L) n
.gpio = DA850_USER_LED0,4 F: Y1 q k6 Q1 Y+ F: P. H
.name = "user_led0",5 y8 ?' B8 Y; J X3 {
.default_trigger = "default-on",
! I" I" ^. t; u4 D [9 L6 z* j },
- c- C, g# H3 N( ~; X3 T( F {
; k% y" i: ~/ z .active_low = 0,
3 e+ @' a5 H" T. I5 C* V .gpio = DA850_USER_LED1,
, }1 f8 S5 _+ d .name = "user_led1",
8 Y6 |0 p5 d: x; { .default_trigger = "default-on",
- Y1 ~4 h, ~% V# N },
, Y% z2 Q& O/ e {
; b% _8 g l t% o .active_low = 0, r p0 k4 e+ A$ S1 U4 r5 W
.gpio = DA850_USER_LED2,( g3 j5 k2 p8 S2 k* r0 m# ~
.name = "user_led2",
6 _5 w' \& G( }0 x* J; R- | .default_trigger = "default-on",) }% C- L% h4 J
},
' }& {4 b& [* @* u" _& g) I5 i {
8 ?" m/ V! j' [9 Q5 O% E8 d .active_low = 0,2 K. y* r% }! e' z! s6 ?' a$ I
.gpio = DA850_USER_LED3," j h a) U: Y O3 m2 x
.name = "user_led3",: H E: q( e u7 m
.default_trigger = "default-on",9 n. u+ H) P0 I. i, |( f, o% j
},5 e2 G& j- M2 }- a0 O
};
) ]: T, c& `0 ?! ?+ H+ k
; r2 o3 K8 ?7 e3 R5 {, o. M2 Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 N& q' }4 J5 `1 H
.leds = da850_evm_tl_leds,6 O% c" N9 S& k4 x' V6 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% E, Q# J% \- y v) [4 h
};
$ P2 p, r7 s3 G: ^+ `& W* ` O' g* M9 x
static void led_dev_release(struct device *dev)6 c6 q- }8 k3 f S# a
{ _: [4 B u- Q- ?( \+ }( L5 T! p
};
3 q: ]9 U) U! H) ]- d+ i- G) q: O
4 O- f% [* `, I' i. U7 k" astatic struct platform_device da850_evm_tl_leds_device = {8 g0 ]7 O; k: e9 n
.name = "leds-gpio",$ @. w2 O" B( |' a7 B
.id = 1,
8 V) P2 F' P! f* U% R) W( l) B \* y .dev = {" i$ {( K+ u4 g
.platform_data = &da850_evm_tl_leds_pdata,
$ v' b" B$ W2 R) n .release = led_dev_release,
1 f+ t) j% e+ |7 E- P }
. @3 F6 Q9 L) d, O8 K0 J};, h4 J9 A" \ N. Z
( F& J7 d8 R, d! l8 V) }static int __init led_platform_init(void)
% k6 h; ?% j0 M" K( e1 I6 e{' R% X) {. b3 f; z! ~6 j2 d0 Y' ?* a
int ret;! r! ]$ y/ n' [7 x: _5 U
#if 0) L' R! p& p# {4 K3 h) U: W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 K! G/ U U. {5 A" B7 v2 O: m
if (ret)
$ E5 [( K# Q$ G# m4 s, O' z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ ]% H3 I% U" q) G "%d\n", ret);
- B, h& c2 t- x K' x#endif
; `* @4 [/ G" z5 J ret = platform_device_register(&da850_evm_tl_leds_device);- u, \4 k, w" }4 I
if (ret)
) {8 a/ F" k d& \7 m& J/ O pr_warning("Could not register som GPIO expander LEDS");, n: q3 k3 [1 L& k, h$ F% `
else2 |* D$ K3 j( [) P
printk(KERN_INFO "LED register sucessful!\n");3 Y# h3 ~+ \: o: g/ G3 f
! f7 ~ k( O' r7 ~1 q8 W1 G$ J return ret;
$ w) W5 _& s6 H9 l( E( ?}
, S) {/ t6 \: ~+ H" ^! Z5 \! g/ y+ M) O
static void __exit led_platform_exit(void)
: p! H5 V7 S, |5 S/ e{$ J* o9 y# \, y, R S+ x% ^
platform_device_unregister(&da850_evm_tl_leds_device);7 K+ s3 J* B4 X6 P# G
8 K8 T" Q+ }# G9 \5 g0 R
printk(KERN_INFO "LED unregister!\n");4 H; K" a# N+ b' F' M2 i
}
% {6 R3 C. N6 p- M* a" d: K' S$ j) ]( T2 a( s5 L
module_init(led_platform_init);+ n' u( M8 G; j! I
module_exit(led_platform_exit);: ]+ o$ [; {8 E- t, U; _
% l6 I# H2 Y8 @: |
MODULE_DESCRIPTION("Led platform driver");
% u/ N) a5 d* u$ u/ LMODULE_AUTHOR("Tronlong");
- a. l9 B) \% b2 M, ?- F! ^( L$ D8 HMODULE_LICENSE("GPL");
8 N. V! ?' a0 U
1 x; F& p, b( \; ~ |
|