|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. G3 N, V8 ]3 k#include <linux/init.h>
9 K0 L7 ]# d |' }1 D#include <linux/module.h>
$ m5 W1 B7 |- p) a; p( |' d#include <linux/kernel.h>2 X4 \8 ^% h1 o& e6 s; H
#include <linux/types.h>
- B# v( U5 v0 F/ P& M V8 G' d#include <linux/gpio.h>4 ^0 R8 a$ v* V, w7 j9 Q
#include <linux/leds.h>
7 p% z3 V6 @! a. d/ a6 e#include <linux/platform_device.h>
; ^3 X+ F& k) o- m7 m. e1 M: Z6 \% C2 J4 F$ m
#include <asm/mach-types.h>
% `% N' `" y m' d3 k9 ]" \ A( B#include <asm/mach/arch.h>* H- Z% y% q, A
#include <mach/da8xx.h>
/ v9 k; k. O; R/ x0 j#include <mach/mux.h>" z( v$ x# x; i$ Q- f9 A
+ G) J* W$ E6 |9 Q3 w3 e* ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 F- q- z0 W7 V& p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 U s7 U/ Y4 `+ V: u+ K, S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' v3 N/ K( E/ t' s; t# B1 z1 k: {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 i, I3 f. N5 `" y# u7 `# x
7 O6 s2 X* B8 |6 f4 M/* assign the tl som board LED-GPIOs*/
. s8 {8 D9 O0 [static const short da850_evm_tl_user_led_pins[] = {0 k3 O$ b4 G. n* y
/* These pins are definition at <mach/mux.h> file */) T) u: I3 q# Y) W4 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 @, M- n& ?& h# ?% y7 g6 x. v
-18 Z& s( L. E2 ^$ N
};
' ~! M3 |8 ?3 s2 j$ ~9 C( B5 e4 k- ]! o/ }, i6 i
static struct gpio_led da850_evm_tl_leds[] = {8 L1 t/ Z( V* u% M+ U7 c* Q4 q
{
" c0 ]- m8 T+ U2 P1 T .active_low = 0,3 M r" Q8 R9 z( q
.gpio = DA850_USER_LED0,
1 V' U; y. I1 H7 e7 U .name = "user_led0",' {7 X' \& _$ w$ m) Z' R0 `. Q( ?( O
.default_trigger = "default-on",/ m3 Z$ n3 Z7 S, o- M0 k1 H/ ?
},. v4 q/ p! \3 U I9 L* q- Y
{
# i4 P; w: a0 I& r8 p7 I& e .active_low = 0,! d/ Q" c: M! C
.gpio = DA850_USER_LED1,
6 z& b* n }$ m .name = "user_led1",
! p" v+ m2 k2 e' J8 f8 _, l1 m. m .default_trigger = "default-on",
/ U. o7 _8 J& R0 i+ w0 w },
4 F7 K/ ^) z% c% b( d {
6 S ?0 e& C( m2 j; N1 u; J .active_low = 0,% ^3 s4 K/ P/ b! P
.gpio = DA850_USER_LED2, U( r3 ~% F% s' B2 n5 n5 u
.name = "user_led2",
# z) ]( ~7 d( P7 Q5 Y. @4 s5 q* n .default_trigger = "default-on",3 |% m4 A6 u9 s% @
},1 i# a" o7 i0 u2 U6 w, D
{
6 W5 l) S8 V" C3 f .active_low = 0,2 z" C8 m) @6 L0 h; b2 \
.gpio = DA850_USER_LED3,2 p. W7 ?! W1 J3 W
.name = "user_led3",* c+ W7 P% |8 V8 C1 F& J
.default_trigger = "default-on",
: Q3 ^* G( _! U% H4 Q* @ },
( F; S8 r- F# m- V7 i+ O};
& r& C; b; f: ^- s7 {
# Y, L% P9 h" _. y0 D4 n a2 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 W. L7 F n D* O# A .leds = da850_evm_tl_leds,
0 r% E, D' W1 i6 K8 P# ^) L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 D: c/ m; z- Z H/ G/ p};
; M, x3 z. H) x$ d6 Z; X
! G" W7 D$ E: e# z- T+ U u xstatic void led_dev_release(struct device *dev)! ]: t- w2 W! @. z% {( T( `
{+ ?# N( h# l7 N7 ~' }
};. {8 Q- b/ f& Z% ~. h
& y2 T3 k1 R" A, D4 D/ w
static struct platform_device da850_evm_tl_leds_device = {
! b/ e0 w/ N- G0 F* Z2 p; y3 ?/ I .name = "leds-gpio", I2 Y, t9 H0 ^2 i
.id = 1,
; {+ |: j0 c+ {: l! q+ R3 Z# z .dev = {
' ?* ~1 f0 }( ^/ a) |* L4 v# a3 i .platform_data = &da850_evm_tl_leds_pdata,, x2 }; S' y0 W$ d$ ]- N7 Z
.release = led_dev_release,9 @. V v5 j1 l! I0 [
}, ~+ `9 M( u& v6 C) y0 c
};
+ @' U/ N) x# P) U8 u1 A
& x0 _" F" j' q- {: F$ a* G) V) c6 ?static int __init led_platform_init(void)
- i$ v: g7 T" h& F& P{/ f/ g3 l6 }" l% Z5 U
int ret;
/ Y! K- v1 k. O" Y8 b#if 0
8 L1 y6 y* x- o2 }; Z3 Q+ n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ b, V% I0 A% R! I/ _
if (ret)
% G' l- x" C. o; \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% z* y/ O9 ^; }3 ~4 C5 C( v( [
"%d\n", ret);0 W" S. T, U' o5 a% X& ]6 R
#endif8 c+ q& X3 p! v; S/ l% R
ret = platform_device_register(&da850_evm_tl_leds_device);
8 C5 B9 I- r$ k# d* Q0 j, U if (ret)$ V v9 ?, W0 A/ H" s
pr_warning("Could not register som GPIO expander LEDS");# U! k% F# \' O4 | b$ K0 x! X
else
" q8 N) i0 \3 {$ Q8 t* E/ C printk(KERN_INFO "LED register sucessful!\n");
' Y5 j5 X: h) G1 I/ v4 Q9 y v( M. K1 ]( B( D
return ret;
; m- k1 k. f9 g2 t}; a7 @. B2 [9 P% S0 `, _+ C
9 a4 a: a" a" q5 G" x5 B9 V
static void __exit led_platform_exit(void)7 x# S" ?4 l6 S& G3 G
{
2 ` `) f `1 [8 Q* a* o* o platform_device_unregister(&da850_evm_tl_leds_device);3 L- c: c: T$ T! ~; [: k
, o- |$ f' H& P" m% i printk(KERN_INFO "LED unregister!\n");2 v9 t' b- p0 s! A$ v K. |8 |
}
: C& V& ?# ?' s4 x. {: f
* f- t7 j7 \6 S" I. I( o0 Cmodule_init(led_platform_init);4 _% ]$ U* ~) L. _6 j
module_exit(led_platform_exit);0 r; n. _( K5 Z7 }2 p8 B
# R, z3 P# @9 O; J7 z
MODULE_DESCRIPTION("Led platform driver");
- n! v5 {( G5 n, F& f4 hMODULE_AUTHOR("Tronlong");) `1 a6 `( ^9 p. J
MODULE_LICENSE("GPL");
# y i5 c. v, B- {. c& J$ d4 {5 n! [6 ~
|
|