|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 \2 [& v# f& p" b7 A" f! j#include <linux/init.h>
8 P6 r" e, M% j, u% }6 u; N4 Q9 b#include <linux/module.h>
( r1 z3 h S& R! i( ~0 n- Z# Z#include <linux/kernel.h>
% N4 c |7 P ]7 s1 i#include <linux/types.h>9 O2 O; a6 W" i
#include <linux/gpio.h>) p6 `: e/ I6 S7 U( A$ i
#include <linux/leds.h>
: O$ O( @/ `8 @) I$ X- I0 a) y, ]6 r! G#include <linux/platform_device.h>: C8 O/ x3 \+ _. R" A* O( W
5 g2 l Y; `$ g6 F% F1 X' _; I
#include <asm/mach-types.h>7 n2 m; h( p. |8 a( a5 }3 _0 ?
#include <asm/mach/arch.h>0 Q" S( L3 }( n0 L# D
#include <mach/da8xx.h>1 _4 p* N" F% l4 X7 C- t
#include <mach/mux.h>, s" b- m+ n) d2 w0 f
0 C N8 e8 u" m: @% S+ b% J' o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, e; f3 P9 x+ F3 w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* U; V" V0 R" {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* K5 R! Q S [4 k0 T: W; Z* m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% k3 r6 F! \4 t. F9 t& E
5 g1 Q, C1 h0 s' Z6 s2 ^) b/* assign the tl som board LED-GPIOs*/3 ]1 e. v7 ~& l
static const short da850_evm_tl_user_led_pins[] = {6 J; o! Y0 F+ B
/* These pins are definition at <mach/mux.h> file */& X; [- \1 T$ K7 ]% g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 p! {& U$ z! X -1
2 `5 u2 C9 p' A2 Y};# e4 w& W O' O, S
4 t7 n$ z$ z: N0 y2 k! U
static struct gpio_led da850_evm_tl_leds[] = {% a) r0 T) w8 y: ^
{. L7 s8 k9 q6 i6 l3 E( g* \
.active_low = 0,* D3 w9 g7 W4 n: t
.gpio = DA850_USER_LED0,& e$ z% {( t+ U0 h
.name = "user_led0",
- C, ?. |3 Z- O+ b2 k .default_trigger = "default-on",6 Y: x4 y/ x" D4 D$ P* t% t6 V; u9 i
},- \9 [2 a8 Y ^; h8 [! ?6 ?' H* P, o
{
+ T: p4 D5 u$ w .active_low = 0,' ~( `, E6 G# O, V V
.gpio = DA850_USER_LED1,
8 c/ G6 S7 U( p% @# Y2 j: m+ J: t .name = "user_led1",) s) u* b( g! n, ?! V. b1 @( A
.default_trigger = "default-on",
9 l5 j9 K1 L$ ~( U( k },
% l" |4 M% S" o3 G {
7 P6 ?; O* [' z* Z5 e7 Z/ H# N- Y; k .active_low = 0,/ g2 D% H" f( s3 N+ [% t% ?9 Z( o6 @
.gpio = DA850_USER_LED2,
- ?3 {3 }" K( P .name = "user_led2",
. w) s A4 d% J9 a1 ^+ {" H .default_trigger = "default-on",
6 O* @9 q% B: L },; f% C6 e7 c' `" J( g/ ]
{' Q* @( p ]! A& a6 ^
.active_low = 0,
! ?* v, a- _' @& R8 w .gpio = DA850_USER_LED3,. n! u, g% X( _
.name = "user_led3",
7 x; Y" @% H# _ .default_trigger = "default-on",
/ }, }/ A2 c/ m6 u! E1 [ },
& e. H+ j7 R# F* \1 B};
( D# ^) _- b: f1 m: F( M* e
% k# K5 q1 w* t7 H0 @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ M0 E1 N$ y4 b3 m: S .leds = da850_evm_tl_leds,
- Q# v+ ^# @6 P: g* V) q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
w% R) _0 Z9 `9 d& K9 U- `};
* I2 E, R+ Y( E9 {$ D
4 x; [0 R; ^2 p* i: X* Zstatic void led_dev_release(struct device *dev)
/ U# k* \3 p4 U! l" Q5 g5 s1 }{
! ~; S( P4 @5 y) @; d/ ~9 v};
$ f' P3 N5 `* M0 u/ _, q/ K, S) D$ s* v I8 g: F4 l7 {
static struct platform_device da850_evm_tl_leds_device = {( v! N) g1 W0 E6 v. A* I
.name = "leds-gpio",
& M2 q* j* U9 W+ j' r: ]3 z .id = 1, C8 J# S' F7 x8 F4 s5 E4 q
.dev = {
1 i. S( [8 n+ D .platform_data = &da850_evm_tl_leds_pdata,
2 V! X1 z, p6 ^3 x) a, _0 f* _ .release = led_dev_release,3 C$ Y+ t% a" }) {+ U
}
6 [* {# @: i2 U2 x) o. j @- F};4 l g- Z/ s$ n- X/ \2 i8 h
0 F& e( l4 W8 V0 O# sstatic int __init led_platform_init(void)) l) x8 a5 f0 W; L5 e
{# z+ r& Z5 x3 W# d+ f3 N
int ret;3 n" V& g6 w4 Y8 H* y, f. z2 g
#if 01 J* q, b* [! ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ @: x. @$ K: D# I if (ret)
2 ]2 K4 C( ~! O3 F" d) A; M( @+ H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" t/ h) k/ a* j% J: [! \
"%d\n", ret);$ {9 z5 r! s/ b7 [
#endif
# t/ }) ]5 t2 P0 A. Z ret = platform_device_register(&da850_evm_tl_leds_device);
+ [2 e7 l2 Y8 r" y' g% x if (ret)2 C, Q7 ]( P) u0 ^( B. ?
pr_warning("Could not register som GPIO expander LEDS");
% T _) P; Y9 j3 { else2 Z$ S3 P8 ]% }
printk(KERN_INFO "LED register sucessful!\n"); d8 f2 o0 `4 P3 f8 Q
- W3 m9 V( ]: h9 \
return ret;
! M/ P. ~/ Y$ t( Y5 r+ N5 u}2 c j5 u. ?' s% V2 X H
0 c! j" l$ b) K% B+ T0 o0 T
static void __exit led_platform_exit(void)6 Q( Q. L1 P( h& d8 `
{; C4 Y. ^8 A8 x$ B3 s
platform_device_unregister(&da850_evm_tl_leds_device);: A4 k9 V) ]* G4 x& L
& J% [9 {3 A9 _: @' }) O
printk(KERN_INFO "LED unregister!\n");
w# v4 W6 N& ]: V3 L; d}; M, V" c6 K- p7 m
) I! k! X, y- i1 k, |module_init(led_platform_init);; f7 z% I: S+ Z' W* W
module_exit(led_platform_exit);
% S. _3 }- w1 d f9 f6 M- \0 ]- k: n6 z' v" M/ w. C5 @! f1 F
MODULE_DESCRIPTION("Led platform driver");
) e" G F% p" q, m* w- ~" LMODULE_AUTHOR("Tronlong");
6 A7 c6 W; ?3 _# _: g, XMODULE_LICENSE("GPL");$ V! r* t4 I! H2 M0 E4 ]; Y; Q
% V U7 n @8 M, o- h6 v
|
|