|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ j: L- m4 F' T& j6 N0 Q#include <linux/init.h>
( z- q9 D* _5 e- y \8 F& A+ r2 j#include <linux/module.h>
. W3 P0 M: }5 C: p#include <linux/kernel.h>% T% G2 b1 ]3 i |: h$ P7 r- `9 B6 l
#include <linux/types.h>- d. h& v" u" }
#include <linux/gpio.h>
" J! X/ E! u- X* z# }#include <linux/leds.h>' y+ c$ z5 ]9 z. g8 F% s7 l9 V/ w
#include <linux/platform_device.h>% z: I i! W) i, V9 w& h
. c9 K: |5 |6 O" A
#include <asm/mach-types.h>1 c7 W* z% n P/ B( G' Y1 ^
#include <asm/mach/arch.h>
6 i' X% g) ?- A0 ~/ f4 [#include <mach/da8xx.h>
5 e! C9 E2 [. s9 o K#include <mach/mux.h>
; x6 V5 P% A' e
7 _1 O, P* @9 r6 W+ p$ q) Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 w0 O+ |+ r4 W# R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& V$ s6 C6 ~/ c% \. h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); }# a; B. P% s, I5 h0 ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 v. r5 A1 h/ l+ E. c+ ?( E3 i0 J2 S" [( n; D# k7 R
/* assign the tl som board LED-GPIOs*/
+ i6 o S( T) Qstatic const short da850_evm_tl_user_led_pins[] = {% k$ Y8 j% l& O$ g& f8 U' D
/* These pins are definition at <mach/mux.h> file */3 f) u9 M, Z1 @5 K; I9 C" j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 T% H1 \3 Y! B0 w7 j& `* H -1
3 `) M; o9 u6 E7 @: ^};% K7 a1 F) A9 @' r3 r
0 s# c! b) w; n" P, v0 `- a8 [
static struct gpio_led da850_evm_tl_leds[] = {: N1 i$ S; \* c* q
{
6 C- L, I" O7 _0 a4 K .active_low = 0,
8 T3 r( t. o7 T- l .gpio = DA850_USER_LED0,5 n a4 T5 e) ^: E1 I$ U
.name = "user_led0",
2 E: J: h9 [- x1 g5 Z6 o .default_trigger = "default-on",% P1 _& B( `0 v# p3 D/ A" q1 l
},3 ~! Y- I5 l( }" S
{9 v; ]' U+ y- y# q
.active_low = 0,1 c# b, X. M8 T3 w
.gpio = DA850_USER_LED1,0 {5 P* Z- K" X( _" ?1 u
.name = "user_led1",
+ Q$ u6 d7 U1 y- D .default_trigger = "default-on",
2 `- n( m' S+ y5 a6 b1 ] },
8 N8 N- \" [# H6 l/ s" x7 N {
/ X4 z, Z2 w, Y) [9 O% L- u9 x .active_low = 0,
3 b' i. }( o3 R- s .gpio = DA850_USER_LED2,4 C5 J4 @3 R/ F% v8 w' y
.name = "user_led2",
) l: S5 |7 ?% W .default_trigger = "default-on",
; N" r0 D" P7 g }," D* ~( s& {9 Y( J0 b* t
{
* a0 m4 w# ]* x1 n .active_low = 0,
6 g" K6 d: ^; A/ A .gpio = DA850_USER_LED3,9 N" p K9 Z6 H# W3 ^/ `, Y
.name = "user_led3",6 b6 g. q2 q) `6 G, a* G
.default_trigger = "default-on",
8 @. o" N" i1 A! I },
- W! f) v( Q; o/ u' R+ J};5 |- j6 G; z0 R+ S' i- {: m Z2 ~8 T
2 l9 m y' c# v: Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- j" J! k/ H1 V9 a; O, b* i; c .leds = da850_evm_tl_leds,6 h8 W" ~/ I) r4 O* {) N |6 a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& u( e; H6 K$ J: ^4 I1 S# _
};0 z5 P3 l; \, b9 c8 X7 @ V
$ W' G8 U6 l7 @, k# E
static void led_dev_release(struct device *dev)
. z8 U1 a3 c( g5 a2 `{
: c* l2 w' G" ^0 v/ ]! D; r};! |, g4 S s8 R+ Q
# I0 N& v! {4 W6 c5 V/ c
static struct platform_device da850_evm_tl_leds_device = {
/ p6 b5 F7 q( u1 ]3 @) U .name = "leds-gpio",
2 [8 \- U! s8 D/ D" ?7 ]( Q$ ^8 M .id = 1,
9 q+ O- o1 G% k3 o' m( O .dev = {
# y j% v% T% X4 ? J( ]" A3 G4 h .platform_data = &da850_evm_tl_leds_pdata,
4 j8 O3 B- r7 s* X1 a' g+ ~ .release = led_dev_release,
. ?$ s' s8 W) S! l6 c) A2 h }
- ]+ i6 [6 v8 `3 a8 F! \( B) R" Y};6 O6 }% M3 E5 Z- z# _; v2 K5 @+ K
9 X4 o4 y; I2 E( } ]static int __init led_platform_init(void)
0 n5 ^8 P3 f( G, j9 e{7 O' i9 P) @$ y+ D! C# z/ |
int ret;/ V+ v) J! ]0 V0 Y
#if 05 D* z6 {# a( X3 y) p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' g; H% ?* d6 M1 e! O+ P
if (ret)
" p0 m+ T) o3 v6 S% _# X; S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 J, l& H. G' x2 h4 n "%d\n", ret);
" M6 }/ r- N9 s4 ]% X#endif
; _* {& H5 H5 U- {) ~ ret = platform_device_register(&da850_evm_tl_leds_device);
& f J6 l+ N( n0 M if (ret): q$ ^& v6 P) ]
pr_warning("Could not register som GPIO expander LEDS");6 o- \ i/ t! z& F, A
else3 |7 Y2 r# S, I# d: p( Z
printk(KERN_INFO "LED register sucessful!\n");
; f' _6 {% B9 h) r: r
* t/ H) q; I* }# m" s+ C7 c' l return ret;, I. |, t0 m5 t7 Z7 D4 }, M
}' U' z9 q/ D# X S
0 Q. y7 G* H$ I4 }
static void __exit led_platform_exit(void)
, [2 m; N0 s5 H9 z{
) L9 C* A: B: ~ J/ e8 _3 ?. r" I platform_device_unregister(&da850_evm_tl_leds_device);
/ ~0 Z* H* a$ ^0 u
- W( C1 H2 T5 k* y/ `% x# q3 L printk(KERN_INFO "LED unregister!\n");$ X' m7 _! J% J* e& j. d. K
}
2 ^0 y$ Y% w1 x' y
4 P) v- g9 M# ]& Q0 v5 [module_init(led_platform_init);, O1 m4 s8 A9 }+ H
module_exit(led_platform_exit);5 L2 Z" u( B9 k
6 n, Z, J4 u; l, ~! lMODULE_DESCRIPTION("Led platform driver");
6 ]( c" X. i5 S' k1 f# v( kMODULE_AUTHOR("Tronlong");
3 q, S& b4 U; \+ ^, SMODULE_LICENSE("GPL");
- Z1 d3 S; H( d4 }8 c5 \% k, ]+ e, X1 h
|
|