|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, ~4 P0 e5 o8 I" f G#include <linux/init.h>
9 @% k( T3 B( k& [6 w$ \. I& W3 J4 q#include <linux/module.h>+ i8 q% q# i( d: u; O7 ^
#include <linux/kernel.h> `! [3 h! [6 P' c4 |
#include <linux/types.h>( Y5 O0 U/ A$ `0 |/ j( g4 `
#include <linux/gpio.h>: L: `9 \! ]& `7 b; m9 d
#include <linux/leds.h> g/ r( g; _# V$ e+ A0 n
#include <linux/platform_device.h>
: c# b. }2 Q: j3 }* f7 @8 z& I- |% I# k2 C. l% r4 P3 h
#include <asm/mach-types.h>7 N/ N2 T" d5 `$ s! f, e- ^
#include <asm/mach/arch.h>2 t+ X7 t! D5 z% s' n0 n
#include <mach/da8xx.h>
5 M( M! r$ |5 l4 E, j% R#include <mach/mux.h>& c! j# C6 O0 J, n4 A0 S
/ M$ Y7 V! l; a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 [3 W1 |# P9 H6 ~) G3 n. ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 J: e7 F: H9 |0 N2 A) I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) A- t) {& B9 K, X9 @9 \0 U4 D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), M: n! S" R6 \
: c; Z2 V! l+ r5 W* q3 X/ @/* assign the tl som board LED-GPIOs*/2 ]3 C) t% x; W& [! J2 f
static const short da850_evm_tl_user_led_pins[] = { t2 }# h" p, |
/* These pins are definition at <mach/mux.h> file */
9 H1 H9 w+ L7 W4 B' ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 @7 M4 }. g6 e f8 B -1
- N! X( W5 ~/ _0 {1 f# e: p) j! N: q};
r7 M3 M( _. v$ X$ }, M# n! i4 q- ~7 D; h/ _9 ^: r
static struct gpio_led da850_evm_tl_leds[] = {; J: u6 b3 ` w) u4 t' Y
{
1 s: S; Z) Q4 g6 g. @1 L, _ .active_low = 0,
3 W$ ?( z$ v B0 R; k* A' p8 ?: I .gpio = DA850_USER_LED0,7 @. f7 f. G- U1 `$ o6 d- e$ d% Z
.name = "user_led0",$ t/ U9 G, l: r0 @& P
.default_trigger = "default-on",- u z/ \& i! i& G
},
* Z% u* \* Y; K4 v" D {
+ z) Z1 j: V" W; j0 P .active_low = 0,
3 x& {( [7 A5 F) i- ^ r3 w .gpio = DA850_USER_LED1,
' V0 R1 v* i$ y2 i .name = "user_led1",
7 q, y3 t& A e" H. P% g .default_trigger = "default-on",- _. C* l2 c" ^, M7 W9 O1 V- J
},
# W! _+ b/ l! ]/ e6 \& H {
( K, p, r' i# c/ h2 B .active_low = 0," ?% M' n6 k9 E+ Q1 b1 c* S1 Q
.gpio = DA850_USER_LED2,
, U( E' O- s$ A/ A% U/ Z# x .name = "user_led2",+ v# H, d; ?' M* E+ P8 z, ]& U
.default_trigger = "default-on",' h- T) {4 V, B( j1 o
},/ N( A* t( ], ]; u3 m9 l, z0 o
{
9 h) D9 |* }+ t* }, g+ M, D .active_low = 0,2 o# ?2 \6 q A! u7 }0 N5 Z
.gpio = DA850_USER_LED3,, z/ J4 k! s4 P! m4 V
.name = "user_led3", M7 u* n4 f4 n! M4 ~/ |. }, A! [
.default_trigger = "default-on",
* K% }* O( c& j/ V },. l+ N! P4 G4 `
};/ @2 z: I Y/ v4 r+ T; F
0 q/ j2 E5 z0 A3 e0 z/ b; u) \6 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 `8 C) \/ I% o8 W% s# [8 {( k .leds = da850_evm_tl_leds,8 g1 Q' c3 M2 V; ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' ~' u& f( D0 ^5 S
};/ R0 u9 _! T& J6 j
0 Z$ P: T8 y: A9 `static void led_dev_release(struct device *dev)
' p* w" A$ \9 n, F Z{% V: A; S- e2 F! p
};+ b% H! k: W8 f- W/ f
1 H0 u$ @! L: F# ^- ~# t
static struct platform_device da850_evm_tl_leds_device = {
1 a: W0 M" S$ M. y .name = "leds-gpio",
5 c" \5 B2 k8 Z .id = 1,
: x. ]2 @7 \- V' x( y .dev = {- e) t. _5 B r
.platform_data = &da850_evm_tl_leds_pdata,1 _# ?2 K9 @5 M' C( ^% F! R$ s9 t
.release = led_dev_release,$ ^1 L% n H" t, K( n2 X9 f
}! j. a! Q! X3 `! c7 H" j0 r; U U
};
( F* ]: A% \0 w9 k3 K. y7 x4 X
' k+ x$ i% s5 l [6 u2 Dstatic int __init led_platform_init(void)$ T: S' }) S& Q2 z6 ?& q# @
{( l I1 W: u' D2 ~1 y( M
int ret;
2 \; W R4 Y. r" ?2 U#if 0
/ o& C( ? y* m0 ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* A* g! S* s1 o3 M0 F if (ret)$ a0 |; r: U# w" H$ f" v) U9 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 @& u# L8 f7 u8 i7 {* a; P; N. U0 P "%d\n", ret);4 S. e, T( q2 ^- ]$ s5 H
#endif
3 p* Q9 K0 `$ M5 r8 A: A ret = platform_device_register(&da850_evm_tl_leds_device);0 ~( a! ?* {+ `3 c- L" t' q' B
if (ret)
3 ~' ]7 l6 w3 o. M4 v& j. \ pr_warning("Could not register som GPIO expander LEDS");
y T7 x% a/ k/ z+ F; }* ]+ ] else, S) x% y) i4 r# z7 v" N& `5 g
printk(KERN_INFO "LED register sucessful!\n");) y$ `! I; j: }' o/ ]
' Q7 ~" W, W6 Y" n3 h1 e
return ret;
* _# s+ d7 u$ m3 z5 H}* c* e9 o1 }" g" Q* E2 @0 a: l; e0 ?
6 ^! y/ Z; o3 K7 E; e
static void __exit led_platform_exit(void)& P# }0 i0 m& p, a3 ^8 H2 }! d
{" b% z% A! s* x5 U$ Q
platform_device_unregister(&da850_evm_tl_leds_device);
4 [& a1 ]8 m' K# ?' ^ n% g* C. C7 ?% S1 j/ Y/ s( o2 I; V
printk(KERN_INFO "LED unregister!\n");0 L* F7 `, G9 w) R( K
}
# u7 p8 \( N4 k5 ?: s ? c3 M& ]) `6 d; O) R
module_init(led_platform_init);
3 B3 D9 Y0 k% ~3 |0 pmodule_exit(led_platform_exit);
& O+ t! W# X& H/ x2 c+ i# v& j# d8 e9 H3 B0 G
MODULE_DESCRIPTION("Led platform driver");
- d& f# s" ^0 _, _7 NMODULE_AUTHOR("Tronlong");
4 s" p F3 Y0 L& iMODULE_LICENSE("GPL");
) e& S% x2 r# P" \- h9 I$ L! J4 b6 J5 F* ]: {
|
|