|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 y) W- `" f# Y! ~: A8 j#include <linux/init.h>7 a& z, k0 J `) Y: X/ `* P N# I
#include <linux/module.h>
- r% {! @5 d7 T, B#include <linux/kernel.h>
p2 y0 Z; `. `" a8 A+ r V#include <linux/types.h>
S8 ]2 k S' U#include <linux/gpio.h>. w* k/ C/ w1 Y! J
#include <linux/leds.h>
# R. |- F. p% h#include <linux/platform_device.h>- S5 V* s0 b+ [. d6 x) I: R# K
3 f3 ?8 C. y) R2 h
#include <asm/mach-types.h>7 i) ?8 d: `3 ]: `: [/ k: ~
#include <asm/mach/arch.h>
, d( |; V. b3 G/ Y; \# P#include <mach/da8xx.h>
R) [2 H) l5 r8 \ [#include <mach/mux.h>( J) y7 [* m' z0 n; Q7 q( |5 E& O
% n: O! O" @( z8 [8 X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% D/ {% T9 U1 ?4 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' Q. S( Z3 ~' ^( P# T" N `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 n% s6 I- s5 S+ n, C9 `2 J5 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 g& v+ ^2 `4 u- H" X4 R9 h, m6 t0 q
/* assign the tl som board LED-GPIOs*/; `' G$ g) N; Y
static const short da850_evm_tl_user_led_pins[] = {
2 K$ U5 [1 [, A6 D/ \& y /* These pins are definition at <mach/mux.h> file */
4 V9 {/ U, g8 M! @% m5 L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# ?4 o: H! @$ E$ o' q) w. q( s( H -1: }% J+ S3 |" W# N4 F
};- r; {0 c2 z8 E, n$ x) \
6 a G" w" y4 @: R1 [6 m$ M8 c
static struct gpio_led da850_evm_tl_leds[] = {
$ H! [: {6 P& P; v$ l { {8 P& A8 }4 ]" _
.active_low = 0,2 {1 u) T( k% d: `( L! Y
.gpio = DA850_USER_LED0,
$ k s( v% @/ D' r6 w5 o, g .name = "user_led0",
" B7 P3 ^/ o p0 `% j" V .default_trigger = "default-on",
# y# p# F6 i" w* e4 Y },
3 q% G& l) g0 h# h D4 x5 l' H {
0 n! I0 B0 {! O4 p0 {& S .active_low = 0,
) A# R' _# s# A# z$ V" X4 \ .gpio = DA850_USER_LED1, H9 p f$ c- A0 D# o7 B8 R: d
.name = "user_led1",
( `: B5 I- E @7 w+ P .default_trigger = "default-on",
4 i) Q0 Y' r: I* _5 d: w1 h. P" t6 X },
8 ]+ h" t, k9 {! U, R6 v) h: c {
4 o) k" O8 j9 @+ {# k0 G9 Q .active_low = 0,! B& G1 f" j$ Z% N
.gpio = DA850_USER_LED2,/ t/ D: W7 ?, m: u
.name = "user_led2",
+ B( d( J, N8 H4 t" n5 z# Y .default_trigger = "default-on",
% L7 P, K- B+ V2 m },
2 V0 O6 S7 \# Z+ g0 v& t" L8 D {
; }$ M1 c6 d1 R9 @( n9 p b# b .active_low = 0,/ M' h- h1 @( z' d1 `
.gpio = DA850_USER_LED3,2 {/ \! b3 x6 @# h4 R& @- |
.name = "user_led3",- J: C V- H4 S0 R! m: O! s% i
.default_trigger = "default-on",8 i5 z) K& P/ B! s+ k& C
},
/ E% P2 C+ B# d3 x3 ~/ Z};0 _2 P" V4 K( [" t+ `
9 t' \( A# X p8 t% T+ K/ m6 o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) T6 P$ k) ^+ G5 ] .leds = da850_evm_tl_leds,8 x* r v; H! D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 i+ o; j0 B) d f) V};, P6 c8 {- [1 q. n8 @) N+ y
+ _& q9 b# s1 m0 }& X9 ~0 W" v, [
static void led_dev_release(struct device *dev)
& l5 H; b1 u( j5 G& X! O8 }; a{
1 t) @9 O6 z. ^};: P, k8 X, d* A
4 G7 G% e7 `3 r F, E; s3 P. F6 H$ w- q6 J
static struct platform_device da850_evm_tl_leds_device = {
4 w! V9 y, \. m& a5 F0 \" q .name = "leds-gpio",$ f: d7 q2 t8 R ]" u# z
.id = 1,
5 H" j* R4 ~* K .dev = {/ i# N3 p4 ?) l, k c. u+ z5 x
.platform_data = &da850_evm_tl_leds_pdata,
) \: b$ C3 D4 B+ E .release = led_dev_release,
' z5 Z6 O9 {# y: p, } }
% v: r( W3 e7 I( s5 M7 I};$ W* ^; h, K- C* q
/ s" l0 `: H; e
static int __init led_platform_init(void)6 J; g- k @" B) s% D& U9 O
{
! N2 }4 {6 s# ^% D5 ]8 g C5 F int ret;
0 W' O% p8 `$ ?* B: m#if 0
' T! N1 t9 K! l+ W/ G8 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ s/ b7 F8 @/ p if (ret)
* `5 N8 t5 y" X; @) m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* R3 ^1 ] j6 C: D$ E% V: c. u
"%d\n", ret); O* C F( j6 ]+ n; c0 n
#endif. L# @+ ^6 q. \7 G4 H1 w# N
ret = platform_device_register(&da850_evm_tl_leds_device);* L* J6 H3 M; n; x1 W
if (ret). L; U; I$ b. p6 H2 q( r
pr_warning("Could not register som GPIO expander LEDS");* c* {/ D% s) t" d4 \( B
else, v6 K# z1 _% n ^! L( L/ v
printk(KERN_INFO "LED register sucessful!\n");- T; y; K; k; s0 ]: c! O; t3 K
/ A2 F" k! X- X: P! v return ret;$ e5 }) r7 l* x
}9 q" n# Q o3 t& ]+ G" U
5 |$ e" Z3 ~" J3 s
static void __exit led_platform_exit(void)! k7 b) M, k k' }; Z0 a" Y
{
9 J! ?! S( f& i platform_device_unregister(&da850_evm_tl_leds_device);9 m- u. K1 u* L* h% b
' d7 U. k5 I9 m
printk(KERN_INFO "LED unregister!\n");" i- G! f& b! Z# A- C! o
}8 B; S' ~- Z! x1 A
2 B5 M- O7 j& M1 G
module_init(led_platform_init);5 r; i# G7 Y- D) [8 s
module_exit(led_platform_exit);
0 y1 t. p4 p$ H& e
$ u) q* A( A$ BMODULE_DESCRIPTION("Led platform driver");
# w3 ^: k% D0 [# |# Z4 L; hMODULE_AUTHOR("Tronlong");
5 b9 x6 L! g% Z& I# Y3 A# KMODULE_LICENSE("GPL");
. H/ p. S1 ?0 u
3 x; J; L) c" `; C1 t$ p |
|