|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ q" s3 o4 x, {3 |0 y1 [
#include <linux/init.h>, o7 F( V. |5 ^* D# x' j
#include <linux/module.h>( g: z5 |) o5 F* F# m; R
#include <linux/kernel.h>+ Z! B) @ k" }( \* ~
#include <linux/types.h>
' i* y5 ^8 y9 U/ e& W#include <linux/gpio.h>
) x$ |; y$ e* e: u# z#include <linux/leds.h> ]7 v D( ?! |; v- V: ^2 n# w E9 V
#include <linux/platform_device.h>+ j- I& o1 Z. M, I# \% H T9 I+ z
6 C4 ~6 r1 W; g; x; \& G#include <asm/mach-types.h>
% V- w$ ^% U0 V! x" E" j( B2 M#include <asm/mach/arch.h>
* D; Z5 ^$ Q( s: M4 f+ [6 e: Z#include <mach/da8xx.h>
0 u- c' l6 k+ l( P% J#include <mach/mux.h>. g/ M9 o5 r/ @5 t
7 M+ n9 l" U% \% h& l5 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- n$ x3 q1 v# T) F* t9 f4 ]( k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( z! N O4 S4 [- c) E5 ^7 L: [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ s- }/ o* B- K/ Q$ H0 T1 y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 S8 @' s# ]6 [2 U- e3 ^, z7 E. P& ~% ~. ?! g- j
/* assign the tl som board LED-GPIOs*/
, W/ {: t0 c% G7 X1 jstatic const short da850_evm_tl_user_led_pins[] = {
' @4 `( Z2 q/ S% {! t+ u* M /* These pins are definition at <mach/mux.h> file */$ B2 C6 g9 E! C$ y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ L9 f4 ~4 U, ]% y; B* n/ v, H Z6 w5 T
-1
3 f, K0 C- n4 w# |};
+ S7 D, g7 {$ n- i7 f# Z9 `, @
! ^% b/ T% I5 N) _static struct gpio_led da850_evm_tl_leds[] = {
2 U) f' [9 H! y) o {2 ~! j6 I7 q$ n, x4 s) g2 Q: S
.active_low = 0,
. X: w- J( [( C% u7 U .gpio = DA850_USER_LED0,
, o8 I S. d' Q+ Z. u9 E: B .name = "user_led0",
, b! g/ s; b! i6 [' g v, g .default_trigger = "default-on",
6 m2 X; {" O8 K% h },0 e) Q9 A. d' y% S8 ?
{. c5 L6 T0 N- \: M1 h8 D
.active_low = 0,
2 N- D* B* c; E, N. M) ? .gpio = DA850_USER_LED1,/ v" {9 n6 P5 [+ Y% v3 f3 A6 \
.name = "user_led1",
1 r9 j5 J6 u G' A0 w .default_trigger = "default-on",: M7 x; J) k4 y9 g; ^
},
% M( j+ A, @( s( O: E {" v/ g a% D; d
.active_low = 0,4 j% Q3 k* }7 X- F V2 q
.gpio = DA850_USER_LED2, n6 _* W0 C( U0 F
.name = "user_led2",+ g8 v6 |8 S& T+ g# s: Z
.default_trigger = "default-on",5 M( |- g. m8 l( V& S( o, E
},
. h1 }- A, l7 r9 i' u1 \2 w! @ {$ _5 m H$ M2 L% v7 L: s A
.active_low = 0,
. B( S$ ?+ c* O9 X- D( B5 _. R) K8 H .gpio = DA850_USER_LED3,5 p" K5 a8 n. z" r3 T
.name = "user_led3",, t- V& c4 P% O* O: G
.default_trigger = "default-on",% m$ c2 ~+ O; o7 _, p
},
- M1 ^% n0 d' e& J};
5 u5 H) J7 o* H _9 |! l
2 V+ b6 U K2 p6 X, G X/ G3 ~" E7 f! Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ t4 d5 ?7 m1 `/ M7 \# {
.leds = da850_evm_tl_leds,) e4 H9 O" U w0 Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 o' Z `% d7 b/ T- d7 R$ b
};
/ `6 [ _, Y. P! }& i% \2 l1 V! F/ y E* g+ ~6 \0 A
static void led_dev_release(struct device *dev)* R; X! V e- p6 p% u4 m
{
0 S, v6 s8 ^- X};/ r) _- J- k6 g6 L0 s
% S6 Y7 z; y' ?
static struct platform_device da850_evm_tl_leds_device = {
4 `" G8 k9 ^* f: }/ w/ T) X% ~; S9 _ .name = "leds-gpio",
1 ^3 `: V4 s4 ?$ L4 I3 |: A .id = 1,1 t9 ~2 p; |% S4 n2 U0 e4 T
.dev = {
) `$ V: e y: W7 g& c .platform_data = &da850_evm_tl_leds_pdata,, u3 D. j! N# B: ^3 M; r% ^
.release = led_dev_release,: o3 X$ Q5 k5 M( x% o# @
}5 G- V2 B6 Q+ N
};2 l- |, A+ L' E) L4 p5 a8 Q: g
$ \. @6 x6 [' o: m' d5 D7 `
static int __init led_platform_init(void)
* H5 f; L( J- J$ Q* X, F. y{
6 H n. P; R: b- I7 k' |( w int ret;" o9 _: Z; P- v/ c a
#if 0
9 S* @: y* D) G5 h! H9 |3 u$ O( W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' J, ?3 ]8 f' H( h3 m# u if (ret)4 I! O0 X8 w& P1 O& r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ d! p* C2 O4 R+ I7 }9 y- p "%d\n", ret);* m( r7 Q* R% w! A/ m3 I# [3 R$ p' h
#endif
+ {& M5 o' d" J3 M- o ret = platform_device_register(&da850_evm_tl_leds_device);
; t. s- b( z; h7 Y( Y, C if (ret), ~/ O' K7 k2 R+ w9 E. p
pr_warning("Could not register som GPIO expander LEDS");5 P3 c9 ?5 i* R. |6 ?& H1 ?& J
else$ x" p" G& S$ p
printk(KERN_INFO "LED register sucessful!\n");! t0 M& J/ i4 N' o( h, A; [* t
1 ^0 t D- r8 b$ v return ret;7 \$ f' f/ Y' w q
}! T5 R; {8 h, E. V: s' A
4 h% W9 M$ ]- Y, c" x/ qstatic void __exit led_platform_exit(void): b( L, C! u! e/ A1 Y
{
1 n3 t* w1 _9 f o platform_device_unregister(&da850_evm_tl_leds_device);) K* d, k5 E! Z- R# a
9 k0 r/ {# Q7 g& H% n' x0 F6 R
printk(KERN_INFO "LED unregister!\n");# m/ p" ~, z+ D: L3 A
}
$ N8 [* r# Y1 A8 t/ L8 h7 L; F& U5 S! {$ b9 ?8 X. t+ t/ q' p8 x( R. z
module_init(led_platform_init);1 q1 ~. G/ z1 J
module_exit(led_platform_exit);
) M5 \+ ^# {! `0 ~" z5 k% }, |5 t% Y: v, J6 J5 ^- i1 m( b2 ^0 m: R
MODULE_DESCRIPTION("Led platform driver");
+ s/ e4 I- p# Z: Q- h1 U1 KMODULE_AUTHOR("Tronlong");
- k; O \; ^0 o1 hMODULE_LICENSE("GPL");% y5 ~9 K% M" N1 @# x' P. y+ i* e
) c2 I3 C: m# ^8 l9 ?$ ]
|
|