|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" c1 k8 k$ e0 `2 w# ]% K! j
#include <linux/init.h>
. |9 m& T7 I% ~ o: K7 O5 U; S1 s#include <linux/module.h>
) ^0 d+ H2 A/ m$ o) F#include <linux/kernel.h>
% L6 v( O, U# G, j- M. q' t5 r#include <linux/types.h>! c2 \( ^" w6 E3 T- @) Y
#include <linux/gpio.h>
$ X( b" p0 _6 D$ X- U. D. A9 Q8 K% c#include <linux/leds.h>
. k* b/ t1 [8 U" [, H h2 @' X#include <linux/platform_device.h>" |) A5 u" P5 q) j4 M, D
: L3 ]6 r7 r( N, H. l0 M#include <asm/mach-types.h>' {+ c3 x+ U7 L" H; F* K" B# y
#include <asm/mach/arch.h>
; C, |. M" W. Z- c; ]6 p! W#include <mach/da8xx.h>+ m0 r; C' T; t- J, S, B
#include <mach/mux.h>
* S+ b6 m( Q; o* J; f$ P. y: O7 w; M" I7 K9 a/ n, H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! r* X2 \- z4 z! ?- {1 O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 O- ?9 ^9 B7 |0 l7 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ C ]( l& a1 Z8 h( @9 H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 G5 G) V! X6 w/ ~9 m9 Y
# M4 J) c$ ?/ a+ D+ L( K+ G
/* assign the tl som board LED-GPIOs*/' i* a( J9 ]$ F: M' y
static const short da850_evm_tl_user_led_pins[] = {
s* k- l( d8 P, Q( e2 X /* These pins are definition at <mach/mux.h> file */- n3 C! R! T3 N# X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ Z* K9 C6 a. B& S/ D1 L
-1, Y; l9 H& t1 K! o6 C
};- C3 D: L% Q4 z4 ~( p
1 q' y9 ^) v) Q2 r, Q1 @; Fstatic struct gpio_led da850_evm_tl_leds[] = {& L3 }6 g' b P/ a. j, W
{5 A% U% e5 }4 \2 I8 b5 S3 Y
.active_low = 0,) e/ ^% v K3 z. r! T1 n# a! j4 I
.gpio = DA850_USER_LED0,0 | U% I5 S* _: h* L+ F5 k
.name = "user_led0", Z0 X g! O/ R
.default_trigger = "default-on",# ^# s5 N6 h0 {" G- K) I
},
- D3 W3 Q; s7 i+ K. m$ _* c {
, ^' |* F5 Y/ r: K( C .active_low = 0,
( ], O/ C' I& m* ?& L* v) z .gpio = DA850_USER_LED1,
* {2 ? \* Z9 p* P% I( t9 X; V .name = "user_led1",! j* s/ V6 H& B2 a% s) ?
.default_trigger = "default-on",
+ y& h6 D; T5 f) W B },1 H, A( \& Y; g& k+ l2 }, m& N
{+ l' A' O( W& p; Y, s9 N
.active_low = 0," [' u3 e5 p: a6 [5 f) E, \$ o3 K* I' e* Z
.gpio = DA850_USER_LED2,
: i/ j- G/ U& I. k+ [8 u) x/ ` .name = "user_led2",
( @3 B! r7 ^+ T+ m' y2 H+ W .default_trigger = "default-on",
O8 Z: g' ]) {6 s4 ~" J: } },
# W0 N0 |( _# P- o6 w {& b r$ N: @$ U8 w p: b
.active_low = 0,: b+ Z% f6 k8 r8 R$ E
.gpio = DA850_USER_LED3,
% O' Q. x0 z$ O1 `6 z .name = "user_led3",9 a3 G; A" G& O; t
.default_trigger = "default-on",
6 t+ \0 E. Y" s },
0 {. Q \4 v4 C8 j};
& K! L! x b+ v; d2 C( s
2 u3 G$ s6 `& |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 O# | p6 T* L .leds = da850_evm_tl_leds,& h y3 l7 \* c# w- y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( e5 l; X% `+ Y+ M! B7 ^};; z* u! e5 d2 c3 V( O
; k9 p8 u1 U1 xstatic void led_dev_release(struct device *dev)
/ F% N$ y/ H. Y{, N$ \! e# |0 p9 y* ]& _: Q
};, a. F0 u, r- Z9 a
/ L4 d3 W' u% G+ X, estatic struct platform_device da850_evm_tl_leds_device = {
2 _- c4 H1 J! A$ ~3 K .name = "leds-gpio",
4 K0 W: T5 P1 I# S( [ .id = 1,/ d6 M5 a0 [0 h" q9 b4 ^
.dev = {* |! ] Y) l8 t- Y9 t
.platform_data = &da850_evm_tl_leds_pdata,
8 }! }6 u$ Z% t- Y7 f5 W8 z .release = led_dev_release,' r0 k) Y6 @: n0 K
}* V1 Q2 R' i! u r
};
' K8 a4 o9 \- O1 k( ?; U
3 T# m3 C8 G0 w8 q* E* qstatic int __init led_platform_init(void)1 v, S- t G. S( Z6 V" {
{
4 t. n+ d. V, B3 S- n: y int ret;
' ^' z6 @8 |1 }" q4 q#if 00 }4 U& T% E- C y) K, g* w2 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 p* c" A! w% L( f+ S if (ret)
! }. [, j2 Q& [0 i; u! [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) r3 s( h1 x o "%d\n", ret);
' i, x1 d0 a6 k; ?+ {$ g1 d, ?2 j) |#endif
7 z6 h3 ]5 w$ ^4 P ret = platform_device_register(&da850_evm_tl_leds_device);
9 y" C2 V- O+ ^$ L9 x* L' Y, _2 u if (ret)
0 X# `+ ~; G0 B T/ w pr_warning("Could not register som GPIO expander LEDS");
$ h" L: ^; T7 f4 ]( T9 [) m else
& Y3 p: m$ m& C printk(KERN_INFO "LED register sucessful!\n"); A% @9 {/ Q. [) ]$ z9 G
9 e) C. [- Y# }) m! [$ q5 y return ret; [6 g& F9 }) S
}+ k" f% L+ J% h- C; Z
4 B5 f: k' q1 F3 E% L d' nstatic void __exit led_platform_exit(void)/ h2 X3 @$ e w. C, d3 W+ ^
{
j0 d: |& |+ n) a3 q; l) `. } platform_device_unregister(&da850_evm_tl_leds_device);, S' }- i8 Y+ A1 C& b( ?2 n
v2 c# R9 A# R/ G+ i4 ~$ q, o6 e
printk(KERN_INFO "LED unregister!\n");) h! ~# A. m' T2 ?7 U+ v
}, g$ j9 c* J: R& F
% [; g9 y; i: u4 L" M8 H$ B( v
module_init(led_platform_init);
0 D5 D$ w% v8 E, H. t3 q! Zmodule_exit(led_platform_exit);
) p8 a$ O ~' C/ z1 Z5 h- A, i7 F! b7 z- i k4 s+ \
MODULE_DESCRIPTION("Led platform driver");
0 ]9 x: `+ u% o9 m; L& sMODULE_AUTHOR("Tronlong");9 ^6 c, x( i5 t$ O# k+ ~
MODULE_LICENSE("GPL");( M3 N( O: I8 S- @+ w
9 b; H1 _# [, K% n4 x4 S
|
|