|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! }6 N+ U6 J- v7 g' b$ A% Q
#include <linux/init.h>
7 Q7 Y! B( D9 O* p: @- H#include <linux/module.h>
7 K2 D7 c& C/ h; b#include <linux/kernel.h># a' }" v# ^8 v6 r0 ]7 W3 Y
#include <linux/types.h>1 A/ | D4 T# k( \5 p
#include <linux/gpio.h>
5 M9 m) y" z8 g' A( L/ @9 D# [#include <linux/leds.h>
/ { O i5 X1 `/ e' X#include <linux/platform_device.h>
/ m9 @0 v- g; ?- [" q9 @3 F- Q% {+ N8 p* A& r6 `) E
#include <asm/mach-types.h>
2 B* z' a X* k, E W7 \* h#include <asm/mach/arch.h>: d5 L9 x z6 F' n! S
#include <mach/da8xx.h>8 d5 X1 m5 M# M: Z& l) O
#include <mach/mux.h>
; Y8 w% `. b0 k( {0 u* e6 A
5 R* I" {, H5 z) H4 w: C- X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 ?4 [3 C3 m2 M8 @5 p" f& m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 c1 q% R2 S$ N8 ?8 |# i- c) l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ [0 Y q1 p) L* Y3 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 Q }0 H$ o, @# v0 S1 r6 {. b/ U8 v- q
/* assign the tl som board LED-GPIOs*/
% l9 J! y4 a- h8 N5 ^* ]static const short da850_evm_tl_user_led_pins[] = {
% I/ g ^! A# e7 S /* These pins are definition at <mach/mux.h> file */( G7 K& u8 N" d w1 o) a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ j. |$ c# O) D' v6 _2 u& A r g
-1
& _+ ]! Y' r- ^8 Q0 y% z};9 f) M0 p3 A/ n1 y6 J# ]
/ z( C9 m. ~, z2 R) @
static struct gpio_led da850_evm_tl_leds[] = {0 ^6 h4 a8 ~( N$ ?
{
5 `* H- a( X' R8 M .active_low = 0,* O; C0 m9 [1 }3 [1 P& c' V( A
.gpio = DA850_USER_LED0,
, e. X f2 u1 e .name = "user_led0",- W& Z( i+ t6 [) o' E
.default_trigger = "default-on",. K% v, Z' u8 u6 @; O4 s
},
7 Z0 T4 D, S, l3 D, R% j9 s) j( ]# N {% T1 K4 v, V9 b( j( r
.active_low = 0,
2 b5 I9 _6 W# U .gpio = DA850_USER_LED1,
& w b. _5 R' \ .name = "user_led1",7 h0 G8 l; G ]6 k' w' N
.default_trigger = "default-on",
) z3 l6 j- Z) ^0 i$ y. x* p },- ~8 H. c8 y2 x& J* d
{: M% Z. t. i6 m0 c# {. T
.active_low = 0,$ k" w2 c: o3 g$ |5 E
.gpio = DA850_USER_LED2,. S2 A& R$ ?) Q! N; O0 d9 V0 p+ G
.name = "user_led2",: d. o2 Q; L8 r* d& N
.default_trigger = "default-on",
3 U9 D8 M2 z) G3 b& d" N; a2 k },2 h+ F( {* K, E+ k( j
{
& k3 N: J) X8 ~ .active_low = 0,
8 F5 \, D1 R8 Z. p .gpio = DA850_USER_LED3,
% y' F; @$ _) S .name = "user_led3",1 u( t3 M9 y8 Z& j# W0 l9 O
.default_trigger = "default-on",; U3 s/ m3 P: q d# e! \
},( o+ B( q' V4 e n
};
6 b8 o# O6 i0 ^# |+ _/ [3 Y8 u* U
; g$ [: d1 M2 [- Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! L( f8 A6 v+ T0 }; ~& c .leds = da850_evm_tl_leds,
H) N! a! {+ K% M# A/ Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds), f5 D# E& l6 W
};/ z2 X) j: h# i5 M6 n4 M1 {6 U
3 Q, I: z g1 q) \2 b" e! k
static void led_dev_release(struct device *dev)
1 E, q, z- K0 M& I Z: |{( R) \: F7 ?- A* B: I1 }( l
};
, Y8 p, H/ E- ]6 K6 B" p) q+ U( c1 {. g! @
static struct platform_device da850_evm_tl_leds_device = {
) a) \# W+ u. Q" [' `! f/ B .name = "leds-gpio",
2 h' a1 |$ @; n# n$ A3 u .id = 1," y# w' R5 }* F5 D! b: T
.dev = {6 c5 Q9 e, l9 |# Y( q
.platform_data = &da850_evm_tl_leds_pdata,
/ ?* _9 J; O+ x1 b j .release = led_dev_release,
" G5 h% i( t7 ]: a; Z6 _- A( Q6 C }
8 F1 O! K4 ]2 F9 u/ u};4 \) p) R0 O; e
0 ~( U4 ^* P9 Z
static int __init led_platform_init(void)" v3 t0 E l5 J, a, P& D6 ?6 _
{
- K: w$ u0 v) [ int ret;
: x- n) i! ]$ ?4 G( _#if 08 s, T {+ l* O# S6 u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# x* k% A7 Q7 Y4 z; [0 T
if (ret)
( x/ B/ h8 o( F( T+ b a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 f0 e$ j( p0 {% N" T- b* i, e M "%d\n", ret);
1 [' X. Q& G( \( o2 { w! D" b#endif
9 w$ t4 T) ^ [0 k4 @ ret = platform_device_register(&da850_evm_tl_leds_device);
- ?+ U, j, G- @' Q I if (ret)9 @5 L3 W" i+ V- d! K
pr_warning("Could not register som GPIO expander LEDS");. T3 E: a( x r9 G9 G% n& G
else
6 @* Z- H' o7 w/ c% ?5 }; m4 V printk(KERN_INFO "LED register sucessful!\n");5 X% i' y- ]5 L; w `) y) R( _
' ~/ V0 W8 I" B7 n return ret;
% g* H" E7 o% c! N$ g6 @$ L* c0 c}
& Q3 c! g* h) J$ N$ `# e+ N
, o4 t+ ~' u$ @3 N0 Jstatic void __exit led_platform_exit(void)' ]. h7 [ ]. K4 l# G5 F1 I* U
{
6 o6 \) T5 |- w platform_device_unregister(&da850_evm_tl_leds_device);
$ D8 r% h6 Z* s* c1 [
9 y; z0 c+ C8 o' N: A! O9 f% Y0 d printk(KERN_INFO "LED unregister!\n");
* z/ M- h0 v5 K0 e% }* _5 h G}
$ m3 ~* h: L7 _! M0 V, o! r2 ~, H- C O; r4 ]
module_init(led_platform_init);5 ~" J P( v. [$ D M
module_exit(led_platform_exit);6 m( a+ o' j5 @( i/ |
' [4 H8 n+ Q7 q8 j7 d
MODULE_DESCRIPTION("Led platform driver");
( j8 G/ i' N) t+ H: R0 yMODULE_AUTHOR("Tronlong");- q( K4 q8 \& q, Z/ y
MODULE_LICENSE("GPL");
/ Y: p2 ~5 Z! w3 y! j: w
7 n9 L7 A" U! i |
|