|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, G" o/ ~% B& } c9 b, r* ^& p+ p#include <linux/init.h>$ w, V3 f$ ~% D U% c5 {/ Z+ K
#include <linux/module.h>; g) T, x8 X- |
#include <linux/kernel.h>1 z3 ~" N, [- d; T2 |$ D. S
#include <linux/types.h>9 \' `% u% \' x3 D
#include <linux/gpio.h>" M2 Y! d, s. ?! ?3 Y
#include <linux/leds.h>) h2 t% E; ^8 @ @
#include <linux/platform_device.h>
9 I S! X: q! S/ F' Z% e2 Y; k8 H3 Q A6 @! o+ r
#include <asm/mach-types.h>
! J4 a. g! ]5 C, m9 a8 a#include <asm/mach/arch.h>
- [# K2 g: `: E8 ~# j: Z& v#include <mach/da8xx.h>
8 e3 R: P9 O) e+ f5 k#include <mach/mux.h># i9 Y+ A/ ~, _/ n
* T( Y! z+ D: ?; l4 D$ Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" r+ F. h& L: `$ ~1 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ W& a& S Y% O0 r! t8 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* i' h }$ j; R+ M2 g' C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" X: a$ z {, K/ P8 u1 g$ c5 W/ x4 r7 T) l
/* assign the tl som board LED-GPIOs*/0 e0 z! K- \; J; C
static const short da850_evm_tl_user_led_pins[] = {
! B2 N* E6 b* d5 ?* H P& a4 `' d /* These pins are definition at <mach/mux.h> file */) \0 S1 P3 M" n N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 ~4 F% c; n9 A3 d7 k# g
-1
' ~0 Q$ n* e. T8 ]8 }/ b};/ A8 f0 L5 {0 h
) [9 G* S" X, h$ w5 K1 A. Pstatic struct gpio_led da850_evm_tl_leds[] = {
- a, ^( v* s. L* [6 L b {7 ~; Z6 G0 U# \5 E7 x* X1 x
.active_low = 0,8 X0 e/ R; N0 x+ |+ Z! b
.gpio = DA850_USER_LED0," a! b/ N9 a8 t' t! n
.name = "user_led0",0 O$ Q, p( N/ S# H
.default_trigger = "default-on",
% h: R1 i. a* L4 } },( C0 B* H0 o$ s, ]
{ u+ y: g% f# Z" e- z3 q9 K D
.active_low = 0,
& `9 q( F* ~2 c6 D | .gpio = DA850_USER_LED1,
% ~$ G1 q5 U. I9 g .name = "user_led1",7 T% O) [$ h/ S1 G/ [) i
.default_trigger = "default-on",( J0 A# H# ~7 o% P
},
- H$ w( h; }. T+ b a. i {
& d, U, J' V. {7 y( o- g .active_low = 0,6 Z5 C8 c a9 ]+ W# E- k
.gpio = DA850_USER_LED2,9 d2 f* E" o# \1 q
.name = "user_led2",8 n$ D. ~1 A; Z0 K
.default_trigger = "default-on",
% F+ ]& Q7 r) r( o5 r },
" T: e* n2 |+ t' H, I8 t# ^) E {
4 H' b& g9 U5 ^6 ^ .active_low = 0,
0 h" ~+ ^ N6 z* Q8 g: Y .gpio = DA850_USER_LED3,4 ~" c" b; I' a$ d
.name = "user_led3",: O% g9 H6 k U( S( `
.default_trigger = "default-on",& i2 ?7 ~( U# _7 t6 v
},% m1 b) A+ K: P2 i6 _7 Y& U1 c
};
0 b6 s0 r5 D8 f% a0 ]" ?
, I" U2 Q. \/ D' |: Y$ \6 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 g$ h0 S. I! T. G9 k- b
.leds = da850_evm_tl_leds,
6 d4 n* a' L% f, V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% i. [4 f' q4 B% @) K+ Z* [9 |};
1 Y! U* m* J& O7 B$ M
- K1 }3 T! d& u. z' V3 { i8 h9 bstatic void led_dev_release(struct device *dev)8 V8 F$ a0 |+ }$ V
{
4 V% N# t5 {0 e7 p8 a};1 u1 Q: k3 P- K: e
" Y4 I( N5 Z6 ^9 G& o+ ~static struct platform_device da850_evm_tl_leds_device = {
+ k% j) X& X. d/ ~4 h* X .name = "leds-gpio",
4 j7 d& s8 v/ a$ y$ C: } j' Z; B0 v .id = 1,+ Y+ g, e* _& a$ A8 p, V. `
.dev = {, {4 {9 s, z, d7 a
.platform_data = &da850_evm_tl_leds_pdata,0 A0 S; o+ N' j
.release = led_dev_release,
5 C# L# {1 G5 b3 b& O }
% c- Y- I0 J' l};- M1 m& w+ @9 O1 t( u
1 L1 `6 X, h& g7 v1 `& fstatic int __init led_platform_init(void)
6 }8 M% U4 n; W# h8 {{
; [; R' n$ D, U! K0 ]3 r6 l0 e int ret;8 n8 e9 i: M& r( t1 k
#if 0
& s/ k+ O2 {( ` ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 o- l3 Q" n, P' X$ q if (ret)
% d9 h1 V/ V( H1 g/ j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; W6 P, q5 F/ F7 h& f "%d\n", ret);: U& W* P. Q, o/ v( I
#endif4 M4 ?4 ?$ F7 Z' V
ret = platform_device_register(&da850_evm_tl_leds_device); B- {# G* a( V
if (ret), ]9 z. b& U: S
pr_warning("Could not register som GPIO expander LEDS");& h" s* j6 H. a; T
else% `9 E/ O' ?& E* x% w h. i
printk(KERN_INFO "LED register sucessful!\n");
0 V, y# K/ g; L, a! D! \# k
2 ^' v2 U, }- ?/ ~. B* G return ret;
. N/ Q( N a7 Z/ G* S: x}
: q0 X$ J3 S8 C% E0 W2 v! I. J
, n5 d5 C$ z5 S6 }* o7 \static void __exit led_platform_exit(void)" A0 y* E3 b. a* r& }/ l
{
0 N+ v* n! p$ B8 k, y9 u' N platform_device_unregister(&da850_evm_tl_leds_device);# O1 F7 P. e! N" m, `: g( t
; U1 l( V* M. f6 O printk(KERN_INFO "LED unregister!\n");
& \6 C2 h' ^7 H3 \* F}
" G$ _+ C- ~ Z) F! ?' @# m# }. f: S) I& w& u4 ^6 y) ]: E
module_init(led_platform_init);
/ d) H0 ^* {* C- s7 omodule_exit(led_platform_exit);/ P0 K6 s: N# R' d2 K" b
( Z9 T% m; T- \3 CMODULE_DESCRIPTION("Led platform driver");
6 ^$ N: G3 r' e. N" tMODULE_AUTHOR("Tronlong");, w* O6 G$ Q& O
MODULE_LICENSE("GPL");
A0 V$ h D6 h1 \5 @, u- p. _" |7 a
|
|