|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' b3 S# t# x; V#include <linux/init.h>; T5 e4 D4 U% l# l: p
#include <linux/module.h>* Q) B; V' H0 B
#include <linux/kernel.h>) B6 y6 d9 G- w, c9 w* S
#include <linux/types.h>/ {3 P0 [ _) T& H/ v6 b. p, ?
#include <linux/gpio.h>( Z+ o( Y# z* z( q- o' o
#include <linux/leds.h>
2 Y0 u4 h+ p6 @6 ^#include <linux/platform_device.h>
S6 _! F; P0 q5 k% v
6 m2 I* L8 ~; p4 _' k: p#include <asm/mach-types.h>9 `& A8 b) i. T6 E
#include <asm/mach/arch.h>! [# K8 w" m' b
#include <mach/da8xx.h>
6 [9 l m& z- U; g#include <mach/mux.h>$ K9 x ?7 R$ G& B6 P7 C
! R7 L A* a" A# c; O5 L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 [# H, d& t8 }* J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) D# g# o, ~1 ^! x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 d) f/ v# ]/ ]" e6 Z9 @3 m4 M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 Z/ r0 B: r+ O! K, p: z' Q5 S ~$ k9 d; C7 G& w
/* assign the tl som board LED-GPIOs*/. j* z$ p. r$ j/ q* e) l& a
static const short da850_evm_tl_user_led_pins[] = {
& B4 A; g) L& c& p8 k7 _ /* These pins are definition at <mach/mux.h> file *// K$ f4 [+ W3 ]1 I3 R. u" [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 ^% o* D' s+ B, Q" |2 m
-1* ^" [' @* S z) h r
};: n# T7 l2 u: O0 M% g( O
) \% X1 V3 ~& Q4 d+ f9 Dstatic struct gpio_led da850_evm_tl_leds[] = {+ k( w( h! Q9 [, D5 O5 l. n
{
+ D* ?& F8 V* {+ ?3 S .active_low = 0,
$ z: k8 K- X' B u/ g .gpio = DA850_USER_LED0,
; H" I) M; I% Q# P% ^5 p+ u .name = "user_led0",
. q# Y$ d$ a- N, H" v! s .default_trigger = "default-on"," ~; Q( @( S3 N' }0 ^( g% x+ ~+ d5 \
},& g$ h" M. `, Q- l: k6 K
{
6 i8 C4 a s( y- {* E .active_low = 0,
- N! |- T2 O4 q+ a2 {/ y .gpio = DA850_USER_LED1,9 N: I" i( E) v+ b6 [. N$ z1 t
.name = "user_led1",
" L: D3 V7 s1 v& |4 b6 X S! T2 X .default_trigger = "default-on",8 O |3 T9 v3 l* P0 w
},
, T5 E+ z& ?* {0 p" Y {
" ]% i* b* n7 l6 C8 r/ u) l) c .active_low = 0,
8 W5 i/ l" P n .gpio = DA850_USER_LED2,5 S1 e. s/ p- f8 k
.name = "user_led2", j" {& |4 M! }' ?# u+ w! g
.default_trigger = "default-on",7 ^$ @4 d& X" I' C- J& T1 x
},
* y7 G/ v1 u* P; ~3 G8 ` {
0 }0 Q6 G0 G- F% z+ Y' |6 f .active_low = 0,) J5 q( N% f0 e' F" [ H9 C# l
.gpio = DA850_USER_LED3,
# c3 e" v% n, L7 }5 f .name = "user_led3",
?# P8 G+ f" H9 u .default_trigger = "default-on",* A! m7 X. [: ^ l* Q/ m5 O
},
% P/ ]# N5 ~9 W$ M};
( g/ M" H$ |6 W' l2 q
: l+ o3 w' Q, g7 V( z$ Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( R) ]5 L; _5 N i
.leds = da850_evm_tl_leds,
, d" s5 k6 v7 S: b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 L- N* C4 t! r; _5 M+ X/ T" v};& y4 p0 i3 D5 }8 ]' o
+ ~( @( Z! b' k8 ]7 Lstatic void led_dev_release(struct device *dev)
. J7 S* ^# w* p4 E% b; h6 ^5 B F7 a{8 K0 {. l8 `5 ]+ {! A
};& D. e7 r( U" y4 Z ]
. R. C% ^, m5 I! qstatic struct platform_device da850_evm_tl_leds_device = {% |" R- S- t) i! t6 k/ o
.name = "leds-gpio",* l5 e! Q" L3 S" s$ {/ \- X+ D; m
.id = 1,
% W' v* w, j3 F% `4 p .dev = {
) W: @# X' c' c5 v- n .platform_data = &da850_evm_tl_leds_pdata,
7 d1 r' o8 X0 D9 U# l+ x .release = led_dev_release,
c H. B" {, y7 W& B$ W; H0 E- c" }# p }
! c1 }, E* S8 u. o `};9 D8 Z+ g0 g) ~7 P( `% }) I
) O$ H8 [6 b6 W! ~' n9 y* p$ g
static int __init led_platform_init(void)
/ ^- v6 [4 ~2 h# X8 @ s{
( e) j) m$ w' A/ y; W$ ? int ret;
- q' m/ k5 q, K1 l3 a( U1 A! x0 L#if 0
0 _+ I" ]- P8 r A: y; N# S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 t$ ~+ R) W! g% X7 H; A4 g" q) u if (ret)
" X% d# x8 \% |4 X. w) s- { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
w: ?( ~. m. x* C" a' Y "%d\n", ret);
. a5 G. L1 M$ k# k0 t, ]) H#endif
+ i8 f9 r; F7 y- g7 D) K9 G5 _# S ret = platform_device_register(&da850_evm_tl_leds_device);
1 L( P, c/ f! C- ^/ E if (ret)
$ W8 l! ]* v& g1 u pr_warning("Could not register som GPIO expander LEDS");
- z9 c. P! ?7 J" L- E$ D% J else+ n. ]6 @. s. S4 }6 |# B" B$ J
printk(KERN_INFO "LED register sucessful!\n");
4 m+ h& ~5 E! y* t3 E7 F0 o; T9 g
return ret;6 @& f. {6 y5 f
}! K/ p. z5 b4 X* M2 K
/ N! m) C) I+ E; M, Hstatic void __exit led_platform_exit(void)( S Q; k' G) X* K/ F1 }( i) M
{- U! L3 | W0 B7 K
platform_device_unregister(&da850_evm_tl_leds_device);
8 V: r L A. Q
J. Z* K+ x% J% I; {' K printk(KERN_INFO "LED unregister!\n");* [5 {( j# M" Y' |, d, O9 F d
}- ^6 J7 R, Y* O8 s, b
8 |$ A% T6 v7 O0 A) Y+ E& \
module_init(led_platform_init);
, h0 |$ m4 Y6 \! \+ jmodule_exit(led_platform_exit);
8 f- {: x8 p4 q+ _' w3 i- c+ V
' M3 Q7 L z/ bMODULE_DESCRIPTION("Led platform driver");
! }% [3 Z! d# IMODULE_AUTHOR("Tronlong");
. A4 O! e3 Y, ]( Y$ x) |( NMODULE_LICENSE("GPL");
: a: H6 g, d% w9 V
4 C+ L" H [0 t$ Y" A |
|