|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: ?6 i2 m: k h3 Z( @, s5 T9 w! V+ e
#include <linux/init.h>0 x- \7 a! v! j" }8 X4 ^$ i8 ~" S6 H
#include <linux/module.h>3 H8 X0 q+ F3 `2 r8 i; J$ B7 j0 g6 \9 _
#include <linux/kernel.h>
( q0 |9 a# Z& L- ]8 b$ c! ]! h#include <linux/types.h>& c K1 l0 r& j, z
#include <linux/gpio.h>
8 I* Y, p5 v9 t" E r! y#include <linux/leds.h>0 H8 U8 T9 @6 q( g T+ `. U
#include <linux/platform_device.h>
$ c. O( V, T; q8 [( H9 \4 P" V+ `0 g4 U" E E- c- T6 E4 f5 b8 d
#include <asm/mach-types.h>
4 M/ [& `) U5 {#include <asm/mach/arch.h>
* _* M% w4 q' Z( J" O( Q#include <mach/da8xx.h>$ h1 { M# ~: R( N% g; E; \
#include <mach/mux.h>
, U5 R7 c2 d% J: F9 Z2 C4 l8 f* `4 B, c2 {: }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ _% P; h" }" K+ T; u: k" \2 C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" B: _$ q: [6 G1 Z. P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& A3 E6 Q8 @( l; r' D0 R) Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 T% k$ m( S8 B) q+ c
0 u' `0 |8 d# `/* assign the tl som board LED-GPIOs*/
+ `) t2 i* n+ R) b3 ], bstatic const short da850_evm_tl_user_led_pins[] = {
# x' V2 V. T3 g /* These pins are definition at <mach/mux.h> file */
# A9 b! {1 O0 ~) {) i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 q1 I1 H7 c2 O1 ]. ]) ? -1# j1 j& {; ?$ `# u% ^/ e
};( @( \4 o& d% _& s& M1 A7 d
- D: I2 z0 |" `8 q- ]/ }
static struct gpio_led da850_evm_tl_leds[] = {2 M7 h, c7 P4 [3 {
{3 O( Q/ c* K s, U
.active_low = 0,
0 t( W4 h) U) N) }* O .gpio = DA850_USER_LED0,
# m# H& L4 J2 p! @) t .name = "user_led0",' E6 h/ K1 F7 |; z
.default_trigger = "default-on",
* F2 s8 P0 Z" _6 D- b },
' Y+ W. ^% o" w' O* _1 r {
& @3 k/ @1 Y! W j .active_low = 0,
1 b3 Q2 f" R& \+ c4 B .gpio = DA850_USER_LED1,
2 s8 b/ ~5 a6 m: c5 n .name = "user_led1",
' Q; N- ?7 V7 j% M3 i. C .default_trigger = "default-on",
! V, x# f. d# Q7 J. n" K },
/ p" x9 t1 v* c% z6 Y" B {2 P$ z! x3 J& j6 f% N
.active_low = 0,
( Z2 M" a7 t0 H) U0 O! D, g; n9 { .gpio = DA850_USER_LED2,
0 Y7 r+ A: E$ Y! \* D .name = "user_led2",
$ [! b+ G% u( ^/ {5 @$ l* u .default_trigger = "default-on",
( ~+ T* {, k; N, k$ a& j& z: b },
) O- v2 E# c8 \0 M$ `/ \+ |2 V! { {( ?0 @* z9 F( U8 J
.active_low = 0,
+ f- O+ Z, w& u o# a .gpio = DA850_USER_LED3,
2 Z6 ^8 o2 i- L# K W .name = "user_led3",' n' d$ C: C' B& x) t# v
.default_trigger = "default-on",
% _$ S2 C$ p9 A, C },: \; I. s% q# L0 n" k
};
+ j, O/ [0 @) V2 s. j. n4 H) f O6 O4 b, O- L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' p3 q7 }* L1 K: r) v1 H
.leds = da850_evm_tl_leds,
" t5 r* y4 C r* D- b) c1 Q+ c/ @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" I* j0 ?7 a: G7 y% x5 l$ W l};
; r; l$ i6 z1 @ J8 N8 X
3 s6 K) {2 t: Estatic void led_dev_release(struct device *dev)$ z& L' A8 Q; [! o' m
{! A2 @; U, v8 X/ b
};; Q1 q A( c' H1 ?! w& `5 J
, b6 Z' b6 v1 G: t, Dstatic struct platform_device da850_evm_tl_leds_device = {
) D1 K3 q- }: N; X/ b, w, H .name = "leds-gpio",
7 r( u& \# a6 g# t. F6 r; s .id = 1,
4 b2 G% d8 _. E- x9 @2 k .dev = {
% F- e6 S8 J0 U) y* }* \ .platform_data = &da850_evm_tl_leds_pdata,
- {9 u# q8 w' k .release = led_dev_release,
1 S/ G6 k1 O+ N) s, ? }
& Y: z* y2 h9 H* h8 r6 r};
4 G& n9 c& q6 f* Z# U1 w3 e2 y" q3 L
static int __init led_platform_init(void)
$ c- [2 g) y" D# [7 h3 r{6 x( @) H. H6 {& ^" F2 w
int ret;
+ H Y% l/ L. h6 F! }3 V7 m#if 0# d. c+ n0 J( m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 v6 _3 \! P0 b% r m if (ret)1 P+ h0 V8 ^4 x1 M4 S6 U! S6 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 M# Z4 A1 M3 O4 B1 C: u4 W+ y "%d\n", ret);
- o; q% ~ t' C6 w) ~#endif
4 |9 d& d* w: z" u; |" |3 | ret = platform_device_register(&da850_evm_tl_leds_device);
8 w$ p: p; ~6 p9 @0 h. Q0 l if (ret)% p5 p7 q1 }2 z* `( t5 n. B. p
pr_warning("Could not register som GPIO expander LEDS");" h8 ~. B1 t9 R) d& E9 Q# D
else
3 Z ?) i. R% g! P' r) v6 Y printk(KERN_INFO "LED register sucessful!\n");/ Z* J& k$ |; o) L7 q5 [4 ~% {' l
2 N# H* y6 [) X* D# g
return ret;1 _% j" r+ r- b [7 y
}7 Z5 U- X0 _ b$ O: X+ A+ N5 S
& Q' _& O L7 @static void __exit led_platform_exit(void)
3 g5 n6 Y( u2 [9 w{7 q4 I7 i q1 Z- U8 C% h7 ^; ~5 c
platform_device_unregister(&da850_evm_tl_leds_device);8 L& F" ]# A$ r! g0 c9 E4 W. R
9 D. w5 d, O9 }( |; @9 u
printk(KERN_INFO "LED unregister!\n");
6 ?3 Z# Q. X- F6 D! \. I" ^}2 f! C3 f% T+ x/ R
- T) R9 ? e9 C, B6 Wmodule_init(led_platform_init);
* P; P; ^8 _# b, l" j% Fmodule_exit(led_platform_exit);
# t! P/ _$ T3 d: a, ^8 P& P% {% l. E3 m
MODULE_DESCRIPTION("Led platform driver");6 F/ e1 w$ r+ W2 R
MODULE_AUTHOR("Tronlong");
9 J; \0 k% d$ A/ n& i) bMODULE_LICENSE("GPL"); V& i9 Y* w* P+ v7 A
4 z3 j+ _) R# G3 B2 ] |
|