|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( H7 J- Z$ g* a6 N. _# v#include <linux/init.h>3 S7 X$ A% C$ K. }$ z* d W
#include <linux/module.h>0 _. f/ ?2 D/ b- ?' y5 N
#include <linux/kernel.h>8 ]8 N/ A- j; i: W/ {
#include <linux/types.h>
# S. h, @! e2 ~# A p8 g' [+ L#include <linux/gpio.h>
( H% f/ r6 r8 j#include <linux/leds.h>
. O& c/ ~# \+ Y#include <linux/platform_device.h>& A# x" i6 {2 l. [
* `$ X% z! o7 K$ T% }
#include <asm/mach-types.h>) i4 }2 g; y O* R/ \! r0 ?
#include <asm/mach/arch.h>0 s) U! K! U) h' w' r9 L' w
#include <mach/da8xx.h>
. ~* g0 H. j7 b7 x( O2 i#include <mach/mux.h>
; i. b7 J- z* m! ~/ R3 G9 E$ D$ M, j& B3 E2 f( J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! M e% Z, Z2 o! d) u0 M2 Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! J1 a/ e$ y, g, J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). T8 H; F% i/ s% m! ^. D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 a+ y: o+ e8 g4 R* c& D" j
2 X8 y( c2 o* z1 o3 w9 x
/* assign the tl som board LED-GPIOs*/
: d, r$ ^/ u2 v& B3 @8 Cstatic const short da850_evm_tl_user_led_pins[] = {
0 x5 G+ V1 n/ n0 Z0 u0 @ /* These pins are definition at <mach/mux.h> file */* C8 k7 T% P( ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! |/ E( r( J8 V& q( y! a
-19 h7 B8 ^8 w+ ?6 Q$ B! Z G' o
};
" b+ z) ^5 j5 _% B. {5 i
5 ]7 X/ L! z! B% U$ C* U3 jstatic struct gpio_led da850_evm_tl_leds[] = {. Z) k1 v0 Z3 R( W) z- O7 a0 q# |
{: _% F. }' E0 h9 Q. ]& J
.active_low = 0,
: D, w; u' I+ `; L9 t' N: l .gpio = DA850_USER_LED0,) n- T& I; S! E9 _2 W9 F7 l; ~
.name = "user_led0",
1 v- J7 _; f1 |- d( L0 _, N) E .default_trigger = "default-on",. C8 @5 z5 u7 b! g) z
},
8 U2 i4 m3 z n2 r# T {
4 a$ f/ j" F# Y; `' w .active_low = 0,
. v) M( C! c/ n0 f: W" X, j .gpio = DA850_USER_LED1,
2 S* L8 E3 P; k: W+ t .name = "user_led1",2 F/ i/ j7 E4 J8 A7 t1 s s
.default_trigger = "default-on",
0 M0 U6 z0 \$ z },/ b, u0 C* e# z4 T" D
{
$ c% x4 N0 _; J' C .active_low = 0,
$ W& q( Z1 }" p3 H- q6 J3 @ .gpio = DA850_USER_LED2,
8 N! O' z. f" s' E4 ~8 n .name = "user_led2",
' E* L3 n; b$ K/ N$ E, W .default_trigger = "default-on",3 A( m, I4 F5 @4 r6 {
},
" i6 @ a r% C8 M7 M {
9 [% H2 J3 b- |' M .active_low = 0,2 U" K3 ? g4 A# N4 m2 H' |
.gpio = DA850_USER_LED3,
! f2 W- \* c: C* ~; v .name = "user_led3",3 j' R) \7 \; J7 d; ~( p
.default_trigger = "default-on",
3 y. m7 [5 J' W e n },. p( w8 H: t% C& }
};
6 @5 C: o% p {! s3 g0 t) s& a' \7 n' H/ F' S. f- C8 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 v# V! V1 ]" J# x; g .leds = da850_evm_tl_leds,
1 L- l) R. k2 A$ J0 _; T/ _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. x5 a4 T" i/ c& {* c% s8 Q
};
* {% j% L/ E1 L: `0 U$ K [* C! n1 V6 b; g$ @+ J E* {
static void led_dev_release(struct device *dev)$ g# M: o1 T2 F P- a2 U3 }- Z
{" q+ u* X% Q4 r; W. H" v3 n+ ], b
};
1 p& _/ ]& x. q" N& m
7 w, a7 G* f' s+ \8 E0 Kstatic struct platform_device da850_evm_tl_leds_device = {
E! n' M s/ q .name = "leds-gpio",
6 P7 d3 r! t& I .id = 1,
+ _$ A+ f; H' i. B1 `; L .dev = {
* R, H3 j6 U3 U. L% S8 H .platform_data = &da850_evm_tl_leds_pdata,
1 s; q" {0 ? g- | { .release = led_dev_release,( j& q" ^& h- q3 V
}7 m1 Y! V! K a _% s
};; [9 i) |" f6 v5 N; T( l( ?4 h
4 s6 k! v* D8 m5 o" W6 ~8 hstatic int __init led_platform_init(void); B3 W1 ~' [& t( [% d: G3 {9 X6 d+ H
{2 Y1 G3 `( E0 Q8 o: X
int ret;: G- i% g) F, c- B% E, k7 d/ z6 J9 S
#if 0
5 f2 M* d K, k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: g( V, y* h0 y! n
if (ret), [: e; `4 `' E" s& r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 E0 d1 }$ w8 u/ {
"%d\n", ret);
d$ B4 y- M0 R% w1 [+ Q% _#endif$ ]. l, x. Q9 m
ret = platform_device_register(&da850_evm_tl_leds_device);
' r) Z- ]* ]6 [9 U if (ret)
& N! {+ y' g1 L& y- ]/ q W pr_warning("Could not register som GPIO expander LEDS");
- R% e6 x4 G% `: K2 y3 o- N else. _- t7 z: z+ ]) w* c& E, o, \( {
printk(KERN_INFO "LED register sucessful!\n");
, i% j! O) D' c% \! ]* V
* h: ~: I- `' r# o p5 { return ret;
6 x8 H! D5 U" e: o% X8 G# q}
9 ~: b* p! @3 P& y2 A
. f j# j# `; k/ O/ Q3 o% k( z1 Zstatic void __exit led_platform_exit(void)
5 x. o) I0 l! J{
+ V3 g) F4 G1 n3 n$ W platform_device_unregister(&da850_evm_tl_leds_device); P! `2 W" e$ t H5 c9 k: R! F: g
+ d( G% `' V5 |8 B1 a+ j6 r printk(KERN_INFO "LED unregister!\n");1 i9 F( q6 G) Z& O( J# Q
}
* {: ^/ g4 |+ `! j- P2 e2 N7 p. K* D
module_init(led_platform_init);5 B- i1 }1 n1 E
module_exit(led_platform_exit);0 z0 s0 d6 j8 a% r# k$ _, B
0 S) H( ?& O AMODULE_DESCRIPTION("Led platform driver");; D% j6 e+ _3 Z% K
MODULE_AUTHOR("Tronlong");
0 n* p1 x# T' ]1 Y! NMODULE_LICENSE("GPL");5 N5 A8 U3 d0 K3 p: y! J
) _' V& d+ F0 {$ L |
|