|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 Y5 q, A8 g! T0 m; p7 k
#include <linux/init.h>* D" l D C( b8 t3 j1 J4 f
#include <linux/module.h>
9 b' m! ~. B8 a+ X) l#include <linux/kernel.h>
& s% F8 T. Z- I' `. T' I) ?. y8 k#include <linux/types.h>
- O: h2 @4 b. Q% }#include <linux/gpio.h>
+ T. B7 \4 @) ]* l$ X#include <linux/leds.h>! \) Y- d. [ l" l& B: B
#include <linux/platform_device.h>
1 J& P: c, K8 L. j' h% C' M" r7 G( U/ L3 B+ j5 F* ]7 ^$ `
#include <asm/mach-types.h>
0 v: N5 X0 s/ t3 G#include <asm/mach/arch.h>
5 X) C4 I$ E- P; B9 y1 Q' B#include <mach/da8xx.h>
9 X: ^% p+ M1 d2 f9 M#include <mach/mux.h>
) V7 f& c) L6 {0 x3 Q6 G* d7 N5 r5 u
8 F1 `0 L1 E$ o0 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ s( p6 k2 @) e, @% d3 ?) _% G' E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: I4 Y6 }8 Y9 Z. D6 P# a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* K! W3 @" g' J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). R1 |& C4 S' i( m# i
, e5 P! N0 a- `! M) \
/* assign the tl som board LED-GPIOs*/; d& p k5 {1 [2 K0 t, \8 H$ p% [
static const short da850_evm_tl_user_led_pins[] = {# W" n# L2 f* h; Y! E
/* These pins are definition at <mach/mux.h> file */
4 f5 u U! o' M% x; q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 ^! i- ^( g1 ~. W; I -1% E9 g! u' {& }& D" a' ?9 r7 q2 J C
};
* d- k0 R X8 y+ b7 g* ?$ x) _9 Q5 ~1 \& e: o: N
static struct gpio_led da850_evm_tl_leds[] = {
) i# j% ?0 i% k8 J8 t! {3 U {0 C0 n% k) E- c7 U( a. O0 i
.active_low = 0,
, ~0 z! s% K5 o; J) U2 j! k- m .gpio = DA850_USER_LED0,
. X- `: u/ A5 K .name = "user_led0",! k) V) \7 l+ p v+ c
.default_trigger = "default-on",
; z0 ~0 J, a* J. N },
. l( {3 B. q/ S; G {
* D% T/ T$ E( K8 h' w9 K6 O1 y .active_low = 0,# g) R1 J5 @5 S% r G: C5 _
.gpio = DA850_USER_LED1,- ]1 F( N/ l; X4 T; o6 x, p
.name = "user_led1",
( u- t& v; ^$ M7 ^1 Q0 x% w .default_trigger = "default-on",+ v" T5 g* S! L& A# @ t E
},
; r# k* U: J+ t) T* D {* d% E: h- R8 f. _2 w! G' Y
.active_low = 0,
5 ]& P4 [6 e; C, G" p .gpio = DA850_USER_LED2,# A" y( i! a3 y8 K4 W( o
.name = "user_led2",0 C9 M! s3 z5 w. z" i$ |
.default_trigger = "default-on",
7 a+ O+ H* r1 R* p5 I },1 k' L: _' {' B. D
{
1 H8 ^& j$ A( ]. _. i6 l .active_low = 0,' w3 u8 Y" L, w8 K _5 l0 y4 R# H
.gpio = DA850_USER_LED3,* q# \) m+ e0 M" n
.name = "user_led3",
5 |* L; r6 b* y* ]. @8 ` _+ j! _: J .default_trigger = "default-on",
# f( ?$ \1 a/ G& G },( T2 m) ~$ Y* T) e/ {6 e
};
' c* L7 R/ q, i! Y/ O
' F; m9 r# d$ U' V1 `* ]# Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% I6 M9 G) b$ S( u: C. e .leds = da850_evm_tl_leds,
) H7 j9 K8 R) i* D+ g* V1 ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- g$ }4 N/ t4 O7 J8 o$ @8 A- f};
: e7 ?* g* {$ G* S' } m5 U' ]0 ]6 i1 L' m' c
static void led_dev_release(struct device *dev)
, V0 K0 H- X' V% w, K; H* `; r: D{
: O; R2 i+ R$ o8 n. ]};
$ |6 ?+ G+ R% |& ^5 B* b5 o5 a4 F, K& @7 s# Z
static struct platform_device da850_evm_tl_leds_device = {) }% ~+ q+ S6 \4 [! D$ g. }
.name = "leds-gpio", } z( o$ }4 k S' m# Z) ~
.id = 1,- f5 v2 {8 T: H7 j( s# C& F
.dev = { \4 |% w0 P* R S
.platform_data = &da850_evm_tl_leds_pdata,. M3 R$ \ C- ?/ r+ I M
.release = led_dev_release,
7 h# |/ y$ o6 A4 ^4 h }
9 c4 b8 H D E4 S" X};4 p1 x( Q( d0 b
" w8 u) Q* d8 w% S ?0 t1 d- ^
static int __init led_platform_init(void)% t$ \7 d/ ?# x+ v: I+ f4 u
{- Q, Y W. o* u) b$ J
int ret;
+ u! r' z ], w' u( V8 Z#if 0# z6 g( ?& _# f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* C& w) S( S3 a5 a
if (ret)
8 }4 M* i/ v9 B; u# T2 U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! ]0 j& i2 R, [" d: U
"%d\n", ret);
3 E) b0 k+ p. C1 G- s j9 d/ ~. ^#endif* q5 k E. P# x- a4 t) H1 U
ret = platform_device_register(&da850_evm_tl_leds_device);' d' P \" T" {& v* M
if (ret)9 }$ y$ @8 I: T6 R9 Q9 K
pr_warning("Could not register som GPIO expander LEDS");
$ j) K" g. J- ^1 l else3 x, h) a( K9 n6 I
printk(KERN_INFO "LED register sucessful!\n");
5 \ Z& f& U1 |, k
# `7 C9 x' v, i! T" D return ret;1 s8 J% ]3 p9 {
}
# Q% j k$ J4 ~; e
2 D7 \% r+ A E% |static void __exit led_platform_exit(void)
* \$ B2 e, ^. o{. Z9 P, C- q1 m( i0 |6 H1 {
platform_device_unregister(&da850_evm_tl_leds_device);+ @; q) c1 U. _0 P
" d9 n( t% l7 x5 R printk(KERN_INFO "LED unregister!\n");
. [, ]: v& |. f1 e" B/ g}( {5 K1 C6 |2 W8 A+ C% ?
1 F; L5 q9 G3 j; O* x6 D& {module_init(led_platform_init);
" c6 H8 v1 {- c0 A1 j# F* A' imodule_exit(led_platform_exit);
: c2 h9 \- Y3 V5 |* g4 P
5 t0 G7 j0 X! C+ z' m1 e& dMODULE_DESCRIPTION("Led platform driver");
6 M% j, j9 ~" z5 `8 GMODULE_AUTHOR("Tronlong");9 V9 b. Y5 t' p4 P3 D' `
MODULE_LICENSE("GPL");
' F& t/ C0 D: Z9 X$ ?/ c/ C+ D* Y4 r, s4 T F' i
|
|