|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( R4 m6 P- B3 }) m. ~0 K#include <linux/init.h>$ A) R% l$ M1 E$ a0 l4 z1 y
#include <linux/module.h>
( H* Z, g& w$ }% _#include <linux/kernel.h># O, {. P$ n, y+ b
#include <linux/types.h>
; x# Z: x$ \; i9 H4 c$ N1 i#include <linux/gpio.h>! E# f, X% l* A5 G- D, m# q* Z
#include <linux/leds.h>6 j1 I. L) F- S( W4 Z
#include <linux/platform_device.h>
) c g1 O" B: i* ^9 w# [& W$ N3 z! |- S$ H: v
#include <asm/mach-types.h> j% J- F; J' X* [( h; Z9 B5 e- T
#include <asm/mach/arch.h>; ~" X1 V P" Z0 s9 v# A8 t# @
#include <mach/da8xx.h>& z' o( h3 M& U& ^. A: i( P
#include <mach/mux.h># P m7 y" S. h# t' H) o* N
) v Z# N+ e$ ]! p+ M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 a: S6 V$ p" y0 u/ d3 @8 I; u1 D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% w1 |$ v" b1 J( r) u. p. h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ D3 x: Q" I6 F1 q. F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( R8 S: H% ~9 @# c7 j# H
6 X' V' i0 ~+ {/* assign the tl som board LED-GPIOs*/
) x9 U; i* z$ {- }) H+ i* astatic const short da850_evm_tl_user_led_pins[] = {) q$ N# w2 x5 Z7 l+ C
/* These pins are definition at <mach/mux.h> file */$ n& A; `) K* |( b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* S4 J W4 a& \* D2 ]5 Q1 v7 z
-1
! f6 ?3 G2 g9 Z- i/ D! S};/ r' |: Y3 I) B, k" \- p
% E5 D5 l' s0 d" T# u( \/ k1 R9 zstatic struct gpio_led da850_evm_tl_leds[] = {
: F8 a5 n) }! a% k) _. V {
: r; S3 M5 X0 |2 ?+ D( R .active_low = 0,
/ i3 _2 F2 m. ]' | .gpio = DA850_USER_LED0,& f# H) O* C- |$ m0 r
.name = "user_led0",6 k) b; L5 K M) G9 R
.default_trigger = "default-on",, b# w; ^4 a5 ~. W# S
},% j% v6 |7 l. p& p O
{1 F# k: F- \3 O& W, G) z* |$ g
.active_low = 0,
9 E1 p8 y& H( R5 M H$ x .gpio = DA850_USER_LED1,
+ v6 D0 W1 D. @ k6 {+ U .name = "user_led1",! p8 S8 |; ]6 M* I+ f+ `- O% z9 h* N
.default_trigger = "default-on",
+ Y0 q: Y5 V% n. U },
& \8 {2 W7 | k% `2 x0 q/ j0 O {
% r: L1 @/ @, n .active_low = 0,
$ V! W# C6 ^0 o' C7 F .gpio = DA850_USER_LED2,
7 l$ g" w1 H8 n( `9 C' d .name = "user_led2",
; ? T3 d* |1 J3 ~ .default_trigger = "default-on",
( i$ j% Y) {4 ]2 E },. y3 I9 T% f. Z% E6 u* {. K4 L
{) H7 u( U! L: F! a
.active_low = 0,
5 O5 ]( q- u+ ~2 D* w; h# s .gpio = DA850_USER_LED3,6 p; ^( J2 ]+ u* U3 u9 [. C' K
.name = "user_led3",
. v0 e- m2 B0 @$ X8 V$ v .default_trigger = "default-on",
! M( Z' g* p0 B! x8 l% [ },* ?) f' f2 {" N5 g
};4 ? T, S, ^" Q3 A) N% t5 K( P* ?
8 X6 z8 o; E& I# m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( R% p0 o7 q1 y. ]! c4 K
.leds = da850_evm_tl_leds,/ f0 b+ {; {+ B- Q. x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) r8 O2 b. ?. Z8 u};8 [$ [3 P/ |5 J6 Q" K1 \
, m) k J% A$ b5 \7 r; Q: ^7 q6 [static void led_dev_release(struct device *dev)) }; L* v( F5 {) S( R
{
% @( P4 b& M! V3 v};
) Q) F# U( U+ `5 W, E2 B" `, J! o% C a
& F2 m# W- i. w5 B' o+ B8 _' Sstatic struct platform_device da850_evm_tl_leds_device = {
5 i8 t- N$ I4 j* b5 f5 \ .name = "leds-gpio",' p3 ^3 n% p# V. |6 Y
.id = 1,4 w c% o: [, j3 o; w" ^( x7 O, G1 Y- q
.dev = {: J3 C B4 A! B3 V
.platform_data = &da850_evm_tl_leds_pdata,% [: w( U* E; e, U5 g; i
.release = led_dev_release,
3 f5 X0 u# r: p* V$ l7 t H }% c9 W( a2 Q% i, T. |, n+ c
};, w n0 m& ~" c: g* U9 @% x
$ z8 m% w9 n8 s, b( t; o
static int __init led_platform_init(void)* [, @: K3 b; n3 D) z# A3 v
{: P) i5 f0 J( C# H
int ret;
0 d$ }9 y1 R8 |9 N#if 0
8 p: y- y7 X8 ~9 I) q. |. a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- z1 o3 j3 J3 Y1 O5 C# C, ^. U
if (ret)
p( D/ V7 @7 W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 R3 s4 p7 w1 L/ \, m/ ^ "%d\n", ret);
3 m4 Q E7 O$ N; O#endif" d" H! y3 O" A; t1 W; T/ V
ret = platform_device_register(&da850_evm_tl_leds_device);
5 h) ]* A, d# j/ H' q3 ] if (ret)
8 m& f5 G, ^' j2 t. s pr_warning("Could not register som GPIO expander LEDS");
2 |. i* A0 x4 j6 v, T2 K else
. M5 P9 s. F5 x/ y6 r printk(KERN_INFO "LED register sucessful!\n");
& O- D2 F' m# d3 T7 B* [+ u; C4 E$ P
return ret;2 ]' B" U0 Z6 i
}6 w4 \' Q7 z1 j$ ^1 a$ j6 n
6 P5 B/ {7 i7 D7 n' T0 d2 O- v2 tstatic void __exit led_platform_exit(void)
& p7 H* r2 Q5 l0 V1 O{
2 \" ?* L* J$ ^: t8 _: _ platform_device_unregister(&da850_evm_tl_leds_device);& B& b2 `. N7 e1 I0 u! P3 @
( r: \2 d# E2 f c( F( h
printk(KERN_INFO "LED unregister!\n");
1 m3 g% P2 w; ^8 c, i}
$ T. ]7 a$ V( E, t7 m' R
6 k# g% r% q2 U" O+ [2 @4 H4 g! Rmodule_init(led_platform_init);# N/ v+ x, {. b
module_exit(led_platform_exit);* C7 O5 w j$ x0 s0 w S! A O% Y
! z) _8 A- r* g* f
MODULE_DESCRIPTION("Led platform driver");1 }, r V+ u/ |% Q p+ C
MODULE_AUTHOR("Tronlong");
7 X4 d- B& `3 J; E _/ xMODULE_LICENSE("GPL");
) c L+ w8 M7 ~7 e" V
. X4 E! {$ ~( j3 h( N5 ~ |
|