|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 I/ k; N- b: ~: d6 j5 i
#include <linux/init.h>
% `6 c) l$ j* _6 i2 A#include <linux/module.h>( ~+ r3 v" I4 ~; F: i, a
#include <linux/kernel.h>
$ j$ @9 Z" Y X#include <linux/types.h>
# D6 a" I( |1 f* W! K/ Q#include <linux/gpio.h>; k. C; O) Z% O2 J% V4 {; M( J6 k
#include <linux/leds.h>" N$ r) \6 ~4 J% u
#include <linux/platform_device.h>" X. Q4 O* ?# K$ i# a, O
, D! w, ~7 w, i, Z$ ^. g+ T#include <asm/mach-types.h>8 Q& X" l* U) k/ {8 T+ B+ d
#include <asm/mach/arch.h>
7 k, B, p4 A6 S4 S2 k/ i#include <mach/da8xx.h>
4 ^( R4 k6 t+ f3 s#include <mach/mux.h>5 L8 B8 C/ R9 O4 [' @) X
% W9 {" ^4 g9 w Y+ n# o& f F% q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( |: t6 Q3 @4 J7 d6 q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* {8 u8 ]0 o2 F/ J0 ^4 l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ W1 B( J! [: b9 e. Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ s/ K/ @- {9 p7 X# t( P3 H' Y K
/ L% w# U: Y- y5 i! H/* assign the tl som board LED-GPIOs*/$ X W1 o8 `" X) n6 v8 H
static const short da850_evm_tl_user_led_pins[] = {* I5 x+ `& |( D3 E, t
/* These pins are definition at <mach/mux.h> file */2 h" Z& ?$ q3 J* s1 }. t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," E9 A9 _) t+ A/ R; W" v
-1
0 {9 I3 k. \( Q};
4 t! R% D U0 L$ t( A5 `. P8 W7 W% i3 ]$ `% A, w' L; a, Q \* Q7 T
static struct gpio_led da850_evm_tl_leds[] = {/ a. P5 P5 h5 D
{7 f Q2 ^' |' d
.active_low = 0,; f1 V, p* d+ p' a
.gpio = DA850_USER_LED0,2 t& |- |, h# ~
.name = "user_led0",
! U" H ?- J! n( ] .default_trigger = "default-on",
2 `7 ?3 y# F5 h; h9 u* c: p B },
+ v; }+ K! n- L9 c6 E {
& y, \2 C* n! G" o .active_low = 0,( T/ y" X8 m# H/ C
.gpio = DA850_USER_LED1,$ G/ Q! Q1 d8 K
.name = "user_led1",1 s8 U1 z+ i) F+ i1 C0 E+ [7 ~+ H# b R$ p
.default_trigger = "default-on",
% o8 p1 u: e2 H" l },( J$ i) ]' b5 z2 @, P
{
" s1 Y2 z. G( x) Z6 A$ A4 A& m .active_low = 0,4 T1 h% Q; R; |8 J( a6 _
.gpio = DA850_USER_LED2,/ B0 ~: H, k$ D
.name = "user_led2",
3 w# D- |! A8 M# ^# B .default_trigger = "default-on", N9 Z6 R3 M/ F: H, Z* m( \! @
},
0 M9 e( _" R _' r& X% ? {1 K- c( M& L/ f3 h, }
.active_low = 0,
' P3 I7 A% i( V2 Y .gpio = DA850_USER_LED3,7 m: `8 Y4 C" O) ?) n9 U
.name = "user_led3",
) |" @- ?% N) B .default_trigger = "default-on",* K- s2 E j( V
},- k4 j2 b9 C' h3 K1 f1 i
};. J/ ]" f7 Y" p/ n7 z
# }7 q1 Z3 W8 ~" Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: ?' u; N/ z% J1 W0 _: U H
.leds = da850_evm_tl_leds,
# S& k3 o% E3 X# e: L* J2 G) R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 `3 h! s4 |& ]% Y! M6 O
};
( B3 t- p' q" F/ ^4 ]9 u7 o5 w
static void led_dev_release(struct device *dev)
- {- K+ a2 }3 c L8 L: T+ l4 N{
* O* R, H6 n) {7 v};* ^+ P2 V5 j$ j+ W3 F# d
2 G) @) \% k2 i% A8 Istatic struct platform_device da850_evm_tl_leds_device = {
$ P6 U$ b4 n) ?9 f+ o' L/ r% ~4 E( e; P .name = "leds-gpio",6 n V% f: `% t9 D
.id = 1,
3 x5 R& k# F. q2 u8 @ .dev = {9 {1 W' v* {5 J
.platform_data = &da850_evm_tl_leds_pdata,9 }* y* X3 w: H' U3 r( t4 r+ g
.release = led_dev_release,
^' b" i: O9 O2 @6 z }: b0 l0 e$ f6 @" T0 o7 x( p
};
$ q# Y2 x- t/ s, {
" O) J& {& O2 y. Wstatic int __init led_platform_init(void)
- e3 _* E: S; G# i! T8 G& p{! G- f$ i7 J3 N4 O( @* N* R
int ret;
* |+ N' t9 h! L2 P8 b7 n8 h+ ~#if 0
; u, n: k* N. s4 f }+ \, B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& i8 X0 {3 ]6 f" j: f& P8 T if (ret)1 o' Z0 ]! E8 \. [$ I% P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' F5 i* {& } k9 h2 J2 b "%d\n", ret);
' k, R7 n: G' v#endif1 b2 P" Z2 p% V- H v; S/ f8 G
ret = platform_device_register(&da850_evm_tl_leds_device);
. {& ^+ ~3 G, A/ Y- R }' V7 z if (ret)
8 w2 l! {( S4 w* d2 S- [- | pr_warning("Could not register som GPIO expander LEDS");
; X7 T) e6 X( d$ H3 ^% c else K( }0 v t* @: _# V' w
printk(KERN_INFO "LED register sucessful!\n");
/ g& Y/ s% B+ S! G# b' V' a. `+ R" S9 W0 f- X8 s! T5 N9 c+ Z
return ret;/ k4 `* B8 j. a% k6 |
}
; f9 n2 P/ E) d9 d6 `: y$ D- y
1 y* N5 d' n5 Q' V9 m5 S9 m8 fstatic void __exit led_platform_exit(void)
) L& L1 r; a6 Z c: x$ y0 ~{
* j" A$ ~# p% [0 V! Q platform_device_unregister(&da850_evm_tl_leds_device);
% ~8 e2 k* v3 F: ~. G) E& c- L3 S
, ^1 q- f" N9 U printk(KERN_INFO "LED unregister!\n");
0 a' x4 e& ~8 w; ^ B0 u/ w}
5 |1 n- M) B% x; j
& Z& d; y e. Y' `9 Tmodule_init(led_platform_init);% D7 d/ Y" z) o% J) }
module_exit(led_platform_exit);
2 m' C+ \* [/ V% l, ^* F+ R6 s! O) p# F
MODULE_DESCRIPTION("Led platform driver");
- A6 P. j$ ]8 r! H6 R7 DMODULE_AUTHOR("Tronlong");/ B: j0 q- `' w7 l- {
MODULE_LICENSE("GPL");
* m+ h8 x4 m) k; E E/ j9 R
' M/ p% I0 Y* E2 H |
|