|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 F$ \9 u! Y9 Z$ ?#include <linux/init.h>9 P5 J) w2 s6 k/ f" u) N2 o0 x" N
#include <linux/module.h>
( g q' A2 l/ @- k7 H2 f#include <linux/kernel.h>
, b6 J- L. R* s) R$ G# Q#include <linux/types.h>5 |4 _. c- _7 P! |
#include <linux/gpio.h>
" N) u1 q: Z1 O. w3 p#include <linux/leds.h>
$ R$ B# T8 f, u6 o#include <linux/platform_device.h>5 M4 m1 @! G6 b( a
+ m3 m( t1 o6 b8 J#include <asm/mach-types.h>
, C0 R0 ? v4 j2 |#include <asm/mach/arch.h>, v% n. P6 b/ f% {# L$ o
#include <mach/da8xx.h>1 P) |) ]7 U% O2 q( C/ x
#include <mach/mux.h>4 u# _. o F; ?/ U$ v
& q( H+ O+ s2 r' T" A; K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). y: g& ?* Q* Q; h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# J+ w& u' j6 u7 _ i2 S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( G9 ^2 Q5 c, O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! I, l% ?, x0 _4 X
4 W# R$ z4 c( S' [0 |' X. W/* assign the tl som board LED-GPIOs*/
$ V9 w' l+ H9 e4 N# Y m+ n4 N0 p' Rstatic const short da850_evm_tl_user_led_pins[] = {
1 ?! C" u- M$ R7 h4 t /* These pins are definition at <mach/mux.h> file */: U' Q/ ~' V; y* H9 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 U: O- n& p2 ]2 r( n
-1# I5 [( |. X8 x0 S5 k L9 R
};% l7 U% x( s; \7 C( U
) n9 b" p o2 g
static struct gpio_led da850_evm_tl_leds[] = {# [8 ^8 ~( E% l
{! P+ D$ ?. j) w9 O
.active_low = 0,9 v7 w5 N. C2 t Q' f
.gpio = DA850_USER_LED0,
: K8 |# l v4 n2 f .name = "user_led0",
" e4 U, Q( D! S- A& d" L: z .default_trigger = "default-on",
. }; k4 H6 a v8 X/ i$ Z },
) t; s( z* s9 G: e+ q {% y6 H5 B0 Q- F. N
.active_low = 0,5 e$ _: W6 N$ d; d6 ]0 C
.gpio = DA850_USER_LED1,
. w1 r: S/ O: z5 ~ .name = "user_led1",5 h' I3 ?3 `5 X; Q( k
.default_trigger = "default-on"," n' a! c0 ~: M' u
},0 B7 |& i \; u! W
{
0 ~2 i2 i" z: L .active_low = 0,
# h& \- \ j! n0 f; D' f .gpio = DA850_USER_LED2,* `8 ^9 ~) K& W+ R
.name = "user_led2",
8 v. X+ }( @4 d. J- F8 f# x, W .default_trigger = "default-on",3 C1 I" K% U6 F' w. e# B
},- v K0 M( W9 y9 f6 v
{
1 F" @& _, X! N P, f" x0 G) \) a .active_low = 0,
& S$ X% J7 u( C( ~; y8 B .gpio = DA850_USER_LED3,2 E7 p; q/ v+ t: }% |! |( m, c' z
.name = "user_led3",
& q0 p1 l, v4 }; a .default_trigger = "default-on", I4 j' M- E1 w2 g1 a9 c
},2 R E1 ~, t: {2 n% `0 O7 H0 ^
};
: K0 \( x& R3 U6 s9 a
0 L1 X% \& b% A7 ~' h3 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" o& j: \0 i2 y4 S
.leds = da850_evm_tl_leds,9 l. X1 b/ w5 i* W- c/ C0 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" P8 {( U( | i& a1 y: h! j};
9 |- e/ H1 S* V8 ]% w& \- l6 K
/ }0 ^# f. i: u' Cstatic void led_dev_release(struct device *dev)
% ?9 d: s2 I+ O# ?* }+ c! i{
/ X# ^) @4 X% u+ W4 l4 Y' f5 F4 v};
# b: t# T2 z8 \. O2 T: K
) O9 i, D0 k- ~- R! L) Hstatic struct platform_device da850_evm_tl_leds_device = {- M& r: o" d: m" v) L2 ~1 K4 X- ~
.name = "leds-gpio",
+ ~: O( d* w* X8 N& }: i1 d .id = 1,0 I1 P5 z' w6 x6 X4 J, e
.dev = {6 p# U y6 S* Z6 y8 N7 {
.platform_data = &da850_evm_tl_leds_pdata,
. `9 J" o+ G( T! Y .release = led_dev_release,7 r/ F& k V- p- e9 C2 _
}+ R, ]$ v$ o0 L6 F
};
: h- o) m1 o) I1 _3 |/ }/ ~, v, c! s) v
static int __init led_platform_init(void)# g+ Q. Z% n6 a" m
{
" S } n4 c* g5 k! l7 ~ int ret;5 Y! q0 |# w# W4 c* N( A1 r
#if 0
0 Z$ h1 T Z2 F2 O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, s/ ~6 z5 C% c2 t' g& F" ^0 u* [ if (ret)2 p2 F% l* C- J! g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* ^! j1 f7 B% i; g8 o V
"%d\n", ret);
i# e( D, h7 }#endif2 x' f$ N5 @) }# U
ret = platform_device_register(&da850_evm_tl_leds_device);* [; U: ]" ]; U
if (ret)3 Y/ q/ o. _- o: l
pr_warning("Could not register som GPIO expander LEDS");
# y* v% T* U. T* `5 D1 ] else
1 q9 P) F+ G+ _) U! o printk(KERN_INFO "LED register sucessful!\n");
8 |% O9 K9 P6 _5 {" |
! m2 ?2 z; p9 K A! P/ p return ret;
1 A1 n1 b6 F) a7 i/ v) y# k% |. d}
$ z! e) @/ j& L6 \; M! k' m* ~$ n6 j5 ]% X* D( B O. V4 m
static void __exit led_platform_exit(void)
( M: X5 I$ X+ U{" c% u8 d; Q" a" }. s8 g8 V
platform_device_unregister(&da850_evm_tl_leds_device);
) A$ [+ P" B4 n
" C5 P6 [/ T6 }: V% w } printk(KERN_INFO "LED unregister!\n");7 L; O; k5 h$ e" y- C% M, H
}
* w3 E# @& T/ @8 j1 e! f
S6 f* a, [0 Q) I4 D# ymodule_init(led_platform_init);% }& N: I1 c* a
module_exit(led_platform_exit);7 _; s2 M& [, z+ F0 R8 m
% U% D' c( D; L6 \' K
MODULE_DESCRIPTION("Led platform driver");
. \) e3 T6 ?$ nMODULE_AUTHOR("Tronlong");
8 p% x2 o9 J0 ^# WMODULE_LICENSE("GPL");2 \0 P0 f( n' k- i
$ A! d, i6 x; h: B2 D- d |
|