|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 C* I. t; k" z; X, y ^( z0 z, _* W
#include <linux/init.h>) Q, m3 i4 ~4 j2 e, V* D' l# T! ~
#include <linux/module.h>
0 g: Q3 E) ?: ^1 s: w0 ~& A7 S#include <linux/kernel.h>
( r9 V) l* R, q% P: L#include <linux/types.h>+ z/ I; I: T9 ^- k9 C n
#include <linux/gpio.h>
5 S4 L+ `, |, h#include <linux/leds.h>" D, }8 j! |4 t: j
#include <linux/platform_device.h>
2 S! B+ ~, u4 K9 v: R6 T2 d
$ ~$ Q0 D0 _8 v1 k#include <asm/mach-types.h>
! P* `/ J/ F6 r#include <asm/mach/arch.h>
% i. C M9 x+ b1 T) G#include <mach/da8xx.h>/ C0 l# M2 S" n& D2 }) `0 G
#include <mach/mux.h>1 U! S ^( \7 Y# d% L# j
) `# ^: G+ Y2 N V' D0 W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 T* O* T8 w; J1 o4 t. y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- z! l# R, O7 s) B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 n8 u( q8 }3 u% t, V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# u7 k7 e) l* x
7 z, ?* D2 R5 f0 ]- M# t6 z) K5 Q/* assign the tl som board LED-GPIOs*/; x9 S' i# V/ l, U2 z0 s7 R, g0 C
static const short da850_evm_tl_user_led_pins[] = {
$ \& z& \- L7 u e* \" b) @ /* These pins are definition at <mach/mux.h> file */
0 F& c, P j6 R' N3 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ H. p6 c: a. C, X4 S -1
; y+ Y7 {1 A* ^: f# I7 n};
9 f% x1 b5 p* ]! w- o5 l
3 `5 ]* }9 ~8 c. Mstatic struct gpio_led da850_evm_tl_leds[] = {4 o' C) C9 @1 J6 v
{
* l0 `3 [! i9 F .active_low = 0,. t2 L. W0 {) s) v
.gpio = DA850_USER_LED0,
5 b$ |+ ]2 M' A; e! a' B0 K A .name = "user_led0",
( u8 u) [$ y7 S0 | .default_trigger = "default-on",
) t0 n3 T! g; I9 b' V3 c/ _, Y },
( }7 g. e7 R3 L4 d# c* i: e! K {
! M D- T% S) q2 J$ t: o7 _8 t .active_low = 0,
8 H/ b: ~3 v8 d ?* ] .gpio = DA850_USER_LED1,
0 @/ j+ H4 u' [5 ^7 X: `) n" E .name = "user_led1",
' b% w0 U; y( e' i. q .default_trigger = "default-on",
* k; n' s) ^4 \* u9 J7 | }, k2 Y7 j8 {6 z! e0 {- E
{& X% \0 q) L- Z9 J* y% Q& M }
.active_low = 0,1 ^9 j( u5 r$ R3 E: s& }7 \
.gpio = DA850_USER_LED2,! ^- `6 Q7 a. u
.name = "user_led2",
9 N/ X0 Z z8 ^( h( K0 f7 f .default_trigger = "default-on",, G% H) \2 p6 d- i1 m7 E p
},6 o1 K3 M; c- O6 Z9 f
{ \" l1 C0 ]! p4 t* z. v! W5 ~
.active_low = 0,% Y9 c4 \: p( M
.gpio = DA850_USER_LED3,
3 k/ P! f# p# X8 M( m0 c6 c) J .name = "user_led3",
4 A L# ^' @4 ^5 c, k8 o& O+ R, L5 w .default_trigger = "default-on",: k; F+ [) x7 `. J
},7 s4 D0 G; b6 W5 [! Q7 L8 w) I
};
) @) z' o3 ]' C9 s) p; V. d
9 o# r- |% q; B; s' lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ y1 Q; L5 K. j6 u; i2 B* i .leds = da850_evm_tl_leds,
* D' V. ~7 M1 o' h* _1 K. ]. f& h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 p5 z2 f) X" a! J}; n- l; U2 }: u4 x7 T
) f* s W0 n8 Q) a6 c5 Z
static void led_dev_release(struct device *dev) I( g8 ` g& k2 |
{
5 o. _2 N/ `: y3 e5 Y' N0 z/ l w};
6 H: ?* R9 T0 w- c% }8 e n- X5 N2 f) }- w! ^+ y5 o5 k1 Z
static struct platform_device da850_evm_tl_leds_device = {
+ c2 g2 ^9 U/ m( c9 m |! u .name = "leds-gpio",5 v9 v3 W, n5 {7 p
.id = 1,
) z; y; a8 `$ b7 w2 P" e* {' V .dev = {2 c( }7 B9 `! D6 T2 D0 Q2 L
.platform_data = &da850_evm_tl_leds_pdata,0 ~: h6 _ ^+ H9 X& W& l0 c
.release = led_dev_release,
3 j4 O( t7 L2 v4 W) A$ |+ y2 k }( f3 z2 g& Q3 p2 [
};* V6 h* a) Q0 q* D: n: B
$ u, Y! n% U! |, ?/ a+ m! F; L
static int __init led_platform_init(void)" v% ]8 I1 D/ ~0 g6 M; A
{4 O: L6 l9 O4 W5 z- f) [# ^
int ret;2 I8 y1 O- A% u, Y
#if 0
, x2 c% X& ]: N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; a: c" }7 V X/ K2 V$ } if (ret)& A* d2 W! f: O4 }. ]5 l7 r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" D9 q. f' b7 V) o! }+ m, ~
"%d\n", ret);
/ u; I. d" N( N+ ]3 Q#endif# L; y7 ~' A5 l1 d
ret = platform_device_register(&da850_evm_tl_leds_device);
" |7 Q7 |/ R6 U7 ]! d if (ret)6 Z8 |; d4 F9 \' B1 _' s3 t
pr_warning("Could not register som GPIO expander LEDS");
; A3 f4 D1 H& @# N! _' l6 ~ else* f) t/ o+ Z1 a% q
printk(KERN_INFO "LED register sucessful!\n");
' ~5 o0 g: O% b( d! ^
1 v7 [( i8 M- s. g" |: L" e return ret;
. _( B, ?" ^5 l1 R# ]) @- C9 X; ?}
% s: s( Y7 O1 d8 a9 J2 [6 u) j+ Y* b `, }7 \
static void __exit led_platform_exit(void)
- i0 _! ^, q, i{( v6 b* H) i7 Y! {& g, U0 I
platform_device_unregister(&da850_evm_tl_leds_device);
8 {8 }% \- a' J* p# H# `: E4 J! a3 N9 d# j; N+ A. b2 ?+ m) A6 i
printk(KERN_INFO "LED unregister!\n");
$ t K" r; q4 y; Z- I}
' W; |- L3 Y9 @% Q) G
1 Z H: ?1 h+ Vmodule_init(led_platform_init);
+ X4 ^+ n5 Q$ q3 Rmodule_exit(led_platform_exit);/ E/ y: |/ g! q; G: ]- X
5 q/ D: _, w/ X( Z% I3 w7 l
MODULE_DESCRIPTION("Led platform driver");, @2 f* {* P- U9 l `5 e7 A
MODULE_AUTHOR("Tronlong");
0 v- b& G X7 B: KMODULE_LICENSE("GPL");* n$ `5 C3 e, u
# c/ y# @& v7 s! n) q `5 e7 S) K7 L
|
|