|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ k: o& S* X# _& p3 D% O M! a
#include <linux/init.h>
+ `* C" N; I/ q0 L7 ~#include <linux/module.h> B% P4 }, `# z6 L; I* k% s4 I
#include <linux/kernel.h> a& c0 |6 e+ K( i3 M, n
#include <linux/types.h>& Q3 I' _/ [3 x
#include <linux/gpio.h>
- s1 y9 @ u& F m4 ?4 Z. ?3 ~#include <linux/leds.h>
( Q" V9 R5 _" j% L2 k; j$ f#include <linux/platform_device.h> I& s. O/ {7 Y1 J) _
7 _- s+ j4 q2 f8 [#include <asm/mach-types.h>
" s/ m$ G( ^+ Y$ y' _6 L4 G#include <asm/mach/arch.h>, i. v& @7 |/ H9 }7 W
#include <mach/da8xx.h>/ {) j2 X, x. \3 u7 C2 w
#include <mach/mux.h>
9 E u! D4 X7 y E7 H/ c
" F- b$ l0 z7 S" ~. C4 }# |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( F. B' q' i6 U0 I: r4 {* ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 @( Q/ l3 [4 }9 e6 S+ i' d, b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) m: j6 D* f8 g" m, \4 V+ z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' U, U5 a! [( C9 K/ w1 e; z. I
! c$ ^/ r& o; V! b# `/* assign the tl som board LED-GPIOs*/7 V5 y7 j& Y0 L3 w% Z; i; ?9 X( G
static const short da850_evm_tl_user_led_pins[] = {3 b0 q' ], p5 n1 ?$ d
/* These pins are definition at <mach/mux.h> file */- o" F' x: Y# j z! m1 {0 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: ?( v7 R9 @3 O -1
8 k: d% }, J" z k/ u. M};! _, Y9 M; a9 p# O
1 P$ \9 h8 `; A1 O% M& ?/ Pstatic struct gpio_led da850_evm_tl_leds[] = {7 F8 L6 _& g" J( @7 A
{
- g& \2 P; c% S$ h- ]. q .active_low = 0,0 @5 I( k' k/ t3 g& S
.gpio = DA850_USER_LED0,7 O5 `* W4 w+ P' u- N7 A3 Q; r: q
.name = "user_led0",
1 `6 R+ x ~* d .default_trigger = "default-on",
. q2 F& {8 r) |1 v4 m' L },
; ~; J% t; y* R {
9 s5 V& [+ H+ m6 N- U f .active_low = 0,) n4 V0 O9 {8 @6 y
.gpio = DA850_USER_LED1,
! J% ?$ e+ n% g3 T8 Q .name = "user_led1",' Y/ `5 R! N4 y( w: s/ u2 ?
.default_trigger = "default-on",
, r5 n( M' f7 E) C; A2 F },
' u* r; J5 Y: j% A3 z; h7 W {3 c* P& ^# M7 T
.active_low = 0,
" E! W+ g- T l/ H0 Z2 E7 Y .gpio = DA850_USER_LED2,% R6 V) Q6 g4 k. h6 j6 q- `! `
.name = "user_led2",
5 {7 t* @4 a% x# c& F: I1 Z- Z .default_trigger = "default-on", ^2 S. d+ u) B4 k+ d) M! ~
},% ^ }8 u. F1 S! e ^# [3 V# P$ l
{
2 H. \) Z$ m: P! G' N .active_low = 0,
4 {! ]+ ^$ ~9 L0 | .gpio = DA850_USER_LED3,
4 S; B/ B/ K9 U$ } .name = "user_led3",/ x* ?! L B' d$ g- R8 d' p. q" h
.default_trigger = "default-on",
4 ~4 A/ R8 \: |7 g1 L$ U/ E4 C },$ T1 m. T( D/ M
}; o% S6 \* c/ ~ m m
' J6 [' I( ?! R9 |$ l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# F$ m ]& @% N. [. ]
.leds = da850_evm_tl_leds,
c; M! E P2 V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! M3 \0 U6 A+ ]; ~* n- U% l# \* j
};( B! M& |& \% i. Q; C8 t4 G
4 Z; a* f% |+ c: O3 m7 L2 @# Vstatic void led_dev_release(struct device *dev)6 Q; d, ]3 Y8 Z/ d/ y) Y+ Z
{
$ E2 _3 z# X! Q};! f/ s3 j) r5 S1 ?7 d" b; J5 |
( V8 R' @/ t# ?static struct platform_device da850_evm_tl_leds_device = {
; q, t: R* h1 ` .name = "leds-gpio",
. F( Q4 L$ }" |+ j! u/ s .id = 1,0 {+ {7 w. r# v
.dev = {/ x c! p# L* k% M% d- d: k
.platform_data = &da850_evm_tl_leds_pdata,' ^7 t2 o& `! e3 b: C: c0 [
.release = led_dev_release, c; G3 @# T7 T/ V$ b! f, { D
}
0 C$ V" K+ M- a8 `5 W};/ ]9 z! @7 a+ x3 l1 |1 p9 A) l) T
9 Q5 b) T$ O2 _
static int __init led_platform_init(void)
5 | O# ?4 R9 a% S* q' P{
* q' L3 L2 h* G, a3 b { int ret;* M, d5 X7 {/ F9 t7 M( o9 f
#if 0
- M; f8 H* r) T) \8 t# A! X: s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. C T& a6 R) y& h
if (ret)
" l+ R: l6 Y9 ^/ M. P% V7 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ @/ W7 D" A/ S* }: ?: F3 J$ G# W "%d\n", ret);
8 F$ V" q( `8 @- k1 f#endif2 R' k, }, H& @5 y, D
ret = platform_device_register(&da850_evm_tl_leds_device);7 y0 `3 v9 p& V, D7 y
if (ret)
+ v/ k, `+ l7 w/ q7 V# U# b4 {6 u1 m7 } pr_warning("Could not register som GPIO expander LEDS");0 e5 C, n- y( E8 g8 {: n: s) L
else
0 Z6 V' H, L8 [% N: x% R printk(KERN_INFO "LED register sucessful!\n");8 L" z8 h7 t' ~! n, A. F: P
! i1 G0 Q `. n' l. k4 T9 Q+ M1 h return ret;
. j& }: Y7 |9 S}
0 Q* [ }- o8 f) u3 _- g+ r8 g; f
static void __exit led_platform_exit(void)! G1 w2 B+ U+ t9 G& P8 _
{6 S7 Z; n# G0 Q! D+ f0 b
platform_device_unregister(&da850_evm_tl_leds_device);
5 d2 Y' w8 H. i: q
u6 b" t z- K: q/ s8 C+ j printk(KERN_INFO "LED unregister!\n");
% K9 v5 {+ r* K8 f7 j* b8 p}
! Q% q5 V4 V. z# Q) Z1 q2 [5 | I/ V
1 O6 S a8 I, ?module_init(led_platform_init);4 s6 J) I& Z. h6 d" d& h
module_exit(led_platform_exit);: ^0 X7 x7 ?- T# w `
' b9 G: @' k9 O" E( pMODULE_DESCRIPTION("Led platform driver");2 l6 u; K! d4 ]' h: n( ?
MODULE_AUTHOR("Tronlong");
^/ N) r# r' }, B" Q# {MODULE_LICENSE("GPL");; Y- Z: q2 c( \0 o
% e7 c9 g. W7 n" p3 p |
|