|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) |3 v( J6 n) h$ r, u
#include <linux/init.h>
$ M) L& d, |/ f4 C/ p#include <linux/module.h>
( z. T6 V% A# z, {4 D#include <linux/kernel.h>
. T9 \6 h" g. X1 m. j) u3 P#include <linux/types.h>2 ~# s" m" Z* P) l) G" m
#include <linux/gpio.h>
7 y( G; y! {6 Q5 N- Y( F#include <linux/leds.h>
1 a) t& U& K2 {4 t x#include <linux/platform_device.h>% n; V. K. @3 Y
& ~+ Q( [3 K% k7 N#include <asm/mach-types.h>4 E0 H$ c( F! Z ^' ^& j4 k
#include <asm/mach/arch.h>. X8 w5 u7 o3 b. s/ b
#include <mach/da8xx.h>9 r3 y1 O3 Y7 Y
#include <mach/mux.h>. G, b$ Y! N5 V" k# j* F
( B- q2 @7 r X% i$ {# W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# z& f- V' N& \6 L5 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: q5 C! ^$ B2 m( X1 Z! P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ \. i( ?. f* y1 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), O6 g% G( S! y+ Y; t) @
% A& H" y7 d- P6 e( l# L- R, ~/* assign the tl som board LED-GPIOs*/6 e2 C/ \- \6 t' N
static const short da850_evm_tl_user_led_pins[] = {( `8 Y' P7 J J% D$ Q) y- \9 F$ j
/* These pins are definition at <mach/mux.h> file */
+ f. L$ A% H: O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# d9 Q, A/ |3 j) d -1
+ j/ S: Z* V2 {: V};* n* i! g/ c' c5 W; b- I
5 F. U! O1 K# L- Q: M% Q, R
static struct gpio_led da850_evm_tl_leds[] = {
. }' f0 X0 L0 S4 i6 b: R {3 ^( `0 f$ j; E# S8 p
.active_low = 0,4 G: [2 Y' d# T! H. a
.gpio = DA850_USER_LED0,
6 {# T3 o `5 @. F7 r- H .name = "user_led0",! `9 ~- y7 J. I4 K$ m3 j# g/ l# e7 Y `
.default_trigger = "default-on",
' P6 E2 P' @' a4 u9 D9 d8 o },3 T! T9 Q* B8 o$ |% L( R# k9 \
{- h2 B& f, h$ ]; M1 i: h
.active_low = 0,9 \, {+ @) ~, f& g# v. ~+ w
.gpio = DA850_USER_LED1,) e" ]2 U! z- o! C: T
.name = "user_led1",
@; y s7 B" y2 f, |! i .default_trigger = "default-on",$ e5 n+ _, |' e* p$ ~# x+ d- l9 q
},% `+ x0 K6 y; n! r, g0 d
{
: I$ V' ~( [1 H! m" k0 ~! s: a2 U. w" V .active_low = 0,# W3 H H7 {: [- h4 s9 _
.gpio = DA850_USER_LED2,
! j" f# K: \" m6 ~0 E+ s .name = "user_led2",8 p6 J4 O# F9 V/ @# U$ x; q
.default_trigger = "default-on",% r5 }3 O" ?1 Q9 V/ @
},
9 s7 h4 G9 z0 `/ h. A/ E7 y4 h {
8 r% G9 G2 N% e$ l4 n- J+ E .active_low = 0,
6 Y+ y) a; G1 k, [4 q8 X, `& d .gpio = DA850_USER_LED3,
, b8 n& K1 m* m& I .name = "user_led3", h; Z6 d, ?9 N& `) F8 I! A4 p
.default_trigger = "default-on",
5 V9 b, {: V; {2 p& ?1 h },) h$ k7 g7 q2 v
};
1 P6 }# m# [4 S6 ^7 d' l1 u! ^- V7 W: ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( ~8 ~, l0 f8 ?/ c .leds = da850_evm_tl_leds,
3 X; Z# y; }+ Q/ H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* q: g, N# n- c& [) J};
2 E* b2 _! s+ ?& ]* x- t
* m" Z% n( `+ s; h+ f5 b* qstatic void led_dev_release(struct device *dev)! h' a2 d5 ~* k
{
' D* e% ^( Y* o2 }6 W};
: w C9 T' O* y7 Z- s3 C5 \* k, `$ Q- }, H" P" }
static struct platform_device da850_evm_tl_leds_device = {; G/ i2 E4 }6 |3 N3 F
.name = "leds-gpio",
, }7 M b Y# m) d+ \ .id = 1,3 n, o: V9 @; V( Q9 W K
.dev = {
- g8 w: e1 |: {* \4 m .platform_data = &da850_evm_tl_leds_pdata,
0 ^- b( a4 A$ S# O& K .release = led_dev_release,8 v# k9 ~$ T J' t" C$ ^ `( s/ b
}; Z1 k$ y. y7 J5 m3 X; I* e
};
' f" J9 r# } N. o& _6 M, M ~( t9 I' J0 Z, j0 H! D
static int __init led_platform_init(void)5 `6 i/ D' [- ~" M7 b3 I
{" \5 J/ X* j6 P5 \) k
int ret;
; U8 z# @" p* P8 @8 a2 K#if 0 U8 _0 q9 h4 R) g! B3 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 W: q2 B/ ?5 T2 ~& o' [
if (ret)7 Y# @' N' o( P- \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! q; ^. E# t/ O+ e8 q# g0 e "%d\n", ret);8 \/ O8 e# y0 f4 j; Q, f3 N
#endif2 N- u- E' a! |; o* y2 X' ~. ?
ret = platform_device_register(&da850_evm_tl_leds_device);
( c1 u. y9 p( k, e* A! @5 `7 q if (ret)2 ?, Z! U$ k8 i% a8 k
pr_warning("Could not register som GPIO expander LEDS");7 o& ~4 R, O7 a, P' E8 U
else
# `8 X1 b3 |7 X6 \ { printk(KERN_INFO "LED register sucessful!\n");: v/ r1 U, {: {, C5 O' Z3 z+ B' d: U
) D0 i# B% d9 Q }/ T8 u- H" B/ q" Z
return ret;
/ n7 c4 Z% w0 e7 y! J: r}
* q- s) Z( U4 b% x' q. g) d% k+ P4 [7 M$ F K- J l" R& }0 j1 g
static void __exit led_platform_exit(void)2 P6 h+ X) L) b) x
{
! _! S8 J$ f' N: z' h platform_device_unregister(&da850_evm_tl_leds_device);7 P1 r1 X& |) r! g5 ]0 C$ k
3 Z% Y2 Y: u' _; f' E7 ] printk(KERN_INFO "LED unregister!\n");) G* }# Q \ I; j( f( L
}
$ w0 k: X4 H4 u1 L
7 I. d6 @9 c% R% _' f: L9 gmodule_init(led_platform_init);, c s2 K" `. s* Q
module_exit(led_platform_exit);# ?: P" i* P# q5 D$ F0 @
1 f( a' H; m# Y: [" S; uMODULE_DESCRIPTION("Led platform driver");
$ a, g! y9 a- wMODULE_AUTHOR("Tronlong");
( w# C5 P* O ]& q+ j( W0 \MODULE_LICENSE("GPL");
/ s/ y& D2 u" B
6 m4 @- i, @2 n, J$ I& K) @ |
|