|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ Z0 ?2 L* D! K: Z
#include <linux/init.h>
" X! G2 n/ T0 T3 h. ?#include <linux/module.h>4 B: X G F4 z L6 a+ w7 H k2 J
#include <linux/kernel.h>
0 @- b4 n& d+ a#include <linux/types.h>, x) X# A, c! v' I/ W) Y
#include <linux/gpio.h> ]9 R7 b4 [9 y n
#include <linux/leds.h>. m% ^; v2 T: O7 u7 P' L% P; J
#include <linux/platform_device.h> l+ H2 d1 x" G u2 X7 y4 E
& D# N- y* j5 G7 h$ e% u#include <asm/mach-types.h>, _( H2 S2 _4 ?2 X4 P
#include <asm/mach/arch.h>0 F1 g. {" m/ @4 C& ^* I* j
#include <mach/da8xx.h>6 a, A& i$ Q# ^# T5 w( y) a
#include <mach/mux.h>1 _- }9 i9 i$ q. N' q9 |9 B K
# E" P9 }+ m4 w+ J0 m7 o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 n0 F# e( A7 K# Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ [& ]5 ]/ Z# v# H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 P7 ^7 U, y# x I) b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
?* U9 q( M [2 ~
# J, ^9 Y, H9 `0 M/* assign the tl som board LED-GPIOs*/
4 r. ]7 N/ f9 |6 [static const short da850_evm_tl_user_led_pins[] = {
Y' D' ]7 x& c- A2 L /* These pins are definition at <mach/mux.h> file */4 P+ m, C8 f5 m, n; x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," T5 C n) B# |; S3 z! j
-1' q! B4 ]) V9 b$ [- G2 @
};& _! p# o' k3 P) ~ S+ L
# ~& G& f, k! I3 d8 K
static struct gpio_led da850_evm_tl_leds[] = {3 f0 t7 o0 c+ ^! b: m1 L
{
: F/ m; ?4 v6 o .active_low = 0,
( e2 S9 ^" s- q4 L .gpio = DA850_USER_LED0," [/ z" |# @6 d
.name = "user_led0",
, w# O( m( c+ [' g .default_trigger = "default-on",/ Z' f+ w" c, u/ U, K7 j8 L
},
% z' N. S4 k" a {
2 c$ j# c& W, c, S( m .active_low = 0,
) p. {1 C/ e9 S/ M .gpio = DA850_USER_LED1,
& H. {3 x+ Z: B! x .name = "user_led1",; V8 {) t+ y' t2 j
.default_trigger = "default-on",* i! `( C) A5 J Z5 p
},
9 D) {& A# b* F) j1 j! M {, ^( d' J& u! v
.active_low = 0,
+ H; \7 h4 Z5 }) D$ Y9 @ .gpio = DA850_USER_LED2,
" A( y5 V4 A, K5 k+ e( v* A* {2 { .name = "user_led2",
( H) F- F( \1 x4 O1 M( M* W6 M. f .default_trigger = "default-on",+ o1 F& t6 l+ f, L7 r
},
P& N R. t' S) @6 b& _ {
0 i: i, D8 j- Q5 y& N G2 V( b .active_low = 0,) m& W( Z6 o. s) X$ s% I# Y8 w& I
.gpio = DA850_USER_LED3,
2 m. a4 T& ^4 ~2 \8 _+ ^, n .name = "user_led3",7 o) I) w8 V9 F% Z+ f! Z/ A: I
.default_trigger = "default-on",$ y* a# l$ L0 u) R# O! e, E
},/ E7 d4 `( p& {, }7 r% P8 H
};
* q$ j7 V" F3 \9 Y3 o" Q* f/ F! Q; ?3 b- H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 K# l d1 L6 K. F .leds = da850_evm_tl_leds,* K8 y9 N7 h4 R. {% l, C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 A) A3 A3 H$ U# d' N$ }};; H! E: [7 B; D$ S
: r0 K! S# |( V1 }0 y/ F4 `
static void led_dev_release(struct device *dev)
' F5 y. q. k- b+ Y( R2 q- D{) `( j) V/ ]2 T0 x
};4 j0 a; G- j) K, T8 [
& o6 {* q% }+ N/ b4 sstatic struct platform_device da850_evm_tl_leds_device = {9 Y6 H; ~* h7 k2 P8 }6 I
.name = "leds-gpio",0 w" A7 a) g d
.id = 1,( {7 B0 _, d% l u: W: Z7 M
.dev = {" k4 Q% B+ ?3 X" X
.platform_data = &da850_evm_tl_leds_pdata,
9 u0 o% `& D- H- i) ]3 `: D .release = led_dev_release,
0 t/ q0 U* S. j' u' O } `2 a) ?% R% H* M0 ^4 L
};; ~ A' G: O- A C2 ]
8 f% f4 W. a3 m9 b9 F3 q) m
static int __init led_platform_init(void)
+ X6 D0 `) s# F7 E+ n9 a{
0 T$ G2 F2 _4 \1 e9 E: L$ g int ret;
2 W$ j( [1 G* k3 A5 R#if 0
0 b. I) O3 C$ S7 b2 Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 b) G: w$ O& j; \" @ if (ret)
4 O1 h* Y, Y- Q& e3 O1 Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; l" X& |& p- e" D0 o, K# x
"%d\n", ret);
: ^' W* s7 w" ~9 ]" n- l. u#endif+ `* c" Q# o1 @: a
ret = platform_device_register(&da850_evm_tl_leds_device);/ O( c$ D: X' z' O" C
if (ret)
# U) l; d6 g2 |) r9 Q pr_warning("Could not register som GPIO expander LEDS");! K$ U7 Z- N8 {
else
8 ^* Z2 _! Q8 ] printk(KERN_INFO "LED register sucessful!\n");
! W7 q3 z. S% O, w
! d" ~, @; ]$ ` return ret;
V7 I7 F$ E: ?) i( G0 u' G, w}
6 f+ l' \. P: k& Q
" g3 L- w9 a$ dstatic void __exit led_platform_exit(void)
$ y& u" I* }0 l- A{) Y( _, N( G! P1 R1 m2 O3 q2 H
platform_device_unregister(&da850_evm_tl_leds_device);0 s0 U. L6 h, R+ I' e4 v2 T
9 ^8 `! K) t2 @9 E: C6 V' z4 B
printk(KERN_INFO "LED unregister!\n");9 B" z. i6 ]. [/ G% V4 X
}
; |. Y i9 \3 o) g
6 k* I Z; S$ [" T& \( |4 J- Lmodule_init(led_platform_init);2 u* D( ?$ i# n7 [9 t* V( K
module_exit(led_platform_exit);
" P# T8 O& j, o& z9 u$ T, N: j; {: W+ U
8 S: f, V$ g1 d. \: uMODULE_DESCRIPTION("Led platform driver");
! v j7 ^1 L+ |) PMODULE_AUTHOR("Tronlong");0 r) ` s) E# @ ^7 H/ x) H: q; x
MODULE_LICENSE("GPL");; M6 z. t$ | a+ v
' | d/ a3 s' V0 u2 c# {
|
|