|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 @: J3 @1 H5 @) U" `) @#include <linux/init.h>
4 @$ K. n- f# }6 V2 M#include <linux/module.h>! C# S# O2 T" }, T+ e
#include <linux/kernel.h>: I1 {) E$ ]3 A
#include <linux/types.h>8 L. [) e9 u1 r- z
#include <linux/gpio.h>) W6 W- [. C# Z' Y0 k# P
#include <linux/leds.h>
* }3 V/ t: ]0 k: ]5 }#include <linux/platform_device.h>+ m9 Y9 C9 m: ~5 `0 V
2 q7 Z, q2 E$ Y) a
#include <asm/mach-types.h>. Y% v, q+ M( u, U( h
#include <asm/mach/arch.h>
" n3 h% Z' R& Z2 i3 [" z5 \#include <mach/da8xx.h>1 W7 v' N! f9 m
#include <mach/mux.h>; C y+ J: w" {
0 X* e! M3 T0 c9 |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 }7 S4 f8 a6 _, o4 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 A- t9 W |9 E9 `1 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( Q8 B) C1 i5 H! U; t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& b; V# S! `. E7 M6 R$ _
3 d" k0 H R4 V3 N- ?1 `/* assign the tl som board LED-GPIOs*/
. J2 s+ z ]) o# Estatic const short da850_evm_tl_user_led_pins[] = {; m! L% m0 K* f3 i- {. D
/* These pins are definition at <mach/mux.h> file *// U0 g7 i9 o& {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 Y* N/ s3 C& I( P# U9 \0 }5 r
-1- K% j: O. t: x
};
4 b% n& E6 Q0 [2 E) w% k" y3 ? x8 P7 {
static struct gpio_led da850_evm_tl_leds[] = {
* W# |1 A2 R/ X: h! A8 m4 F {
( c6 z3 }$ f& T- G# A# l0 { .active_low = 0,
( |) w1 ^2 U$ ?5 T2 ], N .gpio = DA850_USER_LED0,. c- e) J- i4 a5 K- t* D
.name = "user_led0",
* h2 P' x" r; K- V0 c0 ~ .default_trigger = "default-on",0 W( o$ A t) A' f9 L- T% G
},) F) j7 E" l. J% Y
{
) d6 M5 ~" [- C) o .active_low = 0,
1 s" c: m; s" a* x7 w9 X .gpio = DA850_USER_LED1,
8 e6 e5 A) T( J .name = "user_led1",
0 ?+ T X% _# z# }" r, ~ .default_trigger = "default-on",$ p+ h1 \+ e/ N% Q& t
},, H0 V/ q3 f4 Y- }
{
t q" Q* S& v& K# | .active_low = 0,
|- b6 ]: T8 t6 q1 ], W .gpio = DA850_USER_LED2," k9 q& v8 k" w1 K! \% y
.name = "user_led2",0 z8 O' t O" G; i$ W* @8 \
.default_trigger = "default-on",9 f+ ]" q5 }% e( K1 N* ~
},
9 {6 Q2 q& D5 Z. a/ R {1 E8 m6 l% q0 e# h
.active_low = 0,# i' i S2 n; X6 s- F/ J
.gpio = DA850_USER_LED3,3 q* v N! S, m' b: X
.name = "user_led3",
1 V: {: c U' \/ J( @* I .default_trigger = "default-on",
5 g" ?5 G$ h' j9 j! f2 D },
( k! Q- B$ W/ R7 {" U};* a) o$ Q+ m- J: X7 B
& n4 z) y1 ~' j$ z' N1 S: X4 y# Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ w) U$ i, T7 b, i5 p
.leds = da850_evm_tl_leds,
+ H: i5 P. _/ P$ u3 x- A* T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 W, M+ u4 M! u};2 S' ~" ~( S0 `/ q j) n4 k
$ o& B1 X( Q; ?1 s6 F
static void led_dev_release(struct device *dev)
2 i, e1 H: F% w: M& H3 a( }{
4 O- i1 b) X% _/ r: l$ w}; i2 f0 Z$ c$ O, Q) V
, |' B0 |/ d1 E& d0 n
static struct platform_device da850_evm_tl_leds_device = {
% u+ x- W# S9 J! ~$ V: A .name = "leds-gpio",
7 Z: G4 @) ^3 t, j" I' p2 H$ A .id = 1,( w: B1 u) O5 N$ w
.dev = {
) Y: w# ~& q6 M; y .platform_data = &da850_evm_tl_leds_pdata,
6 U* u# N7 c0 s% d7 ~ .release = led_dev_release,
: Z2 ], t2 Y- }7 I }, Q' Q- s& f. `
};
* Z7 k; N" w9 `# W9 g3 ~( U' [1 E" t' K
static int __init led_platform_init(void)
- _$ W; _* W E& y! J{$ {. U+ d7 H* E, i$ a: k- t
int ret;
w( j L3 G& F+ a, Z#if 0
* V" Z& H6 k. h9 ?5 C7 H! \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 | j3 @* E9 U3 ^ if (ret)- S% B) O4 m% G( \( Y' \8 y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: c9 m* J0 Q3 }: A9 { "%d\n", ret);
4 k; u5 E# w6 z9 P+ @3 e( X#endif' ?3 @+ F, y. P! E; J8 O J# p) R
ret = platform_device_register(&da850_evm_tl_leds_device);
7 E3 z3 K2 N4 u. W if (ret); Z$ y! r: I: Y* Z6 g6 X2 x
pr_warning("Could not register som GPIO expander LEDS");& v) t( H0 J- @6 m) l* ~9 G
else
' G/ T: H5 J5 V* V3 B9 J5 V/ V$ f printk(KERN_INFO "LED register sucessful!\n");% W/ i% X+ l; V
% P6 o* B% b- e+ }/ z3 m return ret;
! \8 G6 x- x4 d1 _2 h3 J3 o}
: j( K' Q) f F+ _ ?7 k6 x6 `) c1 p6 T
static void __exit led_platform_exit(void)9 {+ s3 Y0 k9 d
{+ ]2 O7 P8 O, D, d2 s
platform_device_unregister(&da850_evm_tl_leds_device);7 ~6 ?' j# M( |# T1 u+ r( t
; [( Z6 n5 J" e printk(KERN_INFO "LED unregister!\n");
# l3 A1 Q7 `% k. y* M! }9 V h% H}0 w1 u( l( _+ Y
$ M% X5 @' k: M5 n
module_init(led_platform_init);+ Z$ y3 b' ?! P2 S' Q/ i
module_exit(led_platform_exit);+ T* e# { t" r* Q$ o; s
! E. y- [3 w( i6 V- s4 j$ k& xMODULE_DESCRIPTION("Led platform driver");
# d- E% L9 F% Y/ m: Y" x4 AMODULE_AUTHOR("Tronlong");4 o& s' h* l# V5 h0 C
MODULE_LICENSE("GPL");0 S* M4 `0 H( W( f/ }: U
4 n( z# A* V" P! k: k$ a- h4 ^, u
|
|