|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 {) W- G- f) {; p' S2 e#include <linux/init.h>
. B0 h! L9 n7 D: N+ i1 u#include <linux/module.h>. ]: }. S. ]9 {* u
#include <linux/kernel.h>
& s0 h* J9 m5 t#include <linux/types.h>4 e+ ]" w: B I/ E+ B# P# \+ F
#include <linux/gpio.h>3 y* v7 I$ }" C. e% g, O8 C$ P
#include <linux/leds.h>
$ w6 W' Z2 g: y/ K, f2 j#include <linux/platform_device.h>
& R# F1 @( ^: d: L* _
* e; `9 z& o. p3 r s#include <asm/mach-types.h>$ Y+ _- ~3 r4 Q5 h; M: W
#include <asm/mach/arch.h>
% P& U5 L. |+ _+ E, S#include <mach/da8xx.h>+ `4 P% J$ N, W
#include <mach/mux.h> J T) \2 s( K) t) x6 i
$ J8 o: v* W( ~ [2 i% @) \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), v# c8 B; a( R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: h4 n6 g; K! W3 }5 g# G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, m5 `* n! T8 {. U3 O0 g9 {4 _4 T2 G! n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( ]# P& u& c5 @5 u1 H
1 h; z/ [& g6 O( r/ y$ T% f/* assign the tl som board LED-GPIOs*/
5 V% K7 ~5 k0 y+ A* J/ Rstatic const short da850_evm_tl_user_led_pins[] = {. D0 Q9 W$ i+ M% L! F; g5 N; @
/* These pins are definition at <mach/mux.h> file */
$ w# [5 b. @% V) u- D" D' K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 F8 J) a" I# d
-1
2 x3 K- N6 e( r$ F" b2 y# v( M};
{1 h! F1 R% P. N9 C
! e0 @ J1 @: A M6 ?' G( Zstatic struct gpio_led da850_evm_tl_leds[] = {! d( x2 d1 w3 K6 n) e. d
{2 p/ g1 h) b6 n2 i. ~4 O$ w
.active_low = 0,3 J0 a/ d# J$ D
.gpio = DA850_USER_LED0,6 Z% u! u# d; l8 q7 ^% m1 Z
.name = "user_led0",: I2 A8 ?5 ~3 x k5 G
.default_trigger = "default-on",7 p+ d+ p% h7 _/ p
},% Y# k$ c$ K+ D* H+ G1 A( `3 C+ r
{
6 L! |8 {% }& e/ N6 G .active_low = 0,
6 X- s* \/ X- W3 C/ A .gpio = DA850_USER_LED1,6 c1 P% w5 c/ t# G, Z% u3 s0 V
.name = "user_led1",6 K7 v: D& S/ ^9 Z& C& k$ `
.default_trigger = "default-on",
7 R# m% }' |( k' D! V },
7 s& u" n# u L: f( I {3 o4 k6 Y4 ?# Y$ E# |& V, T5 ?
.active_low = 0,; P+ C% x3 p" g z" X* R
.gpio = DA850_USER_LED2,
! y) m5 u- V2 v! Z6 i' t .name = "user_led2",* F, h5 E4 Q& g7 s
.default_trigger = "default-on",! K o& `9 ]) k5 t& c. h8 g5 L; f
},! i) n/ v$ q% Y4 a8 a: L1 [. e1 K
{/ I" r7 `( y& ?4 @* I4 k( W1 u
.active_low = 0," v6 H! `$ p# q. p+ Z
.gpio = DA850_USER_LED3,/ x! J& i8 u! g o: ^/ J9 H
.name = "user_led3",$ M e) f( ?1 ^' {3 u2 A0 G$ l
.default_trigger = "default-on",
* @' A D) X+ N; N, s& i },
( z- V2 s- ^4 X$ ^# Q% G% v1 K7 n};% ?+ K5 _$ }; i# H. P' E! w
, K; k [1 o1 D Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' p/ o S, C' y4 z7 i$ n* M1 l5 N .leds = da850_evm_tl_leds,! y( R+ z$ x9 f W' @: w% G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' ]: r3 V' G( l. N; K: t1 m, O* G};5 E' l4 G1 }* Q4 `) O9 m( R
* X! ?. L4 m# n
static void led_dev_release(struct device *dev)
6 l, ^1 J B1 _- n* \ _* r{
H1 b" W2 w' e1 i};; Y' y- ]: Z! l' H/ N
6 B/ A8 _3 S( M$ C5 Q+ mstatic struct platform_device da850_evm_tl_leds_device = {
+ g! D* I. u: A8 p6 A .name = "leds-gpio",
+ d" L* d" P2 U0 z- I .id = 1,& @) G" ]7 _! u0 |5 \( M7 K1 P3 O$ c
.dev = {( @* V+ Y% g* o* ~* _. i
.platform_data = &da850_evm_tl_leds_pdata,
; u8 u* K- z: I( \5 @! P f .release = led_dev_release,. H8 o; T# C1 Z$ Q) O% C9 Z, K* V [
}; c" M6 H. Q0 E' K3 m" u1 C! \9 F4 a
};
1 y; ^; ?4 e& O7 d3 Q1 [1 }- o
5 _7 e# N* P( @+ astatic int __init led_platform_init(void)9 R0 T2 |: w& f F8 T
{
3 I. H, M6 w c( A8 {! J- ]" L int ret;! G9 I9 y3 G0 ]3 i# | @, \: g6 g
#if 0
* }& U) o4 G! f) O) N# @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" C8 L9 S+ z3 ^- j* ` if (ret)8 f+ x; ]( u$ _9 H) z7 H: ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ i% t5 [7 o0 e ?! e1 a6 @0 v
"%d\n", ret);
. K' k; h( @. J' f* t: f8 O |, ^0 f#endif+ D# B; | O t6 e3 `/ f
ret = platform_device_register(&da850_evm_tl_leds_device);3 |6 X' M8 K4 Z. O% d# g8 @4 N' V
if (ret)
+ k1 J" X: Z- Z' H' x" |0 o7 { pr_warning("Could not register som GPIO expander LEDS");
6 i; v( j5 i) X. O3 i3 @ else
8 A9 ?9 U0 ?- L) A' } printk(KERN_INFO "LED register sucessful!\n");9 P# c' Y: ]# c: r4 E# l+ d
1 x! a+ U* s; p% F* M) `, X; v return ret;
6 Q2 G1 [7 c# b' g5 O' M! D}
' f; |7 x' i4 P a5 Q( _) ~0 U. ~: M$ _4 v. ]1 ]
static void __exit led_platform_exit(void)
; {* B$ T4 c- e5 B3 S7 S{
! W+ h/ D7 \1 c/ m1 h2 h# `! W& q8 H platform_device_unregister(&da850_evm_tl_leds_device);) Q7 x! P6 N- G
. l8 }2 F& H+ M0 ^, @
printk(KERN_INFO "LED unregister!\n");
' ?, t/ }/ {6 {* d. q}6 P- h: i) p$ _# X3 D7 o) v c! ?
# u6 }( g- N( P1 c; h, i
module_init(led_platform_init);
7 M) s9 B& U0 h U2 omodule_exit(led_platform_exit);8 d. S' a; U& K- p, e( _
3 A- h- e' d# b' x- k5 `
MODULE_DESCRIPTION("Led platform driver");
' k& `( \0 X% i! R+ MMODULE_AUTHOR("Tronlong");
* O* L1 `, z. E' r6 aMODULE_LICENSE("GPL");
: Y% t0 |2 a* B
( C2 A8 r4 X6 o |
|