|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ j' N, m. ]7 w# P#include <linux/init.h>
. M2 ]3 ~8 i; k) ?8 S#include <linux/module.h>/ `9 @: \1 V# ]5 ]: |& K" V% t3 D
#include <linux/kernel.h>9 m! B2 V& m* E3 v2 V8 h
#include <linux/types.h> X. h9 a. c. n# B9 t5 r
#include <linux/gpio.h>
/ x6 W; Y6 N( D$ D+ r& E#include <linux/leds.h>4 i2 w1 o a! ?( }
#include <linux/platform_device.h>* \ m; Z5 C0 H; S& j, e3 x
" U* U, `3 f) M3 U' ]& U# Q
#include <asm/mach-types.h>
: J/ i4 C" m' Q0 O" w, U#include <asm/mach/arch.h>
# c! c) U4 @' m& _#include <mach/da8xx.h>. G, ~( `3 ~0 w, y. D9 @- Q
#include <mach/mux.h>
% E3 ]6 P$ _2 p& D
8 z% {, I3 K" v( S) E" G# q x, [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 Y( }" p# E6 K& b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 D) P8 h6 o: A: |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. b/ n7 S/ ^4 x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, _( o- Q! a" P( |' O# k; l# v, W; p- E
/* assign the tl som board LED-GPIOs*/- M; D3 u. W5 w
static const short da850_evm_tl_user_led_pins[] = {
, F, a7 B2 \. d6 X /* These pins are definition at <mach/mux.h> file */ k: }, i% c3 g, T# c; l& a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 Q) ]: s7 w% n t5 E
-14 _! i* E2 `# \" |
};- t3 m$ W0 {, y4 g/ j3 u) R
- c% V1 l; n6 ?8 [! W
static struct gpio_led da850_evm_tl_leds[] = {
5 R1 i m. X7 L0 ^( s {
$ L2 R) X9 K: n& J .active_low = 0, U9 U! C' w L) R& @) J$ z
.gpio = DA850_USER_LED0,
9 ]/ c. x+ | R% O6 T+ A .name = "user_led0",% Y* b: O5 @$ \" `% F" }; z
.default_trigger = "default-on",
3 k, C/ V( M) a* I3 h( v4 h0 g },
# ?" z, k) Y, Q8 B G0 P {; e1 |* B4 O& X4 Q
.active_low = 0,
: p8 e8 C0 \! N' e .gpio = DA850_USER_LED1,
0 |* W4 \+ X% R! D/ X7 K; D .name = "user_led1",7 Y/ O" I7 {( b% o L9 }
.default_trigger = "default-on",
~) f3 C8 w, T; i1 [/ l! }# w( b },
4 \+ V# } X7 W: z& j {
0 t" N$ H5 }: r .active_low = 0,. K2 @ K+ N4 K2 d2 f
.gpio = DA850_USER_LED2,
* s# c4 ~, y$ s/ z& ` q .name = "user_led2",* E) I6 J+ X2 G/ ]8 m
.default_trigger = "default-on",8 S8 s; z7 Z/ _: q
},
5 |# _/ v+ ]( g! G8 f {
( w; b( {# D& W; ]4 F .active_low = 0,' D0 y4 O0 I) z+ h- B
.gpio = DA850_USER_LED3,
# D# w1 M( s( H- ?# e .name = "user_led3",
# H$ l/ {: C! F; t1 _( Q .default_trigger = "default-on",/ R s) _# ~0 I4 o( u, @/ F
},
2 g8 X" s [# y3 `};8 O/ _/ x1 A1 S# D5 n2 d
& o% E0 p( e* ]* `. G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 H2 t& v3 q) Y6 F7 V" b: S. C. x5 i .leds = da850_evm_tl_leds,. [. R; C6 \& p7 f7 Y ~+ G# X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; s: D1 k Q% n$ v- }( l};8 q a. l8 R6 U$ R1 q% N; o$ L. S
0 O) `. }) G$ q$ p' D5 d9 v
static void led_dev_release(struct device *dev)3 W- c6 m+ D2 l+ U- P7 H
{+ h% m7 P7 P3 k
};
/ R- i5 e7 y2 V: @+ |9 X
! R% t+ v; X* r& `9 w& L) X" Kstatic struct platform_device da850_evm_tl_leds_device = {
' |) S( d9 k. o5 O .name = "leds-gpio",
. z% u' Q6 |7 i$ c, t/ H4 k( i I* k .id = 1,
# ~. L& `5 a; C( u5 m .dev = {( l; v) R' P% }) |; K% @; A& z
.platform_data = &da850_evm_tl_leds_pdata,/ @: b# V U) p
.release = led_dev_release,
' R4 e# |, d9 S+ t4 [ }4 N4 L1 }5 @+ K( f v
};
! h( N/ i4 [0 }& N( u P& ?; W$ J' r/ j3 F
static int __init led_platform_init(void)9 }. A4 m7 z3 ^7 Q4 h7 \
{( Z) U0 `4 `7 w/ ^
int ret;
9 M: P' e t' l5 E5 j& v#if 0; v& w/ e2 m V- i7 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 l- m, [6 ?7 I2 ^) L* h" ^
if (ret)
6 h$ w V3 o4 J2 Z \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 [4 S' J0 d( m* w0 r" s "%d\n", ret);$ K/ D& g" B+ p% I. m1 k, M( P' t
#endif
4 B' `7 I/ w' v- f ret = platform_device_register(&da850_evm_tl_leds_device);
' c0 O* O" }: c5 a& s( E- j if (ret)8 ^0 @4 f' M1 `. T8 T
pr_warning("Could not register som GPIO expander LEDS");
& O, w# n. F5 P/ c else
$ Y/ X4 ^1 U. z0 {9 p) }7 S; D+ k( D printk(KERN_INFO "LED register sucessful!\n");
& b& Y; d4 B0 ?7 }$ }9 f+ V v5 i& g0 e* v9 L
return ret;
" j5 k" K5 S" ?; a5 Y; R}
1 c0 u7 r$ X M' M" @- p
; F5 w7 f, b; Z/ l8 h' cstatic void __exit led_platform_exit(void)
5 h4 ?# E& F4 I+ U# x{
- M3 B6 \8 s& ?7 x3 j platform_device_unregister(&da850_evm_tl_leds_device);
+ w& a! c! y! U; L0 w2 a$ ~8 K9 B2 j3 y' t- g
printk(KERN_INFO "LED unregister!\n");
4 _. g e3 N5 h' \4 ^}
* [2 N( }. V- T$ X0 N; ~+ p& p5 G% z* d0 F
module_init(led_platform_init);$ ^9 G. T7 D, t
module_exit(led_platform_exit);1 K" O* T& q l
; c" R7 S# v# G9 G/ P! F/ `
MODULE_DESCRIPTION("Led platform driver");1 |. P* Y$ j1 ?1 D$ j
MODULE_AUTHOR("Tronlong");
8 s2 B5 f- e) J8 p( z& QMODULE_LICENSE("GPL");
' |5 |" J3 Z* W# E+ k4 U% E2 k2 R7 U
' {3 u7 S) V" h. c |
|