|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% ?9 V# @/ n1 X# f#include <linux/init.h>. h6 X6 a! Y# u' k% v6 q
#include <linux/module.h>1 b4 x& B0 @" [( H
#include <linux/kernel.h>3 p% a! ^8 _1 R0 {/ U
#include <linux/types.h>* W; s2 `# D' ^6 z% S
#include <linux/gpio.h>
1 k' d3 E, m- F7 O1 T2 t$ A9 N#include <linux/leds.h>
# S) J2 h* ^0 x' T" U* |! h#include <linux/platform_device.h>
, `) m* ~6 p( Z7 r2 f; O1 b% q" ~, K- N
#include <asm/mach-types.h>$ r' r" _5 i' n) b
#include <asm/mach/arch.h>7 M/ Z- K' Y% b* p
#include <mach/da8xx.h>
4 X* m3 _/ k/ u! v! o9 E. j#include <mach/mux.h>
9 ]! R. b) w" T; [5 B% x) _- [6 ^
. U# ^- F. u% c$ a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 S6 a) }$ O4 r6 P0 s( f5 ?$ x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): o0 x# Z; R8 s! q6 R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 j" T0 R% J9 H0 l3 R1 g- U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( Q% b4 }; g4 C! Y J0 {2 U& y. k. H* {' `, a* q& Q$ C l. v; |
/* assign the tl som board LED-GPIOs*/
+ |8 ]7 k7 X2 n& ~/ Pstatic const short da850_evm_tl_user_led_pins[] = {
6 L6 |' y: g7 C7 e" F1 K /* These pins are definition at <mach/mux.h> file */
+ c4 {+ |1 V& D0 _$ M" i6 g! ^" s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 w+ [! p2 i# y4 T) p/ q
-1
( f0 t6 A5 \' q, ?( n};
% T( K' V5 U0 Y/ d# j+ ?; a$ R& t7 _( A
; H+ e6 d7 X' i) Q2 q& v, [static struct gpio_led da850_evm_tl_leds[] = {
; S' b; t1 q& ^1 C: S) r {
* B6 {+ _+ ]; r# O- m$ [; E .active_low = 0,; Z7 L) h* `. |8 a8 J- c; Q% }
.gpio = DA850_USER_LED0,& R3 n' u# R& W4 a% L. E& M
.name = "user_led0",
) P$ d5 k8 H& J7 n4 K .default_trigger = "default-on",5 a* Z# o4 B" t6 ]+ b. Y, ]
},
3 U( @ H: p8 S( L/ ^1 s. P9 D9 V {
1 e% f+ O' s" e* e8 K( a/ b .active_low = 0,1 |; d0 d; F( Y
.gpio = DA850_USER_LED1,! \- f2 w: {8 P/ t% A. ?
.name = "user_led1", @4 \7 _( K9 h1 i7 `
.default_trigger = "default-on",
& \" r$ r8 [- M. K( F },8 D# N" r# Z" a4 `8 x# |
{
5 u9 l1 Y6 Q) Y# q7 h .active_low = 0,& M9 [8 U! W- ?. |1 i2 W0 p
.gpio = DA850_USER_LED2,, b+ i! X u8 o: _' _$ C
.name = "user_led2",, l) x% ^# U6 M/ ]. e
.default_trigger = "default-on",
. O# N! x z' s7 d1 F# W( O0 z },6 P7 V8 k4 b- \/ y
{
' A8 |% D: L% F$ _ .active_low = 0,
. ?" ~0 V. b0 n' B C$ D9 j6 m .gpio = DA850_USER_LED3,
" R$ Q3 f3 p* h% E+ `6 @8 V0 F) u .name = "user_led3",
, y7 a$ @2 i7 R+ [ .default_trigger = "default-on",
4 f4 W: w( W/ \& e( W0 P) h; N },
) K3 B3 ?- K- M' W# J: ?& p% t};
7 ~2 y t' C, h; E# u& L5 c+ `; K- Z1 p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! w$ X( {* o# V' C/ X .leds = da850_evm_tl_leds,
( U5 _# F! a" m' h. y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) ^8 ?- j! t6 U3 K/ K$ [};
3 T4 }& f# j$ S: X( r
! ]/ m! ^+ w1 x; Q" ~! qstatic void led_dev_release(struct device *dev)
$ K2 f) _/ {# y( K{
( e& ~2 R; T5 {3 A. h# T};; H+ r! K; ]' {- u
$ L$ M V" W' z: ?1 Istatic struct platform_device da850_evm_tl_leds_device = {+ V2 h! t9 E& X9 Y
.name = "leds-gpio",
& o1 l: {, A/ H1 q( v6 R" D* t+ } .id = 1,6 \! x/ u3 z; E& \! ?( a+ `+ J: x
.dev = {
7 C% W7 z* o: _# v' F1 N" `+ h .platform_data = &da850_evm_tl_leds_pdata,
& z9 |7 N6 a, A- m6 C- _ .release = led_dev_release,* ]9 X3 Y U$ `. Z$ A$ i8 W; I2 I
}
" T; O0 G$ `6 m) }0 M+ S};
6 M+ N; }8 Y) P9 e% ?" _
! Y2 Y/ g5 R/ k5 J8 C+ R7 nstatic int __init led_platform_init(void)
' e) b8 q& y6 L$ ]7 H2 ]3 P{+ C- Q0 B0 V2 ~. ?2 L& p! K0 y
int ret;' z; h) O% k! w0 i
#if 0
& L5 K4 O1 D6 r6 R% z6 d ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. t0 C0 h" ~- n9 b( o! f if (ret)" q0 i( s" | Q8 b; \; a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( Z5 i/ y- h% T$ o" f" d* u "%d\n", ret);( o( Y; L: R/ |
#endif
8 K: m) B) T4 w7 o9 A ret = platform_device_register(&da850_evm_tl_leds_device);, C2 o# \& Y; `, ~- X- |
if (ret)
& L5 `+ Q9 n2 l) z' p" R9 `- _ pr_warning("Could not register som GPIO expander LEDS");
) ^7 A3 _' k6 ?, x0 t N else1 o" T/ u* D# U% K W
printk(KERN_INFO "LED register sucessful!\n");
9 ?1 x* P P, I/ D( y$ s, y# r8 W" P3 ~) s
return ret;! o, R z& F! K5 v1 _
}
; ]$ `+ O% @* x+ w# C _1 H. `* B4 |2 Q, U
static void __exit led_platform_exit(void)& G& K7 C, Q' C/ J+ M& q) L
{- o: t" R6 |/ z1 G" m* L9 C6 t* z
platform_device_unregister(&da850_evm_tl_leds_device);1 y7 H) ]/ n! \, S- J5 P& l2 a
( d3 k$ {$ H$ ]0 p$ c printk(KERN_INFO "LED unregister!\n");
W2 G7 d5 I; x, p$ x}( I8 ?5 B3 \, ?3 i5 c/ `- H) {
; n1 O: h: l4 X. A: w
module_init(led_platform_init);. P$ s' c* u- f, r- @
module_exit(led_platform_exit);: T Q( z. P2 ^2 T7 B
$ a6 `- {" V9 I$ Z. R; ^9 P5 vMODULE_DESCRIPTION("Led platform driver");/ s3 Z% y7 J# H( M
MODULE_AUTHOR("Tronlong");
, J! ~7 I9 l N- T8 D1 D' j- ^MODULE_LICENSE("GPL");
8 Y/ ^* Z" Z% k; M9 }/ V/ ~; n X- X1 |3 [' }% M
|
|