|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: B7 s% Y; H X
#include <linux/init.h>
( _$ ~' y/ C' w# Y# h; n% n6 V#include <linux/module.h>
2 X- ?% U4 J5 b; l, Y1 e2 y#include <linux/kernel.h>- Q9 g' z5 ^0 v' t7 w
#include <linux/types.h># k5 l3 Z. t. X6 n% Z' w# R( ]
#include <linux/gpio.h>
8 v0 b. m) h0 o5 h0 V#include <linux/leds.h>2 P/ h" n( M- M- N
#include <linux/platform_device.h>% D, u C) R( |. e: j5 c
& d4 E% U; [6 Q4 H7 X1 p8 e
#include <asm/mach-types.h>
* _/ c$ I. _& x7 G3 G* x7 s* V g#include <asm/mach/arch.h>
! z6 O, {6 U/ G0 V#include <mach/da8xx.h>/ `; u+ F1 j; A d, O
#include <mach/mux.h>
( U$ Z9 o% U8 L& ?* Z% P
# Z6 n7 G/ F1 v i/ r2 S9 l' t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); s4 L, M7 Q" ^" E$ t5 Z6 e& y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
\- _3 Y- N4 B2 o" M) T5 T4 W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% r. a9 M: p2 j( J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 D) V* p9 k+ M) w
) e4 x9 ?* W' ?/ u/* assign the tl som board LED-GPIOs*/2 {9 j9 o! B& [- o% `
static const short da850_evm_tl_user_led_pins[] = {
m8 k& z6 _# X4 g* U# Q2 E /* These pins are definition at <mach/mux.h> file */
+ y4 i$ d+ A" P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ \8 j, x3 Y: c- T -1
( K& v8 @. x6 h% ?+ n4 a' V};1 Q; |' K* g2 F. l/ f3 X9 a
+ U; r: Y6 j: G3 \. z# }static struct gpio_led da850_evm_tl_leds[] = {( n# a# ?; `1 V' D
{
0 j8 u/ M1 Y+ Q' C' @- W- |2 w. B .active_low = 0,1 F R& u. T1 X: ^# }9 x. c
.gpio = DA850_USER_LED0,' r" q) S! y) j1 w0 Q$ R
.name = "user_led0",/ z3 Z* x7 X; K
.default_trigger = "default-on",
! c9 m4 e- j. z- |* k4 X },
/ q" z7 u! ?. k6 X+ j {! ^, ^3 w5 a/ D* A9 l, A5 a
.active_low = 0,
. [$ b0 V% ]6 s; q .gpio = DA850_USER_LED1,
( m. |4 i, f4 s# b% i .name = "user_led1",
3 b2 [& |7 G1 i0 A% ` .default_trigger = "default-on",
6 N8 I8 Q) s. l/ v0 w( M6 W },$ @0 c; x* q2 U4 R4 ^5 C
{# b6 ~, S: [# h; w# U3 o
.active_low = 0,
$ k* c* W* W% ]( n- f( f2 Z .gpio = DA850_USER_LED2,
" o. |9 o& @/ ^7 ?1 b .name = "user_led2",, `! ~) W. E" G3 }$ V
.default_trigger = "default-on",
# D( N( j Y) ?' e! J+ }$ ? },' \2 T M) U( S
{1 d( @$ [. |" X- Q/ u
.active_low = 0,+ m" C/ S- Q7 Z, |+ k: c
.gpio = DA850_USER_LED3,0 i! E) M7 n5 b4 d: [' ^" P
.name = "user_led3",- b* i, F4 j! Y
.default_trigger = "default-on",
9 A7 o1 P; o& R R1 f },4 C" N" X0 u7 K- _
};7 j3 K( h$ h: j, X, s8 [& \' M
' V: b( a- `% _% s2 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ j7 b, h/ R* J y1 ]" |( j .leds = da850_evm_tl_leds,# N% F: s4 S E) o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ |. j& O5 Q0 \8 d. k1 j
};+ X* I- ^ F5 I9 g, j/ B/ e; F( @$ [
) d: x+ W! u9 d9 w: }" p; q
static void led_dev_release(struct device *dev)
, @, [. C$ m K+ ?: t$ x{
; I2 f0 l% c5 X};) B/ Y2 C7 W% H. j" R" r4 M
3 n- u; B9 v( j9 Z" h" E: X, h% t
static struct platform_device da850_evm_tl_leds_device = {4 L4 ?" D; M$ U5 _- L
.name = "leds-gpio",) `) l" W+ t/ b8 l: j
.id = 1,' `$ a2 c6 [/ S, }2 V. z6 v# Y& X
.dev = {2 j1 V& e+ s" @5 t
.platform_data = &da850_evm_tl_leds_pdata,
% x( U" {. |3 s6 C( X6 z K .release = led_dev_release, v2 g5 \. u, v3 \3 T5 Z& [
}
; X* ?9 ^8 U1 P% D# D};
3 I+ Y# o; H' S# Q) L* o+ q. y9 ?$ L% `0 J5 L
static int __init led_platform_init(void)
2 N7 a) w- P9 T% T1 W+ v{
, V; y% l; b) k- ?7 w) M int ret;2 Z+ C# Q/ @& V
#if 0
( i3 o0 K" o1 V1 I( H( ~0 q1 ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 {; V& |" Z# B# {7 C1 U
if (ret)* P' ]- A) n# \7 x/ w! {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- W: K6 j) q9 E; g$ f
"%d\n", ret); X T: W, w M$ i7 x! ? }
#endif' @' a% Z$ t/ J0 T& N! T) U
ret = platform_device_register(&da850_evm_tl_leds_device);
! U5 t3 k6 s# a% w% I) r if (ret)2 P/ P' F3 V3 Z/ d
pr_warning("Could not register som GPIO expander LEDS");
9 ~9 ?. X# R9 G6 b5 J# b2 g2 @. u else5 ?1 n% y; A# `. V' q% `; O
printk(KERN_INFO "LED register sucessful!\n");
: n+ K% M2 `8 J* a+ [
4 I6 ]" c0 }* [3 D return ret;
6 B/ ]! k8 }9 }' S# b}! o4 \' z7 _* R* s! V: q' p
; a( p" d' S4 U0 F! O; m& nstatic void __exit led_platform_exit(void)
0 m2 N) ^: L& R{# {6 {% b. O- Z) A3 f
platform_device_unregister(&da850_evm_tl_leds_device);
# z1 [( o! i" M/ k/ f7 d& s+ v" L6 y0 q9 P" |4 d
printk(KERN_INFO "LED unregister!\n");
* D J# J! J9 a e! y+ y}, j) t- x2 Y1 D. J8 m0 n! i/ U
4 K! r+ u! K0 k# E/ L3 G0 P5 b$ N Jmodule_init(led_platform_init);
7 i6 |# @. j" ?9 \" |" Qmodule_exit(led_platform_exit);
$ L, z: v& [& O: F3 q, ^5 O' Q& u3 w0 }
MODULE_DESCRIPTION("Led platform driver");; c2 G1 a- W0 J* t5 d0 d E2 L
MODULE_AUTHOR("Tronlong");
/ s2 A+ e! n" g' y7 gMODULE_LICENSE("GPL");) F8 {- y& p) l5 Q2 M& f: R) I
, n" q+ H; M4 \9 s
|
|