|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# s/ s2 p8 P6 o. X& C7 ~' H#include <linux/init.h>
3 S3 p# a' Q3 j0 {#include <linux/module.h>
2 w0 w9 N" m! r, W; `#include <linux/kernel.h>
1 g& x/ |* n f#include <linux/types.h>
, i/ t! \: j) Z0 L0 ^. {# P#include <linux/gpio.h>( i$ l, a- } s9 a, r! r# P
#include <linux/leds.h>' W# W: S# f& b, ]* @# W# ~- a
#include <linux/platform_device.h>! L7 T6 y- y- c' E( k
( @! I% h, s/ \" u* T8 l$ {#include <asm/mach-types.h>
: x+ I! l+ ~8 \9 E6 [3 f#include <asm/mach/arch.h>
9 x+ ?9 D( U; i, |/ D6 }#include <mach/da8xx.h>
0 q+ y& t5 I9 l8 l3 `. }+ |8 v#include <mach/mux.h>
" N. b: K+ h; R1 Q$ s# e4 d
/ d; o2 d& x% \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& B' s* v6 W4 N( r0 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 d! S" {5 D7 T/ K/ P9 q/ R* l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) ]& p( \% Z0 j5 B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% _ \8 I/ @" O; X2 } {# }" C* { O' ?
/* assign the tl som board LED-GPIOs*/
\% J- I! N: N8 E6 ostatic const short da850_evm_tl_user_led_pins[] = {
, P$ c% ~- j3 U9 q0 S2 B5 x* Y /* These pins are definition at <mach/mux.h> file */
6 L! `, X- | _ x {) J' W% ^: s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ R: r" R4 u/ O7 q0 _$ n4 b
-1
* R- G4 J, B- t Z, l8 U# Q1 B0 M' [};
9 j7 D/ v% S" N, i( O) p) S
+ o6 x! L1 }$ G+ e" ^# J2 Hstatic struct gpio_led da850_evm_tl_leds[] = {+ V. f9 m% Z* |9 E# y0 M
{
$ ?. o# C: p% ? _; }- o6 C .active_low = 0,
/ M" {3 [3 Q- K/ m) F8 X7 L& q .gpio = DA850_USER_LED0,
5 t% M% j0 b9 s" ^( W6 c .name = "user_led0",
3 d- Y5 V* ]4 B- n. T .default_trigger = "default-on",; j! q/ v0 z2 A% i- \0 b- a
}, i T! i7 w. ^0 _! B3 g
{
8 p: O9 l, x6 z" K* b: L .active_low = 0,% S) Z! ?* ~$ b: a1 t
.gpio = DA850_USER_LED1,9 s) N' t( @- o) D
.name = "user_led1",
3 Y( t& s9 ~& t2 t' N: t& M8 w .default_trigger = "default-on",
+ f5 v3 C( O. L4 } },
* |# D2 u# g; e- Y+ U2 G2 f {
" K+ Y) e8 f9 f, K* I .active_low = 0,& V- r+ C7 K9 ` c( S8 k
.gpio = DA850_USER_LED2,, ]2 s) M& `% D, e* m
.name = "user_led2",
0 p/ A, `' u; I' r% U .default_trigger = "default-on",+ h$ r# E0 _% O# @- k
},2 z, P9 }, ]0 C0 a8 ^! i3 s
{
4 A; v; E: z& W5 `) j .active_low = 0,7 t% Q$ o/ L1 W2 K4 L9 e, w
.gpio = DA850_USER_LED3,
! A. @; P6 t( o. r6 Z) a .name = "user_led3",
/ F7 r0 Z! o+ K+ w- Q .default_trigger = "default-on",
5 J8 ~6 F( Q; ]7 I7 h3 {" Z },, k1 i& k2 k9 a; t# Z
};
* e9 P4 W( T6 M9 u! ^& h$ P, i. f2 b9 I& h8 l# U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 K: r: d; C! B- h
.leds = da850_evm_tl_leds,$ E g1 s3 X8 o& d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ X% `) A' M3 ^) ?' Z: I}; e. R( C5 T1 U+ W. s- ^
) Y4 H8 B* H. d- [7 \
static void led_dev_release(struct device *dev)
0 `5 S* o# ^% ?' q8 f{
& ^( `) C, g3 z. m& @% S, ?/ s9 p};
& l/ W. [4 L2 `( l3 A# \( q. |) n0 I6 Y6 I
( B! B; q3 C) A! ~3 _% O; Qstatic struct platform_device da850_evm_tl_leds_device = {! n8 o# M# ]8 `3 m3 j! f
.name = "leds-gpio",
: M: ]$ o! q+ ^. g# b9 A& Z .id = 1,9 @; W0 H. z# L. `
.dev = {
" G& ?" L- i0 o, U8 C/ I0 B0 R .platform_data = &da850_evm_tl_leds_pdata,/ i8 P; s; N- \+ [+ Y7 [ d: Q$ H
.release = led_dev_release,
/ W& m' Y! }" I G% g& B }
4 [, f" j$ _4 L. e2 U};7 `5 B0 b8 D0 A
; E" V8 J9 |. j1 Cstatic int __init led_platform_init(void)
4 y# Q+ h5 i! v8 n& t+ o- q- d{& ?% X7 t- j0 k! N3 ]
int ret;
( q, T% L" p( J: d) l#if 0
- p( N4 i* ?: x, _4 C" f0 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# P+ Q' R8 ?/ O
if (ret)+ t9 \7 R/ w* \, P% U! R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) A! r/ t6 O0 Q& x; U "%d\n", ret);
+ \. W6 T* m2 \" F$ P' l1 C#endif
! x2 _5 k$ k2 Y9 B2 |4 W2 Q( m ret = platform_device_register(&da850_evm_tl_leds_device);
- ]( f. E* M ~+ h# R5 r+ I if (ret)
: J& F) Y, d' |. b( j% I pr_warning("Could not register som GPIO expander LEDS");* W) v7 Y4 z1 l# I& f2 S
else" u( m2 J! B4 L+ g9 X' I
printk(KERN_INFO "LED register sucessful!\n");% V- e5 J; x& s/ y0 M, w
3 P! z9 y% M6 z( \, e1 t
return ret;* ^' B7 X. B* [. P
}! p5 |/ S* \) k, B* R
& D3 C' P4 t7 i6 B% ^/ [# x7 U& \
static void __exit led_platform_exit(void)
1 x8 n e+ t: n/ M3 L3 X ^) b{
2 M8 o; b% M# a" `0 B7 U3 y. `8 I platform_device_unregister(&da850_evm_tl_leds_device);
4 ?2 v, A- l: P$ P7 |1 O0 a6 [& H; J M" @4 u# D" Z1 S( j" _
printk(KERN_INFO "LED unregister!\n");
/ r4 {- z- P7 [$ _2 z: k}
' i& [/ n) _- |2 u Z$ R: H) x& m. t; r! ?$ y% _) H
module_init(led_platform_init);* H% y) I' J9 z. S- X; \ U+ w0 x
module_exit(led_platform_exit);3 C, f2 L9 {, }8 R$ Q; `* F
/ j' u- [( p$ s s2 g( A
MODULE_DESCRIPTION("Led platform driver");$ z7 q* o, n) F) S Y4 s
MODULE_AUTHOR("Tronlong");9 K' i' H! M- g: y! r
MODULE_LICENSE("GPL");2 k8 d% i/ \5 {: a
0 z4 j+ Q" g, @9 w% w" P- P: N |
|