|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! y! k5 C2 @5 c: P
#include <linux/init.h>, ^# H* K9 ]7 U+ ]' n
#include <linux/module.h>
# F5 h5 G, p" L, X#include <linux/kernel.h>
8 a$ z6 z0 \- c6 G#include <linux/types.h>/ i$ [0 _9 D! Q. `0 O
#include <linux/gpio.h>
7 d/ e9 X, E2 F0 a E. I7 E3 {- Y#include <linux/leds.h>7 K* Y% S, D. D* u
#include <linux/platform_device.h>
6 x8 N* E4 M% j( A m- _5 o7 J1 ^0 i) t: B# J. b- ]1 w
#include <asm/mach-types.h>
; W& X' `( X5 E- F* N#include <asm/mach/arch.h>
4 P9 s R% B" I- n. @- y* `#include <mach/da8xx.h>
1 l, e3 v: [" K: G) T" e#include <mach/mux.h>+ l+ z! R5 Y! o+ j. P. S$ C
( H; i0 t- s4 M5 w& A( {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# Q7 k1 f k" m* ~. i) m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 _& ~2 n5 T& {. l3 r! v( o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 U: s6 C- h5 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; n* M7 T9 d; N) h: I- b% V) p
+ J1 ^( S5 y% r1 q9 B: T/* assign the tl som board LED-GPIOs*/
% J g G% R% T% F$ cstatic const short da850_evm_tl_user_led_pins[] = {
+ Q8 y. W* U+ A6 A8 Q5 g /* These pins are definition at <mach/mux.h> file */$ I: D4 n4 g8 z" Y: {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 p! Q# W( h9 @# U
-1
2 ~; g3 ?+ v- u( @$ |};) p4 A$ U0 e8 p0 E5 I( b0 f# e
# d- u1 i* w4 A0 b4 k
static struct gpio_led da850_evm_tl_leds[] = {5 |" D+ u# V4 E
{
% ]6 y4 ^8 N8 l* ^9 @7 ]6 I; r .active_low = 0,
% ]1 Y( ^" g. w) ^1 F5 \% R .gpio = DA850_USER_LED0,
$ A- e2 W4 f4 x# M& P. [- Q. s .name = "user_led0", ^" F4 u; a8 z9 N
.default_trigger = "default-on",$ E! P6 K6 N6 Y
},
2 y# P/ T4 z7 O' M$ v) ~ {
5 ~& O- ?. {# [& x .active_low = 0,
% t5 D. S- V* y K; q, e$ J .gpio = DA850_USER_LED1,
6 {2 |* B- S4 `+ @& ]8 U3 P .name = "user_led1",4 t- S. f- f$ C! W
.default_trigger = "default-on",3 M& v. V( T) P8 o7 m% y" J
},
. n% K4 c7 J4 U- `, h. B2 L {6 Y, W( U: g. G8 c
.active_low = 0,( _9 c* L$ b' p6 [8 K: l1 j! h
.gpio = DA850_USER_LED2,
! ], T% f `7 B, m X& u/ d .name = "user_led2",
+ N" L. L/ P5 L8 F3 {4 \$ e. J .default_trigger = "default-on",2 m$ ^# R4 A# W1 W
},8 m8 ]- G$ I) ]4 {/ _0 Q
{( j) O5 z* [8 o6 P0 D1 @1 e3 s' N" l
.active_low = 0,
+ Z5 _+ t6 w* o/ f$ K .gpio = DA850_USER_LED3,5 n& \8 n$ t4 `0 |" N5 a7 w
.name = "user_led3",2 C; o/ u. i) n
.default_trigger = "default-on",' u! O" ^0 @5 n6 \! O
},0 `+ Z# l" Z. y7 R' w, y" |
};
/ P2 P& G: j% }4 U' y/ u$ q' I* a# K8 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ f# f9 W+ ~: k" t% ~" ? P .leds = da850_evm_tl_leds,0 e' r; I0 t/ B& N) S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 K9 e( m* |3 ]2 ~4 c: Q};) c( A) |. X4 ]9 \- C# `4 F
) n5 j# A: i5 H: f5 U, S
static void led_dev_release(struct device *dev)
) |3 K" w- k+ T" _3 |5 i7 d# o) i) E{$ J+ U: f$ h. {. S) H
};/ K8 Q3 R! f7 f2 ?
4 Q: B) P2 s7 f7 K& H% w5 Kstatic struct platform_device da850_evm_tl_leds_device = {3 g. f$ n. q# M+ _8 W, `! v
.name = "leds-gpio",2 s- I2 o: i& T; C$ i$ U9 e0 x
.id = 1,
) _, L6 Y9 v" y- G- V9 P1 J .dev = {
2 j8 P2 I9 o5 @( s .platform_data = &da850_evm_tl_leds_pdata,' i* `! P/ K+ k: K
.release = led_dev_release,3 ^* h+ \. N0 `; Z. O
}; G0 s( J+ R2 n4 ]/ a
};3 v6 ~- C5 ~2 G. Z
+ o& c- E# G4 _+ r- R/ f( qstatic int __init led_platform_init(void)
9 ^8 e: y! D2 {( I. o4 m{# s: g0 R3 a7 K2 @. a N
int ret;
% i3 ?. c) x9 N% p#if 0
! q4 }5 M/ |* n G% c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
| m; N) e: h0 Y3 D* H if (ret)4 o/ J# H- p1 t. [8 `: h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 Z' [. m- T3 B3 k3 f! Z& S+ r
"%d\n", ret);5 z* a2 N# ?/ u# F3 G* v
#endif
8 T2 n* G6 y: Y: `9 Y ret = platform_device_register(&da850_evm_tl_leds_device);
d5 ~7 J* r$ m: z# {5 U. }2 L! { if (ret), e0 |9 `- O; {1 q
pr_warning("Could not register som GPIO expander LEDS");! e9 O3 X8 z3 S7 b
else
; k V% b5 a6 O8 }$ o$ W5 v: F printk(KERN_INFO "LED register sucessful!\n");
+ {1 [4 l+ o2 s$ I6 `2 j
7 L! {# r% d# M return ret;
. `- H( h2 w5 R# {! ~}+ ~7 c" o! p& q
6 z; J5 L/ O6 d( s
static void __exit led_platform_exit(void)$ c9 ~+ X$ o* X8 R
{5 s+ m V, J' |
platform_device_unregister(&da850_evm_tl_leds_device);
4 g, \- j1 e3 e# t1 a+ T$ R# p% S0 W4 q3 C; L0 D
printk(KERN_INFO "LED unregister!\n");
4 C0 e3 x* i L}) ]/ V4 k7 C4 L' I8 V" U3 S1 H
# p; B+ @0 v) x
module_init(led_platform_init);' J9 M9 s' D0 u/ z9 N! s" B$ u4 h
module_exit(led_platform_exit);
* I0 @. g2 O, \3 F
G- I# q, L* E$ zMODULE_DESCRIPTION("Led platform driver");
% @: g9 o0 b* ~5 k8 d* K! WMODULE_AUTHOR("Tronlong");3 J3 ?9 k6 N$ N3 P: r5 O: N
MODULE_LICENSE("GPL");
5 n: z+ {$ @: q0 ^, N- h! {' q2 }; Y) v2 t* y! V9 n
|
|