|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; B+ @) }5 ]+ ~% f3 N
#include <linux/init.h>! T/ f1 h9 J1 _
#include <linux/module.h>
9 y* x h! i4 F u7 j3 m#include <linux/kernel.h>$ s' m( q6 c( ^2 |$ r) t; _
#include <linux/types.h>8 ?8 L2 U2 `0 m5 g" { {
#include <linux/gpio.h>
+ K/ M; d( A! Z1 e; @+ [' }#include <linux/leds.h>
* l0 c! H$ K: [. g0 \#include <linux/platform_device.h>4 T8 a$ K' j/ N' Z
. [9 p X+ s+ {1 Z6 s#include <asm/mach-types.h>2 h5 l8 Y, l R6 M
#include <asm/mach/arch.h>
} O% Z0 p9 _3 q4 {5 j) {* A#include <mach/da8xx.h>3 b' @" D d" ]8 V3 V e
#include <mach/mux.h>
5 j( S* p9 a$ W/ I4 H
5 n. l4 ^# F. O h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 ^1 O! i, z- i0 C2 H/ `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 F) p: G) @% b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ u" ?- j' m" U/ c. G3 L' D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- i' f# e: D9 R9 i2 t& I, |6 S/ z/ c, ~. F/ i0 e+ n* O
/* assign the tl som board LED-GPIOs*/$ N! M5 Q5 M8 ~ A) {. _ x3 C
static const short da850_evm_tl_user_led_pins[] = {
$ y' U2 _7 s/ J+ M /* These pins are definition at <mach/mux.h> file */
0 e- L/ A. z$ m! f" p9 L2 B d, U- D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) P y5 F9 g. Z# y
-1
% F' F# Y0 h; j7 C# B};) i! [% M( B! r H
+ i. t9 j) l9 f" W$ e% Y
static struct gpio_led da850_evm_tl_leds[] = {' g( T& c5 `1 Z& N
{4 E9 W/ h) z/ w3 a) n
.active_low = 0,
6 B4 i# p& W6 _. a |3 k& Q .gpio = DA850_USER_LED0,0 Q( D. O# Y7 z
.name = "user_led0",
+ d8 q' P& ? `7 ] .default_trigger = "default-on",1 C4 _* a8 h. N& g8 C
},
+ N, i5 t7 w: r' A+ L D {
) p; B! V2 t+ I, D; l1 R. q% J .active_low = 0,
$ S8 w0 z2 C% p" ] .gpio = DA850_USER_LED1,' K0 ?' Y* G1 P+ r* B
.name = "user_led1",
) o( a' M/ W. Q) m2 u: \& u$ x .default_trigger = "default-on",
: B( n! C: k2 n4 i3 n: s2 Y3 n },: e* C5 Y" k3 T6 x
{
$ ~4 {+ {& N$ z# B/ r .active_low = 0,
, O7 z( B, e* R/ s; Q- M .gpio = DA850_USER_LED2,' t1 O+ v" s) I# q/ P4 T2 C8 f
.name = "user_led2",% Z5 P3 j2 z6 t5 Z9 j/ @ E
.default_trigger = "default-on",9 [* W7 f3 J4 R' V! S
},! B! J n Q+ f2 o k1 f9 I# }& [- ^
{
( V5 s- N5 Y! H, ^/ [# B I4 b .active_low = 0,* a4 M' w/ O1 P3 j
.gpio = DA850_USER_LED3,
* \- @! D9 `' g! Z+ v .name = "user_led3",
% N/ s! a: v' Q" M. Q7 J5 S) m .default_trigger = "default-on",
$ }* j2 R$ u& R },. c! K f' \2 L
};
- R0 v* r+ W" S8 G5 n! d
2 }/ L) J7 Q% b# B1 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) a* r3 G: G( z/ s7 q .leds = da850_evm_tl_leds,' g# W0 H$ v/ i3 w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ ~9 `+ f: J+ J# x- F _4 |};
/ r; c% Z T9 x0 i/ y, y# t- ^- l" t# E
static void led_dev_release(struct device *dev)
1 k$ C' d6 F3 _# N6 ?8 A( \/ \{
/ M/ T& w E7 c7 G; a J& B- y' D};
& k0 b7 ?4 ]# | j3 f7 X% L+ ]+ [" U- @2 c7 J
static struct platform_device da850_evm_tl_leds_device = {
7 S9 c$ Y. H2 t4 E .name = "leds-gpio",$ c, m% e0 g- f5 r$ j
.id = 1,) {2 O; l4 J* a9 Z9 t! U
.dev = {6 }! r. r% v5 a5 u- X; G
.platform_data = &da850_evm_tl_leds_pdata,
' Z: l5 u, g5 h/ N .release = led_dev_release,; P. d; a; k3 z: ~: M1 W2 I
}' t+ a& o( W1 L+ |5 V
};
" ~6 U r7 R: |( X4 @. b1 {& s/ V2 c5 {. r9 D2 O
static int __init led_platform_init(void)
* f" P J5 B% p{
/ P# ^5 ~, @& j2 a int ret;
& ]) V8 I6 e" x4 m6 X4 x, I& `#if 0
P5 g; O' ~6 ^/ p I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, |+ [6 P! i* R ^) g
if (ret)( r9 K, W$ Z1 ]7 y5 B; h R; E' W5 \+ `/ V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 t! m. V7 R% n" A+ u* I% S "%d\n", ret);$ V0 ~: Q0 M& g* o4 N6 s! z
#endif6 t" h5 Z0 w8 Y+ U) X
ret = platform_device_register(&da850_evm_tl_leds_device);6 c) Q5 K3 d) S5 C
if (ret)
$ I G- B0 `$ \. c, W, a pr_warning("Could not register som GPIO expander LEDS");+ }4 F0 c. j; z
else
, T9 d6 B0 J1 J3 \! s printk(KERN_INFO "LED register sucessful!\n");
) R v( i6 d+ a
8 l+ b) a1 i5 c$ I1 V5 N return ret;( ^/ O0 E" e' V' h. N# S* T
}
1 l, r; D8 J( H+ |+ Y; }& G" O/ p; e) L- D2 @+ l* x, r
static void __exit led_platform_exit(void)
2 s: J j3 |5 P5 A{
% ]# a6 q# a& X+ b- ] platform_device_unregister(&da850_evm_tl_leds_device);5 \1 Z3 [: U/ L ~2 C& b0 b
& w+ [ Z4 z7 f- g4 h printk(KERN_INFO "LED unregister!\n");
: Y# [. ~6 Z: n, F: z1 o}' B" D' q9 w1 L4 K: L
2 w0 N+ @( R I- omodule_init(led_platform_init);
- t" z" W6 F5 k% G; u1 Z Imodule_exit(led_platform_exit);
+ O8 Y8 C1 L" a1 B# J. N7 |) L* k J) J8 I
MODULE_DESCRIPTION("Led platform driver");
4 \- h& s W$ A4 N% xMODULE_AUTHOR("Tronlong");
+ \+ s+ b5 r9 U; d- Q5 IMODULE_LICENSE("GPL");
- k! {& V; m6 ^
5 q0 Q) J4 r H7 M" M0 Y" ` |
|