|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 |# h- j' K1 p4 ] ] J: B6 M#include <linux/init.h>
9 c* q1 Q5 |; X, ~! v; c#include <linux/module.h>
8 l* f; ?! q9 G+ B: m1 H#include <linux/kernel.h>
O2 ]! J1 b5 D/ m8 L; w. w#include <linux/types.h>
2 u& ]5 r$ @9 Q# [#include <linux/gpio.h>4 r0 y! ]1 y! _3 d
#include <linux/leds.h> n: [- l/ Z0 y! |2 B/ e
#include <linux/platform_device.h>
' T% R) M0 o$ P2 b7 @, |+ i5 l& s4 r' U! v5 ]* v9 Z
#include <asm/mach-types.h>5 B8 _1 \1 Q7 b+ `
#include <asm/mach/arch.h>$ {& T" L8 K, O( |. B
#include <mach/da8xx.h>
m3 l' G5 k6 v#include <mach/mux.h>
) J; k z. m" y+ F# l: k8 V
4 E+ p p, J( G! V' `( N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) e1 w4 K6 Q* Z* ]) B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); s1 ~/ ^% d @8 C- W: U+ S& f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 l- u7 i; M) E$ F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 C: o9 v/ s, a- `" {' t1 h: I1 o! n8 f$ q% u. e1 R+ z
/* assign the tl som board LED-GPIOs*/
; _( d' J* d4 ?8 z5 ^! }2 i, u' @4 N5 jstatic const short da850_evm_tl_user_led_pins[] = {
% y- _: t; T, Z4 D6 W /* These pins are definition at <mach/mux.h> file */
) L" M6 b* y# C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; K% X# D3 U- @4 J
-1
r+ U2 t2 d( r6 Z9 v' f( [/ A$ t};
( y/ ~$ D3 `0 b& D) f8 Y* `7 \ b' U v! S
static struct gpio_led da850_evm_tl_leds[] = {3 }- ] v z$ D1 U$ t% A8 T5 @" j! ^
{3 t9 v2 j, t' F4 B% b( h
.active_low = 0,$ E, n( ~/ Y# p1 i
.gpio = DA850_USER_LED0,; o3 z) o1 E- {2 f5 \
.name = "user_led0",2 P5 v, S# f0 Z3 q% m2 B
.default_trigger = "default-on",
- S- j: n# G. D5 r5 G# D },8 c. b" L) a6 P* n! _, l# n+ J( X
{
: w6 W7 t3 v8 \0 }0 w+ d# c) r .active_low = 0,
2 _1 D6 k* l: y- R* A" t; \' k" i) k .gpio = DA850_USER_LED1,7 O- E0 D& v! d+ J
.name = "user_led1",( @5 u7 F$ d# V3 J5 l1 C
.default_trigger = "default-on",
7 J- Z" y' O- G1 S$ P },
/ g& O4 H8 Y/ h! T m' M$ U& F9 j {
, \* i2 z/ S0 a8 F7 G .active_low = 0,
8 u# m& J; L8 I% N* m .gpio = DA850_USER_LED2,
% ~# j& c* L7 l) F0 R .name = "user_led2",3 D3 Z3 q' P" }/ F' o- f
.default_trigger = "default-on",
' C8 b; j- C, F" S' O },
2 m1 n8 P. V! Z' \3 F% [0 M" V {
! p, p* J: h" g# h/ s4 r .active_low = 0,' N0 x; s O; v% f6 S- q
.gpio = DA850_USER_LED3,/ S5 s0 g+ b" ?- s
.name = "user_led3",5 S* P+ a& c7 e6 ^) Z! L
.default_trigger = "default-on",
% ^5 H [8 f9 z0 b },; j5 E! W0 ] ~$ H8 I% y- ^( A9 t
};
3 s! X3 g. s d, v# F- i2 n4 F, V5 s# f4 [3 p/ V4 B( ?6 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. I$ ?* M: F+ w* k/ Y0 K! o
.leds = da850_evm_tl_leds,
1 w" u Q/ L1 O) l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) V1 U& o* }5 W+ r};/ L+ j4 m. X# c, X5 S7 }
/ b r2 z- b, sstatic void led_dev_release(struct device *dev)
( j5 }6 f1 I( d: x1 G+ ^{* o* |' W \" t$ F/ g; F3 u7 {- J
};
8 B- D Y6 J d: E6 l1 }* s( _: c- U
" y4 G) [- Z$ _7 |static struct platform_device da850_evm_tl_leds_device = {
9 v/ t- J; M4 l# J9 {, M$ L .name = "leds-gpio",
* Y' c& F7 T; m# j( D1 e* K: V .id = 1,
5 x) ~! O4 T1 I2 E .dev = {
5 U5 r) X8 S0 `* {- F! ^- S J .platform_data = &da850_evm_tl_leds_pdata,
! |5 S$ N# ]. z) o; n# \ .release = led_dev_release,5 d! [# h( A) T. y2 y7 j; A
}7 }/ H/ `* f2 {$ A
};
$ f8 Z; _; ~3 E3 n5 c' X9 e- [2 w; F% }4 H5 v
static int __init led_platform_init(void)
9 _8 G& h* J4 l ~+ O- W4 @8 K{' z" j' v0 ^, y- t, L5 @, H; p2 c
int ret;! |! i. p: a3 M9 B% {
#if 0
% m+ J1 B1 Y9 u `& H) t( Q4 j# |. S1 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 g% c5 C% C% j& j* e% V* } if (ret). Y: ^" q/ z/ J9 P2 R& A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 D6 W' i! A, D( G. I& m( o+ Y2 B
"%d\n", ret);
8 [, y! E! ?( z2 o#endif
3 f4 V; d1 \( q# ?! ] ret = platform_device_register(&da850_evm_tl_leds_device);
( ?( a6 r: Y0 |3 q% j3 P if (ret)
) o' D- G& q- o( c pr_warning("Could not register som GPIO expander LEDS");
/ `$ u& E6 k/ Z# |. d else
. i, z: W( t2 c) Q3 N- Y printk(KERN_INFO "LED register sucessful!\n");" C5 }3 F9 y7 F. c. ^
0 j( q6 Y5 w% o0 x& f) e6 y
return ret;% v/ ^+ ^3 \9 ]; {
}
+ l, f$ h: {. T" F: p/ X7 i& I+ r# @4 s! t$ c& J2 P% c
static void __exit led_platform_exit(void) t" i- \8 n+ J4 R
{
) a h7 ?2 c) |- k* j9 _ platform_device_unregister(&da850_evm_tl_leds_device);! V4 O {8 G2 @" n3 _* Q+ Y* P
, }0 q2 I/ n$ B0 E( z. `
printk(KERN_INFO "LED unregister!\n");
8 h6 R1 o7 X5 Y}% |8 g. h0 N# b2 h* S# W7 q" d5 ]
) z) s+ o/ f- s6 y C2 K& }$ ]1 z* c- Vmodule_init(led_platform_init);" `4 E# W9 f/ E( [8 ?5 H
module_exit(led_platform_exit);
) f. m' H* ? \* v; T8 T+ x8 g0 O/ \
MODULE_DESCRIPTION("Led platform driver");
5 Q& e7 w& M3 V8 J$ R5 K& bMODULE_AUTHOR("Tronlong");
9 {5 M8 U% F8 u9 f6 |' b+ O, NMODULE_LICENSE("GPL");
; n: @; e; i- q& ~
; F& D& a4 u8 w; r |
|