|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 R8 t. t; u; s1 O$ D' `
#include <linux/init.h>
2 _& r# F$ f$ s* [' I- z#include <linux/module.h>
5 N' y3 o, b) Y8 ~$ q6 I( C/ S3 j#include <linux/kernel.h>
! H/ n" T3 E+ V. l#include <linux/types.h>
0 }7 _# t+ f8 h9 [#include <linux/gpio.h>& h+ O4 R% ?4 s0 T* h2 G! u' W
#include <linux/leds.h>; o: D9 Q# \# ]! F- _
#include <linux/platform_device.h>
2 }) B( V4 I t$ S# X. p9 u3 ]2 k" N/ X2 f/ S' \0 w
#include <asm/mach-types.h>
) d% S! n& X/ I; e- c" j3 I#include <asm/mach/arch.h>/ H# v! e' Q+ u) F
#include <mach/da8xx.h>
; l V# i# }2 V" h#include <mach/mux.h>$ p& V" a. k2 J5 H# h+ ]$ j
' `& `& k. i# T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
`- M) ?! O5 A; O' X5 d+ o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* O& ?. z1 K: Z0 \0 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): `: {( Y6 ]5 K/ j9 [* O1 D3 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! i7 t) i, @0 h' Y
( v4 B' r+ P+ ]& C6 {# p' b: P% x/* assign the tl som board LED-GPIOs*/
' S$ F v% s6 b0 _/ K2 J3 W9 k* Cstatic const short da850_evm_tl_user_led_pins[] = {& B8 E- Q" v" n
/* These pins are definition at <mach/mux.h> file */
& Z) B o0 {" r; o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 N% l( t9 } P7 C- U2 { -1" q$ m/ E7 P, `" R1 B
};
5 } d* g2 d$ `' O% Y: L: b8 m0 J1 m& S3 M" q
static struct gpio_led da850_evm_tl_leds[] = {
2 C' }/ `. c- v# ^2 { {; @* e5 T! S: y/ n9 r9 U
.active_low = 0,
1 ^3 `% k0 P5 ^$ d& @3 n .gpio = DA850_USER_LED0,& y. u% j7 f v+ M# o8 I
.name = "user_led0",1 E2 ~( I+ Z) Y% U/ ]
.default_trigger = "default-on",
' w8 a6 F: w. y4 e) q, U5 R; z8 G9 { },; S6 T; {4 K# _* Y, [7 B
{" Q4 C" b! c! S- c2 d0 D1 M
.active_low = 0,
! n8 U9 r2 P! r! x9 f4 B .gpio = DA850_USER_LED1,) @/ y F3 d0 ?- {$ o" z; x
.name = "user_led1",# P& O4 [8 V% r( T, h0 a
.default_trigger = "default-on",) p% I# J9 ^3 }9 j
},/ o# U7 A/ p& C5 u2 w
{
$ K+ S- d) B, c! f1 @ .active_low = 0,/ K$ |- M |2 B- o0 `
.gpio = DA850_USER_LED2,
& ]4 p" Q3 e5 d' Y/ q .name = "user_led2",, m- m1 ~) k. E, Q8 ~0 }
.default_trigger = "default-on",
$ J( z+ R% y. R ^! \1 ] },5 f3 N! U( E7 r5 O1 p
{! }( M. T# o7 I- N2 j7 x3 Q( c, T
.active_low = 0,
+ Z- P- {( Q; v0 n) P$ s% O .gpio = DA850_USER_LED3,( I) r3 H9 r z' U. ?3 R
.name = "user_led3",
7 s. U1 i j; S .default_trigger = "default-on",( A# c. [$ |5 c2 S% Z/ h4 v7 R
},) \9 q8 ^0 p! U7 g U; A; V
};7 V I9 D4 s2 z: H' U# d( r7 U
/ X5 C5 D- k: a' g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' S/ X+ P6 U+ i9 E! x2 t .leds = da850_evm_tl_leds,$ J4 u Q1 F9 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: T' B* p. h$ z) |! ` r
};
7 k2 j5 I4 R; [( k* k0 l. L3 U- q$ P! g2 y3 Z$ W% l
static void led_dev_release(struct device *dev)
. v4 k3 g6 Z/ }5 b{- D# o7 T' G6 p+ q1 C1 ^) ?
};
0 q6 _4 L5 ?4 P) P1 Z6 O
/ L0 J$ ^* s; Z5 sstatic struct platform_device da850_evm_tl_leds_device = {
; g$ h d0 n) \ .name = "leds-gpio",) N( [. J0 ]. a# h
.id = 1,
7 b6 k/ p/ V- |1 W .dev = {
1 h o V( C8 Z( Q+ d( ^/ O .platform_data = &da850_evm_tl_leds_pdata,' b, o: P$ h" e- Q2 u/ j+ K" b
.release = led_dev_release,
1 u0 r- h$ ~) l) n* E }
! I+ W5 ]* `& }};4 |7 K( C# O/ C. U. s1 L: r6 Q
# |+ }( L( U& p( ?: t! C3 rstatic int __init led_platform_init(void)
4 i) m% }# _4 h/ p1 \( `{
! w9 c/ A5 W$ C0 S1 z' M R int ret;
7 {# V1 J0 u. M8 q#if 0 F: G% R! [2 K. U) n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% e0 k7 U+ I# ~; h5 L
if (ret)
& N) ~$ ~% x3 K' B6 c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 a3 u4 Y3 @; f/ i$ ^
"%d\n", ret);
1 f* d" \4 k+ O3 L" M; ]#endif3 s1 s+ a$ [, V7 L$ N1 T) z; Y) x
ret = platform_device_register(&da850_evm_tl_leds_device);1 J5 q$ Y2 n! D k
if (ret)
# d m2 y2 W/ L3 B8 @/ r) | pr_warning("Could not register som GPIO expander LEDS");7 M! {# o# W0 I# e$ a
else
1 Q) i8 b8 r" ~5 L1 Z+ L4 ^ printk(KERN_INFO "LED register sucessful!\n");, c. z5 ~; I/ \4 X& L* }' W
5 K8 @" i$ B) I+ }; ]# C
return ret;
5 S4 U. g q2 b. ~3 }! x) M}
' Y% J) o5 Z, }& {2 @+ K" j/ ~3 a& w+ g$ g/ |7 w6 L- d4 z
static void __exit led_platform_exit(void). j" U+ Z" {3 D# \9 `( _
{: q4 d. H3 c6 j9 V* x
platform_device_unregister(&da850_evm_tl_leds_device);
& G% B/ r$ _2 z. Y. e; U, x- R% G* R3 k. [3 W. ~
printk(KERN_INFO "LED unregister!\n");
+ Q: J8 e( v g L- M}
4 g0 o1 E b& e7 @% j2 Q' @0 i
5 u' p0 V) _; U! n j3 m/ N: _module_init(led_platform_init); G6 T9 o/ ^( Q5 t. t3 u, q$ N
module_exit(led_platform_exit);
- Z1 v* [$ _$ s K- y# K D# K q% Z
$ B& k( P( A- _MODULE_DESCRIPTION("Led platform driver");
, j' o( @; m' V& W; oMODULE_AUTHOR("Tronlong");1 b' P6 \, L \ L6 [
MODULE_LICENSE("GPL");! r: z" N' _* K
: T; c# A5 E+ B8 h1 M |
|