|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: ~) v3 \& X/ L#include <linux/init.h>7 F& W @( f5 T) a# g* g6 P+ D
#include <linux/module.h>" b6 w# H( N$ \" x, G
#include <linux/kernel.h>7 v: F& S6 _4 K' X/ k
#include <linux/types.h>
# U9 r: K( d0 z. S#include <linux/gpio.h>5 f @# ^$ Y+ f6 g$ m8 \
#include <linux/leds.h>
6 C+ O, U r7 u/ S# }4 y# c* `3 [% V#include <linux/platform_device.h>
8 t6 W/ N- s2 S; L: X k
1 W! ]) p% t5 p8 L" E. H#include <asm/mach-types.h>
* b; ?% l9 H# i* D#include <asm/mach/arch.h>( P1 `; C' q& H8 I& e6 I
#include <mach/da8xx.h>
+ x* E. S% l3 B- f( Z4 j" u#include <mach/mux.h>
' t7 }3 \1 h9 k( m9 q8 K# Z
3 E/ N" P0 N8 s7 T/ {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) s9 \8 H* ?+ `* e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ K: t( Q k; s. p$ v3 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" d1 G9 K( P! h( l- }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 I& f4 N/ S- T# @9 @- P( M' j6 u c
. N" Q# P" l' B- r
/* assign the tl som board LED-GPIOs*/0 o! R' j; L3 }! t5 O
static const short da850_evm_tl_user_led_pins[] = { u3 c, A6 ?% `# ]
/* These pins are definition at <mach/mux.h> file */: _* T/ n* h a W1 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- o+ v: M! Z7 r) e8 V( [9 ?8 k
-1
6 S% b0 V1 ^0 K( ?/ F% S};3 ?# [5 w2 x( | I$ T: V
6 t% X x& C5 L1 Nstatic struct gpio_led da850_evm_tl_leds[] = {
" F, V, L: \/ k4 W' d {& z6 W2 y1 g& Y% S) Z( \% R
.active_low = 0,
" b9 ~4 k& Z% H" _* I% n .gpio = DA850_USER_LED0,
( I5 B R1 j; |+ b2 |* z9 K& s% h .name = "user_led0",
8 g- e V' j, M4 s& U4 T& b: ]; w .default_trigger = "default-on",
, J, o; V5 g/ c! D0 ?- M9 h- u },8 } l- V- r3 j/ h
{' |& C$ I$ X7 T5 `( s# N
.active_low = 0,
( w2 Q4 h7 V2 |" j7 s .gpio = DA850_USER_LED1,
) R! }6 K* ]# I .name = "user_led1",, Q% m0 f( O3 L+ z; m, N" F
.default_trigger = "default-on",
) U! e7 B7 Q) Z, i2 A },
4 C( v ?5 q8 } J% ~/ u {) m& x1 i4 `* g! g x* D6 C
.active_low = 0,, ^# W N4 `: `$ h! V9 ]
.gpio = DA850_USER_LED2,
3 a5 y5 Y$ z. @7 ^0 Y .name = "user_led2"," @( c0 ?) M. b9 n7 N7 i( X
.default_trigger = "default-on",
( K2 K" C, C; n9 b3 U },
# \3 S9 ]- Q2 Y' K& I. ] {$ ^: _% ~' s$ B4 w
.active_low = 0,
; J% B" ?, t* v N2 { .gpio = DA850_USER_LED3,: b( C5 ?7 h2 s# D
.name = "user_led3",
$ n% x2 i v5 F6 I" o; Y .default_trigger = "default-on",
3 H. K. Z, i8 f: ?( C },
# Q9 Y, ^. }. J. y};0 Y' f2 {0 u2 J& o* p/ @
, ^# ^0 B6 C/ d' P9 V8 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; R! n1 G% P/ w3 j
.leds = da850_evm_tl_leds,
6 e! q! x3 k/ y7 Z- I+ Z) e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 K7 n7 B2 ^! W* [* a+ ]
}; @! T% P3 c9 \
$ M5 f: N4 A# k. _: \) M: ostatic void led_dev_release(struct device *dev)
3 e |+ K6 m- |! J{$ S! d0 s1 ~. M- ^; [5 W
};, A. t2 e3 I; X' B4 D( K8 |
6 e7 K2 A$ K+ Mstatic struct platform_device da850_evm_tl_leds_device = {
0 l9 f! G& `: g" n0 z .name = "leds-gpio",
, n' A* K# ~* k& ?- n3 G0 I9 T .id = 1,8 h" ^: H* n a0 r; y9 z6 b
.dev = {
4 @: Z1 @( m( q4 C+ O+ | .platform_data = &da850_evm_tl_leds_pdata,7 C( ~! G1 x* L) A2 h" z
.release = led_dev_release,
. I5 s' r; W+ J. k2 T! s/ x" V }
4 z) E; R2 ?7 W/ B" t Y' D};9 I+ J& N A, r; d5 Z% W' S
A+ F2 w2 {$ d8 C: E# ~
static int __init led_platform_init(void)
# h; S, Y% ?5 b' v8 v0 X{
- h) { b/ S, c, r+ W: b2 F int ret;
" Z$ e: I2 B, l. p$ R" X# g x#if 0$ g7 A) @0 N v: {; z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 k8 l% q O( s5 z8 S! s* k( C
if (ret)5 H- i! h' q5 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ v. ?: b8 _& b$ ~& D/ `9 b "%d\n", ret);. { o A* } c& [: ~0 @+ U8 r
#endif
6 ?& R G6 y9 e ret = platform_device_register(&da850_evm_tl_leds_device);9 e" O" l/ R+ d0 k E# W3 Y
if (ret)+ D, K4 \3 }6 ]( |- Z8 K/ q
pr_warning("Could not register som GPIO expander LEDS");1 Q& w' [$ q& J' o0 ~/ T
else
2 [! n1 H1 G: t( E6 C5 p9 Y6 ?3 c; }+ t printk(KERN_INFO "LED register sucessful!\n");# ^/ W/ X- d$ y/ b/ {7 x
& n) Y) F. X% B/ j7 W r- N0 ^! c7 ] return ret;
: R5 V9 H) ^6 m$ ]}1 J; |% L: i$ Y! ]
6 F& O/ D9 K: z, C4 g, {
static void __exit led_platform_exit(void)
/ F/ r @6 y B9 b! a$ z{8 Y+ B- H$ R- D5 B( f. X
platform_device_unregister(&da850_evm_tl_leds_device);
4 X" w" w' S# w/ l- X
0 D) W* o. B& |0 U. @9 x$ T1 m! c9 q printk(KERN_INFO "LED unregister!\n");
) ^( I+ s) @. k) _7 `}' f* U& c3 }" x4 Q
K1 Y u, ~; V+ d/ B' w
module_init(led_platform_init);
3 r4 T5 l2 {9 n9 vmodule_exit(led_platform_exit);
0 T0 y; H! i8 c- Q
6 E5 e, L" U! w( u3 mMODULE_DESCRIPTION("Led platform driver");( E1 ^: J. N$ C( _, H, W7 v% d
MODULE_AUTHOR("Tronlong"); ~7 w2 l' h4 l
MODULE_LICENSE("GPL");
: I% K z: g; y; I& e. d" v; n6 m; Z! {' r% S- `
|
|