|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 d7 W8 y& g3 v# x, T$ S& y8 l
#include <linux/init.h>
" L! Q8 c) C3 k#include <linux/module.h>
+ u E c& n1 |- N1 b#include <linux/kernel.h>
! Q; d" _, Z9 ~#include <linux/types.h>
! [* K& V v3 t9 {- r#include <linux/gpio.h>
6 m* q5 m' |% z% N# U! I; K5 H5 c#include <linux/leds.h>1 k1 \. [/ G' E, e4 |% g5 o3 \* k
#include <linux/platform_device.h>
9 @/ \5 {6 B1 h1 S2 D5 P, i
4 X" Z' e4 A6 d7 E+ F#include <asm/mach-types.h>
$ a! |' ?4 K2 F9 }) Q* f#include <asm/mach/arch.h>: S6 L \& N: Z6 D" E
#include <mach/da8xx.h>+ d O% G: |; a/ l/ ~. {
#include <mach/mux.h>
8 B7 S7 f& E; i- C5 ~( d( W
5 e4 Z" \3 t, Q) q5 E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) Q$ x! c; t0 S! T( h8 E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; X; u9 w7 K! I+ K. |& [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 \, y* T' M$ V+ _: }) {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& j! e# _2 T( x2 y4 p% |6 ?
4 O4 T# T$ f" D3 O% A0 j( F! }6 @/* assign the tl som board LED-GPIOs*/! W* m E# G+ L& c% i9 H2 K
static const short da850_evm_tl_user_led_pins[] = {! C: o# H3 _# z4 l! i7 r& O7 g, P
/* These pins are definition at <mach/mux.h> file */
: w* f1 [3 S0 w! C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: d" x9 m$ t0 N/ T% }+ Y; Q -1
2 Q+ G) z# Y/ j+ M& n) @};5 x1 c% m' a2 _; i( W( S7 c5 x- z) [
5 r0 t: c; W* ^1 @static struct gpio_led da850_evm_tl_leds[] = {
* y% @6 O3 O1 b3 c/ L- k {
% N$ P% r, t7 I .active_low = 0,% w9 ~. ~$ `+ F* p1 P" M
.gpio = DA850_USER_LED0,/ ?/ l8 F# _6 F, P$ m
.name = "user_led0",9 b2 i0 s C/ M
.default_trigger = "default-on",
z3 A4 ~4 ?6 Y5 k: E0 r },
6 g3 f0 m7 j/ H/ Y {
; f f! ]3 d" d5 m .active_low = 0,- X" P0 d6 T2 |, F4 U9 G
.gpio = DA850_USER_LED1,
1 T0 r& l& C* L5 s: s, \ .name = "user_led1",0 y; p( _" r5 K1 C$ Q' I1 `+ g
.default_trigger = "default-on",
" L5 d* _6 G0 o r# t. r- J" x4 i },2 W2 w3 l" }) v3 H) d7 D0 y8 L
{
5 N. m1 n9 o" U& U i .active_low = 0, Z8 x# [! d: H i) E
.gpio = DA850_USER_LED2,) U# @. D* Y, O/ U" q" b
.name = "user_led2",( H2 m9 N! Z) @
.default_trigger = "default-on",
) F$ y3 I6 m. M$ o% o# M; o },, i( P( v/ l# A7 O& R
{
8 O8 K1 P3 o0 s8 X1 W .active_low = 0,6 a7 j' V* Y8 o* s
.gpio = DA850_USER_LED3,
% L! M) I a5 u$ p .name = "user_led3",
* v3 }7 L+ p4 e+ w' D .default_trigger = "default-on",6 f) K$ `6 ]! c1 X5 I5 O
},
% {! a( D7 M8 m+ S};8 g9 K- }# S5 Y/ o+ {/ i
+ _# @2 I; D. S' ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& V+ W$ l5 u, c1 Z4 k .leds = da850_evm_tl_leds,( E# N3 g/ p% w4 w( s$ J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) j b. T6 @" T. c! Y3 t
};. U" v" i8 {# A
. n2 b& L* r g% o' X% s
static void led_dev_release(struct device *dev)
; O5 M! d/ D' c' v3 j- r M{
( K. \# @2 }8 C1 K};
+ D0 h6 g, m/ o
& ~; y1 ^3 l9 d* ]' @static struct platform_device da850_evm_tl_leds_device = {
7 @" R8 ]& m% k& j5 T .name = "leds-gpio",# a- O$ U, Y0 Q& G" K2 L
.id = 1,
' m+ [# a7 u' S7 ^4 f1 n3 A .dev = {' j( d1 F8 Q/ l1 a+ g/ X1 |
.platform_data = &da850_evm_tl_leds_pdata,0 z! ~$ x( c. S8 m5 h$ e
.release = led_dev_release,
* r: p3 U G; a, B' d* i7 F }2 G$ F5 T$ i" K$ q9 ~% e' b3 E
};: }9 p3 y1 F. O5 T
7 ?1 |8 L: g* G V6 }5 m. f6 }
static int __init led_platform_init(void)
0 @7 [5 X( ^0 S; O7 {{6 s! @6 |+ W6 K# w
int ret;
) v! s, j( j0 ]$ I% \#if 0
1 J( b6 b1 X3 u; P2 U: t: N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 a \3 o. F, v; k/ m9 U5 X
if (ret)& T! Y; v2 m v( p6 N4 h- v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 C1 H3 j) A) L8 L0 A6 m
"%d\n", ret);# m$ {& e& _/ I% a7 P
#endif6 M. ^( b2 P5 `+ m8 Y
ret = platform_device_register(&da850_evm_tl_leds_device);
( ~5 G* b& D; U if (ret)
- k+ `0 F. S' q* ?; g+ L pr_warning("Could not register som GPIO expander LEDS");
$ [/ }7 q9 B6 K+ Y else
! Q, A. s/ @1 z: b, k- U# Z! t. s$ @ printk(KERN_INFO "LED register sucessful!\n");
$ }) O9 g& H. m% m6 s& j1 E2 t3 n0 h! L7 |- i: h5 F
return ret;! T! w: C& B6 X1 b5 N1 J" Q7 b
}
, Q7 o; n% p5 G& [0 N3 I7 J" f1 V ]
static void __exit led_platform_exit(void)
5 U3 f+ L% w/ Z. ~) P; \2 V/ c{; @8 X2 e, {( r" K
platform_device_unregister(&da850_evm_tl_leds_device);9 d, e+ w9 Q+ K3 V* B, r
& p9 A) k4 a1 P1 g
printk(KERN_INFO "LED unregister!\n");
7 p e3 |& C& I' Y}1 t- C. I& o$ o: W/ u, ?
1 y# P3 I) \# h _4 f0 O U3 gmodule_init(led_platform_init);/ a/ Z& w6 a% Z; w, e# d# c
module_exit(led_platform_exit);5 v. a* J& j) j7 H% U! J) N
% ^1 h0 J: P( v, qMODULE_DESCRIPTION("Led platform driver");
" s) R1 o" j% A& i9 NMODULE_AUTHOR("Tronlong");( Y& p/ v) r$ a% P$ y) [1 ^6 q: T
MODULE_LICENSE("GPL");
' ^* [( @+ }/ A p5 [
M* k& u6 {# g7 A3 M( m |
|