|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 T! O! V @' ]
#include <linux/init.h>% \( u, B5 I- U1 M$ c) p
#include <linux/module.h>
$ m S C" H0 }# X9 J S#include <linux/kernel.h>
& w- L2 l# H) J; H4 I0 U8 V#include <linux/types.h> ^; r& `! }6 J7 n e. J" d
#include <linux/gpio.h>
0 F( B$ m; [7 u; F% A#include <linux/leds.h>9 }3 s% p! f7 u0 d
#include <linux/platform_device.h>8 e, j8 g. a2 h. `. {* D& A5 V- P9 N+ B
/ d+ s7 o/ J" ?" h7 O
#include <asm/mach-types.h>2 A7 d. p A! a" y% `2 X) \
#include <asm/mach/arch.h>$ ~6 p7 K! }' l) \: y
#include <mach/da8xx.h>+ n, f- P. h& ~
#include <mach/mux.h>
& R' R* j2 @6 K1 O5 w' x( {
' R( I. j0 Q$ e [! O8 J4 p- h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! X# ]# m8 U/ t0 L$ G: g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- k7 G# p3 h) R. t$ S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 N' Y( q5 y9 L2 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( H$ w0 R: _- v
& D `5 ?+ D# P9 V8 _6 z1 B/* assign the tl som board LED-GPIOs*/
+ U. f7 c3 r3 A- U$ u2 Estatic const short da850_evm_tl_user_led_pins[] = {
. } h( C) ?9 L9 d/ r3 `: ? /* These pins are definition at <mach/mux.h> file */) F6 r9 u' {* s* Q# B. E) |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: t* K V7 @& s) f2 w0 p( v+ Z
-18 N+ U$ V7 w3 \. |
};
6 P: F8 w/ a& h# n" i' E8 S# C1 _
static struct gpio_led da850_evm_tl_leds[] = {4 ?$ \' G" p. Z) |$ ^
{7 `8 R$ s" Q$ K e: q
.active_low = 0,
6 W) u8 m+ J- r .gpio = DA850_USER_LED0,
5 U' K t" T% ]; W .name = "user_led0",
, g* d7 H2 k" K* M .default_trigger = "default-on",
. p+ E6 w3 i5 r0 D% z5 f },' [6 l+ u2 i6 H* ]
{
6 I G* n+ V3 t# \/ S .active_low = 0,8 `9 M7 ^% J. x2 g( Q1 g8 c) G
.gpio = DA850_USER_LED1,
9 D3 u1 C/ ~! J/ f) T: j) w .name = "user_led1",
, g Q' I/ i& J' L) m .default_trigger = "default-on",- W4 f5 U6 [3 l1 \) O
},
^) x4 m( z0 _+ U3 h {
* H+ T0 R; n5 d( P2 B% h" n( n6 \ .active_low = 0,2 K/ ^$ @2 @& B. z- C7 h" n' Y
.gpio = DA850_USER_LED2,
* k C9 A8 {( i7 S0 g6 u .name = "user_led2",
# v$ r3 T* o/ ]1 t0 h' u6 c .default_trigger = "default-on",
2 N* \8 T, f- `, t },1 n5 @, [& ^9 f* \. @. E) m/ q
{
$ Q/ r1 d6 `, Y( W9 o7 u9 z .active_low = 0,( `+ P6 o ]$ P- }
.gpio = DA850_USER_LED3,
/ ~1 o. H1 M$ b7 n# ^0 s$ ~ .name = "user_led3",
# p" U0 p" k! @3 N4 _! c$ m .default_trigger = "default-on",9 s% W: y& O v9 E3 e4 V* I
},& n- i- v; `: b1 U
};
0 L7 S7 O7 i+ ?: h, q8 D8 ^8 T; o0 \7 j/ b9 q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 C% j* P0 P- ~0 K .leds = da850_evm_tl_leds,; O6 X: ~, j1 |$ C4 c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), D0 @- M3 n' [ G4 A$ B
};
3 T6 r0 C; O- x8 L( R* ?
9 j# k9 r% P6 M* a. ]! W* Xstatic void led_dev_release(struct device *dev)* c& W& f5 p8 U. c+ ^; ~) s
{; A" C4 V/ b$ w X
};* s; _) K3 t2 i+ u0 q6 S; S
8 f* B1 m. r% K1 ~/ ?
static struct platform_device da850_evm_tl_leds_device = {$ e7 `: y9 j0 S3 ]; C
.name = "leds-gpio"," v# Q* `9 t3 `
.id = 1,
$ C9 r5 u1 {, X! n* G+ Y .dev = {
2 P" Q! u$ k; _' g$ ?! m7 A .platform_data = &da850_evm_tl_leds_pdata,
- k* F* R3 ^( v# V .release = led_dev_release,
9 ^% a- U+ O3 g* s5 @ }
! `& W/ j7 e8 x* j3 D/ p o/ |};% L4 X6 Z9 ?7 M/ e6 r8 W
9 l3 k+ H& p* Y1 \1 `$ x! _0 {
static int __init led_platform_init(void)( T# q; R; \5 M% H1 y
{
5 `9 g8 H* q3 |2 |4 z int ret;
; ?8 Y4 k5 j1 G. v& X: h#if 0
: B8 W0 `: P( Q. R* a# v& K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 U6 Q0 C8 M9 [2 l0 {- m/ n if (ret)9 u) v+ N4 J* m6 c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* G+ l6 p p, L2 u "%d\n", ret);
* R e! p4 V6 r#endif
6 }- i4 j1 L, ^& c5 X$ S ret = platform_device_register(&da850_evm_tl_leds_device);/ ^7 E ~. r" ]2 h/ E L
if (ret)
% L9 Y. Y5 }) w3 m5 x pr_warning("Could not register som GPIO expander LEDS");
' M0 s* e s# o) ? else- H/ e6 Y. z! n% @
printk(KERN_INFO "LED register sucessful!\n");1 G4 c& U9 {5 t2 J) R i$ ~2 \
. W# f5 }- E' N4 ?. O( {! X
return ret;: Q( }% d$ j6 Z6 P2 x( T
}- B: x) k8 H1 B/ H
8 f* }& e# d2 Y6 m8 i. k* m
static void __exit led_platform_exit(void). N9 l* B* l" Y% x2 S3 W
{& ~1 @: R' S+ h' q
platform_device_unregister(&da850_evm_tl_leds_device);' W9 i* t. l8 V6 t1 o2 V* @9 }
) I4 G* C7 v0 p# k printk(KERN_INFO "LED unregister!\n");4 k1 I! ?: E M( u2 @; u
}
: k, W# s6 X8 I' Q* `1 t# S4 M1 }; q5 n# N9 b7 [
module_init(led_platform_init);
0 M) t; ?' Z8 Xmodule_exit(led_platform_exit);
' l4 u6 q% z' k+ O$ }! \6 x6 O9 R+ a! k+ l, r9 q9 z
MODULE_DESCRIPTION("Led platform driver");& \0 L$ Y1 A* {
MODULE_AUTHOR("Tronlong"); H7 Q" \6 E/ I8 c, c
MODULE_LICENSE("GPL");
% l3 z$ Z/ D+ u' g7 x s
# p( I. q* J" B: |+ {8 r' W |
|