|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# N% S8 @+ G' ]0 ]! O! J# Q2 @- s
#include <linux/init.h>& y3 K, o" j* S9 }
#include <linux/module.h>$ [- A" [, N4 G6 r7 N
#include <linux/kernel.h>
9 Z% Q1 i( c6 \#include <linux/types.h>( S& U, V w: D3 h8 f1 x- W2 o f+ B
#include <linux/gpio.h>; P9 \% u3 \9 }% I
#include <linux/leds.h>
* n: [' V9 O2 S" O8 W7 r#include <linux/platform_device.h>
0 A' }" B% c8 S9 `* [' ~2 n) c
9 D$ O$ J8 X6 }4 _+ J#include <asm/mach-types.h>7 D6 P7 D2 \. d1 G# M' \
#include <asm/mach/arch.h>
7 g. E: v1 y! Z#include <mach/da8xx.h>8 j! I& J/ P. p" y7 Z* P. b
#include <mach/mux.h>
+ @# l3 T6 E3 w" ?4 E) o# W. _3 K1 r6 a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) R, K# a; G3 g: u I4 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 i' z k' `+ V! x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
q B+ A: H" A& O7 I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); f; ?! m" V: {; c9 h2 P
) V# O% s8 N9 ?: b7 W8 L/ u# v/* assign the tl som board LED-GPIOs*/
^' h" P. k, B3 ^static const short da850_evm_tl_user_led_pins[] = {
7 `( c* i: l4 I* t* o /* These pins are definition at <mach/mux.h> file */) D5 Z2 g/ N" L8 P; G! p# w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 U- p8 \: c1 q8 i" S; \$ ?/ w0 K -1! i$ @/ q* W8 @4 t7 I
};
9 [& ]. l: \1 l- c( j; c1 f; P# V( h5 q/ {! z
static struct gpio_led da850_evm_tl_leds[] = {) t% i) S9 Z. H% D% \: F
{
9 v3 ~, S1 u: Y& N3 E5 z .active_low = 0,
( m+ w4 y- \) R' S7 D3 y0 I .gpio = DA850_USER_LED0," g Z' \* L$ W$ n7 r: J
.name = "user_led0",
. J4 O& y+ _9 v) f .default_trigger = "default-on",1 ]3 P4 x2 ~( B d6 ?/ g
},
) D8 e5 A/ [7 M7 o( Y/ F {/ |5 `8 q, f3 b+ k
.active_low = 0,
, a, R. N2 u9 L& Y: Q. r7 z+ i .gpio = DA850_USER_LED1,0 M) o( w# a. r3 m: R
.name = "user_led1",
. C, t- V/ X7 y7 n .default_trigger = "default-on",
' F' f/ q# R8 N' t/ D7 X0 B },
o2 K+ n1 t! \' r {
4 F4 r% n: q3 Z2 s4 H7 O .active_low = 0,
6 q3 w4 g- Z) u! [, d: B" K .gpio = DA850_USER_LED2,
9 f. F1 ^9 Z0 R5 V .name = "user_led2",
4 b( ?; J u+ `! h7 |! c# H( e* q .default_trigger = "default-on",7 w9 q. K( g& C( n' q, E1 X
},
# j' F9 P E6 h5 u {
?, v. l* z. }' h7 h H .active_low = 0," t) s, }' Q' R+ X5 Q4 s+ L
.gpio = DA850_USER_LED3,
G H3 {6 |, ^3 N$ a0 i .name = "user_led3",
! a, n- k( @; M1 h0 Q3 f7 X1 v2 G$ y .default_trigger = "default-on",
. m& f! \ |: g. g },
2 W+ P0 s8 ~& C& T$ |. e" ]};7 g% M0 y/ G; x! \. U7 `, d
/ A. ^) T; C1 D/ `% x7 Z0 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 l, t1 j5 M% W, p/ v
.leds = da850_evm_tl_leds,
8 `% x: z2 n( N7 P0 v3 s* j .num_leds = ARRAY_SIZE(da850_evm_tl_leds), `1 T. p% p4 \: b0 a3 e$ m! A
};8 ~8 d$ C% L$ J( g2 q
2 R& _0 A/ o+ d; {
static void led_dev_release(struct device *dev)
6 k* y& E2 w: d1 C3 a! c+ S8 s2 c{3 f, T% a1 W/ i# U" h9 t0 q- v
};% y2 S1 V; T1 O0 b
+ Z* ]. d, N( b0 H% Dstatic struct platform_device da850_evm_tl_leds_device = {9 D! P6 m* d9 d+ v
.name = "leds-gpio",2 X9 E( o) X6 F% s ^
.id = 1,4 G5 l. e L1 H: ?+ j: l0 R
.dev = {
5 z( e4 S3 p, @; j .platform_data = &da850_evm_tl_leds_pdata,
# k8 `* K& F! c; A .release = led_dev_release,
( _9 X3 k7 J- @# s/ B3 F1 r }
6 n+ W' O k& g};7 D0 w2 D* r- n% [
' R3 t0 U( O Z+ S% M9 T8 [8 D7 Pstatic int __init led_platform_init(void)/ k+ }" X: U9 i
{& s) a% |8 L: j0 P y; |3 r
int ret;
8 {: V% Y5 K; G# [7 a! W) C#if 0+ T+ V `- F# J% l* G# i9 Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 W- L* L4 m* ^
if (ret)
: r1 p4 y$ k# j. I6 L6 m9 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :", j: Y i& w) z& n) `2 z
"%d\n", ret);9 r5 i u3 A; {: P0 }0 b
#endif
3 o; L" S% p4 j) G- Q ret = platform_device_register(&da850_evm_tl_leds_device);* q2 S+ T9 `4 I7 m" A
if (ret)* R( N) K4 C+ f/ v5 L$ E; P
pr_warning("Could not register som GPIO expander LEDS");) V, I5 N7 b! x) [
else
) S) J, T) [& G, T' W4 H# l0 T2 z8 o printk(KERN_INFO "LED register sucessful!\n");7 @( D1 g l' @7 o: [! H/ ~1 V
2 V' @7 e: @& Y l# A return ret;
% n( |: N. Y- o) _0 {}
A8 l7 U- `) V% g
, i! l/ P+ R6 k7 k" v$ o6 Fstatic void __exit led_platform_exit(void)* z$ M+ z* _0 f* [: V7 y: B
{
; h2 @! D/ t1 u; D$ U6 e+ j platform_device_unregister(&da850_evm_tl_leds_device);
2 G5 U7 I8 @% H# q& ^! |) V, E* J' i* t' N
printk(KERN_INFO "LED unregister!\n");
- ^; }" A7 ~: X}. F& A8 |* k/ T! X+ D- a B- G
/ z- d5 ^* b7 mmodule_init(led_platform_init);2 o: z* }/ ^4 l! Y: G
module_exit(led_platform_exit);
z6 X7 Y- c! @. @9 ~ L: T
4 z9 g/ q: y/ K9 E5 F- }MODULE_DESCRIPTION("Led platform driver");4 _4 j* l. q2 H
MODULE_AUTHOR("Tronlong");
) H. Z$ ] [8 `" B! C# \MODULE_LICENSE("GPL");) p' t* M) d F
2 Y) T) z5 o5 @
|
|