|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. j- k) b( T0 j" m/ k
#include <linux/init.h>" o+ S1 a* {9 [# o
#include <linux/module.h>
! I, r& V6 i5 W5 F#include <linux/kernel.h>
2 Y; K" K4 e( t W#include <linux/types.h>
|+ B4 @* p, G' c: d, {1 [#include <linux/gpio.h>' ^5 |9 [+ j) ^# i- W% y$ H# ]7 P5 _
#include <linux/leds.h>" c- j& N3 Y% d
#include <linux/platform_device.h>
1 h3 |2 ^) d6 s1 ]' n$ ]5 I
' G* D: L$ D- n0 W. c#include <asm/mach-types.h>
- R& ?- ]* l+ r% ?( ^2 M8 l" u#include <asm/mach/arch.h>
) N9 n/ b' m; M: I9 G#include <mach/da8xx.h>
+ ?8 W* C" q+ m! R#include <mach/mux.h>0 y" o, `% E5 P& p4 V
" ^+ m1 G7 H& M+ b/ V% e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 E1 p g5 V% c4 U" t _; F0 n$ U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" g; W5 y/ I6 x. O6 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ z. c7 r$ c, Y9 W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ E; L l: Q2 u" v2 @
- `$ U y& M* L W/* assign the tl som board LED-GPIOs*/! f8 A- a- N" d
static const short da850_evm_tl_user_led_pins[] = {3 Z0 G3 B* w9 p; ^% R, [2 o3 {
/* These pins are definition at <mach/mux.h> file */+ ?5 @4 t/ R4 ^$ b- r0 W' `9 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
r0 d/ t/ y4 N3 o -1
9 X# X2 g5 s/ V9 Q" a/ t; w};
" w" V# O3 V! i6 f% T; k) {
* n- O% S7 Q( G: j# z1 xstatic struct gpio_led da850_evm_tl_leds[] = {
C( B2 g! `" H) b5 j3 j {% w& g5 j8 M7 J( I! D4 }+ j
.active_low = 0,
L) B! i+ @8 H7 f/ g* _/ h: c1 n% I .gpio = DA850_USER_LED0,. i1 P, z& _: @4 c
.name = "user_led0",
2 p6 `& {* A" y5 B* Z1 G .default_trigger = "default-on",! f( ?" q5 [0 W
},
y) W `% ~2 b9 `4 {; N1 L {
e l2 d, F, W3 t5 t .active_low = 0,
0 N D8 M. U9 r* q. g2 S! S .gpio = DA850_USER_LED1,
4 r- x) j$ T2 \0 i .name = "user_led1",% e2 t( l: D/ c1 b
.default_trigger = "default-on",$ F9 ]$ j+ b. U1 `' \
},
$ M' m, n0 h6 {) K {6 u$ h- {/ }, O( w- N5 G: I
.active_low = 0,
5 o9 m) y7 Q8 x. U% f* ~ .gpio = DA850_USER_LED2,4 n! T/ ?' ?1 X/ l/ e: [$ n7 y( v
.name = "user_led2",5 V( E4 i7 E2 S% V
.default_trigger = "default-on",& l$ R' H7 L, o6 w0 ~
},5 U0 A, d/ y( o6 ^* B; w
{
( _" j% y' H3 `+ ] .active_low = 0,
. L: u5 s1 y) D; ] .gpio = DA850_USER_LED3,6 P/ z' E0 l. ~- Z
.name = "user_led3",
o9 A4 j1 V w5 g7 m* d .default_trigger = "default-on",
8 u [% J6 q4 q },; d# p( m2 T% ~$ G. ~
};) `- U8 h& t$ O: W- @" M& K
2 \/ r7 Y8 Q4 m D( Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 j% O, p: F i, @
.leds = da850_evm_tl_leds,
: |0 P; V3 \3 i2 p# Z+ Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 ~; [6 c* O; }& J" p
};+ N2 [+ Z9 M; O4 S
& U6 X! f1 p/ p' ~static void led_dev_release(struct device *dev)' v3 B& ]0 J4 O+ r; `, h% [2 p# Y
{9 ~7 _3 w O8 d, j) X( u( J: b n
};- T) k2 |% M! t4 k/ J3 G4 ?& Y
" T6 L( p& W1 P9 }static struct platform_device da850_evm_tl_leds_device = {, Z8 h* u" z) g) Q& v/ V
.name = "leds-gpio",+ M2 {2 m+ ~+ [& `% P G
.id = 1,
7 ?1 M# a! M2 Z0 Q* K .dev = { C, }. u' Y$ y4 L8 C" k
.platform_data = &da850_evm_tl_leds_pdata,. E& d l' y4 N) S6 ?9 T* x
.release = led_dev_release,
r; Z3 u6 d- p }+ A! b5 t! M4 j1 z' Z% s
};
5 x0 T" f+ S- E: g# |- K
( X# @. [) Y4 [4 N' U6 c" K8 kstatic int __init led_platform_init(void)' ]! `3 l! [; d% b1 w
{, i4 W3 L& k1 M* h, d- u( Y, I9 _# \
int ret;/ r8 Q0 G, \9 E' I
#if 0' c: }( R! L8 i% a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: P F1 J% d9 ]. O# `, ]
if (ret)
; v4 _1 w7 W1 ~# ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" ^' `8 y6 v1 ?0 \& ?
"%d\n", ret);
9 k* U) C3 _% o" T" j#endif
- N6 Y) q) w: ~; V$ W2 Q ret = platform_device_register(&da850_evm_tl_leds_device);
- w* ]" V& T# n; g5 H. F, @; L4 U if (ret)' J2 W o- \7 x: B& E0 P
pr_warning("Could not register som GPIO expander LEDS");- a; u: I S7 S9 y" O, I# A
else m; D* p D+ {' M
printk(KERN_INFO "LED register sucessful!\n");
" D( n7 f" d( b8 y D8 z5 x
! {3 t' {5 {. N/ y% x4 T return ret;
$ ?: j/ @& }! _7 J M4 G}6 ~* ?4 }: r& _+ _7 s" I4 m, Z2 x8 N7 Q
- B5 n, j1 w: O ]static void __exit led_platform_exit(void)
. N- u0 l8 U7 r4 I{2 O5 y- U" A+ X# P. Q# [
platform_device_unregister(&da850_evm_tl_leds_device);
; e! u5 E! h" M4 u g2 n5 O- z% H
printk(KERN_INFO "LED unregister!\n");
- T. ~3 y* u0 e}% q7 A" m8 v9 `! b R) k& d
7 z& _' e6 p$ v3 T+ f( U3 _module_init(led_platform_init);. B5 f) \! p) s2 n; b L y
module_exit(led_platform_exit);' G+ A7 R8 J5 J4 t2 s4 i# y7 y
4 |4 {5 t4 c; L+ j0 Q* C* ]MODULE_DESCRIPTION("Led platform driver");
0 Y. t. k W- AMODULE_AUTHOR("Tronlong");8 |( q% F( A/ Z2 i
MODULE_LICENSE("GPL");
' B( [ D) N0 G+ J- D! w
) z6 ^: S9 u' i8 { |
|