|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; z% x& ~* Z3 F; w# o' K1 k! Y
#include <linux/init.h>
# l7 H5 D, F0 x/ l) N3 Q( `+ B+ A#include <linux/module.h>
" K [# }: m5 G" R#include <linux/kernel.h>
3 n7 X# a; O: ] T+ ~( D' q0 X Z#include <linux/types.h>" u3 s0 x, r& a
#include <linux/gpio.h>
0 D6 O' ~# w1 i; F#include <linux/leds.h>$ y7 ?: z( z$ k) {8 a
#include <linux/platform_device.h> N4 |: r# h' N% E
8 k T' S Y8 G! A4 P; L5 D
#include <asm/mach-types.h>3 o4 q- \( j8 k h" `: q2 V8 h) `& c
#include <asm/mach/arch.h>/ t q& m: D) l; ?) `2 z. }
#include <mach/da8xx.h>
1 } w. n9 R, U#include <mach/mux.h>
- }) v, e; n$ f, \2 K0 I: Y: O- H$ ^3 J6 F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 M: V" o! q/ P) j' N4 X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ F% r b. d# H; T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" x8 Z5 z! r% c3 [2 F' g+ i7 i/ A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 }% j* h6 a' `% Y9 V
3 x2 F6 ]6 f+ E" {/* assign the tl som board LED-GPIOs*/
' l+ P- I9 v& V# K) ^4 kstatic const short da850_evm_tl_user_led_pins[] = {
8 K* |7 U2 u3 |2 m/ u4 w /* These pins are definition at <mach/mux.h> file */
7 b+ n2 m8 r5 r3 q+ X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- ]& H4 ^/ C) a8 }, I# { -1; B8 n- i1 }/ t* V
};6 V# ?7 Z% n0 A- \& T w
& v: V: d! z, ^0 ]3 S! }- E4 b
static struct gpio_led da850_evm_tl_leds[] = {% V, M1 Z/ k1 U
{
5 Y: E1 \% _9 F+ Y0 t .active_low = 0,, B- e* Q9 N9 `/ [$ z. z( O+ l
.gpio = DA850_USER_LED0,
) n$ y& Y- c5 k9 v. z .name = "user_led0",; E& N( X; E& z
.default_trigger = "default-on",2 y+ _1 `9 J- O9 G# G% D, Z [
},4 f2 ~' K( m& T2 a: O6 a
{
U$ |3 A2 [" |3 [ .active_low = 0,
* D5 ~3 E" q/ w .gpio = DA850_USER_LED1,
2 b, w) z3 x" ~7 V# I .name = "user_led1",& ~# g% |8 i/ X* E4 C5 `1 w
.default_trigger = "default-on",
% W r% F4 A k# S- B },) @3 X/ m9 _& B. [0 w. @! D
{ Y8 w, [! \& v" @
.active_low = 0,; u5 }" K- n; T
.gpio = DA850_USER_LED2,
% V+ E. B# D) L' V) d1 P .name = "user_led2",
2 S7 f* I6 ^) Q .default_trigger = "default-on",
% q8 s( k' m1 ]- n8 z6 D7 O },
v3 x ~" }! z" Y. P3 C$ V {/ k0 x: S* p6 M7 O( A+ c3 w
.active_low = 0,
" s$ @1 A1 v6 T! g/ |; k( O' Y .gpio = DA850_USER_LED3,
3 h& Y4 I/ J3 a% P7 D* X B( ] .name = "user_led3",) V+ b' |' b% G0 d w5 e" P+ S% T: `" C
.default_trigger = "default-on",
6 H; `/ B8 Y, e" T# U1 f },1 S7 |3 f% k1 ^% g: {0 s9 M
};
0 n# N% D; Q5 U8 @- n8 q8 X# j, S! V* m3 y% e$ A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. f" R U* @1 N9 `" d' U) b2 q .leds = da850_evm_tl_leds,
3 k; a( n0 [/ Q) V$ }5 N: E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ [3 N# i7 U9 c+ t7 D};
8 K' `" |) T. c9 \% U1 A3 O0 B D9 K0 e% j. w: i3 x4 K. j
static void led_dev_release(struct device *dev)+ L8 Z) C" X+ B2 C7 F; c
{9 ?4 m9 l0 c8 m9 L5 X
};
1 ^# ?) o( L& t3 x
6 C. x* x# ]' H4 vstatic struct platform_device da850_evm_tl_leds_device = {# y. g- \2 W7 M7 f( ?+ n/ }
.name = "leds-gpio",
) s0 g, ] U# t; \- r .id = 1,
, _$ ~5 d1 e; e/ a6 ^' A5 c+ L .dev = {$ D0 w- h0 n7 b, r6 B
.platform_data = &da850_evm_tl_leds_pdata,1 ~: W' o- l6 d" u, b3 [. R
.release = led_dev_release,
1 y& `! q N0 Y }
8 p9 X# L# ]% N0 J9 k};
/ C, d0 ~( ^2 h o& X; X/ `2 O
7 m8 S; l' w" O, W9 Wstatic int __init led_platform_init(void)
6 T, j% M# g, c5 I: T: ?. r6 i9 c{
( v! E& u& Y; j5 B) j3 \ int ret;- d: f! Y2 W5 T; p3 O& c' B3 R; X5 ^
#if 0
7 T4 L t# i, B. L1 Y5 r* B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 j6 {8 u! _- h* Q if (ret)
, s& T: f/ u) d/ a- b" P/ A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- k. e4 x0 m6 M& L9 T0 E "%d\n", ret);
/ |. z5 A3 [9 h& Z% }& S#endif9 r5 ?. X+ L) w. _
ret = platform_device_register(&da850_evm_tl_leds_device);, T3 ]7 X/ [ f3 V1 m6 J% X! ]
if (ret)( D9 y) d+ K4 N9 t4 p$ \! a
pr_warning("Could not register som GPIO expander LEDS");
8 _. I ?6 m0 O$ R" S7 _ else3 A' v+ a4 H5 ^5 U+ x8 E
printk(KERN_INFO "LED register sucessful!\n");
/ n# p) ?' k( r8 R' ], f7 K2 d3 G! p3 N4 U8 O; f
return ret;
9 Q% |6 E4 U) e}
- r& G* C; F$ A' i7 |6 ]4 ?& E0 d/ u5 B8 Y, X# B1 x$ D
static void __exit led_platform_exit(void)" Q7 `8 ]( u$ B& D p! c
{% z' }" k$ p2 y( _. \9 w9 G. X
platform_device_unregister(&da850_evm_tl_leds_device); A* s9 t$ {# ~
/ p% I: q% L0 f- m* |
printk(KERN_INFO "LED unregister!\n");
3 m2 f+ q4 @: ]9 v}
0 N* ~* d$ p' s9 ?' m( `8 \; a& W# C ~5 H0 q! s4 V5 a+ S
module_init(led_platform_init);
8 ]# q. W0 ]! q7 Nmodule_exit(led_platform_exit);; n8 X. M# O7 s( N
4 V% R! ]0 q1 U/ b$ J' C& c- C: V$ fMODULE_DESCRIPTION("Led platform driver");+ v" g$ s# m7 f2 w3 v
MODULE_AUTHOR("Tronlong");
) _0 b% o( |- }% zMODULE_LICENSE("GPL");; q9 U! s* B" F$ i! ?
+ d" Q; x, m- N" f
|
|