|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 o0 `) T3 ]! S#include <linux/init.h>/ W& p: k9 g n
#include <linux/module.h>6 A( Y. _" U9 i t7 j
#include <linux/kernel.h>. F$ a Q3 \# u) x, {% }; w& `" z, }
#include <linux/types.h>0 v, c, G5 |0 O! L" J( |
#include <linux/gpio.h>
1 {4 m( m! Q9 w* u$ ^#include <linux/leds.h>
6 L/ B j) {: w% |#include <linux/platform_device.h>1 P i, p6 [* a/ n7 ~/ X r
& y0 n: n1 j1 r8 p* X
#include <asm/mach-types.h>
0 B2 z: x7 w1 J6 M9 B- J1 E+ Z#include <asm/mach/arch.h>7 j6 Q6 T2 C3 C1 U* e4 Q' ^
#include <mach/da8xx.h>
$ C3 ^' m1 l- I0 Y9 ]#include <mach/mux.h>
6 a7 L+ W; K! O( s$ T+ M1 W6 v5 w, k* B. ~ j0 O0 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 u. R( N6 L, e5 z/ \ O& @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! c9 J3 M6 Q* h: h) R# w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ L; p8 Q( }# V* O! N+ z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! R# |8 |( ]) v$ C2 [2 n) x" D$ C
, g; W! \. }% q$ r) ?5 Q5 i9 [/* assign the tl som board LED-GPIOs*/, @8 j0 _$ r! P9 R3 U" [1 r
static const short da850_evm_tl_user_led_pins[] = {
9 N8 _5 Y) g' y# }* ]& v4 B /* These pins are definition at <mach/mux.h> file */4 L3 e p- O! F8 {' `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; N% H _' D$ Q6 ^2 S4 _$ n9 w2 I -11 o% g4 W6 d) _0 ]( q9 R2 h
};
+ r% f9 |; Q+ F" O9 \) w
2 a3 l. D: b# y& {/ bstatic struct gpio_led da850_evm_tl_leds[] = {
' d1 w$ z% X5 Q$ j {" B& {# ^ N0 t# t+ G* C. L! f
.active_low = 0,- { i9 e7 D9 Z. U! d
.gpio = DA850_USER_LED0,
/ g* ?: p; q1 }! I, {' l6 H" Y Z .name = "user_led0",( Z: F& D8 s; }
.default_trigger = "default-on",% e6 i4 t! z" S( d
},- P% Y/ J) V& T; i- J/ j8 i) \5 y5 L
{
; j: h) W+ B# `5 h0 {/ F- o .active_low = 0,3 a8 Q& S# w0 N* O& n) C
.gpio = DA850_USER_LED1,
! H- R& D2 D, [7 t' q% ` .name = "user_led1",, f# j+ M+ R9 [- u- ^5 |
.default_trigger = "default-on",$ q0 V4 g9 I4 L7 }" r, P. o5 |
},8 Y! k O! T E1 `
{, h0 B. i. x+ t
.active_low = 0,+ e7 c8 P; C" s3 [* K4 F
.gpio = DA850_USER_LED2,6 S+ D6 L/ U8 F6 |9 c
.name = "user_led2",
7 h3 x1 X3 ^4 X! K2 b6 C) L; u1 w .default_trigger = "default-on",
) s% d: Z: P1 \; o# Z },
1 e" u" {- V8 w5 ^ {
9 r4 T' l F3 K# k9 d" ?6 V .active_low = 0,
5 }$ `2 E% U. } .gpio = DA850_USER_LED3,& b" `- D" j8 |( G
.name = "user_led3",+ j+ B6 G( n, M2 x
.default_trigger = "default-on",
! |8 z+ n$ W+ }! ]3 D2 E },
/ W/ U) X0 z. g& E: o8 C};! G- ~2 E9 M" z0 b8 `5 ^
$ C5 ~# ?" E: D, E& d1 J6 U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" f" t) ^# Q+ ^9 X* K7 ]1 t% S
.leds = da850_evm_tl_leds,
7 Q! T9 o2 P+ }9 i; T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 C8 O. G2 y8 _, J+ [5 L, t! K q
};, c# [) a6 b" c, I3 w2 f/ w
5 Q5 @/ e6 z/ b+ \" p8 F2 qstatic void led_dev_release(struct device *dev)
& H- I* j5 Y; o; u, t1 l{
( L0 G/ S6 q9 Z0 \* c* D};& N5 ~: ~( S* T$ {; i% U
! m6 d4 y# o# N# S& T* V
static struct platform_device da850_evm_tl_leds_device = {% v! h- W$ I% g8 r0 o+ N) i
.name = "leds-gpio",
' Y v) t8 p9 |0 X4 m .id = 1,
$ I. E! a/ P; U .dev = {
# n, }# `3 E! C2 f f. ~& m% s. Z .platform_data = &da850_evm_tl_leds_pdata,2 c" o& u- g3 k6 t, @7 `
.release = led_dev_release,
@; \) `2 D1 z* b# _. w& \0 U/ j }
6 v5 H) k# y w; b/ A! B9 ?( b};- m2 ~! U5 o1 k. k; L
% b! n2 R6 K) P4 i( k9 q8 @static int __init led_platform_init(void)
( F, t# o9 P, D; `{
6 J+ h; v% F* h! z0 b int ret;, d5 h- ?& t9 j% `) e! n7 }/ z
#if 0
1 S7 c* g/ N6 Y: y8 y9 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 j0 Y7 V. f" {6 D- H* T* G- h
if (ret)! F- h+ ~* {+ m" q7 A# O5 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, I8 b$ _- y% v( N) n4 U# U "%d\n", ret);1 a6 Z' c# E* r5 |2 y; y# t2 m
#endif
% @) y+ o7 I3 f: u ret = platform_device_register(&da850_evm_tl_leds_device);
' V' J6 a& z0 p if (ret)- K- t' D8 a+ c! j
pr_warning("Could not register som GPIO expander LEDS");
: M' W/ _1 K% d! r3 Y" M else1 T8 ^. B. Q. J( m9 V& I, p$ y
printk(KERN_INFO "LED register sucessful!\n");0 I1 K% x& B/ e+ [. S% X
1 s6 C9 g% L6 ]" r+ P
return ret;& ~0 i9 E' P9 j
}. C5 P2 p2 A+ S3 u6 T$ i) s4 S
- _+ R" K3 u1 J& c' C, T; {static void __exit led_platform_exit(void)
6 ~/ X, L/ n( ^& }% i* q{
: L, w& T7 K- v& q4 {+ o$ U platform_device_unregister(&da850_evm_tl_leds_device);
/ }2 C( x$ p6 j# b9 S
- _; h2 {1 {: ~ printk(KERN_INFO "LED unregister!\n");& P n( N3 c: O; Z5 D8 h Z
}/ a) P* L5 f9 Z3 Y" ^% {6 [5 ]
& y8 |+ E- M- B- n! t4 k
module_init(led_platform_init);9 H& F& L/ O2 D+ Q- F) v! x1 P
module_exit(led_platform_exit);
$ w& j# u' X% W6 O+ u# a6 v' W' B* ]4 ~6 f6 A! j6 z5 a
MODULE_DESCRIPTION("Led platform driver");) w; D, K. R( D R( E
MODULE_AUTHOR("Tronlong");
+ j# M ?# ^+ B) o6 R% c! PMODULE_LICENSE("GPL");8 O4 N2 M" m9 C/ g% H$ |
0 p/ g& b- v& y- E9 f |
|