|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 Z1 q- U! o( p3 r#include <linux/init.h># |! ~/ l( |# U
#include <linux/module.h>5 y& Z# }, n) Z+ D
#include <linux/kernel.h>; t5 @2 X; _2 m7 W2 |
#include <linux/types.h>8 K) N" q( R* L
#include <linux/gpio.h>
1 o. g; f; E, B#include <linux/leds.h>
W$ o, D' g$ X$ J* p4 X#include <linux/platform_device.h>
/ r" g9 X! t. W
& Z V" r. h4 N' q+ \: n#include <asm/mach-types.h>
9 @- f/ T" ?3 l! J1 W+ k9 n#include <asm/mach/arch.h>
) G. i; J- r/ q6 k; ?+ S#include <mach/da8xx.h>9 G" [. X; r0 B% s' {" M$ l3 Y4 q
#include <mach/mux.h>; G) T0 j' Y1 g8 Y" ?, x) x% t# s0 D! |
' j7 F2 P# [( a1 w) R, D2 K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( X6 B: x# b5 T* o9 ^: ^0 B9 v/ n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* Q) J9 n! T, E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" P8 C) T% a& N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: V4 H# d" @. g6 `# F, i1 [% Z; h; O A$ f
/* assign the tl som board LED-GPIOs*/
) c% N& b: N- astatic const short da850_evm_tl_user_led_pins[] = {/ I) z: F* H& e. ]
/* These pins are definition at <mach/mux.h> file */4 m8 W9 v2 Q& Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 @0 X2 y& ?1 q* T- c
-1
- ^; @$ I8 b% h6 q# V};
5 i; J- @% H5 O8 e/ W2 p5 n( ?5 b. K1 c$ S
static struct gpio_led da850_evm_tl_leds[] = {
0 \* T0 R! D1 J0 ?! I( u! x {
0 G; i# p( r3 O+ L- S* k .active_low = 0,
# C2 ^+ Z; V* V. Z9 J7 g .gpio = DA850_USER_LED0,1 M$ r* C) X* S- ~. x. e7 {
.name = "user_led0",
1 T$ T$ F b4 X& N .default_trigger = "default-on",: ^! c5 c/ ~/ V7 \
},: j7 E, J5 P5 R$ U; V% Z9 g
{
# [1 l/ J4 Z: g4 J .active_low = 0,$ A9 K, V3 T3 C& ~0 r+ H
.gpio = DA850_USER_LED1,
: M8 e% j" }0 F' C .name = "user_led1",
" [- O5 _( o% ^! I' x .default_trigger = "default-on",
8 \9 b8 |9 k: i8 I },* T6 |* H% j2 t$ t: j
{! H1 Y4 h p" M! G# l1 {7 d
.active_low = 0,& V; B8 F$ m1 A
.gpio = DA850_USER_LED2,
4 F9 r, @8 ~ L+ { .name = "user_led2",; I# S' U: e4 h+ B$ n' N
.default_trigger = "default-on",
& l/ O& D& f8 C" M/ q: F },
& ?0 A7 T2 g- _& z3 L/ ] {" C$ F3 l8 t: o2 t
.active_low = 0,
5 U2 b* o/ n9 d+ S- w2 J .gpio = DA850_USER_LED3,5 `* m, Z7 Y: s1 R
.name = "user_led3",
* Q2 o3 @$ b; b; w .default_trigger = "default-on",
" f+ p0 T) ]& D V2 o },
+ J- P6 Z5 |+ G' ?5 r7 T9 O: ~};: o- S% }: D$ B* G
4 ?3 H0 I6 D. n& S' r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) c- x/ U' L1 \$ m: I& G/ ] .leds = da850_evm_tl_leds,0 u2 w$ \4 B- W1 b3 ]5 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( m; ]( F4 X- O9 K- {) t};& w# w8 ]6 I- s: Z+ H- y7 Q2 O
" M, W5 ~( l o$ ?
static void led_dev_release(struct device *dev)
' ]% e$ P( T$ e, V9 i; B{9 y/ s9 |0 {+ w1 m
};
; Q/ j! M1 c: E4 a _ P
4 o/ N0 V. x2 ^" }- Qstatic struct platform_device da850_evm_tl_leds_device = {2 s' f7 X Z2 M9 c0 V8 e
.name = "leds-gpio",
5 _$ E( f4 o( i8 v- h/ b .id = 1,% m3 T W" W; o. O6 [" ]
.dev = {! }/ x; |( [* h
.platform_data = &da850_evm_tl_leds_pdata,8 ~" w. p0 v, Y
.release = led_dev_release,
% G! t8 k5 K) U& P- Y }
! B3 R- ]1 e6 L7 w# Z};
- [) T- `8 j1 u% Q( M
- T+ J+ H! F& a1 Wstatic int __init led_platform_init(void)& l% G0 G8 w" y% H
{
7 k) s5 a: F: k1 z$ a2 j0 |6 t: N. ] int ret;- L8 q6 s4 S9 M
#if 0
" t7 s$ Z' A' B, i" Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- X! F' O$ c3 l) J9 m
if (ret)
' Y9 e' Q6 \, {0 d! l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ }9 l4 ^- ^5 Z
"%d\n", ret);: P) b: H) I4 S8 Q
#endif
9 n0 x7 N$ G4 v# t ret = platform_device_register(&da850_evm_tl_leds_device);+ s- j9 Q) c" A% A3 T# I
if (ret). _- p( C. V9 C
pr_warning("Could not register som GPIO expander LEDS");
9 a( X3 p+ o T$ F$ A, `. g# @ else9 S! g6 v! a9 ^1 U& l- ~9 X
printk(KERN_INFO "LED register sucessful!\n");7 Z- L% f {1 p; ?- n
0 |/ b7 w' }% W" }% b return ret;5 z3 ~2 C I- [' f* W6 A- D
}' E, v% O' I x T
6 [( g) p; M7 `& O7 s, T0 Astatic void __exit led_platform_exit(void)
, Q Y6 v; c. j0 x u4 H{
?: {1 p$ P1 B7 A platform_device_unregister(&da850_evm_tl_leds_device);
+ o, D2 K1 y) j' T7 z
* g; L u$ }4 u; v printk(KERN_INFO "LED unregister!\n");, p* S! w( {# Y8 r
} R4 C1 W* R6 y
5 E: u( R8 b" [: Z, Z6 I7 Rmodule_init(led_platform_init);
8 |5 d4 |5 s! k$ F! {module_exit(led_platform_exit);# b8 p8 f1 W$ Z$ P( p
: a7 V A% s h" f5 W: @4 {MODULE_DESCRIPTION("Led platform driver");6 Q& o$ }5 u0 [
MODULE_AUTHOR("Tronlong");' B' g" F1 g0 d
MODULE_LICENSE("GPL");+ F$ g( Y- @; a( a0 t9 H6 G" l1 f
" @. q/ f1 c8 F
|
|