|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ Y l/ j2 v+ R8 J7 y7 _% F
#include <linux/init.h>( W! X' Y: v+ H; e
#include <linux/module.h>
; u4 y5 o0 Z. H' G$ ~) X" A/ \/ p#include <linux/kernel.h>0 m% \) {/ g7 _7 I2 a8 j0 y0 h
#include <linux/types.h>
+ }* R& ]8 n- g# i" V! S5 p# C#include <linux/gpio.h>
5 g, y; u9 `- n6 L. m8 R#include <linux/leds.h>
: U; T; ?% N6 `) a: G6 |' G#include <linux/platform_device.h>
" D7 y7 _8 L M( h; _2 C- z+ B5 B- j" `
$ g) |$ v: a* H8 A#include <asm/mach-types.h>9 Z$ q( d# W. ?
#include <asm/mach/arch.h>
, i+ a0 r, Y% `3 _4 d! s/ q#include <mach/da8xx.h>* b2 W2 R# U$ i; \6 q, r! n. ?$ L
#include <mach/mux.h>8 n- G) O+ c9 O, b' R' |+ N3 V
& f, v( J2 Z. \, y5 h# i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 w# d3 d& P! U C/ }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 b S& I- w% d+ J) g2 P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): X9 ^, Y1 G3 y# [7 ]8 A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# t! E1 q9 y$ [5 v5 n! Q1 U8 H
$ z" W/ B* E+ |/ W3 P" S
/* assign the tl som board LED-GPIOs*/6 a! x* ?2 Q E+ i W% S
static const short da850_evm_tl_user_led_pins[] = {
0 v# D. {5 T7 U" x9 ?1 M0 M3 O0 a0 A /* These pins are definition at <mach/mux.h> file *// ~ F# F9 _8 `9 @+ h8 T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* n6 j4 ~/ ~) o; T
-10 ~! a) U' D4 [1 `4 l L
};- W4 I8 }( _* E) t% E
u& q2 K6 A0 e7 M( X! r7 \& z! ^( rstatic struct gpio_led da850_evm_tl_leds[] = {
% H5 T0 l0 ^$ n1 r8 } {
' n0 l* W5 g e5 x: X .active_low = 0,
) S, j7 F- N, o7 d$ u% o; M3 x .gpio = DA850_USER_LED0,
" V, j- k; Y8 ] .name = "user_led0",: x4 L& Z, X5 B8 G9 C$ C+ A' C
.default_trigger = "default-on",4 ]" Q& ~6 O% b7 S, L" r0 h C
},
: C" u! X3 L/ H9 U6 {6 n5 M {
$ H, H4 |- l' ? Z .active_low = 0,9 i% o" f! R8 s$ w$ i/ S' w
.gpio = DA850_USER_LED1,
9 }; \. b5 J4 a6 c5 q% O .name = "user_led1",
8 C# q7 A+ X# a, M- K# l .default_trigger = "default-on",
5 P4 u' t: n0 o0 s$ l3 M/ I a- X# w: w },
* b, @1 K: a; I, q1 I {
7 f; u9 M) P; ^; ~6 o .active_low = 0,, ^. L6 Q2 J0 d: i+ s
.gpio = DA850_USER_LED2,
: e/ O6 E) t! P3 } .name = "user_led2",
* [& {. c) O7 X [. V/ x2 d: J- w .default_trigger = "default-on",
: a8 @* e3 L8 w },
* m# @6 P0 G" I4 l {
3 u% J( j# x3 f! r( s .active_low = 0,
# O* c7 q) s! U: {9 V ^ .gpio = DA850_USER_LED3,8 [8 X* e8 ^3 F( W+ r: r1 A& t# Y* F
.name = "user_led3",
: v- y1 u" M+ }) ~ .default_trigger = "default-on",
4 p2 Q' T# x7 e) ~ },
( L5 C, D# ^' o, q1 ~& M4 q/ S};
/ x/ F8 G8 l5 O( J. ~0 R
! q" X( t1 i( O4 b+ Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ X. J% g5 @/ X+ F
.leds = da850_evm_tl_leds,
# b2 j: f7 } H5 z+ r' r% H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; g3 v( C7 j2 r! U; W5 P: B};: x7 E) P9 c" Q N; @3 n' w. F
2 ^% ]& I1 T: G# _$ ^ jstatic void led_dev_release(struct device *dev)# y* _! V/ f' ~! I
{
; G1 X* c: B2 \: j, A};" V' |2 k. }& e1 K& Z( t
3 a s( a8 x5 R+ ?, o. l) l; u$ Mstatic struct platform_device da850_evm_tl_leds_device = {% ]9 ~1 S1 O: F5 J* J
.name = "leds-gpio",
1 j, }0 t7 I. P: F .id = 1," v/ B v0 [. N P: F6 S
.dev = {
9 {" H/ u! u* H( {5 | .platform_data = &da850_evm_tl_leds_pdata,' [, X$ M) f E& e$ B* i/ N
.release = led_dev_release,
/ e; G8 g5 }" D9 G. m {* i& ` }
) m1 | w, U6 Q/ S};
- |; {' X8 x# X3 e# R
* O! k' W7 }$ k: O: q. ystatic int __init led_platform_init(void)
" H9 d( {( p" W0 U# e7 A, w1 r" q1 }{7 H: z" g1 G3 C# }6 }
int ret;7 Y, q' X7 y( a7 _ }3 o0 x
#if 0' O }. f: `* s/ q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 B$ E1 E2 h- J1 V" F7 G7 q8 W2 ^/ m* L if (ret)
9 g1 |" v! s0 B7 ]/ J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 N0 i) O' F# @3 I: S1 c
"%d\n", ret);; O* l3 {$ s8 S; V, @" y7 j
#endif7 b, v. p4 D h& ?$ W) [
ret = platform_device_register(&da850_evm_tl_leds_device);( Q( r/ ?1 S) T% Z# F; d9 o* _
if (ret)* k) m% x+ ?, @# J3 j# U
pr_warning("Could not register som GPIO expander LEDS");
% {* `: Y* Q8 I7 t else$ n# @0 g0 F5 I/ Z8 \% q$ @
printk(KERN_INFO "LED register sucessful!\n");
& M' V) B! B; n0 `
2 ~( ~4 {+ x/ Y. d return ret;
0 i/ V7 y' Z% k9 |}! y) ?8 m; u. [- X! s A1 K) d
5 `3 K6 J. b* Q+ B3 s" h; H
static void __exit led_platform_exit(void)
) S4 {1 p& Z7 |8 F. s$ Q{' d8 o& m1 k6 `( \( G; O
platform_device_unregister(&da850_evm_tl_leds_device);
% b4 x. U5 T( E) ~$ L) O5 q. p. u# b0 ~& ~2 D, w
printk(KERN_INFO "LED unregister!\n");
# W% S6 E/ m, G}* }! W' c- W5 A
: k6 }5 p) Y( Z* A
module_init(led_platform_init);7 ]2 F4 q* k" o9 Y- O
module_exit(led_platform_exit);
, Q$ |! E1 W n/ p
" d+ y& b- u5 t6 U0 T0 O" sMODULE_DESCRIPTION("Led platform driver");3 i+ @, m+ H! Z3 ~0 ?) _- q8 s
MODULE_AUTHOR("Tronlong");- W: t4 k- U* P* X4 f7 W
MODULE_LICENSE("GPL");9 \1 D. J5 l7 H% ~3 O% S+ @
1 w% F8 ?9 ~# y7 p8 B' f
|
|