|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 N9 e/ m v( L& W# `0 }#include <linux/init.h>' t+ {$ V* i2 L8 ]+ j; I5 m
#include <linux/module.h>" N" h g# Q7 r h9 p% D' _2 Z, [
#include <linux/kernel.h>2 Y% P' L+ u& r8 v5 b$ e7 @
#include <linux/types.h>3 C$ F+ V- [( L
#include <linux/gpio.h>* X8 O7 } K ]( A; ]
#include <linux/leds.h>
- d& i" F2 C$ f! T2 }" n#include <linux/platform_device.h>& R T% o6 t8 L+ [9 [
6 ^& h5 P1 h& C. t/ z4 S g#include <asm/mach-types.h>2 d* |2 m9 B8 ^$ I2 h8 H
#include <asm/mach/arch.h>
) X& K' F1 U; j" d4 p, G#include <mach/da8xx.h>
9 R1 g) V& t$ D* U* @+ i2 V K#include <mach/mux.h>% F' o4 T$ r3 e0 _
7 X: J$ D! Q2 X" b8 E9 r9 U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 H, U6 s: H5 |% N2 B- M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! B1 c# h3 e# _( z- T& u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* {/ S# V- G H0 h$ s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 |! {9 K3 p5 f4 N" A5 w8 m8 r% e% ~
/* assign the tl som board LED-GPIOs*/+ ]% B3 L! C5 h. y
static const short da850_evm_tl_user_led_pins[] = {
* |6 ]2 ]7 w0 n4 D: Y B+ f /* These pins are definition at <mach/mux.h> file */' H; X9 O' f4 Y4 Q2 I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 V9 H* Z8 m. G, \ -1
7 w. X0 y7 S/ U) @, W# D};
1 l2 Y8 Z! e8 ?" Z( b$ J- H' E" e1 S# ]4 X* N2 I% }; C
static struct gpio_led da850_evm_tl_leds[] = {6 r& j- O2 R4 G4 N
{( ]! w+ J& u& z2 M8 z. D# S0 Z
.active_low = 0,
: n6 p# K- O, y C .gpio = DA850_USER_LED0,* R8 Z* w! j& x* ` d( L
.name = "user_led0",/ o3 {, J" p- p% V$ r/ D" J
.default_trigger = "default-on",. G7 {" y- o$ M. V
},
6 V$ f5 y8 E# P: i# l& q$ t5 W% B {+ c: \8 ~7 I. {3 o3 s
.active_low = 0,& [5 _' u; ?# s% [: U- q1 {- S% o
.gpio = DA850_USER_LED1,/ n+ i" t# A' F8 U) _- Y; }. O: l j
.name = "user_led1",
- s( `/ f+ r, p# t' }6 D .default_trigger = "default-on"," h6 M' b* O9 S" c' p
},
0 s Z& z. c) ^0 B3 O: G6 v {
0 H9 r; D+ A, I. M) w8 \ .active_low = 0,
w8 H$ u+ H, @ s/ ?, \ .gpio = DA850_USER_LED2, a7 }+ i2 n: b. o8 R
.name = "user_led2",
* T% F3 e& V$ a9 M* y+ G- Q- Y; q2 @ .default_trigger = "default-on",- x& \9 Y ]9 j& q- ]8 D' h% d
},1 N" P% o2 M' Z, q4 s
{
, J+ p z1 ^0 W; h$ z: u& \ .active_low = 0,! i E: P h3 s% b+ C) @4 Z
.gpio = DA850_USER_LED3,. a, K' L* `- z9 G4 V
.name = "user_led3",
2 w4 O. a: V( r .default_trigger = "default-on",' d) I& a3 Z* A a3 K3 \8 B5 r, Z
},( i6 I! G/ s% O: p F+ W2 _, y% O
};
, v$ ?5 }" d" l4 k; G& x
/ p* t) S% L9 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 N9 @3 ]6 P* j1 ]9 l2 W
.leds = da850_evm_tl_leds,' `' A. T0 n' h' z% b7 T% o% h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 d4 i! M. {- h' l" y# v. d
};
" I6 h' h, S" A: y; [- D9 K( z R" @+ U4 R2 ]
static void led_dev_release(struct device *dev)
: W- I: z. i5 F0 l2 R5 h% f{
; z5 }/ E- y, _9 F9 A# o};8 ~' }: u4 a$ p {! l
& f8 _( `1 O8 G% t+ p- x6 S/ f' F$ c( Q" l
static struct platform_device da850_evm_tl_leds_device = {9 R* L; _* r( A" Y
.name = "leds-gpio",
4 Q+ d* V. w9 ~& S; ]. O .id = 1,
n3 z1 g" y1 X6 Y" l! j- b4 G .dev = {
6 }/ `, N9 D9 \2 u& B .platform_data = &da850_evm_tl_leds_pdata,. R6 \* N1 s% T: H
.release = led_dev_release,
( W. l. ~* n$ I% F; r; O }+ G% z3 @# K7 c& J
};
' \2 U8 h5 `; a$ C8 \5 Q
! d4 Q J% c7 Z! h* q6 Y3 X3 o3 `7 @static int __init led_platform_init(void)
3 L! R: R) V/ o5 V{5 E9 c* c* {/ ~8 | n
int ret;2 R! L9 U M5 r" d
#if 03 b. t. _2 f: L/ R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 u# K2 u% \0 V6 u/ W if (ret): a& }- s$ P: w) z+ ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ C3 c0 |. C& I0 m/ C/ i9 q- G/ ^ "%d\n", ret);
- H& k! s* \, j, G#endif4 s" E% w$ d; {
ret = platform_device_register(&da850_evm_tl_leds_device);
, J4 k& N% J! q' u if (ret)
5 k3 W9 O& k6 d" L1 E0 U( @! ?( w pr_warning("Could not register som GPIO expander LEDS");
( \7 w3 f8 ~! y else
3 M5 ~+ R7 X' |* ` printk(KERN_INFO "LED register sucessful!\n");1 C9 @" {( a% s/ Q& }. s
4 W0 a' s/ a2 X2 s& y
return ret;+ v. u* F; r6 E. x7 E- o
}! } c: I4 h$ r \8 \
0 O) y, V1 S/ D# _" cstatic void __exit led_platform_exit(void)
+ q% e$ h/ |9 c( @* }{
! h( z8 D) e: |* x platform_device_unregister(&da850_evm_tl_leds_device);4 \' z+ p" p3 H' _% g" {# F# ]
) F A: s3 f# w, S$ Y& E5 u& ~ printk(KERN_INFO "LED unregister!\n");2 Q4 o& X8 U2 F
}
7 x" W- a: F1 x* q7 ^$ M" ^$ E! f N/ Y* i
module_init(led_platform_init);
5 l; u) l/ X' o5 H* Cmodule_exit(led_platform_exit);
" y& n2 L3 m9 u( B& k& a/ K! y+ \1 Q
5 L9 S0 r- E$ Y( X7 v+ t# X& LMODULE_DESCRIPTION("Led platform driver");: W/ a8 W5 E! r) o% ]
MODULE_AUTHOR("Tronlong");
$ l' m! b3 k! YMODULE_LICENSE("GPL");
* U* a0 G+ k' V+ E* ?- x7 x" ], m0 b0 t c
|
|