|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* L/ }" K! [+ i
#include <linux/init.h>
$ M# D+ T. r; s& g. Q! `& e9 y3 m# ^" y#include <linux/module.h>
- V; j. w4 X' c. B#include <linux/kernel.h> J( r, R4 h$ v" C, V% o1 \: C' p
#include <linux/types.h>
7 W# N2 ]+ N! V8 x' n6 f" F' o#include <linux/gpio.h>7 @7 N3 S, R5 U: ~3 d
#include <linux/leds.h>
+ g. m# q6 `) b3 C1 w; d#include <linux/platform_device.h>
* D% [( z8 U, H0 Y% B) U
+ x" p5 @: b* \* q' ], J1 G#include <asm/mach-types.h>' W, T0 B! [4 v2 t- r3 p& G# L
#include <asm/mach/arch.h>9 g7 i7 y8 d' T. g& }
#include <mach/da8xx.h>
6 F$ ?* \# W3 ^: e' G: b#include <mach/mux.h>
v. _0 A* [- V) Y# r; [
- ^' ^; m+ W/ B1 u' Q8 j8 j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 I. z: A# y! F" z# n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 I5 y1 a0 I! F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 q3 X* T' n7 g" O1 ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 L) X" q1 D8 u. n
) {; f3 f: U# }$ K
/* assign the tl som board LED-GPIOs*/
0 ] U/ m. G9 k$ N* `static const short da850_evm_tl_user_led_pins[] = {
; g$ q' T5 {1 i& c/ u% O5 q0 \. ` /* These pins are definition at <mach/mux.h> file */ T5 v1 g8 Z+ k9 |8 L' G; t5 C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, S# {/ ^; I. s -14 [* z5 ]1 d7 Q
};0 q8 ]9 S( @- d X" B
- V4 ?" J: o0 R; ]) M
static struct gpio_led da850_evm_tl_leds[] = {
1 e2 t) |- L6 {, z+ `% w: K+ g {( u# c( n H8 n9 U
.active_low = 0,. C& M7 @* M8 J: p; l, r- ^* s8 T- x2 s
.gpio = DA850_USER_LED0,
! i- ?- ]# i& V' ]. ]( d, @ .name = "user_led0",, n8 W; |! o# w6 H$ ~
.default_trigger = "default-on",+ K! D9 U/ O) y% ?
},. i9 _9 `, ]8 D/ a
{1 N; R& `% h. q9 r
.active_low = 0,
9 H! ?! p: W6 w5 q0 X' |* e .gpio = DA850_USER_LED1,
$ ], I# I: _ L, j& y" _ .name = "user_led1",
/ v* F! T( |+ b6 E. h& F .default_trigger = "default-on",& W4 U% q1 |( W, ~' ^) E( R' J) H: Y
},
0 R2 `% f) m$ M# ^ {9 o- o3 t: M; Z m5 a1 i$ g4 s
.active_low = 0,/ z# S. V/ T4 b0 U: J5 J
.gpio = DA850_USER_LED2,
1 Q) {) {* g" T% w .name = "user_led2",
6 V4 y0 s. M2 Z3 T .default_trigger = "default-on",* Z. o$ D; q S
},5 H# D& j% t0 }
{
4 X; F+ G' o5 Y5 R( U+ F .active_low = 0,3 e9 h/ D. M) ^- I
.gpio = DA850_USER_LED3,( R) E) n, t- b5 [7 ?& @! {$ t
.name = "user_led3",; J" S9 N/ w4 _( h! H4 _" b; p
.default_trigger = "default-on",3 v: D! v' S) K* x
},
( J; E6 e! Q9 W# T, D# c};
0 ~/ h9 s; H# G3 D8 e
! `: b" | m" v8 _* b# \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- A; P9 m) g9 Z" v .leds = da850_evm_tl_leds,3 ~3 H7 ` K ^+ _4 d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& h6 ?8 e6 b) ?' s9 }};, r1 A) s+ }! Z3 e( S7 k4 B' ^
2 ]: \7 G1 T, q3 u' t
static void led_dev_release(struct device *dev)
+ l* q0 Y; L1 |* j8 {* a{
2 s! s/ N% R) f @, G8 f};
, H" D4 [6 k# a& z3 ^+ `# ~1 }% s8 P( M
static struct platform_device da850_evm_tl_leds_device = {+ E' E. ], w- O6 `" G; s) `3 Z8 D
.name = "leds-gpio",; n! e4 X. X1 V
.id = 1,
& }$ R8 R4 V4 ?8 {# H .dev = {& _3 O+ b/ ?( W( T+ s0 _2 u- c8 _
.platform_data = &da850_evm_tl_leds_pdata,
# `; V- ^4 T' N: Z; a" _ .release = led_dev_release,
& ?7 l+ Y2 ?. w" e# [" Y, j }
/ H- z6 |0 {9 B- o};1 j8 Q/ g6 c) c# Q6 u- u5 X- H
! k& C2 W) ^4 M4 \
static int __init led_platform_init(void)& \" s! ?. O' S
{
4 r' z, U% J8 }4 I: b4 F: b% [! f int ret;
; m9 y* g7 |, X' y* ~, T! P5 h% m#if 0
4 p5 K% y7 i \5 n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 y+ m$ s" J1 K" Z& L if (ret)
: j! p; v7 H+ B- k! w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% j8 k" r0 U4 \' w: O3 R "%d\n", ret);
W4 E3 f) `4 t6 O#endif; T7 S9 A9 @* }* d4 C
ret = platform_device_register(&da850_evm_tl_leds_device);
5 B X6 s6 x8 e* k2 W% J+ s if (ret)
8 K. x- ~7 C; [3 t; w% s3 m pr_warning("Could not register som GPIO expander LEDS");
8 a, k# m% r* [, m else$ e/ e. L6 k$ \9 K" L
printk(KERN_INFO "LED register sucessful!\n");5 o( }* Q, S1 F5 Y$ u
7 `5 ~. ]& d! e3 r% X
return ret;
6 X' D- V% N9 |) X4 O}
' ]6 q' b( A$ ]. Y; ]3 ^: N) m: b5 T; p& u# K3 Q g6 k
static void __exit led_platform_exit(void)
' E U X# k5 j& e2 N4 ^* a{
5 V U3 y5 _) G* P" P' b% n platform_device_unregister(&da850_evm_tl_leds_device);
. Y+ c3 I0 Q, R) d- R ^! V3 b5 i
0 x! E, w+ E& C9 O* m+ e" D printk(KERN_INFO "LED unregister!\n");2 I @, a! d* Z7 E% u$ x+ E
}) d. h6 M S( E4 d/ `
' b @, [. f+ E1 x% p3 g
module_init(led_platform_init);+ W- k; U$ d0 s, L
module_exit(led_platform_exit);7 D. J- ?$ e5 N% b
" q2 \$ k! r* F! u* J: P& o1 BMODULE_DESCRIPTION("Led platform driver");( D* l% k8 u" H$ F: u4 C' Y
MODULE_AUTHOR("Tronlong");
8 \, \: w) `- @" n+ G7 Q6 iMODULE_LICENSE("GPL");
/ w& W: D) k* o4 n9 b* }
- j! ~/ I' `9 D4 e! n3 o |
|