|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
}5 x) l) g7 U. P% i#include <linux/init.h>
8 j- `0 D: S0 D- f2 [4 j* k; @. U) ~#include <linux/module.h>
! B1 q' h0 B4 k- L; e8 n#include <linux/kernel.h>
( L& q6 ? [5 o/ d# {: P#include <linux/types.h>% U7 l' v4 j) s& b6 P f+ k. \$ y
#include <linux/gpio.h>
! V8 O7 \8 k6 f2 H; v#include <linux/leds.h>3 _" l# R5 K# L5 g3 C3 v! W
#include <linux/platform_device.h>
" C) h7 t0 S7 i, N! \
, t1 M! a0 m) z# l# E# O9 ~#include <asm/mach-types.h>
! E4 b1 s; k! S& R5 F$ y' [% F#include <asm/mach/arch.h>
' Z, F/ p, X( k( p/ I#include <mach/da8xx.h>- M# H, U" P% P( B( W% w
#include <mach/mux.h>3 P5 Y* M) Q1 v% n! R5 ?
) x' a: O- w# `( [) w) n) e7 O" t- r2 u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) Q; j/ V' s) f5 o/ e, c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) T. S% ~1 J( s8 D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 J( z8 T; q g5 S4 g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ A1 i& S! l+ b! K' q( [4 S8 m
/ L9 C8 D" H; j1 d" N
/* assign the tl som board LED-GPIOs*/
9 Z. b6 \7 Q0 M: K2 G' N- ~static const short da850_evm_tl_user_led_pins[] = {
' Z/ z3 `% o+ R! d: w) B /* These pins are definition at <mach/mux.h> file *// k% X/ M p! ~; u( N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 H: G- {, ~8 ]6 {
-1
]5 n! N0 n7 }# T1 O' Z/ ~};. D. V" I& }2 i7 X/ }* f% C
0 l6 V9 q) E. @5 j8 ~; b. w' Z
static struct gpio_led da850_evm_tl_leds[] = {
" I* u' U5 ~/ p5 V {) a2 k$ q4 _1 [8 F9 J+ H, f! q0 L% t
.active_low = 0,4 R: c) R8 u" `
.gpio = DA850_USER_LED0," F7 y7 M# m8 P' H# f+ k: N
.name = "user_led0",, y. M) T0 `8 x8 ? P5 q
.default_trigger = "default-on",, l# H8 c5 \' H" i" x. E, d! k
},
1 H6 P$ I/ F1 r' I7 o( x; H8 P& P {' O1 i6 H! V) L; i+ N2 f t
.active_low = 0,. K9 G" c# K9 U% s' T
.gpio = DA850_USER_LED1,1 v' H% I: O, S2 u8 n( t
.name = "user_led1",4 O. d. F/ q/ O$ I# D, o, a
.default_trigger = "default-on",
( ]6 T1 Z7 K. B },: a3 E% U% t) }. K
{ A( h0 d2 z; r
.active_low = 0,* e- F3 n( w: W3 V+ ]( Q7 q3 @5 `
.gpio = DA850_USER_LED2,. p5 @* |5 O2 u) a; H( S
.name = "user_led2",, c/ Z5 d) y* i- r
.default_trigger = "default-on",. r4 O( I8 F8 A4 O" Q! R$ \
}, S/ x! |: O6 M7 Z* S
{
+ O7 c6 S+ s( Z$ T4 h5 V% k .active_low = 0,! x. n+ _! I! ~4 M1 x8 [" ]
.gpio = DA850_USER_LED3,
& m2 Q' r& H4 T: u .name = "user_led3",
( r' j9 |6 h/ @! x% z* e .default_trigger = "default-on",
8 K& g+ T2 {) s },
. s1 S# l! h7 Y7 j" Q" G};2 y5 y1 f3 Z! @2 E, M
: x- T( K, s c) Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& J5 z- u8 f: w$ d3 n .leds = da850_evm_tl_leds,' h1 T: _* @- M; i# H/ D* d( L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, ^5 `" s$ W- i* w};6 G* \ R; {, L' p9 V
+ I! M. W9 Z6 a" D' ^- Mstatic void led_dev_release(struct device *dev)) K* S2 I4 b+ S( L: e. m' M1 @
{& _# e$ V2 |, a- u
};1 F+ y- d- x! b
$ @1 q% T3 v$ |) X
static struct platform_device da850_evm_tl_leds_device = {9 g& b$ J. k Q" t. ]1 r+ v+ Q
.name = "leds-gpio",* {( t' |& S" ~+ w! t
.id = 1,/ q r2 u9 ]8 L. g( j8 `
.dev = {
Q/ t5 \ D& F; W3 `# c .platform_data = &da850_evm_tl_leds_pdata,
2 t/ t2 P/ |# u! O" T .release = led_dev_release,. J; o M1 \7 @4 O2 U4 S
} |8 x. ^% Y9 p& U- m2 V+ W& P
};
& O2 Y- ~5 A1 D8 s0 J) ~ }$ Z/ @8 Q( ]9 A
static int __init led_platform_init(void)1 J* k$ R1 @* e# W$ o/ B& Z' x
{' B8 ~1 h4 J5 u4 o. _
int ret;/ g& D9 h. t* I: N
#if 0- v- h/ q9 r4 g$ ]% X) m: r3 N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. s, o3 f9 [/ ]2 r* ^; j# l if (ret)
2 p+ I2 J L: `! o) e3 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ p. c9 H( p. b "%d\n", ret);
/ ]7 t8 K0 W e+ Q2 a#endif( s% r) U4 b# y" k* S! A6 a+ z
ret = platform_device_register(&da850_evm_tl_leds_device);
4 d: @' ~( v6 ] if (ret)
+ ^/ q9 o. J% ?! x pr_warning("Could not register som GPIO expander LEDS");
" ~6 ]: a- u$ c1 s else( V: f$ g. b' ^
printk(KERN_INFO "LED register sucessful!\n");& d& W- g7 C$ X+ k! k5 b
* U N3 r8 z$ [# g
return ret;9 i6 d7 b4 {. b: h3 w% D
}8 B% a- Y( ^ ~% E
1 T4 B5 t5 h) m8 J" }0 ystatic void __exit led_platform_exit(void)! f( g3 y! v- I( \- A
{* P( d0 t: W, l0 p
platform_device_unregister(&da850_evm_tl_leds_device);
3 q& C$ W" g7 l% } C6 s# @0 d: D" U% b5 `, I. ]7 H$ H4 M
printk(KERN_INFO "LED unregister!\n");
( _! _ E" q$ N) j}
; W- q( ^0 Z0 B/ c% B# D$ h
5 m& C; C$ {: t( P* L# Rmodule_init(led_platform_init);: l% i4 D; {+ A6 s5 B3 N w
module_exit(led_platform_exit); F, ` J+ Z$ s0 `' s/ A* v- \
5 s* D! B0 W" J0 h7 ]2 U9 e
MODULE_DESCRIPTION("Led platform driver");
9 e, L- h$ b4 IMODULE_AUTHOR("Tronlong");
* T1 `: e, U. |& C2 iMODULE_LICENSE("GPL");
7 R% [$ N* L) Q S* A# h) @ e# A1 d
|
|