|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 a, k$ M' M H#include <linux/init.h>
- M% Z: h0 F. }1 I$ a3 N* q#include <linux/module.h>* i9 i' N% q) G) \2 R1 j) U2 ]
#include <linux/kernel.h>
, E0 p) b, U+ ^1 Q5 ?#include <linux/types.h>9 V9 l+ a3 e8 J" [5 P% H& t
#include <linux/gpio.h>. j2 j3 Z2 a% L
#include <linux/leds.h>3 x* ^( r- Z; T$ V* i7 w' h7 e4 ~
#include <linux/platform_device.h>5 ^3 D) L X2 Z: C$ q
; d' F! u# r1 u$ \- N! Y
#include <asm/mach-types.h>
+ x$ t; y( [; U5 {#include <asm/mach/arch.h>
9 g0 e7 ]/ L0 e3 m#include <mach/da8xx.h>$ Y t9 ^4 E7 \9 c- p4 t
#include <mach/mux.h>7 f: h5 ^# I! ~+ E: ?. W, l
$ I6 `* z$ Z$ E3 ]5 _2 O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 p, Z9 ~- q j; L0 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- o; {. }! }6 G( P' s4 x g4 {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* ~2 y1 h$ D8 C, Q6 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 K y8 Z/ Y y+ k
+ z' o; e) Q( T! P# |/* assign the tl som board LED-GPIOs*/9 o: X! A. {+ ]+ f+ ^+ R
static const short da850_evm_tl_user_led_pins[] = {
' @3 r2 X& T) E4 h$ @" l /* These pins are definition at <mach/mux.h> file */- C% E' \: S N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' O# B# P% B9 G& L: U* U. ?# s -1; V/ j, |# b+ L4 \* n! w1 M
};
1 {$ t9 {) C0 w5 A( E6 ~$ E
% }2 A+ L. P/ F2 ostatic struct gpio_led da850_evm_tl_leds[] = {; A/ l6 @- g1 K Y3 u- {
{
- B2 z' {- J v6 s .active_low = 0,
- Z, H0 ?( G9 x; \9 R: X .gpio = DA850_USER_LED0,
5 v$ ]7 T- X* Q8 `; V .name = "user_led0",
9 R* ~8 }3 V, \, h .default_trigger = "default-on",
% U2 u( D# ]# w6 }9 z& S; e( n },+ p) o; f( ]1 V" @0 m% u; f( L
{
4 y6 u. D5 R7 J. m .active_low = 0,9 P9 k1 E8 z. L! ^% b1 r) p ]
.gpio = DA850_USER_LED1,
+ o B) W2 [2 ^3 a9 q; G .name = "user_led1",( F% t) n/ o" O& t: h0 a( a+ G. X! [
.default_trigger = "default-on",
4 z Y! ]; n: ` M' q$ I },
2 H2 d+ |3 P/ E. B {
- N1 E" f$ m1 t- i ]( W5 F4 r m .active_low = 0,7 b# b+ N6 P7 ?# _
.gpio = DA850_USER_LED2,
; M& A- i1 }5 G8 m3 F .name = "user_led2", _' u2 w4 O: o* n4 `
.default_trigger = "default-on",
$ f# C: `' D- N; I0 L },
" t+ E' D6 h3 n0 t {
( }0 H" E- @) E+ B* L# _ .active_low = 0,. e6 ], S1 j% v
.gpio = DA850_USER_LED3,7 }/ T; w* j5 n6 L7 b
.name = "user_led3",! t/ g6 G; S' z5 C7 B
.default_trigger = "default-on",
( x: ]3 g( {* D, O9 W0 m& r9 H% J },2 T. O+ U0 \! v; y5 a2 J- r
};
4 u( ?- P5 h$ M' P8 a9 c( X3 n
Q# x6 s! u( v6 i8 ]! o* rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 ~" B: q8 i% @, D$ P) y" o7 d+ V
.leds = da850_evm_tl_leds,
& t. P T4 i# s9 m: x7 Q- r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. a) @. } ]+ v3 Y& F
};
$ n& y5 D& t% ? N% q
5 H; r- S6 G% dstatic void led_dev_release(struct device *dev)
: ]) x1 P" @, I5 `# H{
! ?+ h8 W$ S$ P3 O2 J};
8 S) ?0 t5 n; h! N6 o9 E# c' `; U3 D8 c0 l$ t+ F6 V- M4 x) d
static struct platform_device da850_evm_tl_leds_device = {
. r4 l. i* J) a9 x$ J7 e .name = "leds-gpio",
! K" a2 G8 \# _* R5 s8 A3 u .id = 1,
% ~# H8 w% | K: [ .dev = {2 E6 P; q; @) }8 ]4 r6 X# U
.platform_data = &da850_evm_tl_leds_pdata,! _% f9 f- I Z8 ? i
.release = led_dev_release,
8 @( A, ?! u7 T* I }
' q. i' {/ R- a6 A$ z" x- g6 p+ c};
5 K; w& V- X0 m6 i
$ Q& k8 h" D9 k8 M" A6 xstatic int __init led_platform_init(void)* `' g; y( t9 b3 k2 C
{
$ ]7 l8 q1 j9 i7 B! A int ret;+ Z$ D9 X6 c/ M# C2 b* d
#if 07 e+ T' L/ c& h! j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* F8 g* z8 [# I! { if (ret)0 k6 j7 i$ _, z, {. `+ U% Z+ ]' F, z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" O3 _* B6 H# i) z; ?, D, l& p0 z
"%d\n", ret);
3 F$ K/ ^& S8 d! ?4 u3 X#endif2 F a9 v6 k: w& i( Z
ret = platform_device_register(&da850_evm_tl_leds_device);! B% I! f- L, O0 n$ l( Q N
if (ret)
6 s5 m3 q9 G' R) c# W) m pr_warning("Could not register som GPIO expander LEDS");2 d6 a" Q" e, Q" l5 ?8 \# @
else
8 ?: t. N" O# z6 U printk(KERN_INFO "LED register sucessful!\n");
. S8 S2 Z* N6 D- q! Q& b
; _' X7 t# x% | return ret;
& s: ?. C0 H7 ^4 A" }}, z8 O. @4 ]9 f h, X, y
5 r9 `% q) Q' }; r' E$ ?- \
static void __exit led_platform_exit(void) n* F3 Z6 q( T# q, X; E
{: U/ Q0 P8 Q& I, p
platform_device_unregister(&da850_evm_tl_leds_device);' [% B& x5 M9 `3 H( E# B* f
1 t* `8 F8 O' `
printk(KERN_INFO "LED unregister!\n");
D" D. `! A& F+ g/ e% E}6 ^3 W: a ], y: |
) i. n7 D; t8 e; Q/ c) ^+ { z ~1 Vmodule_init(led_platform_init);
9 O0 \# V+ B( C* U7 ^. h' @module_exit(led_platform_exit);
) W" ?; F' t' R6 h& W7 ^8 Q8 w. f9 F) W
MODULE_DESCRIPTION("Led platform driver");7 M0 G4 w; H% v
MODULE_AUTHOR("Tronlong");
7 R; H! ~$ f4 A1 l( P4 CMODULE_LICENSE("GPL");" o8 ~* |* \8 L5 w' W. ?
7 D$ W0 q: H" P1 B |
|