|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! i/ a) t: \5 S# {. m4 V
#include <linux/init.h>6 I1 c8 E. i# d/ h7 m7 H% G2 h
#include <linux/module.h>
) g% T7 K) D3 `5 q+ P#include <linux/kernel.h>; y# w! b' u$ O9 Y# ^+ B
#include <linux/types.h>; e& e0 f/ a' ?
#include <linux/gpio.h>/ p; j& Q4 N- e9 C# m% x+ x& S+ m
#include <linux/leds.h>
( z' R% I5 u8 p! g0 d#include <linux/platform_device.h>1 s; I: g2 C8 W9 q* u! e
" [5 }9 x- B6 \
#include <asm/mach-types.h>
( R4 A; J8 b0 D# N4 [" [/ |, S#include <asm/mach/arch.h>
- L. o- o7 L8 R5 H4 \) [+ l#include <mach/da8xx.h>3 m3 r3 h* M+ v2 o% T$ j% }
#include <mach/mux.h>
" x1 n% \7 B a2 ~& ]! [/ p3 I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ^9 \: A8 `6 j3 W4 l y; w$ H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# f9 Y) d+ g! S& Z) p W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 h9 c/ p1 ?8 B) R3 s c: {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( R9 m3 G+ E0 p3 i
+ ]% S: X, R; t1 x/ R/* assign the tl som board LED-GPIOs*/. _. B4 z+ r( V. m4 `: X
static const short da850_evm_tl_user_led_pins[] = {
L3 N- ~7 @/ P0 n /* These pins are definition at <mach/mux.h> file */
4 w1 T2 O% k- E; y0 }! |/ O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ Q0 z* C0 V3 ]% `! S" {5 D ? -1
- b, T" l/ |; K3 i};9 |# S/ j# [* r6 z
, J) x5 L- d9 N, g5 v; Sstatic struct gpio_led da850_evm_tl_leds[] = {
; U! d' L4 \2 T. T8 ]) L2 c9 L4 S4 v {
. f/ `6 E* [: a2 e9 m( V( V& ] .active_low = 0,
$ [! P4 i5 |6 V .gpio = DA850_USER_LED0,
% s! P: r3 K9 G: r: j0 ` .name = "user_led0",
' x, Q# U2 Y% t+ z& p- v X( n3 o .default_trigger = "default-on",0 ^1 v" B: ~9 e2 I
},
$ ^+ {3 v* n: Z' \ {5 s. J% s: ]- n. E
.active_low = 0,. J) `" m D ?3 y: q/ c' ]$ L# t
.gpio = DA850_USER_LED1,8 k8 I% Q/ v. c9 C5 e' l: d
.name = "user_led1",* ?2 O9 N1 |% _7 y2 I) f
.default_trigger = "default-on",
2 [$ v$ I b1 q* n* q$ m },
, Z+ e0 h2 a# l. ?" c1 D2 s {1 ^1 @7 v0 ]9 L7 G
.active_low = 0,$ g8 [+ p; o) ?" F0 M1 `1 E
.gpio = DA850_USER_LED2,
' n P. r" B! e: D" M .name = "user_led2",& h. n m$ \+ z
.default_trigger = "default-on",7 k+ A4 b* e! z4 |
},: w2 k* z% a& Y# P0 H% j
{; y: L! @% ?9 W' r/ D9 E: X1 a
.active_low = 0,: ^+ ~# \0 Q; q% P
.gpio = DA850_USER_LED3,3 y7 X, V' o0 H9 s6 N! D) s
.name = "user_led3",
/ Q9 Z3 U5 z/ }4 @& Z .default_trigger = "default-on",
q7 Q! V( s$ c6 N% p5 Z, Q) a },
- o' g9 B. l: P7 d9 t};
' q2 j( k8 w! U6 ]5 ?) J' c1 o
w7 Z% Q" y( }/ @* z: [! qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' N; t" v% `# W2 \ .leds = da850_evm_tl_leds,
. y8 \# A. p! P! p, t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( g' F6 ?9 h" L! C9 @5 U* R# x/ h};
* u' ]- @! s6 N7 b$ y" P- D+ X# k& h7 {1 |9 }
static void led_dev_release(struct device *dev)" @; L) g, h5 n
{0 a5 |+ d; H7 T% _) c
};
" A) d. }8 q9 t* H+ z. z+ Y1 p
1 t3 S8 \8 e' I4 K. ostatic struct platform_device da850_evm_tl_leds_device = {
; g& x. T/ P4 a/ R- e .name = "leds-gpio",! W% v% S" L0 } O, Y' u3 V
.id = 1,/ C0 _: b: _8 Y8 O+ ~% v6 Y0 P8 z
.dev = {
. Y: W$ `. z3 a8 S7 D- d .platform_data = &da850_evm_tl_leds_pdata,( x4 D" J2 N6 H5 G+ V
.release = led_dev_release,) t3 f0 a, T) E
}) y" ~/ q6 q9 [9 ]. c- J
};/ c' k0 J( J/ Y
; p" N# s n' [5 \' istatic int __init led_platform_init(void)
" G2 d8 x' L/ j+ H' c{
. b% I, ^* b. i; Z) q! k* I int ret;% x* Q: ?( N* s' e% ]" ^8 x: N! V9 K
#if 0+ Q& |: A7 x7 h" K9 `1 V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; f4 W4 K8 q c1 r8 D* ? if (ret)5 y# C- R! K( p+ ~+ C8 b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- [% O$ h/ J9 t- P0 z4 i5 W" a% N
"%d\n", ret);/ N: `$ I8 `6 U) S+ B+ ?2 U
#endif
% f7 ]5 v5 I' f! R ret = platform_device_register(&da850_evm_tl_leds_device);5 \$ Y X# B/ L/ q
if (ret)
6 G/ F# W8 I+ S7 I* E# P pr_warning("Could not register som GPIO expander LEDS");
4 J1 m* n) d' Y1 E0 ~( _; F' e B* }- ` else7 X0 g, A9 z( v4 E; s
printk(KERN_INFO "LED register sucessful!\n");! `2 `* y! E7 u
2 |0 _+ ^8 u& D0 t
return ret;
- |) U/ `* d5 l3 a3 \8 ]}' [$ X! f$ M" U$ ?
! k' U2 e% Y5 P4 m& R0 R
static void __exit led_platform_exit(void)
8 z+ E; a' {$ A& h& g{% ?* e8 |* f- P* u: H; Q# W9 e& q: O
platform_device_unregister(&da850_evm_tl_leds_device);2 N7 U1 P+ ]/ A0 l/ @; o# y8 a
, T$ H, C: u5 P/ Z, j printk(KERN_INFO "LED unregister!\n");. L: E! Y/ ?4 j
}
7 F4 O/ X- Q; }; y6 P' k4 ^) U: T5 I
5 T& u% K$ D% h8 ymodule_init(led_platform_init);
5 B( m/ C3 N: i& s4 Umodule_exit(led_platform_exit); }9 R. h2 f/ n6 I
1 ]+ F: K4 R5 P7 l& B3 uMODULE_DESCRIPTION("Led platform driver");9 i7 {. C3 v+ F* i2 k) f
MODULE_AUTHOR("Tronlong");
0 h+ g5 O; P; vMODULE_LICENSE("GPL");
2 t& {# y) d& D4 ? C9 Q
9 G2 | N% s5 x% c1 U2 j |
|