|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) Y; {0 K; m5 _1 w#include <linux/init.h>3 O; p, {; Y' A: H( w
#include <linux/module.h>
/ x9 R, A8 h1 ?( t- u' O" I#include <linux/kernel.h>' @$ r" i7 A) Y
#include <linux/types.h>8 {+ X( [2 S1 k- w! U8 f
#include <linux/gpio.h>
' c l ?: ]# \#include <linux/leds.h>& m5 n5 O: w* s( D- G, o6 O
#include <linux/platform_device.h>
* @+ X% q; I9 s! U: S
) ^/ ?* s U% `& Y#include <asm/mach-types.h># }4 y# m [& H2 p- u: b3 g
#include <asm/mach/arch.h>3 R- h8 H& S" L8 `& M
#include <mach/da8xx.h>
5 Y5 y, i7 c% V& s0 K! C+ c#include <mach/mux.h>
/ y! c4 d& T0 M! U" i$ o, j6 Y# h, Z: `- k2 d0 W" g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 L+ i! T! X9 ?; W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ w, k8 A9 H# j a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! e; X$ A! [& R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ T$ q* D5 V) m( D( h1 e/ Y- K% S4 p
0 V% m, S9 t; Y& e, d: j+ [5 T
/* assign the tl som board LED-GPIOs*/8 L& Z' s3 W4 ?
static const short da850_evm_tl_user_led_pins[] = {
: A6 m$ @! A9 P6 `$ V- \! E( V /* These pins are definition at <mach/mux.h> file */! r: u4 q/ J8 B' B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( j( i& j8 y* e6 B -10 i% m; f% C& K# L4 V
};
/ q! S7 a& e$ |9 y
4 T9 W3 ~( ^8 x0 z5 @* Y( sstatic struct gpio_led da850_evm_tl_leds[] = {
: y* ^6 O- y4 z, }; l4 ?1 z {9 j; `5 b" {+ \3 L2 g2 ~: k
.active_low = 0,
% q+ \" _, g9 z! j .gpio = DA850_USER_LED0,) m2 x1 @8 Q d& \
.name = "user_led0",9 W) @# v m4 W: I9 ]6 V- w6 p
.default_trigger = "default-on",
) q/ U; ?" k! z* U0 L. V% c },$ _, `4 C+ o% `* | L
{; Y. f- S$ q) I7 H+ ^
.active_low = 0,) [) i6 d( [( E" s+ q, Q' V
.gpio = DA850_USER_LED1,. U3 }* R- m6 C: w( e+ T% A
.name = "user_led1",9 e L0 T% v! y) e2 q) B3 \. B9 d
.default_trigger = "default-on",
# w# ^' \& }7 r# g. f },
# U/ @/ U0 |5 f* w {/ N, a0 g: J) l3 T( p( ~: E
.active_low = 0,. T! E8 V5 I0 [% K. g" _5 a ?
.gpio = DA850_USER_LED2,; F% q. B& S( j% C' N2 Q8 ~# Y
.name = "user_led2",
6 T* N4 M- t+ u' ^3 F1 V) ^, O( F c .default_trigger = "default-on",
0 X N( @7 z4 ?9 G2 Y" P, o$ o& E },8 d( _1 L& H) J
{
* v/ G- M [" t) y2 M( _' L a* k .active_low = 0,
; W( R& t F2 B* |( x- x .gpio = DA850_USER_LED3,- c+ z9 p& x- K
.name = "user_led3",
. a* I1 l0 A" N; k- g .default_trigger = "default-on",
* @8 z( }2 e; X0 ] },
% C2 K- W, m0 o; F" d+ A) R};
. T4 \/ j& D( s4 H$ T1 l: \8 T1 p) d( j5 c6 x* j% B) |: C, E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) u; m$ y! y" K: s, q1 | .leds = da850_evm_tl_leds,
, e0 d. W- Y, T+ J5 G# [; Q8 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 u, i& K& D) P: H, u. d% F};
1 j% F3 C6 B9 U$ o# o) K0 j& ]: L4 j
static void led_dev_release(struct device *dev)
8 E1 S# X- g/ M; f V% C{
2 \- X9 w1 R) I' t! i6 n};4 o4 b+ M# j* ]3 _7 ~2 J
+ K( g2 c8 p0 l( H2 f
static struct platform_device da850_evm_tl_leds_device = {
* r! H! m! r4 W" J! l; c0 X4 ^0 ^ .name = "leds-gpio",2 `* n' |/ P, K* | a" o
.id = 1,% t# Q- k/ w, y; s$ D
.dev = {9 f1 b+ z/ N) C! j1 p1 C
.platform_data = &da850_evm_tl_leds_pdata,
; ~4 o- Z4 ~8 f C, B .release = led_dev_release,$ n# u( j: n; x. Q# v: O& A& h
}* v2 s' ^0 X% i8 y5 \" Y
};
! x( |, x3 @; O4 U' D; E ?8 }/ X3 V4 P1 E" |7 j! f1 X1 ~1 [
static int __init led_platform_init(void)
! \3 n! E% z7 s; u+ q# \! Q2 M4 f{
+ g; i# m$ |$ Z. U5 Y* _' _* D int ret;
$ N% |/ L. i& `& m( b, Y- E$ K4 F#if 0 \) u$ \6 E/ q% [1 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 w7 x8 C5 L6 ]5 R+ b- D( ` if (ret)
, [* a1 g0 M' ?7 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :", s( X: n% i2 e) c& J4 {
"%d\n", ret);
2 y& f' Y" E/ U9 \) e" M+ b v/ I#endif3 a, w) Z: [# |( d- z% ~! l
ret = platform_device_register(&da850_evm_tl_leds_device);& ` q- n5 {# k! e: p6 d/ _; \
if (ret)4 \, X+ R6 A; q( G1 t+ r" m' u# O
pr_warning("Could not register som GPIO expander LEDS");! A0 Y( f8 E7 z. B
else& M* a, F' h5 Z: ?3 D) H) n! Z
printk(KERN_INFO "LED register sucessful!\n");2 E5 p3 }9 Z" n' l- C0 R: `
- G1 }9 {, c' F return ret;3 B7 s6 O" I) _' A) ~/ \. m
}
( c. \4 C8 [3 q! `# @, m- ~$ t' A
static void __exit led_platform_exit(void)
5 D" `+ m/ C3 i# I* i{
+ o' l: u- F$ l& M platform_device_unregister(&da850_evm_tl_leds_device);
( s. N1 J% ?9 ?5 o. q" b V3 o1 f1 Q, _* I( w
printk(KERN_INFO "LED unregister!\n");
; \4 J) p' O) D' U}
7 @. [. c3 v- W$ _+ Q% a3 B
/ v( I W1 G' ]8 i& }module_init(led_platform_init);. _( f& w8 @# [ y i
module_exit(led_platform_exit);
) h; z' \/ y# t2 @& V) d/ R
: x3 Q O- s, bMODULE_DESCRIPTION("Led platform driver");
6 D# y; @5 O2 q' b5 ?& f! C6 P, QMODULE_AUTHOR("Tronlong");
9 `+ d3 s; s3 A7 N; G& HMODULE_LICENSE("GPL");
$ b7 y% x6 K3 l0 X) ^' F
' A4 E$ ~0 n5 t+ K6 D. B" Q |
|