|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ z9 f7 [" a6 T9 Q+ j0 y1 g
#include <linux/init.h>
+ I+ {; o, U5 |7 X#include <linux/module.h>6 c/ N8 @3 b* D4 J
#include <linux/kernel.h>
2 g5 H: |+ J3 |' L2 m#include <linux/types.h>
8 W, r) f1 u' j; ^#include <linux/gpio.h>
- m3 k+ O6 M' k0 O; [#include <linux/leds.h>
+ Q. r5 u% r' K* c1 Z#include <linux/platform_device.h>
+ t2 Z0 a @' }+ g0 ^+ t. b" W
# [' X1 u) c: B& g1 V' z#include <asm/mach-types.h>" d; B2 B l3 X6 i L2 L$ j) \, {
#include <asm/mach/arch.h>" X& _- `, }- ]8 D/ B6 ^& S7 v
#include <mach/da8xx.h>: T, l! W, ]. L
#include <mach/mux.h>* M1 K( K+ V: X, N) ~
3 n1 M( e: F# Z% ], n9 i/ _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; g: T3 [/ a2 e. J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 X; _/ k6 x8 B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ f. _: i. x5 a' J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. z. V" n0 C5 v# r
7 C4 E. x) @; L% m/* assign the tl som board LED-GPIOs*/. Y: b! J: d3 Z: ?$ _
static const short da850_evm_tl_user_led_pins[] = {4 m$ ?" [4 @4 n, ~& k& y. F
/* These pins are definition at <mach/mux.h> file */
/ J7 B% X) y( R4 Q z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 @, [( ]+ i& L) J
-16 B3 W0 l" F: t- e1 @7 u
};
7 c6 z0 g z6 ^' R+ ~5 x: |6 X2 U4 J* j B- B w) O
static struct gpio_led da850_evm_tl_leds[] = {
4 Z. X" V3 c% W% U( U; k {
; W: I8 n' `' A9 j, v5 l: a .active_low = 0,
* b5 \$ {! x* S! S# V- A$ w1 y/ }, i .gpio = DA850_USER_LED0,( p6 g' R8 H4 ^% n; B
.name = "user_led0",
! |. y3 T: F8 u .default_trigger = "default-on",/ z- Y$ ^8 P2 k Q& s
},
- }* C' d( D: t: g+ e {
4 t U4 q2 _4 P .active_low = 0,* f$ R Z2 G* Y6 K2 v' d0 y: t
.gpio = DA850_USER_LED1,+ C# [, v/ F" `* @
.name = "user_led1",
& x% s8 t' ]9 D, ?9 z2 i .default_trigger = "default-on",* c0 Q" Q( u3 V; R
},
1 {5 j- a6 u( t1 w9 F! h1 S {
$ h) z+ _. R9 R2 u- Y .active_low = 0,0 |/ ^0 f9 E4 E; E9 N; f
.gpio = DA850_USER_LED2,. x) t) ?# ]' S! I( X; ?# p
.name = "user_led2",
* a& x1 V! l& p, | .default_trigger = "default-on",$ G/ S @0 ]* \8 y# D% \) t) q
},! {2 a: e; {# R( O, O4 i, {: r
{
/ r* c/ h# K7 l .active_low = 0,% ]9 V* Q2 g. V$ A% L
.gpio = DA850_USER_LED3,
0 k/ ]1 L" z! R$ u E4 q .name = "user_led3",
- s; K' c7 ~$ O- b Y .default_trigger = "default-on",% b# B9 C; m. h; ~0 n4 A2 s
},6 H. M+ a# C' ^- r$ g: h- t3 V9 j
};$ ]- J* x% Y! z0 I
% B6 }/ p f* g2 c7 i) q: [, ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 `- n8 Y2 d7 l( ?$ e .leds = da850_evm_tl_leds,* {$ L! O6 }. X6 E* v* v1 a! G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 ^) V, u& e" B) @}; [" [( ]9 O5 |3 W9 {
/ H+ z! o: T7 y3 n' l; Bstatic void led_dev_release(struct device *dev)' P* Q1 ]( H' t
{9 ]( y1 n4 \$ [! E8 n
};
( E' ^1 p3 R; p9 e6 J" S$ x; j0 C5 U) Z
static struct platform_device da850_evm_tl_leds_device = {. x% {( N ?* C- {' R
.name = "leds-gpio",
- c3 l( A8 ^" K7 K .id = 1,
; Q4 `% T$ k( o# }7 |. m7 v- K; q .dev = {
2 X' Y$ Z/ G8 ^/ F/ z5 G .platform_data = &da850_evm_tl_leds_pdata,
9 s, N0 l# R' s5 w" A .release = led_dev_release,
2 q7 A1 Y4 R/ P }
" V' h0 H$ p6 u};
9 M1 y7 B f1 ?- U6 a* B7 n
# Y0 _9 O) ~4 i4 a, R& estatic int __init led_platform_init(void)
& {) u) F1 k% W* E5 \/ n+ ]1 B{+ O3 ?! C) f) |) d' W* X
int ret;5 J* V) I/ v9 h; I3 ]0 U8 S+ p3 t' \/ V+ ~
#if 0) W$ a/ y' k }5 _4 a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- i' p& h8 t* q/ f/ E* e7 v3 b if (ret)& h a/ w7 q' I2 W. {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 _& j) i- k9 h5 o+ S "%d\n", ret);
# t6 _ A# u# l' b#endif" T+ ^* p/ {* u% H* W$ C2 {) t
ret = platform_device_register(&da850_evm_tl_leds_device);
" V8 X w0 e- k# [2 x' G* D if (ret)
4 w9 |& q+ E, h) ?' v; f pr_warning("Could not register som GPIO expander LEDS");9 l: F& u! {5 N* S8 {
else
% c# b6 F" z5 B% i$ l% O printk(KERN_INFO "LED register sucessful!\n");- w" |: S/ d1 \" g
: M9 l# R: m0 X# G return ret;
H8 V7 ^9 c$ i7 n/ L ?}7 u9 k: i( r0 g) d3 n$ Y7 C6 H
# N, x+ W/ B5 Y( _& Qstatic void __exit led_platform_exit(void) P; y% q5 Q5 e/ a+ i) T6 D. g
{
4 ]2 z& d4 E) C0 }9 L platform_device_unregister(&da850_evm_tl_leds_device);
7 |. E6 k" u, x( k _. a$ [8 K7 o, v( k
printk(KERN_INFO "LED unregister!\n");
, t% |. r9 y$ q n6 N. ^8 k}
" R, l) u5 `. T" t# K
2 \5 E4 u/ F* x8 e$ \module_init(led_platform_init);
" O$ v7 a4 U# e' E3 U5 cmodule_exit(led_platform_exit);& T- A" z8 L, v4 A
; D. \) q/ p& I5 {MODULE_DESCRIPTION("Led platform driver");
+ I# A1 T3 D3 UMODULE_AUTHOR("Tronlong");
* b% r: m. l6 i5 @MODULE_LICENSE("GPL");+ j; U. O3 G# d
% O5 Z. N9 r' r, [ ~" ] |
|